652 lines
15 KiB
Vue
652 lines
15 KiB
Vue
<template>
|
||
<el-dialog
|
||
:title="titleMap[mode]"
|
||
v-model="visible"
|
||
width="1000px"
|
||
:size="1000"
|
||
destroy-on-close
|
||
@closed="$emit('closed')"
|
||
>
|
||
<el-form
|
||
ref="dialogForm"
|
||
:model="form"
|
||
:rules="rules"
|
||
label-width="80px"
|
||
>
|
||
<el-row>
|
||
<el-form-item label="交接物料">
|
||
<el-button type="primary" @click="addMaterial" v-if="mode!=='show'">手动添加</el-button>
|
||
<scScanner @scanResult="codeTextChange"></scScanner>
|
||
</el-form-item>
|
||
<el-form-item label-width="0">
|
||
<el-input
|
||
ref="codeInput"
|
||
v-model="codeText"
|
||
clearable
|
||
placeholder="物料批次"
|
||
style="width: 200px;margin-left: 4px;"
|
||
@keyup.enter="codeTextChange(codeText)"
|
||
></el-input>
|
||
</el-form-item>
|
||
<el-form-item label="总计:">
|
||
{{ totalCount }}
|
||
</el-form-item>
|
||
</el-row>
|
||
<el-row v-show="addShow">
|
||
<el-col>
|
||
<el-form-item label="交接物料">
|
||
<el-select
|
||
v-model="selectItems"
|
||
placeholder="交接物料"
|
||
filterable
|
||
multiple
|
||
clearable
|
||
@change="materialChange"
|
||
style="width: 100%"
|
||
>
|
||
<el-option
|
||
v-for="item in materialOptions"
|
||
:key="item.id"
|
||
:label="item.batch"
|
||
:value="item.id"
|
||
>
|
||
<span>{{ item.batch }}</span>
|
||
<div style="float: right">
|
||
<span>{{ item.count }}</span>
|
||
<span v-if="item.notok_sign_name !== null" style="color: #aaaaaa">
|
||
({{ item.notok_sign_name }})
|
||
</span>
|
||
</div>
|
||
</el-option>
|
||
</el-select>
|
||
</el-form-item>
|
||
</el-col>
|
||
</el-row>
|
||
<el-row v-for="(listItem,$index) in form.handoverb" :key="listItem">
|
||
<el-col :span="10">
|
||
<el-form-item label="交接物料">
|
||
<el-input v-model="listItem.batch" disabled></el-input>
|
||
</el-form-item>
|
||
</el-col>
|
||
<el-col :span="5">
|
||
<el-form-item label="总数量">
|
||
<span>{{ listItem.count_cando }}</span>
|
||
</el-form-item>
|
||
</el-col>
|
||
<el-col :span="7">
|
||
<el-form-item label="交接数量">
|
||
<el-input-number
|
||
v-model="listItem.count"
|
||
controls-position="right"
|
||
:min="0"
|
||
step="1"
|
||
:max="listItem.count_cando"
|
||
:disabled="mode==='show'"
|
||
:step-strictly="true"
|
||
style="width: 100%"
|
||
placeholder="交接数量"
|
||
@change="countChange"
|
||
>
|
||
</el-input-number>
|
||
</el-form-item>
|
||
</el-col>
|
||
<el-col :span="2" v-if="mode!=='show'">
|
||
<el-button type="danger" icon="el-icon-delete" @click="delMaterial($index)"></el-button>
|
||
</el-col>
|
||
</el-row>
|
||
<el-row>
|
||
<el-col :md="12" :sm="24">
|
||
<el-form-item label="交送日期" prop="send_date">
|
||
<el-date-picker
|
||
v-model="form.send_date"
|
||
type="date"
|
||
placeholder="选择时间"
|
||
format="YYYY-MM-DD"
|
||
value-format="YYYY-MM-DD"
|
||
style="width: 100%"
|
||
/>
|
||
</el-form-item>
|
||
</el-col>
|
||
<el-col :md="12" :sm="24" v-if="mtype!==30">
|
||
<el-form-item label="交送人">
|
||
<el-select
|
||
v-model="form.send_user"
|
||
placeholder="交送人"
|
||
clearable
|
||
filterable
|
||
style="width: 100%"
|
||
>
|
||
<el-option
|
||
v-for="item in userList"
|
||
:key="item.id"
|
||
:label="item.name"
|
||
:value="item.id"
|
||
/>
|
||
</el-select>
|
||
</el-form-item>
|
||
</el-col>
|
||
<el-col :md="12" :sm="24" v-if="mtype!==30">
|
||
<el-form-item label="接收工段" prop="recive_mgroup">
|
||
<el-select
|
||
v-model="form.recive_mgroup"
|
||
placeholder="接收工段"
|
||
clearable
|
||
style="width: 100%"
|
||
:disabled="type==40"
|
||
@change="getUserList2"
|
||
>
|
||
<el-option
|
||
v-for="item in mgroupOptions"
|
||
:key="item.id"
|
||
:label="item.name"
|
||
:value="item.id"
|
||
></el-option>
|
||
</el-select>
|
||
</el-form-item>
|
||
</el-col>
|
||
<el-col :md="12" :sm="24" v-if="mtype!==30">
|
||
<el-form-item label="接收人">
|
||
<el-select
|
||
v-model="form.recive_user"
|
||
placeholder="接收人"
|
||
clearable
|
||
filterable
|
||
style="width: 100%"
|
||
>
|
||
<el-option
|
||
v-for="item in userList2"
|
||
:key="item.id"
|
||
:label="item.name"
|
||
:value="item.id"
|
||
/>
|
||
</el-select>
|
||
</el-form-item>
|
||
</el-col>
|
||
<el-col :md="12" :sm="24">
|
||
<el-form-item label="更改批次">
|
||
<el-switch v-model="change_batch"></el-switch>
|
||
</el-form-item>
|
||
</el-col>
|
||
<el-col :md="12" :sm="24">
|
||
<el-form-item label="处理备注">
|
||
<el-input v-model="form.note" placeholder="处理备注"></el-input>
|
||
</el-form-item>
|
||
</el-col>
|
||
<el-col :md="12" :sm="24" v-if="change_batch">
|
||
<el-form-item label="新批次号" prop="new_batch">
|
||
<el-input v-model="form.new_batch" placeholder="新批次号"></el-input>
|
||
</el-form-item>
|
||
</el-col>
|
||
</el-row>
|
||
</el-form>
|
||
<el-footer v-if="mode!=='show'">
|
||
<el-button type="primary" v-loading="isSaveing" @click="submit">确定</el-button>
|
||
<el-button @click="visible = false">取消</el-button>
|
||
</el-footer>
|
||
</el-dialog>
|
||
</template>
|
||
<script>
|
||
export default {
|
||
emits: ["success", "closed"],
|
||
props: {
|
||
type: {
|
||
type: Number,
|
||
default: 10,
|
||
},
|
||
mgroupId: {
|
||
type: String,
|
||
default: "",
|
||
},
|
||
mgroupName: {
|
||
type: String,
|
||
default: "",
|
||
},
|
||
processtype:{
|
||
type:String,
|
||
default:""
|
||
|
||
},
|
||
process:{
|
||
type:String,
|
||
default:""
|
||
|
||
},
|
||
changebatch:{
|
||
type:Boolean,
|
||
default:false
|
||
}
|
||
},
|
||
data() {
|
||
return {
|
||
change_batch:false,
|
||
selectItems:[],
|
||
yseorno: ["是", "否"],
|
||
loading: false,
|
||
mode: "add",
|
||
titleMap: {
|
||
add: "新增交接记录",
|
||
edit: "编辑交接记录",
|
||
show: "查看交接记录",
|
||
},
|
||
lists:[],//交接数组
|
||
handle_user: [],
|
||
form: {
|
||
send_date: null,
|
||
send_user: null,
|
||
send_mgroup: null,
|
||
recive_user: null,
|
||
recive_mgroup: null,
|
||
handoverb:[],
|
||
},
|
||
rules: {
|
||
batch: [
|
||
{
|
||
required: true,
|
||
message: "请输入批次号",
|
||
trigger: "blur",
|
||
},
|
||
],
|
||
wm: {
|
||
required: true,
|
||
message: "请选择物料",
|
||
trigger: "blur",
|
||
},
|
||
send_date: [
|
||
{
|
||
required: true,
|
||
message: "请选择送料日期",
|
||
trigger: "blur",
|
||
},
|
||
],
|
||
send_user: [
|
||
{
|
||
required: true,
|
||
message: "请选择交送人",
|
||
trigger: "blur",
|
||
},
|
||
],
|
||
send_mgroup: [
|
||
{
|
||
required: true,
|
||
message: "请选择交送工段",
|
||
trigger: "blur",
|
||
},
|
||
],
|
||
new_batch: [
|
||
{
|
||
required: true,
|
||
message: "请填写新批次号",
|
||
trigger: "blur",
|
||
},
|
||
],
|
||
recive_mgroup: [
|
||
{
|
||
required: true,
|
||
message: "请选择接收工段",
|
||
trigger: "blur",
|
||
},
|
||
],
|
||
},
|
||
listParams:{},
|
||
totalCount: 0,
|
||
deptID:'',
|
||
codeText: "",
|
||
userList: [],
|
||
userList2: [],
|
||
mgroupOptions: [],
|
||
materialOptions: [],
|
||
addShow: false,
|
||
visible: false,
|
||
scanVisible:false,
|
||
isSaveing: false,
|
||
setFiltersVisible: false,
|
||
};
|
||
},
|
||
mounted() {
|
||
let that = this;
|
||
that.change_batch = that.changebatch;
|
||
that.form.type = that.type;
|
||
let materialObj = that.$TOOL.data.get("MATERIAL_OBJECT");
|
||
that.materialObj = materialObj;
|
||
that.form.handle_date = that.form.send_date = this.$TOOL.dateFormat2(new Date());
|
||
that.form.send_mgroup = that.mgroupId;
|
||
//type 10:正常交接 ;20:返工交接 ;40:报废交接
|
||
//mtype 10:正常交接 ;20:分批操作 ;30:合批操作
|
||
//获取交接人员
|
||
if(that.type==20&&that.mgroupName=='废品库'){//废品出库交接
|
||
that.getCkUserList();
|
||
}else{
|
||
that.deptID = that.$TOOL.data.get('gx_deptID');
|
||
that.getUserList();
|
||
}
|
||
//获取交接物料
|
||
if((that.type==20&&that.mgroupName!=='废品库')||that.type==40){
|
||
//返工交接和报废交接
|
||
that.getMaterialNotok();
|
||
}else if(that.type==20&&that.mgroupName=='废品库'){
|
||
//废品出库
|
||
that.getMaterialFP();
|
||
}else{
|
||
//其他
|
||
that.getMaterial();
|
||
}
|
||
if(that.type==40||that.type==20){
|
||
that.getMgroupOptions();
|
||
}else{
|
||
that.getMgroupOptions();
|
||
}
|
||
},
|
||
methods: {
|
||
//获取工段列表
|
||
getMgroupOptions() {
|
||
let that = this;
|
||
that.$API.mtm.mgroup.list.req({ page: 0}).then((res) => {
|
||
that.mgroupOptions = res;
|
||
if(that.type==40){
|
||
res.forEach(item=>{
|
||
if(item.name=="废品库"){
|
||
that.form.recive_mgroup = item.id;
|
||
}
|
||
})
|
||
that.getCkUserList();//废品库接收人
|
||
}
|
||
});
|
||
},
|
||
//获取车间物料
|
||
getMaterial() {
|
||
let that = this;
|
||
var req = {
|
||
page: 0,
|
||
state:10,
|
||
tag:'done'
|
||
};
|
||
that.materialOptions = [];
|
||
req.mgroup = that.mgroupId;
|
||
that.listParams = req;
|
||
this.$API.wpm.wmaterial.list.req(req).then((res) => {
|
||
that.materialOptions = res;
|
||
res.forEach(item=>{
|
||
if(that.codeText!==''&&item.batch === that.codeText){
|
||
let obj = {};
|
||
obj.wm = item.id;
|
||
obj.batch = item.batch;
|
||
obj.count = item.count_cando;
|
||
obj.count_cando = item.count_cando;
|
||
that.totalCount = item.count_cando;
|
||
that.form.handoverb.push(obj)
|
||
that.getResaveMgroups(item.material);
|
||
}
|
||
})
|
||
});
|
||
},
|
||
getResaveMgroups(material){
|
||
let that = this;
|
||
let params = {
|
||
material: material,
|
||
type: that.type,
|
||
};
|
||
that.$API.wpm.handover.mgroups.req(params).then((res) => {
|
||
that.mgroupOptions = res;
|
||
if(res.length==1){
|
||
that.form.recive_mgroup = res[0].id;
|
||
}
|
||
})
|
||
},
|
||
//获取车间不合格物料
|
||
getMaterialNotok() {
|
||
let that = this;
|
||
that.materialOptions = [];
|
||
var req = {
|
||
mgroupx: that.mgroupId,
|
||
page: 0,
|
||
state:20
|
||
};
|
||
that.listParams = req;
|
||
this.$API.wpm.wmaterial.list.req(req).then((res) => {
|
||
that.materialOptions = res;
|
||
});
|
||
},
|
||
//获取废品库物料
|
||
getMaterialFP() {
|
||
let that = this;
|
||
that.materialOptions = [];
|
||
var obj = {
|
||
page: 0,
|
||
state : 50,
|
||
state_all: 1
|
||
};
|
||
that.$API.wpm.wmaterial.list.req(obj).then((res) => {
|
||
that.materialOptions = res;
|
||
});
|
||
},
|
||
//获取交送工段人员
|
||
getUserList() {
|
||
let that = this;
|
||
let userInfo = that.$TOOL.data.get("USER_INFO");
|
||
this.$API.system.user.list.req({ depts: that.deptID, page: 0 }).then((res) => {
|
||
that.userList = res;
|
||
let arr = res.filter(item=>{
|
||
return item.id==userInfo.id;
|
||
})
|
||
if(arr.length>0){
|
||
that.form.send_user = userInfo.id;
|
||
}else{
|
||
let obj = {};
|
||
obj.id = userInfo.id;
|
||
obj.name = userInfo.name;
|
||
that.userList.push(obj)
|
||
that.form.send_user = userInfo.id;
|
||
}
|
||
|
||
});
|
||
},
|
||
//获取仓库人员
|
||
getCkUserList() {
|
||
let that = this;
|
||
this.$API.system.user.list.req({ page: 0, posts__code: "inm&check" })
|
||
.then((res) => {
|
||
if(that.type==40){
|
||
that.userList2 = [];
|
||
that.userList2 = res;
|
||
}else if(that.type==20&&that.mgroupName=='废品库'){
|
||
that.userList = [];
|
||
that.userList = res;
|
||
}
|
||
});
|
||
},
|
||
//获取接收工段人员
|
||
getUserList2() {
|
||
let that = this;
|
||
let deptID = '';
|
||
if(that.form.recive_dept&&that.form.recive_dept!==''&&that.form.recive_dept!==null){
|
||
deptID = that.form.recive_dept;
|
||
}else{
|
||
that.mgroupOptions.forEach(item => {
|
||
if(item.id==that.form.recive_mgroup){
|
||
deptID = item.belong_dept;
|
||
}
|
||
});
|
||
}
|
||
that.$API.system.user.list.req({ depts: deptID, page: 0 }).then((res) => {
|
||
that.userList2 = res;
|
||
});
|
||
},
|
||
//获取接收部门人员
|
||
getUserList3() {
|
||
let that = this;
|
||
this.$API.system.user.list
|
||
.req({ depts: that.form.recive_dept, page: 0 })
|
||
.then((res) => {
|
||
that.userList2 = res;
|
||
});
|
||
},
|
||
addMaterial(){
|
||
this.addShow = true;
|
||
},
|
||
delMaterial(index){
|
||
this.form.handoverb.splice(index,1);
|
||
this.countChange();
|
||
},
|
||
//显示
|
||
open(mode = "add",data,mtype) {
|
||
this.mode = mode;
|
||
this.mtype = mtype;
|
||
if(data!==''&&data!==null&&data!==undefined){
|
||
if(typeof(data)=='string'){
|
||
this.codeText = data.replace(" ","");
|
||
this.codeTextChange(this.codeText)
|
||
}else{
|
||
this.form.handoverb = data;
|
||
data.forEach(item=>{
|
||
this.totalCount += item.count_cando;
|
||
})
|
||
}
|
||
}
|
||
if(mtype==30){//合批
|
||
this.change_batch = true;
|
||
}
|
||
this.visible = true;
|
||
return this;
|
||
},
|
||
materialChange() {
|
||
let that = this;
|
||
let totalCount = 0;
|
||
let data = that.materialOptions.filter((item) => {
|
||
return that.selectItems.indexOf(item.id)>-1;
|
||
});
|
||
data.forEach(item=>{
|
||
item.wm = item.id;
|
||
item.count = item.count_cando;
|
||
totalCount += item.count_cando;
|
||
})
|
||
that.totalCount = totalCount;
|
||
that.form.handoverb = data;
|
||
that.getResaveMgroups(data[0].material);
|
||
},
|
||
countChange(){
|
||
let that = this;
|
||
let totalCount = 0;
|
||
if(this.form.handoverb.length>0){
|
||
this.form.handoverb.forEach(item=>{
|
||
totalCount += item.count;
|
||
})
|
||
that.totalCount = totalCount;
|
||
}
|
||
},
|
||
//提交
|
||
submit() {
|
||
let that = this;
|
||
that.$refs.dialogForm.validate(async (valid) => {
|
||
if (valid) {
|
||
if(that.mtype==20||that.mtype==30){
|
||
that.form.recive_mgroup = that.form.send_mgroup;
|
||
that.form.mtype = that.mtype;
|
||
}
|
||
if(that.form.new_batch!==''){
|
||
that.form.mtype=30;
|
||
that.mtype==30
|
||
}
|
||
if(that.mtype==20||that.mtype==30||that.type==40){
|
||
that.$API.wpm.handover.createsubmit.req(that.form).then((res) => {
|
||
that.isSaveing = false;
|
||
that.$emit("success");
|
||
that.visible = false;
|
||
that.$message.success("操作成功");
|
||
}).catch((err) => {
|
||
that.isSaveing = false;
|
||
return err;
|
||
});
|
||
}else{
|
||
if(that.form.new_batch!==''){
|
||
that.form.mtype=30;
|
||
}
|
||
if (that.mode == "add") {
|
||
that.$API.wpm.handover.create.req(that.form).then((res) => {
|
||
that.isSaveing = false;
|
||
that.$emit("success");
|
||
that.visible = false;
|
||
that.$message.success("操作成功");
|
||
}).catch((err) => {
|
||
that.isSaveing = false;
|
||
return err;
|
||
});
|
||
} else if (that.mode == "edit") {
|
||
that.$API.wpm.handover.update.req(that.form.id, that.form).then((res) => {
|
||
that.isSaveing = false;
|
||
that.$emit("success", that.form, that.mode);
|
||
that.visible = false;
|
||
that.$message.success("操作成功");
|
||
}).catch((err) => {
|
||
that.isSaveing = false;
|
||
return err;
|
||
});
|
||
}
|
||
}
|
||
}
|
||
});
|
||
},
|
||
//表单注入数据
|
||
setData(data) {
|
||
Object.assign(this.form, data);
|
||
if(data.type==30){
|
||
this.getUserList3();
|
||
}else{
|
||
this.getUserList2();
|
||
}
|
||
},
|
||
//设置过滤项
|
||
setFilters(filters) {
|
||
this.selectionFilters = filters;
|
||
this.setFiltersVisible = true;
|
||
},
|
||
//扫描
|
||
scanCode(){
|
||
let that = this;
|
||
that.scanVisible = true;
|
||
},
|
||
codeTextChange(data){
|
||
if(data==''||data==undefined||data==null){
|
||
return;
|
||
}
|
||
let that = this;
|
||
// data = data.replace(' ','');
|
||
let id = data.split('#')[1];
|
||
this.$API.cm.labelmat.item.req(id).then((res) => {
|
||
let arr = that.form.handoverb.filter((item) => {
|
||
return item.batch == res.batch;
|
||
})
|
||
if(arr.length>0){
|
||
that.$message.error("该批次已存在")
|
||
}else{
|
||
that.materialOptions.forEach((item) => {
|
||
if(item.batch == res.batch){
|
||
let obj = {};
|
||
obj.wm = item.id;
|
||
obj.batch = item.batch;
|
||
obj.counts = item.count;
|
||
obj.count = item.count;
|
||
that.form.handoverb.push(obj)
|
||
that.getResaveMgroups(item.material);
|
||
}
|
||
})
|
||
}
|
||
})
|
||
//根据扫描内容,获取物料详情匹配当前库存物料
|
||
this.scanVisible = false;
|
||
},
|
||
},
|
||
};
|
||
</script>
|
||
<style scoped>
|
||
.formTitle {
|
||
margin-bottom: 10px;
|
||
font-weight: 600;
|
||
}
|
||
.total-count{
|
||
width: 100%;
|
||
text-align: right;
|
||
height: 50px;
|
||
line-height: 50px;
|
||
}
|
||
</style>
|