fix:出入库记录添加退还入库

This commit is contained in:
shijing 2025-07-30 15:54:02 +08:00
parent 8216495736
commit df5410dc42
2 changed files with 355 additions and 178 deletions

View File

@ -135,8 +135,9 @@
icon="el-icon-plus"
@click="table_add"
></el-button>
<scScanner @scanResult="codeTextChange"></scScanner>
<scScanner v-if="cate=='do_in'|| cate=='do_out'" @scanResult="codeTextChange"></scScanner>
<el-input
v-if="cate=='do_in'|| cate=='do_out'"
ref="codeInput"
v-model="codeText"
clearable
@ -260,7 +261,7 @@
</div>
</template>
</el-table-column>
<el-table-column label="不合格数量" prop="count_notok">
<el-table-column label="备注" prop="note">
</el-table-column>
<el-table-column
label="创建时间"
@ -268,7 +269,7 @@
show-overflow-tooltip
>
</el-table-column>
<el-table-column width="90">
<el-table-column width="90" v-if="cate=='do_in'|| cate=='do_out'">
<template #default="scope">
<el-button @click="printMaterial(scope.row)" type="text">物料标签</el-button>
</template>
@ -337,7 +338,12 @@ export default {
mio_user: "",
},
stateDict: {10: "创建中",20: "已提交",},
typeDict:{'do_in':'生产入库','do_out':'生产领料'},
typeDict:{
'do_in':'生产入库',
'do_out':'生产领料',
'borrow_out': "领用出库",
'return_in': "退还入库"
},
apiworkerObj: null,
materials: [],
apiObj: null,
@ -362,6 +368,7 @@ export default {
};
},
mounted() {
this.active = 0;
this.isSaveing = false;
this.form.mgroup = this.mgroupId;
this.form.type = this.cate;
@ -413,6 +420,7 @@ export default {
//
getDeptUsers() {
let that = this;
that.userList = [];
let userInfo = that.$TOOL.data.get("USER_INFO");
that.$API.system.user.list.req({ depts: that.deptId, page: 0 }).then((res) => {
that.userOptions = res;

View File

@ -12,182 +12,273 @@
:rules="rules"
label-width="120px"
>
<el-form-item label="物料" v-if="cate == 'do_out'">
<el-select
v-model="form.material"
value-key="id"
clearable
filterable
style="width: 100%"
@change="selectMaterialChange"
>
<el-option
v-for="item in materialOptions"
:key="item.id"
:label="item.full_name"
:value="item.id"
<template v-if="cate == 'do_in'||cate == 'do_out'">
<el-form-item label="物料" v-if="cate == 'do_out'">
<el-select
v-model="form.material"
value-key="id"
clearable
filterable
style="width: 100%"
@change="selectMaterialChange"
>
<span style="float: left">{{ item.full_name }}</span>
<span
style="
float: right;
color: '#E6A23C';
font-size: 13px;
"
v-if="item.is_hidden"
></span
<el-option
v-for="item in materialOptions"
:key="item.id"
:label="item.full_name"
:value="item.id"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="批次选择" v-else>
<el-select
v-model="selectBatch"
filterable
value-key="id"
style="width: 100%;"
multiple
@change="selectwmChange"
>
<el-option
v-for="item in wbatchOptions"
:key="item.id"
:label="item.batch"
:value="item.id"
>
<span style="display:inline-block;float: left;">{{item.material_.name}}|{{ item.batch }}</span>
<span v-if="item.defect_name!==null" style="display:inline-block;float: left;color: orangered;">{{ item.defect_name }}</span>
<span
style="
float: right;
color: var(--el-text-color-secondary);
font-size: 13px;
"
>{{ item.count }}</span
>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="批次扫描" v-if="cate == 'do_in'">
<scScanner @scanResult="codeTextChange"></scScanner>
<el-input
ref="codeInput"
v-model="codeText"
clearable
placeholder="物料扫码"
style="width:150px;margin-left: 4px;"
@keyup.enter="codeTextChange(codeText)"
></el-input>
</el-form-item>
<el-form-item label="批次" v-if="cate == 'do_out'">
<el-select
v-model="selectBatch"
value-key="id"
clearable
filterable
multiple
@change="selectBatchChange"
@clear="selectBatchClear"
style="width: 60%;"
>
<el-option
v-for="item in batchOptions"
:key="item.id"
:label="item.batch"
:value="item.id"
>
<span style="float: left">{{ item.batch }}</span>
<span
style="
float: right;
color: var(--el-text-color-secondary);
font-size: 13px;
"
>{{ item.count }} -- {{ item.warehouse_name }}</span
>
</el-option>
</el-select>
<scScanner @scanResult="codeTextChange"></scScanner>
<el-input
ref="codeInput"
v-model="codeText"
clearable
placeholder="物料扫码"
style="width:150px;margin-left: 4px;"
@keyup.enter="codeTextChange(codeText)"
></el-input>
</el-form-item>
<template v-if="cate == 'do_out'&&mode == 'add'">
<el-row v-for="item in selectList" :key="item.mb">
<el-col :span="12">
<el-form-item label="批次号">
<el-input v-model="item.batch" disabled />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="仓库" label-width="60px">
<el-select
v-model="item.warehouse"
disabled
style="width: 100%"
<span style="float: left">{{ item.full_name }}</span>
<span
style="
float: right;
color: '#E6A23C';
font-size: 13px;
"
v-if="item.is_hidden"
></span
>
<el-option
v-for="item in warehouseOptions"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="数量" label-width="60px">
<el-input v-model="item.count" disabled />
</el-form-item>
</el-col>
</el-row>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="批次选择" v-else>
<el-select
v-model="selectBatch"
filterable
value-key="id"
style="width: 100%;"
multiple
@change="selectwmChange"
>
<el-option
v-for="item in wbatchOptions"
:key="item.id"
:label="item.batch"
:value="item.id"
>
<span style="display:inline-block;float: left;">{{item.material_.name}}|{{ item.batch }}</span>
<span v-if="item.defect_name!==null" style="display:inline-block;float: left;color: orangered;">{{ item.defect_name }}</span>
<span
style="
float: right;
color: var(--el-text-color-secondary);
font-size: 13px;
"
>{{ item.count }}</span
>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="批次扫描" v-if="cate == 'do_in'">
<scScanner @scanResult="codeTextChange"></scScanner>
<el-input
ref="codeInput"
v-model="codeText"
clearable
placeholder="物料扫码"
style="width:150px;margin-left: 4px;"
@keyup.enter="codeTextChange(codeText)"
></el-input>
</el-form-item>
<el-form-item label="批次" v-if="cate == 'do_out'">
<el-select
v-model="selectBatch"
value-key="id"
clearable
filterable
multiple
@change="selectBatchChange"
@clear="selectBatchClear"
style="width: 60%;"
>
<el-option
v-for="item in batchOptions"
:key="item.id"
:label="item.batch"
:value="item.id"
>
<span style="float: left">{{ item.batch }}</span>
<span
style="
float: right;
color: var(--el-text-color-secondary);
font-size: 13px;
"
>{{ item.count }} -- {{ item.warehouse_name }}</span
>
</el-option>
</el-select>
<scScanner @scanResult="codeTextChange"></scScanner>
<el-input
ref="codeInput"
v-model="codeText"
clearable
placeholder="物料扫码"
style="width:150px;margin-left: 4px;"
@keyup.enter="codeTextChange(codeText)"
></el-input>
</el-form-item>
<template v-if="cate == 'do_out'&&mode == 'add'">
<el-row v-for="item in selectList" :key="item.mb">
<el-col :span="12">
<el-form-item label="批次号">
<el-input v-model="item.batch" disabled />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="仓库" label-width="60px">
<el-select
v-model="item.warehouse"
disabled
style="width: 100%"
>
<el-option
v-for="item in warehouseOptions"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="数量" label-width="60px">
<el-input v-model="item.count" disabled />
</el-form-item>
</el-col>
</el-row>
</template>
<template v-if="cate == 'do_in'&&mode == 'add'">
<el-row v-for="item in selectList" :key="item.mb">
<el-col :span="12">
<el-form-item label="批次号">
<el-input v-model="item.batch" disabled />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="数量" label-width="60px">
<el-input v-model="item.count" disabled />
</el-form-item>
</el-col>
</el-row>
</template>
<el-form-item label="仓库" prop="warehouse" v-if="(cate == 'do_in'&&mode == 'add')||mode == 'edit'" >
<el-select
v-model="form.warehouse"
clearable
style="width: 100%"
>
<el-option
v-for="item in warehouseOptions"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="数量" v-if="mode == 'edit'">
<el-input-number
v-model="form.count"
:min="0"
:precision="0"
style="width: 100%"
/>
</el-form-item>
</template>
<template v-if="cate == 'do_in'&&mode == 'add'">
<el-row v-for="item in selectList" :key="item.mb">
<el-col :span="12">
<el-form-item label="批次号">
<el-input v-model="item.batch" disabled />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="数量" label-width="60px">
<el-input v-model="item.count" disabled />
</el-form-item>
</el-col>
</el-row>
<template v-if="cate=='borrow_out'">
<el-form-item label="物料" prop="material">
<xtSelect
:apiObj="apiObj"
v-model="form.material"
v-model:obj="selectObj"
:labelField="'full_name'"
style="width:100%"
:params="query"
@change="selectMaterialChange2"
>
<el-table-column label="物料" prop="full_name"></el-table-column>
</xtSelect>
</el-form-item>
<el-form-item label="仓库已有批次">
<el-select
v-model="selectBatch"
value-key="id"
clearable
style="width: 100%"
@change="selectBatchChange2"
@clear="selectBatchClear"
>
<el-option
v-for="item in batchOptions"
:key="item.id"
:label="item.batch"
:value="item"
>
<span style="float: left">{{ item.batch }}</span>
<span
style="
float: right;
color: var(--el-text-color-secondary);
font-size: 13px;
"
>{{ item.count }} -- {{ item.warehouse_name }}</span
>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="数量">
<el-input-number
v-model="form.count"
:min="1"
:max="batchcount"
style="width: 100%"
/>
</el-form-item>
</template>
<template v-if="cate=='return_in'">
<el-form-item label="批次号" >
<el-select
v-model="form.batch"
filterable
allow-create
clearable
style="width: 100%"
@clear="selectBatchClear"
@change="selectChange"
>
<el-option
v-for="item in wbatchOptions"
:key="item.id"
:value="item.batch"
>
<span style="float: left">{{item.material_name}} {{ item.batch }}</span>
<span
style="
float: right;
color: var(--el-text-color-secondary);
font-size: 13px;
"
>{{ item.count }}</span
>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="数量">
<el-input-number
v-model="form.count"
:min="0"
:max="batchcount"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="备注">
<el-input v-model="form.note"></el-input>
</el-form-item>
</template>
<el-form-item label="仓库" prop="warehouse" v-if="(cate == 'do_in'&&mode == 'add')||mode == 'edit'" >
<el-select
v-model="form.warehouse"
clearable
style="width: 100%"
>
<el-option
v-for="item in warehouseOptions"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="数量" v-if="mode == 'edit'">
<el-input-number
v-model="form.count"
:min="0"
:precision="0"
style="width: 100%"
/>
</el-form-item>
</el-form>
<template #footer>
<el-button type="primary" :loading="isSaveing" @click="submit">
保存
</el-button>
<el-button v-if="cate == 'do_in'||cate == 'do_out'" type="primary" :loading="isSaveing" @click="submit">保存</el-button>
<el-button v-else type="primary" :loading="isSaveing" @click="submit2">保存</el-button>
<el-button @click="visible = false">取消</el-button>
</template>
</el-dialog>
@ -213,6 +304,8 @@ export default {
titleMap: {
do_out: "生产领料",
do_in: "生产入库",
borrow_out: "领用出库",
return_in: "退还入库",
},
form: {},
rules: {
@ -232,6 +325,9 @@ export default {
selectMaterial: null,
selectBatch: null,
wbatchOptions: [],//
selectObj: {},
query: {},
apiObj:this.$API.mtm.material.list,
};
},
mounted() {
@ -241,7 +337,7 @@ export default {
this.inputBatchDisable = true;
this.getMaterialOptions();
this.getBatchOptions();
}else{//----
}else if(this.cate == 'do_in'||this.cate == 'return_in'){//----
this.getMgroupWmaterial();
}
this.getWarehouseOptions();
@ -249,8 +345,17 @@ export default {
methods: {
//
getWarehouseOptions() {
let that = this;
this.$API.inm.warehouse.list.req({ page: 0 }).then((res) => {
this.warehouseOptions = res;
if(that.cate=='return_in'||that.cate=='borrow_out'){
res.forEach(item => {
if (item.name =="辅料库") {
that.form.warehouse = item.id;
}
})
}
});
},
//
@ -275,10 +380,14 @@ export default {
getMgroupWmaterial() {
let that = this;
let obj = {};
obj.state = 10;
if(that.cate== 'do_in'){
obj.state = 10;
obj.material__process= that.process;
}else if(that.cate== 'return_in'){
obj.material__type = 40;
}
obj.page= 0;
obj.mgroupx= that.mgroupId;
obj.material__process= that.process;
if (that.mgroupId != null &&that.mgroupId != undefined &&that.mgroupId != "") {
that.$API.wpm.wmaterial.list.req(obj).then((res) => {
that.wbatchOptions = res;
@ -358,6 +467,14 @@ export default {
selectMaterialChange() {
this.getBatchOptions();
},
selectMaterialChange2(){
var that = this;
console.log('that.selectObj',that.selectObj.id);
that.form.material = that.selectObj.id;
if(that.selectObj.id!==undefined){
this.getBatchOptions();
}
},
getItem(options, id) {
for (var i = 0; i < options.length; i++) {
if (options[i].id == id) {
@ -367,10 +484,8 @@ export default {
},
selectBatchChange() {
let that = this;
console.log('selectBatch',that.selectBatch);
that.selectList = [];
that.batchOptions.forEach((item) => {
console.log('indexOfselectBatch',that.selectBatch.indexOf(item.id));
if(that.mode == "add"){//
if(that.selectBatch.indexOf(item.id)>-1){
let obj = {};
@ -391,6 +506,33 @@ export default {
}
})
},
//
selectBatchChange2(item) {
let that = this;
if(item){
that.$API.wpm.wpr.list.req({ page: 0, mb: item.id }).then((res) => {
that.wprList = res;
})
that.form.batch = item.batch;
that.form.mb = item.id;
that.batchcount = Number(item.count);
that.form.count = Number(item.count);
that.form.warehouse = item.warehouse;
}
},
//
selectChange(){
let that = this;
that.wbatchOptions.forEach((item) => {
if(that.form.batch == item.batch){
that.form.wm = item.id;
that.form.batch = item.batch;
that.form.count = Number(item.count);
that.batchcount = Number(item.count);
}
})
},
//
selectwmChange(id){
let that = this;
@ -416,6 +558,7 @@ export default {
},
selectBatchClear() {
this.form.batch = "";
this.form.count =0;
this.form.warehouse = "";
},
//
@ -464,6 +607,32 @@ export default {
}
});
},
submit2() {
let that = this;
that.$refs.dialogForm.validate(async (valid) => {
if (valid) {
that.isSaveing = true;
that.form.mio = that.mioId;
try {
let res;
if (that.mode == "add") {
res = await that.$API.inm.mioitem.create.req(that.form);
} else if (that.mode == "edit") {
res = await that.$API.inm.mioitem.update.req(that.form.id,that.form);
}
that.isSaveing = false;
that.$emit("success");
that.visible = false;
that.$message.success("操作成功");
} catch (err) {
console.log(err);
//
that.isSaveing = false;
return err;
}
}
})
},
//
setData(data) {
Object.assign(this.form, data);