fix:成品库配棒管显示半成品的规格型号,不要显示物料编号

This commit is contained in:
shijing 2024-03-29 14:16:24 +08:00
parent 2d500e396d
commit bb7b2817e0
1 changed files with 433 additions and 304 deletions

View File

@ -1,314 +1,443 @@
<template> <template>
<el-dialog :title="titleMap[form.type]" v-model="visible" :size="1000" destroy-on-close @closed="$emit('closed')"> <el-dialog
<el-form ref="dialogForm" :model="form" :rules="rules" label-width="120px"> :title="titleMap[form.type]"
<el-form-item label="物料"> v-model="visible"
<el-select v-model="selectMaterial" value-key="id" clearable filterable style="width: 100%" :size="1000"
@change="selectMaterialChange"> destroy-on-close
<el-option v-for="item in materialOptions" :key="item.id" :label="item.full_name" :value="item"> @closed="$emit('closed')"
<span style="float: left">{{ item.full_name }}</span> >
</el-option> <el-form
</el-select> ref="dialogForm"
</el-form-item> :model="form"
<el-form-item label="批次号"> :rules="rules"
<!-- <el-input v-model="form.batch" placeholder="手动输入批次号" :disabled="inputBatchDisable" /> --> label-width="120px"
<el-select v-model="form.batch" filterable allow-create clearable style="width: 100%" >
:disabled="inputBatchDisable"> <el-form-item label="物料">
<el-option v-for="item in wbatchOptions" :key="item.id" :value="item.batch"> <el-select
<span style="float: left">{{ item.batch }}</span> v-model="selectMaterial"
<span style=" value-key="id"
float: right; clearable
color: var(--el-text-color-secondary); filterable
font-size: 13px; style="width: 100%"
">{{ item.count }}</span> @change="selectMaterialChange"
</el-option> >
</el-select> <el-option
</el-form-item> v-for="item in materialOptions"
<el-form-item label="仓库已有批次"> :key="item.id"
<el-select v-model="selectBatch" value-key="id" clearable style="width: 100%" @change="selectBatchChange" :label="item.full_name"
@clear="selectBatchClear" :disabled="selectBatchDisable"> :value="item"
<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: left">{{ item.full_name }}</span>
<span style=" </el-option>
float: right; </el-select>
color: var(--el-text-color-secondary); </el-form-item>
font-size: 13px; <el-form-item label="批次号">
">{{ item.count }} -- {{ item.warehouse_name }}</span> <!-- <el-input v-model="form.batch" placeholder="手动输入批次号" :disabled="inputBatchDisable" /> -->
</el-option> <el-select
</el-select> v-model="form.batch"
</el-form-item> filterable
<el-form-item label="仓库"> allow-create
<el-select v-model="form.warehouse" clearable style="width: 100%" :disabled="warehouseDisable"> clearable
<el-option v-for="item in warehouseOptions" :key="item.id" :label="item.name" :value="item.id"></el-option> style="width: 100%"
</el-select> :disabled="inputBatchDisable"
</el-form-item> >
<el-form-item label="数量"> <el-option
<el-input-number v-model="form.count" :min="1" style="width: 100%" /> v-for="item in wbatchOptions"
</el-form-item> :key="item.id"
<div v-if="assembShow"> :value="item.batch"
<el-row v-for="item in components" v-bind:key="item" style="margin-bottom: 8px"> >
<el-col :span="12"> {{ item.number }} - {{ item.name }} </el-col> <span style="float: left">{{ item.batch }}</span>
<el-col :span="12"> <span
<el-select v-model="item.batch" clearable style="width: 100%"> style="
<el-option v-for="itemx in item.batchOptions" :key="itemx.id" :label="itemx.batch" :value="itemx.batch"> float: right;
<span style="float: left">{{ itemx.batch }}</span> color: var(--el-text-color-secondary);
<span style=" font-size: 13px;
float: right; "
color: var(--el-text-color-secondary); >{{ item.count }}</span
font-size: 13px; >
">{{ itemx.count }}</span> </el-option>
</el-option> </el-select>
</el-select> </el-form-item>
</el-col> <el-form-item label="仓库已有批次">
</el-row> <el-select
</div> v-model="selectBatch"
</el-form> value-key="id"
<template #footer> clearable
<el-button type="primary" :loading="isSaveing" @click="submit"> style="width: 100%"
保存 @change="selectBatchChange"
</el-button> @clear="selectBatchClear"
<el-button @click="dialogVisible = false">取消</el-button> :disabled="selectBatchDisable"
</template> >
</el-dialog> <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-select
v-model="form.warehouse"
clearable
style="width: 100%"
:disabled="warehouseDisable"
>
<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="数量">
<el-input-number
v-model="form.count"
:min="1"
style="width: 100%"
/>
</el-form-item>
<div v-if="assembShow">
<el-row
v-for="item in components"
v-bind:key="item"
style="margin-bottom: 8px"
>
<el-col :span="12" style="padding-left: 120px">
{{ item.name
}}<span v-if="item.model !== null"
>|{{ item.model }}</span
><span v-if="item.specification !== null"
>|{{ item.specification }}</span
>
</el-col>
<el-col :span="12">
<el-select
v-model="item.batch"
clearable
style="width: 100%"
>
<el-option
v-for="itemx in item.batchOptions"
:key="itemx.id"
:label="itemx.batch"
:value="itemx.batch"
>
<span style="float: left">{{
itemx.batch
}}</span>
<span
style="
float: right;
color: var(--el-text-color-secondary);
font-size: 13px;
"
>{{ itemx.count }}</span
>
</el-option>
</el-select>
</el-col>
</el-row>
</div>
</el-form>
<template #footer>
<el-button type="primary" :loading="isSaveing" @click="submit">
保存
</el-button>
<el-button @click="dialogVisible = false">取消</el-button>
</template>
</el-dialog>
</template> </template>
<script> <script>
const defaultForm = { const defaultForm = {
"state": 10, state: 10,
"type": "do_in" type: "do_in",
} };
export default { export default {
emits: ["success", "closed"], emits: ["success", "closed"],
props: { props: {
cate: { type: String, default: '' }, cate: { type: String, default: "" },
mioId: { type: String, default: '' }, mioId: { type: String, default: "" },
belongDeptName: { type: String, default: '' }, belongDeptName: { type: String, default: "" },
belongDeptId: { type: String, default: null }, belongDeptId: { type: String, default: null },
mioObj: { type: Object } mioObj: { type: Object },
}, },
data() { data() {
return { return {
type: 'do_in', type: "do_in",
loading: false, loading: false,
mode: "add", mode: "add",
titleMap: { titleMap: {
'do_out': '生产领料', do_out: "生产领料",
'sale_out': '销售发货', sale_out: "销售发货",
'pur_in': '采购入库', pur_in: "采购入库",
'do_in': '生产入库', do_in: "生产入库",
'other_in': '其他入库', other_in: "其他入库",
'other_out': '其他出库', other_out: "其他出库",
}, },
form: {}, form: {},
rules: { rules: {
material: [{ required: true, message: "请选择所需产品", trigger: "blur" }], material: [
}, {
visible: false, required: true,
isSaveing: false, message: "请选择所需产品",
materialOptions: [], trigger: "blur",
batchOptions: [], },
setFiltersVisible: false, ],
warehouseOptions: [], },
warehouseDisable: false, visible: false,
selectBatchDisable: false, isSaveing: false,
assembShow: false, materialOptions: [],
selectMaterial: null, batchOptions: [],
selectBatch: null, setFiltersVisible: false,
components: [], warehouseOptions: [],
wbatchOptions: [], warehouseDisable: false,
}; selectBatchDisable: false,
}, assembShow: false,
mounted() { selectMaterial: null,
// this.getBatchs(); selectBatch: null,
}, components: [],
methods: { wbatchOptions: [],
init() { };
this.getMaterialOptions() },
this.getWarehouseOptions() mounted() {
}, // this.getBatchs();
getWarehouseOptions() { },
this.$API.inm.warehouse.list.req({ page: 0 }).then(res => { methods: {
this.warehouseOptions = res init() {
}) this.getMaterialOptions();
}, this.getWarehouseOptions();
// },
getWBatchs() { // getWarehouseOptions() {
if (this.belongDeptId != null && this.belongDeptId != undefined && this.belongDeptId != '') { this.$API.inm.warehouse.list.req({ page: 0 }).then((res) => {
this.$API.wpm.wmaterial.list.req({ this.warehouseOptions = res;
"belong_dept": this.belongDeptId, });
"material": this.form.material, },
"page": 0 //
}).then(res => { getWBatchs() {
this.wbatchOptions = res //
}) if (
} this.belongDeptId != null &&
}, this.belongDeptId != undefined &&
getMaterialOptions() { this.belongDeptId != ""
var type = this.form.type; ) {
var cate = this.cate; this.$API.wpm.wmaterial.list
var query = {}; .req({
// 'do_out': '', belong_dept: this.belongDeptId,
// 'sale_out': '', material: this.form.material,
// 'pur_in': '', page: 0,
// 'do_in': '', })
// 'other_in': '', .then((res) => {
// 'other_out': '', this.wbatchOptions = res;
//(10, ''), (20, ''), (30, ''), });
// (40, ''), (50, ''), (60, ''), (70, '') }
let type__in = ''; },
if (cate == 'good') { getMaterialOptions() {
type__in = '10' var type = this.form.type;
} else if (cate == 'halfgood') { var cate = this.cate;
type__in = '20' var query = {};
} else if (cate == 'mainso') { // 'do_out': '',
type__in = '30' // 'sale_out': '',
} else if (cate == 'helpso') { // 'pur_in': '',
type__in = '40, 50, 60, 70' // 'do_in': '',
} // 'other_in': '',
if (type == 'do_out') {//'10, 20, 30' // 'other_out': '',
query = { page: 0, type__in: type__in, is_hidden: false, is_assemb: false }; //(10, ''), (20, ''), (30, ''),
this.inputBatchDisable = true // (40, ''), (50, ''), (60, ''), (70, '')
} let type__in = "";
else if (type == 'do_in') {// if (cate == "good") {
query = { page: 0, type__in: type__in, is_hidden: false } type__in = "10";
this.inputBatchDisable = false; } else if (cate == "halfgood") {
} type__in = "20";
else if (type == 'pur_in') {// } else if (cate == "mainso") {
query = { page: 0, type__in: type__in, is_hidden: false, pu_orderitem_material__pu_order: this.mioObj.pu_order } type__in = "30";
this.inputBatchDisable = false } else if (cate == "helpso") {
} type__in = "40, 50, 60, 70";
else if (type == 'sale_out') {// }
query = { page: 0, type__in: 10, is_hidden: false, orderitem_material__order: this.mioObj.order } if (type == "do_out") {
this.inputBatchDisable = true; //'10, 20, 30'
} query = {
else { page: 0,
query = { page: 0 } type__in: type__in,
} is_hidden: false,
is_assemb: false,
};
this.inputBatchDisable = true;
} else if (type == "do_in") {
//
query = { page: 0, type__in: type__in, is_hidden: false };
this.inputBatchDisable = false;
} else if (type == "pur_in") {
//
query = {
page: 0,
type__in: type__in,
is_hidden: false,
pu_orderitem_material__pu_order: this.mioObj.pu_order,
};
this.inputBatchDisable = false;
} else if (type == "sale_out") {
//
query = {
page: 0,
type__in: 10,
is_hidden: false,
orderitem_material__order: this.mioObj.order,
};
this.inputBatchDisable = true;
} else {
query = { page: 0 };
}
this.$API.mtm.material.list.req(query).then(res => { this.$API.mtm.material.list.req(query).then((res) => {
this.materialOptions = res this.materialOptions = res;
}) });
}, },
async initAssemb(item) { async initAssemb(item) {
this.selectBatchDisable = true this.selectBatchDisable = true;
this.assembShow = true this.assembShow = true;
this.components = [] this.components = [];
var id__in = Object.keys(item.components).join(',') var id__in = Object.keys(item.components).join(",");
if (id__in.length > 0) { if (id__in.length > 0) {
var res = await this.$API.mtm.material.list.req({ page: 0, id__in: id__in }) var res = await this.$API.mtm.material.list.req({
this.components = res page: 0,
for (var i = 0; i < this.components.length; i++) { id__in: id__in,
var res2 = await this.$API.wpm.wmaterial.list.req({ page: 0, material: this.components[i].id, belong_dept: this.belongDeptId }) });
this.components[i].batchOptions = res2 this.components = res;
} for (var i = 0; i < this.components.length; i++) {
} var res2 = await this.$API.wpm.wmaterial.list.req({
}, page: 0,
getBatchOptions() { material: this.components[i].id,
// belong_dept: this.belongDeptId,
this.getWBatchs(); });
this.$API.inm.warehouse.batch.req({ page: 0, material: this.form.material }).then(res => { this.components[i].batchOptions = res2;
this.batchOptions = res }
if (res.length == 0) { }
this.selectBatchDisable = true },
} else { getBatchOptions() {
this.selectBatchDisable = false //
} this.getWBatchs();
}) this.$API.inm.warehouse.batch
}, .req({ page: 0, material: this.form.material })
selectMaterialChange(item) { .then((res) => {
var that = this this.batchOptions = res;
var type = this.form.type if (res.length == 0) {
var material = item.id this.selectBatchDisable = true;
that.form.material = material } else {
this.selectBatchDisable = false;
}
});
},
selectMaterialChange(item) {
var that = this;
var type = this.form.type;
var material = item.id;
that.form.material = material;
if (type == 'do_in') { if (type == "do_in") {
if (item.is_assemb) { if (item.is_assemb) {
this.initAssemb(item) this.initAssemb(item);
} else { } else {
this.selectBatchDisable = false this.selectBatchDisable = false;
this.components = [] this.components = [];
this.assembShow = false this.assembShow = false;
this.getBatchOptions() this.getBatchOptions();
} }
} else {
} this.getBatchOptions();
else { }
this.getBatchOptions() },
} getItem(options, id) {
for (var i = 0; i < options.length; i++) {
if (options[i].id == id) {
}, return options[i];
getItem(options, id) { }
for (var i = 0; i < options.length; i++) { }
if (options[i].id == id) { },
return options[i] selectBatchChange(item) {
} // var item = this.getItem(this.batchOptions, id)
} this.form.batch = item.batch;
}, this.form.warehouse = item.warehouse;
selectBatchChange(item) { this.warehouseDisable = true;
// var item = this.getItem(this.batchOptions, id) this.inputBatchDisable = true;
this.form.batch = item.batch },
this.form.warehouse = item.warehouse selectBatchClear() {
this.warehouseDisable = true this.form.batch = "";
this.inputBatchDisable = true this.form.warehouse = "";
}, this.warehouseDisable = false;
selectBatchClear() { this.inputBatchDisable = false;
this.form.batch = '' },
this.form.warehouse = '' //
this.warehouseDisable = false open(mode = "add", type = "") {
this.inputBatchDisable = false this.mode = mode;
}, this.form.type = type;
// if (mode == "add") {
open(mode = "add", type = "") { this.init();
this.mode = mode; }
this.form.type = type; this.visible = true;
if (mode == 'add') { return this;
this.init() },
} //
this.visible = true; submit() {
return this; this.$refs.dialogForm.validate(async (valid) => {
}, if (valid) {
// this.isSaveing = true;
submit() { this.form.mio = this.mioId;
this.$refs.dialogForm.validate(async (valid) => { if (this.components.length > 0) {
if (valid) { this.form.assemb = [];
this.isSaveing = true; for (var i = 0; i < this.components.length; i++) {
this.form.mio = this.mioId; this.form.assemb.push({
if (this.components.length > 0) { material: this.components[i].id,
this.form.assemb = [] batch: this.components[i].batch,
for (var i = 0; i < this.components.length; i++) { });
this.form.assemb.push({ 'material': this.components[i].id, 'batch': this.components[i].batch }) }
} }
} try {
try { var res;
var res; if (this.mode == "add") {
if (this.mode == "add") { res = await this.$API.inm.mioitem.create.req(
res = await this.$API.inm.mioitem.create.req(this.form); this.form
} else if (this.mode == "edit") { );
res = await this.$API.inm.mioitem.update.req(this.form.id, this.form); } else if (this.mode == "edit") {
} res = await this.$API.inm.mioitem.update.req(
this.isSaveing = false; this.form.id,
this.$emit("success", this.form, this.mode); this.form
this.visible = false; );
this.$message.success("操作成功"); }
} catch (err) { this.isSaveing = false;
console.log(err) this.$emit("success", this.form, this.mode);
// this.visible = false;
this.isSaveing = false; this.$message.success("操作成功");
return err; } catch (err) {
} console.log(err);
} //
}); this.isSaveing = false;
}, return err;
// }
setData(data) { }
Object.assign(this.form, data); });
}, },
// //
setFilters(filters) { setData(data) {
this.selectionFilters = filters; Object.assign(this.form, data);
this.setFiltersVisible = true; },
}, //
}, setFilters(filters) {
this.selectionFilters = filters;
this.setFiltersVisible = true;
},
},
}; };
</script> </script>
<style></style> <style></style>