Browse Source

'修改账户选择-添加搜索'

魏志佳 5 năm trước cách đây
mục cha
commit
86cd268596
1 tập tin đã thay đổi với 35 bổ sung11 xóa
  1. 35 11
      src/views/modules/Statistics/accountReport.vue

+ 35 - 11
src/views/modules/Statistics/accountReport.vue

@@ -6,16 +6,28 @@
           <span>项目选择:</span>
           <a-tree-select
             v-model="treeValue"
-            style="width: 575px;height:30px"
+            show-search
+            style="width: 600px;height:30px"
             :dropdownMatchSelectWidth='true'
-            :tree-data="treeData"
+            :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"              
             tree-checkable
+            searchPlaceholder='请输入账户关键字搜索'
             :show-checked-strategy="SHOW_PARENT"
-            placeholder="请选择项目和账户"
+            placeholder="请选择项目和账户或搜索账户关键字"
+            treeNodeFilterProp="title"
             :allowClear="true"
             @change="treeChange"
-            :maxTagCount='2'            
-          />
+            @search="treeSearch"
+            @select="treeSelect"                        
+             :maxTagCount='1'    
+            :tree-data="treeData"
+            :filterOption='filterOption'
+          >
+              <!-- <a-tree-select-node v-for="(item) in treeData" :key="item.key" :value="item.value" :title="item.title">
+                  <a-tree-select-node v-for="(ele) in item.children" :key="ele.key" :value="ele.value" :title="ele.title" >
+                  </a-tree-select-node>
+              </a-tree-select-node> -->
+          </a-tree-select>
       <div style="float:right"   @click="opendate">
             <DatePicker :openOptions='openOptions' :left=left :parentDate='dateValue' />
       </div>
@@ -524,7 +536,7 @@ export default {
     //项目改变后的事件
     treeChange(val) {
       // console.log(this.treeData)
-      // console.log(val[0])
+      console.log(val)
       this.accountId = [];
       //选择一个后禁用其他
       if(val.length==1){
@@ -602,12 +614,12 @@ export default {
       if(val){
         val.forEach((ele,index)=>{
           if(ele*1){
-              this.accountId.push(ele)
+              this.accountId.push(ele.value)
           }else{              
               let projectArr=this.treeData.filter((item)=>{
                   return item.value==ele
               });
-              
+              console.log(projectArr)
               projectArr[0].children.forEach((element)=>{
                  this.accountId.push(element.value)
               })
@@ -615,14 +627,26 @@ export default {
         })       
       }
       
-     
+     console.log(this.accountId)
+    },
+    treeSearch(){
+      console.log(arguments);
+    },
+    treeSelect(){
+      // console.log(arguments);
+      // this.treeValue=arguments[0].value
     },
     disabledDate(current) {
       // console.log(current)
 
-      return current && current > moment().subtract(1, 'day')
+       return current && current > moment().subtract(1, 'day')
+    },
+    filterOption(input, option){
+      console.log(input, option)
+      return (
+          option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
+        );
     },
-
     //查询按钮的事件
     searchgetData(){