模具 本地过滤
This commit is contained in:
parent
9205dd80c6
commit
0c4db9adc8
|
|
@ -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
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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); // 返回成功
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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+''
|
|
||||||
}
|
}
|
||||||
]
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue