index.vue 28 KB

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