2026-06-27 08:55:33 +08:00
|
|
|
|
<script setup lang="ts">
|
2026-06-29 09:53:24 +08:00
|
|
|
|
import { computed, onMounted, ref } from 'vue';
|
2026-07-02 16:34:08 +08:00
|
|
|
|
import { FEEDBACK_STATUS_DICT_CODE } from '@/constants/dict';
|
2026-06-29 09:53:24 +08:00
|
|
|
|
import { fetchGetUserSimpleList } from '@/service/api';
|
2026-07-02 16:34:08 +08:00
|
|
|
|
import { useDict } from '@/hooks/business/dict';
|
2026-06-27 08:55:33 +08:00
|
|
|
|
import TableSearchFields, { type SearchField } from '@/components/custom/table-search-fields.vue';
|
|
|
|
|
|
|
|
|
|
|
|
defineOptions({ name: 'FeedbackSearch' });
|
|
|
|
|
|
|
|
|
|
|
|
const emit = defineEmits<{
|
|
|
|
|
|
reset: [];
|
|
|
|
|
|
search: [];
|
|
|
|
|
|
}>();
|
|
|
|
|
|
|
|
|
|
|
|
const model = defineModel<Api.Feedback.FeedbackSearchParams>('model', { required: true });
|
|
|
|
|
|
|
2026-06-29 09:53:24 +08:00
|
|
|
|
// 提交人下拉选项(全员简易列表;value 取用户 id,ID 铁律 string)
|
|
|
|
|
|
const userOptions = ref<{ label: string; value: string }[]>([]);
|
2026-07-02 16:34:08 +08:00
|
|
|
|
const { dictOptions: statusOptions } = useDict(FEEDBACK_STATUS_DICT_CODE);
|
2026-06-29 09:53:24 +08:00
|
|
|
|
|
2026-07-02 16:34:08 +08:00
|
|
|
|
// 分类保留在左侧分面;搜索区补充标题关键词、提交人、状态
|
2026-06-29 09:53:24 +08:00
|
|
|
|
const fields = computed<SearchField[]>(() => [
|
|
|
|
|
|
{ key: 'title', label: '标题', type: 'input', placeholder: '请输入标题关键词' },
|
|
|
|
|
|
{
|
|
|
|
|
|
key: 'creator',
|
|
|
|
|
|
label: '提交人',
|
|
|
|
|
|
type: 'select',
|
|
|
|
|
|
placeholder: '请选择提交人',
|
|
|
|
|
|
filterable: true,
|
|
|
|
|
|
options: userOptions.value
|
2026-07-02 16:34:08 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
key: 'status',
|
|
|
|
|
|
label: '状态',
|
|
|
|
|
|
type: 'select',
|
|
|
|
|
|
placeholder: '请选择状态',
|
|
|
|
|
|
options: statusOptions.value
|
2026-06-29 09:53:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
async function loadUserOptions() {
|
|
|
|
|
|
const { data, error } = await fetchGetUserSimpleList();
|
|
|
|
|
|
if (!error && data) {
|
|
|
|
|
|
userOptions.value = data.map(item => ({ label: item.nickname, value: item.id }));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-06-27 08:55:33 +08:00
|
|
|
|
|
|
|
|
|
|
function reset() {
|
|
|
|
|
|
emit('reset');
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function search() {
|
|
|
|
|
|
// 输入期不实时 trim(避免受控 input 吃掉词间空格);提交前规整一次,空串归一为 undefined
|
|
|
|
|
|
model.value.title = model.value.title?.trim() || undefined;
|
|
|
|
|
|
emit('search');
|
|
|
|
|
|
}
|
2026-06-29 09:53:24 +08:00
|
|
|
|
|
|
|
|
|
|
onMounted(loadUserOptions);
|
2026-06-27 08:55:33 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<template>
|
2026-06-29 09:53:24 +08:00
|
|
|
|
<TableSearchFields v-model="model" :fields="fields" :columns="4" @reset="reset" @search="search" />
|
2026-06-27 08:55:33 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped></style>
|