diff --git a/src/views/modules/pms/order/components/order--edit.vue b/src/views/modules/pms/order/components/order--edit.vue
index 810e444..517dec3 100644
--- a/src/views/modules/pms/order/components/order--edit.vue
+++ b/src/views/modules/pms/order/components/order--edit.vue
@@ -433,8 +433,8 @@
- 保存
- 更新
+ 保存
+ 更新
重置
取消
@@ -694,6 +694,7 @@ export default {
const targetBom = this.versionList.find((item) => item.value === v);
// this.bomId 用于在提交的时候置换 this.dataForm.bomId
this.bomId = targetBom.id;
+ console.log("[handleVersionChange] new bomID", this.bomId);
},
async init(id) {
@@ -749,101 +750,36 @@ export default {
this.$forceUpdate();
},
- 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.formLoading = 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,
- };
- }
-
- // Object.getOwnPropertyNames(this.dataForm).forEach((prop) => {
- // if (/.*?Time/.test(prop)) {
- // console.log("HTTP prop", prop, this.dataForm[prop]);
- // }
- // });
-
- // return;
-
- /** 发送 */
- return this.$http({
- url: this.urls.base,
- method,
- data: httpPayload,
- })
- .then(({ data: res }) => {
- // console.log("[add&update] res is: ", res);
- this.formLoading = false;
- if (res.code === 0) {
- this.$message.success(method === "POST" ? "添加成功" : "更新成功");
- this.$emit("refreshDataList");
- this.handleClose();
- } else {
- this.$message({
- message: `${res.code}: ${res.msg}`,
- type: "error",
- duration: 2000,
- });
- }
- })
- .catch((errMsg) => {
- this.$message.error("参数错误:" + errMsg);
- if (this.formLoading) this.formLoading = false;
+ async handleSave(method = "POST") {
+ this.$refs.dataForm.validate((valid) => {
+ if (valid) {
+ this.btnLoading = true;
+ try {
+ const { data: res } = this.$http({
+ url: this.urls.base,
+ method,
+ data: {
+ ...this.dataForm,
+ bomId: this.bomId != null ? this.bomId : this.dataForm.bomId,
+ },
});
- } else {
- this.$message.error("请核查字段信息");
+
+ if (res && res.code == 0) {
+ this.$message.success("添加成功");
+ this.$emit("refreshDataList");
+ this.handleClose();
+ this.btnLoading = false;
+ } else {
+ throw new Error("请求出错");
+ }
+ } catch (err) {
+ this.$message.error("参数错误:" + "msg" in err ? err.msg : err);
+ this.btnLoading = false;
+ }
}
});
},
- handleSave() {},
-
- handleUpdate() {},
-
handleReset() {},
handleClose() {