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