fix:交接表单变动,并添加分批合批功能(分批但拉出来了)
This commit is contained in:
		
							parent
							
								
									aacdd0b892
								
							
						
					
					
						commit
						86921313d8
					
				|  | @ -13,117 +13,14 @@ | |||
| 			:rules="rules" | ||||
| 			label-width="80px" | ||||
| 		> | ||||
| 			<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"> | ||||
| 					<el-form-item label="交接数量" width="100"> | ||||
| 						<el-input-number | ||||
| 							v-model="form.count" | ||||
| 							controls-position="right" | ||||
| 							:min="0" | ||||
| 							step="1" | ||||
| 							:step-strictly="true" | ||||
| 							style="width: 100%" | ||||
| 							placeholder="交接数量" | ||||
| 						> | ||||
| 						</el-input-number> | ||||
| 					</el-form-item> | ||||
| 				</el-col> --> | ||||
| 				<el-col :md="12" :sm="24"> | ||||
| 					<el-form-item label="交送人" prop="send_user"> | ||||
| 						<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="type==30"> | ||||
| 					<el-form-item label="接收部门" prop="recive_dept"> | ||||
| 						<el-select | ||||
| 							v-model="form.recive_dept" | ||||
| 							placeholder="接收部门" | ||||
| 							clearable | ||||
| 							style="width: 100%" | ||||
| 							@change="getUserList3" | ||||
| 						> | ||||
| 							<el-option | ||||
| 								v-for="item in deptOptions" | ||||
| 								: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-else> | ||||
| 					<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"> | ||||
| 					<el-form-item label="接收人" prop="recive_user"> | ||||
| 						<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-input v-model="form.note" placeholder="处理备注"></el-input> | ||||
| 					</el-form-item> | ||||
| 				</el-col> | ||||
| 			</el-row> | ||||
| 			<el-row> | ||||
| 				<el-form-item label="交接物料"> | ||||
| 					<el-button type="primary" @click="addMaterial" v-if="mode!=='show'">手动添加</el-button> | ||||
| 					<scan-dialog ref="scanDialog" @closed="scanClose"> </scan-dialog> | ||||
| 				</el-form-item> | ||||
| 				<el-form-item label="总计:"> | ||||
| 					{{ totalCount }} | ||||
| 				</el-form-item> | ||||
| 			</el-row> | ||||
| 			<el-row v-show="addShow"> | ||||
| 				<el-col> | ||||
|  | @ -188,7 +85,88 @@ | |||
| 				</el-col> | ||||
| 			</el-row> | ||||
| 			<el-row> | ||||
| 				<div class="total-count">总计:{{ totalCount }}</div> | ||||
| 				<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'"> | ||||
|  | @ -214,12 +192,27 @@ export default { | |||
| 			type: String, | ||||
| 			default: "", | ||||
| 		}, | ||||
| 		processtype:{ | ||||
| 			type:String, | ||||
| 			default:"" | ||||
| 
 | ||||
| 		}, | ||||
| 		process:{ | ||||
| 			type:String, | ||||
| 			default:"" | ||||
| 
 | ||||
| 		}, | ||||
| 		changebatch:{ | ||||
| 			type:Boolean, | ||||
| 			default:false | ||||
| 		} | ||||
| 	}, | ||||
| 	components: { | ||||
| 		scanDialog | ||||
| 	}, | ||||
| 	data() { | ||||
| 		return { | ||||
| 			change_batch:false, | ||||
| 			selectItems:[], | ||||
| 			yseorno: ["是", "否"], | ||||
| 			loading: false, | ||||
|  | @ -288,14 +281,11 @@ export default { | |||
| 					}, | ||||
| 				], | ||||
| 			}, | ||||
| 			listParams:{ | ||||
| 
 | ||||
| 			}, | ||||
| 			listParams:{}, | ||||
| 			totalCount: 0, | ||||
| 			deptID:'', | ||||
| 			userList: [], | ||||
| 			userList2: [], | ||||
| 			deptOptions:[], | ||||
| 			mgroupOptions: [], | ||||
| 			materialOptions: [], | ||||
| 			addShow: false, | ||||
|  | @ -307,6 +297,7 @@ export default { | |||
| 	}, | ||||
| 	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; | ||||
|  | @ -314,39 +305,35 @@ export default { | |||
| 		let year = date.getFullYear(); | ||||
| 		let month = date.getMonth() + 1; | ||||
| 		let day = date.getDate(); | ||||
| 		that.form.handle_date = year + "-" + month + "-" + day; | ||||
| 		month = month>9?month:'0'+month; | ||||
| 		day = day>9?day:'0'+day; | ||||
| 		that.form.handle_date = that.form.send_date = year + "-" + month + "-" + day; | ||||
| 		that.form.send_mgroup = that.mgroupId; | ||||
| 		if(that.mgroupName=="size"||that.mgroupName=="facade"){//检验部交接 | ||||
| 			that.$API.system.user.list | ||||
| 				.req({ page: 0, posts__code__contains: "check" }) | ||||
| 				.then((res) => { | ||||
| 					that.userList = res; | ||||
| 				}); | ||||
| 		}else if(that.type==20&&that.mgroupName=='废品库'){//废品交接 | ||||
| 		//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(); | ||||
| 		} | ||||
| 		that.getDeptOptions(); | ||||
| 		if(that.type==40||that.type==20){ | ||||
| 			that.getMgroupOptions(); | ||||
| 		}else{} | ||||
| 	}, | ||||
| 	methods: { | ||||
| 		//获取部门列表 | ||||
| 		getDeptOptions() { | ||||
| 			this.$API.system.dept.list | ||||
| 				.req({ page: 0, type: "dept" }) | ||||
| 				.then((res) => { | ||||
| 					this.deptOptions = res; | ||||
| 				}); | ||||
| 		}, | ||||
| 		//获取工段列表 | ||||
| 		getMgroupOptions() { | ||||
| 			let that = this; | ||||
|  | @ -367,37 +354,40 @@ export default { | |||
| 			let that = this; | ||||
| 			var req = { | ||||
| 				page: 0, | ||||
| 				notok_sign__isnull : 1, | ||||
| 				count_xtest__isnull:1 | ||||
| 				state:10, | ||||
| 				tag:'done' | ||||
| 			}; | ||||
| 			that.materialOptions = []; | ||||
| 			if(that.mgroupName=="size"){ | ||||
| 				that.$API.system.dept.list.req({name__contains:'尺寸',page:0}).then((res) => { | ||||
| 					if(res.length>0){ | ||||
| 						req.belong_dept=res[0].id; | ||||
| 			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); | ||||
| 					} | ||||
| 				}) | ||||
| 			}else if(that.mgroupName=="facade"){ | ||||
| 				that.$API.system.dept.list.req({name__contains:'外观',page:0}).then((res) => { | ||||
| 					if(res.length>0){ | ||||
| 						req.belong_dept=res[0].id; | ||||
| 						that.listParams = req; | ||||
| 						this.$API.wpm.wmaterial.list.req(req).then((res) => { | ||||
| 							that.materialOptions = res; | ||||
| 			}); | ||||
| 		}, | ||||
| 		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; | ||||
| 				} | ||||
| 			}) | ||||
| 			}else{ | ||||
| 				req.mgroupx = that.mgroupId; | ||||
| 				that.listParams = req; | ||||
| 				this.$API.wpm.wmaterial.list.req(req).then((res) => { | ||||
| 					that.materialOptions = res; | ||||
| 				}); | ||||
| 			} | ||||
| 		}, | ||||
| 		//获取车间不合格物料 | ||||
| 		getMaterialNotok() { | ||||
|  | @ -406,8 +396,7 @@ export default { | |||
| 			var req = { | ||||
| 				mgroupx: that.mgroupId, | ||||
| 				page: 0, | ||||
| 				notok_sign__isnull : 0, | ||||
| 				count_xtest__isnull:1 | ||||
| 				state:20 | ||||
| 			}; | ||||
| 			that.listParams = req; | ||||
| 			this.$API.wpm.wmaterial.list.req(req).then((res) => { | ||||
|  | @ -430,8 +419,22 @@ export default { | |||
| 		//获取交送工段人员 | ||||
| 		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; | ||||
| 				} | ||||
| 				 | ||||
| 			}); | ||||
| 		}, | ||||
| 		//获取仓库人员 | ||||
|  | @ -478,8 +481,24 @@ export default { | |||
| 			this.countChange(); | ||||
| 		}, | ||||
| 		//显示 | ||||
| 		open(mode = "add") { | ||||
| 		open(mode = "add",data,mtype) { | ||||
| 			this.mode = mode; | ||||
| 			this.mtype = mtype; | ||||
| 			if(typeof(data)=='string'){ | ||||
| 				if(data!==''){ | ||||
| 					this.codeText = data.replace(" ",""); | ||||
| 				} | ||||
| 			}else{ | ||||
| 				this.form.handoverb = data; | ||||
| 			} | ||||
| 			// if(mtype==10){//正常交接 | ||||
| 			// 	console.log('data',data) | ||||
| 				 | ||||
| 			// }else if(mtype==20){//分批 | ||||
| 			// 	this.codeText = data.replace(" ",""); | ||||
| 			// }else if(mtype==30||this.type==20||this.type==40){//合批 | ||||
| 			// 	this.form.handoverb = data; | ||||
| 			// } | ||||
| 			this.visible = true; | ||||
| 			return this; | ||||
| 		}, | ||||
|  | @ -496,6 +515,7 @@ export default { | |||
| 			}) | ||||
| 			that.totalCount = totalCount; | ||||
| 			that.form.handoverb = data; | ||||
| 			that.getResaveMgroups(data[0].material); | ||||
| 		}, | ||||
| 		countChange(){ | ||||
| 			let that = this; | ||||
|  | @ -513,8 +533,13 @@ export default { | |||
| 			that.$refs.dialogForm.validate(async (valid) => { | ||||
| 				if (valid) { | ||||
| 					if (that.mode == "add") { | ||||
| 						if(that.mtype==30){ | ||||
| 							that.form.mtype =30; | ||||
| 							that.form.recive_user = that.form.send_user; | ||||
| 							that.form.recive_mgroup = that.form.send_mgroup; | ||||
| 						} | ||||
| 						that.$API.wpm.handover.create.req(that.form).then((res) => { | ||||
| 							if(that.type==40){ | ||||
| 							if(that.type==40||that.mtype==20||that.mtype==30){ | ||||
| 								//提交 | ||||
| 								that.$API.wpm.handover.submit.req(res.id).then((res1) => { | ||||
| 									that.isSaveing = false; | ||||
|  | @ -592,6 +617,7 @@ export default { | |||
| 							obj.count = item.count; | ||||
| 							that.form.handoverb.push(obj) | ||||
| 							that.$refs.scanDialog.closed(); | ||||
| 							that.getResaveMgroups(item.material); | ||||
| 						}	 | ||||
| 					}) | ||||
| 				} | ||||
|  |  | |||
|  | @ -0,0 +1,299 @@ | |||
| <template> | ||||
| 	<el-dialog | ||||
| 		:title="titleMap[type]" | ||||
| 		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-col>交接物料:{{codeText}} <el-button type="primary" @click="batchAdd">分批</el-button></el-col> | ||||
| 				<el-form-item label="剩余可分配数量:" label-width="130"> | ||||
| 					{{saveCount}} | ||||
| 				</el-form-item> | ||||
| 				 | ||||
| 			</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="7"> | ||||
| 					<el-form-item label="数量"> | ||||
| 						<el-input-number | ||||
| 							v-model="listItem.count" | ||||
| 							controls-position="right" | ||||
| 							:min="0" | ||||
| 							step="1" | ||||
| 							:max="batchOrign.count" | ||||
| 							: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"> | ||||
| 					<el-form-item label="处理备注">	 | ||||
| 						<el-input v-model="form.note" 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> | ||||
| import scanDialog from "./../template/scan.vue"; | ||||
| export default { | ||||
| 	emits: ["success", "closed"], | ||||
| 	props: { | ||||
| 		type: { | ||||
| 			type: Number, | ||||
| 			default: 10, | ||||
| 		}, | ||||
| 		mgroupId: { | ||||
| 			type: String, | ||||
| 			default: "", | ||||
| 		}, | ||||
| 		process:{ | ||||
| 			type:String, | ||||
| 			default:"" | ||||
| 
 | ||||
| 		} | ||||
| 	}, | ||||
| 	components: { | ||||
| 		scanDialog | ||||
| 	}, | ||||
| 	data() { | ||||
| 		return { | ||||
| 			selectItems:[], | ||||
| 			loading: false, | ||||
| 			mode: "add", | ||||
| 			titleMap: { | ||||
| 				20: "分批", | ||||
| 				30: "合批", | ||||
| 			}, | ||||
| 			mtype:20, | ||||
| 			saveCount:0, | ||||
| 			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", | ||||
| 				}, | ||||
| 			}, | ||||
| 			batchOrign:{}, | ||||
| 			totalCount: 0, | ||||
| 			deptID:'', | ||||
| 			materialOptions: [], | ||||
| 			visible: false, | ||||
| 			isSaveing: false, | ||||
| 			setFiltersVisible: false, | ||||
| 		}; | ||||
| 	}, | ||||
| 	mounted() { | ||||
| 		let that  = this; | ||||
| 		that.form.type = that.type; | ||||
| 		let materialObj = that.$TOOL.data.get("MATERIAL_OBJECT"); | ||||
| 		that.materialObj = materialObj; | ||||
| 		let date = new Date(); | ||||
| 		let year = date.getFullYear(); | ||||
| 		let month = date.getMonth() + 1; | ||||
| 		let day = date.getDate(); | ||||
| 		month = month>9?month:'0'+month; | ||||
| 		day = day>9?day:'0'+day; | ||||
| 		that.form.handle_date = that.form.send_date = year + "-" + month + "-" + day; | ||||
| 		that.form.send_mgroup = that.form.recive_mgroup = that.mgroupId; | ||||
| 		let userInfo = that.$TOOL.data.get("USER_INFO"); | ||||
| 		that.deptID = that.$TOOL.data.get('gx_deptID'); | ||||
| 		that.form.send_user = that.form.recive_user= userInfo.id; | ||||
| 		that.getMaterial(); | ||||
| 	}, | ||||
| 	methods: { | ||||
| 		//获取车间物料 | ||||
| 		getMaterial() { | ||||
| 			let that = this; | ||||
| 			var req = { | ||||
| 				page: 0, | ||||
| 				state:10, | ||||
| 				material__process:that.process | ||||
| 			}; | ||||
| 			that.materialOptions = []; | ||||
| 			req.mgroupx = that.mgroupId; | ||||
| 			that.listParams = req; | ||||
| 			this.$API.wpm.wmaterial.list.req(req).then((res) => { | ||||
| 				that.materialOptions = res; | ||||
| 				that.form.handoverb = []; | ||||
| 				res.forEach(item=>{ | ||||
| 					that.batchOrign= item; | ||||
| 					if(item.batch === that.codeText){ | ||||
| 						let obj = {}; | ||||
| 						obj.wm = item.id; | ||||
| 						obj.batch = item.batch+'-1'; | ||||
| 						obj.count = item.count; | ||||
| 						that.form.handoverb.push(obj) | ||||
| 					} | ||||
| 				}) | ||||
| 			}); | ||||
| 		}, | ||||
| 		//获取车间不合格物料 | ||||
| 		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; | ||||
| 			}); | ||||
| 		}, | ||||
| 		batchAdd(){ | ||||
| 			let that = this; | ||||
| 			if(that.saveCount>0){ | ||||
| 				let indexs = that.form.handoverb.length+1; | ||||
| 				let count = 0; | ||||
| 				that.form.handoverb.forEach(item=>{ | ||||
| 					count+=item.count; | ||||
| 				}) | ||||
| 				let obj = { }; | ||||
| 				obj.wm = that.batchOrign.id; | ||||
| 				obj.batch = that.codeText+"-"+indexs; | ||||
| 				obj.count = that.batchOrign.count - count; | ||||
| 				that.saveCount = 0; | ||||
| 				that.form.handoverb.push(obj) | ||||
| 			}else{ | ||||
| 				that.$message.warning("已无可分配数量"); | ||||
| 			} | ||||
| 		}, | ||||
| 		delMaterial(index){ | ||||
| 			this.form.handoverb.splice(index,1); | ||||
| 			this.countChange(); | ||||
| 		}, | ||||
| 		//显示 | ||||
| 		open(mode = "add",data,mtype) { | ||||
| 			this.mode = mode; | ||||
| 			this.form.mtype = mtype; | ||||
| 			this.codeText = data.replace(" ",""); | ||||
| 			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; | ||||
| 				totalCount += item.count; | ||||
| 			}) | ||||
| 			that.totalCount = totalCount; | ||||
| 			that.form.handoverb = data; | ||||
| 		}, | ||||
| 		countChange(){ | ||||
| 			let that = this; | ||||
| 			let totalCount = 0; | ||||
| 			if(this.form.handoverb.length>0){ | ||||
| 				this.form.handoverb.forEach(item=>{ | ||||
| 					totalCount += item.count; | ||||
| 				}) | ||||
| 				that.saveCount = that.batchOrign.count-totalCount; | ||||
| 			} | ||||
| 		}, | ||||
| 		//提交 | ||||
| 		submit() { | ||||
| 			let that = this; | ||||
| 			that.$refs.dialogForm.validate(async (valid) => { | ||||
| 				if (valid) { | ||||
| 					if (that.mode == "add") { | ||||
| 						that.$API.wpm.handover.create.req(that.form).then((res) => { | ||||
| 							that.$API.wpm.handover.submit.req(res.id).then((res1) => { | ||||
| 								that.isSaveing = false; | ||||
| 								that.$emit("success"); | ||||
| 								that.visible = false; | ||||
| 								that.$message.success("操作成功"); | ||||
| 							}); | ||||
| 						}).catch((err) => { | ||||
| 							//可以处理校验错误 | ||||
| 							that.isSaveing = false; | ||||
| 							return err; | ||||
| 						}); | ||||
| 					}  | ||||
| 				} | ||||
| 			}); | ||||
| 		}, | ||||
| 		//表单注入数据 | ||||
| 		setData(data) { | ||||
| 			Object.assign(this.form, data); | ||||
| 			console.log('this.form',this.form); | ||||
| 		}, | ||||
| 		//设置过滤项 | ||||
| 		setFilters(filters) { | ||||
| 			this.selectionFilters = filters; | ||||
| 			this.setFiltersVisible = true; | ||||
| 		}, | ||||
| 	}, | ||||
| }; | ||||
| </script> | ||||
| <style scoped> | ||||
| .formTitle { | ||||
| 	margin-bottom: 10px; | ||||
| 	font-weight: 600; | ||||
| } | ||||
| .total-count{ | ||||
| 	width: 100%; | ||||
|     text-align: right; | ||||
|     height: 50px; | ||||
|     line-height: 50px; | ||||
| } | ||||
| </style> | ||||
		Loading…
	
		Reference in New Issue