|
@@ -1,48 +1,120 @@
|
|
|
<template>
|
|
|
- <div class="d-flex">
|
|
|
- <companyIndustry positionIndexPage @inputChange="val => inputChange(ids.industryIds, val)"></companyIndustry>
|
|
|
- <positionType positionIndexPage @inputChange="val => inputChange(ids.positionId, val)"></positionType>
|
|
|
- <JobType positionIndexPage @inputChange="val => inputChange(ids.jobType, val)"></JobType>
|
|
|
- <expType positionIndexPage @inputChange="val => inputChange(ids.expType, val)"></expType>
|
|
|
- <payScope positionIndexPage @inputChange="val => inputChange(ids.payType, val)"></payScope>
|
|
|
- <educationType positionIndexPage :isSingle="false" @inputChange="val => inputChange(ids.scale, val)"></educationType>
|
|
|
- <scale positionIndexPage @inputChange="val => inputChange(ids.eduType, val)"></scale>
|
|
|
- <financingStatus positionIndexPage @inputChange="val => inputChange(ids.financingStatus, val)"></financingStatus>
|
|
|
+ <div>
|
|
|
+ <div class="d-flex">
|
|
|
+ <template v-for="item in list" :key="item.key">
|
|
|
+ <component
|
|
|
+ :is="item.path"
|
|
|
+ :idName="item.key"
|
|
|
+ :title="item.title"
|
|
|
+ :isSingle="item.isSingle"
|
|
|
+ :dictName="item.dictShow"
|
|
|
+ :info="item"
|
|
|
+ @inputChange="inputChange"
|
|
|
+ ></component>
|
|
|
+ </template>
|
|
|
+ </div>
|
|
|
+ <div v-if="showSelectList?.length">
|
|
|
+ <div style="margin-top: 20px; border-top: 1px solid #eee;">
|
|
|
+ <div v-for="item in showSelectList" :key="item.key" style="margin: 8px 8px 8px 0px;">
|
|
|
+ <template v-if="item.checkedItems?.length">
|
|
|
+ <span style="color: #999;">{{ item.title }}:</span>
|
|
|
+ <v-btn
|
|
|
+ v-for="(val, index) in item.checkedItems" :key="item.key + index"
|
|
|
+ class="mr-3 py-0 px-2"
|
|
|
+ density="comfortable"
|
|
|
+ color="primary" variant="tonal"
|
|
|
+ v-bind="props"
|
|
|
+ >
|
|
|
+ {{ val.text }}
|
|
|
+ <v-icon class="ml-1" style="margin-top: 1px;" @click="deleteChip(item, val)">mdi-close</v-icon>
|
|
|
+ </v-btn>
|
|
|
+ </template>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="clearFilterCriteria" @click="emits('reset')">{{ $t('common.clearFilterCriteria') }}</div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</template>
|
|
|
<script setup>
|
|
|
-import companyIndustry from './conditionFilter/companyIndustry.vue'
|
|
|
-import positionType from './conditionFilter/positionType.vue'
|
|
|
-import JobType from './conditionFilter/JobType.vue'
|
|
|
-import expType from './conditionFilter/expType.vue'
|
|
|
-import payScope from './conditionFilter/payScope.vue'
|
|
|
-import educationType from './conditionFilter/educationType.vue'
|
|
|
-import scale from './conditionFilter/scale.vue'
|
|
|
-import financingStatus from './conditionFilter/financingStatus.vue'
|
|
|
-import { ref } from 'vue'
|
|
|
+import { useRoute } from 'vue-router'; const route = useRoute()
|
|
|
+import { watch, ref, shallowRef } from 'vue'
|
|
|
+import { filterList, getItemObj } from './dict'
|
|
|
defineOptions({name: 'retrieval-components-conditionFilter'})
|
|
|
-const emits = defineEmits(['change'])
|
|
|
-const ids = ref({
|
|
|
- industryIds: 'industryIds',
|
|
|
- positionId: 'positionId',
|
|
|
- jobType: 'jobType',
|
|
|
- expType: 'expType',
|
|
|
- payType: 'payType',
|
|
|
- eduType: 'eduType',
|
|
|
- scale: 'scale',
|
|
|
- financingStatus: 'financingStatus',
|
|
|
+const emits = defineEmits(['change', 'reset'])
|
|
|
+const props = defineProps({
|
|
|
+ showFilterList: { // 职位检索
|
|
|
+ type: [Array, String],
|
|
|
+ default: 'all'
|
|
|
+ },
|
|
|
})
|
|
|
+const list = shallowRef(props.showFilterList === 'all' ? filterList : props.showFilterList.map(e => {
|
|
|
+ const item = filterList.find(i => i.key === e.key)
|
|
|
+ return item ? { ...item, ...e } : ''
|
|
|
+}).filter(Boolean))
|
|
|
|
|
|
-const inputChange = (key, arr) => {
|
|
|
- const str = arr.length ? arr.join('_') : ''
|
|
|
+const inputChange = ({ idName: key, values }) => {
|
|
|
+ const str = values.length ? values.join('_') : ''
|
|
|
+ if (!key) return
|
|
|
emits('change', key, str)
|
|
|
}
|
|
|
|
|
|
-// const clearFun = () => {
|
|
|
-// Object.keys(ids).forEach(key => emits('change', key, ''))
|
|
|
-// }
|
|
|
+const deleteChip = (item, val) => { // 删除某个标签-更新路由 val结构:{ text:, value: }
|
|
|
+ const ids = item?.checkedItems?.reduce((newArr, e) => {
|
|
|
+ if (e.value !== val.value) newArr.push(e.value)
|
|
|
+ return newArr
|
|
|
+ }, []) || []
|
|
|
+ inputChange({ idName: item.key, values: ids, isDel: true })
|
|
|
+}
|
|
|
|
|
|
-defineExpose({
|
|
|
- ids
|
|
|
-})
|
|
|
-</script>
|
|
|
+const showSelectList = ref([])
|
|
|
+// 添加
|
|
|
+const assembleList = ({ key, idsStr }) => {
|
|
|
+ const ids = idsStr.split('_') || []
|
|
|
+ const obj = getItemObj({ key, ids })
|
|
|
+ if (!obj) return
|
|
|
+ const index = showSelectList.value.findIndex(i => i.key === key)
|
|
|
+ if (index === -1) showSelectList.value.push(obj)
|
|
|
+ else showSelectList.value[index] = obj
|
|
|
+}
|
|
|
+
|
|
|
+watch(
|
|
|
+ () => route.query,
|
|
|
+ (newVal = {}, oldVal = {}) => {
|
|
|
+ // console.log('oldVal', oldVal); console.log('newVal', newVal)
|
|
|
+ // 回显已选筛选-标签
|
|
|
+ if (!Object.keys(newVal).length) { // 路由没有参数
|
|
|
+ showSelectList.value = []
|
|
|
+ }
|
|
|
+ else if (!Object.keys(oldVal).length && Object.keys(newVal).length) { // 只有新加参数
|
|
|
+ Object.keys(newVal).forEach(key => {
|
|
|
+ assembleList({ key, idsStr: newVal[key] })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ else if (Object.keys(newVal).length && Object.keys(oldVal).length) { //路由参数更新
|
|
|
+ Object.keys(newVal).forEach(key => {
|
|
|
+ if (newVal[key] === oldVal[key]) return
|
|
|
+ assembleList({ key, idsStr: newVal[key] })
|
|
|
+ })
|
|
|
+ // showSelectList去掉newVal里面没有的key
|
|
|
+ showSelectList.value = showSelectList.value.filter(item => Object.keys(newVal).includes(item.key))
|
|
|
+ }
|
|
|
+ },
|
|
|
+ { immediate: true },
|
|
|
+ { deep: true }
|
|
|
+)
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.clearFilterCriteria {
|
|
|
+ cursor: pointer;
|
|
|
+ line-height: 28px;
|
|
|
+ margin-right: 12px;
|
|
|
+ font-size: 14px;
|
|
|
+ margin-top: 4px;
|
|
|
+ color: var(--color-999);
|
|
|
+ text-align: right;
|
|
|
+ &:hover {
|
|
|
+ color: var(--v-primary-base);
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|