From 0c4db9adc8bf321f051968d36765379dc348cddf Mon Sep 17 00:00:00 2001 From: xielue Date: Wed, 4 Oct 2023 10:33:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A8=A1=E5=85=B7=20=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E8=BF=87=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/application/mk/basic-pages/list.vue | 17 +++++++++-- src/application/mk/libs/function/apis.js | 16 +++++++++- src/pages/Middle/Mold/MoldOrder/List.vue | 38 ++++++++++-------------- 3 files changed, 45 insertions(+), 26 deletions(-) diff --git a/src/application/mk/basic-pages/list.vue b/src/application/mk/basic-pages/list.vue index 3b23787..3990daf 100644 --- a/src/application/mk/basic-pages/list.vue +++ b/src/application/mk/basic-pages/list.vue @@ -98,7 +98,10 @@ export default { data() { return { - showSheetNameSelector: false, excelSheetName: '', excelSheetNames: [], + showSheetNameSelector: false, + excelSheetName: '', + excelSheetNames: [], + rowFilters:[], bindSearchData: null }; @@ -317,6 +320,7 @@ export default { // 获取搜索参数 getSearchParms() { // 获取搜索参数 var rules = []; // 定义搜索参数 + this.rowFilters = []; let findMode = k => { // 查找搜索模式 for (let i in this.options.searchRules) { // 遍历搜索规则 if (this.options.searchRules[i].key == k) return this.options.searchRules[i].mode; // 如果找到了就返回搜索模式 @@ -329,7 +333,12 @@ export default { if (value === 0 || value) { // 如果有值 let mode = findMode(key); // 获取搜索模式 if (typeof (mode) == "function") { - rules = [...rules,mode({value:value,key:key})]; + let v = mode({value:value,key:key}); + if(v.rules){ + rules = [...rules,v.rules]; + }else if(v.filter){ + this.rowFilters.push(v.filter); + } } else { if (mode == "like") { // 如果是模糊搜索 @@ -383,7 +392,9 @@ export default { params.end_time = this.end_time; // 结束时间 return this.$mk.getPagedData({ url: this.options.actions.getList, - data: params + data: params, + listFieldName : this.options.listFieldName, + rowFilters:this.rowFilters }); }, diff --git a/src/application/mk/libs/function/apis.js b/src/application/mk/libs/function/apis.js index f6b9668..9004821 100644 --- a/src/application/mk/libs/function/apis.js +++ b/src/application/mk/libs/function/apis.js @@ -92,7 +92,7 @@ export default { }, // 获取分页数据 - getPagedData: function ({ url, method = 'post', data, callback, config,useBigInt }) { // 获取分页数据 默认post请求 + getPagedData: function ({ url, method = 'post', data, callback, config,useBigInt,rowFilters,listFieldName }) { // 获取分页数据 默认post请求 if (useBigInt) { config = config || {}; @@ -129,6 +129,20 @@ export default { } return; } + + if(rowFilters &&rowFilters.length && listFieldName && result.data && result.data[listFieldName] && result.data[listFieldName].length){ + console.log( JSON.stringify(result.data[listFieldName])) + result.data[listFieldName] = result.data[listFieldName].filter((row)=>{ + for(let i =0;i { - if (value == 1.5) { - return [ - { - column: key, - mode: ">", - value: "0" - }, - { - column: key, - mode: "<", - value: "1" - } - ] - } - return [ - { - column: key, - mode: "=", - value: value+'' + { + key: 'production_status', mode: ({ value }) => { + return { + filter :(row)=> { return row.production_status == value } + } + } + }, + { + key: 'progress', mode: ({ value }) => { + if (value == 1.5) { + return { + filter :(row)=> { return row.progress > 0 && row.progress < 1} + } + } + return { + filter :(row)=> { return row.progress == value } } - ] } }