feat:硬件分组查询

This commit is contained in:
dzc committed 2025-01-14 17:27:15 +08:00
1 parent 3262e2cbd2
commit 6e32c1d4d7
9 files changed
+433 -19

No files matched your search

+81
View File
@@ -0,0 +1,81 @@
<template>
<el-select
style="width: 100%"
v-model="state.selectId"
:placeholder="props.placeholder"
clearable
remote-show-suffix
filterable
remote
:remote-method="remoteSearch"
:loading="state.loading"
@visible-change="(e: boolean) => e && getOptions()"
>
<el-option v-for="v in state.options" :key="v.id" :label="`${v.name}`" :value="v.id">
<div class="flex items-center">
<div class="color-primary">{{ v.name }}</div>
</div>
</el-option>
</el-select>
</template>
<script setup lang="ts" name="select-hard-group">
import { reactive, defineModel, withDefaults, defineProps } from "vue"
import * as hardGroup from "/@/api/hard/hard-group"
const selectId = defineModel()
export type Props = {
placeholder?: string
}
const props = withDefaults(defineProps<Props>(), {
placeholder: "请选择",
})
const queryForm = reactive<any>({
name: null,
current: 1,
size: 10,
})
const state = reactive<any>({
loading: true,
selectId: selectId,
options: [],
})
watch(
selectId,
(newVal, oldValue) => {
if (newVal == oldValue) return
state.selectId = newVal
getOptions()
},
{ immediate: true },
)
async function getOptions() {
try {
state.loading = true
const _pa = {
...queryForm,
}
const { data } = await hardGroup.pageJoin(_pa)
state.options = data.records ?? []
} finally {
setTimeout(() => (state.loading = false), 500)
}
}
function remoteSearch(params: string) {
if (params != queryForm.name) {
queryForm.name = params
getOptions()
}
}
function clear() {
state.selectId = null
getOptions()
}
</script>