index.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902
  1. <template>
  2. <div>
  3. <!-- 左侧树侧形结构-->
  4. <el-container>
  5. <layout-sider :resize-directions="['right']" :width="220" style="margin-right: 10px;">
  6. <div class="JKWTree-tree" style="height: 70vh;">
  7. <h3>计件工计时单维护</h3>
  8. <el-tree :data="treeData" highlight-current="true" @node-click="handleNodeClick" />
  9. </div>
  10. </layout-sider>
  11. <el-container>
  12. <el-main>
  13. <!-- 按钮 -->
  14. <div class="gva-table-box">
  15. <el-form>
  16. <el-form-item>
  17. <el-input v-model="searchInfo" placeholder="搜索产品编号或产品名称" clearable style="width: 180px;" />
  18. <el-button type="primary" icon="Search" class="search" @click="handleSearch" />
  19. <el-button type="primary" icon="edit" class="bt" @click="handleShowDetail">查改 </el-button>
  20. <el-button type="primary" icon="plus" class="bt" @click="handleShowAdd">新增 </el-button>
  21. <el-button type="primary" class="bt" icon="delete" @click="onDel">删除</el-button>
  22. </el-form-item>
  23. </el-form>
  24. <!-- 数据展示 -->
  25. <el-table ref="table" style="width: 100%" tooltip-effect="dark" :data="tableData" row-key="ID"
  26. highlight-current-row border show-overflow-tooltip="true" :row-style="{ height: '20px' }"
  27. :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
  28. :header-cell-style="{ padding: '0px' }" @selection-change="handleSelectionChange"
  29. @row-dblclick="handleShowDetail" @row-click="Click"
  30. @current-change="(row, oldRow) => { currentRow = row}">
  31. <!-- 循环渲染列 -->
  32. <el-table-column v-for=" column in tableColumns " :key="column.prop" :prop="column.prop"
  33. :label="column.label" :width="column.width" sortable />
  34. </el-table>
  35. <!-- 分页 -->
  36. <div class="gva-pagination">
  37. <el-pagination v-model:current-page="page" v-model:page-size="limit"
  38. layout="total, sizes, prev, pager, next, jumper" :page-sizes="[10, 30, 50, 100]"
  39. :total="total" @current-change="handleCurrentChange" @size-change="handleSizeChange" />
  40. </div>
  41. </div>
  42. <!-- 弹出框 -->
  43. <div>
  44. <!-- 弹出框 -->
  45. <el-dialog v-model="dialogFormVisible" :before-close="closeDialog"
  46. :title="type === 'add' ? '新增' : '修改'" destroy-on-close width="800px">
  47. <!-- <el-scrollbar height="500px"> -->
  48. <el-form id="detail-form" ref="elFormRef" :model="detailData" label-position="left"
  49. @keyup="moveFocus">
  50. <!-- 日期 -->
  51. <el-row>
  52. <el-form-item label="日期" prop="name">
  53. <el-input type="date" max="9999-12-31" v-model="detailData.wgjs_rq"
  54. style="width: 100px;" />
  55. </el-form-item>
  56. </el-row>
  57. <!-- 标题栏 -->
  58. <el-row :gutter="10">
  59. <el-col :span="3"> <span>员工编号</span> </el-col>
  60. <el-col :span="3"> <span>员工姓名</span> </el-col>
  61. <el-col :span="3"> <span>计时</span> </el-col>
  62. <el-col :span="12"> <span>原因备注</span> </el-col>
  63. <el-col :span="3"> <span>冲月定额</span> </el-col>
  64. </el-row>
  65. <!-- 员工1 -->
  66. <el-row :gutter="5" style="margin-top: 10px;">
  67. <el-col :span="3">
  68. <el-input v-model="detailData.wgjs_bh1" :formatter="val => val.toUpperCase()"
  69. placeholder="Enter回车" />
  70. </el-col>
  71. <el-col :span="3">
  72. <el-input v-model="detailData.name1" readonly />
  73. </el-col>
  74. <el-col :span="3">
  75. <el-input v-model="detailData.wgjs_js1" />
  76. </el-col>
  77. <el-col :span="12">
  78. <el-input v-model="detailData.wgjs_yy1" />
  79. </el-col>
  80. <el-col :span="3">
  81. <el-select v-model="detailData.wgjs_冲定额1">
  82. <el-option label="" value="" />
  83. <el-option label="是" value="是" />
  84. </el-select>
  85. </el-col>
  86. </el-row>
  87. <!-- 员工2 -->
  88. <el-row :gutter="5" style="margin-top: 10px;">
  89. <el-col :span="3">
  90. <el-input v-model="detailData.wgjs_bh2" :formatter="val => val.toUpperCase()"
  91. placeholder="Enter回车" />
  92. </el-col>
  93. <el-col :span="3">
  94. <el-input v-model="detailData.name2" readonly />
  95. </el-col>
  96. <el-col :span="3">
  97. <el-input v-model="detailData.wgjs_js2" />
  98. </el-col>
  99. <el-col :span="12">
  100. <el-input v-model="detailData.wgjs_yy2" />
  101. </el-col>
  102. <el-col :span="3">
  103. <el-select v-model="detailData.wgjs_冲定额2">
  104. <el-option label="" value="" />
  105. <el-option label="是" value="是" />
  106. </el-select>
  107. </el-col>
  108. </el-row>
  109. <!-- 员工3 -->
  110. <el-row :gutter="5" style="margin-top: 10px;">
  111. <el-col :span="3">
  112. <el-input v-model="detailData.wgjs_bh3" :formatter="val => val.toUpperCase()"
  113. placeholder="Enter回车" />
  114. </el-col>
  115. <el-col :span="3">
  116. <el-input v-model="detailData.name3" readonly />
  117. </el-col>
  118. <el-col :span="3">
  119. <el-input v-model="detailData.wgjs_js3" />
  120. </el-col>
  121. <el-col :span="12">
  122. <el-input v-model="detailData.wgjs_yy3" />
  123. </el-col>
  124. <el-col :span="3">
  125. <el-select v-model="detailData.wgjs_冲定额3">
  126. <el-option label="" value="" />
  127. <el-option label="是" value="是" />
  128. </el-select>
  129. </el-col>
  130. </el-row>
  131. <!-- 员工4 -->
  132. <el-row :gutter="5" style="margin-top: 10px;">
  133. <el-col :span="3">
  134. <el-input v-model="detailData.wgjs_bh4" :formatter="val => val.toUpperCase()"
  135. placeholder="Enter回车" />
  136. </el-col>
  137. <el-col :span="3">
  138. <el-input v-model="detailData.name4" readonly />
  139. </el-col>
  140. <el-col :span="3">
  141. <el-input v-model="detailData.wgjs_js4" />
  142. </el-col>
  143. <el-col :span="12">
  144. <el-input v-model="detailData.wgjs_yy4" />
  145. </el-col>
  146. <el-col :span="3">
  147. <el-select v-model="detailData.wgjs_冲定额4">
  148. <el-option label="" value="" />
  149. <el-option label="是" value="是" />
  150. </el-select>
  151. </el-col>
  152. </el-row>
  153. <!-- 员工5 -->
  154. <el-row :gutter="5" style="margin-top: 10px;">
  155. <el-col :span="3">
  156. <el-input v-model="detailData.wgjs_bh5" :formatter="val => val.toUpperCase()"
  157. placeholder="Enter回车" />
  158. </el-col>
  159. <el-col :span="3">
  160. <el-input v-model="detailData.name5" readonly />
  161. </el-col>
  162. <el-col :span="3">
  163. <el-input v-model="detailData.wgjs_js5" />
  164. </el-col>
  165. <el-col :span="12">
  166. <el-input v-model="detailData.wgjs_yy5" />
  167. </el-col>
  168. <el-col :span="3">
  169. <el-select v-model="detailData.wgjs_冲定额5">
  170. <el-option label="" value="" />
  171. <el-option label="是" value="是" />
  172. </el-select>
  173. </el-col>
  174. </el-row>
  175. <!-- 员工6 -->
  176. <el-row :gutter="5" style="margin-top: 10px;">
  177. <el-col :span="3">
  178. <el-input v-model="detailData.wgjs_bh6" :formatter="val => val.toUpperCase()"
  179. placeholder="Enter回车" />
  180. </el-col>
  181. <el-col :span="3">
  182. <el-input v-model="detailData.name6" readonly />
  183. </el-col>
  184. <el-col :span="3">
  185. <el-input v-model="detailData.wgjs_js6" />
  186. </el-col>
  187. <el-col :span="12">
  188. <el-input v-model="detailData.wgjs_yy6" />
  189. </el-col>
  190. <el-col :span="3">
  191. <el-select v-model="detailData.wgjs_冲定额6">
  192. <el-option label="" value="" />
  193. <el-option label="是" value="是" />
  194. </el-select>
  195. </el-col>
  196. </el-row>
  197. </el-form>
  198. <template #footer>
  199. <div class="dialog-footer">
  200. <el-button @click="closeDialog">取 消</el-button>
  201. <el-button type="primary" @click="enterDialog">确 定</el-button>
  202. </div>
  203. </template>
  204. </el-dialog>
  205. </div>
  206. <!-- 员工选择 -->
  207. <el-dialog v-model="dialogSelectVisible_Yg" title="选择" destroy-on-close width="300px"
  208. @keydown="selectGX_Yg($event)">
  209. <el-table tooltip-effect="dark" :data="selectData_Yg" row-key="ID" highlight-current-row="true"
  210. border style="width:100%" @row-dblclick="handleSelectClick_Yg" ref="table_Yg">
  211. <el-table-column prop="员工编号" label="员工编号" width="100" />
  212. <el-table-column prop="ygxm" label="员工姓名" width="200" />
  213. </el-table>
  214. </el-dialog>
  215. </el-main>
  216. </el-container>
  217. </el-container>
  218. </div>
  219. </template>
  220. <script setup>
  221. // 全量引入格式化工具 请按需保留
  222. import {
  223. Layout,
  224. LayoutContent,
  225. LayoutHeader,
  226. LayoutSider
  227. } from '@arco-design/web-vue'
  228. import {
  229. ElMessage,
  230. ElMessageBox,
  231. dayjs
  232. } from 'element-plus'
  233. import {
  234. ref,
  235. reactive
  236. } from 'vue'
  237. import {
  238. getSide,
  239. getTable,
  240. getDetail,
  241. updateData,
  242. getLocate,
  243. createData,
  244. getYg,
  245. deleteData
  246. } from '@/api/mes_api_gty/timesheet'
  247. import {
  248. useUserStore
  249. } from '@/pinia/modules/user'
  250. const userStore = useUserStore()
  251. const sys_id = '[' + userStore.userInfo.userName + '/' + userStore.userInfo.nickName + ']'
  252. defineOptions({
  253. name: '08Timesheet'
  254. })
  255. // 侧边栏数据请求
  256. const treeData = reactive([])
  257. const getSideData = async () => {
  258. const response = await getSide()
  259. if (response.code === 0) {
  260. const transformedData = response.data.map(item => ({
  261. label: item.date,
  262. params: {
  263. date: item.date.substring(0, 4) + '-' + item.date.substring(4),
  264. },
  265. }))
  266. treeData.splice(0, treeData.length, ...transformedData)
  267. }
  268. }
  269. getSideData()
  270. const elFormRef = ref()
  271. // const elSearchFormRef = ref()
  272. // ============== 表格页面 ==============
  273. const tableColumns = [{
  274. prop: 'wgjs_rq',
  275. label: '日期',
  276. width: 100
  277. },
  278. {
  279. prop: 'wgjs_bh1',
  280. label: '员工编号1',
  281. width: 120
  282. },
  283. {
  284. prop: 'name1',
  285. label: '姓名1',
  286. width: 100
  287. },
  288. {
  289. prop: 'department',
  290. label: '所在部门',
  291. width: 120
  292. },
  293. {
  294. prop: 'wgjs_js1',
  295. label: '计时1',
  296. width: 100
  297. },
  298. {
  299. prop: 'wgjs_yy1',
  300. label: '原因1',
  301. width: 100
  302. },
  303. {
  304. prop: 'wgjs_bh2',
  305. label: '员工编号2',
  306. width: 120
  307. },
  308. {
  309. prop: 'name2',
  310. label: '姓名2',
  311. width: 100
  312. },
  313. {
  314. prop: 'wgjs_js2',
  315. label: '计时2',
  316. width: 100
  317. },
  318. {
  319. prop: 'wgjs_yy2',
  320. label: '原因2',
  321. width: 100
  322. },
  323. {
  324. prop: 'wgjs_bh3',
  325. label: '员工编号3',
  326. width: 120
  327. },
  328. {
  329. prop: 'name3',
  330. label: '姓名3',
  331. width: 100
  332. },
  333. {
  334. prop: 'wgjs_js3',
  335. label: '计时3',
  336. width: 100
  337. },
  338. {
  339. prop: 'wgjs_yy3',
  340. label: '原因3',
  341. width: 100
  342. },
  343. {
  344. prop: 'wgjs_bh4',
  345. label: '员工编号4',
  346. width: 120
  347. },
  348. {
  349. prop: 'name4',
  350. label: '姓名4',
  351. width: 100
  352. },
  353. {
  354. prop: 'wgjs_js4',
  355. label: '计时4',
  356. width: 100
  357. },
  358. {
  359. prop: 'wgjs_yy4',
  360. label: '原因4',
  361. width: 100
  362. },
  363. {
  364. prop: 'wgjs_bh5',
  365. label: '员工编号5',
  366. width: 120
  367. },
  368. {
  369. prop: 'name5',
  370. label: '姓名5',
  371. width: 120
  372. },
  373. {
  374. prop: 'wgjs_js5',
  375. label: '计时5',
  376. width: 100
  377. },
  378. {
  379. prop: 'wgjs_yy5',
  380. label: '原因5',
  381. width: 100
  382. },
  383. {
  384. prop: 'wgjs_bh6',
  385. label: '员工编号6',
  386. width: 120
  387. },
  388. {
  389. prop: 'name6',
  390. label: '姓名6',
  391. width: 100
  392. },
  393. {
  394. prop: 'wgjs_js6',
  395. label: '计时6',
  396. width: 100
  397. },
  398. {
  399. prop: 'wgjs_yy6',
  400. label: '原因6',
  401. width: 100
  402. },
  403. ]
  404. const table = ref(null)
  405. const tableData = reactive([])
  406. const page = ref(1)
  407. const total = ref(0)
  408. const limit = ref(10)
  409. const searchInfo = ref('')
  410. const params = {
  411. date: '',
  412. search: '',
  413. type: '',
  414. }
  415. const getTableData = async (params) => {
  416. const response = await getTable(params)
  417. if (response.code === 0) {
  418. total.value = response.data.total
  419. tableData.splice(0, tableData.length, ...response.data.rows)
  420. table.value?.setCurrentRow(tableData[0])
  421. }
  422. }
  423. // 搜索
  424. const getLocateData = async (params) => {
  425. const res = await getLocate(params)
  426. if (res.code === 0) {
  427. total.value = res.data.total
  428. tableData.splice(0, tableData.length, ...res.data.rows)
  429. table.value?.setCurrentRow(tableData[0])
  430. }
  431. }
  432. // 分页设置
  433. const handleSizeChange = () => {
  434. switch (params.type) {
  435. case 'getTableData':
  436. getTableData({
  437. date: params.date,
  438. page: page.value.toString(),
  439. limit: limit.value.toString()
  440. })
  441. break
  442. case 'getLocateData':
  443. getLocateData({
  444. date: params.date.replace('-', ''),
  445. search: params.search,
  446. page: page.value.toString(),
  447. limit: limit.value.toString()
  448. })
  449. break
  450. default:
  451. break
  452. }
  453. }
  454. // 页面跳转
  455. const handleCurrentChange = () => {
  456. switch (params.type) {
  457. case 'getTableData':
  458. getTableData({
  459. date: params.date,
  460. page: page.value.toString(),
  461. limit: limit.value.toString()
  462. })
  463. break
  464. case 'getLocateData':
  465. getLocateData({
  466. date: params.date.replace('-', ''),
  467. search: params.search,
  468. page: page.value.toString(),
  469. limit: limit.value.toString()
  470. })
  471. break
  472. default:
  473. break
  474. }
  475. }
  476. const handleNodeClick = (node, check) => {
  477. if (node.params) {
  478. params.date = node.params.date
  479. params.type = 'getTableData'
  480. page.value = 1
  481. handleCurrentChange()
  482. }
  483. }
  484. // 搜索
  485. function handleSearch() {
  486. params.search = searchInfo.value
  487. params.type = 'getLocateData'
  488. page.value = 1
  489. handleCurrentChange()
  490. }
  491. // ============== 详情页面 ==============
  492. const detailData = reactive({})
  493. const currentRow = ref()
  494. // 行为控制标记(弹窗内部需要增还是改)
  495. const type = ref('')
  496. // 弹窗控制标记
  497. const dialogFormVisible = ref(false)
  498. // 查改
  499. const handleShowDetail = async () => {
  500. type.value = 'update'
  501. const {
  502. UniqId
  503. } = currentRow.value
  504. const res = await getDetail({
  505. UniqId
  506. })
  507. if (res.code === 0) {
  508. Object.assign(detailData, res.data)
  509. // dialogFormVisible.value = true
  510. showDialog()
  511. }
  512. }
  513. // 新增数据
  514. const handleShowAdd = () => {
  515. type.value = 'add';
  516. if (!currentRow.value) {
  517. detailData.wgjs_rq = '';
  518. detailData.wgjs_bh1 = '';
  519. detailData.wgjs_js1 = '';
  520. detailData.wgjs_yy1 = '';
  521. detailData.wgjs_冲定额1 = '';
  522. detailData.wgjs_bh2 = '';
  523. detailData.wgjs_js2 = '';
  524. detailData.wgjs_yy2 = '';
  525. detailData.wgjs_冲定额2 = '';
  526. detailData.wgjs_bh3 = '';
  527. detailData.wgjs_js3 = '';
  528. detailData.wgjs_yy3 = '';
  529. detailData.wgjs_冲定额3 = '';
  530. detailData.wgjs_bh4 = '';
  531. detailData.wgjs_js4 = '';
  532. detailData.wgjs_yy4 = '';
  533. detailData.wgjs_冲定额4 = '';
  534. detailData.wgjs_bh5 = '';
  535. detailData.wgjs_js5 = '';
  536. detailData.wgjs_yy5 = '';
  537. detailData.wgjs_冲定额5 = '';
  538. detailData.wgjs_bh6 = '';
  539. detailData.wgjs_js6 = '';
  540. detailData.wgjs_yy6 = '';
  541. detailData.wgjs_冲定额6 = '';
  542. } else {
  543. Object.assign(detailData, currentRow.value)
  544. }
  545. // dialogFormVisible.value = true
  546. const date = dayjs().format('YYYY-MM-DD')
  547. detailData.wgjs_rq = date
  548. showDialog()
  549. }
  550. // 更新数据
  551. const enterDialog = async () => {
  552. if (type.value === 'update') {
  553. updateDetailData()
  554. } else if (type.value === 'add') {
  555. addDetailData()
  556. }
  557. }
  558. // 新增
  559. const addDetailData = async () => {
  560. const restoredData = {
  561. wgjs_rq: detailData.wgjs_rq,
  562. wgjs_bh1: detailData.wgjs_bh1,
  563. wgjs_js1: detailData.wgjs_js1,
  564. wgjs_yy1: detailData.wgjs_yy1,
  565. wgjs_冲定额1: detailData.wgjs_冲定额1,
  566. wgjs_bh2: detailData.wgjs_bh2,
  567. wgjs_js2: detailData.wgjs_js2,
  568. wgjs_yy2: detailData.wgjs_yy2,
  569. wgjs_冲定额2: detailData.wgjs_冲定额2,
  570. wgjs_bh3: detailData.wgjs_bh3,
  571. wgjs_js3: detailData.wgjs_js3,
  572. wgjs_yy3: detailData.wgjs_yy3,
  573. wgjs_冲定额3: detailData.wgjs_冲定额3,
  574. wgjs_bh4: detailData.wgjs_bh4,
  575. wgjs_js4: detailData.wgjs_js4,
  576. wgjs_yy4: detailData.wgjs_yy4,
  577. wgjs_冲定额4: detailData.wgjs_冲定额4,
  578. wgjs_bh5: detailData.wgjs_bh5,
  579. wgjs_js5: detailData.wgjs_js5,
  580. wgjs_yy5: detailData.wgjs_yy5,
  581. wgjs_冲定额5: detailData.wgjs_冲定额5,
  582. wgjs_bh6: detailData.wgjs_bh6,
  583. wgjs_js6: detailData.wgjs_js6,
  584. wgjs_yy6: detailData.wgjs_yy6,
  585. wgjs_冲定额6: detailData.wgjs_冲定额6,
  586. }
  587. restoredData.sys_id = sys_id;
  588. const res = await createData(restoredData)
  589. if (res.code === 0) {
  590. ElMessage({
  591. type: 'success',
  592. message: '新增成功',
  593. })
  594. //刷新
  595. if (params.date != '') {
  596. getTableData({
  597. date: params.date,
  598. page: page.value.toString(),
  599. limit: limit.value.toString()
  600. })
  601. }
  602. getSideData()
  603. dialogFormVisible.value = false
  604. }
  605. }
  606. // 修改
  607. const updateDetailData = async () => {
  608. const obj = detailData
  609. for (let i = 1; i <= 6; i++) {
  610. delete obj[`name${i}`]
  611. }
  612. const res = await updateData(obj)
  613. if (res.code === 0) {
  614. ElMessage({
  615. type: 'success',
  616. message: '更新成功'
  617. })
  618. params.type = 'getTableData'
  619. if (params.date != '') {
  620. getTableData({
  621. date: params.date,
  622. page: page.value.toString(),
  623. limit: limit.value.toString()
  624. })
  625. }
  626. dialogFormVisible.value = false
  627. }
  628. }
  629. // 开启弹窗
  630. const showDialog = () => {
  631. dialogFormVisible.value = true
  632. // 在 setTimeout 中获取元素,确保在 DOM 渲染完毕后执行
  633. setTimeout(() => {
  634. formElements = document.getElementById('detail-form').elements
  635. formElements[0].focus()
  636. }, 0)
  637. }
  638. // 关闭弹窗
  639. const closeDialog = () => {
  640. dialogFormVisible.value = false
  641. }
  642. let index_Yg = '';
  643. let formElements
  644. const moveFocus = async (event) => {
  645. const index = Array.from(formElements).indexOf(event.target)
  646. index_Yg = index
  647. const key = event.key
  648. event.preventDefault()
  649. // 切换焦点
  650. const focusNext = (step) => {
  651. const nextIndex = (index + step + formElements.length) % formElements.length
  652. formElements[nextIndex].focus()
  653. formElements[nextIndex].select()
  654. }
  655. switch (index) {
  656. case 1:
  657. case 6:
  658. case 11:
  659. case 16:
  660. case 21:
  661. case 26:
  662. if (key === 'ArrowDown') {
  663. formElements[index + 1].focus()
  664. } else if (key === 'ArrowUp') {
  665. formElements[index - 1].focus()
  666. } else if (key === 'Enter') {
  667. formElements[index + 1].focus()
  668. const sczl_bh = formElements[index]?.value
  669. if (sczl_bh === '') {
  670. detailData[`name${(index - 1) / 5 + 1}`] = ''
  671. break
  672. }
  673. const response = await getYg({
  674. sczl_bh
  675. })
  676. if (response.code == 0) {
  677. if (response.data.length == 1) {
  678. detailData[`name${(index - 1) / 5 + 1}`] = response.data[0].ygxm;
  679. detailData[`wgjs_bh${(index - 1) / 5 + 1}`] = response.data[0].员工编号;
  680. } else if (response.data.length > 1) {
  681. selectData_Yg.splice(0, selectData_Yg.length, ...response.data)
  682. setGXCurrent_Yg(selectData_Yg[0])
  683. dialogSelectVisible_Yg.value = true
  684. } else {
  685. ElMessage({
  686. type: 'warning',
  687. message: '未查询到该员工'
  688. })
  689. detailData[`name${(index - 1) / 5 + 1}`] = '';
  690. detailData[`wgjs_bh${(index - 1) / 5 + 1}`] = '';
  691. }
  692. } else {
  693. detailData[`name${(index - 1) / 5 + 1}`] = '';
  694. detailData[`wgjs_bh${(index - 1) / 5 + 1}`] = '';
  695. }
  696. // if (res.code === 0) {
  697. // // const { data: { 员工编号,ygxm }} = res
  698. // // console.log((index - 1) / 5 + 1)
  699. // detailData[`name${(index - 1) / 5 + 1}`] = res.data[0].ygxm
  700. // detailData[`wgjs_bh${(index - 1) / 5 + 1}`] = res.data[0].员工编号
  701. // }
  702. }
  703. break
  704. default:
  705. if (key === 'ArrowDown') {
  706. focusNext(1)
  707. } else if (key === 'ArrowUp') {
  708. focusNext(-1)
  709. } else if (key === 'Enter') {
  710. focusNext(1)
  711. }
  712. break
  713. }
  714. }
  715. const dialogSelectVisible_Yg = ref(false)
  716. const selectData_Yg = reactive([])
  717. // 处理选择框
  718. const handleSelectClick_Yg = (row, column, event) => {
  719. detailData[`name${(index_Yg - 1) / 5 + 1}`] = row.ygxm
  720. detailData[`wgjs_bh${(index_Yg - 1) / 5 + 1}`] = row.员工编号
  721. dialogSelectVisible_Yg.value = false
  722. }
  723. const currentIndex_Yg = ref(0);
  724. const GXCurrent_Yg = ref(0);
  725. const selectGX_Yg = (event) => {
  726. if (event.keyCode === 40) { // 向下箭头
  727. if (currentIndex_Yg.value < selectData_Yg.length - 1) {
  728. currentIndex_Yg.value++;
  729. setGXCurrent_Yg(selectData_Yg[currentIndex_Yg.value]);
  730. } else {
  731. currentIndex_Yg.value = 0;
  732. setGXCurrent_Yg(selectData_Yg[currentIndex_Yg.value]); // 到达最后一行时回到第一行
  733. }
  734. } else if (event.keyCode === 38) { // 向上箭头
  735. if (currentIndex_Yg.value > 0) {
  736. currentIndex_Yg.value--;
  737. setGXCurrent_Yg(selectData_Yg[currentIndex_Yg.value]);
  738. } else {
  739. currentIndex_Yg.value = selectData_Yg.length - 1;
  740. setGXCurrent_Yg(selectData_Yg[currentIndex_Yg.value]); // 到达第一行时回到最后一行
  741. }
  742. } else if (event.keyCode === 13) { // 回车键
  743. dialogSelectVisible_Yg.value = false;
  744. }
  745. }
  746. const table_Yg = ref()
  747. const setGXCurrent_Yg = (row) => {
  748. setTimeout(() => {
  749. table_Yg.value?.setCurrentRow(row)
  750. detailData[`name${(index_Yg - 1) / 5 + 1}`] = row.ygxm
  751. detailData[`wgjs_bh${(index_Yg - 1) / 5 + 1}`] = row.员工编号
  752. })
  753. }
  754. //删除
  755. const onDel = (value) => {
  756. if (currentRow.value == undefined) {
  757. ElMessage({
  758. type: 'warning',
  759. message: '未选中记录',
  760. })
  761. return
  762. }
  763. ElMessageBox.confirm(
  764. `确认删除这条数据么?`,
  765. '警告', {
  766. confirmButtonText: '确认',
  767. cancelButtonText: '取消',
  768. type: 'warning',
  769. }
  770. ).then(async () => {
  771. const response = await deleteData({
  772. UniqId: currentRow.value.UniqId
  773. });
  774. if (response.code === 0) {
  775. ElMessage({
  776. type: 'success',
  777. message: '删除成功',
  778. })
  779. //刷新页面
  780. getTableData({
  781. date: params.date,
  782. page: page.value.toString(),
  783. limit: limit.value.toString()
  784. })
  785. }
  786. })
  787. }
  788. </script>
  789. <style scoped>
  790. .JKWTree-container {
  791. display: flex;
  792. }
  793. .JKWTree-tree {
  794. width: 100%;
  795. background-color: #fff;
  796. padding: 10px;
  797. margin-right: 20px;
  798. }
  799. .JKWTree-tree h3 {
  800. font-size: 15px;
  801. font-weight: 700;
  802. margin: 10px 0;
  803. }
  804. .JKWTree-content {
  805. flex: 1;
  806. }
  807. /* 选中某行时的背景色 */
  808. :deep(.el-table__body tr.current-row)>td {
  809. background: #ff80ff !important;
  810. }
  811. </style>
  812. <style scoped>
  813. :deep(.el-table td .cell) {
  814. line-height: 25px !important;
  815. }
  816. :deep(.el-tabs__header) {
  817. margin-bottom: 0;
  818. }
  819. .search {
  820. margin-left: 0px !important;
  821. margin-right: 10px !important;
  822. }
  823. .bt {
  824. margin-left: 2px !important;
  825. padding: 3px !important;
  826. font-size: 12px;
  827. }
  828. .el-tabs__header {
  829. margin: 0px !important;
  830. }
  831. .gva-table-box {
  832. padding: 0px !important;
  833. }
  834. .mab {
  835. margin-bottom: 5px;
  836. }
  837. </style>