fix:原料库->出入库记录->采购入库添加供应商

This commit is contained in:
shijing 2024-03-25 15:31:32 +08:00
parent 9e475887b5
commit 89d70548b9
1 changed files with 289 additions and 196 deletions

View File

@ -1,204 +1,297 @@
<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="编号" prop="number"> v-model="visible"
<el-input v-model="form.number" placeholder="编号" /> :size="1000"
</el-form-item> destroy-on-close
<el-form-item label="出入库日期"> @closed="$emit('closed')"
<el-date-picker v-model="form.inout_date" type="date" placeholder="出入库日期" value-format="YYYY-MM-DD" >
style="width:100%"> <el-form
</el-date-picker> ref="dialogForm"
</el-form-item> :model="form"
<el-form-item label="采购订单" v-if="form.type == 'pur_in'"> :rules="rules"
<el-select v-model="form.pu_order" clearable style="width: 100%;"> label-width="120px"
<el-option v-for="item in puOrderOptions" :key="item.id" :label="item.number" >
:value="item.id"></el-option> <el-form-item label="编号" prop="number">
</el-select> <el-input v-model="form.number" placeholder="编号" />
</el-form-item> </el-form-item>
<el-form-item label="供应商" v-if="form.type == 'other_in'"> <el-form-item label="出入库日期">
<el-select v-model="form.supplier" clearable style="width: 100%;"> <el-date-picker
<el-option v-for="item in supplierOptions" :key="item.id" :label="item.name" v-model="form.inout_date"
:value="item.id"></el-option> type="date"
</el-select> placeholder="出入库日期"
</el-form-item> value-format="YYYY-MM-DD"
<el-form-item label="销售订单" v-if="form.type == 'sale_out'"> style="width: 100%"
<el-select v-model="form.order" clearable style="width: 100%;"> >
<el-option v-for="item in orderOptions" :key="item.id" :label="item.number" </el-date-picker>
:value="item.id"></el-option> </el-form-item>
</el-select> <el-form-item label="采购订单" v-if="form.type == 'pur_in'">
</el-form-item> <el-select
<el-form-item label="客户" v-if="form.type == 'other_out'"> v-model="form.pu_order"
<el-select v-model="form.customer" clearable style="width: 100%;"> clearable
<el-option v-for="item in customerOptions" :key="item.id" :label="item.name" style="width: 100%"
:value="item.id"></el-option> >
</el-select> <el-option
</el-form-item> v-for="item in puOrderOptions"
<el-form-item label="执行车间" v-if="form.type == 'do_in' || form.type == 'do_out'"> :key="item.id"
<el-select v-model="form.belong_dept" clearable style="width: 100%;" @change="deptChange"> :label="item.number"
<el-option v-for="item in deptOptions" :key="item.id" :label="item.name" :value="item.id"></el-option> :value="item.id"
</el-select> ></el-option>
</el-form-item> </el-select>
<el-form-item label="车间执行人" v-if="form.type == 'do_in' || form.type == 'do_out'"> </el-form-item>
<el-select v-model="form.do_user" clearable style="width: 100%;"> <el-form-item
<el-option v-for="item in userOptions" :key="item.id" :label="item.name" :value="item.id"></el-option> label="供应商"
</el-select> v-if="form.type == 'other_in' || form.type == 'pur_in'"
</el-form-item> >
<el-form-item label="仓库执行人" v-if="form.type == 'do_in' || form.type == 'do_out'"> <el-select
<el-select v-model="form.mio_user" clearable style="width: 100%;"> v-model="form.supplier"
<el-option v-for="item in userOption" :key="item.id" :label="item.name" :value="item.id"></el-option> clearable
</el-select> style="width: 100%"
</el-form-item> >
</el-form> <el-option
<template #footer> v-for="item in supplierOptions"
<el-button type="primary" :loading="isSaveing" @click="submit"> :key="item.id"
保存 :label="item.name"
</el-button> :value="item.id"
<el-button @click="dialogVisible = false">取消</el-button> ></el-option>
</template> </el-select>
</el-dialog> </el-form-item>
<el-form-item label="销售订单" v-if="form.type == 'sale_out'">
<el-select v-model="form.order" clearable style="width: 100%">
<el-option
v-for="item in orderOptions"
:key="item.id"
:label="item.number"
:value="item.id"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="客户" v-if="form.type == 'other_out'">
<el-select
v-model="form.customer"
clearable
style="width: 100%"
>
<el-option
v-for="item in customerOptions"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</el-form-item>
<el-form-item
label="执行车间"
v-if="form.type == 'do_in' || form.type == 'do_out'"
>
<el-select
v-model="form.belong_dept"
clearable
style="width: 100%"
@change="deptChange"
>
<el-option
v-for="item in deptOptions"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</el-form-item>
<el-form-item
label="车间执行人"
v-if="form.type == 'do_in' || form.type == 'do_out'"
>
<el-select v-model="form.do_user" clearable style="width: 100%">
<el-option
v-for="item in userOptions"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</el-form-item>
<el-form-item
label="仓库执行人"
v-if="form.type == 'do_in' || form.type == 'do_out'"
>
<el-select
v-model="form.mio_user"
clearable
style="width: 100%"
>
<el-option
v-for="item in userOption"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</el-form-item>
</el-form>
<template #footer>
<el-button type="primary" :loading="isSaveing" @click="submit">
保存
</el-button>
<el-button @click="visible = 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: {},
}, 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: [
material: [{ required: true, message: "请选择所需产品", trigger: "blur" }], {
}, required: true,
visible: false, message: "请选择所需产品",
isSaveing: false, trigger: "blur",
options: [], },
setFiltersVisible: false, ],
deptOptions: [], },
userOptions: [], visible: false,
userOption:[], isSaveing: false,
orderOptions: [], options: [],
puOrderOptions: [], setFiltersVisible: false,
supplierOptions: [], deptOptions: [],
customerOptions: [] userOptions: [],
}; userOption: [],
}, orderOptions: [],
mounted() { puOrderOptions: [],
}, supplierOptions: [],
methods: { customerOptions: [],
init() { };
var type = this.form.type },
if (type == 'pur_in') { mounted() {},
this.getPuOrderOptions() methods: {
} init() {
else if (type == 'sale_out') { var type = this.form.type;
this.getOrderOptions() if (type == "pur_in") {
} this.getPuOrderOptions();
else if (type == 'do_in' || type == 'do_out') { this.getSupplierOptions();
this.getDeptOptions(); } else if (type == "sale_out") {
this.getDeptUser(); this.getOrderOptions();
} } else if (type == "do_in" || type == "do_out") {
else if (type == 'other_in') { this.getDeptOptions();
this.getSupplierOptions() this.getDeptUser();
} } else if (type == "other_in") {
else if (type == 'other_out') { this.getSupplierOptions();
this.getCustomerOptions() } else if (type == "other_out") {
} this.getCustomerOptions();
}, }
getSupplierOptions() { },
this.$API.pum.supplier.list.req({ page: 0 }).then(res => { getSupplierOptions() {
this.supplierOptions = res this.$API.pum.supplier.list.req({ page: 0 }).then((res) => {
}) this.supplierOptions = res;
}, });
getCustomerOptions() { },
this.$API.sam.customer.list.req({ page: 0 }).then(res => { getCustomerOptions() {
this.customerOptions = res this.$API.sam.customer.list.req({ page: 0 }).then((res) => {
}) this.customerOptions = res;
}, });
getDeptOptions() { },
this.$API.system.dept.list.req({ page: 0, type__in: 'dept' }).then((res) => { getDeptOptions() {
this.deptOptions = res this.$API.system.dept.list
}); .req({ page: 0, type__in: "dept" })
}, .then((res) => {
getPuOrderOptions() { this.deptOptions = res;
this.$API.pum.order.list.req({ page: 0, type__in: '20,30' }).then(res => { });
this.puOrderOptions = res },
}) getPuOrderOptions() {
}, this.$API.pum.order.list
getOrderOptions() { .req({ page: 0, type__in: "20,30" })
this.$API.sam.order.list.req({ page: 0, type__in: '20,30' }).then(res => { .then((res) => {
this.orderOptions = res this.puOrderOptions = res;
}) });
}, },
deptChange(val) { getOrderOptions() {
this.$API.system.user.list.req({ depts: val, page: 0 }).then(res => { this.$API.sam.order.list
this.userOptions = res .req({ page: 0, type__in: "20,30" })
}) .then((res) => {
}, this.orderOptions = res;
getDeptUser() { });
this.$API.system.user.list.req({ belong_dept__name: '8车间', page: 0 }).then(res => { },
this.userOption = res; deptChange(val) {
}) this.$API.system.user.list
}, .req({ depts: val, page: 0 })
// .then((res) => {
open(mode = "add", type = "") { this.userOptions = res;
this.mode = mode; });
this.form.type = type; },
if (mode == 'add') { getDeptUser() {
this.init() this.$API.system.user.list
} .req({ belong_dept__name: "8车间", page: 0 })
this.visible = true; .then((res) => {
return this; this.userOption = res;
}, });
// },
submit() { //
this.$refs.dialogForm.validate(async (valid) => { open(mode = "add", type = "") {
if (valid) { this.mode = mode;
this.isSaveing = true; this.form.type = type;
try { if (mode == "add") {
var res; this.init();
if (this.mode == "add") { }
res = await this.$API.inm.mio.create.req(this.form); this.visible = true;
} else if (this.mode == "edit") { return this;
res = await this.$API.inm.mio.update.req(this.form.id, this.form); },
} //
this.isSaveing = false; submit() {
this.$emit("success", this.form, this.mode); this.$refs.dialogForm.validate(async (valid) => {
this.visible = false; if (valid) {
this.$message.success("操作成功"); this.isSaveing = true;
} catch (err) { try {
console.log(err) var res;
// if (this.mode == "add") {
this.isSaveing = false; res = await this.$API.inm.mio.create.req(this.form);
return err; } else if (this.mode == "edit") {
} res = await this.$API.inm.mio.update.req(
} this.form.id,
}); this.form
}, );
// }
setData(data) { this.isSaveing = false;
Object.assign(this.form, data); this.$emit("success", this.form, this.mode);
}, this.visible = false;
// this.$message.success("操作成功");
setFilters(filters) { } catch (err) {
this.selectionFilters = filters; console.log(err);
this.setFiltersVisible = true; //
}, this.isSaveing = false;
}, return err;
}
}
});
},
//
setData(data) {
Object.assign(this.form, data);
},
//
setFilters(filters) {
this.selectionFilters = filters;
this.setFiltersVisible = true;
},
},
}; };
</script> </script>
<style></style> <style></style>