fix:coding#656form表单

This commit is contained in:
shijing 2024-11-29 17:43:00 +08:00
parent 5b676f7c4b
commit 3e3c34e49f
1 changed files with 100 additions and 58 deletions

View File

@ -3,28 +3,44 @@
@closed="$emit('closed')"> @closed="$emit('closed')">
<el-form ref="dialogForm" :model="form" :rules="rules" label-width="80px"> <el-form ref="dialogForm" :model="form" :rules="rules" label-width="80px">
<el-row> <el-row>
<el-col :md="12" :sm="24"> <el-col>
<el-form-item label="交接物料" prop="material"> <el-form-item label="交接物料" prop="wm">
<el-select v-model="form.wm" placeholder="交接物料" clearable style="width:100%" <el-select
@change="materialChange"> v-model="formWm"
<el-option v-for="item in materialOptions" :key="item.id" :label="item.batch" placeholder="交接物料"
:value="item.id"></el-option> clearable
value-key="id"
style="width:100%"
:disabled="mode == 'edit'"
@change="materialChange"
>
<el-option
v-for="item in materialOptions"
:key="item.id"
:label="item.material_name + '---' + item.batch"
:value="item"
>
<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-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :md="12" :sm="24"> <el-col :md="12" :sm="24">
<el-form-item label="交接数量" width="100"> <el-form-item label="交送日期">
<el-input-number v-model="form.count" controls-position="right" :min="0" step="1" <el-date-picker v-model="form.send_date" type="date" placeholder="选择时间" format="YYYY-MM-DD"
:step-strictly="true" style="width:100%" placeholder="交接数量"> value-format="YYYY-MM-DD" style="width:100%" />
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="送料部门" prop="send_dept">
<el-select v-model="form.send_dept" placeholder="送料部门" clearable style="width:100%">
<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>
</el-col> </el-col>
<el-col :md="12" :sm="24"> <el-col :md="12" :sm="24">
@ -36,7 +52,7 @@
</el-col> </el-col>
<el-col :md="12" :sm="24"> <el-col :md="12" :sm="24">
<el-form-item label="接收部门" prop="recive_dept"> <el-form-item label="接收部门" prop="recive_dept">
<el-select v-model="form.recive_dept" placeholder="接收部门" clearable style="width:100%"> <el-select v-model="form.recive_dept" placeholder="接收部门" @change="reciveDeptChange" clearable style="width:100%">
<el-option v-for="item in deptOptions" :key="item.id" :label="item.name" <el-option v-for="item in deptOptions" :key="item.id" :label="item.name"
:value="item.id"></el-option> :value="item.id"></el-option>
</el-select> </el-select>
@ -50,9 +66,10 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :md="12" :sm="24"> <el-col :md="12" :sm="24">
<el-form-item label="交送日期"> <el-form-item label="交接数量" width="100">
<el-date-picker v-model="form.send_date" type="date" placeholder="选择时间" format="YYYY-MM-DD" <el-input-number v-model="form.count" controls-position="right" :min="0" step="1"
value-format="YYYY-MM-DD" style="width:100%" /> :step-strictly="true" style="width:100%" placeholder="交接数量">
</el-input-number>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
@ -66,6 +83,11 @@
<script> <script>
export default { export default {
emits: ["success", "closed"], emits: ["success", "closed"],
props: {
mgroup: { type: String, default: "" },
type: { type: String, default: "" },
dept: { type: String, default: "" }
},
data() { data() {
return { return {
yseorno: ['是', '否'], yseorno: ['是', '否'],
@ -78,15 +100,19 @@ export default {
}, },
handle_user: [], handle_user: [],
form: { form: {
batch: '',
count: 0,//
wm: '', wm: '',
batch: '',
count: 0, //
send_user: '', send_user: '',
send_dept: '', send_dept: '',
send_date: '', send_date: '',
send_mgroup:'',
recive_dept: '', recive_dept: '',
recive_user: '', recive_user: '',
count_eweight : 0 ,//
// handoverb:[],
}, },
formWm:null,
userList: [], userList: [],
userList2: [], userList2: [],
deptOptions: [], deptOptions: [],
@ -97,39 +123,42 @@ export default {
}; };
}, },
mounted() { mounted() {
let materialObj = this.$TOOL.data.get('MATERIAL_OBJECT'); let that = this;
this.materialObj = materialObj;
this.getDeptOptions();
this.getMaterial();
this.getUserList();
let date = new Date(); let date = new Date();
let year = date.getFullYear(); let year = date.getFullYear();
let month = date.getMonth() + 1; let month = date.getMonth() + 1;
let day = date.getDate(); let day = date.getDate();
this.form.handle_date = year + '-' + month + '-' + day; that.form.handle_date = that.$TOOL.dateFormat2(date);
let materialObj = that.$TOOL.data.get('MATERIAL_OBJECT');
that.materialObj = materialObj;
that.getDeptOptions();//
that.getMaterial();//
that.getUserList();//
that.form.send_dept = that.dept;
}, },
methods: { methods: {
//68 //
getUserList() { getUserList() {
let that = this; let that = this;
this.$API.system.user.list.req({ belong_dept__name: '6车间', page: 0 }).then(res => { that.$API.system.user.list.req({ belong_dept: that.dept, page: 0 }).then(res => {
that.userList2 = res;
});
this.$API.system.user.list.req({ belong_dept__name: '8车间', page: 0 }).then(res => {
that.userList = res; that.userList = res;
}); });
}, },
// //
getDeptOptions() { getDeptOptions() {
this.$API.system.dept.list.req({ page: 0, type__in: 'dept' }).then((res) => { let that = this;
this.deptOptions = res; that.$API.system.dept.list.req({ page: 0, type__in: 'dept' }).then((res) => {
that.deptOptions = res;
}); });
}, },
// //
getMaterial() { getMaterial() {
let that = this; let that = this;
this.$API.wpm.wmaterial.list.req({ belong_dept_name: '8车间', page: 0 }).then(res => { let obj = {};
obj.belong_dept = that.dept;
obj.page = 0;
obj.count__gte = 1;
that.$API.wpm.wmaterial.list.req(obj).then(res => {
that.materialOptions = res; that.materialOptions = res;
}); });
}, },
@ -149,36 +178,49 @@ export default {
this.visible = true; this.visible = true;
return this; return this;
}, },
//
reciveDeptChange(){
let that = this;
that.$API.system.user.list.req({ belong_dept:that.form.recive_dept, page: 0 }).then(res => {
that.userList2 = res;
});
},
materialChange(val) { materialChange(val) {
let data = this.materialOptions.filter(item => { // let obj = new Object();
return item.id == val; // obj.wm = val.id;
}) // obj.count = val.count;
this.form.batch = data[0].batch; // this.form.handoverb.push(obj);
this.form.wm = val.id;
this.form.count = val.count;
this.form.batch = val.batch;
this.form.material = val.material;
// this.form.count_eweight = val.count_eweight;
}, },
// //
submit() { submit() {
this.$refs.dialogForm.validate(async (valid) => { let that = this;
that.$refs.dialogForm.validate(async (valid) => {
if (valid) { if (valid) {
if (this.mode == "add") { if (that.mode == "add") {
this.$API.wpm.handover.create.req(this.form).then(res => { that.$API.wpm.handover.create.req(that.form).then(res => {
this.isSaveing = false; that.isSaveing = false;
this.$emit("success", this.form, this.mode); that.$emit("success", that.form, that.mode);
this.visible = false; that.visible = false;
this.$message.success("操作成功"); that.$message.success("操作成功");
}).catch((err) => { }).catch((err) => {
// //
this.isSaveing = false; that.isSaveing = false;
return err; return err;
}) })
} else if (this.mode == "edit") { } else if (that.mode == "edit") {
this.$API.wpm.handover.update.req(this.form.id, this.form).then(res => { that.$API.wpm.handover.update.req(that.form.id, that.form).then(res => {
this.isSaveing = false; that.isSaveing = false;
this.$emit("success", this.form, this.mode); that.$emit("success", that.form, that.mode);
this.visible = false; that.visible = false;
this.$message.success("操作成功"); that.$message.success("操作成功");
}).catch((err) => { }).catch((err) => {
// //
this.isSaveing = false; that.isSaveing = false;
return err; return err;
}) })
} }