jeecg-boot-vue3/mock/demo/select-demo.ts

38 lines
901 B
TypeScript
Raw Permalink Normal View History

2021-10-20 06:32:09 +00:00
import { MockMethod } from 'vite-plugin-mock';
2022-03-10 01:47:29 +00:00
import { resultSuccess, baseUrl } from '../_util';
2021-10-20 06:32:09 +00:00
2022-03-10 01:47:29 +00:00
const demoList = (keyword, count = 20) => {
2021-10-20 06:32:09 +00:00
const result = {
list: [] as any[],
};
2022-03-10 01:47:29 +00:00
for (let index = 0; index < count; index++) {
2024-03-06 08:33:03 +00:00
//根据搜索关键词做一下匹配
let name = `选项${index}`;
if(keyword && name.indexOf(keyword)!=-1){
result.list.push({
name: `选项${index}`,
id: `${index}`,
});
}else if(!keyword){
result.list.push({
name: `选项${index}`,
id: `${index}`,
});
}
2021-10-20 06:32:09 +00:00
}
return result;
};
export default [
{
2022-03-10 01:47:29 +00:00
url: `${baseUrl}/select/getDemoOptions`,
2021-10-20 06:32:09 +00:00
timeout: 1000,
method: 'get',
response: ({ query }) => {
2022-09-22 06:05:12 +00:00
const { keyword,count} = query;
2023-09-20 02:17:09 +00:00
console.log("查询条件:", keyword);
2022-09-22 06:05:12 +00:00
return resultSuccess(demoList(keyword,count));
2021-10-20 06:32:09 +00:00
},
},
] as MockMethod[];