[feat] 重构客户信息和供应商信息页面的搜索栏- 移除原有的冗余代码和复杂逻辑

- 新增 SearchBarEx 组件用于通用搜索栏
- 优化搜索栏的显示和交互逻辑
- 统一处理搜索、重置、新增和导出操作
This commit is contained in:
hhyykk 2024-12-20 19:44:17 +08:00
parent 4cbb3fbc31
commit 74dac2a818

View File

@ -77,16 +77,20 @@ import download from '@/utils/download'
import { ProjectTrackingApi, ProjectTrackingVO } from '@/api/pm/projecttracking'
import ProjectTrackingForm from './ProjectTrackingForm.vue'
import SearchBarEx from "@/components/SearchBar/SearchBarEx.vue";
import { CustomerApi } from "@/api/pm/customer";
import * as DeptApi from '@/api/system/dept'
import { handleTree } from '@/utils/tree'
/** 项目跟踪 列表 */
defineOptions({ name: 'ProjectTracking' })
const message = useMessage() //
const { t } = useI18n() //
const loading = ref(true) //
const list = ref<ProjectTrackingVO[]>([]) //
const total = ref(0) //
const constructionOptions = ref([]); //
const deptOptions = ref<any[]>([]) //
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
@ -103,16 +107,7 @@ const queryParams = reactive({
})
const formRef = ref()
//
const allFields = [
{ label: '项目名称', prop: 'name', component: 'el-input' },
{ label: '建设单位', prop: 'constructionName', component: 'el-input' },
{ label: '主控部门', prop: 'deptName',component: 'el-input' },
{ label: '负责人', prop: 'pmName',component: 'el-input' },
{ label: '合同额', prop: 'contractAmount', component: 'el-input' },
{ label: '业务类型', prop: 'businessType', component: 'el-select', options: getStrDictOptions(DICT_TYPE.PROJECT_TYPE).map(dict => ({ label: dict.label, value: dict.value })) },
{ label: '落地性', prop: 'landingPossibility', component: 'el-select', options: getStrDictOptions(DICT_TYPE.POSSIBILITY_OF_LANDING).map(dict => ({ label: dict.label, value: dict.value })) },
]
/** 查询列表 */
const getList = async () => {
@ -172,8 +167,54 @@ const handleExport = async () => {
} catch {}
}
const getConstructionOptions = async () => {
const resList = [];
resList.value = await CustomerApi.getCustomerList({});
resList.value.forEach((item) => {
constructionOptions.value.push({
value: item.id,
label: item.name,
});
});
}
const getDeptOptions = async () => {
deptOptions.value = handleTree(await DeptApi.getSimpleDeptList())
}
//
const allFields = [
{ label: '项目名称', prop: 'name', component: 'el-input' },
{
label: '建设单位',
prop: 'constructionId',
component: 'el-select',
options: constructionOptions.value,
},
// { label: '', prop: 'deptName',component: 'el-input' },
{
label: '主控部门',
prop: 'deptId',
component: 'el-tree-select',
props: {
data: deptOptions.value,
props: { children: 'children', label: 'name', value: 'id' },
checkStrictly: true,
filterable: true,
clearable: true,
},
},
{ label: '负责人', prop: 'pmName',component: 'el-input' },
{ label: '合同额', prop: 'contractAmount', component: 'el-input' },
{ label: '业务类型', prop: 'businessType', component: 'el-select', options: getStrDictOptions(DICT_TYPE.PROJECT_TYPE).map(dict => ({ label: dict.label, value: dict.value })) },
{ label: '落地性', prop: 'landingPossibility', component: 'el-select', options: getStrDictOptions(DICT_TYPE.POSSIBILITY_OF_LANDING).map(dict => ({ label: dict.label, value: dict.value })) },
]
/** 初始化 **/
onMounted(() => {
getList()
getConstructionOptions(); //
getDeptOptions(); //
})
</script>