模具 本地过滤

This commit is contained in:
xielue 2023-10-04 10:33:30 +08:00
parent 9205dd80c6
commit 0c4db9adc8
3 changed files with 45 additions and 26 deletions

View File

@ -98,7 +98,10 @@ export default {
data() { data() {
return { return {
showSheetNameSelector: false, excelSheetName: '', excelSheetNames: [], showSheetNameSelector: false,
excelSheetName: '',
excelSheetNames: [],
rowFilters:[],
bindSearchData: null bindSearchData: null
}; };
@ -317,6 +320,7 @@ export default {
// //
getSearchParms() { // getSearchParms() { //
var rules = []; // var rules = []; //
this.rowFilters = [];
let findMode = k => { // let findMode = k => { //
for (let i in this.options.searchRules) { // for (let i in this.options.searchRules) { //
if (this.options.searchRules[i].key == k) return this.options.searchRules[i].mode; // if (this.options.searchRules[i].key == k) return this.options.searchRules[i].mode; //
@ -329,7 +333,12 @@ export default {
if (value === 0 || value) { // if (value === 0 || value) { //
let mode = findMode(key); // let mode = findMode(key); //
if (typeof (mode) == "function") { 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 { else {
if (mode == "like") { // if (mode == "like") { //
@ -383,7 +392,9 @@ export default {
params.end_time = this.end_time; // params.end_time = this.end_time; //
return this.$mk.getPagedData({ return this.$mk.getPagedData({
url: this.options.actions.getList, url: this.options.actions.getList,
data: params data: params,
listFieldName : this.options.listFieldName,
rowFilters:this.rowFilters
}); });
}, },

View File

@ -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) { if (useBigInt) {
config = config || {}; config = config || {};
@ -129,6 +129,20 @@ export default {
} }
return; 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<rowFilters.length;i++){
let f = rowFilters[i];
if(!f(row)){
return false;
}
}
return true;
});
console.log( JSON.stringify(result.data[listFieldName]))
}
// console.log(result.data) // console.log(result.data)
resolve(result.data); // 返回成功 resolve(result.data); // 返回成功

View File

@ -75,29 +75,23 @@ export default {
}, },
// //
searchRules: [ searchRules: [
{ {
key: 'progress', mode: ({ value, key }) => { key: 'production_status', mode: ({ value }) => {
if (value == 1.5) { return {
return [ filter :(row)=> { return row.production_status == value }
{ }
column: key, }
mode: ">", },
value: "0" {
}, key: 'progress', mode: ({ value }) => {
{ if (value == 1.5) {
column: key, return {
mode: "<", filter :(row)=> { return row.progress > 0 && row.progress < 1}
value: "1" }
} }
] return {
} filter :(row)=> { return row.progress == value }
return [
{
column: key,
mode: "=",
value: value+''
} }
]
} }
} }