update 混料订单编辑里加一个配方

This commit is contained in:
lb
2023-03-27 17:01:11 +08:00
parent d2c0978321
commit 0d8bd350fa
5 changed files with 137 additions and 64 deletions

View File

@@ -31,7 +31,8 @@
:dialog-visible.sync="dialogVisible"
:configs="dialogConfigs"
@refreshDataList="getList"
/>
/>
<!-- :bom-code="dialogBomCode" -->
</div>
</template>
@@ -81,6 +82,7 @@ export default {
dataList: [],
tableLoading: false,
refreshLayoutKey: null,
dialogBomCode: "",
};
},
inject: ["urls"],
@@ -138,7 +140,7 @@ export default {
} else this.dataList = res.data.list;
this.totalPage = res.data.total;
}
}
} else {
this.$message({
message: `${res.code}: ${res.msg}`,
@@ -209,13 +211,13 @@ export default {
this.openDialog(data, true);
break;
}
case 'view-batch': {
case "view-batch": {
this.$router.push({
name: toRouter,
query: {
id: data // 混料订单id
}
})
query: {
id: data, // 混料订单id
},
});
break;
}
case "detach": {
@@ -302,6 +304,11 @@ export default {
openDialog(row_data) {
this.dialogVisible = true;
// if ("bomCode" in row_data) {
// const { bomCode } = row_data;
// this.dialogBomCode = bomCode;
// }
this.$nextTick(() => {
this.$refs["edit-dialog"].init(row_data);
});

View File

@@ -85,7 +85,6 @@
<script>
import { pick as __pick } from "@/utils/filters";
import Cookies from "js-cookie";
import moment from "moment";
export default {
name: "DialogJustForm",
@@ -102,43 +101,58 @@ export default {
type: Boolean,
default: false,
},
// 特殊需求
// bomCode: {
// type: String,
// default: "x",
// },
},
inject: ["urls"],
data() {
const dataForm = {};
const delayList = [];
this.configs.form.rows.forEach((row) => {
row.forEach((col) => {
dataForm[col.prop] = col.default ?? null;
if (col.fetchData)
col.fetchData().then(({ data: res }) => {
if (res.code === 0) {
if ("list" in res.data) {
this.$set(
col,
"options",
res.data.list.map((i) => ({
label: col.optionLabelProp ? i[col.optionLabelProp] : i.name,
value: col.optionValue ? i[col.optionValue] : i.id,
}))
);
} else if (Array.isArray(res.data)) {
this.$set(
col,
"options",
res.data.map((i) => ({
label: col.optionLabelProp ? i[col.optionLabelProp] : i.name,
value: col.optionValue ? i[col.optionValue] : i.id,
}))
);
if (col.fetchData && typeof col.fetchData === "function") {
if (col.delayRequest) delayList.push(col);
// let doRequest = null;
// if (col.fetchData.length) {
// console.log(`this.bomCode '${this.bomCode}'`);
// // 如果有参数
// doRequest = col.fetchData.bind(this.bomCode);
// } else doRequest = col.fetchData;
else
col.fetchData().then(({ data: res }) => {
if (res.code === 0) {
if ("list" in res.data) {
this.$set(
col,
"options",
res.data.list.map((i) => ({
label: col.optionLabelProp ? i[col.optionLabelProp] : i.name,
value: col.optionValue ? i[col.optionValue] : i.id,
}))
);
} else if (Array.isArray(res.data)) {
this.$set(
col,
"options",
res.data.map((i) => ({
label: col.optionLabelProp ? i[col.optionLabelProp] : i.name,
value: col.optionValue ? i[col.optionValue] : i.id,
}))
);
} else {
console.log("请检查返回的数据类型");
}
} else {
console.log("请检查返回的数据类型");
col.options.splice(0);
}
} else {
col.options.splice(0);
}
});
});
}
});
});
return {
@@ -146,6 +160,7 @@ export default {
dataForm,
detailMode: false,
baseDialogConfig: null,
delayList,
};
},
computed: {
@@ -200,18 +215,61 @@ export default {
);
},
init({ id, code, blender }) {
// id 和 混料机 ID 混料订单号
init(row) {
this.loadingStatus = true;
// id 和 混料机 ID 混料订单号 和 配方id
const { id, code, blender, bomId } = row;
// console.log(" { id, code, blender } = row;", row);
if (this.$refs.dataForm) {
this.$refs.dataForm.clearValidate();
}
this.detailMode = false;
this.$nextTick(() => {
this.dataForm.id = id || null;
this.dataForm.blender = blender;
this.dataForm.code = code;
this.delayList.forEach((col) => {
// console.log("delay fetch", col);
// 需要延迟获取异步数据的 col 配置
if (col.fetchDataParam in row) {
// console.log("delay row ", row, row[col.fetchDataParam]);
col.fetchData(row[col.fetchDataParam]).then(({ data: res }) => {
if (res.code === 0) {
if ("list" in res.data) {
this.$set(
col,
"options",
res.data.list.map((i) => ({
label: col.optionLabelProp ? i[col.optionLabelProp] : i.name,
value: col.optionValue ? i[col.optionValue] : i.id,
}))
);
} else if (Array.isArray(res.data)) {
this.$set(
col,
"options",
res.data.map((i) => ({
label: col.optionLabelProp ? i[col.optionLabelProp] : i.name,
value: col.optionValue ? i[col.optionValue] : i.id,
}))
);
} else {
console.log("请检查返回的数据类型");
}
} else {
col.options.splice(0);
}
this.loadingStatus = false;
});
}
});
this.detailMode = false;
this.dataForm.id = id || null;
this.dataForm.blender = blender;
this.dataForm.code = code;
this.dataForm.bomId = bomId;
if (!this.delayList.length) this.loadingStatus = false;
},
/** handlers */
@@ -234,9 +292,10 @@ export default {
if (passed) {
this.loadingStatus = true;
const { id, blender } = this.dataForm
const { id, blender, bomId } = this.dataForm;
return this.$http.get(this.urls.changeBlender, { params: { id, blender } })
return this.$http
.get(this.urls.changeBlender, { params: { id, blender, bomId } })
.then(({ data: res }) => {
this.loadingStatus = false;
if (res.code === 0) {