update 订单详情
This commit is contained in:
parent
b62db4d40c
commit
422560c6ef
24
src/components/noTemplateComponents/textOnlyComponent.js
Normal file
24
src/components/noTemplateComponents/textOnlyComponent.js
Normal file
@ -0,0 +1,24 @@
|
||||
export default {
|
||||
props: {
|
||||
modelValue: {
|
||||
type: String | Number,
|
||||
required: true,
|
||||
},
|
||||
useBuiltin: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
orderStatusMap: ["等待", "确认", "生产", "暂停", "结束", "接受", "拒绝"],
|
||||
};
|
||||
},
|
||||
render: function (h) {
|
||||
return h(
|
||||
"span",
|
||||
{ style: { display: "block", marginTop: "0" } },
|
||||
this.useBuiltin ? this.orderStatusMap[this.modelValue] ?? "-" : this.modelValue.toString().trim() === "" ? "-" : this.modelValue.toString()
|
||||
);
|
||||
},
|
||||
};
|
@ -19,17 +19,13 @@
|
||||
<TrayDetail />
|
||||
</el-tab-pane>
|
||||
<el-tab-pane name="order" label="订单详情">
|
||||
<OrderDetail />
|
||||
<OrderDetail :configs="configs" />
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { pick as __pick } from "@/utils/filters";
|
||||
import Cookies from "js-cookie";
|
||||
import moment from "moment";
|
||||
|
||||
import CarDetail from "./tabs/carDetail.vue";
|
||||
import OrderDetail from "./tabs/orderDetail.vue";
|
||||
import SubOrderDetail from "./tabs/subOrderDetail.vue";
|
||||
@ -50,309 +46,40 @@ export default {
|
||||
},
|
||||
inject: ["urls"],
|
||||
data() {
|
||||
const dataForm = {};
|
||||
const watchList = [];
|
||||
const cachedList = {};
|
||||
|
||||
this.configs.form.rows.forEach((row) => {
|
||||
row.forEach((col) => {
|
||||
dataForm[col.prop] = col.default ?? null;
|
||||
|
||||
if (col.fetchData)
|
||||
col.fetchData().then(({ data: res }) => {
|
||||
// console.log("[DialogJustForm fetchData -->]", res.data.list);
|
||||
if (res.code === 0 && res.data.list) {
|
||||
if ("injectTo" in col) {
|
||||
// 保存完整的数据列表
|
||||
cachedList[col.prop] = res.data.list;
|
||||
}
|
||||
|
||||
this.$set(
|
||||
col,
|
||||
"options",
|
||||
res.data.list.map((i) => ({
|
||||
label: col.optionLabel ? i[col.optionLabel] : i.name,
|
||||
value: col.optionValue ? i[col.optionValue] : i.id,
|
||||
}))
|
||||
);
|
||||
// col.options = res.data.list;
|
||||
} else {
|
||||
col.options.splice(0);
|
||||
}
|
||||
// dataForm[col.prop] = col.default ?? null; // not perfect!
|
||||
});
|
||||
else if (col.fetchTreeData) {
|
||||
// 获取设备类型时触发的,用于前端构建属性结构,约定,parentId 为0时是顶级节点
|
||||
col.fetchTreeData().then(({ data: res }) => {
|
||||
// console.log("[DialogJustForm fetchTreeData -->]", res.data);
|
||||
if (res.code === 0 && res.data) {
|
||||
if ("list" in res.data) {
|
||||
this.$set(col, "options", res.data.list);
|
||||
} else if (Array.isArray(res.data)) {
|
||||
this.$set(col, "options", res.data);
|
||||
}
|
||||
} else {
|
||||
col.options.splice(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
return {
|
||||
loadingStatus: false,
|
||||
dataForm,
|
||||
watchList,
|
||||
cachedList,
|
||||
detailMode: false,
|
||||
baseDialogConfig: null,
|
||||
visible: false,
|
||||
activeTab: "sub",
|
||||
orderId: null,
|
||||
orderSubId: null,
|
||||
carLayoutKey: 0
|
||||
carLayoutKey: 0,
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
/** 处理 injectTo 选项 */
|
||||
// this.configs.form.rows.forEach((row) => {
|
||||
// row.forEach((col) => {
|
||||
// if ("injectTo" in col && Array.isArray(col.injectTo)) {
|
||||
// // console.log("watching options ..... ", col);
|
||||
// col.injectTo.map((item) => {
|
||||
// const unwatch = this.$watch(
|
||||
// () => this.dataForm[col.prop],
|
||||
// (newVal) => {
|
||||
// const chosenObject = this.cachedList[col.prop].find((i) => i.id === newVal);
|
||||
// if (chosenObject) {
|
||||
// // 如果找到了
|
||||
// this.$set(this.dataForm, item[0], chosenObject[item[1]]);
|
||||
// }
|
||||
// },
|
||||
// {
|
||||
// immediate: false,
|
||||
// }
|
||||
// );
|
||||
// this.watchList.push(unwatch);
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
},
|
||||
|
||||
methods: {
|
||||
handleTabClick(tab, event) {
|
||||
console.log('handle tab click', tab, event)
|
||||
console.log("handle tab click", tab, event);
|
||||
// tab.getAList(this.orderId)
|
||||
switch (tab.label) {
|
||||
case "子订单进度": break;
|
||||
case "窑车详情": this.carLayoutKey = Math.random(); break;
|
||||
case "托盘详情": break;
|
||||
case "订单详情": break;
|
||||
case "子订单进度":
|
||||
break;
|
||||
case "窑车详情":
|
||||
this.carLayoutKey = Math.random();
|
||||
break;
|
||||
case "托盘详情":
|
||||
break;
|
||||
case "订单详情":
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
/** utitilities */
|
||||
showButton(operate) {
|
||||
const notDetailMode = !this.detailMode;
|
||||
const showAlways = operate.showAlways ?? false;
|
||||
const editMode = operate.showOnEdit && this.dataForm.id;
|
||||
const addMode = !operate.showOnEdit && !this.dataForm.id;
|
||||
const permission = operate.permission ? this.$hasPermission(operate.permission) : true;
|
||||
return notDetailMode && (showAlways || ((editMode || addMode) && permission));
|
||||
},
|
||||
|
||||
resetForm(excludeId = false, immediate = false) {
|
||||
setTimeout(
|
||||
() => {
|
||||
Object.keys(this.dataForm).forEach((key) => {
|
||||
if (excludeId && key === "id") return;
|
||||
this.dataForm[key] = null;
|
||||
});
|
||||
// console.log("[DialogJustForm resetForm()] clearing form...");
|
||||
this.$refs.dataForm.clearValidate();
|
||||
this.$emit("dialog-closed"); // 触发父组件销毁自己
|
||||
this.watchList.map((unwatch) => unwatch());
|
||||
this.cachedList = {};
|
||||
},
|
||||
immediate ? 0 : 200
|
||||
);
|
||||
},
|
||||
|
||||
/** init **/
|
||||
init(order, detailMode) {
|
||||
this.orderId = order.id;
|
||||
console.log("init menu dialog,", order);
|
||||
this.visible = true;
|
||||
// if (this.$refs.dataForm) {
|
||||
// this.$refs.dataForm.clearValidate();
|
||||
// }
|
||||
|
||||
this.detailMode = detailMode ?? false;
|
||||
this.$nextTick(() => {
|
||||
// this.dataForm.id = id || null;
|
||||
if (this.dataForm.id) {
|
||||
// 如果是编辑
|
||||
this.loadingStatus = true;
|
||||
|
||||
// 获取基本信息
|
||||
this.$http
|
||||
.get(this.urls.base + `/${this.dataForm.id}`)
|
||||
.then(({ data: res }) => {
|
||||
if (res && res.code === 0) {
|
||||
this.dataForm = __pick(res.data, Object.keys(this.dataForm));
|
||||
/** 格式化文件上传列表 */
|
||||
if (Array.isArray(this.dataForm.files)) {
|
||||
this.dataForm.files = this.dataForm.files.map((file) => ({
|
||||
id: file.id,
|
||||
name: file.fileUrl.split("/").pop(),
|
||||
typeCode: file.typeCode,
|
||||
url: file.fileUrl,
|
||||
}));
|
||||
}
|
||||
// console.log("[DialogJustForm] init():", this.dataForm);
|
||||
} else {
|
||||
this.$message({
|
||||
message: `${res.code}: ${res.msg}`,
|
||||
type: "error",
|
||||
duration: 1500,
|
||||
});
|
||||
}
|
||||
this.loadingStatus = false;
|
||||
})
|
||||
.catch((err) => {
|
||||
this.loadingStatus = false;
|
||||
this.$message({
|
||||
message: `${err}`,
|
||||
type: "error",
|
||||
duration: 1500,
|
||||
});
|
||||
});
|
||||
} else {
|
||||
// 如果不是编辑
|
||||
this.loadingStatus = false;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/** handlers */
|
||||
handleSelectChange(col, eventValue) {
|
||||
// console.log("[dialog] select change: ", col, eventValue);
|
||||
this.$forceUpdate();
|
||||
},
|
||||
|
||||
handleSwitchChange(val) {
|
||||
// console.log("[dialog] switch change: ", val, this.dataForm);
|
||||
},
|
||||
|
||||
handleComponentModelUpdate(propName, { subject, payload: { data } }) {
|
||||
this.dataForm[propName] = JSON.stringify(data);
|
||||
// console.log("[DialogJustForm] handleComponentModelUpdate", this.dataForm[propName]);
|
||||
},
|
||||
|
||||
addOrUpdate(method = "POST") {
|
||||
if ("parentId" in this.dataForm) {
|
||||
// console.log("[DialogJustForm parentId]", this.dataForm.parentId);
|
||||
// 对特殊的键做特殊处理,如 parentId 是一个 cascader,获取的值是 ["xxx"],后端只需要xxx
|
||||
const lastItem = this.dataForm.parentId.length - 1;
|
||||
this.dataForm.parentId = this.dataForm.parentId[lastItem];
|
||||
}
|
||||
|
||||
this.$refs.dataForm.validate((passed, result) => {
|
||||
if (passed) {
|
||||
this.loadingStatus = true;
|
||||
|
||||
let httpPayload = null;
|
||||
/** 针对有文件上传选项的弹窗提供特殊的 payload */
|
||||
if (this.dataForm.files) {
|
||||
httpPayload = {
|
||||
...this.dataForm,
|
||||
fileIds: this.dataForm.files.map((file) => file.id),
|
||||
};
|
||||
} else {
|
||||
httpPayload = this.dataForm;
|
||||
}
|
||||
|
||||
/** 针对时间段设置 payload */
|
||||
if ("startTime" in this.dataForm && "endTime" in this.dataForm) {
|
||||
const { startTime, endTime } = this.dataForm;
|
||||
httpPayload = {
|
||||
...httpPayload,
|
||||
startTime: startTime ? moment(startTime).format("YYYY-MM-DDTHH:mm:ss") : moment().format("YYYY-MM-DDTHH:mm:ss"),
|
||||
endTime: endTime ? moment(endTime).format("YYYY-MM-DDTHH:mm:ss") : moment().format("YYYY-MM-DDTHH:mm:ss"),
|
||||
};
|
||||
}
|
||||
|
||||
// /** 针对时间段设置 payload */
|
||||
// if ("updateTime" in this.dataForm) {
|
||||
// const { updateTime } = this.dataForm;
|
||||
// httpPayload = {
|
||||
// ...httpPayload,
|
||||
// updateTime: updateTime ? moment(updateTime).format("YYYY-MM-DDTHH:mm:ss") : moment().format("YYYY-MM-DDTHH:mm:ss"),
|
||||
// };
|
||||
// }
|
||||
/** 针对时间段设置 payload */
|
||||
if ("deliveryTime" in this.dataForm) {
|
||||
const { deliveryTime } = this.dataForm;
|
||||
httpPayload = {
|
||||
...httpPayload,
|
||||
deliveryTime: deliveryTime ? moment(deliveryTime).format("YYYY-MM-DDTHH:mm:ss") : null,
|
||||
};
|
||||
}
|
||||
|
||||
/** 发送 */
|
||||
return this.$http({
|
||||
url: this.urls.base,
|
||||
method,
|
||||
data: httpPayload,
|
||||
})
|
||||
.then(({ data: res }) => {
|
||||
// console.log("[add&update] res is: ", res);
|
||||
this.loadingStatus = false;
|
||||
if (res.code === 0) {
|
||||
this.$message.success(method === "POST" ? "添加成功" : "更新成功");
|
||||
this.$emit("refreshDataList");
|
||||
if (method === "POST") this.handleClose();
|
||||
} else {
|
||||
this.$message({
|
||||
message: `${res.code}: ${res.msg}`,
|
||||
type: "error",
|
||||
duration: 2000,
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((errMsg) => {
|
||||
this.$message.error("参数错误:" + errMsg);
|
||||
if (this.loadingStatus) this.loadingStatus = false;
|
||||
});
|
||||
} else {
|
||||
this.$message.error("请核查字段信息");
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
handleBtnClick(payload) {
|
||||
// console.log("btn click payload: ", payload);
|
||||
|
||||
if ("name" in payload) {
|
||||
switch (payload.name) {
|
||||
case "cancel":
|
||||
this.handleClose();
|
||||
break;
|
||||
case "reset":
|
||||
this.resetForm(true, true); // true means exclude id, immediate execution
|
||||
break;
|
||||
case "add":
|
||||
case "update":
|
||||
this.addOrUpdate(payload.name === "add" ? "POST" : "PUT");
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
console.log("[x] 不是这么用的! 缺少name属性");
|
||||
}
|
||||
},
|
||||
|
||||
handleUploadChange(file, fileList) {
|
||||
// console.log("[Upload] handleUploadChange...", file, fileList);
|
||||
},
|
||||
|
||||
handleClose() {
|
||||
|
@ -1,19 +1,339 @@
|
||||
<template>
|
||||
<div class="order-detail">
|
||||
Order Detail
|
||||
<el-form ref="dataForm" :model="dataForm" v-loading="loadingStatus" style="padding: 0 40px">
|
||||
<el-row v-for="(row, rowIndex) in configs.form.rows" :key="'row_' + rowIndex" :gutter="20">
|
||||
<el-col v-for="(col, colIndex) in row" :key="colIndex" :span="24 / row.length" :class="{ h0: col.hidden }">
|
||||
<!-- 通过多个 col === null 可以控制更灵活的 span 大小 -->
|
||||
<el-form-item v-if="col !== null" :label="col.label" :prop="col.prop" :rules="col.rules || null">
|
||||
<el-input v-if="col.input" v-model="dataForm[col.prop]" clearable :disabled="detailMode" v-bind="col.elparams" />
|
||||
<el-cascader
|
||||
v-if="col.cascader"
|
||||
v-model="dataForm[col.prop]"
|
||||
:options="col.options"
|
||||
:disabled="detailMode"
|
||||
v-bind="col.elparams"
|
||||
></el-cascader>
|
||||
<el-select
|
||||
v-if="col.select"
|
||||
v-model="dataForm[col.prop]"
|
||||
clearable
|
||||
:disabled="detailMode"
|
||||
v-bind="col.elparams"
|
||||
@change="handleSelectChange(col, $event)"
|
||||
>
|
||||
<el-option v-for="(opt, optIdx) in col.options" :key="'option_' + optIdx" :label="opt.label" :value="opt.value" />
|
||||
</el-select>
|
||||
<el-switch
|
||||
v-if="col.switch"
|
||||
v-model="dataForm[col.prop]"
|
||||
:active-value="col.activeValue ?? 1"
|
||||
:inactive-value="col.activeValue ?? 0"
|
||||
@change="handleSwitchChange"
|
||||
:disabled="detailMode"
|
||||
/>
|
||||
<el-input v-if="col.textarea" type="textarea" v-model="dataForm[col.prop]" :disabled="detailMode" v-bind="col.elparams" />
|
||||
<el-date-picker v-if="col.datetime" v-model="dataForm[col.prop]" :disabled="detailMode" v-bind="col.elparams" />
|
||||
|
||||
<div class="" v-if="col.component" style="margin: 42px 0 0">
|
||||
<!-- 下面这个 component 几乎是为 富文本 quill 定制的了... TODO:后续可能会根据业务需求创建新的版本 -->
|
||||
<component
|
||||
:is="col.component"
|
||||
:key="'component_' + col.prop"
|
||||
@update:modelValue="handleComponentModelUpdate(col.prop, $event)"
|
||||
:modelValue="dataForm[col.prop] ?? ''"
|
||||
:mode="detailMode ? 'detail' : dataForm.id ? 'edit' : 'create'"
|
||||
v-bind="col.bind"
|
||||
/>
|
||||
</div>
|
||||
<!-- add more... -->
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// import textOnlyComponent from "@/components/noTemplateComponents/textOnlyComponent.js";
|
||||
import moment from "moment";
|
||||
import { pick as __pick } from "@/utils/filters";
|
||||
|
||||
export default {
|
||||
name: "OrderDetailTag",
|
||||
props: {},
|
||||
data() {
|
||||
return {};
|
||||
props: {
|
||||
configs: {
|
||||
type: Object,
|
||||
default: () => ({
|
||||
clickModalToClose: true,
|
||||
forms: null,
|
||||
}),
|
||||
},
|
||||
},
|
||||
data() {
|
||||
const dataForm = {};
|
||||
const watchList = [];
|
||||
const cachedList = {};
|
||||
|
||||
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 && res.data.list) {
|
||||
if ("injectTo" in col) {
|
||||
// 保存完整的数据列表
|
||||
cachedList[col.prop] = res.data.list;
|
||||
}
|
||||
|
||||
this.$set(
|
||||
col,
|
||||
"options",
|
||||
res.data.list.map((i) => ({
|
||||
label: col.optionLabel ? i[col.optionLabel] : i.name,
|
||||
value: col.optionValue ? i[col.optionValue] : i.id,
|
||||
}))
|
||||
);
|
||||
} else {
|
||||
col.options.splice(0);
|
||||
}
|
||||
});
|
||||
else if (col.fetchTreeData) {
|
||||
// 获取设备类型时触发的,用于前端构建属性结构,约定,parentId 为0时是顶级节点
|
||||
col.fetchTreeData().then(({ data: res }) => {
|
||||
// console.log("[DialogJustForm fetchTreeData -->]", res.data);
|
||||
if (res.code === 0 && res.data) {
|
||||
if ("list" in res.data) {
|
||||
this.$set(col, "options", res.data.list);
|
||||
} else if (Array.isArray(res.data)) {
|
||||
this.$set(col, "options", res.data);
|
||||
}
|
||||
} else {
|
||||
col.options.splice(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return {
|
||||
loadingStatus: false,
|
||||
detailMode: false,
|
||||
dataForm,
|
||||
watchList,
|
||||
cachedList,
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
/** 处理 injectTo 选项 */
|
||||
this.configs.form.rows.forEach((row) => {
|
||||
row.forEach((col) => {
|
||||
if ("injectTo" in col && Array.isArray(col.injectTo)) {
|
||||
col.injectTo.map((item) => {
|
||||
const unwatch = this.$watch(
|
||||
() => this.dataForm[col.prop],
|
||||
(newVal) => {
|
||||
const chosenObject = this.cachedList[col.prop].find((i) => i.id === newVal);
|
||||
if (chosenObject) {
|
||||
this.$set(this.dataForm, item[0], chosenObject[item[1]]);
|
||||
}
|
||||
},
|
||||
{
|
||||
immediate: false,
|
||||
}
|
||||
);
|
||||
this.watchList.push(unwatch);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
/** utitilities */
|
||||
showButton(operate) {
|
||||
const notDetailMode = !this.detailMode;
|
||||
const showAlways = operate.showAlways ?? false;
|
||||
const editMode = operate.showOnEdit && this.dataForm.id;
|
||||
const addMode = !operate.showOnEdit && !this.dataForm.id;
|
||||
const permission = operate.permission ? this.$hasPermission(operate.permission) : true;
|
||||
return notDetailMode && (showAlways || ((editMode || addMode) && permission));
|
||||
},
|
||||
|
||||
resetForm(excludeId = false, immediate = false) {
|
||||
setTimeout(
|
||||
() => {
|
||||
Object.keys(this.dataForm).forEach((key) => {
|
||||
if (excludeId && key === "id") return;
|
||||
this.dataForm[key] = null;
|
||||
});
|
||||
this.$refs.dataForm.clearValidate();
|
||||
this.$emit("dialog-closed"); // 触发父组件销毁自己
|
||||
this.watchList.map((unwatch) => unwatch());
|
||||
this.cachedList = {};
|
||||
},
|
||||
immediate ? 0 : 200
|
||||
);
|
||||
},
|
||||
|
||||
handleComponentModelUpdate(propName, { subject, payload: { data } }) {
|
||||
this.dataForm[propName] = JSON.stringify(data);
|
||||
// console.log("[DialogJustForm] handleComponentModelUpdate", this.dataForm[propName]);
|
||||
},
|
||||
|
||||
addOrUpdate(method = "POST") {
|
||||
if ("parentId" in this.dataForm) {
|
||||
// console.log("[DialogJustForm parentId]", this.dataForm.parentId);
|
||||
// 对特殊的键做特殊处理,如 parentId 是一个 cascader,获取的值是 ["xxx"],后端只需要xxx
|
||||
const lastItem = this.dataForm.parentId.length - 1;
|
||||
this.dataForm.parentId = this.dataForm.parentId[lastItem];
|
||||
}
|
||||
|
||||
this.$refs.dataForm.validate((passed, result) => {
|
||||
if (passed) {
|
||||
this.loadingStatus = true;
|
||||
|
||||
let httpPayload = null;
|
||||
/** 针对有文件上传选项的弹窗提供特殊的 payload */
|
||||
if (this.dataForm.files) {
|
||||
httpPayload = {
|
||||
...this.dataForm,
|
||||
fileIds: this.dataForm.files.map((file) => file.id),
|
||||
};
|
||||
} else {
|
||||
httpPayload = this.dataForm;
|
||||
}
|
||||
|
||||
/** 针对时间段设置 payload */
|
||||
if ("startTime" in this.dataForm && "endTime" in this.dataForm) {
|
||||
const { startTime, endTime } = this.dataForm;
|
||||
httpPayload = {
|
||||
...httpPayload,
|
||||
startTime: startTime ? moment(startTime).format("YYYY-MM-DDTHH:mm:ss") : moment().format("YYYY-MM-DDTHH:mm:ss"),
|
||||
endTime: endTime ? moment(endTime).format("YYYY-MM-DDTHH:mm:ss") : moment().format("YYYY-MM-DDTHH:mm:ss"),
|
||||
};
|
||||
}
|
||||
|
||||
// /** 针对时间段设置 payload */
|
||||
// if ("updateTime" in this.dataForm) {
|
||||
// const { updateTime } = this.dataForm;
|
||||
// httpPayload = {
|
||||
// ...httpPayload,
|
||||
// updateTime: updateTime ? moment(updateTime).format("YYYY-MM-DDTHH:mm:ss") : moment().format("YYYY-MM-DDTHH:mm:ss"),
|
||||
// };
|
||||
// }
|
||||
/** 针对时间段设置 payload */
|
||||
if ("deliveryTime" in this.dataForm) {
|
||||
const { deliveryTime } = this.dataForm;
|
||||
httpPayload = {
|
||||
...httpPayload,
|
||||
deliveryTime: deliveryTime ? moment(deliveryTime).format("YYYY-MM-DDTHH:mm:ss") : null,
|
||||
};
|
||||
}
|
||||
|
||||
/** 发送 */
|
||||
return this.$http({
|
||||
url: this.urls.base,
|
||||
method,
|
||||
data: httpPayload,
|
||||
})
|
||||
.then(({ data: res }) => {
|
||||
// console.log("[add&update] res is: ", res);
|
||||
this.loadingStatus = false;
|
||||
if (res.code === 0) {
|
||||
this.$message.success(method === "POST" ? "添加成功" : "更新成功");
|
||||
this.$emit("refreshDataList");
|
||||
if (method === "POST") this.handleClose();
|
||||
} else {
|
||||
this.$message({
|
||||
message: `${res.code}: ${res.msg}`,
|
||||
type: "error",
|
||||
duration: 2000,
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((errMsg) => {
|
||||
this.$message.error("参数错误:" + errMsg);
|
||||
if (this.loadingStatus) this.loadingStatus = false;
|
||||
});
|
||||
} else {
|
||||
this.$message.error("请核查字段信息");
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
handleBtnClick(payload) {
|
||||
// console.log("btn click payload: ", payload);
|
||||
|
||||
if ("name" in payload) {
|
||||
switch (payload.name) {
|
||||
case "cancel":
|
||||
this.handleClose();
|
||||
break;
|
||||
case "reset":
|
||||
this.resetForm(true, true); // true means exclude id, immediate execution
|
||||
break;
|
||||
case "add":
|
||||
case "update":
|
||||
this.addOrUpdate(payload.name === "add" ? "POST" : "PUT");
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
console.log("[x] 不是这么用的! 缺少name属性");
|
||||
}
|
||||
},
|
||||
|
||||
init(order, detailMode) {
|
||||
if (this.$refs.dataForm) {
|
||||
this.$refs.dataForm.clearValidate();
|
||||
}
|
||||
|
||||
this.detailMode = detailMode ?? false;
|
||||
this.$nextTick(() => {
|
||||
// this.dataForm.id = id || null;
|
||||
if (this.dataForm.id) {
|
||||
// 如果是编辑
|
||||
this.loadingStatus = true;
|
||||
|
||||
// 获取基本信息
|
||||
this.$http
|
||||
.get(this.urls.base + `/${this.dataForm.id}`)
|
||||
.then(({ data: res }) => {
|
||||
if (res && res.code === 0) {
|
||||
this.dataForm = __pick(res.data, Object.keys(this.dataForm));
|
||||
/** 格式化文件上传列表 */
|
||||
if (Array.isArray(this.dataForm.files)) {
|
||||
this.dataForm.files = this.dataForm.files.map((file) => ({
|
||||
id: file.id,
|
||||
name: file.fileUrl.split("/").pop(),
|
||||
typeCode: file.typeCode,
|
||||
url: file.fileUrl,
|
||||
}));
|
||||
}
|
||||
// console.log("[DialogJustForm] init():", this.dataForm);
|
||||
} else {
|
||||
this.$message({
|
||||
message: `${res.code}: ${res.msg}`,
|
||||
type: "error",
|
||||
duration: 1500,
|
||||
});
|
||||
}
|
||||
this.loadingStatus = false;
|
||||
})
|
||||
.catch((err) => {
|
||||
this.loadingStatus = false;
|
||||
this.$message({
|
||||
message: `${err}`,
|
||||
type: "error",
|
||||
duration: 1500,
|
||||
});
|
||||
});
|
||||
} else {
|
||||
// 如果不是编辑
|
||||
this.loadingStatus = false;
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
created() {},
|
||||
mounted() {},
|
||||
methods: {},
|
||||
};
|
||||
</script>
|
||||
|
||||
|
233
src/views/modules/pms/order/components/tabs/t.js
Normal file
233
src/views/modules/pms/order/components/tabs/t.js
Normal file
@ -0,0 +1,233 @@
|
||||
formRows: [
|
||||
[
|
||||
{
|
||||
label: "订单状态",
|
||||
prop: "statusDictValue",
|
||||
component: textOnlyComponent,
|
||||
},
|
||||
{
|
||||
input: true,
|
||||
label: "订单号",
|
||||
prop: "code",
|
||||
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
|
||||
elparams: { placeholder: "请输入订单号" },
|
||||
},
|
||||
{
|
||||
input: true,
|
||||
label: "订单子号",
|
||||
prop: "cate",
|
||||
rules: [
|
||||
{ required: true, message: "必填项不能为空", trigger: "blur" },
|
||||
{ type: "number", message: "请输入正确的数字类型", trigger: "blur", transform: (val) => Number(val) },
|
||||
],
|
||||
elparams: { placeholder: "请输入订单子号" },
|
||||
},
|
||||
{
|
||||
input: true,
|
||||
label: "生产订单类型",
|
||||
prop: "specifications",
|
||||
elparams: { placeholder: "请输入生产订单类型" },
|
||||
},
|
||||
{
|
||||
select: true,
|
||||
label: "物料编号",
|
||||
prop: "productId",
|
||||
options: [],
|
||||
optionLabel: "code",
|
||||
fetchData: () => this.$http.get("/pms/product/page", { params: { limit: 999, page: 1, key: "" } }),
|
||||
elparams: { placeholder: "请选择物料", filterable: true },
|
||||
},
|
||||
{
|
||||
select: true,
|
||||
label: "包装代码",
|
||||
prop: "packTech",
|
||||
options: [],
|
||||
optionLabel: "code",
|
||||
fetchData: () => this.$http.post("/pms/equipmentTech/pageView", { limit: 999, page: 1, key: "", shape: "", wsId: 5 }),
|
||||
elparams: { placeholder: "请选择物料", filterable: true },
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
input: true,
|
||||
label: "生产订单砖数",
|
||||
prop: "prodqty",
|
||||
rules: [
|
||||
{ required: true, message: "必填项不能为空", trigger: "blur" },
|
||||
{ type: "number", message: "请输入正确的数字类型", trigger: "blur", transform: (val) => Number(val) },
|
||||
],
|
||||
elparams: { placeholder: "请输入要求生产的数量" },
|
||||
},
|
||||
{
|
||||
input: true,
|
||||
label: "已生产数",
|
||||
prop: "yieldqty",
|
||||
// rules: { required: true, message: "必填项不能为空", trigger: "blur" },
|
||||
rules: [
|
||||
// { required: true, message: "必填项不能为空", trigger: "blur" },
|
||||
{ type: "number", message: "请输入正确的数字类型", trigger: "blur", transform: (val) => Number(val) },
|
||||
],
|
||||
elparams: { placeholder: "请输入已经生产的数量" },
|
||||
},
|
||||
{
|
||||
input: true,
|
||||
label: "托盘码放砖数",
|
||||
prop: "pcsKilnCar",
|
||||
rules: [
|
||||
{ required: true, message: "必填项不能为空", trigger: "blur" },
|
||||
{ type: "number", message: "请输入正确的数字类型", trigger: "blur", transform: (val) => Number(val) },
|
||||
],
|
||||
elparams: { placeholder: "请输入要求生产的数量" },
|
||||
},
|
||||
{
|
||||
input: true,
|
||||
label: "Add on",
|
||||
prop: "sapParam1",
|
||||
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
|
||||
elparams: { placeholder: "请输入addon" },
|
||||
},
|
||||
{
|
||||
select: true,
|
||||
label: "砖型",
|
||||
prop: "shape",
|
||||
optionLabel: "code",
|
||||
options: [],
|
||||
fetchData: () => this.$http.get("/pms/shape/page", { params: { limit: 999, page: 1, key: "" } }),
|
||||
elparams: { placeholder: "请选择砖型", filterable: true },
|
||||
},
|
||||
{
|
||||
select: true,
|
||||
label: "压机",
|
||||
prop: "press",
|
||||
options: [],
|
||||
optionLabel: "code",
|
||||
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
|
||||
fetchData: () => this.$http.get("/pms/equipment/page", { params: { limit: 999, page: 1, name: "" } }),
|
||||
elparams: { placeholder: "请选择压机号", filterable: true },
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
select: true,
|
||||
label: "牌号",
|
||||
prop: "bomId",
|
||||
options: [],
|
||||
// optionLabel: '',
|
||||
fetchData: () => this.$http.get("/pms/bom/page", { params: { limit: 999, page: 1, key: "", externalCode: "" } }),
|
||||
elparams: { placeholder: "请选择牌号", filterable: true },
|
||||
injectTo: [
|
||||
["bomCode", "code"],
|
||||
["ai", "externalCode"],
|
||||
],
|
||||
},
|
||||
{
|
||||
label: "配方号代码",
|
||||
prop: "bomCode",
|
||||
component: textOnlyComponent,
|
||||
bind: {
|
||||
useBuiltin: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "版本号",
|
||||
prop: "ai",
|
||||
component: textOnlyComponent,
|
||||
bind: {
|
||||
useBuiltin: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
select: true,
|
||||
label: "混料机号",
|
||||
prop: "blender",
|
||||
options: [],
|
||||
optionLabel: "code",
|
||||
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
|
||||
fetchData: () => this.$http.get("/pms/equipment/page", { params: { limit: 999, page: 1, name: "" } }),
|
||||
elparams: { placeholder: "请选择混料机号", filterable: true },
|
||||
},
|
||||
{
|
||||
select: true,
|
||||
label: "隧道窑号",
|
||||
prop: "kiln",
|
||||
options: [],
|
||||
optionLabel: "code",
|
||||
fetchData: () => this.$http.get("/pms/equipment/page", { params: { limit: 999, page: 1, name: "" } }),
|
||||
elparams: { placeholder: "请选择隧道窑号", filterable: true },
|
||||
},
|
||||
{
|
||||
input: true,
|
||||
label: "烧成温度 ℃",
|
||||
prop: "sapParam6",
|
||||
rules: [
|
||||
{ required: true, message: "必填项不能为空", trigger: "blur" },
|
||||
{ type: "number", message: "请输入正确的数字类型", trigger: "blur", transform: (val) => Number(val) },
|
||||
],
|
||||
elparams: { placeholder: "请输入烧成温度" },
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
input: true,
|
||||
label: "烧成时间 H",
|
||||
prop: "sapParam7",
|
||||
rules: [
|
||||
{ required: true, message: "必填项不能为空", trigger: "blur" },
|
||||
{ type: "number", message: "请输入正确的数字类型", trigger: "blur", transform: (val) => Number(val) },
|
||||
],
|
||||
elparams: { placeholder: "请输入烧成时间" },
|
||||
},
|
||||
{
|
||||
input: true,
|
||||
label: "销售订单号",
|
||||
prop: "saleNo",
|
||||
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
|
||||
elparams: { placeholder: "请输入销售订单号" },
|
||||
},
|
||||
{
|
||||
input: true,
|
||||
label: "销售订单item号",
|
||||
prop: "saleOrderItem",
|
||||
// rules: { required: true, message: "必填项不能为空", trigger: "blur" },
|
||||
elparams: { placeholder: "请输入销售订单item号" },
|
||||
},
|
||||
{
|
||||
input: true,
|
||||
label: "销售订单砖数",
|
||||
prop: "soqty",
|
||||
rules: [
|
||||
{ required: true, message: "必填项不能为空", trigger: "blur" },
|
||||
{ type: "number", message: "请输入正确的数字类型", trigger: "blur", transform: (val) => Number(val) },
|
||||
],
|
||||
elparams: { placeholder: "请输入销售订单砖数" },
|
||||
},
|
||||
{
|
||||
datetime: true,
|
||||
label: "销售时间",
|
||||
prop: "deliveryTime",
|
||||
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
|
||||
elparams: { placeholder: "请选择销售时间" },
|
||||
},
|
||||
{
|
||||
select: true,
|
||||
label: "客户",
|
||||
prop: "customerId",
|
||||
option: [],
|
||||
optionLabel: "name",
|
||||
fetchData: () => this.$http.get("/pms/customer/page", { params: { limit: 999, page: 1, name: "" } }),
|
||||
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
|
||||
elparams: { placeholder: "请选择客户" },
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
label: "物料号销售文本",
|
||||
prop: "shortDesc",
|
||||
component: textOnlyComponent,
|
||||
bind: {
|
||||
useBuiltin: false,
|
||||
},
|
||||
},
|
||||
],
|
||||
[{ input: true, label: "备注", prop: "remark", elparams: { placeholder: "备注" } }],
|
||||
],
|
Loading…
Reference in New Issue
Block a user