index.vue 27 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003
  1. <template>
  2. <div>
  3. <layout>
  4. <layout-header>
  5. <!-- 按钮 -->
  6. <el-form inline>
  7. <el-form-item>
  8. <el-input
  9. v-model="searchInfo"
  10. placeholder="搜索产品编号或产品名称"
  11. clearable
  12. style="width: 180px;"
  13. />
  14. <el-button
  15. type="primary"
  16. icon="Search"
  17. class="search"
  18. @click="handleSearch"
  19. />
  20. <el-button
  21. type="primary"
  22. icon="edit"
  23. class="bt"
  24. @click="handleShowDetail"
  25. ><i class="el-icon-edit" />查改
  26. </el-button>
  27. <el-button
  28. type="primary"
  29. icon="edit"
  30. class="bt"
  31. @click="handleShowAdd"
  32. >新增
  33. </el-button>
  34. <el-button
  35. type="primary"
  36. icon="delete"
  37. class="bt"
  38. @click="handleDelete"
  39. >删除
  40. </el-button>
  41. </el-form-item>
  42. </el-form>
  43. <!-- 弹出框 -->
  44. <div>
  45. <el-dialog
  46. v-model="dialogFormVisible"
  47. :title="type"
  48. destroy-on-close
  49. width="1200px"
  50. >
  51. <el-form
  52. id="detail-form"
  53. :model="detailData"
  54. inline
  55. label-position="left"
  56. @keyup="moveFocus"
  57. >
  58. <el-form-item
  59. label="日期"
  60. >
  61. <el-input
  62. v-model="detailData.sczl_rq"
  63. style="width: 120px;"
  64. />
  65. </el-form-item>
  66. <el-form-item
  67. label="员工编号"
  68. >
  69. <el-input
  70. v-model="detailData.sczl_bh"
  71. style="width: 100px;"
  72. />
  73. <el-input
  74. v-model="detailData.name"
  75. style="width: 100px; padding-left: 5px;"
  76. @click="selectvalue($event)"
  77. readonly
  78. />
  79. </el-form-item>
  80. <el-form-item label="组别">
  81. <el-select
  82. v-model="detailData.sczl_bzdh"
  83. placeholder=" "
  84. style="width: 80px"
  85. >
  86. <el-option
  87. label="A班"
  88. value="A班"
  89. />
  90. <el-option
  91. label="B班"
  92. value="B班"
  93. />
  94. </el-select></el-form-item>
  95. <br>
  96. <el-form-item
  97. label="计时时数"
  98. style="padding-left: 195px;"
  99. >
  100. <el-input
  101. v-model="detailData.sczl_jsss"
  102. style="width: 100px;"
  103. @click="selectvalue($event)"
  104. />
  105. </el-form-item>
  106. <el-form-item label="冲月定额">
  107. <el-select
  108. v-model="detailData.sczl_冲定额"
  109. placeholder=" "
  110. style="width: 100px"
  111. >
  112. <el-option
  113. label=""
  114. value=""
  115. />
  116. <el-option
  117. label="是"
  118. value="是"
  119. />
  120. </el-select>
  121. </el-form-item>
  122. <el-table
  123. :data="detailData.table"
  124. border
  125. tooltip-effect="dark"
  126. :row-style="{ height: '20px' }"
  127. :cell-style="{ padding: '0px' }"
  128. :header-row-style="{ height: '20px' }"
  129. :header-cell-style="{ padding: '0px' }"
  130. >
  131. <el-table-column
  132. label="工单编号"
  133. width="100"
  134. >
  135. <template #default="{ row, $index }">
  136. <el-input
  137. v-model="row.sczl_gdbh"
  138. @keyup.enter="handleEnter($index, row)"
  139. />
  140. </template>
  141. </el-table-column>
  142. <el-table-column
  143. label="印件工序"
  144. width="100"
  145. >
  146. <template #default="{ row }">
  147. <el-input
  148. v-model="row.sczl_yjGx"
  149. readonly
  150. />
  151. </template>
  152. </el-table-column>
  153. <el-table-column
  154. label="工序名称"
  155. width="100"
  156. >
  157. <template #default="{ row }">
  158. <el-input
  159. v-model="row.sczl_gxmc"
  160. readonly
  161. />
  162. </template>
  163. </el-table-column>
  164. <el-table-column label="印件名称">
  165. <template #default="{ row }">
  166. <el-input
  167. v-model="row.Gd_cpmc"
  168. readonly
  169. />
  170. </template>
  171. </el-table-column>
  172. <el-table-column
  173. label="包装产量"
  174. width="100"
  175. >
  176. <template #default="{ row }">
  177. <el-input v-model="row.sczl_cl" />
  178. </template>
  179. </el-table-column>
  180. <el-table-column
  181. label="返工产量"
  182. width="100"
  183. >
  184. <template #default="{ row }">
  185. <el-input v-model="row.sczl_返工产量" />
  186. </template>
  187. </el-table-column>
  188. <el-table-column
  189. label="每箱数量"
  190. width="100"
  191. >
  192. <template #default="{ row }">
  193. <el-input v-model="row.sczl_PgCl" />
  194. </template>
  195. </el-table-column>
  196. <el-table-column
  197. label="计产系数"
  198. width="100"
  199. >
  200. <template #default="{ row }">
  201. <el-input v-model="row.sczl_计产系数" />
  202. </template>
  203. </el-table-column>
  204. <el-table-column
  205. label="来源"
  206. width="100"
  207. >
  208. <template #default="{ row }">
  209. <el-input v-model="row.sczl_Jtbh1" />
  210. </template>
  211. </el-table-column>
  212. <el-table-column
  213. label="定额代号"
  214. width="100"
  215. >
  216. <template #default="{ row }">
  217. <el-input
  218. v-model="row.sczl_dedh"
  219. @keyup.enter.native="getDedhsubmit"
  220. />
  221. </template>
  222. </el-table-column>
  223. </el-table>
  224. <el-form-item
  225. label="其他备注"
  226. style="margin-top: 10px;"
  227. >
  228. <el-input v-model="detailData.sczl_desc" />
  229. </el-form-item>
  230. </el-form>
  231. <template #footer>
  232. <div class="dialog-footer">
  233. <el-button @click="dialogFormVisible = false">取 消</el-button>
  234. <el-button
  235. type="primary"
  236. @click="enterDialog"
  237. >确 定
  238. </el-button>
  239. </div>
  240. </template>
  241. </el-dialog>
  242. <!-- 弹出选项框 -->
  243. <el-dialog
  244. v-model="dialogSelectVisible"
  245. title="选择"
  246. destroy-on-close
  247. width="600px"
  248. @keydown="selectCP($event)"
  249. >
  250. <el-table
  251. tooltip-effect="dark"
  252. :data="selectData"
  253. row-key="ID"
  254. highlight-current-row
  255. border
  256. style="width:100%"
  257. @row-dblclick="handleSelectClick"
  258. ref="table2"
  259. >
  260. <el-table-column
  261. prop="Gd_cpmc"
  262. label="产品名称"
  263. width="300"
  264. />
  265. <el-table-column
  266. prop="Gy0_gxmc"
  267. label="产品名称"
  268. width="100"
  269. />
  270. <el-table-column
  271. prop="jyGx"
  272. label="产品名称"
  273. width="100"
  274. />
  275. </el-table>
  276. </el-dialog>
  277. </div>
  278. </layout-header>
  279. <layout>
  280. <!-- 左侧树侧形结构-->
  281. <layout-sider
  282. :resize-directions="['right']"
  283. :width="220"
  284. style="margin-right: 10px;"
  285. >
  286. <div
  287. class="JKWTree-tree"
  288. style="height: 70vh;"
  289. >
  290. <h3>包装计件单据维护</h3>
  291. <el-tree
  292. :data="treeData"
  293. highlight-current
  294. @node-click="handleNodeClick"
  295. />
  296. </div>
  297. </layout-sider>
  298. <layout-content>
  299. <!-- 数据展示 -->
  300. <div class="gva-table-box">
  301. <el-table
  302. ref="table"
  303. style="width: 100%"
  304. :data="tableData"
  305. row-key="ID"
  306. highlight-current-row
  307. border
  308. show-overflow-tooltip
  309. :row-style="{ height: '20px' }"
  310. :cell-style="{ padding: '0px' }"
  311. :header-row-style="{ height: '20px' }"
  312. :header-cell-style="{ padding: '0px' }"
  313. @row-dblclick="handleShowDetail"
  314. @current-change="(row, oldRow) => { currentRow = row}"
  315. >
  316. <el-table-column
  317. type="selection"
  318. width="55"
  319. />
  320. <!-- 循环渲染列 -->
  321. <el-table-column
  322. v-for=" column in tableColumns "
  323. :key="column.prop"
  324. :prop="column.prop"
  325. :label="column.label"
  326. width="110"
  327. sortable
  328. />
  329. </el-table>
  330. <!-- 分页 -->
  331. <div class="gva-pagination">
  332. <el-pagination
  333. v-model:current-page="page"
  334. v-model:page-size="limit"
  335. layout="total, sizes, prev, pager, next, jumper"
  336. :page-sizes="[10, 30, 50, 100]"
  337. :total="total"
  338. @current-change="handleCurrentChange"
  339. @size-change="handleSizeChange"
  340. />
  341. </div>
  342. </div>
  343. </layout-content>
  344. </layout>
  345. </layout>
  346. </div>
  347. </template>
  348. <script setup>
  349. import { Layout, LayoutContent, LayoutHeader, LayoutSider } from '@arco-design/web-vue'
  350. import { ElMessage, ElMessageBox, dayjs } from 'element-plus'
  351. // import { Download, Search, Delete } from '@element-plus/icons-vue'
  352. import { reactive, ref } from 'vue'
  353. import { getGxMc, getInfo, getLocate, getPackingSideTable, getPackingTable, updatePackingTable, getYg, DeletePackingTable, addPackingTable, getDedh } from '@/api/mes_api_gty/myapi'
  354. import { useUserStore } from '@/pinia/modules/user'
  355. const userStore = useUserStore()
  356. const sys_id='['+userStore.userInfo.userName+'/'+userStore.userInfo.nickName+']'
  357. defineOptions({
  358. name: '06PackingDocuments',
  359. })
  360. // 侧边栏功能
  361. const treeData = reactive([])
  362. const getSideData = async() => {
  363. try {
  364. const response = await getPackingSideTable()
  365. if (response.code === 0) {
  366. const transformedData = response.data.map(item => ({
  367. label: `${item.date.replace(/-/g, '.')}【单据数: ${item.counts}张】`,
  368. children: item.sys.map(sysItem => ({
  369. label: `${sysItem.sys_id} 【记录数: ${sysItem.count}张】`,
  370. params: {
  371. date: item.date.replace(/\./g, '-'),
  372. sys_id: sysItem.sys_id,
  373. },
  374. })),
  375. }))
  376. treeData.splice(0, treeData.length, ...transformedData)
  377. }
  378. } catch (e) {
  379. console.log(e)
  380. }
  381. }
  382. getSideData()
  383. // 表格功能
  384. const tableColumns = [
  385. { label: '员工编号', prop: 'sczl_bh', width: '100' },
  386. { label: '员工姓名', prop: 'name', width: '100' },
  387. { label: '生产日期', prop: 'sczl_rq', width: '100' },
  388. { label: '班组', prop: 'sczl_bzdh', width: '100' },
  389. { label: '包装产量', prop: 'sczl_cl', width: '100' },
  390. { label: '返工产量', prop: 'sczl_fgsl', width: '100' },
  391. { label: '计件产量', prop: 'sczl_jjcl', width: '100' },
  392. { label: '相关工单', prop: 'sczl_gdbh1', width: '100' },
  393. { label: '创建用户', prop: 'sys_id', width: '120' },
  394. { label: '创建时间', prop: 'sys_rq', width: '180' },
  395. { label: '修改时间', prop: 'mod_rq', width: '180' },
  396. { label: 'UNIQID', prop: 'UniqId', width: '100' },
  397. ]
  398. const tableData = reactive([])
  399. const params = {
  400. type: '',
  401. date: '',
  402. sys_id: '',
  403. gdbh: '',
  404. }
  405. const total = ref(0)
  406. const page = ref(1)
  407. const limit = ref(10)
  408. const type = ref('')
  409. const searchInfo = ref('')
  410. const currentRow = ref({})
  411. // const multipleSelection = ref([])
  412. // 获取列表数据
  413. const getTableData = async() => {
  414. try {
  415. const response = await getPackingTable({
  416. date: params.date, sys_id: params.sys_id,
  417. page: page.value.toString(), limit: limit.value.toString(),
  418. })
  419. if (response.code === 0) {
  420. total.value = response.data.total
  421. tableData.splice(0, tableData.length, ...response.data.rows)
  422. setCurrent(tableData[0])
  423. }
  424. } catch (e) {
  425. console.log(e)
  426. }
  427. }
  428. // 获取定位数据
  429. const getLocateTable = async() => {
  430. try {
  431. const response = await getLocate({
  432. gdbh: params.gdbh,
  433. page: page.value.toString(), limit: limit.value.toString(),
  434. })
  435. if (response.code === 0) {
  436. total.value = response.data.total
  437. tableData.splice(0, tableData.length, ...response.data.rows)
  438. }
  439. } catch (e) {
  440. console.log(e)
  441. }
  442. }
  443. // 删除数据
  444. const deleteTableData = async(id) => {
  445. try {
  446. const res = await DeletePackingTable({ UniqId: id })
  447. if (res.code === 0) {
  448. return 0
  449. }
  450. } catch (e) {
  451. console.log(e)
  452. }
  453. }
  454. const handleNodeClick = (node, check) => {
  455. if (node.params) {
  456. params.date = node.params.date
  457. params.sys_id = node.params.sys_id
  458. params.type = 'getTableData'
  459. page.value = 1
  460. getTableData()
  461. }
  462. }
  463. const selectvalue = (e) => {
  464. console.log(e)
  465. e.currentTarget.select();
  466. }
  467. // 定位
  468. const handleSearch = () => {
  469. params.gdbh = searchInfo.value
  470. params.type = 'getLocateTable'
  471. page.value = 1
  472. getLocateTable()
  473. }
  474. // 查改
  475. const handleShowDetail = () => {
  476. type.value = '查改'
  477. getTableInfo(currentRow.value?.UniqId)
  478. }
  479. // 删除
  480. const handleDelete = () => {
  481. console.log(currentRow.value)
  482. ElMessageBox.confirm(
  483. `确认删除这条数据么?`,
  484. '警告',
  485. {
  486. confirmButtonText: '确认',
  487. cancelButtonText: '取消',
  488. type: 'warning',
  489. }
  490. )
  491. .then(async() => {
  492. const ret = await deleteTableData(currentRow.value?.UniqId)
  493. console.log(ret)
  494. if (ret === 0) {
  495. ElMessage({
  496. type: 'success',
  497. message: '删除成功',
  498. })
  499. } else {
  500. ElMessage({
  501. type: 'error',
  502. message: '删除失败',
  503. })
  504. }
  505. })
  506. .catch(() => {
  507. ElMessage({
  508. type: 'info',
  509. message: '取消删除',
  510. })
  511. })
  512. }
  513. // 分页
  514. // #region
  515. const handleSizeChange = () => {
  516. switch (params.type) {
  517. case 'getTableData':
  518. getTableData()
  519. break
  520. case 'getLocateTable':
  521. getLocateTable()
  522. break
  523. default:
  524. break
  525. }
  526. }
  527. const handleCurrentChange = () => {
  528. switch (params.type) {
  529. case 'getTableData':
  530. getTableData()
  531. break
  532. case 'getLocateTable':
  533. getLocateTable()
  534. break
  535. default:
  536. break
  537. }
  538. }
  539. // #endregion
  540. // 详情界面
  541. const detailData = reactive({
  542. UniqId: '',
  543. selectIndex: 0,
  544. sczl_rq: '',
  545. sczl_bh: '',
  546. name: '',
  547. sczl_bzdh: '',
  548. sczl_jsss: '',
  549. sczl_冲定额: '',
  550. sczl_desc: '',
  551. table: [],
  552. })
  553. const selectData = reactive([])
  554. const table = ref()
  555. // 弹窗控制标记
  556. const dialogFormVisible = ref(false)
  557. const dialogSelectVisible = ref(false)
  558. const setCurrent = (row) => {
  559. table.value?.setCurrentRow(row)
  560. }
  561. // 获取详细信息
  562. const getTableInfo = async(id) => {
  563. try {
  564. const response = await getInfo({ UniqId: id })
  565. if (response.code === 0) {
  566. const { sczl_rq, sczl_bh, name, sczl_bzdh, sczl_jsss, sczl_冲定额, sczl_desc, ...rest } = response.data
  567. Object.assign(detailData, { sczl_rq, sczl_bh, name, sczl_bzdh, sczl_jsss, sczl_冲定额, sczl_desc })
  568. detailData.table = Array.from({ length: 6 }, (_, i) => i + 1)
  569. .map(num => {
  570. return {
  571. sczl_gdbh: rest[`sczl_gdbh${num}`],
  572. sczl_yjGx: rest[`sczl_yjGx${num}`],
  573. sczl_gxmc: rest[`sczl_gxmc${num}`],
  574. Gd_cpmc: rest[`Gd_cpmc${num}`],
  575. sczl_cl: rest[`sczl_cl${num}`],
  576. sczl_返工产量: rest[`sczl_返工产量${num}`],
  577. sczl_PgCl: rest[`sczl_PgCl${num}`],
  578. sczl_计产系数: rest[`sczl_计产系数${num}`],
  579. sczl_Jtbh1: rest[`sczl_Jtbh${num}`],
  580. sczl_dedh: rest[`sczl_dedh${num}`],
  581. }
  582. })
  583. if (type.value === '新增') {
  584. console.log(detailData)
  585. detailData.name=''
  586. detailData.sczl_bh=''
  587. detailData.sczl_bzdh=''
  588. detailData.sczl_desc=''
  589. detailData.sczl_jsss=''
  590. detailData.sczl_rq=''
  591. detailData.table.forEach(row => {
  592. for (const key in row) {
  593. row[key] = '' // 清空每行的内容
  594. }
  595. })
  596. }else{
  597. detailData.UniqId = id
  598. dialogFormVisible.value = true
  599. }
  600. if (type.value === '新增' || type.value === '编辑') {
  601. detailData.UniqId = id
  602. dialogFormVisible.value = true
  603. // 在 setTimeout 中获取元素,确保在 DOM 渲染完毕后执行
  604. setTimeout(() => {
  605. formElements = document.getElementById('detail-form').elements
  606. formElements[0].focus()
  607. }, 0)
  608. }
  609. }
  610. } catch (e) {
  611. console.log(e)
  612. }
  613. }
  614. // 获取工序名称
  615. const getTableGxMc = async(index, row) => {
  616. try {
  617. const response = await getGxMc({ gdbh: row.sczl_gdbh })
  618. if (response.code === 0) {
  619. const { Gd_cpmc, Gy0_gxmc, jyGx } = response.data[0]
  620. if (response.data.length === 1) {
  621. detailData.table[index].Gd_cpmc = Gd_cpmc
  622. detailData.table[index].sczl_yjGx = jyGx
  623. detailData.table[index].sczl_gxmc = Gy0_gxmc
  624. } else {
  625. selectData.splice(0, selectData.length, ...response.data)
  626. setCPCurrent(selectData[0])
  627. detailData.selectIndex = index
  628. dialogSelectVisible.value = true
  629. }
  630. }
  631. } catch (e) {
  632. console.log(e)
  633. }
  634. }
  635. // 更新数据
  636. const updateDetailData = async() => {
  637. const restoredData = {
  638. UniqId: detailData.UniqId,
  639. sczl_rq: detailData.sczl_rq,
  640. sczl_bh: detailData.sczl_bh,
  641. name: detailData.name,
  642. sczl_bzdh: detailData.sczl_bzdh,
  643. sczl_jsss: detailData.sczl_jsss,
  644. sczl_冲定额: detailData.sczl_冲定额,
  645. sczl_desc: detailData.sczl_desc,
  646. }
  647. detailData.table.forEach((item, index, array) => {
  648. const num = index + 1
  649. restoredData[`sczl_gdbh${num}`] = item.sczl_gdbh
  650. restoredData[`sczl_yjGx${num}`] = item.sczl_yjGx
  651. restoredData[`sczl_gxmc${num}`] = item.sczl_gxmc
  652. restoredData[`Gd_cpmc${num}`] = item.Gd_cpmc
  653. restoredData[`sczl_cl${num}`] = item.sczl_cl
  654. restoredData[`sczl_返工产量${num}`] = item.sczl_返工产量
  655. restoredData[`sczl_PgCl${num}`] = item.sczl_PgCl
  656. restoredData[`sczl_计产系数${num}`] = item.sczl_计产系数
  657. restoredData[`sczl_Jtbh${num}`] = item.sczl_Jtbh1
  658. restoredData[`sczl_dedh${num}`] = item.sczl_dedh
  659. })
  660. const res = await updatePackingTable(restoredData)
  661. if (res.code === 0) {
  662. ElMessage({
  663. type: 'success',
  664. message: '更新成功',
  665. })
  666. dialogFormVisible.value = false
  667. }
  668. }
  669. // 新增数据
  670. const handleShowAdd = async() => {
  671. type.value = '新增'
  672. if(currentRow.value.UniqId==null){
  673. detailData.table = Array.from({ length: 6 }, (_, i) => i + 1)
  674. .map(num => {
  675. return {
  676. sczl_gdbh: '',
  677. sczl_yjGx: '',
  678. sczl_gxmc: '',
  679. Gd_cpmc: '',
  680. sczl_cl: '',
  681. sczl_返工产量: '',
  682. sczl_PgCl: '',
  683. sczl_计产系数: '',
  684. sczl_Jtbh1: '',
  685. sczl_dedh: '',
  686. }
  687. })
  688. dialogFormVisible.value = true
  689. }else{
  690. await getTableInfo(currentRow.value?.UniqId)
  691. // 默认日期为前一天的日期
  692. const date = dayjs().subtract(1, 'day').format('YYYY-MM-DD')
  693. detailData.sczl_rq = date
  694. }
  695. }
  696. const addDetailData = async() => {
  697. const restoredData = {
  698. sys_id:sys_id,
  699. sczl_rq: detailData.sczl_rq,
  700. sczl_bh: detailData.sczl_bh,
  701. // name: detailData.name,
  702. sczl_bzdh: detailData.sczl_bzdh,
  703. sczl_jsss: detailData.sczl_jsss,
  704. sczl_冲定额: detailData.sczl_冲定额,
  705. sczl_desc: detailData.sczl_desc,
  706. }
  707. detailData.table.forEach((item, index, array) => {
  708. const num = index + 1
  709. restoredData[`sczl_gdbh${num}`] = item.sczl_gdbh
  710. restoredData[`sczl_yjGx${num}`] = item.sczl_yjGx
  711. restoredData[`sczl_gxmc${num}`] = item.sczl_gxmc
  712. // restoredData[`Gd_cpmc${num}`] = item.Gd_cpmc
  713. restoredData[`sczl_cl${num}`] = item.sczl_cl
  714. restoredData[`sczl_返工产量${num}`] = item.sczl_返工产量
  715. restoredData[`sczl_PgCl${num}`] = item.sczl_PgCl
  716. restoredData[`sczl_计产系数${num}`] = item.sczl_计产系数
  717. restoredData[`sczl_Jtbh${num}`] = item.sczl_Jtbh1
  718. restoredData[`sczl_dedh${num}`] = item.sczl_dedh
  719. })
  720. const res = await addPackingTable(restoredData)
  721. console.log(restoredData)
  722. console.log(res)
  723. if (res.code === 0) {
  724. ElMessage({
  725. type: 'success',
  726. message: '新增成功',
  727. })
  728. dialogFormVisible.value = false
  729. getTableData()
  730. getSideData()
  731. }
  732. }
  733. const handleGetYg = async() => {
  734. try {
  735. const res = await getYg({ sczl_bh: detailData.sczl_bh })
  736. if (res.code === 0) {
  737. detailData.name = res.data.ygxm
  738. } else {
  739. detailData.name = ''
  740. }
  741. } catch (e) {
  742. console.log(e)
  743. }
  744. }
  745. // 处理选择框回车操作
  746. const handleEnter = (index, row) => {
  747. if (row.sczl_gdbh === '') {
  748. detailData.table[index].sczl_yjGx = ''
  749. detailData.table[index].sczl_gxmc = ''
  750. detailData.table[index].Gd_cpmc = ''
  751. } else {
  752. getTableGxMc(index, row)
  753. }
  754. }
  755. // 处理选择框
  756. const handleSelectClick = (row, column, event) => {
  757. const { Gd_cpmc, Gy0_gxmc, jyGx } = row
  758. const index = detailData.selectIndex
  759. detailData.table[index].Gd_cpmc = Gd_cpmc
  760. detailData.table[index].sczl_yjGx = jyGx
  761. detailData.table[index].sczl_gxmc = Gy0_gxmc
  762. dialogSelectVisible.value = false
  763. }
  764. const table2=ref()
  765. const setCPCurrent = (row) => {
  766. setTimeout(()=>{
  767. table2.value?.setCurrentRow(row)
  768. const { Gd_cpmc, Gy0_gxmc, jyGx } = row
  769. const index = detailData.selectIndex
  770. detailData.table[index].Gd_cpmc = Gd_cpmc
  771. detailData.table[index].sczl_yjGx = jyGx
  772. detailData.table[index].sczl_gxmc = Gy0_gxmc
  773. })
  774. }
  775. const CPIndex = ref(0);
  776. const JYCurrent = ref(0);
  777. const selectCP = (event) => {
  778. if (event.keyCode === 40) { // 向下箭头
  779. if (CPIndex.value < selectData.length - 1) {
  780. CPIndex.value++;
  781. setCPCurrent(selectData[CPIndex.value]);
  782. } else {
  783. CPIndex.value = 0;
  784. setCPCurrent(selectData[CPIndex.value]); // 到达最后一行时回到第一行
  785. }
  786. } else if (event.keyCode === 38) { // 向上箭头
  787. if (CPIndex.value > 0) {
  788. CPIndex.value--;
  789. setCPCurrent(selectData[CPIndex.value]);
  790. } else {
  791. CPIndex.value = selectData.length - 1;
  792. setCPCurrent(selectData[CPIndex.value]); // 到达第一行时回到最后一行
  793. }
  794. } else if (event.keyCode === 13) { // 回车键
  795. dialogSelectVisible.value = false
  796. }
  797. }
  798. // 弹窗确定
  799. const enterDialog = () => {
  800. if (type.value === '查改') {
  801. updateDetailData()
  802. } else if (type.value === '新增') {
  803. addDetailData()
  804. }
  805. }
  806. // 定额代号回车事件
  807. const getDedhsubmit = () => {}
  808. let formElements
  809. const moveFocus = (event) => {
  810. const index = Array.from(formElements).indexOf(event.target)
  811. const key = event.key
  812. event.preventDefault()
  813. switch (index) {
  814. case 0:
  815. if (key === 'ArrowDown') {
  816. formElements[1].focus()
  817. formElements[1].select()
  818. } else if (key === 'ArrowUp') {
  819. formElements[formElements.length - 1].focus()
  820. formElements[formElements.length - 1].select()
  821. } else if (key === 'Enter') {
  822. formElements[1].focus()
  823. formElements[1].select()
  824. }
  825. break
  826. case 1:
  827. if (key === 'ArrowDown') {
  828. formElements[3].focus()
  829. formElements[3].select()
  830. handleGetYg()
  831. } else if (key === 'ArrowUp') {
  832. formElements[0].focus()
  833. formElements[0].select()
  834. handleGetYg()
  835. } else if (key === 'Enter') {
  836. formElements[3].focus()
  837. formElements[3].select()
  838. handleGetYg()
  839. }
  840. break
  841. case 3:
  842. if (key === 'ArrowDown') {
  843. formElements[4].focus()
  844. formElements[4].select()
  845. } else if (key === 'ArrowUp') {
  846. formElements[1].focus()
  847. formElements[1].select()
  848. } else if (key === 'Enter') {
  849. formElements[4].focus()
  850. formElements[4].select()
  851. }
  852. break
  853. case formElements.length - 1 :
  854. if (key === 'ArrowDown') {
  855. formElements[0].focus()
  856. formElements[0].select()
  857. } else if (key === 'ArrowUp') {
  858. formElements[index - 1].focus()
  859. formElements[index - 1].select()
  860. } else if (key === 'Enter') {
  861. formElements[0].focus()
  862. formElements[0].select()
  863. }
  864. break
  865. default:
  866. if (key === 'ArrowDown') {
  867. formElements[index + 1].focus()
  868. formElements[index + 1].select()
  869. } else if (key === 'ArrowUp') {
  870. formElements[index - 1].focus()
  871. formElements[index - 1].select()
  872. } else if (key === 'Enter') {
  873. formElements[index + 1].focus()
  874. formElements[index + 1].select()
  875. }
  876. break
  877. }
  878. }
  879. </script>
  880. <style scoped>
  881. :deep(.plan-usage-low div) {
  882. color: red !important;
  883. }
  884. .JKWTree-container {
  885. display: flex;
  886. }
  887. .JKWTree-tree {
  888. width: 100%;
  889. background-color: #fff;
  890. /*background-color: rgba(241, 224, 224, 0.99);*/
  891. padding: 10px;
  892. margin-right: 20px;
  893. }
  894. .JKWTree-tree h3 {
  895. font-size: 15px;
  896. font-weight: 700;
  897. margin: 10px 0;
  898. }
  899. .JKWTree-content {
  900. flex: 1;
  901. }
  902. :deep(.el-table__body .warning-row) {
  903. background: #FFFF80 !important;
  904. }
  905. /* 选中某行时的背景色 */
  906. :deep(.el-table__body tr.current-row) > td {
  907. background: #ff80ff !important;
  908. }
  909. :deep(.el-table .bg-yellow) {
  910. background: yellow;
  911. }
  912. </style>
  913. <style scoped>
  914. :deep(.el-table td .cell) {
  915. line-height: 25px !important;
  916. }
  917. :deep(.el-tabs__header) {
  918. margin-bottom: 0;
  919. }
  920. .search {
  921. margin-left: 0px !important;
  922. margin-right: 10px !important;
  923. }
  924. .bt {
  925. margin-left: 2px !important;
  926. padding: 3px !important;
  927. font-size: 12px;
  928. }
  929. .el-tabs__header {
  930. margin: 0px !important;
  931. }
  932. .gva-table-box {
  933. padding: 0px !important;
  934. }
  935. .mab {
  936. margin-bottom: 5px;
  937. }
  938. </style>