index.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146
  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. @keydown="selectSL($event)"
  382. >
  383. <el-table
  384. tooltip-effect="dark"
  385. :data="selectData"
  386. row-key="ID"
  387. highlight-current-row
  388. border
  389. style="width:100%"
  390. @row-dblclick="handleSelectClick"
  391. ref="table2"
  392. >
  393. <el-table-column
  394. v-for=" column in selectColumns "
  395. :key="column.prop"
  396. :prop="column.prop"
  397. :label="column.label"
  398. :width="column.width"
  399. />
  400. </el-table>
  401. </el-dialog>
  402. <el-dialog
  403. v-model="GetjtbhVisible"
  404. title="选择"
  405. destroy-on-close
  406. width="600px"
  407. >
  408. <el-table
  409. tooltip-effect="dark"
  410. :data="JTBHselectData"
  411. row-key="ID"
  412. highlight-current-row="true"
  413. border
  414. style="width:100%"
  415. @row-dblclick="JTBHSelectClick"
  416. >
  417. <el-table-column
  418. prop="gxh"
  419. label="工序号"
  420. width="70"
  421. />
  422. <el-table-column
  423. prop="gxmc"
  424. label="工序名称"
  425. width="150"
  426. />
  427. <el-table-column
  428. prop="addGxmc"
  429. label="工序名称"
  430. width="150"
  431. />
  432. </el-table>
  433. </el-dialog>
  434. <!-- 废品日统计 -->
  435. <Meirihejiantongji
  436. v-if="dialogMrhjtj"
  437. v-model="dialogMrhjtj"
  438. />
  439. <!-- 工单质检废品统计 -->
  440. <Gongdanzhijianfeipintongji
  441. v-if="dialogGdzjfptj"
  442. v-model="dialogGdzjfptj"
  443. :val="value1"
  444. />
  445. <!-- 测试图表 -->
  446. <Shebeizhuangtai
  447. v-if="dialogSbyxgl"
  448. v-model="dialogSbyxgl"
  449. title="【01.30 08:30】【JY01#--海德堡对开八色平版胶印机(JY08-01)】【2311116-->钻石(荷花)盒包装纸】【01--胶印】"
  450. />
  451. </el-main>
  452. </el-container>
  453. </el-container>
  454. </div>
  455. </template>
  456. <script setup>
  457. import {
  458. createCompany,
  459. deleteCompany,
  460. deleteCompanyByIds,
  461. updateCompany,
  462. findCompany,
  463. getCompanyList
  464. } from '@/api/company'
  465. // 全量引入格式化工具 请按需保留
  466. import { ElMessage } from 'element-plus'
  467. import { Search, Refresh, Download } from '@element-plus/icons-vue'
  468. import { ref, reactive } from 'vue'
  469. import { getSide, getTable, getOneWorkOrder, getOrderInfo, getGxAndLeader, getYjInfo, getWastInfo, updateData, add } from '@/api/mes_api_gty/workOrderVerification'
  470. import Meirihejiantongji from '@/view/performance/09-workOrderVerification/componets/meirihejiantongji.vue'
  471. import Gongdanzhijianfeipintongji from '@/view/performance/09-workOrderVerification/componets/gongdanzhijianfeipintongji.vue'
  472. import Shebeizhuangtai from '@/view/performance/09-workOrderVerification/componets/shebeizhuangtai.vue'
  473. import { Layout, LayoutContent, LayoutHeader, LayoutSider } from '@arco-design/web-vue'
  474. defineOptions({
  475. name: '06PackingDocuments'
  476. })
  477. // 侧边栏数据请求
  478. const treeData = reactive([])
  479. const getSideData = async() => {
  480. const response = await getSide()
  481. if (response.code === 0) {
  482. const transformedData = response.data.map(item => ({
  483. label: `${item.date.replace(/-/g, '.')}【单据数: ${item.counts}张】`,
  484. children: item.sys.map(sysItem => ({
  485. label: `${sysItem.sys_id} 【记录数: ${sysItem.count}张】`,
  486. params: {
  487. date: item.date.replace(/\./g, '-'),
  488. sys_id: sysItem.sys_id,
  489. },
  490. })),
  491. }))
  492. treeData.splice(0, treeData.length, ...transformedData)
  493. }
  494. }
  495. getSideData()
  496. // 验证规则
  497. const rule = reactive({
  498. })
  499. const elFormRef = ref()
  500. const elSearchFormRef = ref()
  501. // =========== 表格控制部分 ===========
  502. const tableColumns = [
  503. { label: '工单编号', prop: 'qczl_gdbh', width: '100' },
  504. { label: '印件号', prop: 'qczl_yjno', width: '100' },
  505. { label: '印件名称', prop: 'Gd_cpmc', width: '400' },
  506. { label: '日期', prop: 'qczl_rq', width: '100' },
  507. { label: '流程单号', prop: 'qczl_num', width: '100' },
  508. { label: '流程单备注', prop: 'qczl_NumDesc', width: '100' },
  509. { label: '总废品', prop: 'qczl_fp', width: '100' },
  510. { label: '废品1', prop: 'sl_lb1', width: '250' },
  511. { label: '废品2', prop: 'sl_lb2', width: '250' },
  512. { label: '废品3', prop: 'sl_lb3', width: '250' },
  513. { label: '废品4', prop: 'sl_lb4', width: '250' },
  514. { label: '废品5', prop: 'sl_lb5', width: '250' },
  515. { label: '废品6', prop: 'sl_lb6', width: '250' },
  516. { label: '废品7', prop: 'sl_lb7', width: '250' },
  517. { label: '废品8', prop: 'sl_lb8', width: '250' },
  518. { label: '废品9', prop: 'sl_lb9', width: '250' },
  519. { label: '废品10', prop: 'sl_lb10', width: '250' },
  520. { label: '废品11', prop: 'sl_lb11', width: '250' },
  521. { label: '废品12', prop: 'sl_lb12', width: '250' },
  522. { label: '废品13', prop: 'sl_lb13', width: '250' },
  523. { label: '废品14', prop: 'sl_lb14', width: '250' },
  524. { label: '废品15', prop: 'sl_lb15', width: '250' },
  525. { label: '废品16', prop: 'sl_lb16', width: '250' },
  526. { label: '废品17', prop: 'sl_lb17', width: '250' },
  527. { label: '创建用户', prop: 'sys_id', width: '200' }
  528. ]
  529. const tableData = reactive([])
  530. const GetjtbhVisible = ref(false)
  531. const total = ref(0)
  532. const page = ref(1)
  533. const limit = ref(10)
  534. const JTBHselectData = reactive([])
  535. const searchInfo = ref('')
  536. const params = {
  537. date: '',
  538. sys_id: '',
  539. order: '',
  540. page: page.value.toString(),
  541. limit: limit.value.toString(),
  542. }
  543. // 获取工序
  544. const getgxsubmit = () => {
  545. GetJtbh()
  546. }
  547. const GetJtbh = async() => {
  548. try {
  549. const { qczl_gdbh, qczl_yjno } = detailData
  550. const response = await getYjInfo({ order: qczl_gdbh, yj_no: qczl_yjno })
  551. if (response.code === 0) {
  552. const data = response.data
  553. if (data) {
  554. const tableData = data.gx_data.map(item => ({
  555. gxh: item.Gy0_gxh,
  556. gxmc: item.Gy0_gxmc + (item.Add_gxmc === '' ? '' : '-' + item.Add_gxmc),
  557. // addGxmc: item.Add_gxmc
  558. }))
  559. console.log(tableData)
  560. JTBHselectData.splice(0, JTBHselectData.length, ...tableData)
  561. GetjtbhVisible.value = true
  562. // Now you can use the tableData to populate your table
  563. } else {
  564. console.log('No data found')
  565. }
  566. } else {
  567. console.log('Error: ', response.msg)
  568. }
  569. } catch (error) {
  570. console.error('Error fetching data: ', error)
  571. }
  572. }
  573. const JTBHSelectClick = (row, column, event) => {
  574. const { gxh, gxmc } = row
  575. detailData.qczl_gxmc = gxh + '-' + gxmc
  576. detailData.qczl_gxh = gxh
  577. GetjtbhVisible.value = false
  578. }
  579. // 批量删除控制标记
  580. const deleteVisible = ref(false)
  581. const multipleSelection = ref([])
  582. const minUniqId = ref('')
  583. const getTableData = async() => {
  584. const response = await getTable(params)
  585. if (response.code === 0) {
  586. total.value = response.data.total
  587. // Object.assign(tableData, response.data.rows)
  588. tableData.splice(0, tableData.length, ...response.data.rows)
  589. minUniqId.value = Math.min(...tableData.map(row => row.UniqId))
  590. }
  591. }
  592. // 左侧树结构点击
  593. const handleNodeClick = (node, check) => {
  594. if (node.params) {
  595. params.date = node.params.date
  596. params.sys_id = node.params.sys_id
  597. page.value = 1
  598. handleCurrentChange()
  599. }
  600. }
  601. // 搜索
  602. function handleSearch() {
  603. params.sys_id = ''
  604. params.date = ''
  605. params.order = searchInfo.value
  606. page.value = 1
  607. handleCurrentChange()
  608. }
  609. // 分页
  610. const handleSizeChange = () => {
  611. params.limit = limit.value.toString()
  612. getTableData()
  613. }
  614. // 页面跳转
  615. const handleCurrentChange = () => {
  616. params.page = page.value.toString()
  617. getTableData()
  618. }
  619. // ============== 详情页面 ==============
  620. const detailData = reactive({})
  621. const selectData = reactive([])
  622. const selectColumns = [
  623. { label: '', prop: 'sczl_gxmc', width: '500' },
  624. { label: '', prop: 'sczl_jtbh', width: '100' },
  625. { label: '', prop: 'sczl_bzdh', width: '100' },
  626. { label: '', prop: 'name', width: '100' },
  627. ]
  628. let selecTreeData = []
  629. // 行为控制标记(弹窗内部需要增还是改)
  630. const type = ref('')
  631. // 弹窗控制标记
  632. const dialogFormVisible = ref(false)
  633. const dialogSelectVisible1 = ref(false)
  634. const dialogSelectVisible2 = ref(false)
  635. let selectIndex = 0
  636. const getDetailData = async(id) => {
  637. try {
  638. const res = await getOneWorkOrder({ UniqId: id })
  639. if (res.code === 0) {
  640. const obj = res.data
  641. // 裁剪返回数据的前后空格
  642. for (const key in obj) {
  643. if (Object.prototype.hasOwnProperty.call(obj, key) && typeof obj[key] === 'string') {
  644. obj[key] = obj[key].trim()
  645. }
  646. }
  647. // 修改日期格式
  648. if (Object.prototype.hasOwnProperty.call(obj, 'qczl_rq') && typeof obj['qczl_rq'] === 'string') {
  649. obj['qczl_rq'] = obj['qczl_rq'].split(' ')[0]
  650. }
  651. Object.assign(detailData, obj)
  652. const table = []
  653. // 循环13行数据
  654. for (let i = 1; i <= 13; i++) {
  655. table.push({
  656. fp_lb: detailData[`fp_lb${i}`] || '',
  657. fp_sl: detailData[`fp_sl${i}`] || '',
  658. fp_gxmc: detailData[`fp_gxmc${i}`] || '',
  659. fp_bz: detailData[`fp_bz${i}`] || '',
  660. fp_bh: detailData[`fp_bh${i}`] || '',
  661. fp_name: detailData[`fp_name${i}`] || '',
  662. })
  663. // 从原对象中删除这些属性
  664. delete detailData[`fp_lb${i}`]
  665. delete detailData[`fp_sl${i}`]
  666. delete detailData[`fp_gxmc${i}`]
  667. delete detailData[`fp_bz${i}`]
  668. delete detailData[`fp_bh${i}`]
  669. delete detailData[`fp_name${i}`]
  670. }
  671. detailData.table = table
  672. try {
  673. const res = await getOrderInfo({ order: detailData.qczl_gdbh })
  674. if (res.code === 0) {
  675. detailData.Gd_cpmc = res.data.Gd_cpmc
  676. // dialogFormVisible.value = true
  677. showDialog()
  678. }
  679. } catch (e) {
  680. console.log(e)
  681. }
  682. }
  683. } catch (e) {
  684. console.log(e)
  685. }
  686. }
  687. // 工单编号回车
  688. const handleGdbhEnter = async() => {
  689. const res = await getOrderInfo({ order: detailData.qczl_gdbh })
  690. if (res.code === 0) {
  691. const { Gd_cpmc, yj_Yjno, yj_yjmc } = res.data
  692. detailData.Gd_cpmc = Gd_cpmc
  693. detailData.qczl_yjno = yj_Yjno
  694. detailData.yj_yjmc = yj_yjmc
  695. }
  696. }
  697. // 废品类别回车
  698. const handleFplbEnter = async(index, row) => {
  699. let res
  700. try {
  701. res = await getWastInfo({ search: row.fp_lb })
  702. if (res.code !== 0) {
  703. return
  704. }
  705. } catch (e) {
  706. console.log(e)
  707. return
  708. }
  709. const obj = res.data
  710. const treeData = []
  711. for (const category in obj) {
  712. if (Object.prototype.hasOwnProperty.call(obj, category)) {
  713. const children = []
  714. for (const subCategory in obj[category]) {
  715. if (Object.prototype.hasOwnProperty.call(obj[category], subCategory)) {
  716. const subChildren = obj[category][subCategory].map(item => {
  717. return { label: item }
  718. })
  719. children.push({
  720. label: subCategory,
  721. children: subChildren
  722. })
  723. }
  724. }
  725. treeData.push({
  726. label: category,
  727. children: children
  728. })
  729. }
  730. }
  731. selecTreeData = treeData
  732. selectIndex = index
  733. dialogSelectVisible1.value = true
  734. }
  735. const handleFplbClick = (node, check) => {
  736. if (!node.children) {
  737. detailData.table[selectIndex].fp_lb = node.label
  738. dialogSelectVisible1.value = false
  739. }
  740. }
  741. // 废品数量回车
  742. const handleFpslEnter = async(index, row) => {
  743. if (row.fp_sl === '0') {
  744. detailData.table[index].fp_gxmc = ''
  745. detailData.table[index].fp_bz = ''
  746. detailData.table[index].fp_bh = ''
  747. detailData.table[index].fp_name = ''
  748. return
  749. }
  750. const params = {
  751. type: row.fp_lb,
  752. order: detailData.qczl_gdbh,
  753. }
  754. let res
  755. try {
  756. res = await getGxAndLeader(params)
  757. if (res.code !== 0) {
  758. return
  759. }
  760. } catch (e) {
  761. console.log(e)
  762. return
  763. }
  764. selectIndex = index
  765. Object.assign(selectData, res.data)
  766. setCurrent(selectData[0])
  767. dialogSelectVisible2.value = true
  768. }
  769. // 双击表格操作
  770. function doubleClick(row, column, event) {
  771. type.value = '查改'
  772. getDetailData(row.UniqId)
  773. }
  774. // 处理选择框回车操作
  775. const handleSelectClick = (row, column, event) => {
  776. const { sczl_gxmc, sczl_bzdh, sczl_bh1, name } = row
  777. const index = selectIndex
  778. detailData.table[index].fp_gxmc = sczl_gxmc
  779. detailData.table[index].fp_bz = sczl_bzdh
  780. detailData.table[index].fp_bh = sczl_bh1
  781. detailData.table[index].fp_name = name
  782. dialogSelectVisible2.value = false
  783. }
  784. const table2 = ref()
  785. const setCurrent = (row) => {
  786. setTimeout(()=>{
  787. table2.value?.setCurrentRow(row)
  788. // SelectClick(row)
  789. // console.log(row)
  790. // console.log(table)
  791. const { sczl_gxmc, sczl_bzdh, sczl_bh1, name } = row
  792. const index = selectIndex
  793. detailData.table[index].fp_gxmc = sczl_gxmc
  794. detailData.table[index].fp_bz = sczl_bzdh
  795. detailData.table[index].fp_bh = sczl_bh1
  796. detailData.table[index].fp_name = name
  797. })
  798. }
  799. const SLIndex = ref(0);
  800. const JYCurrent = ref(0);
  801. const selectSL = (event) => {
  802. if (event.keyCode === 40) { // 向下箭头
  803. if (SLIndex.value < selectData.length - 1) {
  804. SLIndex.value++;
  805. setCurrent(selectData[SLIndex.value]);
  806. } else {
  807. SLIndex.value = 0;
  808. setCurrent(selectData[SLIndex.value]); // 到达最后一行时回到第一行
  809. }
  810. } else if (event.keyCode === 38) { // 向上箭头
  811. if (SLIndex.value > 0) {
  812. SLIndex.value--;
  813. setCurrent(selectData[SLIndex.value]);
  814. } else {
  815. SLIndex.value = selectData.length - 1;
  816. setCurrent(selectData[SLIndex.value]); // 到达第一行时回到最后一行
  817. }
  818. } else if (event.keyCode === 13) { // 回车键
  819. dialogSelectVisible2.value = false
  820. }
  821. }
  822. // 弹窗确定
  823. const enterDialog = async() => {
  824. if (type.value === '查改') {
  825. updateDetailData()
  826. } else if (type.value === '新增') {
  827. addDetailData()
  828. }
  829. }
  830. const addDetailData = async () => {
  831. const formatDate = (date) => {
  832. const year = date.getFullYear();
  833. const month = String(date.getMonth() + 1).padStart(2, '0');
  834. const day = String(date.getDate()).padStart(2, '0');
  835. return `${year}-${month}-${day}`;
  836. };
  837. const restoredData = {
  838. UniqId: detailData.UniqId,
  839. qczl_gdbh: detailData.qczl_gdbh,
  840. qczl_yjno: detailData.qczl_yjno,
  841. qczl_gxh: detailData.qczl_gxh,
  842. qczl_gxmc: detailData.qczl_gxmc,
  843. qczl_rq: formatDate(new Date(detailData.qczl_rq)),
  844. qczl_fp: detailData.qczl_fp,
  845. qczl_num: detailData.qczl_num,
  846. qczl_NumDesc: detailData.qczl_NumDesc,
  847. qczl_NumDesc1: detailData.qczl_NumDesc1,
  848. qczl_NumDesc2: detailData.qczl_NumDesc2,
  849. qczl_NumDesc3: detailData.qczl_NumDesc3,
  850. qczl_NumDesc4: detailData.qczl_NumDesc4,
  851. qczl_NumDesc5: detailData.qczl_NumDesc5,
  852. qczl_NumDesc6: detailData.qczl_NumDesc6,
  853. qczl_NumDesc7: detailData.qczl_NumDesc7,
  854. qczl_NumDesc8: detailData.qczl_NumDesc8,
  855. sys_id: '[1003/洪桂芬]'
  856. };
  857. detailData.table.forEach((item, index) => {
  858. const num = index + 1;
  859. restoredData[`fp_lb${num}`] = item.fp_lb;
  860. restoredData[`fp_sl${num}`] = item.fp_sl;
  861. restoredData[`fp_bh${num}`] = item.fp_bh;
  862. restoredData[`fp_bz${num}`] = item.fp_bz;
  863. restoredData[`fp_gxmc${num}`] = item.fp_gxmc;
  864. });
  865. console.log(restoredData);
  866. const res = await add(restoredData)
  867. console.log(res)
  868. if (res.code === 0) {
  869. ElMessage({
  870. type: 'success',
  871. message: '新增成功',
  872. })
  873. dialogFormVisible.value = false
  874. }
  875. };
  876. // 修改
  877. const updateDetailData = async() => {
  878. const formatDate = (date) => {
  879. const year = date.getFullYear();
  880. const month = String(date.getMonth() + 1).padStart(2, '0');
  881. const day = String(date.getDate()).padStart(2, '0');
  882. return `${year}-${month}-${day}`;
  883. };
  884. const restoredData = {
  885. UniqId: detailData.UniqId,
  886. qczl_gdbh: detailData.qczl_gdbh,
  887. qczl_yjno: detailData.qczl_yjno,
  888. qczl_gxh: detailData.qczl_gxh,
  889. qczl_gxmc: detailData.qczl_gxmc,
  890. qczl_rq: formatDate(new Date(detailData.qczl_rq)),
  891. qczl_fp: detailData.qczl_fp,
  892. qczl_num: detailData.qczl_num,
  893. qczl_NumDesc: detailData.qczl_NumDesc,
  894. qczl_NumDesc1: detailData.qczl_NumDesc1,
  895. qczl_NumDesc2: detailData.qczl_NumDesc2,
  896. qczl_NumDesc3: detailData.qczl_NumDesc3,
  897. qczl_NumDesc4: detailData.qczl_NumDesc4,
  898. qczl_NumDesc5: detailData.qczl_NumDesc5,
  899. qczl_NumDesc6: detailData.qczl_NumDesc6,
  900. qczl_NumDesc7: detailData.qczl_NumDesc7,
  901. qczl_NumDesc8: detailData.qczl_NumDesc8,
  902. }
  903. detailData.table.forEach((item, index) => {
  904. const num = index + 1
  905. restoredData[`fp_lb${num}`] = item.fp_lb
  906. restoredData[`fp_sl${num}`] = item.fp_sl
  907. restoredData[`fp_bh${num}`] = item.fp_bh
  908. restoredData[`fp_bz${num}`] = item.fp_bz
  909. restoredData[`fp_gxmc${num}`] = item.fp_gxmc
  910. })
  911. const res = await updateData(restoredData)
  912. if (res.code === 0) {
  913. ElMessage({
  914. type: 'success',
  915. message: res.msg,
  916. })
  917. dialogFormVisible.value = false
  918. }
  919. }
  920. // 多选
  921. const handleSelectionChange = (val) => {
  922. multipleSelection.value = val
  923. }
  924. // 多选删除
  925. const onDelete = async() => {
  926. const ids = []
  927. if (multipleSelection.value.length === 0) {
  928. ElMessage({
  929. type: 'warning',
  930. message: '请选择要删除的数据'
  931. })
  932. return
  933. }
  934. multipleSelection.value &&
  935. multipleSelection.value.map(item => {
  936. ids.push(item.ID)
  937. })
  938. const res = await deleteCompanyByIds({ ids })
  939. if (res.code === 0) {
  940. ElMessage({
  941. type: 'success',
  942. message: '删除成功'
  943. })
  944. if (tableData.value.length === ids.length && page.value > 1) {
  945. page.value--
  946. }
  947. deleteVisible.value = false
  948. getTableData()
  949. }
  950. }
  951. // 更新行
  952. const updateCompanyFunc = async(row) => {
  953. const res = await findCompany({ ID: row.ID })
  954. type.value = 'update'
  955. if (res.code === 0) {
  956. formData.value = res.data.recompany
  957. // dialogFormVisible.value = true
  958. showDialog()
  959. }
  960. }
  961. // 关闭弹窗
  962. const closeDialog = () => {
  963. dialogFormVisible.value = false
  964. }
  965. // 导出excel
  966. function exportExcel() {
  967. console.log('导出到excel')
  968. dialogSbyxgl.value = true
  969. }
  970. const dialogMrhjtj = ref(false)
  971. const dialogGdzjfptj = ref(false)
  972. const dialogSbyxgl = ref(false)
  973. const value1 = ref('')
  974. const table = ref(null)
  975. const showGdzjfptj = () => {
  976. value1.value = currentRow.value?.qczl_gdbh
  977. dialogGdzjfptj.value = true
  978. }
  979. const currentRow = ref()
  980. const handleSelectChange = (row, column, event) => {
  981. currentRow.value = row.UniqId
  982. }
  983. // 新增数据
  984. const handleShowAdd = async() => {
  985. type.value = '新增'
  986. // console.log()
  987. getDetailData(minUniqId.value)
  988. // type.value='add'
  989. // Object.assign(detailData);
  990. // dialogFormVisible.value = true
  991. }
  992. // 开启弹窗
  993. const showDialog = () => {
  994. dialogFormVisible.value = true
  995. // 在 setTimeout 中获取元素,确保在 DOM 渲染完毕后执行
  996. setTimeout(() => {
  997. formElements = document.getElementById('detail-form').elements
  998. formElements[0].focus()
  999. }, 0)
  1000. }
  1001. let formElements
  1002. const moveFocus = (event) => {
  1003. const index = Array.from(formElements).indexOf(event.target)
  1004. const key = event.key
  1005. event.preventDefault()
  1006. switch (index) {
  1007. case 0:
  1008. if (key === 'ArrowDown') {
  1009. formElements[1].focus()
  1010. formElements[1].select();
  1011. } else if (key === 'ArrowUp') {
  1012. formElements[formElements.length - 1].focus()
  1013. } else if (key === 'Enter') {
  1014. formElements[1].focus()
  1015. formElements[1].select();
  1016. }
  1017. break
  1018. case formElements.length - 1 :
  1019. if (key === 'ArrowDown') {
  1020. formElements[0].focus()
  1021. formElements[0].select();
  1022. } else if (key === 'ArrowUp') {
  1023. formElements[index - 1].focus()
  1024. } else if (key === 'Enter') {
  1025. formElements[0].focus()
  1026. formElements[0].select();
  1027. }
  1028. break
  1029. default:
  1030. if (key === 'ArrowDown') {
  1031. formElements[index + 1].focus()
  1032. formElements[index + 1].select();
  1033. } else if (key === 'ArrowUp') {
  1034. formElements[index - 1].focus()
  1035. formElements[index + 1].select();
  1036. } else if (key === 'Enter') {
  1037. formElements[index + 1].focus()
  1038. formElements[index + 1].select();
  1039. }
  1040. break
  1041. }
  1042. }
  1043. </script>
  1044. <style scoped>
  1045. .JKWTree-container {
  1046. display: flex;
  1047. }
  1048. .JKWTree-tree {
  1049. width: 300px;
  1050. background-color: #fff;
  1051. padding: 10px;
  1052. margin-right: 20px;
  1053. }
  1054. .JKWTree-tree h3 {
  1055. font-size: 15px;
  1056. font-weight: 700;
  1057. margin: 10px 0;
  1058. }
  1059. .JKWTree-content {
  1060. flex: 1;
  1061. }
  1062. /* 选中某行时的背景色 */
  1063. :deep(.el-table__body tr.current-row) > td {
  1064. background: #ff80ff !important;
  1065. }
  1066. </style>