소스 검색

bug修复

chenrui 3 년 전
부모
커밋
b8c1fe02cd
2개의 변경된 파일27개의 추가작업 그리고 3개의 파일을 삭제
  1. 25 1
      src/views/productManagement/productInfo/edit.vue
  2. 2 2
      src/views/productManagement/productInfo/list.vue

+ 25 - 1
src/views/productManagement/productInfo/edit.vue

@@ -378,12 +378,36 @@ export default {
     getProductType () {
       productTypeQueryAll({}).then(res => {
         if (res.status == 200) {
-          this.productTypeList = res.data
+          if (res.data && res.data.length > 0) {
+            //  递归处理disabled禁用
+            this.recursionFun(res.data, false)
+            this.productTypeList = res.data
+          } else {
+            this.productTypeList = []
+          }
         } else {
           this.productTypeList = []
         }
       })
     },
+    //  递归函数
+    recursionFun (data, state) {
+      if (data) {
+        data.map((item, index) => {
+          // enabledFlag为0表示禁用,父级禁用则子级也为禁用
+          if ((item.enabledFlag && item.enabledFlag == 0) || state) {
+            item.disabled = true
+          } else {
+            item.disabled = false
+          }
+          if (item.children && item.children.length == 0) {
+            delete item.children
+          } else {
+            this.recursionFun(item.children, item.disabled)
+          }
+        })
+      }
+    },
     filterOption (input, option) {
       return (
         option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0

+ 2 - 2
src/views/productManagement/productInfo/list.vue

@@ -195,7 +195,7 @@ import { STable, VSelect } from '@/components'
 import productInfoDetailModal from './detailModal.vue'
 import productInfoOfflineModal from './offlineModal.vue'
 import { productBrandQuery } from '@/api/productBrand'
-import { productTypeQuery } from '@/api/productType'
+import { productTypeQueryAll } from '@/api/productType'
 import { productList, productAudit, productBatchAudit, productDel, productOnline, productBatchOnline, productExport } from '@/api/product'
 export default {
   components: { STable, VSelect, productInfoDetailModal, productInfoOfflineModal },
@@ -567,7 +567,7 @@ export default {
     },
     //  产品分类  列表
     getProductType () {
-      productTypeQuery({}).then(res => {
+      productTypeQueryAll({}).then(res => {
         if (res.status == 200) {
           this.productTypeList = res.data
         } else {