Files
tuanwei-admin/src/views/oa/task_bak/components/search.vue
T
南宁网宿科技 13bed2bafb Initial commit
2023-06-03 23:57:39 +08:00

125 lines
3.1 KiB
Vue

<!-- 搜索表单 -->
<template>
<a-space :size="10" style="flex-wrap: wrap">
<a-button type="primary" class="ele-btn-icon" @click="add">
<template #icon>
<plus-outlined />
</template>
<span>新建</span>
</a-button>
<a-button
danger
type="primary"
class="ele-btn-icon"
:disabled="selection.length === 0"
@click="removeBatch"
>
<template #icon>
<delete-outlined />
</template>
<span>批量删除</span>
</a-button>
<a-input-search
allow-clear
placeholder="请输入关键词"
v-model:value="searchText"
@pressEnter="search"
@search="search"
>
<template #addonBefore>
<a-select v-model:value="type" style="width: 100px; margin: -5px -12px">
<a-select-option value="keywords">模糊搜索</a-select-option>
<a-select-option value="taskId">工单号</a-select-option>
<!-- <a-select-option value="name">工单标题</a-select-option>-->
<!-- <a-select-option value="promoter">发起人ID</a-select-option>-->
<!-- <a-select-option value="commander">受理人ID</a-select-option>-->
</a-select>
</template>
</a-input-search>
<a-button @click="reload">重置</a-button>
</a-space>
</template>
<script lang="ts" setup>
import useSearch from '@/utils/use-search';
import type { CustomerParam } from '@/api/oa/customer/model';
import { ref, watch } from 'vue';
import { TaskParam } from '@/api/oa/task/model';
import { assignObject } from 'ele-admin-pro';
import {
PlusOutlined,
EditOutlined,
SearchOutlined,
DeleteOutlined,
UpSquareOutlined,
DownSquareOutlined
} from '@ant-design/icons-vue';
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: [];
}>(),
{}
);
const emit = defineEmits<{
(e: 'search', where?: CustomerParam): void;
(e: 'add'): void;
(e: 'remove'): void;
}>();
// 表单数据
const { where } = useSearch<TaskParam>({
taskId: undefined,
name: undefined,
userId: undefined,
nickname: undefined
});
// 下来选项
const type = ref('keywords');
// 搜索内容
const searchText = ref('');
/* 搜索 */
const search = () => {
assignObject(where, {});
if (type.value == 'taskId' && Number(searchText.value) > 0) {
where.taskId = Number(searchText.value);
}
if (type.value == 'name') {
where.name = searchText.value;
}
if (type.value == 'promoter') {
where.promoter = Number(searchText.value);
}
if (type.value == 'commander') {
where.commander = Number(searchText.value);
}
if (type.value == 'keywords') {
where.keywords = searchText.value;
}
emit('search', where);
};
// 新增
const add = () => {
emit('add');
};
// 批量删除
const removeBatch = () => {
emit('remove');
};
const reload = () => {
// 刷新当前路由
emit('search', where);
};
watch(
() => props.selection,
() => {}
);
</script>