瀏覽代碼

优惠券

1
mo 3 年之前
父節點
當前提交
c49feb712c
共有 1 個文件被更改,包括 50 次插入24 次删除
  1. 50 24
      src/views/couponManager/couponUpdate.vue

+ 50 - 24
src/views/couponManager/couponUpdate.vue

@@ -34,23 +34,29 @@
               </el-input>
               <el-checkbox   v-model="form.warningStockNum" :true-label='-1' false-label=''	 @change="(val)=>{checkNo(val,'warningStockNum')}" >不限制</el-checkbox>
             </el-form-item> -->
-            <el-select
-              style="width: 100% !important"
-              class="multiple"
-              v-model.trim="form.organId"
-              filterable
-              multiple
-              clearable
-              placeholder="请选择分部"
-              :rules="[{ required: true, message: '请选择分部' }]"
+            <el-form-item
+              label="可用分部"
+              prop="organId"
+              :rules="[{ required: true, message: '请选择可用分部' }]"
             >
-              <el-option
-                v-for="(item, index) in selects.branchs"
-                :key="index"
-                :label="item.name"
-                :value="item.id"
-              ></el-option>
-            </el-select>
+              <el-select
+                style="width: 100% !important"
+                class="multiple"
+                v-model.trim="form.organId"
+                filterable
+                multiple
+                clearable
+                placeholder="请选择分部"
+                :rules="[{ required: true, message: '请选择分部' }]"
+              >
+                <el-option
+                  v-for="(item, index) in selects.branchs"
+                  :key="index"
+                  :label="item.name"
+                  :value="item.id"
+                ></el-option>
+              </el-select>
+            </el-form-item>
           </el-col>
         </el-row>
         <el-row>
@@ -377,7 +383,7 @@ export default {
         warningStockNum: "",
         limitExchangeNum: "",
         getTime: [],
-        organId:[]
+        organId: [],
       },
       activeRow: null,
       isDisabled: false,
@@ -389,7 +395,16 @@ export default {
     this.$store.dispatch("setBranchs");
     if (this.$route.query.row) {
       this.activeRow = JSON.parse(this.$route.query.row);
-      this.form = { ...this.activeRow };
+      let organIdStr = JSON.parse(this.activeRow.useCondition).organId;
+      let organId = [];
+      if (organIdStr) {
+        organId =
+          organIdStr.split(",").map((item) => {
+            return Number(item);
+          }) || [];
+      }
+
+      this.form = { ...this.activeRow, organId };
       // 优惠券只能时满减
       this.form.type = "FULL_REDUCTION";
 
@@ -425,7 +440,13 @@ export default {
     resetForm() {
       this.$refs.form.resetFields();
       if (this.activeRow) {
-        this.form = { ...this.activeRow };
+        let organIdStr = JSON.parse(this.activeRow.useCondition);
+        let organId = [];
+        if (organIdStr) {
+          organId = organIdStr.split(",") || [];
+        }
+
+        this.form = { ...this.activeRow, organId };
         let effectiveStartTime = this.activeRow.effectiveStartTime;
         let effectiveExpireTime = this.activeRow.effectiveExpireTime;
         let startDate = this.activeRow.startDate;
@@ -448,6 +469,9 @@ export default {
             .then(async () => {
               try {
                 let { effectiveTime, getTime, ...rest } = this.form;
+                let str = JSON.stringify({
+                  organId: this.form.organId.join(","),
+                });
                 let params = {
                   ...rest,
                   ...getTimes(
@@ -460,7 +484,7 @@ export default {
                     ["startDate", "endDate"],
                     "YYYY-MM-DD HH:mm:ss"
                   ),
-                  useCondition:{organId: this.form.organId.join(',')}
+                  useCondition:str,
                 };
                 const res = await addSysCoupon(params);
                 this.$message.success("新增成功");
@@ -484,8 +508,10 @@ export default {
             .then(async () => {
               try {
                 let { effectiveTime, getTime, ...rest } = this.form;
-                let str = String({organId: this.form.organId.join(',')})
-                console.log(str)
+                let str = JSON.stringify({
+                  organId: this.form.organId.join(","),
+                });
+
                 let params = {
                   ...rest,
                   ...getTimes(
@@ -498,10 +524,10 @@ export default {
                     ["startDate", "endDate"],
                     "YYYY-MM-DD HH:mm:ss"
                   ),
-                  useCondition:str
+                  useCondition: str,
                 };
                 const res = await resetSysCoupon(params);
-                this.$message.success("新增成功");
+                this.$message.success("修改成功");
                 this.onCancel();
               } catch (e) {
                 console.log(e);