Kaynağa Gözat

页面修改

wayne 6 yıl önce
ebeveyn
işleme
d9afe85de4
1 değiştirilmiş dosya ile 99 ekleme ve 35 silme
  1. 99 35
      pages/main/index/artificial_order.vue

+ 99 - 35
pages/main/index/artificial_order.vue

@@ -71,8 +71,8 @@
           </el-col>
           <el-col :span="12">
             <el-form-item label="变更余额">
-              <el-radio v-model="radio" label="1">收入</el-radio>
-              <el-radio v-model="radio" label="2">支出</el-radio>
+              <el-radio v-model="radio" label="1" disabled>收入</el-radio>
+              <el-radio v-model="radio" label="2" disabled>支出</el-radio>
             </el-form-item>
           </el-col>
         </el-row>
@@ -132,11 +132,12 @@
     
       <el-form-item>
         <el-button class="save-btn" type="primary" @click="saveSubmit()">保存</el-button>
-        <el-button class="cancel-btn">取消</el-button>
+        <el-button class="cancel-btn" @click="cancelSubmit()">取消</el-button>
       </el-form-item>
 
       <el-form-item>
-        <el-button class="comfirm-btn" type="primary" @click="confirmSubmit()">确认提交订单</el-button>
+        <el-button v-if="hasSave" class="comfirm-btn" type="primary" @click="confirmSubmit()">确认提交订单</el-button>
+        <el-button v-else class="comfirm-btn" type="info">确认提交订单</el-button>
       </el-form-item>
     </el-form>
   </div>
@@ -163,6 +164,7 @@ export default {
         orderNo: "",
         status: ""
       },
+      saveData: {},
       rules: {
         uid: [{ required: true, message: "请输入用户uid", trigger: "blur" }],
         productTitle: [{ required: true, max: 25, message: "请输入订单名称,尽量遵守命名规则", trigger: "blur" }],
@@ -174,6 +176,7 @@ export default {
       productTypes: [],
       channels: [],
       orderState: [],
+      hasSave: false,
       radio: "1",
       editorOption: {
         modules: {
@@ -196,6 +199,30 @@ export default {
       }
     };
   },
+  // computed: {
+  //   radio() {
+  //     if (this.form.orderType === 2 || this.form.orderType === 5 || this.form.orderType === 8) {
+  //       this.radio = "1"
+  //     } else if (this.form.orderType === 9) {
+  //       this.radio = "2"
+  //     } else {
+  //       this.radio = "3"
+  //     }
+  //   }
+  // },
+  watch: {
+    'form.orderType': {
+      handler() {
+        if (this.form.orderType === 2 || this.form.orderType === 5 || this.form.orderType === 8) {
+          this.radio = "1"
+        } else if (this.form.orderType === 9) {
+          this.radio = "2"
+        } else {
+          this.radio = "3"
+        }
+      }
+    }
+  },
   mounted() {
     console.log(this.$route.query);
     const type = this.$route.query.type;
@@ -203,10 +230,11 @@ export default {
       this.action = "create";
       this.getAllChoice();
     } else if (type === "edit") {
-      this.action = "";
-      this.id = this.$route.query.id;
-      this.getAllChoice();
-      this.getOrder();
+      this.action = ""
+      this.id = this.$route.query.id
+      this.hasSave = true
+      this.getAllChoice()
+      this.getOrder()
     }
   },
   methods: {
@@ -215,12 +243,12 @@ export default {
         action: this.action
       });
       if (res) {
-        console.log(res);
-        const allChoice = res.data;
-        this.orderTypes = allChoice.order_types;
-        this.productTypes = allChoice.product_types;
-        this.channels = allChoice.channels;
-        this.orderState = allChoice.order_state;
+        console.log(res)
+        const allChoice = res.data
+        this.orderTypes = allChoice.order_types
+        this.productTypes = allChoice.product_types
+        this.channels = allChoice.channels
+        this.orderState = allChoice.order_state
       }
     },
     async getOrder() {
@@ -229,25 +257,29 @@ export default {
       });
       if (res) {
         if (res.status === 1 && res.data) {
-          const data = res.data;
-          this.form.uid = data.uid || "";
-          this.form.productTitle = data.product_title || "";
-          this.form.productType = data.product_type || "";
-          this.form.orderType = data.order_type || "";
-          this.form.price = data.price || "";
-          this.form.channel = data.channel || "";
-          this.form.outOrderId = data.out_order_id || "";
-          this.form.productId = data.product_id || "";
-          this.form.originOrderNo = data.origin_order_no || "";
-          this.form.publicComment = data.public_comment || "";
-          this.form.privateComment = data.private_comment || "";
-          this.form.orderNo = data.order_no || "";
-          this.form.status = data.status || "";
+          const data = res.data
+          this.form.uid = data.uid || ""
+          this.form.productTitle = data.product_title || ""
+          this.form.productType = data.product_type || ""
+          this.form.orderType = data.order_type || ""
+          this.form.price = data.price || ""
+          this.form.channel = data.channel || ""
+          this.form.outOrderId = data.out_order_id || ""
+          this.form.productId = data.product_id || ""
+          this.form.originOrderNo = data.origin_order_no || ""
+          this.form.publicComment = data.public_comment || ""
+          this.form.privateComment = data.private_comment || ""
+          this.form.orderNo = data.order_no || ""
+          this.form.status = data.status || ""
+          this.form.productTypeName = data.product_type_name || ""
+          this.form.orderTypeName = data.order_type_name || ""
+          this.form.channelName = data.channel_name || ""
+          console.log(this.form)
         }
       }
     },
     async saveOrder() {
-      let res = await this.$post("/api/admin/order/create", {
+      const data = {
         id: this.id,
         uid: this.form.uid,
         product_title: this.form.productTitle,
@@ -259,17 +291,23 @@ export default {
         origin_order_no: this.form.originOrderNo,
         public_comment: this.form.publicComment,
         private_comment: this.form.privateComment
-      });
+      }
+      this.saveData = data
+      let res = await this.$post("/api/admin/order/create", data)
       if (res) {
-        if (res.status === 1 && res.data && res.data.order_id) {
-          // this.id = res.data.id
+        if (res.status === 1) {
+          this.hasSave = true
+          this.$message({
+            message: "保存成功",
+            type: "success"
+          })
         } else if (res.info) {
-          console.log(res.info);
+          console.log(res.info)
         }
       }
     },
     async confirmOrder() {
-      let res = await this.$post("/api/admin/order/confirm_order", {
+      const data = {
         id: this.id,
         uid: this.form.uid,
         product_title: this.form.productTitle,
@@ -281,7 +319,30 @@ export default {
         origin_order_no: this.form.originOrderNo,
         public_comment: this.form.publicComment,
         private_comment: this.form.privateComment
-      });
+      }
+      const confirmData = data
+      const saveData = this.saveData
+      const isConfirm = true
+      for (const key in confirmData) {
+        if (confirmData[key] !== saveData[key]) {
+          this.$message({
+            message: '与保存订单不一致,请先保存订单!',
+            type: 'warning'
+          })
+          rerun
+        }
+      }
+      let res = await this.$post("/api/admin/order/confirm_order", data)
+      if (res) {
+        if (res.status === 1) {
+          this.$message({
+            message: "提交成功",
+            type: "success"
+          })
+        } else if (res.info) {
+          console.log(res.info)
+        }
+      }
     },
     saveSubmit() {
       this.$refs['form'].validate(valid => {
@@ -302,6 +363,9 @@ export default {
           return false
         }
       })
+    },
+    cancelSubmit() {
+      this.$router.push('/main/artificial_orders')
     }
   }
 };