index.vue 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177
  1. <template>
  2. <div>
  3. <el-container>
  4. <!-- 左侧树形结构 -->
  5. <el-scrollbar max-height="75vh">
  6. <!-- <el-aside>
  7. <div class="JKWTree-tree">
  8. <h3>工单核验单维护</h3>
  9. <el-tree
  10. :data="treeData"
  11. highlight-current
  12. @node-click="handleNodeClick"
  13. />
  14. </div>
  15. </el-aside> -->
  16. <layout-sider
  17. :resize-directions="['right']"
  18. :width="220"
  19. style="margin-right: 50px;"
  20. >
  21. <div
  22. class="JKWTree-tree"
  23. style="height: 70vh;"
  24. >
  25. <h3>工单核验单维护</h3>
  26. <el-tree
  27. :data="treeData"
  28. highlight-current
  29. @node-click="handleNodeClick"
  30. />
  31. </div>
  32. </layout-sider>
  33. </el-scrollbar>
  34. <el-container>
  35. <el-main>
  36. <div class="gva-table-box">
  37. <!-- 按钮区域 -->
  38. <div class="gva-btn-list">
  39. <el-row :span="6">
  40. <el-input
  41. v-model="searchInfo"
  42. placeholder="输入工单编号"
  43. />
  44. </el-row>
  45. <el-button
  46. type="primary"
  47. :icon="Search"
  48. class="bt"
  49. @click="handleSearch"
  50. >搜索
  51. </el-button>
  52. <el-button
  53. type="primary"
  54. icon="copy-document"
  55. class="bt"
  56. @click="dialogMrhjtj = true"
  57. >每日核检统计
  58. </el-button>
  59. <el-button
  60. type="primary"
  61. icon="copy-document"
  62. class="bt"
  63. @click="showGdzjfptj"
  64. >工单质检废品统计
  65. </el-button>
  66. <el-button
  67. type="primary"
  68. class="bt" icon="plus"
  69. @click="handleShowAdd"
  70. >新增
  71. </el-button>
  72. <div style="margin-left: auto;">
  73. <!-- <el-button
  74. type="primary"
  75. :icon="Download"
  76. class="bt"
  77. @click="exportExcel"
  78. >导出到Excel</el-button> -->
  79. </div>
  80. </div>
  81. <!-- 数据展示 -->
  82. <el-table
  83. ref="table"
  84. style="width: 100%"
  85. :data="tableData"
  86. row-key="ID"
  87. highlight-current-row
  88. border
  89. show-overflow-tooltip
  90. :row-style="{ height: '20px' }"
  91. :cell-style="{ padding: '0px' }"
  92. :header-row-style="{ height: '20px' }"
  93. :header-cell-style="{ padding: '0px' }"
  94. @row-click="handleSelectChange"
  95. @row-dblclick="doubleClick"
  96. >
  97. <el-table-column
  98. type="selection"
  99. width="55"
  100. />
  101. <!-- 循环渲染表格列 -->
  102. <el-table-column
  103. v-for="column in tableColumns"
  104. :key="column.prop"
  105. :prop="column.prop"
  106. :label="column.label"
  107. :width="column.width"
  108. sortable
  109. />
  110. </el-table>
  111. <!-- 分页 -->
  112. <div class="gva-pagination">
  113. <el-pagination
  114. v-model:current-page="page"
  115. v-model:page-size="limit"
  116. layout="total, sizes, prev, pager, next, jumper"
  117. :page-sizes="[10, 30, 50, 100]"
  118. :total="total"
  119. @current-change="handleCurrentChange"
  120. @size-change="handleSizeChange"
  121. />
  122. </div>
  123. </div>
  124. <!-- 弹出框 -->
  125. <el-dialog
  126. v-model="dialogFormVisible"
  127. :before-close="closeDialog"
  128. :title="type"
  129. destroy-on-close
  130. width="70%"
  131. style="position: fixed; top: 35%; left: 50%; transform: translate(-50%, -50%);"
  132. >
  133. <el-form
  134. ref="elFormRef"
  135. :model="detailData"
  136. inline
  137. label-position="left"
  138. :rules="rule"
  139. id="detail-form"
  140. @keyup="moveFocus"
  141. >
  142. <el-form-item
  143. label="日期"
  144. >
  145. <el-date-picker
  146. v-model="detailData.qczl_rq"
  147. type="date"
  148. style="width: 150px;"
  149. />
  150. <!-- <el-input
  151. v-model="detailData.qczl_rq"
  152. style="width: 120px;"
  153. />-->
  154. </el-form-item>
  155. <el-form-item
  156. label="工单编号"
  157. >
  158. <el-input
  159. v-model="detailData.qczl_gdbh"
  160. style="width: 100px;"
  161. @keyup.enter="handleGdbhEnter"
  162. />
  163. </el-form-item>
  164. <el-form-item label="拼印主工单">
  165. <el-input
  166. v-model="detailData.qczl_Pygd"
  167. style="width: 100px;"
  168. />
  169. </el-form-item>
  170. <el-form-item
  171. label="产品名称"
  172. >
  173. <el-input
  174. v-model="detailData.Gd_cpmc"
  175. style="width: 400px;"
  176. readonly
  177. />
  178. </el-form-item>
  179. <br>
  180. <el-form-item
  181. label="印件号"
  182. >
  183. <el-input
  184. v-model="detailData.qczl_yjno"
  185. style="width: 60px;"
  186. />
  187. </el-form-item>
  188. <el-form-item
  189. label="印件名称"
  190. style="margin-left: 47px"
  191. >
  192. <el-input
  193. v-model="detailData.yj_yjmc"
  194. style="width: 500px;"
  195. />
  196. </el-form-item>
  197. <el-form-item
  198. label="废品总数"
  199. >
  200. <el-input
  201. v-model="detailData.qczl_fp"
  202. style="width: 100px;"
  203. />
  204. </el-form-item>
  205. <br>
  206. <el-form-item
  207. label="工序"
  208. >
  209. <el-input
  210. v-model="detailData.qczl_gxmc"
  211. style="width: 200px;"
  212. @keyup.enter.native="getgxsubmit"
  213. />
  214. </el-form-item>
  215. <el-form-item
  216. label="工序号"
  217. >
  218. <el-input
  219. v-model="detailData.qczl_gxh"
  220. style="width: 100px;"
  221. />
  222. </el-form-item>
  223. <el-form-item
  224. label="总流程号"
  225. >
  226. <el-input
  227. v-model="detailData.total_liucheng"
  228. style="width: 100px;"
  229. />
  230. </el-form-item>
  231. <el-form-item
  232. label="流程单号"
  233. >
  234. <el-input
  235. v-model="detailData.qczl_num"
  236. style="width: 60px; margin-left: 5px;"
  237. />
  238. <el-input
  239. v-model="detailData.qczl_NumDesc1"
  240. style="width: 60px; margin-left: 5px;"
  241. />
  242. <el-input
  243. v-model="detailData.qczl_NumDesc2"
  244. style="width: 60px; margin-left: 5px;"
  245. />
  246. <el-input
  247. v-model="detailData.qczl_NumDesc3"
  248. style="width: 60px; margin-left: 5px;"
  249. />
  250. <el-input
  251. v-model="detailData.qczl_NumDesc4"
  252. style="width: 60px; margin-left: 5px;"
  253. />
  254. <el-input
  255. v-model="detailData.qczl_NumDesc5"
  256. style="width: 60px; margin-left: 5px;"
  257. />
  258. <el-input
  259. v-model="detailData.qczl_NumDesc6"
  260. style="width: 60px; margin-left: 5px;"
  261. />
  262. <el-input
  263. v-model="detailData.qczl_NumDesc7"
  264. style="width: 60px; margin-left: 5px;"
  265. />
  266. <el-input
  267. v-model="detailData.qczl_NumDesc8"
  268. style="width: 60px; margin-left: 5px;"
  269. />
  270. </el-form-item>
  271. <el-form-item
  272. label="备注"
  273. >
  274. <el-input
  275. v-model="detailData.qczl_NumDesc"
  276. style="width: 200px;"
  277. />
  278. </el-form-item>
  279. <el-scrollbar height="400px">
  280. <el-table
  281. :data="detailData.table"
  282. border
  283. tooltip-effect="dark"
  284. :row-style="{ height: '20px' }"
  285. :cell-style="{ padding: '0px' }"
  286. :header-row-style="{ height: '20px' }"
  287. :header-cell-style="{ padding: '0px' }"
  288. >
  289. <el-table-column
  290. label="废品类别"
  291. width="200"
  292. >
  293. <template #default="{ row, $index }">
  294. <el-input
  295. v-model="row.fp_lb"
  296. @keyup.enter="handleFplbEnter($index, row)"
  297. />
  298. </template>
  299. </el-table-column>
  300. <el-table-column
  301. label="数量"
  302. width="100"
  303. >
  304. <template #default="{ row, $index }">
  305. <el-input
  306. v-model="row.fp_sl"
  307. @keyup.enter="handleFpslEnter($index, row)"
  308. />
  309. </template>
  310. </el-table-column>
  311. <el-table-column
  312. label="工序及责任机长"
  313. width="500"
  314. >
  315. <template #default="{ row }">
  316. <el-input
  317. v-model="row.fp_gxmc"
  318. />
  319. </template>
  320. </el-table-column>
  321. <el-table-column
  322. label=""
  323. width="100"
  324. >
  325. <template #default="{ row }">
  326. <el-input
  327. v-model="row.fp_bz"
  328. />
  329. </template>
  330. </el-table-column>
  331. <el-table-column
  332. label=""
  333. width="100"
  334. >
  335. <template #default="{ row }">
  336. <el-input
  337. v-model="row.fp_bh"
  338. />
  339. </template>
  340. </el-table-column>
  341. <el-table-column
  342. label=""
  343. width="100"
  344. >
  345. <template #default="{ row }">
  346. <el-input
  347. v-model="row.fp_name"
  348. />
  349. </template>
  350. </el-table-column>
  351. </el-table>
  352. </el-scrollbar>
  353. </el-form>
  354. <template #footer>
  355. <div class="dialog-footer">
  356. <el-button @click="closeDialog">取 消</el-button>
  357. <el-button
  358. type="primary"
  359. @click="enterDialog"
  360. >确 定
  361. </el-button>
  362. </div>
  363. </template>
  364. </el-dialog>
  365. <!-- 废品类别弹出选项框 -->
  366. <el-dialog
  367. v-model="dialogSelectVisible1"
  368. title="选择"
  369. destroy-on-close
  370. width="600px"
  371. >
  372. <el-tree
  373. :data="selecTreeData"
  374. :props="defaultProps"
  375. highlight-current
  376. @node-click="handleFplbClick"
  377. />
  378. </el-dialog>
  379. <!-- 弹出选项框 数量 -->
  380. <el-dialog
  381. v-model="dialogSelectVisible2"
  382. title="选择"
  383. destroy-on-close
  384. width="800px"
  385. @keydown="selectSL($event)"
  386. >
  387. <el-table
  388. tooltip-effect="dark"
  389. :data="selectData"
  390. row-key="ID"
  391. highlight-current-row
  392. border
  393. style="width:100%"
  394. @row-dblclick="handleSelectClick"
  395. ref="table2"
  396. >
  397. <el-table-column
  398. v-for=" column in selectColumns "
  399. :key="column.prop"
  400. :prop="column.prop"
  401. :label="column.label"
  402. :width="column.width"
  403. />
  404. </el-table>
  405. </el-dialog>
  406. <el-dialog
  407. v-model="GetjtbhVisible"
  408. title="选择"
  409. destroy-on-close
  410. width="600px"
  411. >
  412. <el-table
  413. tooltip-effect="dark"
  414. :data="JTBHselectData"
  415. row-key="ID"
  416. highlight-current-row="true"
  417. border
  418. style="width:100%"
  419. @row-dblclick="JTBHSelectClick"
  420. >
  421. <el-table-column
  422. prop="gxh"
  423. label="工序号"
  424. width="70"
  425. />
  426. <el-table-column
  427. prop="gxmc"
  428. label="工序名称"
  429. width="150"
  430. />
  431. <el-table-column
  432. prop="addGxmc"
  433. label="工序名称"
  434. width="150"
  435. />
  436. </el-table>
  437. </el-dialog>
  438. <!-- 废品日统计 -->
  439. <Meirihejiantongji
  440. v-if="dialogMrhjtj"
  441. v-model="dialogMrhjtj"
  442. />
  443. <!-- 工单质检废品统计 -->
  444. <Gongdanzhijianfeipintongji
  445. v-if="dialogGdzjfptj"
  446. v-model="dialogGdzjfptj"
  447. :val="value1"
  448. />
  449. <!-- 测试图表 -->
  450. <Shebeizhuangtai
  451. v-if="dialogSbyxgl"
  452. v-model="dialogSbyxgl"
  453. title="【01.30 08:30】【JY01#--海德堡对开八色平版胶印机(JY08-01)】【2311116-->钻石(荷花)盒包装纸】【01--胶印】"
  454. />
  455. </el-main>
  456. </el-container>
  457. </el-container>
  458. </div>
  459. </template>
  460. <script setup>
  461. import {
  462. createCompany,
  463. deleteCompany,
  464. deleteCompanyByIds,
  465. updateCompany,
  466. findCompany,
  467. getCompanyList
  468. } from '@/api/company'
  469. // 全量引入格式化工具 请按需保留
  470. import { ElMessage } from 'element-plus'
  471. import { Search, Refresh, Download } from '@element-plus/icons-vue'
  472. import { ref, reactive } from 'vue'
  473. import { getSide, getTable, getOneWorkOrder, getOrderInfo, getGxAndLeader, getYjInfo, getWastInfo, updateData, add } from '@/api/mes_api_gty/workOrderVerification'
  474. import Meirihejiantongji from '@/view/performance/09-workOrderVerification/componets/meirihejiantongji.vue'
  475. import Gongdanzhijianfeipintongji from '@/view/performance/09-workOrderVerification/componets/gongdanzhijianfeipintongji.vue'
  476. import Shebeizhuangtai from '@/view/performance/09-workOrderVerification/componets/shebeizhuangtai.vue'
  477. import { Layout, LayoutContent, LayoutHeader, LayoutSider } from '@arco-design/web-vue'
  478. import { useUserStore } from '@/pinia/modules/user'
  479. const userStore = useUserStore()
  480. const sys_id='['+userStore.userInfo.userName+'/'+userStore.userInfo.nickName+']'
  481. defineOptions({
  482. name: '06PackingDocuments'
  483. })
  484. // 侧边栏数据请求
  485. const treeData = reactive([])
  486. const getSideData = async() => {
  487. const response = await getSide()
  488. if (response.code === 0) {
  489. const transformedData = response.data.map(item => ({
  490. label: `${item.date.replace(/-/g, '.')}【单据数: ${item.counts}张】`,
  491. children: item.sys.map(sysItem => ({
  492. label: `${sysItem.sys_id} 【记录数: ${sysItem.count}张】`,
  493. params: {
  494. date: item.date.replace(/\./g, '-'),
  495. sys_id: sysItem.sys_id,
  496. },
  497. })),
  498. }))
  499. treeData.splice(0, treeData.length, ...transformedData)
  500. }
  501. }
  502. getSideData()
  503. // 验证规则
  504. const rule = reactive({
  505. })
  506. const elFormRef = ref()
  507. const elSearchFormRef = ref()
  508. // =========== 表格控制部分 ===========
  509. const tableColumns = [
  510. { label: '工单编号', prop: 'qczl_gdbh', width: '120' },
  511. { label: '印件号', prop: 'qczl_yjno', width: '100' },
  512. { label: '印件名称', prop: 'Gd_cpmc', width: '400' },
  513. { label: '日期', prop: 'qczl_rq', width: '100' },
  514. { label: '流程单号', prop: 'qczl_num', width: '120' },
  515. { label: '流程单备注', prop: 'qczl_NumDesc', width: '120' },
  516. { label: '总废品', prop: 'qczl_fp', width: '100' },
  517. { label: '废品1', prop: 'sl_lb1', width: '250' },
  518. { label: '废品2', prop: 'sl_lb2', width: '250' },
  519. { label: '废品3', prop: 'sl_lb3', width: '250' },
  520. { label: '废品4', prop: 'sl_lb4', width: '250' },
  521. { label: '废品5', prop: 'sl_lb5', width: '250' },
  522. { label: '废品6', prop: 'sl_lb6', width: '250' },
  523. { label: '废品7', prop: 'sl_lb7', width: '250' },
  524. { label: '废品8', prop: 'sl_lb8', width: '250' },
  525. { label: '废品9', prop: 'sl_lb9', width: '250' },
  526. { label: '废品10', prop: 'sl_lb10', width: '250' },
  527. { label: '废品11', prop: 'sl_lb11', width: '250' },
  528. { label: '废品12', prop: 'sl_lb12', width: '250' },
  529. { label: '废品13', prop: 'sl_lb13', width: '250' },
  530. { label: '废品14', prop: 'sl_lb14', width: '250' },
  531. { label: '废品15', prop: 'sl_lb15', width: '250' },
  532. { label: '废品16', prop: 'sl_lb16', width: '250' },
  533. { label: '废品17', prop: 'sl_lb17', width: '250' },
  534. { label: '创建用户', prop: 'sys_id', width: '200' }
  535. ]
  536. const tableData = reactive([])
  537. const GetjtbhVisible = ref(false)
  538. const total = ref(0)
  539. const page = ref(1)
  540. const limit = ref(10)
  541. const JTBHselectData = reactive([])
  542. const searchInfo = ref('')
  543. const params = {
  544. date: '',
  545. sys_id: '',
  546. order: '',
  547. page: page.value.toString(),
  548. limit: limit.value.toString(),
  549. }
  550. // 获取工序
  551. const getgxsubmit = () => {
  552. GetJtbh()
  553. }
  554. const GetJtbh = async() => {
  555. try {
  556. const { qczl_gdbh, qczl_yjno } = detailData
  557. const response = await getYjInfo({ order: qczl_gdbh, yj_no: qczl_yjno })
  558. if (response.code === 0) {
  559. const data = response.data
  560. if (data) {
  561. const tableData = data.gx_data.map(item => ({
  562. gxh: item.Gy0_gxh,
  563. gxmc: item.Gy0_gxmc + (item.Add_gxmc === '' ? '' : '-' + item.Add_gxmc),
  564. // addGxmc: item.Add_gxmc
  565. }))
  566. console.log(tableData)
  567. JTBHselectData.splice(0, JTBHselectData.length, ...tableData)
  568. GetjtbhVisible.value = true
  569. // Now you can use the tableData to populate your table
  570. } else {
  571. console.log('No data found')
  572. }
  573. } else {
  574. console.log('Error: ', response.msg)
  575. }
  576. } catch (error) {
  577. console.error('Error fetching data: ', error)
  578. }
  579. }
  580. const JTBHSelectClick = (row, column, event) => {
  581. const { gxh, gxmc } = row
  582. detailData.qczl_gxmc = gxh + '-' + gxmc
  583. detailData.qczl_gxh = gxh
  584. GetjtbhVisible.value = false
  585. }
  586. // 批量删除控制标记
  587. const deleteVisible = ref(false)
  588. const multipleSelection = ref([])
  589. const minUniqId = ref('')
  590. const getTableData = async() => {
  591. const response = await getTable(params)
  592. if (response.code === 0) {
  593. total.value = response.data.total
  594. // Object.assign(tableData, response.data.rows)
  595. tableData.splice(0, tableData.length, ...response.data.rows)
  596. minUniqId.value = Math.min(...tableData.map(row => row.UniqId))
  597. }
  598. }
  599. // 左侧树结构点击
  600. const handleNodeClick = (node, check) => {
  601. if (node.params) {
  602. params.date = node.params.date
  603. params.sys_id = node.params.sys_id
  604. page.value = 1
  605. handleCurrentChange()
  606. }
  607. }
  608. // 搜索
  609. function handleSearch() {
  610. params.sys_id = ''
  611. params.date = ''
  612. params.order = searchInfo.value
  613. page.value = 1
  614. handleCurrentChange()
  615. }
  616. // 分页
  617. const handleSizeChange = () => {
  618. params.limit = limit.value.toString()
  619. getTableData()
  620. }
  621. // 页面跳转
  622. const handleCurrentChange = () => {
  623. params.page = page.value.toString()
  624. getTableData()
  625. }
  626. // ============== 详情页面 ==============
  627. const detailData = reactive({})
  628. // const selectData = reactive([])
  629. const selectColumns = [
  630. { label: '', prop: 'sczl_gxmc', width: '500' },
  631. { label: '', prop: 'sczl_jtbh', width: '100' },
  632. { label: '', prop: 'sczl_bzdh', width: '100' },
  633. { label: '', prop: 'name', width: '100' },
  634. ]
  635. let selecTreeData = []
  636. // 行为控制标记(弹窗内部需要增还是改)
  637. const type = ref('')
  638. // 弹窗控制标记
  639. const dialogFormVisible = ref(false)
  640. const dialogSelectVisible1 = ref(false)
  641. const dialogSelectVisible2 = ref(false)
  642. let selectIndex = 0
  643. const getDetailData = async(id) => {
  644. try {
  645. const res = await getOneWorkOrder({ UniqId: id })
  646. if (res.code === 0) {
  647. const obj = res.data
  648. // 裁剪返回数据的前后空格
  649. for (const key in obj) {
  650. if (Object.prototype.hasOwnProperty.call(obj, key) && typeof obj[key] === 'string') {
  651. obj[key] = obj[key].trim()
  652. }
  653. }
  654. // 修改日期格式
  655. if (Object.prototype.hasOwnProperty.call(obj, 'qczl_rq') && typeof obj['qczl_rq'] === 'string') {
  656. obj['qczl_rq'] = obj['qczl_rq'].split(' ')[0]
  657. }
  658. Object.assign(detailData, obj)
  659. const table = []
  660. // 循环13行数据
  661. for (let i = 1; i <= 13; i++) {
  662. table.push({
  663. fp_lb: detailData[`fp_lb${i}`] || '',
  664. fp_sl: detailData[`fp_sl${i}`] || '',
  665. fp_gxmc: detailData[`fp_gxmc${i}`] || '',
  666. fp_bz: detailData[`fp_bz${i}`] || '',
  667. fp_bh: detailData[`fp_bh${i}`] || '',
  668. fp_name: detailData[`fp_name${i}`] || '',
  669. })
  670. // 从原对象中删除这些属性
  671. delete detailData[`fp_lb${i}`]
  672. delete detailData[`fp_sl${i}`]
  673. delete detailData[`fp_gxmc${i}`]
  674. delete detailData[`fp_bz${i}`]
  675. delete detailData[`fp_bh${i}`]
  676. delete detailData[`fp_name${i}`]
  677. }
  678. detailData.table = table
  679. try {
  680. const res = await getOrderInfo({ order: detailData.qczl_gdbh })
  681. if (res.code === 0) {
  682. detailData.Gd_cpmc = res.data.Gd_cpmc
  683. // dialogFormVisible.value = true
  684. showDialog()
  685. }
  686. } catch (e) {
  687. console.log(e)
  688. }
  689. }
  690. } catch (e) {
  691. console.log(e)
  692. }
  693. }
  694. // 工单编号回车
  695. const handleGdbhEnter = async() => {
  696. const res = await getOrderInfo({ order: detailData.qczl_gdbh })
  697. if (res.code === 0) {
  698. const { Gd_cpmc, yj_Yjno, yj_yjmc } = res.data
  699. detailData.Gd_cpmc = Gd_cpmc
  700. detailData.qczl_yjno = yj_Yjno
  701. detailData.yj_yjmc = yj_yjmc
  702. }
  703. }
  704. // 废品类别回车
  705. const handleFplbEnter = async(index, row) => {
  706. let res
  707. try {
  708. res = await getWastInfo({ search: row.fp_lb })
  709. if (res.code !== 0) {
  710. return
  711. }
  712. } catch (e) {
  713. console.log(e)
  714. return
  715. }
  716. const obj = res.data
  717. const treeData = []
  718. for (const category in obj) {
  719. if (Object.prototype.hasOwnProperty.call(obj, category)) {
  720. const children = []
  721. for (const subCategory in obj[category]) {
  722. if (Object.prototype.hasOwnProperty.call(obj[category], subCategory)) {
  723. const subChildren = obj[category][subCategory].map(item => {
  724. return { label: item }
  725. })
  726. children.push({
  727. label: subCategory,
  728. children: subChildren
  729. })
  730. }
  731. }
  732. treeData.push({
  733. label: category,
  734. children: children
  735. })
  736. }
  737. }
  738. selecTreeData = treeData
  739. selectIndex = index
  740. dialogSelectVisible1.value = true
  741. }
  742. const handleFplbClick = (node, check) => {
  743. if (!node.children) {
  744. detailData.table[selectIndex].fp_lb = node.label
  745. dialogSelectVisible1.value = false
  746. }
  747. }
  748. let selectData = [] // 将const改为let
  749. const handleFpslEnter = async (index, row) => {
  750. if (row.fp_sl === '0') {
  751. detailData.table[index].fp_gxmc = ''
  752. detailData.table[index].fp_bz = ''
  753. detailData.table[index].fp_bh = ''
  754. detailData.table[index].fp_name = ''
  755. return
  756. }
  757. const params = {
  758. type: row.fp_lb,
  759. order: detailData.qczl_gdbh,
  760. }
  761. let res
  762. try {
  763. res = await getGxAndLeader(params)
  764. if (res.code !== 0) {
  765. return
  766. }
  767. } catch (e) {
  768. console.log(e)
  769. return
  770. }
  771. // 解译乱码并填充到selectData
  772. const decodedData = res.data.map(item => {
  773. return {
  774. sczl_gxmc: decodeEntities(item.sczl_gxmc), // 解译乱码函数
  775. sczl_bzdh: item.sczl_bzdh,
  776. sczl_jtbbh: item.sczl_jtbh,
  777. sczl_bh1: item.sczl_bh1,
  778. name: item.name.trim() // 去除姓名两端的空格
  779. }
  780. })
  781. selectData = decodedData // 对selectData进行赋值
  782. setCurrent(selectData[0])
  783. dialogSelectVisible2.value = true
  784. }
  785. // 解译HTML实体编码的函数
  786. function decodeEntities(encodedString) {
  787. const textArea = document.createElement('textarea')
  788. textArea.innerHTML = encodedString
  789. return textArea.value
  790. }
  791. // 双击表格操作
  792. function doubleClick(row, column, event) {
  793. type.value = '查改'
  794. getDetailData(row.UniqId)
  795. }
  796. // 处理选择框回车操作
  797. const handleSelectClick = (row, column, event) => {
  798. const { sczl_gxmc, sczl_bzdh, sczl_bh1, name } = row
  799. const index = selectIndex
  800. detailData.table[index].fp_gxmc = sczl_gxmc
  801. detailData.table[index].fp_bz = sczl_bzdh
  802. detailData.table[index].fp_bh = sczl_bh1
  803. detailData.table[index].fp_name = name
  804. dialogSelectVisible2.value = false
  805. }
  806. const table2 = ref()
  807. const setCurrent = (row) => {
  808. setTimeout(()=>{
  809. table2.value?.setCurrentRow(row)
  810. // SelectClick(row)
  811. // console.log(row)
  812. // console.log(table)
  813. const { sczl_gxmc, sczl_bzdh, sczl_bh1, name } = row
  814. const index = selectIndex
  815. detailData.table[index].fp_gxmc = sczl_gxmc
  816. detailData.table[index].fp_bz = sczl_bzdh
  817. detailData.table[index].fp_bh = sczl_bh1
  818. detailData.table[index].fp_name = name
  819. })
  820. }
  821. const SLIndex = ref(0);
  822. const JYCurrent = ref(0);
  823. const selectSL = (event) => {
  824. if (event.keyCode === 40) { // 向下箭头
  825. if (SLIndex.value < selectData.length - 1) {
  826. SLIndex.value++;
  827. setCurrent(selectData[SLIndex.value]);
  828. } else {
  829. SLIndex.value = 0;
  830. setCurrent(selectData[SLIndex.value]); // 到达最后一行时回到第一行
  831. }
  832. } else if (event.keyCode === 38) { // 向上箭头
  833. if (SLIndex.value > 0) {
  834. SLIndex.value--;
  835. setCurrent(selectData[SLIndex.value]);
  836. } else {
  837. SLIndex.value = selectData.length - 1;
  838. setCurrent(selectData[SLIndex.value]); // 到达第一行时回到最后一行
  839. }
  840. } else if (event.keyCode === 13) { // 回车键
  841. dialogSelectVisible2.value = false
  842. }
  843. }
  844. // 弹窗确定
  845. const enterDialog = async() => {
  846. if (type.value === '查改') {
  847. updateDetailData()
  848. } else if (type.value === '新增') {
  849. addDetailData()
  850. }
  851. }
  852. const addDetailData = async () => {
  853. const formatDate = (date) => {
  854. const year = date.getFullYear();
  855. const month = String(date.getMonth() + 1).padStart(2, '0');
  856. const day = String(date.getDate()).padStart(2, '0');
  857. return `${year}-${month}-${day}`;
  858. };
  859. const restoredData = {
  860. UniqId: detailData.UniqId,
  861. qczl_gdbh: detailData.qczl_gdbh,
  862. qczl_yjno: detailData.qczl_yjno,
  863. qczl_gxh: detailData.qczl_gxh,
  864. qczl_gxmc: detailData.qczl_gxmc,
  865. qczl_rq: formatDate(new Date(detailData.qczl_rq)),
  866. qczl_fp: detailData.qczl_fp,
  867. qczl_num: detailData.qczl_num,
  868. qczl_NumDesc: detailData.qczl_NumDesc,
  869. qczl_NumDesc1: detailData.qczl_NumDesc1,
  870. qczl_NumDesc2: detailData.qczl_NumDesc2,
  871. qczl_NumDesc3: detailData.qczl_NumDesc3,
  872. qczl_NumDesc4: detailData.qczl_NumDesc4,
  873. qczl_NumDesc5: detailData.qczl_NumDesc5,
  874. qczl_NumDesc6: detailData.qczl_NumDesc6,
  875. qczl_NumDesc7: detailData.qczl_NumDesc7,
  876. qczl_NumDesc8: detailData.qczl_NumDesc8,
  877. sys_id: sys_id
  878. };
  879. detailData.table.forEach((item, index) => {
  880. const num = index + 1;
  881. restoredData[`fp_lb${num}`] = item.fp_lb;
  882. restoredData[`fp_sl${num}`] = item.fp_sl;
  883. restoredData[`fp_bh${num}`] = item.fp_bh;
  884. restoredData[`fp_bz${num}`] = item.fp_bz;
  885. restoredData[`fp_gxmc${num}`] = item.fp_gxmc;
  886. });
  887. console.log(restoredData);
  888. const res = await add(restoredData)
  889. console.log(res)
  890. if (res.code === 0) {
  891. ElMessage({
  892. type: 'success',
  893. message: '新增成功',
  894. })
  895. dialogFormVisible.value = false
  896. }
  897. };
  898. // 修改
  899. const updateDetailData = async() => {
  900. const formatDate = (date) => {
  901. const year = date.getFullYear();
  902. const month = String(date.getMonth() + 1).padStart(2, '0');
  903. const day = String(date.getDate()).padStart(2, '0');
  904. return `${year}-${month}-${day}`;
  905. };
  906. const restoredData = {
  907. UniqId: detailData.UniqId,
  908. qczl_gdbh: detailData.qczl_gdbh,
  909. qczl_yjno: detailData.qczl_yjno,
  910. qczl_gxh: detailData.qczl_gxh,
  911. qczl_gxmc: detailData.qczl_gxmc,
  912. qczl_rq: formatDate(new Date(detailData.qczl_rq)),
  913. qczl_fp: detailData.qczl_fp,
  914. qczl_num: detailData.qczl_num,
  915. qczl_NumDesc: detailData.qczl_NumDesc,
  916. qczl_NumDesc1: detailData.qczl_NumDesc1,
  917. qczl_NumDesc2: detailData.qczl_NumDesc2,
  918. qczl_NumDesc3: detailData.qczl_NumDesc3,
  919. qczl_NumDesc4: detailData.qczl_NumDesc4,
  920. qczl_NumDesc5: detailData.qczl_NumDesc5,
  921. qczl_NumDesc6: detailData.qczl_NumDesc6,
  922. qczl_NumDesc7: detailData.qczl_NumDesc7,
  923. qczl_NumDesc8: detailData.qczl_NumDesc8,
  924. }
  925. detailData.table.forEach((item, index) => {
  926. const num = index + 1
  927. restoredData[`fp_lb${num}`] = item.fp_lb
  928. restoredData[`fp_sl${num}`] = item.fp_sl
  929. restoredData[`fp_bh${num}`] = item.fp_bh
  930. restoredData[`fp_bz${num}`] = item.fp_bz
  931. restoredData[`fp_gxmc${num}`] = item.fp_gxmc
  932. })
  933. const res = await updateData(restoredData)
  934. if (res.code === 0) {
  935. ElMessage({
  936. type: 'success',
  937. message: res.msg,
  938. })
  939. dialogFormVisible.value = false
  940. }
  941. }
  942. // 多选
  943. const handleSelectionChange = (val) => {
  944. multipleSelection.value = val
  945. }
  946. // 多选删除
  947. const onDelete = async() => {
  948. const ids = []
  949. if (multipleSelection.value.length === 0) {
  950. ElMessage({
  951. type: 'warning',
  952. message: '请选择要删除的数据'
  953. })
  954. return
  955. }
  956. multipleSelection.value &&
  957. multipleSelection.value.map(item => {
  958. ids.push(item.ID)
  959. })
  960. const res = await deleteCompanyByIds({ ids })
  961. if (res.code === 0) {
  962. ElMessage({
  963. type: 'success',
  964. message: '删除成功'
  965. })
  966. if (tableData.value.length === ids.length && page.value > 1) {
  967. page.value--
  968. }
  969. deleteVisible.value = false
  970. getTableData()
  971. }
  972. }
  973. // 更新行
  974. const updateCompanyFunc = async(row) => {
  975. const res = await findCompany({ ID: row.ID })
  976. type.value = 'update'
  977. if (res.code === 0) {
  978. formData.value = res.data.recompany
  979. // dialogFormVisible.value = true
  980. showDialog()
  981. }
  982. }
  983. // 关闭弹窗
  984. const closeDialog = () => {
  985. dialogFormVisible.value = false
  986. }
  987. // 导出excel
  988. function exportExcel() {
  989. console.log('导出到excel')
  990. // dialogSbyxgl.value = true
  991. }
  992. const dialogMrhjtj = ref(false)
  993. const dialogGdzjfptj = ref(false)
  994. const dialogSbyxgl = ref(false)
  995. const value1 = ref('')
  996. const table = ref(null)
  997. const showGdzjfptj = () => {
  998. value1.value = currentRow.value?.qczl_gdbh
  999. dialogGdzjfptj.value = true
  1000. }
  1001. const currentRow = ref()
  1002. const handleSelectChange = (row, column, event) => {
  1003. currentRow.value = row.UniqId
  1004. }
  1005. // 新增数据
  1006. const handleShowAdd = async() => {
  1007. type.value = '新增'
  1008. // console.log()
  1009. getDetailData(minUniqId.value)
  1010. // type.value='add'
  1011. // Object.assign(detailData);
  1012. // dialogFormVisible.value = true
  1013. }
  1014. // 开启弹窗
  1015. const showDialog = () => {
  1016. dialogFormVisible.value = true
  1017. // 在 setTimeout 中获取元素,确保在 DOM 渲染完毕后执行
  1018. setTimeout(() => {
  1019. formElements = document.getElementById('detail-form').elements
  1020. formElements[0].focus()
  1021. }, 0)
  1022. }
  1023. let formElements
  1024. const moveFocus = (event) => {
  1025. const index = Array.from(formElements).indexOf(event.target)
  1026. const key = event.key
  1027. event.preventDefault()
  1028. switch (index) {
  1029. case 0:
  1030. if (key === 'ArrowDown') {
  1031. formElements[1].focus()
  1032. formElements[1].select();
  1033. } else if (key === 'ArrowUp') {
  1034. formElements[formElements.length - 1].focus()
  1035. } else if (key === 'Enter') {
  1036. formElements[1].focus()
  1037. formElements[1].select();
  1038. }
  1039. break
  1040. case formElements.length - 1 :
  1041. if (key === 'ArrowDown') {
  1042. formElements[0].focus()
  1043. formElements[0].select();
  1044. } else if (key === 'ArrowUp') {
  1045. formElements[index - 1].focus()
  1046. } else if (key === 'Enter') {
  1047. formElements[0].focus()
  1048. formElements[0].select();
  1049. }
  1050. break
  1051. default:
  1052. if (key === 'ArrowDown') {
  1053. formElements[index + 1].focus()
  1054. formElements[index + 1].select();
  1055. } else if (key === 'ArrowUp') {
  1056. formElements[index - 1].focus()
  1057. formElements[index + 1].select();
  1058. } else if (key === 'Enter') {
  1059. formElements[index + 1].focus()
  1060. formElements[index + 1].select();
  1061. }
  1062. break
  1063. }
  1064. }
  1065. </script>
  1066. <style scoped>
  1067. .JKWTree-container {
  1068. display: flex;
  1069. }
  1070. .JKWTree-tree {
  1071. width: 300px;
  1072. background-color: #fff;
  1073. padding: 10px;
  1074. margin-right: 20px;
  1075. }
  1076. .JKWTree-tree h3 {
  1077. font-size: 15px;
  1078. font-weight: 700;
  1079. margin: 10px 0;
  1080. }
  1081. .JKWTree-content {
  1082. flex: 1;
  1083. }
  1084. .bt{
  1085. margin-left: 2px !important;
  1086. padding: 3px !important;
  1087. font-size: 12px;
  1088. }
  1089. /* 选中某行时的背景色 */
  1090. :deep(.el-table__body tr.current-row) > td {
  1091. background: #ff80ff !important;
  1092. }
  1093. </style>