更新
This commit is contained in:
@@ -19,41 +19,25 @@
|
||||
label-position="top"
|
||||
@keyup.enter.native="dataFormSubmit">
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="配方编码" prop="processCode">
|
||||
<el-col :span="8">
|
||||
<el-form-item label="配方规格" prop="processSize">
|
||||
<el-input
|
||||
v-model="dataForm.processCode"
|
||||
v-model="dataForm.processSize"
|
||||
clearable
|
||||
:disabled="isdetail"
|
||||
placeholder="请输入配方编码" />
|
||||
placeholder="请输入配方规格" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="配方名称" prop="processName">
|
||||
<el-col :span="8">
|
||||
<el-form-item label="配方型号" prop="processName">
|
||||
<el-input
|
||||
v-model="dataForm.processName"
|
||||
clearable
|
||||
:disabled="isdetail"
|
||||
placeholder="请输入配方名称" />
|
||||
placeholder="请输入配方型号" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="产品" prop="materialId">
|
||||
<el-select
|
||||
style="width: 100%"
|
||||
v-model="dataForm.materialId"
|
||||
:disabled="isdetail"
|
||||
@change="setMaterial"
|
||||
placeholder="请选择产品">
|
||||
<el-option
|
||||
v-for="item in productArr"
|
||||
:key="item.id"
|
||||
:label="item.materialName"
|
||||
:value="item.id"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-col :span="8">
|
||||
<el-form-item label="配方描述" prop="processDesc">
|
||||
<el-input
|
||||
v-model="dataForm.processDesc"
|
||||
@@ -68,16 +52,20 @@
|
||||
<small-title
|
||||
style="margin: 16px 0; padding-left: 8px"
|
||||
:no-padding="true"
|
||||
v-if="dataForm.id">
|
||||
产品属性列表
|
||||
v-if="dataForm.processName && dataForm.processSize">
|
||||
物料属性列表
|
||||
</small-title>
|
||||
|
||||
<div class="attr-list" v-if="dataForm.id">
|
||||
<div
|
||||
class="attr-list"
|
||||
v-if="dataForm.processName && dataForm.processSize">
|
||||
<base-table
|
||||
:table-props="tableProps"
|
||||
:page="listQuery.pageNo"
|
||||
:limit="listQuery.pageSize"
|
||||
:add-button-show="isdetail ? null : '添加属性'"
|
||||
:add-button-show="
|
||||
productAttributeList.length > 3 || isdetail ? null : '添加属性'
|
||||
"
|
||||
@emitButtonClick="addNew()"
|
||||
:table-data="productAttributeList">
|
||||
<method-btn
|
||||
@@ -112,7 +100,6 @@
|
||||
<product-attr-add
|
||||
v-if="addOrUpdateVisible"
|
||||
ref="addOrUpdate"
|
||||
:process-id="dataForm.id"
|
||||
@refreshDataList="getList" />
|
||||
</el-drawer>
|
||||
</template>
|
||||
@@ -122,9 +109,8 @@ import {
|
||||
updateProcess,
|
||||
createProcess,
|
||||
getProcess,
|
||||
getProcessMaterialPage,
|
||||
deleteProcessMaterial,
|
||||
getProductPage,
|
||||
getProcessDetailPage,
|
||||
deleteProcess,
|
||||
} from '@/api/ssdl/product&recipe';
|
||||
import productAttrAdd from './attr-add';
|
||||
import { parseTime } from '@/filter/code-filter';
|
||||
@@ -146,17 +132,17 @@ const tableProps = [
|
||||
label: '添加时间',
|
||||
filter: parseTime,
|
||||
},
|
||||
{
|
||||
prop: 'equipmentName',
|
||||
label: '设备名称',
|
||||
},
|
||||
{
|
||||
prop: 'materialName',
|
||||
label: '原料名称',
|
||||
label: '物料型号',
|
||||
},
|
||||
{
|
||||
prop: 'quantity',
|
||||
label: '数量',
|
||||
prop: 'material',
|
||||
label: '物料规格',
|
||||
},
|
||||
{
|
||||
prop: 'materialNumber',
|
||||
label: '物料数量',
|
||||
},
|
||||
];
|
||||
|
||||
@@ -171,41 +157,30 @@ export default {
|
||||
productAttributeList: [],
|
||||
dataForm: {
|
||||
id: null,
|
||||
processName: '', // 配方名称
|
||||
processCode: '', // 配方编码
|
||||
processName: '', // 配方型号
|
||||
processSize: '', // 配方规格
|
||||
processDesc: '', // 配方描述
|
||||
materialId: '', // 物料id
|
||||
materialName: '', // 物料名称
|
||||
materialCode: '', // 物料编码
|
||||
},
|
||||
productArr: [],
|
||||
listQuery: {
|
||||
pageSize: 10,
|
||||
pageNo: 1,
|
||||
total: 0,
|
||||
},
|
||||
dataRule: {
|
||||
processCode: [
|
||||
processSize: [
|
||||
{
|
||||
required: true,
|
||||
message: '配方编码不能为空',
|
||||
message: '配方规格不能为空',
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
processName: [
|
||||
{
|
||||
required: true,
|
||||
message: '配方名称不能为空',
|
||||
message: '配方型号不能为空',
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
materialId: [
|
||||
{
|
||||
required: true,
|
||||
message: '物料不能为空',
|
||||
trigger: 'change',
|
||||
},
|
||||
],
|
||||
},
|
||||
isdetail: false,
|
||||
};
|
||||
@@ -217,9 +192,6 @@ export default {
|
||||
},
|
||||
init(id, isdetail) {
|
||||
this.initData();
|
||||
getProductPage({ pageNo: 1, pageSize: 100 }).then((res) => {
|
||||
this.productArr = res.data.list;
|
||||
});
|
||||
this.isdetail = isdetail || false;
|
||||
this.dataForm.id = id || null;
|
||||
this.visible = true;
|
||||
@@ -228,31 +200,26 @@ export default {
|
||||
this.$refs['dataForm'].resetFields();
|
||||
|
||||
if (this.dataForm.id) {
|
||||
// 获取产品详情
|
||||
// 获取物料详情
|
||||
getProcess(id).then((response) => {
|
||||
this.dataForm = response.data;
|
||||
// 获取物料的属性列表
|
||||
this.getList();
|
||||
});
|
||||
// 获取产品的属性列表
|
||||
this.getList();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
setMaterial() {
|
||||
const data = this.productArr.find(
|
||||
(i) => i.id === this.dataForm.materialId
|
||||
);
|
||||
this.dataForm.materialName = data.materialName;
|
||||
this.dataForm.materialCode = data.materialCode;
|
||||
},
|
||||
getList() {
|
||||
// 获取产品的属性列表
|
||||
getProcessMaterialPage({
|
||||
...this.listQuery,
|
||||
productId: this.dataForm.id,
|
||||
// 获取物料的属性列表
|
||||
getProcessDetailPage({
|
||||
processName: this.dataForm.processName,
|
||||
processSize: this.dataForm.processSize,
|
||||
pageSize: 100,
|
||||
pageNo: 1,
|
||||
total: 1,
|
||||
}).then((response) => {
|
||||
this.productAttributeList = response.data.list;
|
||||
this.listQuery.total = response.data.total;
|
||||
this.productAttributeList = response.data;
|
||||
});
|
||||
},
|
||||
handleClick(raw) {
|
||||
@@ -271,7 +238,7 @@ export default {
|
||||
}
|
||||
)
|
||||
.then(() => {
|
||||
deleteProcessMaterial(raw.data.id).then(({ data }) => {
|
||||
deleteProcess(raw.data.id).then(({ data }) => {
|
||||
this.$message({
|
||||
message: '操作成功',
|
||||
type: 'success',
|
||||
@@ -291,31 +258,30 @@ export default {
|
||||
dataFormSubmit() {
|
||||
this.$refs['dataForm'].validate((valid) => {
|
||||
if (valid) {
|
||||
// 修改的提交
|
||||
if (this.dataForm.id) {
|
||||
updateProcess(this.dataForm).then((response) => {
|
||||
this.$modal.msgSuccess('修改成功');
|
||||
this.visible = false;
|
||||
this.$emit('refreshDataList');
|
||||
});
|
||||
if (
|
||||
!this.productAttributeList ||
|
||||
!(this.productAttributeList.length > 0)
|
||||
) {
|
||||
this.$modal.msg('物料属性不能为空');
|
||||
return;
|
||||
}
|
||||
this.productAttributeList.forEach((item) => {
|
||||
item.processName = this.dataForm.processName;
|
||||
item.processSize = this.dataForm.processSize;
|
||||
item.processDesc = this.dataForm.processDesc;
|
||||
});
|
||||
// 修改的提交
|
||||
updateProcess(this.productAttributeList).then((response) => {
|
||||
this.$modal.msgSuccess('提交成功');
|
||||
this.visible = false;
|
||||
this.$emit('refreshDataList');
|
||||
});
|
||||
return;
|
||||
// 添加的提交
|
||||
createProcess(this.dataForm).then((response) => {
|
||||
createProcess(this.productAttributeList).then((response) => {
|
||||
this.$modal.msgSuccess('新增成功');
|
||||
this.$confirm(`是否新增产品属性?`, '系统提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
})
|
||||
.then(() => {
|
||||
this.dataForm.id = response.data;
|
||||
this.addNew();
|
||||
})
|
||||
.catch(() => {
|
||||
this.visible = false;
|
||||
this.$emit('refreshDataList');
|
||||
});
|
||||
this.visible = false;
|
||||
this.$emit('refreshDataList');
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -325,14 +291,10 @@ export default {
|
||||
},
|
||||
// 新增 / 修改
|
||||
addNew(id) {
|
||||
if (this.dataForm.id) {
|
||||
this.addOrUpdateVisible = true;
|
||||
this.$nextTick(() => {
|
||||
this.$refs.addOrUpdate.init(id);
|
||||
});
|
||||
} else {
|
||||
this.$message('请先创建配方!');
|
||||
}
|
||||
this.addOrUpdateVisible = true;
|
||||
this.$nextTick(() => {
|
||||
this.$refs.addOrUpdate.init(id, this.dataForm);
|
||||
});
|
||||
},
|
||||
goback() {
|
||||
this.$emit('refreshDataList');
|
||||
|
||||
Reference in New Issue
Block a user