index.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829
  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-scrollbar
  10. height="70vh"
  11. >
  12. <el-tree
  13. :data="treeData"
  14. highlight-current
  15. @node-click="handleNodeClick"
  16. />
  17. </el-scrollbar>
  18. </div>
  19. </el-aside>
  20. </el-scrollbar>
  21. <el-container>
  22. <el-main>
  23. <div class="gva-table-box">
  24. <!-- 按钮区域 -->
  25. <div class="gva-btn-list">
  26. <el-row :span="6">
  27. <el-input
  28. v-model="searchInfo"
  29. style="width: 150px;"
  30. placeholder="输入工单编号"
  31. />
  32. </el-row>
  33. <el-button
  34. type="primary"
  35. :icon="Search"
  36. @click="handleSearch"
  37. >定位
  38. </el-button>
  39. <el-button
  40. type="primary"
  41. :icon="Search"
  42. @click="handleShowDetail"
  43. >查改
  44. </el-button>
  45. <el-button
  46. type="primary"
  47. :icon="Search"
  48. @click="handleShowAdd"
  49. >新增
  50. </el-button>
  51. <el-button
  52. type="primary"
  53. :icon="Delete"
  54. @click="handleDelete"
  55. >删除
  56. </el-button>
  57. <div style="margin-left: auto;">
  58. <el-button
  59. type="primary"
  60. :icon="Download"
  61. @click="handleExportExcel"
  62. >导出到Excel
  63. </el-button>
  64. </div>
  65. </div>
  66. <!-- 数据展示 -->
  67. <el-table
  68. ref="multipleTable"
  69. style="width: 100%"
  70. :data="tableData"
  71. row-key="ID"
  72. highlight-current-row
  73. border
  74. show-overflow-tooltip="true"
  75. :row-style="{ height: '20px' }"
  76. :cell-style="{ padding: '0px' }"
  77. :header-row-style="{ height: '20px' }"
  78. :header-cell-style="{ padding: '0px' }"
  79. @selection-change="handleSelectionChange"
  80. @row-dblclick="handleShowDetail"
  81. @row-click="currentRow = $event"
  82. >
  83. <el-table-column
  84. type="selection"
  85. width="55"
  86. />
  87. <!-- 循环渲染列 -->
  88. <el-table-column
  89. v-for=" column in tableColumns "
  90. :key="column.prop"
  91. :prop="column.prop"
  92. :label="column.label"
  93. :width="column.width"
  94. />
  95. </el-table>
  96. <!-- 分页 -->
  97. <div class="gva-pagination">
  98. <el-pagination
  99. v-model:current-page="page"
  100. v-model:page-size="limit"
  101. layout="total, sizes, prev, pager, next, jumper"
  102. :page-sizes="[10, 30, 50, 100]"
  103. :total="total"
  104. @current-change="handleCurrentChange"
  105. @size-change="handleSizeChange"
  106. />
  107. </div>
  108. </div>
  109. <!-- 弹出框 -->
  110. <el-dialog
  111. v-model="dialogFormVisible"
  112. :title="type"
  113. destroy-on-close
  114. width="1200px"
  115. >
  116. <el-form
  117. ref="elFormRef"
  118. :model="detailData"
  119. inline
  120. label-position="left"
  121. >
  122. <el-form-item
  123. label="日期"
  124. >
  125. <el-input
  126. v-model="detailData.sczl_rq"
  127. style="width: 120px;"
  128. />
  129. </el-form-item>
  130. <el-form-item
  131. label="员工编号"
  132. @keyup.enter="handleGetYg"
  133. >
  134. <el-input
  135. v-model="detailData.sczl_bh"
  136. style="width: 100px;"
  137. />
  138. <el-input
  139. v-model="detailData.name"
  140. style="width: 100px; padding-left: 5px;"
  141. readonly
  142. />
  143. </el-form-item>
  144. <el-form-item label="组别">
  145. <!-- <el-input
  146. v-model="detailData.sczl_bzdh"
  147. style="width: 50px;"
  148. /> -->
  149. <el-select v-model="detailData.sczl_bzdh" placeholder="" style="width: 70px"
  150. >
  151. <el-option label="A班" value="A班"></el-option>
  152. <el-option label="B班" value="B班"></el-option>
  153. </el-select>
  154. </el-form-item>
  155. <br>
  156. <el-form-item
  157. label="计时时数"
  158. style="padding-left: 195px;"
  159. >
  160. <el-input
  161. v-model="detailData.sczl_jsss"
  162. style="width: 100px;"
  163. />
  164. </el-form-item>
  165. <el-form-item label="冲月定额">
  166. <!-- <el-input
  167. v-model="detailData.sczl_冲定额"
  168. style="width: 50px;"
  169. /> -->
  170. <el-select v-model="detailData.sczl_冲定额" placeholder="" style="width: 70px"
  171. >
  172. <el-option label="" value=""></el-option>
  173. <el-option label="是" value="B班"></el-option>
  174. </el-select>
  175. </el-form-item>
  176. <el-table
  177. :data="detailData.table"
  178. border
  179. tooltip-effect="dark"
  180. :row-style="{ height: '20px' }"
  181. :cell-style="{ padding: '0px' }"
  182. :header-row-style="{ height: '20px' }"
  183. :header-cell-style="{ padding: '0px' }"
  184. >
  185. <el-table-column
  186. label="工单编号"
  187. width="100"
  188. >
  189. <template #default="{ row, $index }">
  190. <el-input
  191. v-model="row.sczl_gdbh"
  192. @keyup.enter="handleEnter($index, row)"
  193. />
  194. </template>
  195. </el-table-column>
  196. <el-table-column
  197. label="印件工序"
  198. width="100"
  199. >
  200. <template #default="{ row }">
  201. <el-input
  202. v-model="row.sczl_yjGx"
  203. readonly
  204. />
  205. </template>
  206. </el-table-column>
  207. <el-table-column
  208. label="工序名称"
  209. width="100"
  210. >
  211. <template #default="{ row }">
  212. <el-input
  213. v-model="row.sczl_gxmc"
  214. readonly
  215. />
  216. </template>
  217. </el-table-column>
  218. <el-table-column label="印件名称">
  219. <template #default="{ row }">
  220. <el-input
  221. v-model="row.Gd_cpmc"
  222. readonly
  223. />
  224. </template>
  225. </el-table-column>
  226. <el-table-column
  227. label="包装产量"
  228. width="100"
  229. >
  230. <template #default="{ row }">
  231. <el-input v-model="row.sczl_cl" />
  232. </template>
  233. </el-table-column>
  234. <el-table-column
  235. label="返工产量"
  236. width="100"
  237. >
  238. <template #default="{ row }">
  239. <el-input v-model="row.sczl_返工产量" />
  240. </template>
  241. </el-table-column>
  242. <el-table-column
  243. label="每箱数量"
  244. width="100"
  245. >
  246. <template #default="{ row }">
  247. <el-input v-model="row.sczl_PgCl" />
  248. </template>
  249. </el-table-column>
  250. <el-table-column
  251. label="计产系数"
  252. width="100"
  253. >
  254. <template #default="{ row }">
  255. <el-input v-model="row.sczl_计产系数" />
  256. </template>
  257. </el-table-column>
  258. <el-table-column
  259. label="来源"
  260. width="100"
  261. >
  262. <template #default="{ row }">
  263. <el-input v-model="row.sczl_Jtbh1" />
  264. </template>
  265. </el-table-column>
  266. <el-table-column
  267. label="定额代号"
  268. width="100"
  269. >
  270. <template #default="{ row }">
  271. <el-input v-model="row.sczl_dedh" @keyup.enter.native="getDedhsubmit" />
  272. </template>
  273. </el-table-column>
  274. </el-table>
  275. <el-form-item
  276. label="其他备注"
  277. style="margin-top: 10px;"
  278. >
  279. <el-input v-model="detailData.sczl_desc" />
  280. </el-form-item>
  281. </el-form>
  282. <template #footer>
  283. <div class="dialog-footer">
  284. <el-button @click="dialogFormVisible = false">取 消</el-button>
  285. <el-button
  286. type="primary"
  287. @click="enterDialog"
  288. >确 定
  289. </el-button>
  290. </div>
  291. </template>
  292. </el-dialog>
  293. <!-- 弹出选项框 -->
  294. <el-dialog
  295. v-model="dialogSelectVisible"
  296. title="选择"
  297. destroy-on-close
  298. width="600px"
  299. >
  300. <el-table
  301. tooltip-effect="dark"
  302. :data="selectData"
  303. row-key="ID"
  304. highlight-current-row
  305. border
  306. style="width:100%"
  307. @row-dblclick="handleSelectClick"
  308. >
  309. <el-table-column
  310. prop="Gd_cpmc"
  311. label="产品名称"
  312. width="300"
  313. />
  314. <el-table-column
  315. prop="Gy0_gxmc"
  316. label="产品名称"
  317. width="100"
  318. />
  319. <el-table-column
  320. prop="jyGx"
  321. label="产品名称"
  322. width="100"
  323. />
  324. </el-table>
  325. </el-dialog>
  326. </el-main>
  327. </el-container>
  328. </el-container>
  329. </div>
  330. </template>
  331. <script setup>
  332. import { ElMessage, ElMessageBox } from 'element-plus'
  333. import { Download, Search, Delete } from '@element-plus/icons-vue'
  334. import { reactive, ref } from 'vue'
  335. import { getGxMc, getInfo, getLocate, getPackingSideTable, getPackingTable, updatePackingTable, getYg, DeletePackingTable, addPackingTable,getDedh } from '@/api/mes_api_gty/myapi'
  336. defineOptions({
  337. name: '06PackingDocuments',
  338. })
  339. // region 侧边栏功能
  340. const treeData = reactive([])
  341. const getSideData = async() => {
  342. try {
  343. const response = await getPackingSideTable()
  344. if (response.code === 0) {
  345. const transformedData = response.data.map(item => ({
  346. label: `${item.date.replace(/-/g, '.')}【单据数: ${item.counts}张】`,
  347. children: item.sys.map(sysItem => ({
  348. label: `${sysItem.sys_id} 【记录数: ${sysItem.count}张】`,
  349. params: {
  350. date: item.date.replace(/\./g, '-'),
  351. sys_id: sysItem.sys_id,
  352. },
  353. })),
  354. }))
  355. treeData.splice(0, treeData.length, ...transformedData)
  356. }
  357. } catch (e) {
  358. console.log(e)
  359. }
  360. }
  361. getSideData()
  362. // endregion
  363. // region 表格功能
  364. const tableColumns = [
  365. { label: '员工编号', prop: 'sczl_bh', width: '100' },
  366. { label: '员工姓名', prop: 'name', width: '100' },
  367. { label: '生产日期', prop: 'sczl_rq', width: '100' },
  368. { label: '班组', prop: 'sczl_bzdh', width: '100' },
  369. { label: '包装产量', prop: 'sczl_cl', width: '100' },
  370. { label: '返工产量', prop: 'sczl_fgsl', width: '100' },
  371. { label: '计件产量', prop: 'sczl_jjcl', width: '100' },
  372. { label: '相关工单', prop: 'sczl_gdbh1', width: '100' },
  373. { label: '创建用户', prop: 'sys_id', width: '120' },
  374. { label: '创建时间', prop: 'sys_rq', width: '180' },
  375. { label: '修改时间', prop: 'mod_rq', width: '180' },
  376. { label: 'UNIQID', prop: 'UniqId', width: '100' },
  377. ]
  378. const tableData = reactive([])
  379. const params = {
  380. type: '',
  381. date: '',
  382. sys_id: '',
  383. gdbh: '',
  384. }
  385. const total = ref(0)
  386. const page = ref(1)
  387. const limit = ref(10)
  388. const type = ref('')
  389. const searchInfo = ref('')
  390. const currentRow = ref({})
  391. const multipleSelection = ref([])
  392. const minUniqId = ref('')
  393. // 获取列表数据
  394. const getTableData = async() => {
  395. try {
  396. const response = await getPackingTable({
  397. date: params.date, sys_id: params.sys_id,
  398. page: page.value.toString(), limit: limit.value.toString(),
  399. })
  400. if (response.code === 0) {
  401. total.value = response.data.total;
  402. // 清空原有数据并填充新数据
  403. tableData.splice(0, tableData.length, ...response.data.rows);
  404. // 获取最大的 UniqId
  405. minUniqId.value= Math.min(...tableData.map(row => row.UniqId));
  406. console.log('最小的 UniqId:', minUniqId.value);
  407. } else {
  408. console.error('获取数据失败:', response.msg);
  409. }
  410. } catch (e) {
  411. console.log(e)
  412. }
  413. }
  414. // 获取定位数据
  415. const getLocateTable = async() => {
  416. try {
  417. const response = await getLocate({
  418. gdbh: params.gdbh,
  419. page: page.value.toString(), limit: limit.value.toString(),
  420. })
  421. if (response.code === 0) {
  422. total.value = response.data.total
  423. tableData.splice(0, tableData.length, ...response.data.rows)
  424. }
  425. } catch (e) {
  426. console.log(e)
  427. }
  428. }
  429. // 删除数据
  430. const deleteTableData = async(id) => {
  431. try {
  432. const res = await DeletePackingTable({ UniqId: id })
  433. if (res.code === 0) {
  434. return 0
  435. }
  436. } catch (e) {
  437. console.log(e)
  438. }
  439. }
  440. const handleNodeClick = (node, check) => {
  441. if (node.params) {
  442. params.date = node.params.date
  443. params.sys_id = node.params.sys_id
  444. params.type = 'getTableData'
  445. page.value = 1
  446. getTableData()
  447. }
  448. }
  449. // 定位
  450. const handleSearch = () => {
  451. params.gdbh = searchInfo.value
  452. params.type = 'getLocateTable'
  453. page.value = 1
  454. getLocateTable()
  455. }
  456. // 查改
  457. const handleShowDetail = () => {
  458. type.value = '查改'
  459. getTableInfo(currentRow.value?.UniqId)
  460. }
  461. // 删除
  462. const handleDelete = () => {
  463. console.log(currentRow.value)
  464. ElMessageBox.confirm(
  465. `确认删除这条数据么?`,
  466. '警告',
  467. {
  468. confirmButtonText: '确认',
  469. cancelButtonText: '取消',
  470. type: 'warning',
  471. }
  472. )
  473. .then(async() => {
  474. const ret = await deleteTableData(currentRow.value?.UniqId)
  475. console.log(ret)
  476. if (ret === 0) {
  477. ElMessage({
  478. type: 'success',
  479. message: '删除成功',
  480. })
  481. } else {
  482. ElMessage({
  483. type: 'error',
  484. message: '删除失败',
  485. })
  486. }
  487. })
  488. .catch(() => {
  489. ElMessage({
  490. type: 'info',
  491. message: '取消删除',
  492. })
  493. })
  494. }
  495. // 分页
  496. const handleSizeChange = () => {
  497. switch (params.type) {
  498. case 'getTableData':
  499. getTableData()
  500. break
  501. case 'getLocateTable':
  502. getLocateTable()
  503. break
  504. default:
  505. break
  506. }
  507. }
  508. const handleCurrentChange = () => {
  509. switch (params.type) {
  510. case 'getTableData':
  511. getTableData()
  512. break
  513. case 'getLocateTable':
  514. getLocateTable()
  515. break
  516. default:
  517. break
  518. }
  519. }
  520. // endregion
  521. // region 详情界面
  522. const detailData = reactive({
  523. UniqId: '',
  524. selectIndex: 0,
  525. sczl_rq: '',
  526. sczl_bh: '',
  527. name: '',
  528. sczl_bzdh: '',
  529. sczl_jsss: '',
  530. sczl_冲定额: '',
  531. sczl_desc: '',
  532. table: [],
  533. })
  534. const selectData = reactive([])
  535. // 弹窗控制标记
  536. const dialogFormVisible = ref(false)
  537. const dialogSelectVisible = ref(false)
  538. // 获取详细信息
  539. const getTableInfo = async(id) => {
  540. try {
  541. const response = await getInfo({ UniqId: id })
  542. if (response.code === 0) {
  543. const { sczl_rq, sczl_bh, name, sczl_bzdh, sczl_jsss, sczl_冲定额, sczl_desc, ...rest } = response.data
  544. // 直接赋值基础属性
  545. Object.assign(detailData, { sczl_rq, sczl_bh, name, sczl_bzdh, sczl_jsss, sczl_冲定额, sczl_desc })
  546. // 生成表格数据
  547. detailData.table = Array.from({ length: 6 }, (_, i) => i + 1) // 创建一个长度为6的数组 [1, 2, 3, 4, 5, 6]
  548. .map(num => {
  549. return {
  550. sczl_gdbh: rest[`sczl_gdbh${num}`],
  551. sczl_yjGx: rest[`sczl_yjGx${num}`],
  552. sczl_gxmc: rest[`sczl_gxmc${num}`],
  553. Gd_cpmc: rest[`Gd_cpmc${num}`],
  554. sczl_cl: rest[`sczl_cl${num}`],
  555. sczl_返工产量: rest[`sczl_返工产量${num}`],
  556. sczl_PgCl: rest[`sczl_PgCl${num}`],
  557. sczl_计产系数: rest[`sczl_计产系数${num}`],
  558. sczl_Jtbh1: rest[`sczl_Jtbh${num}`],
  559. sczl_dedh: rest[`sczl_dedh${num}`],
  560. }
  561. })
  562. // .filter(item => item.sczl_gdbh !== '') // 过滤掉空的工单编号
  563. detailData.UniqId = id
  564. dialogFormVisible.value = true
  565. }
  566. } catch (e) {
  567. console.log(e)
  568. }
  569. }
  570. // 获取工序名称
  571. const getTableGxMc = async(index, row) => {
  572. try {
  573. const response = await getGxMc({ gdbh: row.sczl_gdbh })
  574. if (response.code === 0) {
  575. const { Gd_cpmc, Gy0_gxmc, jyGx } = response.data[0]
  576. if (response.data.length === 1) {
  577. detailData.table[index].Gd_cpmc = Gd_cpmc
  578. detailData.table[index].sczl_yjGx = jyGx
  579. detailData.table[index].sczl_gxmc = Gy0_gxmc
  580. } else {
  581. selectData.splice(0, selectData.length, ...response.data)
  582. detailData.selectIndex = index
  583. dialogSelectVisible.value = true
  584. }
  585. }
  586. } catch (e) {
  587. console.log(e)
  588. }
  589. }
  590. // 更新数据
  591. const updateDetailData = async() => {
  592. const restoredData = {
  593. UniqId: detailData.UniqId,
  594. sczl_rq: detailData.sczl_rq,
  595. sczl_bh: detailData.sczl_bh,
  596. name: detailData.name,
  597. sczl_bzdh: detailData.sczl_bzdh,
  598. sczl_jsss: detailData.sczl_jsss,
  599. sczl_冲定额: detailData.sczl_冲定额,
  600. sczl_desc: detailData.sczl_desc,
  601. }
  602. detailData.table.forEach((item, index, array) => {
  603. const num = index + 1
  604. restoredData[`sczl_gdbh${num}`] = item.sczl_gdbh
  605. restoredData[`sczl_yjGx${num}`] = item.sczl_yjGx
  606. restoredData[`sczl_gxmc${num}`] = item.sczl_gxmc
  607. restoredData[`Gd_cpmc${num}`] = item.Gd_cpmc
  608. restoredData[`sczl_cl${num}`] = item.sczl_cl
  609. restoredData[`sczl_返工产量${num}`] = item.sczl_返工产量
  610. restoredData[`sczl_PgCl${num}`] = item.sczl_PgCl
  611. restoredData[`sczl_计产系数${num}`] = item.sczl_计产系数
  612. restoredData[`sczl_Jtbh${num}`] = item.sczl_Jtbh1
  613. restoredData[`sczl_dedh${num}`] = item.sczl_dedh
  614. })
  615. const res = await updatePackingTable(restoredData)
  616. if (res.code === 0) {
  617. ElMessage({
  618. type: 'success',
  619. message: '更新成功',
  620. })
  621. dialogFormVisible.value = false
  622. }
  623. }
  624. // 新增数据
  625. const handleShowAdd = () => {
  626. type.value = '新增'
  627. getTableInfo2(minUniqId.value)
  628. }
  629. // 获取详细信息
  630. const getTableInfo2 = async(id) => {
  631. try {
  632. const response = await getInfo({ UniqId: id })
  633. if (response.code === 0) {
  634. const { sczl_bh, name, sczl_bzdh, sczl_jsss, sczl_冲定额, sczl_desc, ...rest } = response.data
  635. // 直接赋值基础属性
  636. let sczl_rq = new Date();
  637. console.log(sczl_rq);
  638. sczl_rq.setDate(sczl_rq.getDate() - 1); // 今天的前N天的日期,N自定义
  639. sczl_rq = sczl_rq.getFullYear() + '-' + (sczl_rq.getMonth() + 1) + '-' + sczl_rq.getDate();
  640. console.log(sczl_rq);
  641. Object.assign(detailData, { sczl_rq, sczl_bh, name, sczl_bzdh, sczl_jsss, sczl_冲定额, sczl_desc })
  642. // 生成表格数据
  643. detailData.table = Array.from({ length: 6 }, (_, i) => i + 1) // 创建一个长度为6的数组 [1, 2, 3, 4, 5, 6]
  644. .map(num => {
  645. return {
  646. sczl_gdbh: rest[`sczl_gdbh${num}`],
  647. sczl_yjGx: rest[`sczl_yjGx${num}`],
  648. sczl_gxmc: rest[`sczl_gxmc${num}`],
  649. Gd_cpmc: rest[`Gd_cpmc${num}`],
  650. sczl_cl: rest[`sczl_cl${num}`],
  651. sczl_返工产量: rest[`sczl_返工产量${num}`],
  652. sczl_PgCl: rest[`sczl_PgCl${num}`],
  653. sczl_计产系数: rest[`sczl_计产系数${num}`],
  654. sczl_Jtbh1: rest[`sczl_Jtbh${num}`],
  655. sczl_dedh: rest[`sczl_dedh${num}`],
  656. }
  657. })
  658. // .filter(item => item.sczl_gdbh !== '') // 过滤掉空的工单编号
  659. detailData.UniqId = id
  660. dialogFormVisible.value = true
  661. }
  662. } catch (e) {
  663. console.log(e)
  664. }
  665. }
  666. const addDetailData = async() => {
  667. const restoredData = {
  668. sys_id: params.sys_id,
  669. sczl_rq: detailData.sczl_rq,
  670. sczl_bh: detailData.sczl_bh,
  671. // name: detailData.name,
  672. sczl_bzdh: detailData.sczl_bzdh,
  673. sczl_jsss: detailData.sczl_jsss,
  674. sczl_冲定额: detailData.sczl_冲定额,
  675. sczl_desc: detailData.sczl_desc,
  676. }
  677. detailData.table.forEach((item, index, array) => {
  678. const num = index + 1
  679. restoredData[`sczl_gdbh${num}`] = item.sczl_gdbh
  680. restoredData[`sczl_yjGx${num}`] = item.sczl_yjGx
  681. restoredData[`sczl_gxmc${num}`] = item.sczl_gxmc
  682. // restoredData[`Gd_cpmc${num}`] = item.Gd_cpmc
  683. restoredData[`sczl_cl${num}`] = item.sczl_cl
  684. restoredData[`sczl_返工产量${num}`] = item.sczl_返工产量
  685. restoredData[`sczl_PgCl${num}`] = item.sczl_PgCl
  686. restoredData[`sczl_计产系数${num}`] = item.sczl_计产系数
  687. restoredData[`sczl_Jtbh${num}`] = item.sczl_Jtbh1
  688. restoredData[`sczl_dedh${num}`] = item.sczl_dedh
  689. })
  690. const res = await addPackingTable(restoredData)
  691. console.log(restoredData)
  692. console.log(res)
  693. if (res.code === 0) {
  694. ElMessage({
  695. type: 'success',
  696. message: '新增成功',
  697. })
  698. dialogFormVisible.value = false
  699. getTableData()
  700. getSideData()
  701. }
  702. }
  703. const handleGetYg = async() => {
  704. try {
  705. const res = await getYg({ sczl_bh: detailData.sczl_bh })
  706. if (res.code === 0) {
  707. detailData.name = res.data.ygxm
  708. }
  709. } catch (e) {
  710. console.log(e)
  711. }
  712. }
  713. // 处理选择框回车操作
  714. const handleEnter = (index, row) => {
  715. if (row.sczl_gdbh === '') {
  716. detailData.table[index].sczl_yjGx = ''
  717. detailData.table[index].sczl_gxmc = ''
  718. detailData.table[index].Gd_cpmc = ''
  719. } else {
  720. getTableGxMc(index, row)
  721. }
  722. }
  723. // 处理选择框
  724. const handleSelectClick = (row, column, event) => {
  725. const { Gd_cpmc, Gy0_gxmc, jyGx } = row
  726. const index = detailData.selectIndex
  727. detailData.table[index].Gd_cpmc = Gd_cpmc
  728. detailData.table[index].sczl_yjGx = jyGx
  729. detailData.table[index].sczl_gxmc = Gy0_gxmc
  730. dialogSelectVisible.value = false
  731. }
  732. // 弹窗确定
  733. const enterDialog = () => {
  734. if (type.value === '查改') {
  735. updateDetailData()
  736. } else if (type.value === '新增') {
  737. addDetailData()
  738. }
  739. }
  740. //定额代号回车事件
  741. const getDedhsubmit = () => {
  742. GetDedh()
  743. }
  744. //获取定额代号
  745. const GetDedh = async (value) => {
  746. const response = await getDedh();
  747. if(response.code==0){
  748. }
  749. }
  750. // 导出excel
  751. function handleExportExcel() {
  752. console.log('导出到excel')
  753. }
  754. // 生命周期钩子
  755. </script>
  756. <style scoped>
  757. .JKWTree-container {
  758. display: flex;
  759. }
  760. .JKWTree-tree {
  761. width: 300px;
  762. background-color: #fff;
  763. padding: 10px;
  764. margin-right: 20px;
  765. }
  766. .JKWTree-tree h3 {
  767. font-size: 15px;
  768. font-weight: 700;
  769. margin: 10px 0;
  770. }
  771. .JKWTree-content {
  772. flex: 1;
  773. }
  774. /* 选中某行时的背景色 */
  775. :deep(.el-table__body tr.current-row) > td {
  776. background: #ff80ff !important;
  777. }
  778. :deep(.el-table td .cell) {
  779. line-height: 30px !important;
  780. }
  781. </style>