Commit cf3b49f3c3b11a6037a2fedfb4e008f4c28a7c19
1 parent
8d8c50ea
支持搜索
Showing
1 changed file
with
18 additions
and
2 deletions
src/views/schedulingAssociateNum/Attendance/scheduling/index.vue
| 1 | <template> | 1 | <template> |
| 2 | <div> | 2 | <div> |
| 3 | - <el-select v-model="childrenItemValue" value-key="id" placeholder="选着考勤规则" @change="handleUpdate"> | 3 | + <el-select v-model="childrenItemValue" value-key="id" placeholder="选着考勤规则" @change="handleUpdate" remote remote-method="remoteMethod" :loading="loading" filterable style="width: 300px"> |
| 4 | <el-option v-for="item in schedulingOptions" :key="item.id" :label="item.ruleName + '(' + item.rangeTime + ')'" | 4 | <el-option v-for="item in schedulingOptions" :key="item.id" :label="item.ruleName + '(' + item.rangeTime + ')'" |
| 5 | :value="item" /> | 5 | :value="item" /> |
| 6 | </el-select> | 6 | </el-select> |
| @@ -20,10 +20,26 @@ const props = defineProps({ | @@ -20,10 +20,26 @@ const props = defineProps({ | ||
| 20 | require: true | 20 | require: true |
| 21 | } | 21 | } |
| 22 | }) | 22 | }) |
| 23 | - | 23 | +const loading = ref(false); |
| 24 | +const options = ref([]) | ||
| 24 | const childrenItemValue = ref(props.schedulingNowValue) | 25 | const childrenItemValue = ref(props.schedulingNowValue) |
| 26 | +const getOptions = (query) => { | ||
| 27 | + return props.schedulingOptions.filter(item => item.ruleName.toLowerCase().includes(query.toLowerCase())); | ||
| 28 | +} | ||
| 25 | const handleUpdate = (val) => { | 29 | const handleUpdate = (val) => { |
| 26 | } | 30 | } |
| 31 | +const remoteMethod = (query) => { // query是输入的关键词 | ||
| 32 | + if (query !== '') { | ||
| 33 | + loading.value = true; // 开始加载数据时设置loading为true | ||
| 34 | + // 模拟异步获取数据,实际应用中应该是调用API获取数据 | ||
| 35 | + setTimeout(() => { | ||
| 36 | + options.value = getOptions(query); // 获取数据后更新options和loading状态 | ||
| 37 | + loading.value = false; // 数据加载完成,设置loading为false | ||
| 38 | + }, 200); // 假设200ms后获取到数据,实际应用中应该是根据API响应时间来调整这个值。 | ||
| 39 | + } else { | ||
| 40 | + this.options = []; // 如果查询为空,则清空选项列表。 | ||
| 41 | + } | ||
| 42 | +} | ||
| 27 | 43 | ||
| 28 | defineExpose({ | 44 | defineExpose({ |
| 29 | childrenItemValue | 45 | childrenItemValue |