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,51 +1,131 @@
<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]"
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-form-item label="编号" prop="number">
<el-input v-model="form.number" placeholder="编号" /> <el-input v-model="form.number" placeholder="编号" />
</el-form-item> </el-form-item>
<el-form-item label="出入库日期"> <el-form-item label="出入库日期">
<el-date-picker v-model="form.inout_date" type="date" placeholder="出入库日期" value-format="YYYY-MM-DD" <el-date-picker
style="width:100%"> v-model="form.inout_date"
type="date"
placeholder="出入库日期"
value-format="YYYY-MM-DD"
style="width: 100%"
>
</el-date-picker> </el-date-picker>
</el-form-item> </el-form-item>
<el-form-item label="采购订单" v-if="form.type == 'pur_in'"> <el-form-item label="采购订单" v-if="form.type == 'pur_in'">
<el-select v-model="form.pu_order" clearable style="width: 100%;"> <el-select
<el-option v-for="item in puOrderOptions" :key="item.id" :label="item.number" v-model="form.pu_order"
:value="item.id"></el-option> 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-select>
</el-form-item> </el-form-item>
<el-form-item label="供应商" v-if="form.type == 'other_in'"> <el-form-item
<el-select v-model="form.supplier" clearable style="width: 100%;"> label="供应商"
<el-option v-for="item in supplierOptions" :key="item.id" :label="item.name" v-if="form.type == 'other_in' || form.type == 'pur_in'"
:value="item.id"></el-option> >
<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-select>
</el-form-item> </el-form-item>
<el-form-item label="销售订单" v-if="form.type == 'sale_out'"> <el-form-item label="销售订单" v-if="form.type == 'sale_out'">
<el-select v-model="form.order" clearable 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-option
:value="item.id"></el-option> v-for="item in orderOptions"
:key="item.id"
:label="item.number"
:value="item.id"
></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="客户" v-if="form.type == 'other_out'"> <el-form-item label="客户" v-if="form.type == 'other_out'">
<el-select v-model="form.customer" clearable style="width: 100%;"> <el-select
<el-option v-for="item in customerOptions" :key="item.id" :label="item.name" v-model="form.customer"
:value="item.id"></el-option> 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-select>
</el-form-item> </el-form-item>
<el-form-item label="执行车间" v-if="form.type == 'do_in' || form.type == 'do_out'"> <el-form-item
<el-select v-model="form.belong_dept" clearable style="width: 100%;" @change="deptChange"> label="执行车间"
<el-option v-for="item in deptOptions" :key="item.id" :label="item.name" :value="item.id"></el-option> 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-select>
</el-form-item> </el-form-item>
<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%;"> label="车间执行人"
<el-option v-for="item in userOptions" :key="item.id" :label="item.name" :value="item.id"></el-option> 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-select>
</el-form-item> </el-form-item>
<el-form-item label="仓库执行人" v-if="form.type == 'do_in' || form.type == 'do_out'"> <el-form-item
<el-select v-model="form.mio_user" clearable style="width: 100%;"> label="仓库执行人"
<el-option v-for="item in userOption" :key="item.id" :label="item.name" :value="item.id"></el-option> 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-select>
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -53,35 +133,40 @@
<el-button type="primary" :loading="isSaveing" @click="submit"> <el-button type="primary" :loading="isSaveing" @click="submit">
保存 保存
</el-button> </el-button>
<el-button @click="dialogVisible = false">取消</el-button> <el-button @click="visible = false">取消</el-button>
</template> </template>
</el-dialog> </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: [{ required: true, message: "请选择所需产品", trigger: "blur" }], material: [
{
required: true,
message: "请选择所需产品",
trigger: "blur",
},
],
}, },
visible: false, visible: false,
isSaveing: false, isSaveing: false,
@ -89,76 +174,82 @@ export default {
setFiltersVisible: false, setFiltersVisible: false,
deptOptions: [], deptOptions: [],
userOptions: [], userOptions: [],
userOption:[], userOption: [],
orderOptions: [], orderOptions: [],
puOrderOptions: [], puOrderOptions: [],
supplierOptions: [], supplierOptions: [],
customerOptions: [] customerOptions: [],
}; };
}, },
mounted() { mounted() {},
},
methods: { methods: {
init() { init() {
var type = this.form.type var type = this.form.type;
if (type == 'pur_in') { if (type == "pur_in") {
this.getPuOrderOptions() this.getPuOrderOptions();
} this.getSupplierOptions();
else if (type == 'sale_out') { } else if (type == "sale_out") {
this.getOrderOptions() this.getOrderOptions();
} } else if (type == "do_in" || type == "do_out") {
else if (type == 'do_in' || type == 'do_out') {
this.getDeptOptions(); this.getDeptOptions();
this.getDeptUser(); this.getDeptUser();
} } else if (type == "other_in") {
else if (type == 'other_in') { this.getSupplierOptions();
this.getSupplierOptions() } else if (type == "other_out") {
} this.getCustomerOptions();
else if (type == 'other_out') {
this.getCustomerOptions()
} }
}, },
getSupplierOptions() { getSupplierOptions() {
this.$API.pum.supplier.list.req({ page: 0 }).then(res => { this.$API.pum.supplier.list.req({ page: 0 }).then((res) => {
this.supplierOptions = res this.supplierOptions = res;
}) });
}, },
getCustomerOptions() { getCustomerOptions() {
this.$API.sam.customer.list.req({ page: 0 }).then(res => { this.$API.sam.customer.list.req({ page: 0 }).then((res) => {
this.customerOptions = res this.customerOptions = res;
}) });
}, },
getDeptOptions() { getDeptOptions() {
this.$API.system.dept.list.req({ page: 0, type__in: 'dept' }).then((res) => { this.$API.system.dept.list
this.deptOptions = res .req({ page: 0, type__in: "dept" })
.then((res) => {
this.deptOptions = res;
}); });
}, },
getPuOrderOptions() { getPuOrderOptions() {
this.$API.pum.order.list.req({ page: 0, type__in: '20,30' }).then(res => { this.$API.pum.order.list
this.puOrderOptions = res .req({ page: 0, type__in: "20,30" })
}) .then((res) => {
this.puOrderOptions = res;
});
}, },
getOrderOptions() { getOrderOptions() {
this.$API.sam.order.list.req({ page: 0, type__in: '20,30' }).then(res => { this.$API.sam.order.list
this.orderOptions = res .req({ page: 0, type__in: "20,30" })
}) .then((res) => {
this.orderOptions = res;
});
}, },
deptChange(val) { deptChange(val) {
this.$API.system.user.list.req({ depts: val, page: 0 }).then(res => { this.$API.system.user.list
this.userOptions = res .req({ depts: val, page: 0 })
}) .then((res) => {
this.userOptions = res;
});
}, },
getDeptUser() { getDeptUser() {
this.$API.system.user.list.req({ belong_dept__name: '8车间', page: 0 }).then(res => { this.$API.system.user.list
.req({ belong_dept__name: "8车间", page: 0 })
.then((res) => {
this.userOption = res; this.userOption = res;
}) });
}, },
// //
open(mode = "add", type = "") { open(mode = "add", type = "") {
this.mode = mode; this.mode = mode;
this.form.type = type; this.form.type = type;
if (mode == 'add') { if (mode == "add") {
this.init() this.init();
} }
this.visible = true; this.visible = true;
return this; return this;
@ -173,14 +264,17 @@ export default {
if (this.mode == "add") { if (this.mode == "add") {
res = await this.$API.inm.mio.create.req(this.form); res = await this.$API.inm.mio.create.req(this.form);
} else if (this.mode == "edit") { } else if (this.mode == "edit") {
res = await this.$API.inm.mio.update.req(this.form.id, this.form); res = await this.$API.inm.mio.update.req(
this.form.id,
this.form
);
} }
this.isSaveing = false; this.isSaveing = false;
this.$emit("success", this.form, this.mode); this.$emit("success", this.form, this.mode);
this.visible = false; this.visible = false;
this.$message.success("操作成功"); this.$message.success("操作成功");
} catch (err) { } catch (err) {
console.log(err) console.log(err);
// //
this.isSaveing = false; this.isSaveing = false;
return err; return err;
@ -201,4 +295,3 @@ export default {
}; };
</script> </script>
<style></style> <style></style>