index.vue 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257
  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. class="bt"
  49. @click="handleSearch"
  50. >搜索
  51. </el-button>
  52. <el-button
  53. type="primary"
  54. icon="copy-document"
  55. class="bt"
  56. @click="dialogMrhjtj = true"
  57. >每日核检统计
  58. </el-button>
  59. <el-button
  60. type="primary"
  61. icon="copy-document"
  62. class="bt"
  63. @click="showGdzjfptj"
  64. >工单质检废品统计
  65. </el-button>
  66. <el-button
  67. type="primary"
  68. class="bt" icon="plus"
  69. @click="handleShowAdd"
  70. >新增
  71. </el-button>
  72. <div style="margin-left: auto;">
  73. <!-- <el-button
  74. type="primary"
  75. :icon="Download"
  76. class="bt"
  77. @click="exportExcel"
  78. >导出到Excel</el-button> -->
  79. </div>
  80. </div>
  81. <!-- 数据展示 -->
  82. <el-table
  83. ref="table"
  84. style="width: 100%"
  85. :data="tableData"
  86. row-key="ID"
  87. highlight-current-row
  88. border
  89. show-overflow-tooltip
  90. :row-style="{ height: '20px' }"
  91. :cell-style="{ padding: '0px' }"
  92. :header-row-style="{ height: '20px' }"
  93. :header-cell-style="{ padding: '0px' }"
  94. @row-click="handleSelectChange"
  95. @row-dblclick="doubleClick"
  96. >
  97. <el-table-column
  98. type="selection"
  99. width="55"
  100. />
  101. <!-- 循环渲染表格列 -->
  102. <el-table-column
  103. v-for="column in tableColumns"
  104. :key="column.prop"
  105. :prop="column.prop"
  106. :label="column.label"
  107. :width="column.width"
  108. sortable
  109. />
  110. </el-table>
  111. <!-- 分页 -->
  112. <div class="gva-pagination">
  113. <el-pagination
  114. v-model:current-page="page"
  115. v-model:page-size="limit"
  116. layout="total, sizes, prev, pager, next, jumper"
  117. :page-sizes="[10, 30, 50, 100]"
  118. :total="total"
  119. @current-change="handleCurrentChange"
  120. @size-change="handleSizeChange"
  121. />
  122. </div>
  123. </div>
  124. <!-- 弹出框 -->
  125. <el-dialog v-model="dialogFormVisible" :before-close="closeDialog"
  126. :title="type" destroy-on-close width="1000px"
  127. >
  128. <el-form ref="elFormRef" :model="detailData"
  129. inline label-position="right"
  130. :rules="rule" id="detail-form"
  131. >
  132. <el-row :gutter="30">
  133. <el-col :span="5">
  134. <el-form-item label="日期" >
  135. <el-date-picker v-model="detailData.qczl_rq" type="date" style="width: 150px;" />
  136. </el-form-item>
  137. </el-col>
  138. <el-col :span="5">
  139. <el-form-item label="工单编号" >
  140. <el-input v-model="detailData.qczl_gdbh"
  141. style="width: 150px;"
  142. @keyup.enter="handleGdbhEnter"
  143. placeholder="Enter回车"
  144. />
  145. </el-form-item>
  146. </el-col>
  147. <el-col :span="5">
  148. <el-form-item label="拼印主工单">
  149. <el-input
  150. v-model="detailData.qczl_Pygd"
  151. style="width: 150px;"
  152. />
  153. </el-form-item>
  154. </el-col>
  155. <el-col :span="6">
  156. <el-form-item label="产品名称" >
  157. <el-input v-model="detailData.Gd_cpmc"
  158. style="width: 300px;" readonly />
  159. </el-form-item>
  160. </el-col>
  161. </el-row>
  162. <br>
  163. <el-form-item
  164. label="印件号"
  165. >
  166. <el-input
  167. v-model="detailData.qczl_yjno"
  168. style="width: 60px;"
  169. />
  170. </el-form-item>
  171. <el-form-item
  172. label="印件名称"
  173. style="margin-left: 47px"
  174. >
  175. <el-input
  176. v-model="detailData.yj_yjmc"
  177. style="width: 500px;"
  178. />
  179. </el-form-item>
  180. <el-form-item
  181. label="废品总数"
  182. >
  183. <el-input
  184. v-model="detailData.qczl_fp" id="废品总数"
  185. style="width: 100px;"
  186. />
  187. </el-form-item>
  188. <br>
  189. <el-form-item
  190. label="工序"
  191. >
  192. <el-input
  193. v-model="detailData.qczl_gxmc"
  194. style="width: 200px;"
  195. @keyup.enter.native="getgxsubmit"
  196. />
  197. </el-form-item>
  198. <el-form-item
  199. label="工序号"
  200. >
  201. <el-input
  202. v-model="detailData.qczl_gxh"
  203. style="width: 100px;"
  204. />
  205. </el-form-item>
  206. <el-form-item
  207. label="总流程号"
  208. >
  209. <el-input
  210. v-model="detailData.total_liucheng"
  211. style="width: 100px;"
  212. />
  213. </el-form-item>
  214. <el-form-item
  215. label="流程单号"
  216. >
  217. <el-input
  218. v-model="detailData.qczl_num"
  219. style="width: 60px; margin-left: 5px;"
  220. />
  221. <el-input
  222. v-model="detailData.qczl_NumDesc1"
  223. style="width: 60px; margin-left: 5px;"
  224. />
  225. <el-input
  226. v-model="detailData.qczl_NumDesc2"
  227. style="width: 60px; margin-left: 5px;"
  228. />
  229. <el-input
  230. v-model="detailData.qczl_NumDesc3"
  231. style="width: 60px; margin-left: 5px;"
  232. />
  233. <el-input
  234. v-model="detailData.qczl_NumDesc4"
  235. style="width: 60px; margin-left: 5px;"
  236. />
  237. <el-input
  238. v-model="detailData.qczl_NumDesc5"
  239. style="width: 60px; margin-left: 5px;"
  240. />
  241. <el-input
  242. v-model="detailData.qczl_NumDesc6"
  243. style="width: 60px; margin-left: 5px;"
  244. />
  245. <el-input
  246. v-model="detailData.qczl_NumDesc7"
  247. style="width: 60px; margin-left: 5px;"
  248. />
  249. <el-input
  250. v-model="detailData.qczl_NumDesc8"
  251. style="width: 60px; margin-left: 5px;"
  252. />
  253. </el-form-item>
  254. <el-form-item
  255. label="备注"
  256. >
  257. <el-input
  258. v-model="detailData.qczl_NumDesc"
  259. style="width: 200px;"
  260. />
  261. </el-form-item>
  262. <el-scrollbar height="400px">
  263. <el-table
  264. :data="detailData.table"
  265. border
  266. tooltip-effect="dark"
  267. :row-style="{ height: '20px' }"
  268. :cell-style="{ padding: '0px' }"
  269. :header-row-style="{ height: '20px' }"
  270. :header-cell-style="{ padding: '0px' }"
  271. >
  272. <el-table-column
  273. label="废品类别"
  274. width="200"
  275. >
  276. <template #default="{ row, $index }">
  277. <el-input
  278. v-model="row.fp_lb"
  279. @keyup.enter="handleFplbEnter($index, row)"
  280. />
  281. </template>
  282. </el-table-column>
  283. <el-table-column
  284. label="数量"
  285. width="100"
  286. >
  287. <template #default="{ row, $index }">
  288. <el-input
  289. v-model="row.fp_sl"
  290. @keyup.enter="handleFpslEnter($index, row)"
  291. />
  292. </template>
  293. </el-table-column>
  294. <el-table-column
  295. label="工序及责任机长"
  296. width="500"
  297. >
  298. <template #default="{ row }">
  299. <el-input
  300. v-model="row.fp_gxmc"
  301. />
  302. </template>
  303. </el-table-column>
  304. <el-table-column
  305. label=""
  306. width="100"
  307. >
  308. <template #default="{ row }">
  309. <el-input
  310. v-model="row.fp_bz"
  311. />
  312. </template>
  313. </el-table-column>
  314. <el-table-column
  315. label=""
  316. width="100"
  317. >
  318. <template #default="{ row }">
  319. <el-input
  320. v-model="row.fp_bh"
  321. />
  322. </template>
  323. </el-table-column>
  324. <el-table-column
  325. label=""
  326. width="100"
  327. >
  328. <template #default="{ row }">
  329. <el-input
  330. v-model="row.fp_name"
  331. />
  332. </template>
  333. </el-table-column>
  334. </el-table>
  335. </el-scrollbar>
  336. </el-form>
  337. <template #footer>
  338. <div class="dialog-footer">
  339. <el-button @click="closeDialog">取 消</el-button>
  340. <el-button
  341. type="primary"
  342. @click="enterDialog"
  343. >确 定
  344. </el-button>
  345. </div>
  346. </template>
  347. </el-dialog>
  348. <!-- 废品类别弹出选项框 -->
  349. <el-dialog
  350. v-model="dialogSelectVisible1"
  351. title="选择"
  352. destroy-on-close
  353. width="600px"
  354. >
  355. <el-tree
  356. :data="selecTreeData"
  357. :props="defaultProps"
  358. highlight-current
  359. @node-click="handleFplbClick"
  360. />
  361. </el-dialog>
  362. <!-- 弹出选项框 数量 -->
  363. <el-dialog
  364. v-model="dialogSelectVisible2"
  365. title="选择"
  366. destroy-on-close
  367. width="800px"
  368. @keydown="selectSL($event)"
  369. >
  370. <el-table
  371. tooltip-effect="dark"
  372. :data="selectData"
  373. row-key="ID"
  374. highlight-current-row
  375. border
  376. style="width:100%"
  377. @row-dblclick="handleSelectClick"
  378. ref="table2"
  379. >
  380. <el-table-column
  381. v-for=" column in selectColumns "
  382. :key="column.prop"
  383. :prop="column.prop"
  384. :label="column.label"
  385. :width="column.width"
  386. />
  387. </el-table>
  388. </el-dialog>
  389. <el-dialog v-model="dialogSelectVisible" title="选择" destroy-on-close width="1000px" @keydown="selectGX($event)" >
  390. <el-table tooltip-effect="dark" :data="selectData_gd"
  391. row-key="ID" highlight-current-row="true"
  392. border style="width:100%"
  393. @row-dblclick="handleSelectClick_gd" ref="table_gd"
  394. >
  395. <el-table-column prop="Gd_cpmc" label="工单名称" width="430" />
  396. <el-table-column prop="yj_Yjno" label="印件号" width="100" />
  397. <el-table-column prop="yj_yjmc" label="印件名称" width="430" />
  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. import { useUserStore } from '@/pinia/modules/user'
  473. const userStore = useUserStore()
  474. const sys_id='['+userStore.userInfo.userName+'/'+userStore.userInfo.nickName+']'
  475. defineOptions({
  476. name: '06PackingDocuments'
  477. })
  478. // 侧边栏数据请求
  479. const treeData = reactive([])
  480. const getSideData = async() => {
  481. const response = await getSide()
  482. if (response.code === 0) {
  483. const transformedData = response.data.map(item => ({
  484. label: `${item.date.replace(/-/g, '.')}【单据数: ${item.counts}张】`,
  485. children: item.sys.map(sysItem => ({
  486. label: `${sysItem.sys_id} 【记录数: ${sysItem.count}张】`,
  487. params: {
  488. date: item.date.replace(/\./g, '-'),
  489. sys_id: sysItem.sys_id,
  490. },
  491. })),
  492. }))
  493. treeData.splice(0, treeData.length, ...transformedData)
  494. }
  495. }
  496. getSideData()
  497. // 验证规则
  498. const rule = reactive({
  499. })
  500. const elFormRef = ref()
  501. const elSearchFormRef = ref()
  502. // =========== 表格控制部分 ===========
  503. const tableColumns = [
  504. { label: '工单编号', prop: 'qczl_gdbh', width: '120' },
  505. { label: '印件号', prop: 'qczl_yjno', width: '100' },
  506. { label: '印件名称', prop: 'Gd_cpmc', width: '400' },
  507. { label: '日期', prop: 'qczl_rq', width: '100' },
  508. { label: '流程单号', prop: 'qczl_num', width: '120' },
  509. { label: '流程单备注', prop: 'qczl_NumDesc', width: '120' },
  510. { label: '总废品', prop: 'qczl_fp', width: '100' },
  511. { label: '废品1', prop: 'sl_lb1', width: '250' },
  512. { label: '废品2', prop: 'sl_lb2', width: '250' },
  513. { label: '废品3', prop: 'sl_lb3', width: '250' },
  514. { label: '废品4', prop: 'sl_lb4', width: '250' },
  515. { label: '废品5', prop: 'sl_lb5', width: '250' },
  516. { label: '废品6', prop: 'sl_lb6', width: '250' },
  517. { label: '废品7', prop: 'sl_lb7', width: '250' },
  518. { label: '废品8', prop: 'sl_lb8', width: '250' },
  519. { label: '废品9', prop: 'sl_lb9', width: '250' },
  520. { label: '废品10', prop: 'sl_lb10', width: '250' },
  521. { label: '废品11', prop: 'sl_lb11', width: '250' },
  522. { label: '废品12', prop: 'sl_lb12', width: '250' },
  523. { label: '废品13', prop: 'sl_lb13', width: '250' },
  524. { label: '废品14', prop: 'sl_lb14', width: '250' },
  525. { label: '废品15', prop: 'sl_lb15', width: '250' },
  526. { label: '废品16', prop: 'sl_lb16', width: '250' },
  527. { label: '废品17', prop: 'sl_lb17', width: '250' },
  528. { label: '创建用户', prop: 'sys_id', width: '200' }
  529. ]
  530. const tableData = reactive([])
  531. const GetjtbhVisible = ref(false)
  532. const total = ref(0)
  533. const page = ref(1)
  534. const limit = ref(10)
  535. const JTBHselectData = reactive([])
  536. const searchInfo = ref('')
  537. const params = {
  538. date: '',
  539. sys_id: '',
  540. order: '',
  541. page: page.value.toString(),
  542. limit: limit.value.toString(),
  543. }
  544. // 获取工序
  545. const getgxsubmit = () => {
  546. GetJtbh()
  547. }
  548. const GetJtbh = async() => {
  549. try {
  550. const { qczl_gdbh, qczl_yjno } = detailData
  551. const response = await getYjInfo({ order: qczl_gdbh, yj_no: qczl_yjno })
  552. if (response.code === 0) {
  553. const data = response.data
  554. if (data) {
  555. const tableData = data.gx_data.map(item => ({
  556. gxh: item.Gy0_gxh,
  557. gxmc: item.Gy0_gxmc + (item.Add_gxmc === '' ? '' : '-' + item.Add_gxmc),
  558. // addGxmc: item.Add_gxmc
  559. }))
  560. console.log(tableData)
  561. JTBHselectData.splice(0, JTBHselectData.length, ...tableData)
  562. GetjtbhVisible.value = true
  563. // Now you can use the tableData to populate your table
  564. } else {
  565. console.log('No data found')
  566. }
  567. } else {
  568. console.log('Error: ', response.msg)
  569. }
  570. } catch (error) {
  571. console.error('Error fetching data: ', error)
  572. }
  573. }
  574. const JTBHSelectClick = (row, column, event) => {
  575. const { gxh, gxmc } = row
  576. detailData.qczl_gxmc = gxh + '-' + gxmc
  577. detailData.qczl_gxh = gxh
  578. GetjtbhVisible.value = false
  579. }
  580. // 批量删除控制标记
  581. const deleteVisible = ref(false)
  582. const multipleSelection = ref([])
  583. const minUniqId = ref('')
  584. const getTableData = async() => {
  585. const response = await getTable(params)
  586. if (response.code === 0) {
  587. total.value = response.data.total
  588. // Object.assign(tableData, response.data.rows)
  589. tableData.splice(0, tableData.length, ...response.data.rows)
  590. minUniqId.value = Math.min(...tableData.map(row => row.UniqId))
  591. }
  592. }
  593. // 左侧树结构点击
  594. const handleNodeClick = (node, check) => {
  595. if (node.params) {
  596. params.date = node.params.date
  597. params.sys_id = node.params.sys_id
  598. page.value = 1
  599. handleCurrentChange()
  600. }
  601. }
  602. // 搜索
  603. function handleSearch() {
  604. params.sys_id = ''
  605. params.date = ''
  606. params.order = searchInfo.value
  607. page.value = 1
  608. handleCurrentChange()
  609. }
  610. // 分页
  611. const handleSizeChange = () => {
  612. params.limit = limit.value.toString()
  613. getTableData()
  614. }
  615. // 页面跳转
  616. const handleCurrentChange = () => {
  617. params.page = page.value.toString()
  618. getTableData()
  619. }
  620. // ============== 详情页面 ==============
  621. const detailData = reactive({})
  622. // const selectData = reactive([])
  623. const selectColumns = [
  624. { label: '', prop: 'sczl_gxmc', width: '500' },
  625. { label: '', prop: 'sczl_jtbh', width: '100' },
  626. { label: '', prop: 'sczl_bzdh', width: '100' },
  627. { label: '', prop: 'name', width: '100' },
  628. ]
  629. let selecTreeData = []
  630. // 行为控制标记(弹窗内部需要增还是改)
  631. const type = ref('')
  632. // 弹窗控制标记
  633. const dialogFormVisible = ref(false)
  634. const dialogSelectVisible1 = ref(false)
  635. const dialogSelectVisible2 = ref(false)
  636. let selectIndex = 0
  637. const getDetailData = async(id) => {
  638. try {
  639. const res = await getOneWorkOrder({ UniqId: id })
  640. if (res.code === 0) {
  641. const obj = res.data
  642. // 裁剪返回数据的前后空格
  643. for (const key in obj) {
  644. if (Object.prototype.hasOwnProperty.call(obj, key) && typeof obj[key] === 'string') {
  645. obj[key] = obj[key].trim()
  646. }
  647. }
  648. // 修改日期格式
  649. if (Object.prototype.hasOwnProperty.call(obj, 'qczl_rq') && typeof obj['qczl_rq'] === 'string') {
  650. obj['qczl_rq'] = obj['qczl_rq'].split(' ')[0]
  651. }
  652. Object.assign(detailData, obj)
  653. const table = []
  654. // 循环13行数据
  655. for (let i = 1; i <= 13; i++) {
  656. table.push({
  657. fp_lb: detailData[`fp_lb${i}`] || '',
  658. fp_sl: detailData[`fp_sl${i}`] || '',
  659. fp_gxmc: detailData[`fp_gxmc${i}`] || '',
  660. fp_bz: detailData[`fp_bz${i}`] || '',
  661. fp_bh: detailData[`fp_bh${i}`] || '',
  662. fp_name: detailData[`fp_name${i}`] || '',
  663. })
  664. // 从原对象中删除这些属性
  665. delete detailData[`fp_lb${i}`]
  666. delete detailData[`fp_sl${i}`]
  667. delete detailData[`fp_gxmc${i}`]
  668. delete detailData[`fp_bz${i}`]
  669. delete detailData[`fp_bh${i}`]
  670. delete detailData[`fp_name${i}`]
  671. }
  672. detailData.table = table
  673. try {
  674. const res = await getOrderInfo({ order: detailData.qczl_gdbh })
  675. if (res.code === 0) {
  676. detailData.Gd_cpmc = res.data.Gd_cpmc
  677. // dialogFormVisible.value = true
  678. showDialog()
  679. }
  680. } catch (e) {
  681. console.log(e)
  682. }
  683. }
  684. } catch (e) {
  685. console.log(e)
  686. }
  687. }
  688. // 工单编号回车
  689. const handleGdbhEnter = async() => {
  690. if(detailData.qczl_gdbh!=''){
  691. const res = await getOrderInfo({ order: detailData.qczl_gdbh })
  692. if (res.code === 0) {
  693. if(res.data.length==0){
  694. ElMessage({
  695. type: 'error',
  696. message: '查无此编号的工单,请仔细检查后重新输入'
  697. })
  698. //设置输入框的值为空
  699. detailData.Gd_cpmc = ''
  700. detailData.qczl_yjno = ''
  701. detailData.yj_yjmc = ''
  702. }else if(res.data.length==1){
  703. detailData.Gd_cpmc = res.data[0]['Gd_cpmc']
  704. detailData.qczl_yjno = res.data[0]['yj_Yjno']
  705. detailData.yj_yjmc = res.data[0]['yj_yjmc']
  706. }else if(res.data.length>1){
  707. document.getElementById('废品总数').focus()
  708. selectData_gd.splice(0, selectData_gd.length, ...res.data)
  709. setGXCurrent(selectData_gd[0])
  710. dialogSelectVisible.value=true
  711. }
  712. }
  713. }else{
  714. detailData.Gd_cpmc = ''
  715. detailData.qczl_yjno = ''
  716. detailData.yj_yjmc = ''
  717. }
  718. }
  719. const dialogSelectVisible = ref(false)
  720. const selectData_gd = reactive([])
  721. // 处理选择框
  722. const handleSelectClick_gd = (row, column, event) => {
  723. detailData.Gd_cpmc = row.Gd_cpmc
  724. detailData.qczl_yjno = row.yj_Yjno
  725. detailData.yj_yjmc = row.yj_yjmc
  726. dialogSelectVisible.value = false
  727. }
  728. const currentIndex = ref(0);
  729. const GXCurrent = ref(0);
  730. const selectGX = (event) => {
  731. if (event.keyCode === 40) { // 向下箭头
  732. if (currentIndex.value < selectData_gd.length - 1) {
  733. currentIndex.value++;
  734. setGXCurrent(selectData_gd[currentIndex.value]);
  735. } else {
  736. currentIndex.value = 0;
  737. setGXCurrent(selectData_gd[currentIndex.value]); // 到达最后一行时回到第一行
  738. }
  739. } else if (event.keyCode === 38) { // 向上箭头
  740. if (currentIndex.value > 0) {
  741. currentIndex.value--;
  742. setGXCurrent(selectData_gd[currentIndex.value]);
  743. } else {
  744. currentIndex.value = selectData_gd.length - 1;
  745. setGXCurrent(selectData_gd[currentIndex.value]); // 到达第一行时回到最后一行
  746. }
  747. } else if (event.keyCode === 13) { // 回车键
  748. dialogSelectVisible.value = false;
  749. }
  750. }
  751. const table_gd = ref()
  752. const setGXCurrent = (row) => {
  753. setTimeout(()=>{
  754. table_gd.value?.setCurrentRow(row)
  755. detailData.Gd_cpmc = row.Gd_cpmc
  756. detailData.qczl_yjno = row.yj_Yjno
  757. detailData.yj_yjmc = row.yj_yjmc
  758. })
  759. }
  760. // 废品类别回车
  761. const handleFplbEnter = async(index, row) => {
  762. let res
  763. try {
  764. res = await getWastInfo({ search: row.fp_lb })
  765. if (res.code !== 0) {
  766. return
  767. }
  768. } catch (e) {
  769. console.log(e)
  770. return
  771. }
  772. const obj = res.data
  773. const treeData = []
  774. for (const category in obj) {
  775. if (Object.prototype.hasOwnProperty.call(obj, category)) {
  776. const children = []
  777. for (const subCategory in obj[category]) {
  778. if (Object.prototype.hasOwnProperty.call(obj[category], subCategory)) {
  779. const subChildren = obj[category][subCategory].map(item => {
  780. return { label: item }
  781. })
  782. children.push({
  783. label: subCategory,
  784. children: subChildren
  785. })
  786. }
  787. }
  788. treeData.push({
  789. label: category,
  790. children: children
  791. })
  792. }
  793. }
  794. selecTreeData = treeData
  795. selectIndex = index
  796. dialogSelectVisible1.value = true
  797. }
  798. const handleFplbClick = (node, check) => {
  799. if (!node.children) {
  800. detailData.table[selectIndex].fp_lb = node.label
  801. dialogSelectVisible1.value = false
  802. }
  803. }
  804. let selectData = [] // 将const改为let
  805. const handleFpslEnter = async (index, row) => {
  806. if (row.fp_sl === '0') {
  807. detailData.table[index].fp_gxmc = ''
  808. detailData.table[index].fp_bz = ''
  809. detailData.table[index].fp_bh = ''
  810. detailData.table[index].fp_name = ''
  811. return
  812. }
  813. const params = {
  814. type: row.fp_lb,
  815. order: detailData.qczl_gdbh,
  816. }
  817. let res
  818. try {
  819. res = await getGxAndLeader(params)
  820. if (res.code !== 0) {
  821. return
  822. }
  823. } catch (e) {
  824. console.log(e)
  825. return
  826. }
  827. // 解译乱码并填充到selectData
  828. const decodedData = res.data.map(item => {
  829. return {
  830. sczl_gxmc: decodeEntities(item.sczl_gxmc), // 解译乱码函数
  831. sczl_bzdh: item.sczl_bzdh,
  832. sczl_jtbbh: item.sczl_jtbh,
  833. sczl_bh1: item.sczl_bh1,
  834. name: item.name.trim() // 去除姓名两端的空格
  835. }
  836. })
  837. selectData = decodedData // 对selectData进行赋值
  838. setCurrent(selectData[0])
  839. dialogSelectVisible2.value = true
  840. }
  841. // 解译HTML实体编码的函数
  842. function decodeEntities(encodedString) {
  843. const textArea = document.createElement('textarea')
  844. textArea.innerHTML = encodedString
  845. return textArea.value
  846. }
  847. // 双击表格操作
  848. function doubleClick(row, column, event) {
  849. type.value = '查改'
  850. getDetailData(row.UniqId)
  851. }
  852. // 处理选择框回车操作
  853. const handleSelectClick = (row, column, event) => {
  854. const { sczl_gxmc, sczl_bzdh, sczl_bh1, name } = row
  855. const index = selectIndex
  856. detailData.table[index].fp_gxmc = sczl_gxmc
  857. detailData.table[index].fp_bz = sczl_bzdh
  858. detailData.table[index].fp_bh = sczl_bh1
  859. detailData.table[index].fp_name = name
  860. dialogSelectVisible2.value = false
  861. }
  862. const table2 = ref()
  863. const setCurrent = (row) => {
  864. setTimeout(()=>{
  865. table2.value?.setCurrentRow(row)
  866. // SelectClick(row)
  867. // console.log(row)
  868. // console.log(table)
  869. const { sczl_gxmc, sczl_bzdh, sczl_bh1, name } = row
  870. const index = selectIndex
  871. detailData.table[index].fp_gxmc = sczl_gxmc
  872. detailData.table[index].fp_bz = sczl_bzdh
  873. detailData.table[index].fp_bh = sczl_bh1
  874. detailData.table[index].fp_name = name
  875. })
  876. }
  877. const SLIndex = ref(0);
  878. const JYCurrent = ref(0);
  879. const selectSL = (event) => {
  880. if (event.keyCode === 40) { // 向下箭头
  881. if (SLIndex.value < selectData.length - 1) {
  882. SLIndex.value++;
  883. setCurrent(selectData[SLIndex.value]);
  884. } else {
  885. SLIndex.value = 0;
  886. setCurrent(selectData[SLIndex.value]); // 到达最后一行时回到第一行
  887. }
  888. } else if (event.keyCode === 38) { // 向上箭头
  889. if (SLIndex.value > 0) {
  890. SLIndex.value--;
  891. setCurrent(selectData[SLIndex.value]);
  892. } else {
  893. SLIndex.value = selectData.length - 1;
  894. setCurrent(selectData[SLIndex.value]); // 到达第一行时回到最后一行
  895. }
  896. } else if (event.keyCode === 13) { // 回车键
  897. dialogSelectVisible2.value = false
  898. }
  899. }
  900. // 弹窗确定
  901. const enterDialog = async() => {
  902. if (type.value === '查改') {
  903. updateDetailData()
  904. } else if (type.value === '新增') {
  905. addDetailData()
  906. }
  907. }
  908. const addDetailData = async () => {
  909. const formatDate = (date) => {
  910. const year = date.getFullYear();
  911. const month = String(date.getMonth() + 1).padStart(2, '0');
  912. const day = String(date.getDate()).padStart(2, '0');
  913. return `${year}-${month}-${day}`;
  914. };
  915. const restoredData = {
  916. UniqId: detailData.UniqId,
  917. qczl_gdbh: detailData.qczl_gdbh,
  918. qczl_yjno: detailData.qczl_yjno,
  919. qczl_gxh: detailData.qczl_gxh,
  920. qczl_gxmc: detailData.qczl_gxmc,
  921. qczl_rq: formatDate(new Date(detailData.qczl_rq)),
  922. qczl_fp: detailData.qczl_fp,
  923. qczl_num: detailData.qczl_num,
  924. qczl_NumDesc: detailData.qczl_NumDesc,
  925. qczl_NumDesc1: detailData.qczl_NumDesc1,
  926. qczl_NumDesc2: detailData.qczl_NumDesc2,
  927. qczl_NumDesc3: detailData.qczl_NumDesc3,
  928. qczl_NumDesc4: detailData.qczl_NumDesc4,
  929. qczl_NumDesc5: detailData.qczl_NumDesc5,
  930. qczl_NumDesc6: detailData.qczl_NumDesc6,
  931. qczl_NumDesc7: detailData.qczl_NumDesc7,
  932. qczl_NumDesc8: detailData.qczl_NumDesc8,
  933. sys_id: sys_id
  934. };
  935. detailData.table.forEach((item, index) => {
  936. const num = index + 1;
  937. restoredData[`fp_lb${num}`] = item.fp_lb;
  938. restoredData[`fp_sl${num}`] = item.fp_sl;
  939. restoredData[`fp_bh${num}`] = item.fp_bh;
  940. restoredData[`fp_bz${num}`] = item.fp_bz;
  941. restoredData[`fp_gxmc${num}`] = item.fp_gxmc;
  942. });
  943. console.log(restoredData);
  944. const res = await add(restoredData)
  945. console.log(res)
  946. if (res.code === 0) {
  947. ElMessage({
  948. type: 'success',
  949. message: '新增成功',
  950. })
  951. //刷新
  952. if(params.date!=''){
  953. getTableData()
  954. }
  955. getSideData()
  956. dialogFormVisible.value = false
  957. }
  958. };
  959. // 修改
  960. const updateDetailData = async() => {
  961. const formatDate = (date) => {
  962. const year = date.getFullYear();
  963. const month = String(date.getMonth() + 1).padStart(2, '0');
  964. const day = String(date.getDate()).padStart(2, '0');
  965. return `${year}-${month}-${day}`;
  966. };
  967. const restoredData = {
  968. UniqId: detailData.UniqId,
  969. qczl_gdbh: detailData.qczl_gdbh,
  970. qczl_yjno: detailData.qczl_yjno,
  971. qczl_gxh: detailData.qczl_gxh,
  972. qczl_gxmc: detailData.qczl_gxmc,
  973. qczl_rq: formatDate(new Date(detailData.qczl_rq)),
  974. qczl_fp: detailData.qczl_fp,
  975. qczl_num: detailData.qczl_num,
  976. qczl_NumDesc: detailData.qczl_NumDesc,
  977. qczl_NumDesc1: detailData.qczl_NumDesc1,
  978. qczl_NumDesc2: detailData.qczl_NumDesc2,
  979. qczl_NumDesc3: detailData.qczl_NumDesc3,
  980. qczl_NumDesc4: detailData.qczl_NumDesc4,
  981. qczl_NumDesc5: detailData.qczl_NumDesc5,
  982. qczl_NumDesc6: detailData.qczl_NumDesc6,
  983. qczl_NumDesc7: detailData.qczl_NumDesc7,
  984. qczl_NumDesc8: detailData.qczl_NumDesc8,
  985. }
  986. detailData.table.forEach((item, index) => {
  987. const num = index + 1
  988. restoredData[`fp_lb${num}`] = item.fp_lb
  989. restoredData[`fp_sl${num}`] = item.fp_sl
  990. restoredData[`fp_bh${num}`] = item.fp_bh
  991. restoredData[`fp_bz${num}`] = item.fp_bz
  992. restoredData[`fp_gxmc${num}`] = item.fp_gxmc
  993. })
  994. const res = await updateData(restoredData)
  995. if (res.code === 0) {
  996. ElMessage({
  997. type: 'success',
  998. message: res.msg,
  999. })
  1000. dialogFormVisible.value = false
  1001. }
  1002. }
  1003. // 多选
  1004. const handleSelectionChange = (val) => {
  1005. multipleSelection.value = val
  1006. }
  1007. // 多选删除
  1008. const onDelete = async() => {
  1009. const ids = []
  1010. if (multipleSelection.value.length === 0) {
  1011. ElMessage({
  1012. type: 'warning',
  1013. message: '请选择要删除的数据'
  1014. })
  1015. return
  1016. }
  1017. multipleSelection.value &&
  1018. multipleSelection.value.map(item => {
  1019. ids.push(item.ID)
  1020. })
  1021. const res = await deleteCompanyByIds({ ids })
  1022. if (res.code === 0) {
  1023. ElMessage({
  1024. type: 'success',
  1025. message: '删除成功'
  1026. })
  1027. if (tableData.value.length === ids.length && page.value > 1) {
  1028. page.value--
  1029. }
  1030. deleteVisible.value = false
  1031. getTableData()
  1032. }
  1033. }
  1034. // 更新行
  1035. const updateCompanyFunc = async(row) => {
  1036. const res = await findCompany({ ID: row.ID })
  1037. type.value = 'update'
  1038. if (res.code === 0) {
  1039. formData.value = res.data.recompany
  1040. // dialogFormVisible.value = true
  1041. showDialog()
  1042. }
  1043. }
  1044. // 关闭弹窗
  1045. const closeDialog = () => {
  1046. dialogFormVisible.value = false
  1047. }
  1048. // 导出excel
  1049. function exportExcel() {
  1050. console.log('导出到excel')
  1051. // dialogSbyxgl.value = true
  1052. }
  1053. const dialogMrhjtj = ref(false)
  1054. const dialogGdzjfptj = ref(false)
  1055. const dialogSbyxgl = ref(false)
  1056. const value1 = ref('')
  1057. const table = ref(null)
  1058. const showGdzjfptj = () => {
  1059. value1.value = currentRow.value?.qczl_gdbh
  1060. dialogGdzjfptj.value = true
  1061. }
  1062. const currentRow = ref()
  1063. const handleSelectChange = (row, column, event) => {
  1064. currentRow.value = row.UniqId
  1065. }
  1066. // 新增数据
  1067. const handleShowAdd = async() => {
  1068. type.value = '新增'
  1069. if(minUniqId.value==''){
  1070. console.log('123')
  1071. // 循环13行数据
  1072. const table = []
  1073. for (let i = 1; i <= 13; i++) {
  1074. table.push({
  1075. fp_lb: '',
  1076. fp_sl: '',
  1077. fp_gxmc: '',
  1078. fp_bz: '',
  1079. fp_bh: '',
  1080. fp_name: '',
  1081. })
  1082. }
  1083. detailData.table = table
  1084. dialogFormVisible.value = true
  1085. }else{
  1086. getDetailData(minUniqId.value)
  1087. }
  1088. // type.value='add'
  1089. // Object.assign(detailData);
  1090. // dialogFormVisible.value = true
  1091. }
  1092. // 开启弹窗
  1093. const showDialog = () => {
  1094. dialogFormVisible.value = true
  1095. // 在 setTimeout 中获取元素,确保在 DOM 渲染完毕后执行
  1096. setTimeout(() => {
  1097. formElements = document.getElementById('detail-form').elements
  1098. formElements[0].focus()
  1099. }, 0)
  1100. }
  1101. // let formElements
  1102. // const moveFocus = (event) => {
  1103. // const index = Array.from(formElements).indexOf(event.target)
  1104. // const key = event.key
  1105. // event.preventDefault()
  1106. // switch (index) {
  1107. // case 0:
  1108. // if (key === 'ArrowDown') {
  1109. // formElements[1].focus()
  1110. // formElements[1].select();
  1111. // } else if (key === 'ArrowUp') {
  1112. // formElements[formElements.length - 1].focus()
  1113. // } else if (key === 'Enter') {
  1114. // formElements[1].focus()
  1115. // formElements[1].select();
  1116. // }
  1117. // break
  1118. // case formElements.length - 1 :
  1119. // if (key === 'ArrowDown') {
  1120. // formElements[0].focus()
  1121. // formElements[0].select();
  1122. // } else if (key === 'ArrowUp') {
  1123. // formElements[index - 1].focus()
  1124. // } else if (key === 'Enter') {
  1125. // formElements[0].focus()
  1126. // formElements[0].select();
  1127. // }
  1128. // break
  1129. // default:
  1130. // if (key === 'ArrowDown') {
  1131. // formElements[index + 1].focus()
  1132. // formElements[index + 1].select();
  1133. // } else if (key === 'ArrowUp') {
  1134. // formElements[index - 1].focus()
  1135. // formElements[index + 1].select();
  1136. // } else if (key === 'Enter') {
  1137. // formElements[index + 1].focus()
  1138. // formElements[index + 1].select();
  1139. // }
  1140. // break
  1141. // }
  1142. // }
  1143. </script>
  1144. <style scoped>
  1145. .JKWTree-container {
  1146. display: flex;
  1147. }
  1148. .JKWTree-tree {
  1149. width: 300px;
  1150. background-color: #fff;
  1151. padding: 10px;
  1152. margin-right: 20px;
  1153. }
  1154. .JKWTree-tree h3 {
  1155. font-size: 15px;
  1156. font-weight: 700;
  1157. margin: 10px 0;
  1158. }
  1159. .JKWTree-content {
  1160. flex: 1;
  1161. }
  1162. .bt{
  1163. margin-left: 2px !important;
  1164. padding: 3px !important;
  1165. font-size: 12px;
  1166. }
  1167. /* 选中某行时的背景色 */
  1168. :deep(.el-table__body tr.current-row) > td {
  1169. background: #ff80ff !important;
  1170. }
  1171. </style>