Kaynağa Gözat

1、完善查询条件组件

zhoux 2 yıl önce
ebeveyn
işleme
1f3f88b240

+ 48 - 9
components/dkbusiness/dk-dropdown-menu/dk-dropdown-menu.js

@@ -25,23 +25,32 @@ Component({
       type: Array,
       default: [],
     },
+    // 查询条件
+    searchForm:{
+      type:Object,
+    }
   },
   /**
    * 组件的初始数据
    */
   data: {
+    $t: app.globalData.lang,
+    // 下拉
     dropDownFlag: false,
+    // 筛选
+    pickFlag: false,
     // 筛选中的日期组件显示标识
     dropDateFlag: false,
     dropType: null,
     dropCode: null,
     index: null,
     searchType: null,
+    // 记录是哪个组件点击出现的日期
+    dropDateCode: null,
     // 下拉多选数据源
     pullMSelectMenuList: [],
     // 下拉多选外数据源
-    pullOtherMenuList: [],
-    searchForm: {}
+    pullOtherMenuList: []
   },
   lifetimes: {
     attached: function () {
@@ -86,7 +95,7 @@ Component({
       // 筛选
       else if (item.searchType === Constants.searchType.pick) {
         this.setData({
-          dropDownFlag: true,
+          pickFlag: true,
           index: index,
           dropCode: item.dropType ? item.dropType : item.code,
           searchType: item.searchType
@@ -96,6 +105,7 @@ Component({
         this.setData({
           index: index,
           dropDownFlag: false,
+          pickFlag: false,
           dropCode: null,
           dropType: null
         })
@@ -114,7 +124,7 @@ Component({
       searchForm[code + 'End'] = data[1]
       let menuList = this.data.menuList
       let dateDefault = e.detail.dateDefault
-      if(this.data.index){
+      if (this.data.index) {
         if (menuList.length > this.data.index) {
           menuList[this.data.index].defaultValue = dateDefault.value
           menuList[this.data.index].title = dateDefault.text
@@ -124,6 +134,8 @@ Component({
         searchForm: searchForm,
         menuList: menuList
       })
+      console.log('fff',this.data.searchForm);
+      this.triggerEvent('search', { searchForm: this.data.searchForm ,trigger:true});
       this.selectComponent('#' + e.detail.code).toggle(false);
     },
     /**
@@ -144,6 +156,7 @@ Component({
         dropDownFlag: false
       })
       console.log('e', this.data.searchForm, e);
+      this.triggerEvent('search', { searchForm: this.data.searchForm });
       this.selectComponent('#' + this.data.dropCode).toggle(false);
     },
     /**
@@ -153,7 +166,7 @@ Component({
      */
     mutiCloseAll(e) {
       this.setData({
-        dropDownFlag: false
+        pickFlag: false
       })
       this.selectComponent('#' + this.data.dropCode).toggle(false);
     },
@@ -196,7 +209,8 @@ Component({
    */
     onClickDate(e) {
       this.setData({
-        dropDateFlag: true
+        dropDateFlag: true,
+        dropDateCode: e.currentTarget.dataset.key
       })
     },
     /**
@@ -205,7 +219,14 @@ Component({
    * @date : 2024/1/29 08:59
    */
     pickDateCommit(e) {
-      console.log('ee2', e);
+      let searchForm = this.data.searchForm
+      let date = e.detail.date[0] + '~' + e.detail.date[1]
+      searchForm[this.data.dropDateCode] = date
+      searchForm[this.data.dropDateCode + 'Start'] = e.detail.date[0];
+      searchForm[this.data.dropDateCode + 'End'] = e.detail.date[1];
+      this.setData({
+        searchForm: searchForm,
+      })
     },
     /**
    * @desc : 筛选重置事件
@@ -229,14 +250,32 @@ Component({
         pullOtherMenuList.forEach(it => {
           if (searchForm[it.code]) {
             // 删除searchForm中的属性
-            delete searchForm[it.code ];
+            delete searchForm[it.code];
+          }
+          // 如果有日期删除日期
+          if (it.dataType == Constants.dataType.date) {
+            delete searchForm[it.code + "Start"];
+            delete searchForm[it.code + "End"];
           }
         })
         console.log('tf', searchForm);
         this.setData({
-          searchForm: searchForm
+          searchForm: searchForm,
+          dropDateCode: null
         })
       }
     },
+    /**
+     * @desc : 获取语言的方法
+     * @author : 周兴
+     * @date : 2024/1/19
+     */
+    $t(name) {
+      if (this.data.$t[name]) {
+        return this.data.$t[name];
+      } else {
+        return name;
+      }
+    },
   },
 })

+ 6 - 3
components/dkbusiness/dk-dropdown-menu/dk-dropdown-menu.wxml

@@ -6,17 +6,20 @@
     </van-dropdown-item>
   </van-dropdown-menu>
   <!-- 多选 -->
-  <dk-side-pull-menu show_p="{{dropDownFlag}}" searchForm="{{searchForm}}" bind:clearSearchForm="clearSearchForm" bind:doSearchData="doSearchData" bind:onClose="mutiCloseAll">
+  <dk-muti-dropdown-item show="{{dropDownFlag}}"  typeName="{{dropType}}" bind:muticommit='mutiSearchAll' bind:muticlose='mutiCloseAll'></dk-muti-dropdown-item>
+  <!-- 筛选 -->
+  <dk-side-pull-menu show_p="{{pickFlag}}" searchForm="{{searchForm}}" bind:clearSearchForm="clearSearchForm" bind:doSearchData="doSearchData" bind:onClose="mutiCloseAll">
     <view wx:for="{{pullMSelectMenuList}}" data-index="{{index}}" data-item="{{item}}">
       <dk-label-multiple-select id="{{item.code}}" show="{{dropDownFlag}}" typeName="{{item.typeName}}" bind:onClickTag="onClickTag"></dk-label-multiple-select>
     </view>
     <van-cell-group wx:if="{{pullOtherMenuList != null && pullOtherMenuList.length > 0}}">
       <view wx:for="{{pullOtherMenuList}}" data-index="{{index}}" data-item="{{item}}">
-        <van-field wx:if="{{!item.dataType || item.dataType == 'number'}}" border="{{ false }}" input-align="right" bind:change="handleFieldChange" label-class="title-class" type="{{item.dataType}}" input-class="value-class" value="{{searchForm[item.code]}}" label="跟进次数" data-key="{{item.code}}" placeholder="请输入跟进次数" right-icon="arrow" />
-        <van-cell wx:if="{{item.dataType == 'date'}}" value-class="{{searchForm[item.code]?'cell-value-class':'cell-value-class-no-select'}}" value="{{searchForm[item.code] ? searchForm[item.code] :'请选择跟进提醒' }}" is-link border="{{ false }}" title-class="title-class" title="跟进提醒" data-key="{{item.code}}" bind:click="onClickDate"></van-cell>
+        <van-field wx:if="{{!item.dataType || item.dataType == 'number'}}" border="{{ false }}" input-align="right" bind:change="handleFieldChange" label-class="title-class" type="{{item.dataType}}" input-class="value-class" value="{{searchForm[item.code]}}" label="{{$t[item.code]}}" data-key="{{item.code}}" placeholder="{{$t['inputWords'] }}{{$t[item.code]}}" right-icon="arrow" />
+        <van-cell wx:if="{{item.dataType == 'date'}}" title-width="150rpx" value-class="{{searchForm[item.code]?'cell-value-class':'cell-value-class-no-select'}}" value="{{searchForm[item.code] ? searchForm[item.code] :($t['inputWords'] + $t[item.code] )}}" is-link border="{{ false }}" title-class="title-class" title="{{$t[item.code]}}" data-key="{{item.code}}" bind:click="onClickDate"></van-cell>
       </view>
     </van-cell-group>
   </dk-side-pull-menu>
 
   <dk-dropdown-date-day show="{{dropDateFlag}}" bind:dateCommit="pickDateCommit"></dk-dropdown-date-day>
+
 </view>

+ 4 - 3
i18n/zh-CN.js

@@ -5,17 +5,18 @@ const button = {
 
 // 列
 const columns = {
-  test:'测试'
+  test:'测试',
+  followCount:'跟进次数',
+  nextFollowTime:'跟进提醒'
 }
 
 // 提示信息
 const messages = {
-
 }
 
 // 其他信息
 const others = {
-
+  inputWords: '请输入',
 }
 
 module.exports  = {

+ 16 - 1
mixins/index.js

@@ -31,7 +31,9 @@ module.exports = {
         // 查询条件
         searchContent:[],
         // 查询条件实体
-        searchForm: null,
+        searchForm: {},
+        // 大查询文本
+        searchText:null,
         // 保存参数
         params:null,
         // 查询结果集
@@ -56,6 +58,14 @@ module.exports = {
      * @date : 2024/1/19
      */
     searchData(e) {
+        console.log('e3',this.data.searchForm);
+        console.log('e4',e,this.data.searchForm);
+        // 说明是查询条件中调用的,todo 展示实现不了双向绑定
+        if(e.detail.trigger){
+            this.setData({
+                searchForm:e.detail.searchForm
+            })
+        }
         // 加载中
         this.setData({
             loading: true
@@ -114,11 +124,16 @@ module.exports = {
      */
     _setSearchParams(){
         let params = this.data.searchForm?this.data.searchForm:{};
+        if(this.data.searchText){
+            params.searchText = this.data.searchText;
+        }
         // 如果需要分页
         if(this.data.pageFlag){
             params.pageSize = this.data.pageInfo.pageSize;
             params.currentPage = this.data.pageInfo.currentPage;
         }
+        console.log('p',params);
+
         if(this.setSearchParams){
             // 调用参数赋值
             params = this.setSearchParams(params);