index.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985
  1. <template>
  2. <div>
  3. <layout>
  4. <layout-header>
  5. <!-- 按钮 -->
  6. <el-form inline>
  7. <el-form-item>
  8. <el-input
  9. v-model="searchInfo"
  10. placeholder="搜索产品编号或产品名称"
  11. clearable
  12. style="width: 180px;"
  13. />
  14. <el-button
  15. type="primary"
  16. icon="Search"
  17. class="search"
  18. @click="handleSearch"
  19. />
  20. <el-button
  21. type="primary"
  22. icon="edit"
  23. class="bt"
  24. @click="handleShowDetail"
  25. ><i class="el-icon-edit" />查改
  26. </el-button>
  27. <el-button
  28. type="primary"
  29. icon="edit"
  30. class="bt"
  31. @click="handleShowAdd"
  32. >新增
  33. </el-button>
  34. <el-button
  35. type="primary"
  36. icon="delete"
  37. class="bt"
  38. @click="handleDelete"
  39. >删除
  40. </el-button>
  41. </el-form-item>
  42. </el-form>
  43. <!-- 弹出框 -->
  44. <div>
  45. <el-dialog
  46. v-model="dialogFormVisible"
  47. :title="type"
  48. destroy-on-close
  49. width="1200px"
  50. >
  51. <el-form
  52. id="detail-form"
  53. :model="detailData"
  54. inline
  55. label-position="left"
  56. @keyup="moveFocus"
  57. >
  58. <el-form-item
  59. label="日期"
  60. >
  61. <el-input
  62. v-model="detailData.sczl_rq"
  63. style="width: 120px;"
  64. />
  65. </el-form-item>
  66. <el-form-item
  67. label="员工编号"
  68. >
  69. <el-input
  70. v-model="detailData.sczl_bh"
  71. style="width: 100px;"
  72. />
  73. <el-input
  74. v-model="detailData.name"
  75. style="width: 100px; padding-left: 5px;"
  76. @click="selectvalue($event)"
  77. readonly
  78. />
  79. </el-form-item>
  80. <el-form-item label="组别">
  81. <el-select
  82. v-model="detailData.sczl_bzdh"
  83. placeholder=" "
  84. style="width: 80px"
  85. >
  86. <el-option
  87. label="A班"
  88. value="A班"
  89. />
  90. <el-option
  91. label="B班"
  92. value="B班"
  93. />
  94. </el-select></el-form-item>
  95. <br>
  96. <el-form-item
  97. label="计时时数"
  98. style="padding-left: 195px;"
  99. >
  100. <el-input
  101. v-model="detailData.sczl_jsss"
  102. style="width: 100px;"
  103. @click="selectvalue($event)"
  104. />
  105. </el-form-item>
  106. <el-form-item label="冲月定额">
  107. <el-select
  108. v-model="detailData.sczl_冲定额"
  109. placeholder=" "
  110. style="width: 100px"
  111. >
  112. <el-option
  113. label=""
  114. value=""
  115. />
  116. <el-option
  117. label="是"
  118. value="是"
  119. />
  120. </el-select>
  121. </el-form-item>
  122. <el-table
  123. :data="detailData.table"
  124. border
  125. tooltip-effect="dark"
  126. :row-style="{ height: '20px' }"
  127. :cell-style="{ padding: '0px' }"
  128. :header-row-style="{ height: '20px' }"
  129. :header-cell-style="{ padding: '0px' }"
  130. >
  131. <el-table-column
  132. label="工单编号"
  133. width="100"
  134. >
  135. <template #default="{ row, $index }">
  136. <el-input
  137. v-model="row.sczl_gdbh"
  138. @keyup.enter="handleEnter($index, row)"
  139. />
  140. </template>
  141. </el-table-column>
  142. <el-table-column
  143. label="印件工序"
  144. width="100"
  145. >
  146. <template #default="{ row }">
  147. <el-input
  148. v-model="row.sczl_yjGx"
  149. readonly
  150. />
  151. </template>
  152. </el-table-column>
  153. <el-table-column
  154. label="工序名称"
  155. width="100"
  156. >
  157. <template #default="{ row }">
  158. <el-input
  159. v-model="row.sczl_gxmc"
  160. readonly
  161. />
  162. </template>
  163. </el-table-column>
  164. <el-table-column label="印件名称">
  165. <template #default="{ row }">
  166. <el-input
  167. v-model="row.Gd_cpmc"
  168. readonly
  169. />
  170. </template>
  171. </el-table-column>
  172. <el-table-column
  173. label="包装产量"
  174. width="100"
  175. >
  176. <template #default="{ row }">
  177. <el-input v-model="row.sczl_cl" />
  178. </template>
  179. </el-table-column>
  180. <el-table-column
  181. label="返工产量"
  182. width="100"
  183. >
  184. <template #default="{ row }">
  185. <el-input v-model="row.sczl_返工产量" />
  186. </template>
  187. </el-table-column>
  188. <el-table-column
  189. label="每箱数量"
  190. width="100"
  191. >
  192. <template #default="{ row }">
  193. <el-input v-model="row.sczl_PgCl" />
  194. </template>
  195. </el-table-column>
  196. <el-table-column
  197. label="计产系数"
  198. width="100"
  199. >
  200. <template #default="{ row }">
  201. <el-input v-model="row.sczl_计产系数" />
  202. </template>
  203. </el-table-column>
  204. <el-table-column
  205. label="来源"
  206. width="100"
  207. >
  208. <template #default="{ row }">
  209. <el-input v-model="row.sczl_Jtbh1" />
  210. </template>
  211. </el-table-column>
  212. <el-table-column
  213. label="定额代号"
  214. width="100"
  215. >
  216. <template #default="{ row }">
  217. <el-input
  218. v-model="row.sczl_dedh"
  219. @keyup.enter.native="getDedhsubmit"
  220. />
  221. </template>
  222. </el-table-column>
  223. </el-table>
  224. <el-form-item
  225. label="其他备注"
  226. style="margin-top: 10px;"
  227. >
  228. <el-input v-model="detailData.sczl_desc" />
  229. </el-form-item>
  230. </el-form>
  231. <template #footer>
  232. <div class="dialog-footer">
  233. <el-button @click="dialogFormVisible = false">取 消</el-button>
  234. <el-button
  235. type="primary"
  236. @click="enterDialog"
  237. >确 定
  238. </el-button>
  239. </div>
  240. </template>
  241. </el-dialog>
  242. <!-- 弹出选项框 -->
  243. <el-dialog
  244. v-model="dialogSelectVisible"
  245. title="选择"
  246. destroy-on-close
  247. width="600px"
  248. @keydown="selectCP($event)"
  249. >
  250. <el-table
  251. tooltip-effect="dark"
  252. :data="selectData"
  253. row-key="ID"
  254. highlight-current-row
  255. border
  256. style="width:100%"
  257. @row-dblclick="handleSelectClick"
  258. ref="table2"
  259. >
  260. <el-table-column
  261. prop="Gd_cpmc"
  262. label="产品名称"
  263. width="300"
  264. />
  265. <el-table-column
  266. prop="Gy0_gxmc"
  267. label="产品名称"
  268. width="100"
  269. />
  270. <el-table-column
  271. prop="jyGx"
  272. label="产品名称"
  273. width="100"
  274. />
  275. </el-table>
  276. </el-dialog>
  277. </div>
  278. </layout-header>
  279. <layout>
  280. <!-- 左侧树侧形结构-->
  281. <layout-sider
  282. :resize-directions="['right']"
  283. :width="220"
  284. style="margin-right: 10px;"
  285. >
  286. <div
  287. class="JKWTree-tree"
  288. style="height: 70vh;"
  289. >
  290. <h3>包装计件单据维护</h3>
  291. <el-tree
  292. :data="treeData"
  293. highlight-current
  294. @node-click="handleNodeClick"
  295. />
  296. </div>
  297. </layout-sider>
  298. <layout-content>
  299. <!-- 数据展示 -->
  300. <div class="gva-table-box">
  301. <el-table
  302. ref="table"
  303. style="width: 100%"
  304. :data="tableData"
  305. row-key="ID"
  306. highlight-current-row
  307. border
  308. show-overflow-tooltip
  309. :row-style="{ height: '20px' }"
  310. :cell-style="{ padding: '0px' }"
  311. :header-row-style="{ height: '20px' }"
  312. :header-cell-style="{ padding: '0px' }"
  313. @row-dblclick="handleShowDetail"
  314. @current-change="(row, oldRow) => { currentRow = row}"
  315. >
  316. <el-table-column
  317. type="selection"
  318. width="55"
  319. />
  320. <!-- 循环渲染列 -->
  321. <el-table-column
  322. v-for=" column in tableColumns "
  323. :key="column.prop"
  324. :prop="column.prop"
  325. :label="column.label"
  326. width="110"
  327. sortable
  328. />
  329. </el-table>
  330. <!-- 分页 -->
  331. <div class="gva-pagination">
  332. <el-pagination
  333. v-model:current-page="page"
  334. v-model:page-size="limit"
  335. layout="total, sizes, prev, pager, next, jumper"
  336. :page-sizes="[10, 30, 50, 100]"
  337. :total="total"
  338. @current-change="handleCurrentChange"
  339. @size-change="handleSizeChange"
  340. />
  341. </div>
  342. </div>
  343. </layout-content>
  344. </layout>
  345. </layout>
  346. </div>
  347. </template>
  348. <script setup>
  349. import { Layout, LayoutContent, LayoutHeader, LayoutSider } from '@arco-design/web-vue'
  350. import { ElMessage, ElMessageBox, dayjs } from 'element-plus'
  351. // import { Download, Search, Delete } from '@element-plus/icons-vue'
  352. import { reactive, ref } from 'vue'
  353. import { getGxMc, getInfo, getLocate, getPackingSideTable, getPackingTable, updatePackingTable, getYg, DeletePackingTable, addPackingTable, getDedh } from '@/api/mes_api_gty/myapi'
  354. import { useUserStore } from '@/pinia/modules/user'
  355. const userStore = useUserStore()
  356. const sys_id='['+userStore.userInfo.userName+'/'+userStore.userInfo.nickName+']'
  357. defineOptions({
  358. name: '06PackingDocuments',
  359. })
  360. // 侧边栏功能
  361. const treeData = reactive([])
  362. const getSideData = async() => {
  363. try {
  364. const response = await getPackingSideTable()
  365. if (response.code === 0) {
  366. const transformedData = response.data.map(item => ({
  367. label: `${item.date.replace(/-/g, '.')}【单据数: ${item.counts}张】`,
  368. children: item.sys.map(sysItem => ({
  369. label: `${sysItem.sys_id} 【记录数: ${sysItem.count}张】`,
  370. params: {
  371. date: item.date.replace(/\./g, '-'),
  372. sys_id: sysItem.sys_id,
  373. },
  374. })),
  375. }))
  376. treeData.splice(0, treeData.length, ...transformedData)
  377. }
  378. } catch (e) {
  379. console.log(e)
  380. }
  381. }
  382. getSideData()
  383. // 表格功能
  384. const tableColumns = [
  385. { label: '员工编号', prop: 'sczl_bh', width: '100' },
  386. { label: '员工姓名', prop: 'name', width: '100' },
  387. { label: '生产日期', prop: 'sczl_rq', width: '100' },
  388. { label: '班组', prop: 'sczl_bzdh', width: '100' },
  389. { label: '包装产量', prop: 'sczl_cl', width: '100' },
  390. { label: '返工产量', prop: 'sczl_fgsl', width: '100' },
  391. { label: '计件产量', prop: 'sczl_jjcl', width: '100' },
  392. { label: '相关工单', prop: 'sczl_gdbh1', width: '100' },
  393. { label: '创建用户', prop: 'sys_id', width: '120' },
  394. { label: '创建时间', prop: 'sys_rq', width: '180' },
  395. { label: '修改时间', prop: 'mod_rq', width: '180' },
  396. { label: 'UNIQID', prop: 'UniqId', width: '100' },
  397. ]
  398. const tableData = reactive([])
  399. const params = {
  400. type: '',
  401. date: '',
  402. sys_id: '',
  403. gdbh: '',
  404. }
  405. const total = ref(0)
  406. const page = ref(1)
  407. const limit = ref(10)
  408. const type = ref('')
  409. const searchInfo = ref('')
  410. const currentRow = ref({})
  411. // const multipleSelection = ref([])
  412. // 获取列表数据
  413. const getTableData = async() => {
  414. try {
  415. const response = await getPackingTable({
  416. date: params.date, sys_id: params.sys_id,
  417. page: page.value.toString(), limit: limit.value.toString(),
  418. })
  419. if (response.code === 0) {
  420. total.value = response.data.total
  421. tableData.splice(0, tableData.length, ...response.data.rows)
  422. setCurrent(tableData[0])
  423. }
  424. } catch (e) {
  425. console.log(e)
  426. }
  427. }
  428. // 获取定位数据
  429. const getLocateTable = async() => {
  430. try {
  431. const response = await getLocate({
  432. gdbh: params.gdbh,
  433. page: page.value.toString(), limit: limit.value.toString(),
  434. })
  435. if (response.code === 0) {
  436. total.value = response.data.total
  437. tableData.splice(0, tableData.length, ...response.data.rows)
  438. }
  439. } catch (e) {
  440. console.log(e)
  441. }
  442. }
  443. // 删除数据
  444. const deleteTableData = async(id) => {
  445. try {
  446. const res = await DeletePackingTable({ UniqId: id })
  447. if (res.code === 0) {
  448. return 0
  449. }
  450. } catch (e) {
  451. console.log(e)
  452. }
  453. }
  454. const handleNodeClick = (node, check) => {
  455. if (node.params) {
  456. params.date = node.params.date
  457. params.sys_id = node.params.sys_id
  458. params.type = 'getTableData'
  459. page.value = 1
  460. getTableData()
  461. }
  462. }
  463. const selectvalue = (e) => {
  464. console.log(e)
  465. e.currentTarget.select();
  466. }
  467. // 定位
  468. const handleSearch = () => {
  469. params.gdbh = searchInfo.value
  470. params.type = 'getLocateTable'
  471. page.value = 1
  472. getLocateTable()
  473. }
  474. // 查改
  475. const handleShowDetail = () => {
  476. type.value = '查改'
  477. getTableInfo(currentRow.value?.UniqId)
  478. }
  479. // 删除
  480. const handleDelete = () => {
  481. console.log(currentRow.value)
  482. ElMessageBox.confirm(
  483. `确认删除这条数据么?`,
  484. '警告',
  485. {
  486. confirmButtonText: '确认',
  487. cancelButtonText: '取消',
  488. type: 'warning',
  489. }
  490. )
  491. .then(async() => {
  492. const ret = await deleteTableData(currentRow.value?.UniqId)
  493. console.log(ret)
  494. if (ret === 0) {
  495. ElMessage({
  496. type: 'success',
  497. message: '删除成功',
  498. })
  499. } else {
  500. ElMessage({
  501. type: 'error',
  502. message: '删除失败',
  503. })
  504. }
  505. })
  506. .catch(() => {
  507. ElMessage({
  508. type: 'info',
  509. message: '取消删除',
  510. })
  511. })
  512. }
  513. // 分页
  514. // #region
  515. const handleSizeChange = () => {
  516. switch (params.type) {
  517. case 'getTableData':
  518. getTableData()
  519. break
  520. case 'getLocateTable':
  521. getLocateTable()
  522. break
  523. default:
  524. break
  525. }
  526. }
  527. const handleCurrentChange = () => {
  528. switch (params.type) {
  529. case 'getTableData':
  530. getTableData()
  531. break
  532. case 'getLocateTable':
  533. getLocateTable()
  534. break
  535. default:
  536. break
  537. }
  538. }
  539. // #endregion
  540. // 详情界面
  541. const detailData = reactive({
  542. UniqId: '',
  543. selectIndex: 0,
  544. sczl_rq: '',
  545. sczl_bh: '',
  546. name: '',
  547. sczl_bzdh: '',
  548. sczl_jsss: '',
  549. sczl_冲定额: '',
  550. sczl_desc: '',
  551. table: [],
  552. })
  553. const selectData = reactive([])
  554. const table = ref()
  555. // 弹窗控制标记
  556. const dialogFormVisible = ref(false)
  557. const dialogSelectVisible = ref(false)
  558. const setCurrent = (row) => {
  559. table.value?.setCurrentRow(row)
  560. }
  561. // 获取详细信息
  562. const getTableInfo = async(id) => {
  563. try {
  564. const response = await getInfo({ UniqId: id })
  565. if (response.code === 0) {
  566. const { sczl_rq, sczl_bh, name, sczl_bzdh, sczl_jsss, sczl_冲定额, sczl_desc, ...rest } = response.data
  567. Object.assign(detailData, { sczl_rq, sczl_bh, name, sczl_bzdh, sczl_jsss, sczl_冲定额, sczl_desc })
  568. detailData.table = Array.from({ length: 6 }, (_, i) => i + 1)
  569. .map(num => {
  570. return {
  571. sczl_gdbh: rest[`sczl_gdbh${num}`],
  572. sczl_yjGx: rest[`sczl_yjGx${num}`],
  573. sczl_gxmc: rest[`sczl_gxmc${num}`],
  574. Gd_cpmc: rest[`Gd_cpmc${num}`],
  575. sczl_cl: rest[`sczl_cl${num}`],
  576. sczl_返工产量: rest[`sczl_返工产量${num}`],
  577. sczl_PgCl: rest[`sczl_PgCl${num}`],
  578. sczl_计产系数: rest[`sczl_计产系数${num}`],
  579. sczl_Jtbh1: rest[`sczl_Jtbh${num}`],
  580. sczl_dedh: rest[`sczl_dedh${num}`],
  581. }
  582. })
  583. if (type.value === '新增') {
  584. console.log(detailData)
  585. detailData.name=''
  586. detailData.sczl_bh=''
  587. detailData.sczl_bzdh=''
  588. detailData.sczl_desc=''
  589. detailData.sczl_jsss=''
  590. detailData.sczl_rq=''
  591. detailData.table.forEach(row => {
  592. for (const key in row) {
  593. row[key] = '' // 清空每行的内容
  594. }
  595. })
  596. }else{
  597. detailData.UniqId = id
  598. dialogFormVisible.value = true
  599. }
  600. if (type.value === '新增' || type.value === '编辑') {
  601. detailData.UniqId = id
  602. dialogFormVisible.value = true
  603. // 在 setTimeout 中获取元素,确保在 DOM 渲染完毕后执行
  604. setTimeout(() => {
  605. formElements = document.getElementById('detail-form').elements
  606. formElements[0].focus()
  607. }, 0)
  608. }
  609. }
  610. } catch (e) {
  611. console.log(e)
  612. }
  613. }
  614. // 获取工序名称
  615. const getTableGxMc = async(index, row) => {
  616. try {
  617. const response = await getGxMc({ gdbh: row.sczl_gdbh })
  618. if (response.code === 0) {
  619. const { Gd_cpmc, Gy0_gxmc, jyGx } = response.data[0]
  620. if (response.data.length === 1) {
  621. detailData.table[index].Gd_cpmc = Gd_cpmc
  622. detailData.table[index].sczl_yjGx = jyGx
  623. detailData.table[index].sczl_gxmc = Gy0_gxmc
  624. } else {
  625. selectData.splice(0, selectData.length, ...response.data)
  626. setCPCurrent(selectData[0])
  627. detailData.selectIndex = index
  628. dialogSelectVisible.value = true
  629. }
  630. }
  631. } catch (e) {
  632. console.log(e)
  633. }
  634. }
  635. // 更新数据
  636. const updateDetailData = async() => {
  637. const restoredData = {
  638. UniqId: detailData.UniqId,
  639. sczl_rq: detailData.sczl_rq,
  640. sczl_bh: detailData.sczl_bh,
  641. name: detailData.name,
  642. sczl_bzdh: detailData.sczl_bzdh,
  643. sczl_jsss: detailData.sczl_jsss,
  644. sczl_冲定额: detailData.sczl_冲定额,
  645. sczl_desc: detailData.sczl_desc,
  646. }
  647. detailData.table.forEach((item, index, array) => {
  648. const num = index + 1
  649. restoredData[`sczl_gdbh${num}`] = item.sczl_gdbh
  650. restoredData[`sczl_yjGx${num}`] = item.sczl_yjGx
  651. restoredData[`sczl_gxmc${num}`] = item.sczl_gxmc
  652. restoredData[`Gd_cpmc${num}`] = item.Gd_cpmc
  653. restoredData[`sczl_cl${num}`] = item.sczl_cl
  654. restoredData[`sczl_返工产量${num}`] = item.sczl_返工产量
  655. restoredData[`sczl_PgCl${num}`] = item.sczl_PgCl
  656. restoredData[`sczl_计产系数${num}`] = item.sczl_计产系数
  657. restoredData[`sczl_Jtbh${num}`] = item.sczl_Jtbh1
  658. restoredData[`sczl_dedh${num}`] = item.sczl_dedh
  659. })
  660. const res = await updatePackingTable(restoredData)
  661. if (res.code === 0) {
  662. ElMessage({
  663. type: 'success',
  664. message: '更新成功',
  665. })
  666. dialogFormVisible.value = false
  667. }
  668. }
  669. // 新增数据
  670. const handleShowAdd = async() => {
  671. type.value = '新增'
  672. await getTableInfo(currentRow.value?.UniqId)
  673. // 默认日期为前一天的日期
  674. const date = dayjs().subtract(1, 'day').format('YYYY-MM-DD')
  675. detailData.sczl_rq = date
  676. }
  677. const addDetailData = async() => {
  678. const restoredData = {
  679. sys_id:sys_id,
  680. sczl_rq: detailData.sczl_rq,
  681. sczl_bh: detailData.sczl_bh,
  682. // name: detailData.name,
  683. sczl_bzdh: detailData.sczl_bzdh,
  684. sczl_jsss: detailData.sczl_jsss,
  685. sczl_冲定额: detailData.sczl_冲定额,
  686. sczl_desc: detailData.sczl_desc,
  687. }
  688. detailData.table.forEach((item, index, array) => {
  689. const num = index + 1
  690. restoredData[`sczl_gdbh${num}`] = item.sczl_gdbh
  691. restoredData[`sczl_yjGx${num}`] = item.sczl_yjGx
  692. restoredData[`sczl_gxmc${num}`] = item.sczl_gxmc
  693. // restoredData[`Gd_cpmc${num}`] = item.Gd_cpmc
  694. restoredData[`sczl_cl${num}`] = item.sczl_cl
  695. restoredData[`sczl_返工产量${num}`] = item.sczl_返工产量
  696. restoredData[`sczl_PgCl${num}`] = item.sczl_PgCl
  697. restoredData[`sczl_计产系数${num}`] = item.sczl_计产系数
  698. restoredData[`sczl_Jtbh${num}`] = item.sczl_Jtbh1
  699. restoredData[`sczl_dedh${num}`] = item.sczl_dedh
  700. })
  701. const res = await addPackingTable(restoredData)
  702. console.log(restoredData)
  703. console.log(res)
  704. if (res.code === 0) {
  705. ElMessage({
  706. type: 'success',
  707. message: '新增成功',
  708. })
  709. dialogFormVisible.value = false
  710. getTableData()
  711. getSideData()
  712. }
  713. }
  714. const handleGetYg = async() => {
  715. try {
  716. const res = await getYg({ sczl_bh: detailData.sczl_bh })
  717. if (res.code === 0) {
  718. detailData.name = res.data.ygxm
  719. } else {
  720. detailData.name = ''
  721. }
  722. } catch (e) {
  723. console.log(e)
  724. }
  725. }
  726. // 处理选择框回车操作
  727. const handleEnter = (index, row) => {
  728. if (row.sczl_gdbh === '') {
  729. detailData.table[index].sczl_yjGx = ''
  730. detailData.table[index].sczl_gxmc = ''
  731. detailData.table[index].Gd_cpmc = ''
  732. } else {
  733. getTableGxMc(index, row)
  734. }
  735. }
  736. // 处理选择框
  737. const handleSelectClick = (row, column, event) => {
  738. const { Gd_cpmc, Gy0_gxmc, jyGx } = row
  739. const index = detailData.selectIndex
  740. detailData.table[index].Gd_cpmc = Gd_cpmc
  741. detailData.table[index].sczl_yjGx = jyGx
  742. detailData.table[index].sczl_gxmc = Gy0_gxmc
  743. dialogSelectVisible.value = false
  744. }
  745. const table2=ref()
  746. const setCPCurrent = (row) => {
  747. setTimeout(()=>{
  748. table2.value?.setCurrentRow(row)
  749. const { Gd_cpmc, Gy0_gxmc, jyGx } = row
  750. const index = detailData.selectIndex
  751. detailData.table[index].Gd_cpmc = Gd_cpmc
  752. detailData.table[index].sczl_yjGx = jyGx
  753. detailData.table[index].sczl_gxmc = Gy0_gxmc
  754. })
  755. }
  756. const CPIndex = ref(0);
  757. const JYCurrent = ref(0);
  758. const selectCP = (event) => {
  759. if (event.keyCode === 40) { // 向下箭头
  760. if (CPIndex.value < selectData.length - 1) {
  761. CPIndex.value++;
  762. setCPCurrent(selectData[CPIndex.value]);
  763. } else {
  764. CPIndex.value = 0;
  765. setCPCurrent(selectData[CPIndex.value]); // 到达最后一行时回到第一行
  766. }
  767. } else if (event.keyCode === 38) { // 向上箭头
  768. if (CPIndex.value > 0) {
  769. CPIndex.value--;
  770. setCPCurrent(selectData[CPIndex.value]);
  771. } else {
  772. CPIndex.value = selectData.length - 1;
  773. setCPCurrent(selectData[CPIndex.value]); // 到达第一行时回到最后一行
  774. }
  775. } else if (event.keyCode === 13) { // 回车键
  776. dialogSelectVisible.value = false
  777. }
  778. }
  779. // 弹窗确定
  780. const enterDialog = () => {
  781. if (type.value === '查改') {
  782. updateDetailData()
  783. } else if (type.value === '新增') {
  784. addDetailData()
  785. }
  786. }
  787. // 定额代号回车事件
  788. const getDedhsubmit = () => {}
  789. let formElements
  790. const moveFocus = (event) => {
  791. const index = Array.from(formElements).indexOf(event.target)
  792. const key = event.key
  793. event.preventDefault()
  794. switch (index) {
  795. case 0:
  796. if (key === 'ArrowDown') {
  797. formElements[1].focus()
  798. formElements[1].select()
  799. } else if (key === 'ArrowUp') {
  800. formElements[formElements.length - 1].focus()
  801. formElements[formElements.length - 1].select()
  802. } else if (key === 'Enter') {
  803. formElements[1].focus()
  804. formElements[1].select()
  805. }
  806. break
  807. case 1:
  808. if (key === 'ArrowDown') {
  809. formElements[3].focus()
  810. formElements[3].select()
  811. handleGetYg()
  812. } else if (key === 'ArrowUp') {
  813. formElements[0].focus()
  814. formElements[0].select()
  815. handleGetYg()
  816. } else if (key === 'Enter') {
  817. formElements[3].focus()
  818. formElements[3].select()
  819. handleGetYg()
  820. }
  821. break
  822. case 3:
  823. if (key === 'ArrowDown') {
  824. formElements[4].focus()
  825. formElements[4].select()
  826. } else if (key === 'ArrowUp') {
  827. formElements[1].focus()
  828. formElements[1].select()
  829. } else if (key === 'Enter') {
  830. formElements[4].focus()
  831. formElements[4].select()
  832. }
  833. break
  834. case formElements.length - 1 :
  835. if (key === 'ArrowDown') {
  836. formElements[0].focus()
  837. formElements[0].select()
  838. } else if (key === 'ArrowUp') {
  839. formElements[index - 1].focus()
  840. formElements[index - 1].select()
  841. } else if (key === 'Enter') {
  842. formElements[0].focus()
  843. formElements[0].select()
  844. }
  845. break
  846. default:
  847. if (key === 'ArrowDown') {
  848. formElements[index + 1].focus()
  849. formElements[index + 1].select()
  850. } else if (key === 'ArrowUp') {
  851. formElements[index - 1].focus()
  852. formElements[index - 1].select()
  853. } else if (key === 'Enter') {
  854. formElements[index + 1].focus()
  855. formElements[index + 1].select()
  856. }
  857. break
  858. }
  859. }
  860. </script>
  861. <style scoped>
  862. :deep(.plan-usage-low div) {
  863. color: red !important;
  864. }
  865. .JKWTree-container {
  866. display: flex;
  867. }
  868. .JKWTree-tree {
  869. width: 100%;
  870. background-color: #fff;
  871. /*background-color: rgba(241, 224, 224, 0.99);*/
  872. padding: 10px;
  873. margin-right: 20px;
  874. }
  875. .JKWTree-tree h3 {
  876. font-size: 15px;
  877. font-weight: 700;
  878. margin: 10px 0;
  879. }
  880. .JKWTree-content {
  881. flex: 1;
  882. }
  883. :deep(.el-table__body .warning-row) {
  884. background: #FFFF80 !important;
  885. }
  886. /* 选中某行时的背景色 */
  887. :deep(.el-table__body tr.current-row) > td {
  888. background: #ff80ff !important;
  889. }
  890. :deep(.el-table .bg-yellow) {
  891. background: yellow;
  892. }
  893. </style>
  894. <style scoped>
  895. :deep(.el-table td .cell) {
  896. line-height: 25px !important;
  897. }
  898. :deep(.el-tabs__header) {
  899. margin-bottom: 0;
  900. }
  901. .search {
  902. margin-left: 0px !important;
  903. margin-right: 10px !important;
  904. }
  905. .bt {
  906. margin-left: 2px !important;
  907. padding: 3px !important;
  908. font-size: 12px;
  909. }
  910. .el-tabs__header {
  911. margin: 0px !important;
  912. }
  913. .gva-table-box {
  914. padding: 0px !important;
  915. }
  916. .mab {
  917. margin-bottom: 5px;
  918. }
  919. </style>