index.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916
  1. <template>
  2. <div>
  3. <el-container>
  4. <!-- 左侧树侧形结构-->
  5. <layout-sider :resize-directions="['right']" :width="220" style="margin-right: 10px;">
  6. <div class="JKWTree-tree" style="height: 70vh;">
  7. <h3>其他计件单据维护</h3>
  8. <el-tree :data="treeData" highlight-current @node-click="handleNodeClick" />
  9. </div>
  10. </layout-sider>
  11. <el-container>
  12. <el-main>
  13. <layout-header>
  14. <!-- 按钮 -->
  15. <el-form inline>
  16. <el-form-item>
  17. <el-input v-model="searchInfo" placeholder="搜索产品编号或产品名称" clearable style="width: 180px;" />
  18. <el-button type="primary" icon="Search" class="search" @click="handleSearch" />
  19. <el-button type="primary" icon="plus" class="bt" @click="handleShowAdd">新增 </el-button>
  20. <el-button type="primary" icon="delete" class="bt" @click="onDel">删除 </el-button>
  21. </el-form-item>
  22. </el-form>
  23. <!-- 弹出框 -->
  24. <div>
  25. <!-- 详情页 -->
  26. <el-dialog v-model="dialogFormVisible" :before-close="closeDialog" :title="type === 'create' ? '新增' : '修改'" destroy-on-close
  27. width="800px">
  28. <!-- <el-scrollbar height="500px"> -->
  29. <el-form :model="detailData" id="detail-form" ref="elFormRef"
  30. label-width="100px"
  31. label-position="right" inline>
  32. <el-row :gutter="24" >
  33. <el-col :span="24">
  34. <el-form-item label="员工编号">
  35. <el-input v-model="detailData.Sczl_bh1" @blur="handleYgbhEnter" placeholder="Enter回车"
  36. @keydown="ent1($event)" style="width: 120px" />
  37. <el-input style="width: 120px; margin-left: 5px" readonly v-model="detailData.name" />
  38. </el-form-item>
  39. </el-col>
  40. </el-row>
  41. <el-row :gutter="24" >
  42. <el-col :span="14">
  43. <el-form-item label="工序类别">
  44. <el-input @blur="get_LB" v-model="detailData.sczl_Type"
  45. @keydown="ent1($event)" style="width: 120px; " />
  46. <!-- <el-select v-model="detailData.sczl_Type" style="width: 150px">
  47. <el-option label="拆片" value="拆片" />
  48. <el-option label="包装" value="包装" />
  49. <el-option label="打包" value="打包" />
  50. <el-option label="拉料" value="拉料" />
  51. </el-select> -->
  52. </el-form-item>
  53. </el-col>
  54. <el-col :span="10">
  55. <el-form-item label="日期">
  56. <el-input type="date" max="9999-12-31" v-model="detailData.Sczl_rq"
  57. @keydown="ent1($event)" style="width: 150px" />
  58. </el-form-item>
  59. </el-col>
  60. </el-row>
  61. <el-row :gutter="24" >
  62. <el-col :span="24">
  63. <el-form-item label="工单编号">
  64. <el-input v-model="detailData.Sczl_gdbh" @blur="handleGdbhEnter" placeholder="Enter回车"
  65. @keydown="ent1($event)" style="width: 120px"/>
  66. <el-input v-model="detailData.Gd_cpmc" style="width: 480px; margin-left: 5px"
  67. readonly />
  68. </el-form-item>
  69. </el-col>
  70. </el-row>
  71. <el-row :gutter="24" >
  72. <el-col :span="24">
  73. <el-form-item label="工艺流程">
  74. <el-input v-model="detailData.Sczl_gxmc" @blur="handleGylcEnter"
  75. @keydown="ent1($event)" style="width: 480px"/>
  76. <el-input v-model="detailData.sczl_gxh" style="width: 120px; margin-left: 5px"
  77. readonly />
  78. </el-form-item>
  79. </el-col>
  80. </el-row>
  81. <el-row :gutter="24" >
  82. <el-col :span="14">
  83. <el-form-item label="" style="margin-left: 67px;">
  84. <el-input v-model="leftData" @keydown="ent1($event)" style="width: 100px; margin-left: 32px;"
  85. @blur="()=>{detailData.Sczl_cl = (leftData * rightData).toString()}"/>X
  86. <el-input v-model="rightData" @keydown="ent1($event)" style="width: 100px;margin-left: 12px;"
  87. @blur="()=>{detailData.Sczl_cl = (leftData * rightData).toString()}"
  88. />
  89. </el-form-item>
  90. </el-col>
  91. <el-col :span="10">
  92. <el-form-item label="计件产量" >
  93. <el-input @keydown="ent1($event)" v-model="detailData.Sczl_cl" style="width: 150px" />
  94. </el-form-item>
  95. </el-col>
  96. </el-row>
  97. <el-row :gutter="24" >
  98. <el-col :span="24">
  99. <el-form-item label="工价代号">
  100. <el-input v-model="detailData.Sczl_dedh" style="width: 150px"
  101. @blur="handleGjdhEnter" @keydown="ent1($event)" />
  102. <el-input v-model="detailData.sys_mc" style="width: 450px; margin-left: 5px" readonly />
  103. </el-form-item>
  104. </el-col>
  105. </el-row>
  106. <el-row :gutter="24" >
  107. <el-col :span="24">
  108. <el-form-item label="票号备注">
  109. <el-input v-model="detailData.Sczl_desc" @keydown="ent1($event)" style="width: 605px" />
  110. </el-form-item>
  111. </el-col>
  112. </el-row>
  113. </el-form>
  114. <template #footer>
  115. <div class="dialog-footer">
  116. <el-button @click="closeDialog">取 消</el-button>
  117. <el-button type="primary" @click="enterDialog">确 定</el-button>
  118. </div>
  119. </template>
  120. </el-dialog>
  121. <!-- 工价代号弹窗 -->
  122. <el-dialog v-model="dialogDedh" :before-close="()=>{dialogDedh = false}" title="工价代号"
  123. destroy-on-close>
  124. <el-scrollbar style="height: 50vh;width: 50vw;">
  125. <el-tree :data="dedhTreeData" highlight-current style="width: 90%;"
  126. @node-click="handleSelectDjdh" />
  127. </el-scrollbar>
  128. </el-dialog>
  129. <!-- 工艺流程弹窗 -->
  130. <el-dialog v-model="dialogGylc" title="工艺流程"
  131. destroy-on-close style="width: 500px; " @keydown="selectGX($event)">
  132. <el-table tooltip-effect="dark" :data="selectData" row-key="ID" highlight-current-row="true"
  133. border style="width:100%" height="400px" @row-dblclick="handleSelectClick" ref="table2">
  134. <el-table-column prop="jyGx" label="检验工序" width="460" />
  135. </el-table>
  136. </el-dialog>
  137. <!-- 工序类别选择 -->
  138. <el-dialog v-model="LBVisible" title="选择"
  139. destroy-on-close width="200px" @keydown="selectLB($event)" >
  140. <el-table tooltip-effect="dark" :data="LBselectData" row-key="ID"
  141. highlight-current-row="true" border style="width:100%"
  142. :row-style="{ height: '30px' }"
  143. @row-dblclick="LBSelectClick"
  144. ref="tableLB"
  145. >
  146. <el-table-column prop="sczl_Type" label="" width="160" />
  147. </el-table>
  148. </el-dialog>
  149. </div>
  150. </layout-header>
  151. <layout-content>
  152. <!-- 数据展示 -->
  153. <el-table ref="table" style="width: 100%" tooltip-effect="dark" :data="tableData" row-key="ID"
  154. highlight-current-row border show-overflow-tooltip="true" :row-style="{ height: '20px' }"
  155. :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
  156. :header-cell-style="{ padding: '0px' }" @selection-change="handleSelectionChange"
  157. @row-dblclick="handleShowEdit" @current-change="(row, oldRow) => { currentRow = row}">
  158. <!-- 循环渲染列 -->
  159. <el-table-column v-for=" column in tableColumns " :key="column.prop" :prop="column.prop"
  160. :label="column.label" :width="column.width" sortable />
  161. </el-table>
  162. <!-- 分页 -->
  163. <div class="gva-pagination">
  164. <el-pagination v-model:current-page="page" v-model:page-size="limit"
  165. layout="total, sizes, prev, pager, next, jumper" :page-sizes="[10, 30, 50, 100]"
  166. :total="total" @current-change="handleCurrentChange" @size-change="handleSizeChange" />
  167. </div>
  168. </layout-content>
  169. </el-main>
  170. </el-container>
  171. </el-container>
  172. </div>
  173. </template>
  174. <script setup>
  175. import {
  176. Layout,
  177. LayoutContent,
  178. LayoutHeader,
  179. LayoutSider
  180. } from '@arco-design/web-vue'
  181. import {
  182. ElMessage,
  183. dayjs,
  184. ElMessageBox
  185. } from 'element-plus'
  186. import {
  187. ref,
  188. reactive,
  189. nextTick
  190. } from 'vue'
  191. import {
  192. getSide,
  193. getTable,
  194. getYg,
  195. getGdmc,
  196. getDedh,
  197. getGxMc,
  198. updateData,
  199. add,
  200. del
  201. } from '@/api/mes_api_gty/otherDocuments'
  202. import {
  203. useUserStore
  204. } from '@/pinia/modules/user'
  205. const userStore = useUserStore()
  206. const sys_id = '[' + userStore.userInfo.userName + '/' + userStore.userInfo.nickName + ']'
  207. defineOptions({
  208. name: '07OtherDocuments'
  209. })
  210. // 侧边栏数据请求
  211. const treeData = reactive([])
  212. const getSideData = async () => {
  213. const response = await getSide()
  214. if (response.code === 0) {
  215. const transformedData = response.data.map(item => ({
  216. label: `${item.date.replace(/-/g, '.')}【产量合计: ${item.counts}】`,
  217. children: item.sys.map(sysItem => ({
  218. label: `${sysItem.Sczl_bh1}(${sysItem.name}) 【产量合计: ${sysItem.count}】`,
  219. params: {
  220. date: item.date.substring(0, 4) + '-' + item.date.substring(4),
  221. Sczl_bh1: sysItem.Sczl_bh1,
  222. },
  223. })),
  224. }))
  225. treeData.splice(0, treeData.length, ...transformedData)
  226. }
  227. }
  228. getSideData()
  229. const elFormRef = ref()
  230. // ============== 表格页面 ==============
  231. const tableColumns = [{
  232. prop: 'sczl_Type',
  233. label: '计件类型',
  234. width: '120'
  235. },
  236. {
  237. prop: 'Sczl_rq',
  238. label: '日期',
  239. width: '100'
  240. },
  241. {
  242. prop: 'Sczl_bh1',
  243. label: '员工编号',
  244. width: '120'
  245. },
  246. {
  247. prop: 'name',
  248. label: '员工姓名',
  249. width: '120'
  250. },
  251. {
  252. prop: 'sczl_gdbh',
  253. label: '工单编号',
  254. width: '120'
  255. },
  256. {
  257. prop: 'Gd_cpmc',
  258. label: '产品名称',
  259. width: '300'
  260. },
  261. {
  262. prop: 'Sczl_cl',
  263. label: '产量',
  264. width: '100'
  265. },
  266. {
  267. prop: '',
  268. label: '千件工价',
  269. width: '120'
  270. }, // prop 属性值需要补充
  271. {
  272. prop: 'sys_mc',
  273. label: '工价备注',
  274. width: '200'
  275. }, // prop 属性值需要补充
  276. {
  277. prop: 'Sczl_desc',
  278. label: '备注',
  279. width: '100'
  280. },
  281. {
  282. prop: 'Sczl_gxmc',
  283. label: '工序名称',
  284. width: '120'
  285. },
  286. {
  287. prop: 'sczl_yjno',
  288. label: '印件号',
  289. width: '100'
  290. },
  291. {
  292. prop: 'sczl_gxh',
  293. label: '工序号',
  294. width: '100'
  295. },
  296. {
  297. prop: 'sys_id',
  298. label: '创建用户',
  299. width: '150'
  300. },
  301. {
  302. prop: 'sys_rq',
  303. label: '创建时间',
  304. width: '200'
  305. },
  306. {
  307. prop: 'mod_rq',
  308. label: '修改时间',
  309. width: '200'
  310. },
  311. {
  312. prop: 'UniqId',
  313. label: 'UNIQID',
  314. width: '100'
  315. }
  316. ]
  317. const tableData = reactive([])
  318. const currentRow = ref()
  319. const type = ref('')
  320. const page = ref(1)
  321. const total = ref(0)
  322. const limit = ref(10)
  323. const searchInfo = ref('')
  324. const params = {
  325. date: '',
  326. Sczl_bh1: '',
  327. order: '',
  328. page: page.value.toString(),
  329. limit: limit.value.toString(),
  330. }
  331. const table = ref()
  332. const setCurrent = (row) => {
  333. table.value?.setCurrentRow(row)
  334. }
  335. // 获取表格数据
  336. const getTableData = async () => {
  337. // try {
  338. const response = await getTable(params)
  339. if (response.code === 0) {
  340. total.value = response.data.total
  341. tableData.splice(0, tableData.length, ...response.data.rows)
  342. setCurrent(tableData[0])
  343. }
  344. }
  345. // 分页设置
  346. const handleSizeChange = () => {
  347. params.limit = limit.value.toString()
  348. getTableData()
  349. }
  350. // 页面跳转
  351. const handleCurrentChange = () => {
  352. params.page = page.value.toString()
  353. getTableData()
  354. }
  355. // 点击左侧节点
  356. const handleNodeClick = (node, check) => {
  357. if (node.params) {
  358. params.date = node.params.date
  359. params.Sczl_bh1 = node.params.Sczl_bh1
  360. params.order = ''
  361. page.value = 1
  362. handleCurrentChange()
  363. }
  364. }
  365. // 搜索
  366. function handleSearch() {
  367. params.order = searchInfo.value
  368. params.date = ''
  369. params.Sczl_bh1 = ''
  370. page.value = 1
  371. handleCurrentChange()
  372. }
  373. // ============== 详情页面 ==============
  374. const detailData = reactive({
  375. Sczl_bh1: '',
  376. sczl_Type: '',
  377. Sczl_rq: '',
  378. Sczl_gdbh: '',
  379. Sczl_gxmc: '',
  380. sczl_gxh: '',
  381. Sczl_cl: '',
  382. Sczl_dedh: '',
  383. Sczl_desc: '',
  384. })
  385. const leftData = ref(0)
  386. const rightData = ref(0)
  387. const dedhTreeData = ref()
  388. const gylcTreeData = ref()
  389. const selectData = reactive([])
  390. // 弹窗控制标记
  391. const dialogFormVisible = ref(false)
  392. const dialogDedh = ref(false)
  393. const dialogGylc = ref(false)
  394. // 新增数据
  395. const handleShowAdd = () => {
  396. type.value = 'create'
  397. // 设置detailData对象中的所有属性值为空
  398. Object.keys(detailData).forEach(key => {
  399. detailData[key] = '';
  400. });
  401. const date = dayjs().format('YYYY-MM-DD')
  402. detailData.Sczl_rq = date
  403. dialogFormVisible.value = true
  404. }
  405. // 查改
  406. const handleShowEdit = () => {
  407. type.value = 'update'
  408. Object.assign(detailData, currentRow.value)
  409. detailData.Sczl_gdbh = detailData.sczl_gdbh
  410. detailData.Sczl_dedh = detailData.sys_bh
  411. dialogFormVisible.value = true
  412. }
  413. const ent1 = (event) => {
  414. const inputs = document.getElementsByTagName('input');
  415. const currentIndex = Array.from(inputs).indexOf(event.target);
  416. if (event.keyCode === 13 || event.keyCode === 40) { // Enter 或向下箭头
  417. for (let i = currentIndex + 1; i < inputs.length; i++) {
  418. if (!inputs[i].readOnly) {
  419. nextTick(()=>{
  420. inputs[i].focus();
  421. inputs[i].select();
  422. })
  423. break;
  424. }
  425. }
  426. } else if (event.keyCode === 38) { // 向上箭头
  427. for (let i = currentIndex - 1; i >= 0; i--) {
  428. if (!inputs[i].readOnly) {
  429. nextTick(()=>{
  430. inputs[i].focus();
  431. inputs[i].select();
  432. })
  433. break;
  434. }
  435. }
  436. } else if (event.keyCode === 8) { // 删除箭头
  437. if (event.target.selectionStart === 0) {
  438. for (let i = currentIndex - 1; i >= 0; i--) {
  439. if (!inputs[i].readOnly) {
  440. nextTick(()=>{
  441. inputs[i].focus();
  442. inputs[i].setSelectionRange(0, 0);
  443. inputs[i].select(); // 全选输入框内容
  444. })
  445. break;
  446. }
  447. }
  448. }
  449. } else if (event.keyCode === 37) { // 向左箭头
  450. if (event.target.selectionStart === 0) {
  451. for (let i = currentIndex - 1; i >= 0; i--) {
  452. if (!inputs[i].readOnly) {
  453. nextTick(()=>{
  454. inputs[i].focus();
  455. inputs[i].select();
  456. })
  457. break;
  458. }
  459. }
  460. }
  461. } else if (event.keyCode === 39) { // 向右箭头
  462. if (event.target.selectionStart === event.target.value.length) {
  463. for (let i = currentIndex + 1; i < inputs.length; i++) {
  464. if (!inputs[i].readOnly) {
  465. nextTick(()=>{
  466. inputs[i].focus();
  467. inputs[i].select();
  468. })
  469. break;
  470. }
  471. }
  472. }
  473. }
  474. }
  475. //员工编号回车事件
  476. const handleYgbhEnter = async () => {
  477. if(!detailData.Sczl_bh1){
  478. return
  479. }
  480. const res = await getYg({
  481. sczl_bh: detailData.Sczl_bh1
  482. })
  483. if (res.code === 0) {
  484. detailData.name = res.data[0].ygxm
  485. detailData.Sczl_bh1 = res.data[0].员工编号
  486. }
  487. }
  488. //工序类型选择
  489. const get_LB = () => {
  490. GetLB()
  491. }
  492. const LBVisible = ref(false)
  493. const LBselectData = reactive([])
  494. //获取仓库信息
  495. const GetLB = async () => {
  496. const data = [{'sczl_Type':'拆片'},{'sczl_Type':'包装'},{'sczl_Type':'打包'},{'sczl_Type':'拉料'}]
  497. LBselectData.splice(0, LBselectData.length, ...data)
  498. setLBCurrent(LBselectData[0])
  499. LBVisible.value=true
  500. }
  501. //选择
  502. const LBSelectClick = (row, column, event) => {
  503. const { sczl_Type } = row
  504. detailData.sczl_Type=sczl_Type
  505. LBVisible.value = false
  506. }
  507. const tableLB=ref()
  508. const setLBCurrent = (row) => {
  509. setTimeout(()=>{
  510. tableLB.value?.setCurrentRow(row)
  511. const { sczl_Type } = row
  512. detailData.sczl_Type = sczl_Type
  513. })
  514. }
  515. const LBIndex = ref(0);
  516. const LBCurrent = ref(0);
  517. const selectLB = (event) => {
  518. if (event.keyCode === 40) { // 向下箭头
  519. if (LBIndex.value < LBselectData.length - 1) {
  520. LBIndex.value++;
  521. setLBCurrent(LBselectData[LBIndex.value]);
  522. } else {
  523. LBIndex.value = 0;
  524. setLBCurrent(LBselectData[LBIndex.value]); // 到达最后一行时回到第一行
  525. }
  526. } else if (event.keyCode === 38) { // 向上箭头
  527. if (LBIndex.value > 0) {
  528. LBIndex.value--;
  529. setLBCurrent(LBselectData[LBIndex.value]);
  530. } else {
  531. LBIndex.value = LBselectData.length - 1;
  532. setLBCurrent(LBselectData[LBIndex.value]); // 到达第一行时回到最后一行
  533. }
  534. } else if (event.keyCode === 13) { // 回车键
  535. LBVisible.value = false
  536. }
  537. }
  538. const handleGdbhEnter = async () => {
  539. const res = await getGdmc({
  540. gdbh: detailData.Sczl_gdbh
  541. })
  542. if (res.code === 0) {
  543. detailData.Gd_cpmc = res.data.Gd_cpmc
  544. }
  545. }
  546. const handleGylcEnter = async () => {
  547. const res = await getGxMc({
  548. gdbh: detailData.Sczl_gdbh,
  549. keyword: ''
  550. })
  551. if (res.code === 0) {
  552. const data = res.data.sort((a, b) => parseInt(a.Gy0_yjno) - parseInt(b.Gy0_yjno));
  553. selectData.splice(0, selectData.length, ...data)
  554. setGXCurrent[selectData[0]]
  555. dialogGylc.value = true
  556. }
  557. }
  558. // 工单选择框
  559. const handleSelectClick = (row, column, event) => {
  560. detailData.Sczl_gxmc = row.jyGx
  561. detailData.sczl_gxh = row.Gy0_gxh
  562. detailData.Gd_cpmc = row.Gd_cpmc
  563. dialogGylc.value = false
  564. }
  565. const table2 = ref()
  566. const setGXCurrent = (row) => {
  567. setTimeout(() => {
  568. table2.value?.setCurrentRow(row)
  569. detailData.Sczl_gxmc = row.jyGx
  570. detailData.sczl_gxh = row.Gy0_gxh
  571. detailData.Gd_cpmc = row.Gd_cpmc
  572. })
  573. }
  574. const handleSelectGylc = (node, check) => {
  575. detailData.Sczl_gxmc = node['jyGx']
  576. detailData.sczl_gxh = node['Gy0_gxh']
  577. detailData.Gd_cpmc = node['Gd_cpmc']
  578. dialogGylc.value = false
  579. }
  580. const currentIndex = ref(0);
  581. const GXCurrent = ref(0);
  582. const selectGX = (event) => {
  583. if (event.keyCode === 40) { // 向下箭头
  584. if (currentIndex.value < selectData.length - 1) {
  585. currentIndex.value++;
  586. setGXCurrent(selectData[currentIndex.value]);
  587. } else {
  588. currentIndex.value = 0;
  589. setGXCurrent(selectData[currentIndex.value]); // 到达最后一行时回到第一行
  590. }
  591. } else if (event.keyCode === 38) { // 向上箭头
  592. if (currentIndex.value > 0) {
  593. currentIndex.value--;
  594. setGXCurrent(selectData[currentIndex.value]);
  595. } else {
  596. currentIndex.value = selectData.length - 1;
  597. setGXCurrent(selectData[currentIndex.value]); // 到达第一行时回到最后一行
  598. }
  599. } else if (event.keyCode === 13) { // 回车键
  600. dialogGylc.value = false
  601. }
  602. }
  603. const handleGjdhEnter = async () => {
  604. const res = await getDedh({ sczl_jtbh: '' })
  605. if (res.code === 0) {
  606. const { data } = res
  607. const transformData = (data) => {
  608. if (Array.isArray(data)) {
  609. return data.map((item) => transformData(item))
  610. } else if (typeof data === 'object') {
  611. const { Key_, sys_bh, sys_mc, bh_mc } = data
  612. const label = `${sys_bh}【${sys_mc}】`
  613. const node = {
  614. Key_,
  615. sys_bh,
  616. sys_mc,
  617. label
  618. }
  619. if (bh_mc) { node.children = transformData(bh_mc) }
  620. return node
  621. } else {
  622. return data
  623. }
  624. }
  625. const temp = []
  626. temp[0] = transformData(data)
  627. dedhTreeData.value = temp
  628. dialogDedh.value = true
  629. }
  630. }
  631. const handleSelectDjdh = (node, check) => {
  632. if (!node['children']) {
  633. const { sys_bh, sys_mc } = node
  634. detailData.Sczl_dedh = sys_bh
  635. detailData.sys_mc = sys_mc
  636. dialogDedh.value = false
  637. }
  638. }
  639. // 弹窗确定
  640. const enterDialog = async () => {
  641. // if(formData.value.入仓类型==''){
  642. // ElMessage({type: 'warning',message: '请选择入仓类型'});
  643. // return;
  644. // }
  645. // if(formData.value.仓库编号==''){
  646. // ElMessage({type: 'warning',message: '请选择仓库'});
  647. // return;
  648. // }
  649. // if(formData.value.jjcp_gdbh==''){
  650. // ElMessage({type: 'warning',message: '请填写工单编号'});
  651. // return;
  652. // }
  653. // if(formData.value.jjcp_cpdh==''){
  654. // ElMessage({type: 'warning',message: '请选择印件'});
  655. // return;
  656. // }
  657. // if(formData.value.jjcp_sl==''){
  658. // ElMessage({type: 'warning',message: '请填写入仓数量'});
  659. // return;
  660. // }
  661. const restoredData = {
  662. Sys_id: sys_id,
  663. Sczl_bh1: detailData.Sczl_bh1,
  664. sczl_Type: detailData.sczl_Type,
  665. Sczl_rq: detailData.Sczl_rq,
  666. Sczl_gdbh: detailData.Sczl_gdbh,
  667. Sczl_gxmc: detailData.Sczl_gxmc,
  668. sczl_gxh: detailData.sczl_gxh,
  669. Sczl_cl: detailData.Sczl_cl,
  670. Sczl_dedh: detailData.Sczl_dedh,
  671. Sczl_desc: detailData.Sczl_desc,
  672. }
  673. let res
  674. switch (type.value) {
  675. case 'create':
  676. res = await add(restoredData)
  677. break
  678. case 'update':
  679. restoredData.UniqId = detailData.UniqId;
  680. res = await updateData(restoredData)
  681. break
  682. default:
  683. // res = await createCompany(formData.value)
  684. break
  685. }
  686. if (res.code === 0) {
  687. ElMessage({
  688. type: 'success',
  689. message: type.value=='create'? '创建成功' :'更改成功'
  690. })
  691. dialogFormVisible.value = false
  692. getTableData()
  693. // getSideData()
  694. }
  695. }
  696. // 关闭弹窗
  697. const closeDialog = () => {
  698. dialogFormVisible.value = false
  699. }
  700. let formElements
  701. const moveFocus = (event) => {
  702. const index = Array.from(formElements).indexOf(event.target)
  703. const key = event.key
  704. event.preventDefault()
  705. console.log(formElements)
  706. switch (index) {
  707. case 0:
  708. if (key === 'ArrowDown') {
  709. formElements[1].focus()
  710. formElements[1].select();
  711. } else if (key === 'ArrowUp') {
  712. formElements[formElements.length - 1].focus()
  713. } else if (key === 'Enter') {
  714. formElements[1].focus()
  715. formElements[1].select();
  716. }
  717. break
  718. case formElements.length - 1:
  719. if (key === 'ArrowDown') {
  720. formElements[0].focus()
  721. formElements[0].select();
  722. } else if (key === 'ArrowUp') {
  723. formElements[index - 1].focus()
  724. } else if (key === 'Enter') {
  725. formElements[0].focus()
  726. formElements[0].select();
  727. }
  728. break
  729. default:
  730. if (key === 'ArrowDown') {
  731. formElements[index + 1].focus()
  732. formElements[index + 1].select();
  733. } else if (key === 'ArrowUp') {
  734. formElements[index - 1].focus()
  735. formElements[index + 1].select();
  736. } else if (key === 'Enter') {
  737. formElements[index + 1].focus()
  738. formElements[index + 1].select();
  739. }
  740. break
  741. }
  742. }
  743. const rowSelection = {
  744. type: 'radio'
  745. };
  746. // let lastCellValue=ref()
  747. // 多选
  748. // const handleSelectionChange = (val) => {
  749. // if(val.length>0){
  750. // lastCellValue = val.map(row=>row.UniqId)
  751. // }
  752. // console.log(lastCellValue)
  753. // console.log(rowSelection)
  754. // }
  755. //删除
  756. function onDel() {
  757. if(!currentRow.value){
  758. ElMessage({
  759. type: 'warning',
  760. message: '请选择要删除的数据',
  761. })
  762. return
  763. }
  764. ElMessageBox.confirm('确定要删除吗?', '提示', {
  765. confirmButtonText: '确定',
  766. cancelButtonText: '取消',
  767. type: 'warning'
  768. }).then(() => {
  769. del({UniqId:currentRow.value.UniqId}).then(res=>{
  770. if (res.code === 0) {
  771. ElMessage({
  772. type: 'success',
  773. message: '删除成功',
  774. })
  775. }
  776. getTableData()
  777. })
  778. })
  779. // Del()
  780. }
  781. //删除
  782. const Del = async () => {
  783. console.log(lastCellValue)
  784. return
  785. const response = await finisheddel({UniqId:lastCellValue});
  786. if (response.code === 0) {
  787. ElMessage({
  788. type: 'success',
  789. message: '删除成功',
  790. })
  791. }
  792. getTableData()
  793. }
  794. </script>
  795. <style scoped>
  796. .JKWTree-container {
  797. display: flex;
  798. }
  799. .JKWTree-tree {
  800. width: 100%;
  801. background-color: #fff;
  802. padding: 10px;
  803. margin-right: 20px;
  804. }
  805. .JKWTree-tree h3 {
  806. font-size: 15px;
  807. font-weight: 700;
  808. margin: 10px 0;
  809. }
  810. .JKWTree-content {
  811. flex: 1;
  812. }
  813. /* 选中某行时的背景色 */
  814. :deep(.el-table__body tr.current-row)>td {
  815. background: #ff80ff !important;
  816. }
  817. </style>
  818. <style scoped>
  819. :deep(.el-table td .cell) {
  820. line-height: 25px !important;
  821. }
  822. :deep(.el-tabs__header) {
  823. margin-bottom: 0;
  824. }
  825. .search {
  826. margin-left: 0px !important;
  827. margin-right: 10px !important;
  828. }
  829. .bt {
  830. margin-left: 2px !important;
  831. padding: 3px !important;
  832. font-size: 12px;
  833. }
  834. .el-tabs__header {
  835. margin: 0px !important;
  836. }
  837. .gva-table-box {
  838. padding: 0px !important;
  839. }
  840. .mab {
  841. margin-bottom: 5px;
  842. }
  843. </style>