|
|
@@ -1,6 +1,5 @@
|
|
|
<template>
|
|
|
<div>
|
|
|
-
|
|
|
<layout>
|
|
|
<layout-header>
|
|
|
<!-- 按钮 -->
|
|
|
@@ -44,16 +43,17 @@
|
|
|
<el-dialog
|
|
|
v-model="dialogFormVisible"
|
|
|
:before-close="closeDialog"
|
|
|
- title="计件工计时单维护"
|
|
|
+ :title="type === 'add' ? '新增' : '修改'"
|
|
|
destroy-on-close
|
|
|
width="800px"
|
|
|
>
|
|
|
<!-- <el-scrollbar height="500px"> -->
|
|
|
<el-form
|
|
|
+ id="detail-form"
|
|
|
ref="elFormRef"
|
|
|
:model="detailData"
|
|
|
label-position="left"
|
|
|
- :rules="rule"
|
|
|
+ @keyup="moveFocus"
|
|
|
>
|
|
|
|
|
|
<!-- 日期 -->
|
|
|
@@ -64,7 +64,6 @@
|
|
|
>
|
|
|
<el-input
|
|
|
v-model="detailData.wgjs_rq"
|
|
|
- :clearable="true"
|
|
|
style="width: 100px;"
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
@@ -97,32 +96,43 @@
|
|
|
<el-col :span="3">
|
|
|
<el-input
|
|
|
v-model="detailData.wgjs_bh1"
|
|
|
- :clearable="true"
|
|
|
+ :formatter="val => val.toUpperCase()"
|
|
|
/>
|
|
|
</el-col>
|
|
|
<el-col :span="3">
|
|
|
<el-input
|
|
|
v-model="detailData.name1"
|
|
|
- :clearable="true"
|
|
|
+ readonly
|
|
|
/>
|
|
|
</el-col>
|
|
|
<el-col :span="3">
|
|
|
<el-input
|
|
|
v-model="detailData.wgjs_js1"
|
|
|
- :clearable="true"
|
|
|
/>
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
|
<el-input
|
|
|
v-model="detailData.wgjs_yy1"
|
|
|
- :clearable="true"
|
|
|
/>
|
|
|
</el-col>
|
|
|
<el-col :span="3">
|
|
|
- <el-input
|
|
|
+ <!-- <el-input
|
|
|
v-model="detailData.wgjs_冲定额1"
|
|
|
- :clearable="true"
|
|
|
- />
|
|
|
+
|
|
|
+ /> -->
|
|
|
+ <el-select
|
|
|
+ v-model="detailData.wgjs_冲定额1"
|
|
|
+ placeholder=" "
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ label=""
|
|
|
+ value=""
|
|
|
+ />
|
|
|
+ <el-option
|
|
|
+ label="是"
|
|
|
+ value="是"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
|
|
|
@@ -134,32 +144,39 @@
|
|
|
<el-col :span="3">
|
|
|
<el-input
|
|
|
v-model="detailData.wgjs_bh2"
|
|
|
- :clearable="true"
|
|
|
+ :formatter="val => val.toUpperCase()"
|
|
|
/>
|
|
|
</el-col>
|
|
|
<el-col :span="3">
|
|
|
<el-input
|
|
|
v-model="detailData.name2"
|
|
|
- :clearable="true"
|
|
|
+ readonly
|
|
|
/>
|
|
|
</el-col>
|
|
|
<el-col :span="3">
|
|
|
<el-input
|
|
|
v-model="detailData.wgjs_js2"
|
|
|
- :clearable="true"
|
|
|
/>
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
|
<el-input
|
|
|
v-model="detailData.wgjs_yy2"
|
|
|
- :clearable="true"
|
|
|
/>
|
|
|
</el-col>
|
|
|
<el-col :span="3">
|
|
|
- <el-input
|
|
|
+ <el-select
|
|
|
v-model="detailData.wgjs_冲定额2"
|
|
|
- :clearable="true"
|
|
|
- />
|
|
|
+ placeholder=" "
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ label=""
|
|
|
+ value=""
|
|
|
+ />
|
|
|
+ <el-option
|
|
|
+ label="是"
|
|
|
+ value="是"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
|
|
|
@@ -171,32 +188,39 @@
|
|
|
<el-col :span="3">
|
|
|
<el-input
|
|
|
v-model="detailData.wgjs_bh3"
|
|
|
- :clearable="true"
|
|
|
+ :formatter="val => val.toUpperCase()"
|
|
|
/>
|
|
|
</el-col>
|
|
|
<el-col :span="3">
|
|
|
<el-input
|
|
|
v-model="detailData.name3"
|
|
|
- :clearable="true"
|
|
|
+ readonly
|
|
|
/>
|
|
|
</el-col>
|
|
|
<el-col :span="3">
|
|
|
<el-input
|
|
|
v-model="detailData.wgjs_js3"
|
|
|
- :clearable="true"
|
|
|
/>
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
|
<el-input
|
|
|
v-model="detailData.wgjs_yy3"
|
|
|
- :clearable="true"
|
|
|
/>
|
|
|
</el-col>
|
|
|
<el-col :span="3">
|
|
|
- <el-input
|
|
|
+ <el-select
|
|
|
v-model="detailData.wgjs_冲定额3"
|
|
|
- :clearable="true"
|
|
|
- />
|
|
|
+ placeholder=" "
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ label=""
|
|
|
+ value=""
|
|
|
+ />
|
|
|
+ <el-option
|
|
|
+ label="是"
|
|
|
+ value="是"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
|
|
|
@@ -208,32 +232,39 @@
|
|
|
<el-col :span="3">
|
|
|
<el-input
|
|
|
v-model="detailData.wgjs_bh4"
|
|
|
- :clearable="true"
|
|
|
+ :formatter="val => val.toUpperCase()"
|
|
|
/>
|
|
|
</el-col>
|
|
|
<el-col :span="3">
|
|
|
<el-input
|
|
|
v-model="detailData.name4"
|
|
|
- :clearable="true"
|
|
|
+ readonly
|
|
|
/>
|
|
|
</el-col>
|
|
|
<el-col :span="3">
|
|
|
<el-input
|
|
|
v-model="detailData.wgjs_js4"
|
|
|
- :clearable="true"
|
|
|
/>
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
|
<el-input
|
|
|
v-model="detailData.wgjs_yy4"
|
|
|
- :clearable="true"
|
|
|
/>
|
|
|
</el-col>
|
|
|
<el-col :span="3">
|
|
|
- <el-input
|
|
|
+ <el-select
|
|
|
v-model="detailData.wgjs_冲定额4"
|
|
|
- :clearable="true"
|
|
|
- />
|
|
|
+ placeholder=" "
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ label=""
|
|
|
+ value=""
|
|
|
+ />
|
|
|
+ <el-option
|
|
|
+ label="是"
|
|
|
+ value="是"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
|
|
|
@@ -245,32 +276,39 @@
|
|
|
<el-col :span="3">
|
|
|
<el-input
|
|
|
v-model="detailData.wgjs_bh5"
|
|
|
- :clearable="true"
|
|
|
+ :formatter="val => val.toUpperCase()"
|
|
|
/>
|
|
|
</el-col>
|
|
|
<el-col :span="3">
|
|
|
<el-input
|
|
|
v-model="detailData.name5"
|
|
|
- :clearable="true"
|
|
|
+ readonly
|
|
|
/>
|
|
|
</el-col>
|
|
|
<el-col :span="3">
|
|
|
<el-input
|
|
|
v-model="detailData.wgjs_js5"
|
|
|
- :clearable="true"
|
|
|
/>
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
|
<el-input
|
|
|
v-model="detailData.wgjs_yy5"
|
|
|
- :clearable="true"
|
|
|
/>
|
|
|
</el-col>
|
|
|
<el-col :span="3">
|
|
|
- <el-input
|
|
|
+ <el-select
|
|
|
v-model="detailData.wgjs_冲定额5"
|
|
|
- :clearable="true"
|
|
|
- />
|
|
|
+ placeholder=" "
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ label=""
|
|
|
+ value=""
|
|
|
+ />
|
|
|
+ <el-option
|
|
|
+ label="是"
|
|
|
+ value="是"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
|
|
|
@@ -282,32 +320,39 @@
|
|
|
<el-col :span="3">
|
|
|
<el-input
|
|
|
v-model="detailData.wgjs_bh6"
|
|
|
- :clearable="true"
|
|
|
+ :formatter="val => val.toUpperCase()"
|
|
|
/>
|
|
|
</el-col>
|
|
|
<el-col :span="3">
|
|
|
<el-input
|
|
|
v-model="detailData.name6"
|
|
|
- :clearable="true"
|
|
|
+ readonly
|
|
|
/>
|
|
|
</el-col>
|
|
|
<el-col :span="3">
|
|
|
<el-input
|
|
|
v-model="detailData.wgjs_js6"
|
|
|
- :clearable="true"
|
|
|
/>
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
|
<el-input
|
|
|
v-model="detailData.wgjs_yy6"
|
|
|
- :clearable="true"
|
|
|
/>
|
|
|
</el-col>
|
|
|
<el-col :span="3">
|
|
|
- <el-input
|
|
|
+ <el-select
|
|
|
v-model="detailData.wgjs_冲定额6"
|
|
|
- :clearable="true"
|
|
|
- />
|
|
|
+ placeholder=" "
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ label=""
|
|
|
+ value=""
|
|
|
+ />
|
|
|
+ <el-option
|
|
|
+ label="是"
|
|
|
+ value="是"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
|
|
|
@@ -352,7 +397,7 @@
|
|
|
<layout-content>
|
|
|
<!-- 数据展示 -->
|
|
|
<el-table
|
|
|
- ref="multipleTable"
|
|
|
+ ref="table"
|
|
|
style="width: 100%"
|
|
|
tooltip-effect="dark"
|
|
|
:data="tableData"
|
|
|
@@ -365,8 +410,9 @@
|
|
|
:header-row-style="{ height: '20px' }"
|
|
|
:header-cell-style="{ padding: '0px' }"
|
|
|
@selection-change="handleSelectionChange"
|
|
|
- @row-dblclick="doubleClick"
|
|
|
+ @row-dblclick="handleShowDetail"
|
|
|
@row-click="Click"
|
|
|
+ @current-change="(row, oldRow) => { currentRow = row}"
|
|
|
>
|
|
|
<el-table-column
|
|
|
type="selection"
|
|
|
@@ -405,9 +451,9 @@
|
|
|
<script setup>
|
|
|
// 全量引入格式化工具 请按需保留
|
|
|
import { Layout, LayoutContent, LayoutHeader, LayoutSider } from '@arco-design/web-vue'
|
|
|
-import { ElMessage } from 'element-plus'
|
|
|
+import { ElMessage, dayjs } from 'element-plus'
|
|
|
import { ref, reactive } from 'vue'
|
|
|
-import { getSide, getTable, getDetail, updateData, getLocate, createData } from '@/api/mes_api_gty/timesheet'
|
|
|
+import { getSide, getTable, getDetail, updateData, getLocate, createData, getYg } from '@/api/mes_api_gty/timesheet'
|
|
|
|
|
|
defineOptions({
|
|
|
name: '08Timesheet'
|
|
|
@@ -429,10 +475,6 @@ const getSideData = async() => {
|
|
|
}
|
|
|
getSideData()
|
|
|
|
|
|
-// 验证规则
|
|
|
-const rule = reactive({
|
|
|
-})
|
|
|
-
|
|
|
const elFormRef = ref()
|
|
|
// const elSearchFormRef = ref()
|
|
|
|
|
|
@@ -465,6 +507,7 @@ const tableColumns = [
|
|
|
{ prop: 'wgjs_js6', label: '计时6', width: 100 },
|
|
|
{ prop: 'wgjs_yy6', label: '原因6', width: 100 },
|
|
|
]
|
|
|
+const table = ref(null)
|
|
|
const tableData = reactive([])
|
|
|
const page = ref(1)
|
|
|
const total = ref(0)
|
|
|
@@ -481,6 +524,7 @@ const getTableData = async(params) => {
|
|
|
if (response.code === 0) {
|
|
|
total.value = response.data.total
|
|
|
tableData.splice(0, tableData.length, ...response.data.rows)
|
|
|
+ table.value?.setCurrentRow(tableData[0])
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -490,6 +534,7 @@ const getLocateData = async(params) => {
|
|
|
if (res.code === 0) {
|
|
|
total.value = res.data.total
|
|
|
tableData.splice(0, tableData.length, ...res.data.rows)
|
|
|
+ table.value?.setCurrentRow(tableData[0])
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -535,15 +580,7 @@ const handleNodeClick = (node, check) => {
|
|
|
handleCurrentChange()
|
|
|
}
|
|
|
}
|
|
|
-// 新增数据
|
|
|
-const handleShowAdd = async() => {
|
|
|
- const res = await getDetail({ wgjs_rq: value1.value, wgjs_bh1: value2.value })
|
|
|
- if (res.code === 0) {
|
|
|
- type.value = 'add'
|
|
|
- Object.assign(detailData, res.data)
|
|
|
- dialogFormVisible.value = true
|
|
|
- }
|
|
|
-}
|
|
|
+
|
|
|
// 搜索
|
|
|
function handleSearch() {
|
|
|
params.search = searchInfo.value
|
|
|
@@ -554,37 +591,40 @@ function handleSearch() {
|
|
|
|
|
|
// ============== 详情页面 ==============
|
|
|
const detailData = reactive({})
|
|
|
+const currentRow = ref()
|
|
|
|
|
|
// 行为控制标记(弹窗内部需要增还是改)
|
|
|
const type = ref('')
|
|
|
// 弹窗控制标记
|
|
|
const dialogFormVisible = ref(false)
|
|
|
|
|
|
-// 双击表格操作
|
|
|
-async function doubleClick(row, column, event) {
|
|
|
+// 查改
|
|
|
+const handleShowDetail = async() => {
|
|
|
type.value = 'update'
|
|
|
- const { wgjs_rq, wgjs_bh1 } = row
|
|
|
+ const { wgjs_rq, wgjs_bh1 } = currentRow.value
|
|
|
const res = await getDetail({ wgjs_rq, wgjs_bh1 })
|
|
|
if (res.code === 0) {
|
|
|
Object.assign(detailData, res.data)
|
|
|
- dialogFormVisible.value = true
|
|
|
+ // dialogFormVisible.value = true
|
|
|
+ showDialog()
|
|
|
}
|
|
|
}
|
|
|
-const value1 = ref()
|
|
|
-const value2 = ref()
|
|
|
-// 单击表格操作
|
|
|
-async function Click(row, column, event) {
|
|
|
- const { wgjs_rq, wgjs_bh1 } = row
|
|
|
- value1.value = wgjs_rq
|
|
|
- value2.value = wgjs_bh1
|
|
|
- // console.log(wgjs_rq)
|
|
|
- // console.log(wgjs_bh1)
|
|
|
- // const res = await getDetail({ wgjs_rq, wgjs_bh1 })
|
|
|
- // if (res.code === 0) {
|
|
|
- // Object.assign(detailData, res.data)
|
|
|
- // dialogFormVisible.value = true
|
|
|
- // }
|
|
|
+
|
|
|
+// 新增数据
|
|
|
+const handleShowAdd = async() => {
|
|
|
+ const { wgjs_rq, wgjs_bh1 } = currentRow.value
|
|
|
+ const res = await getDetail({ wgjs_rq, wgjs_bh1 })
|
|
|
+ if (res.code === 0) {
|
|
|
+ type.value = 'add'
|
|
|
+ Object.assign(detailData, res.data)
|
|
|
+
|
|
|
+ detailData['wgjs_rq'] = dayjs().format('YYYY-MM-DD')
|
|
|
+
|
|
|
+ // dialogFormVisible.value = true
|
|
|
+ showDialog()
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
// 更新数据
|
|
|
const enterDialog = async() => {
|
|
|
if (type.value === 'update') {
|
|
|
@@ -664,11 +704,72 @@ const updateDetailData = async() => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// 开启弹窗
|
|
|
+const showDialog = () => {
|
|
|
+ dialogFormVisible.value = true
|
|
|
+ // 在 setTimeout 中获取元素,确保在 DOM 渲染完毕后执行
|
|
|
+ setTimeout(() => {
|
|
|
+ formElements = document.getElementById('detail-form').elements
|
|
|
+ formElements[0].focus()
|
|
|
+ }, 0)
|
|
|
+}
|
|
|
+
|
|
|
// 关闭弹窗
|
|
|
const closeDialog = () => {
|
|
|
dialogFormVisible.value = false
|
|
|
}
|
|
|
|
|
|
+let formElements
|
|
|
+const moveFocus = async(event) => {
|
|
|
+ console.log(event)
|
|
|
+ const index = Array.from(formElements).indexOf(event.target)
|
|
|
+ const key = event.key
|
|
|
+ event.preventDefault()
|
|
|
+
|
|
|
+ // 切换焦点
|
|
|
+ const focusNext = (step) => {
|
|
|
+ const nextIndex = (index + step + formElements.length) % formElements.length
|
|
|
+ formElements[nextIndex].focus()
|
|
|
+ }
|
|
|
+
|
|
|
+ switch (index) {
|
|
|
+ case 1:
|
|
|
+ case 6:
|
|
|
+ case 11:
|
|
|
+ case 16:
|
|
|
+ case 21:
|
|
|
+ case 26:
|
|
|
+ if (key === 'ArrowDown') {
|
|
|
+ formElements[index + 1].focus()
|
|
|
+ } else if (key === 'ArrowUp') {
|
|
|
+ formElements[index - 1].focus()
|
|
|
+ } else if (key === 'Enter') {
|
|
|
+ formElements[index + 1].focus()
|
|
|
+ const sczl_bh = formElements[index]?.value
|
|
|
+ if (sczl_bh === '') {
|
|
|
+ detailData[`name${(index - 1) / 5 + 1}`] = ''
|
|
|
+ break
|
|
|
+ }
|
|
|
+ const res = await getYg({ sczl_bh })
|
|
|
+ if (res.code === 0) {
|
|
|
+ const { data: { ygxm }} = res
|
|
|
+ detailData[`name${(index - 1) / 5 + 1}`] = ygxm
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break
|
|
|
+
|
|
|
+ default:
|
|
|
+ if (key === 'ArrowDown') {
|
|
|
+ focusNext(1)
|
|
|
+ } else if (key === 'ArrowUp') {
|
|
|
+ focusNext(-1)
|
|
|
+ } else if (key === 'Enter') {
|
|
|
+ focusNext(1)
|
|
|
+ }
|
|
|
+ break
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|