index.vue 27 KB

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