Browse Source

订阅价格统一保存

natasha 1 year ago
parent
commit
505ae04ead

+ 8 - 0
src/components/Upload.vue

@@ -144,6 +144,14 @@ export default {
       } else if (file.size > 200 * 1024 * 1024) {
         this.$message.warning('上传文件大小不能超过200M');
         return false; // 必须返回false
+      } else if(this.uploadType === 'txt'){
+        let index = file.name.lastIndexOf('.');
+        let names = file.name
+        let type = names.substring(index + 1).toLowerCase()
+        if(type!=='txt') {
+            this.$message.warning('请上传txt文件')
+            return false
+        } 
       }
       this.loading = this.$loading({
         lock: true,

+ 4 - 0
src/views/cdkey_manage/AddGoods.vue

@@ -403,6 +403,10 @@ export default {
     },
     // 提交表单
     handleChooseGoods(){
+        if(this.checkGoodsList.length===0){
+            this.$message.warning('至少需要选择一个内容')
+            return
+        }
         this.loading = true
         let MethodName = "/ShopServer/Manager/DiscountCodeManager/AddGoodsToDiscountCode";
         let data = {

+ 5 - 0
src/views/cdkey_manage/CreateCdkey.vue

@@ -51,6 +51,7 @@
                             </ul>
                             <upload :class="['article-mp3']" :datafileList="organizeForm.subcode_import_file_list" :changeFillId="handleAvatarSuccess" :fileName="'articleMp3'" uploadType="txt" tips=' ' :filleNumber="1" :showList="true" />
                         </div>
+                        <p class="tips">只能上传txt类型文件</p>
                     </el-form-item>
                     <el-form-item label="备注" prop="memo">
                         <el-input
@@ -350,6 +351,10 @@ export default {
                     }
                 });
             }else if(this.stepIndex===1){
+                if(this.tableData.length===0){
+                    this.$message.warning('请添加内容')
+                    return false 
+                }
                 this.stepIndex++
             }
         }

+ 55 - 24
src/views/system_config/OrderSetting.vue

@@ -18,9 +18,11 @@
                 </div>
                 <el-table
                     class="search-table order-table"
-                    :data="tableList"
+                    :data="tableObj[typeValue]"
                     border
                     style="width: 672px"
+                    :key="typeValue"
+                    v-loading="tableLoading"
                     :max-height="tableHeight">
                     <el-table-column
                         type="index"
@@ -132,6 +134,8 @@ export default {
             }
         ],
         tableHeight: "", // 表格高度
+        tableObj: {},
+        tableLoading: false
     }
   },
   //计算属性 类似于data概念
@@ -154,26 +158,38 @@ export default {
     },
     // 提交表单
     onSubmit(){
+        let _this = this
         this.loading = true
         let MethodName = "/OrgServer/Manager/ReservationPriceManager/SaveReservationPriceList";
-        let table = JSON.parse(JSON.stringify(this.tableList))
-        table.forEach(item => {
-            item.comb_count = item.comb_count ? item.comb_count * 1 : 1
-            item.price = item.price * 1
-        });
-        let data = {
-            goods_type: 2,
-            goods_study_phase: this.typeValue,
-            reservation_price_list: table
-        }
-        getLogin(MethodName, data)
-        .then((res) => {
-            this.loading = false
-            if(res.status===1){
-                this.$message.success("保存成功")
-            }
-        }).catch((res) =>{
-            this.loading = false
+        let index = 0
+        Object.getOwnPropertyNames(_this.tableObj).forEach(function(key){
+            // if(_this.tableObj&&_this.tableObj[key]&&_this.tableObj[key].length>0){
+                let table = _this.tableObj[key].length>0?JSON.parse(JSON.stringify(_this.tableObj[key])):[]
+                table.forEach(item => {
+                    item.comb_count = item.comb_count ? item.comb_count * 1 : 1
+                    item.price = item.price * 1
+                });
+                let data = {
+                    goods_type: 2,
+                    goods_study_phase: key*1,
+                    reservation_price_list: table
+                }
+                getLogin(MethodName, data)
+                .then((res) => {
+                    // this.loading = false
+                    if(res.status===1){
+                        index ++
+                        if(index===Object.keys(_this.tableObj).length+1){
+                            _this.$message.success("保存成功")
+                            _this.loading = false
+                        }
+                        // this.$message.success("保存成功")
+                    }
+                }).catch((res) =>{
+                    _this.loading = false
+                })
+            // }
+            
         })
     },
     // 取消 恢复到修改前状态
@@ -182,17 +198,24 @@ export default {
     },
     // 得到配置信息
     getInfo(){
+        if(this.tableObj[this.typeValue]&&this.tableObj[this.typeValue].length>0){
+            return
+        }
+        this.tableLoading = true
         let MethodName = "/OrgServer/Manager/ReservationPriceManager/GetReservationPriceList";
         getLogin(MethodName, {
             goods_type: 2,
             goods_study_phase: this.typeValue
         })
         .then((res) => {
+            this.tableLoading = false
             if(res.status===1){
                 this.tableList = res.reservation_price_list
+                this.tableObj[this.typeValue] = res.reservation_price_list
+                this.$forceUpdate()
             }
         }).catch((res) =>{
-            
+            this.tableLoading = false
         })
     },
     //计算table高度(动态设置table高度)
@@ -210,8 +233,8 @@ export default {
     },
     tableLength(type){
         if(type=='-'){
-            if(this.tableList.length>1){
-                this.tableList.splice(this.tableList.length-1,1)
+            if(this.tableObj[this.typeValue].length>1){
+                this.tableObj[this.typeValue].splice(this.tableObj[this.typeValue].length-1,1)
             }else{
                 this.$message.warning('最少须保留一行')
             }
@@ -223,14 +246,22 @@ export default {
                     shelve_date: '',
                     price: ''
                 }
-                this.tableList.push(obj)
+                this.tableObj[this.typeValue].push(obj)
             }
         }
     }
   },
   //生命周期 - 创建完成(可以访问当前this实例)
   created() {
-    this.getInfo()
+    let timer = setInterval(() => {
+        if(this.$studyType&&this.$studyType.length>0){
+            this.$studyType.forEach(item=>{
+                this.tableObj[item.study_phase] = []
+            })
+            this.getInfo()
+            clearInterval(timer);
+        }
+    }, 1000);
     this.getTableHeight();
   },
   //生命周期 - 挂载完成(可以访问DOM元素)