From 38315315aa26e4e852cca22379fc7ce343e1db99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=91=A3=E5=93=B2=E5=A5=87?= <13840175730@139.com> Date: Tue, 20 May 2025 10:00:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=99=E6=96=99=E7=AE=A1=E7=90=86,=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E9=80=80=E5=9B=9E=E5=8A=9F=E8=83=BD=E5=92=8C=E6=89=8B?= =?UTF-8?q?=E5=B7=A5=E4=B8=8A=E6=96=99=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/jhzxgl/ylgl/index.js | 232 +++++++++++++++++++++++++++++++++ 1 file changed, 232 insertions(+) create mode 100644 src/views/jhzxgl/ylgl/index.js diff --git a/src/views/jhzxgl/ylgl/index.js b/src/views/jhzxgl/ylgl/index.js new file mode 100644 index 0000000..6500725 --- /dev/null +++ b/src/views/jhzxgl/ylgl/index.js @@ -0,0 +1,232 @@ +import request from '@/utils/request' +import { VXETable } from 'vxe-table' +import XLSX from 'xlsx' +const init=function (that){ + + let list=[] + const butClick=function (){ + data.options.formConfig.data.dcCh=that.$refs.projectSelectRef.getDcch() + getData(data.options.formConfig.data).then(res=>{ + list=res.data + }) + } + + const 核对=function (){ + const dcCh=that.$refs.xqProjectSelectRef.getDcch(); + const dcPl=data.options.formConfig.data.xqpl + if (!dcCh||!dcPl){ + VXETable.modal.message({ content: '请选择需求船号和批量', status: 'warning' }) + return + } + const table=that.$refs.vGrid + const list=table.getCheckboxRecords() + if (list.length===0){ + VXETable.modal.message({ content: '请选择数据', status: 'warning' }) + return + } + + const _data={ + dcCh:dcCh, + dcPl:dcPl, + ylList:list + } + 核对数据(_data).then(res=>{ + const data=res.data + for (const item of data) { + for (let it of list) { + if (it.id===item.id){ + it=Object.assign(it,item) + break; + } + } + } + }) + } + + const 保存=()=>{ + const list=that.$refs.vGrid.getCheckboxRecords() + if (list.length>0){ + edit(list).then(res=>{ + VXETable.modal.message({ content: '成功', status: 'success' }) + butClick() + }) + } + } + + const 打印=()=>{ + const list=that.$refs.vGrid.getCheckboxRecords() + if (list.length>0){ + print(list).then(res=>{ + const workBook = XLSX.utils.book_new(); + const _data=list.map(item=>{ + return { + 船号:item.使用船号, + 批量:item.使用批量, + 图纸编号:item.使用图纸, + 余料编号:item.余料编号, + 垛位:item.垛位 + } + }) + const sheet=XLSX.utils.json_to_sheet(_data) + XLSX.utils.book_append_sheet(workBook, sheet, "sheet"); + XLSX.writeFile(workBook, `${data.options.formConfig.dcCh}-${data.options.formConfig.dcPl}余料上料计划.xlsx`) + butClick() + }) + } + } + + const 退回=()=>{ + const list=that.$refs.vGrid.getCheckboxRecords() + if(list.length>0){ + rollback(list).then(()=>{ + VXETable.modal.message({ content: '成功', status: 'success' }) + butClick() + }) + } + } + + + const useStatus=[ + {label:'未使用',value:'0'}, + {label:'未打印',value:'1'}, + {label:'已打印',value:'2'}, + {label:'已切割',value:'3'}, + ] + + const formatUseStatus=({cellValue})=>{ + for (const item of useStatus) { + if(item.value===cellValue){ + return item.label + } + } + return cellValue + } + + const data={ + options:{ + height:800, + align:'center', + border: true, + resizable: true, + keepSource:true, + size:'mini', + showOverflow: true, + editConfig:{trigger: 'click', mode: 'cell', showStatus: true}, + highlightCurrentRow:true, + formConfig:{ + data:{ + dcCh:'', + dcPl:'', + tzbh:'', + status:'', + xqch:'', + xqpl:'', + }, + items:[ + { field: 'dcCh', title: '来源船只', span: 3,slots: { default: 'name_czbh' } }, + { field: 'dcPl', title: '来源批量', span: 3 ,itemRender: {name: '$input'}}, + { field: 'tzbh', title: '来源图号', span: 3 ,itemRender: {name: '$input'}}, + { field: 'status', title: '使用状态', span: 3 , + itemRender: {name: '$select',props:{options:useStatus}} + }, + {span: 12, + children:[ + { span: 14,align:'right',itemRender: { + name: '$button', props: {content:'查询',status:'primary'},events:{click:butClick} + } + }, + { align:'right',itemRender: { + name: '$button', props: {content:'核对',status:'primary'},events:{click:核对} + } + }, + { align:'right',itemRender: { + name: '$button', props: {content:'保存',status:'primary'},events:{click:保存} + } + }, + { align:'right',itemRender: { + name: '$button', props: {content:'打印',status:'primary'},events:{click:打印} + } + }, + { align:'right',itemRender: { + name: '$button', props: {content:'退回',status:'primary'},events:{click:退回} + } + }, + ] + }, + { field: 'xqch', title: '需求船只', span: 3,slots: { default: 'name_xqch' } }, + { field: 'xqpl', title: '需求批量', span: 3 ,itemRender: {name: '$input'}}, + ], + }, + columns:[ + { field: 'id', title: 'ID', width: 150 }, + { field: '余料编号', title: '余料编号', width: 150 }, + { field: '规格', title: '规格', width: 150 }, + { field: '板厚', title: '板厚', width: 100 }, + { field: '板宽', title: '板宽', width: 100 }, + { field: '板长', title: '板长', width: 100 }, + { field: '炉批号', title: '炉批号', width: 150 }, + { field: '重量', title: '重量', width: 120 }, + { field: '数量', title: '数量', width: 80 }, + { field: '垛位', title: '垛位', width: 100 }, + { field: '层数', title: '层数', width: 80 }, + { field: '来源船号', title: '来源船号', width: 120 }, + { field: '来源批量', title: '来源批量', width: 120 }, + { field: '来源图纸', title: '来源图纸', width: 150 }, + { field: '物品型号', title: '物品型号', width: 150 }, + { field: '物品规格', title: '物品规格', width: 150 }, + { field: '切割日期', title: '切割日期', width: 150 }, + { field: '使用船号', title: '使用船号', width: 120 }, + { field: '使用批量', title: '使用批量', width: 120 }, + { field: '使用分段', title: '使用分段', width: 120 }, + { field: '使用图纸', title: '使用图纸', width: 150 }, + { field: '使用日期', title: '使用日期', width: 150 }, + {field: '使用状态', title: '使用状态', width: 120, formatter:formatUseStatus} + ], + data:list, + }, + } + + return data +} + +const getData=(data)=>{ + return request({ + url: "/yl/list", + method: "post", + data, + }); +} + +const 核对数据=(data)=>{ + return request({ + url: "/yl/sl", + method: "post", + data, + }); +} + +const edit=(data)=>{ + return request({ + url: "/yl/edit", + method: "post", + data, + }); +} + +const print=(data)=>{ + return request({ + url: "/yl/print", + method: "post", + data, + }); +} + +const rollback=(data)=>{ + return request({ + url: "/yl/rollback", + method: "post", + data, + }); +} + +export default init