index.vue 31 KB

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