ソースを参照

修改选择父级分类前端

hyq 6 年 前
コミット
a88ba1fc5b

+ 1 - 1
kmall-admin/src/main/webapp/WEB-INF/page/shop/category.html

@@ -38,7 +38,7 @@
                 </i-select>
             </Form-item>
             <Form-item label="门店" prop="storeId">
-                <i-select v-model="category.storeId" placeholder="门店" label-in-value>
+                <i-select v-model="category.storeId" placeholder="门店" label-in-value  @on-change="getCategory">
                     <i-option v-for="store in storeList" :value="store.id" :key="store.id">{{store.storeName}}</i-option>
                 </i-select>
             </Form-item>

+ 11 - 7
kmall-admin/src/main/webapp/js/shop/category.js

@@ -106,7 +106,7 @@ var vm = new Vue({
             vm.showList = false;
             vm.title = "新增";
             vm.category = {isShow: 1, type: 0, level: 'L1', bannerUrl: '', iconUrl: '', imgUrl: '', wapBannerUrl: ''};
-            this.getParentCategory();
+            // this.getParentCategory(vm.category.storeId);
             vm.storeList = [];
             vm.merchList = [];
             vm.getMerchList();
@@ -125,12 +125,6 @@ var vm = new Vue({
             vm.getInfo(id[0].id);
             vm.getMerchList();
             vm.getStoresByMerch();
-            this.getParentCategory();
-        },
-        getParentCategory: function () {
-            $.get("../category/getCategorySelect", function (r) {
-                vm.categoryList = r.list;
-            });
         },
         saveOrUpdate: function (event) {
             var url = vm.category.id == null ? "../category/save" : "../category/update";
@@ -180,6 +174,7 @@ var vm = new Vue({
         getInfo: function (id) {
             $.get("../category/info/" + id, function (r) {
                 vm.category = r.category;
+                this.getParentCategory(r.category.storeId);
             });
         },
         getStoresByMerch: function (opt) {
@@ -193,6 +188,15 @@ var vm = new Vue({
                 vm.merchList = r.list;
             });
         },
+        getParentCategory: function (storeId) {
+            $.get("../category/getCategorySelect?storeId="+storeId, function (r) {
+                vm.categoryList = r.list;
+            });
+        },
+        getCategory: function (opt) {
+            var storeId = opt.value;
+            vm.getParentCategory(storeId);
+        },
         reload: function (event) {
             vm.showList = true;
             TreeGrid.table.refresh();