53 lines
1.7 KiB
Vue
53 lines
1.7 KiB
Vue
/**
|
||
* Jeecg QueryGenerator 模糊查询工具:
|
||
* - 普通字段:值两侧加 * 转为 LIKE
|
||
* - 关键字多字段 OR:走 superQueryParams
|
||
*/
|
||
|
||
/** 给指定字符串查询字段追加 *value*(已含 * 则不重复处理) */
|
||
export function applyJeecgLikeQuery(params: Recordable, fields: string[]): Recordable {
|
||
if (!params || !fields?.length) {
|
||
return params;
|
||
}
|
||
for (const field of fields) {
|
||
const raw = params[field];
|
||
if (raw == null || raw === '') {
|
||
continue;
|
||
}
|
||
const text = String(raw).trim();
|
||
if (!text || text.includes('*')) {
|
||
continue;
|
||
}
|
||
params[field] = `*${text}*`;
|
||
}
|
||
return params;
|
||
}
|
||
|
||
/** 构造多字段 OR 模糊高级查询参数 */
|
||
export function buildOrLikeSuperQuery(fields: string[], keyword: string): {
|
||
superQueryMatchType: string;
|
||
superQueryParams: string;
|
||
} | null {
|
||
const kw = keyword?.trim();
|
||
if (!kw || !fields?.length) {
|
||
return null;
|
||
}
|
||
const conditions = fields.map((field) => ({
|
||
field,
|
||
rule: 'like',
|
||
val: kw,
|
||
}));
|
||
return {
|
||
superQueryMatchType: 'or',
|
||
superQueryParams: encodeURI(JSON.stringify(conditions)),
|
||
};
|
||
}
|
||
|
||
/** 密炼物料文本查询字段 */
|
||
export const MIXER_MATERIAL_LIKE_FIELDS = ['materialCode', 'materialName', 'erpCode', 'materialDesc', 'aliasName'];
|
||
|
||
/** 胶料文本查询字段(已去掉胶料编码) */
|
||
//update-begin---author:jiangxh ---date:20260729 for:【选料弹窗】胶料关键字查询去掉编码-----------
|
||
export const RUBBER_MATERIAL_LIKE_FIELDS = ['materialName', 'erpCode', 'aliasName', 'shortName'];
|
||
//update-end---author:jiangxh ---date:20260729 for:【选料弹窗】胶料关键字查询去掉编码-----------
|