parent
f8656f7784
commit
38315315aa
@ -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
|
Loading…
Reference in new issue