index.vue 27 KB

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