Browse Source

bug 修复

lilei 2 years ago
parent
commit
fdc0fd825a

+ 39 - 2
src/views/common/productType.js

@@ -7,6 +7,7 @@ const ProductType = {
         :value="defaultVal"
         expand-trigger="hover"
         :options="productTypeList"
+        :show-search="{ filter }"
         :fieldNames="{ label: 'productTypeName', value: 'productTypeSn', children: 'children' }"
         :id="id"
         placeholder="请选择产品分类"
@@ -22,7 +23,11 @@ const ProductType = {
     id: {
       type: String,
       default: ''
-    }
+    },
+    level: {
+      type: [String,Number],
+      default: ''
+    },
   },
   data () {
     return {
@@ -39,6 +44,10 @@ const ProductType = {
     this.getProductType()
   },
   methods: {
+    filter(inputValue, path) {
+      console.log(inputValue, path)
+      return path.some(option => option.productTypeName.indexOf(inputValue) > -1);
+    },
     setDefValue(defaultVal){
       this.handleChange(defaultVal)
     },
@@ -51,11 +60,39 @@ const ProductType = {
     getProductType () {
       productTypeQuery({}).then(res => {
         if (res.status == 200) {
-          this.productTypeList = res.data
+          if(this.level){
+            this.productTypeList = this.getBylevel(res.data)
+          }else{
+            this.productTypeList = res.data
+          }
         } else {
           this.productTypeList = []
         }
       })
+    },
+    getBylevel(data){
+      const ret = []
+      // 显示一级分类
+      if(this.level == 1){
+        data.map(item => {
+          if(item.children){
+            delete item.children
+          }
+        })
+      }
+      // 显示二级分类
+      if(this.level == 2){
+        data.map(item => {
+          if(item.children){
+            item.children.map(cd => {
+              if(cd.children){
+                 delete cd.children
+              }
+            })
+          }
+        })
+      }
+      return data
     }
   }
 }

+ 2 - 2
src/views/reportData/expenseAccountReport/categoryList.vue

@@ -11,14 +11,14 @@
           :model="queryParam"
           @keyup.enter.native="handleSearch">
           <a-row :gutter="15">
-            <a-col :md="6" :sm="24">
+            <a-col :md="8" :sm="24">
               <a-form-model-item label="统计月份" prop="months">
                 <months v-model="queryParam.months" mode="multiple" style="width: 100%;"/>
               </a-form-model-item>
             </a-col>
             <a-col :md="6" :sm="24">
               <a-form-model-item label="费用归属品类(二级)" prop="productTypeSn2">
-                <ProductType v-model="productType" @change="changeProductType" placeholder="请选择费用归属品类"></ProductType>
+                <ProductType v-model="productType" :level="2" @change="changeProductType" placeholder="请选择费用归属品类"></ProductType>
               </a-form-model-item>
             </a-col>
             <a-col :md="6" :sm="24">