index.vue 30 KB

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