|
@@ -13,7 +13,7 @@
|
|
:itemText="item.itemText"
|
|
:itemText="item.itemText"
|
|
:displayDictName="item.displayDictName"
|
|
:displayDictName="item.displayDictName"
|
|
:provideData="item.provideData || []"
|
|
:provideData="item.provideData || []"
|
|
- btnClass="mt-1"
|
|
|
|
|
|
+ btnClass="mt-2"
|
|
@inputChange="inputChange"
|
|
@inputChange="inputChange"
|
|
></component>
|
|
></component>
|
|
</template>
|
|
</template>
|
|
@@ -46,6 +46,7 @@
|
|
import { useRoute } from 'vue-router'; const route = useRoute()
|
|
import { useRoute } from 'vue-router'; const route = useRoute()
|
|
import { watch, ref, shallowRef, nextTick } from 'vue'
|
|
import { watch, ref, shallowRef, nextTick } from 'vue'
|
|
import { filterList, getItemObj } from './dict'
|
|
import { filterList, getItemObj } from './dict'
|
|
|
|
+import { getDict } from '@/hooks/web/useDictionaries'
|
|
defineOptions({name: 'retrieval-components-conditionFilter'})
|
|
defineOptions({name: 'retrieval-components-conditionFilter'})
|
|
const emits = defineEmits(['change', 'reset'])
|
|
const emits = defineEmits(['change', 'reset'])
|
|
const props = defineProps({
|
|
const props = defineProps({
|
|
@@ -118,42 +119,83 @@ const deleteChip = (item, val) => { // 删除某个标签-更新路由 val结构
|
|
inputChange({ idName: item.key, values: ids })
|
|
inputChange({ idName: item.key, values: ids })
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+let cityLevel2 = []
|
|
const showSelectList = ref([])
|
|
const showSelectList = ref([])
|
|
-// 添加
|
|
|
|
-const assembleList = ({ key, idsStr }) => {
|
|
|
|
|
|
+const assembleList = async ({ key, idsStr, isRefresh = false }) => {
|
|
|
|
+ if (isRefresh && key === 'cityId_1') {
|
|
|
|
+ const res = await getDict('areaTreeData', null, 'areaTreeData')
|
|
|
|
+ const data = res?.data?.length ? res.data : []
|
|
|
|
+ const item = data.find(e => e.id === idsStr)
|
|
|
|
+ if (item) {
|
|
|
|
+ cityLevel2 = item.children?.length? item.children : []
|
|
|
|
+ cityDeal(idsStr, key, item)
|
|
|
|
+ nextTick(() => {
|
|
|
|
+ assembleList({ key, idsStr })
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (isRefresh && key === 'cityId_2') {
|
|
|
|
+ nextTick(async () => {
|
|
|
|
+ const item = cityLevel2.find(e => String(e.id) === String(idsStr))
|
|
|
|
+ if (item) {
|
|
|
|
+ nextTick(() => {
|
|
|
|
+ cityDeal(idsStr, key, item)
|
|
|
|
+ nextTick(() => {
|
|
|
|
+ assembleList({ key, idsStr })
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ if (isRefresh && key === 'cityId_3') {
|
|
|
|
+ nextTick(() => {
|
|
|
|
+ nextTick(() => {
|
|
|
|
+ nextTick(() => {
|
|
|
|
+ assembleList({ key, idsStr })
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ // 添加
|
|
const ids = idsStr.split('_') || []
|
|
const ids = idsStr.split('_') || []
|
|
const obj = getItemObj({ key, ids, dictArr: list.value })
|
|
const obj = getItemObj({ key, ids, dictArr: list.value })
|
|
if (!obj) return
|
|
if (!obj) return
|
|
const index = showSelectList.value.findIndex(i => i.key === key)
|
|
const index = showSelectList.value.findIndex(i => i.key === key)
|
|
if (index === -1) showSelectList.value.push(obj)
|
|
if (index === -1) showSelectList.value.push(obj)
|
|
else showSelectList.value[index] = obj
|
|
else showSelectList.value[index] = obj
|
|
|
|
+ //
|
|
|
|
+ showSelectList.value = [ // 城市放在一起展示
|
|
|
|
+ ...showSelectList.value.filter(item => item.key.includes('cityId_')),
|
|
|
|
+ ...showSelectList.value.filter(item => !item.key.includes('cityId_')),
|
|
|
|
+ ]
|
|
}
|
|
}
|
|
|
|
|
|
watch(
|
|
watch(
|
|
() => route.query,
|
|
() => route.query,
|
|
(newVal = {}, oldVal = {}) => {
|
|
(newVal = {}, oldVal = {}) => {
|
|
- // console.log('oldVal', oldVal); console.log('newVal', newVal)
|
|
|
|
|
|
+ const arr = Object.keys(newVal).length ? [...Object.keys(newVal)] : null
|
|
|
|
+ const newKeyList = arr ? [ // 城市放在一起展示
|
|
|
|
+ ...arr.filter(key => key.includes('cityId_')),
|
|
|
|
+ ...arr.filter(key => !key.includes('cityId_')),
|
|
|
|
+ ] : ''
|
|
// 回显已选筛选-标签
|
|
// 回显已选筛选-标签
|
|
- if (!Object.keys(newVal).length) { // 路由没有参数
|
|
|
|
|
|
+ if (!newKeyList) { // 路由没有参数
|
|
showSelectList.value = []
|
|
showSelectList.value = []
|
|
|
|
+ list.value = list.value.filter(e => !(e.cityLevel && e.cityLevel > 1))
|
|
}
|
|
}
|
|
- else if (!Object.keys(oldVal).length && Object.keys(newVal).length) { // 只有新加参数
|
|
|
|
- Object.keys(newVal).forEach(key => {
|
|
|
|
- assembleList({ key, idsStr: newVal[key] })
|
|
|
|
|
|
+ else if (!Object.keys(oldVal).length && newKeyList) { // 只有新加参数
|
|
|
|
+ newKeyList.forEach(key => {
|
|
|
|
+ assembleList({ key, idsStr: newVal[key], isRefresh: true })
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- else if (Object.keys(newVal).length && Object.keys(oldVal).length) { //路由参数更新
|
|
|
|
- Object.keys(newVal).forEach(key => {
|
|
|
|
|
|
+ else if (newKeyList && Object.keys(oldVal).length) { //路由参数更新
|
|
|
|
+ newKeyList.forEach(key => {
|
|
if (newVal[key] === oldVal[key]) return
|
|
if (newVal[key] === oldVal[key]) return
|
|
assembleList({ key, idsStr: newVal[key] })
|
|
assembleList({ key, idsStr: newVal[key] })
|
|
})
|
|
})
|
|
// showSelectList去掉newVal里面没有的key
|
|
// showSelectList去掉newVal里面没有的key
|
|
- showSelectList.value = showSelectList.value.filter(item => Object.keys(newVal).includes(item.key))
|
|
|
|
|
|
+ showSelectList.value = showSelectList.value.filter(item => newKeyList.includes(item.key))
|
|
}
|
|
}
|
|
- showSelectList.value = [ // 城市放在一起展示
|
|
|
|
- ...showSelectList.value.filter(item => item.key.includes('cityId_')),
|
|
|
|
- ...showSelectList.value.filter(item => !item.key.includes('cityId_')),
|
|
|
|
- ]
|
|
|
|
},
|
|
},
|
|
{ immediate: true },
|
|
{ immediate: true },
|
|
{ deep: true }
|
|
{ deep: true }
|