index.vue 30 KB

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