|
@@ -36,11 +36,15 @@
|
|
|
<script setup>
|
|
|
import { getDict } from '@/hooks/web/useDictionaries'
|
|
|
import { ref } from 'vue'
|
|
|
-import { useRoute } from 'vue-router'
|
|
|
+// import { useRoute } from 'vue-router'
|
|
|
import Snackbar from '@/plugins/snackbar'
|
|
|
defineOptions({ name:'common-components-industryTypeCard'})
|
|
|
const emits = defineEmits(['handleClickIndustry'])
|
|
|
const props = defineProps({
|
|
|
+ limit: { // 限制最大可选择数量, 不限制传false或者0
|
|
|
+ type: [Number, Boolean],
|
|
|
+ default: 3
|
|
|
+ },
|
|
|
select: {
|
|
|
type: Array,
|
|
|
default: () => []
|
|
@@ -55,8 +59,8 @@ const props = defineProps({
|
|
|
}
|
|
|
})
|
|
|
|
|
|
-const route = useRoute()
|
|
|
-const routeQuery = route?.query
|
|
|
+// const route = useRoute()
|
|
|
+// const routeQuery = route?.query
|
|
|
|
|
|
let items = ref()
|
|
|
let idChecked = ref([])
|
|
@@ -70,18 +74,20 @@ getDict('industryTreeData', null, 'industryTreeData').then(({ data }) => {
|
|
|
data = data?.length && data || []
|
|
|
items.value = data
|
|
|
})
|
|
|
-if (routeQuery && routeQuery.industryIds) {
|
|
|
- idChecked.value = routeQuery.industryIds.split('_')
|
|
|
-}
|
|
|
+// if (routeQuery && routeQuery.industryIds) {
|
|
|
+// idChecked.value = routeQuery.industryIds.split('_')
|
|
|
+// }
|
|
|
|
|
|
// 设置选中ids
|
|
|
const handleClick = (val) => {
|
|
|
- const obj = idChecked.value.includes(val.id)
|
|
|
- if (!obj) {
|
|
|
- if (props.showSelect && currentSelect.value.length === 3) return Snackbar.warning('最多可选三个行业')
|
|
|
+ const isExist = idChecked.value.includes(val.id)
|
|
|
+ if (!isExist) {
|
|
|
+ // 添加
|
|
|
+ if (props.limit === currentSelect.value.length) return Snackbar.warning(`最多可选${props.limit}个行业`)
|
|
|
currentSelect.value.push(val)
|
|
|
idChecked.value.push(val.id)
|
|
|
} else {
|
|
|
+ // 删除
|
|
|
currentSelect.value = currentSelect.value.filter(e => e.id !== val.id)
|
|
|
idChecked.value = idChecked.value.filter(e => e !== val.id)
|
|
|
}
|