2023-11-10 17:02:52 +08:00
|
|
|
<!--
|
|
|
|
* @Author: zhp
|
|
|
|
* @Date: 2023-11-08 15:30:27
|
2023-11-23 14:32:53 +08:00
|
|
|
* @LastEditTime: 2023-11-23 14:27:59
|
2023-11-10 17:02:52 +08:00
|
|
|
* @LastEditors: zhp
|
|
|
|
* @Description:
|
|
|
|
-->
|
|
|
|
<template>
|
|
|
|
<el-dialog :visible.sync="visible" :width="'35%'" :append-to-body="true" :close-on-click-modal="false" class="dialog">
|
|
|
|
<template #title>
|
|
|
|
<slot name="title">
|
|
|
|
<div class="titleStyle">
|
|
|
|
{{ !dataForm.id ? '新增' : '编辑' }}
|
|
|
|
</div>
|
|
|
|
</slot>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<el-form ref="dataForm" :model="dataForm" :rules="dataRule" label-width="100px"
|
|
|
|
@keyup.enter.native="dataFormSubmit()">
|
|
|
|
<el-form-item label="物料名称" prop="materialId">
|
2023-11-23 14:32:53 +08:00
|
|
|
<el-select v-model="dataForm.materialId" filterable placeholder="请选择物料名称" multiple>
|
2023-11-10 17:02:52 +08:00
|
|
|
<el-option v-for="dict in materialList" :key=" dict.id" :label="dict.name" :value="dict.id" />
|
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item label="数量" prop="num">
|
|
|
|
<el-input v-model="dataForm.num" placeholder="请输入数量" clearable />
|
|
|
|
</el-form-item>
|
2023-11-23 14:32:53 +08:00
|
|
|
<el-form-item label="备注" prop="remark">
|
|
|
|
<el-input v-model="dataForm.remark" placeholder="请输入备注" clearable />
|
|
|
|
</el-form-item>
|
2023-11-10 17:02:52 +08:00
|
|
|
</el-form>
|
|
|
|
|
|
|
|
<el-row style="text-align: right">
|
|
|
|
<el-button @click="visible = false">取消</el-button>
|
|
|
|
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
|
|
|
|
</el-row>
|
|
|
|
</el-dialog>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import {
|
|
|
|
getProcessEquMaterialBomDet,
|
2023-11-23 14:32:53 +08:00
|
|
|
createProcessEquMaterialBomDetList,
|
2023-11-10 17:02:52 +08:00
|
|
|
updateProcessEquMaterialBomDet,
|
|
|
|
getMaterialList
|
|
|
|
} from '@/api/extend/processEquMaterialBom';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
productId: {
|
|
|
|
type: String,
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
visible: false,
|
|
|
|
materialList:[],
|
|
|
|
dataForm: {
|
|
|
|
id: undefined,
|
|
|
|
bomId: undefined,
|
2023-11-23 14:32:53 +08:00
|
|
|
materialId:[],
|
2023-11-10 17:02:52 +08:00
|
|
|
num: undefined,
|
2023-11-23 14:32:53 +08:00
|
|
|
remark:undefined
|
2023-11-10 17:02:52 +08:00
|
|
|
},
|
|
|
|
dataRule: {
|
2023-11-23 14:32:53 +08:00
|
|
|
materialId: [{ required: true, message: '名称不能为空', trigger: 'change' }],
|
|
|
|
num: [{ required: true, message: '数量不能为空', trigger: 'blur' }],
|
2023-11-10 17:02:52 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted () {
|
|
|
|
this.getDict();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
init(id,bomId) {
|
|
|
|
this.dataForm.id = id || '';
|
|
|
|
this.dataForm.bomId = bomId || '';
|
|
|
|
console.log(bomId);
|
|
|
|
this.visible = true;
|
|
|
|
this.$nextTick(() => {
|
|
|
|
this.$refs['dataForm'].resetFields();
|
|
|
|
if (this.dataForm.id) {
|
|
|
|
getProcessEquMaterialBomDet({
|
|
|
|
id: this.dataForm.id
|
|
|
|
}).then((res) => {
|
2023-11-23 14:32:53 +08:00
|
|
|
this.dataForm = res.data
|
|
|
|
const arr = []
|
|
|
|
arr.push(res.data.materialId)
|
|
|
|
this.dataForm.materialId =arr
|
|
|
|
console.log(this.dataForm.materialId);
|
2023-11-10 17:02:52 +08:00
|
|
|
// this.dataForm.value = value;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
getDict() {
|
|
|
|
getMaterialList().then((res) => [
|
|
|
|
this.materialList = res.data,
|
|
|
|
console.log(res)
|
|
|
|
])
|
|
|
|
},
|
|
|
|
// 表单提交
|
|
|
|
dataFormSubmit() {
|
|
|
|
this.$refs['dataForm'].validate((valid) => {
|
|
|
|
if (valid) {
|
|
|
|
// 修改的提交
|
2023-11-23 14:32:53 +08:00
|
|
|
if (this.dataForm.id) {
|
|
|
|
const dataObj = {
|
|
|
|
materialId: this.dataForm.materialId.toString(),
|
|
|
|
bomId: this.dataForm.bomId,
|
|
|
|
num: this.dataForm.num,
|
|
|
|
id: this.dataForm.id,
|
|
|
|
remark: this.dataForm.remark
|
|
|
|
}
|
2023-11-10 17:02:52 +08:00
|
|
|
updateProcessEquMaterialBomDet({
|
2023-11-23 14:32:53 +08:00
|
|
|
...dataObj
|
2023-11-10 17:02:52 +08:00
|
|
|
}).then((response) => {
|
|
|
|
this.$modal.msgSuccess('修改成功');
|
|
|
|
this.visible = false;
|
|
|
|
this.$emit('refreshDataList');
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
2023-11-23 14:32:53 +08:00
|
|
|
// 添加的提交
|
|
|
|
const dataArr = this.dataForm.materialId.map(ele => {
|
|
|
|
return {
|
|
|
|
materialId: ele,
|
|
|
|
bomId: this.dataForm.bomId,
|
|
|
|
num: this.dataForm.num,
|
|
|
|
remark: this.dataForm.remark
|
|
|
|
}
|
|
|
|
});
|
|
|
|
createProcessEquMaterialBomDetList(dataArr).then((response) => {
|
2023-11-10 17:02:52 +08:00
|
|
|
this.$modal.msgSuccess('新增成功');
|
|
|
|
this.visible = false;
|
|
|
|
this.$emit('refreshDataList');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.dialog >>> .el-dialog__body {
|
|
|
|
padding: 30px 24px;
|
|
|
|
}
|
|
|
|
.dialog >>> .el-dialog__header {
|
|
|
|
font-size: 16px;
|
|
|
|
color: rgba(0, 0, 0, 0.85);
|
|
|
|
font-weight: 500;
|
|
|
|
padding: 13px 24px;
|
|
|
|
border-bottom: 1px solid #e9e9e9;
|
|
|
|
}
|
|
|
|
.dialog >>> .el-dialog__header .titleStyle::before {
|
|
|
|
content: '';
|
|
|
|
display: inline-block;
|
|
|
|
width: 4px;
|
|
|
|
height: 16px;
|
|
|
|
background-color: #0b58ff;
|
|
|
|
border-radius: 1px;
|
|
|
|
margin-right: 8px;
|
|
|
|
position: relative;
|
|
|
|
top: 2px;
|
|
|
|
}
|
|
|
|
</style>
|