|
@@ -10,7 +10,6 @@
|
|
|
<div
|
|
|
v-else
|
|
|
class="jobItem"
|
|
|
- :class="{'act': item.act}"
|
|
|
v-for="val in item.children" :key="val.id"
|
|
|
@click="handleClick(val)"
|
|
|
>{{ val.nameCn }}</div>
|
|
@@ -24,41 +23,35 @@
|
|
|
<script setup>
|
|
|
import { getDict } from '@/hooks/web/useDictionaries'
|
|
|
import { reactive, ref } from 'vue';
|
|
|
+import { useRoute } from 'vue-router';
|
|
|
defineOptions({ name:'common-components-industryTypeCard'})
|
|
|
-const emits = defineEmits(['inputChange'])
|
|
|
+const emits = defineEmits(['handleClickIndustry'])
|
|
|
+
|
|
|
+const route = useRoute()
|
|
|
+const routeQuery = route?.query
|
|
|
|
|
|
let items = ref()
|
|
|
+let idChecked = reactive([])
|
|
|
getDict('industryTreeData', null, 'industryTreeData').then(({ data }) => {
|
|
|
data = data?.length && data || []
|
|
|
items.value = data
|
|
|
})
|
|
|
+if (routeQuery && routeQuery.industryIds) {
|
|
|
+ idChecked = routeQuery.industryIds.split('_').map(e => Number(e))
|
|
|
+}
|
|
|
|
|
|
// 设置选中ids
|
|
|
-const idChecked = reactive([])
|
|
|
const handleClick = (val) => {
|
|
|
- val.act = !val.act
|
|
|
- console.log('val', val)
|
|
|
const findIndex = idChecked?.length ? idChecked.findIndex(j => j === val.id) : -1
|
|
|
if (findIndex === -1) {
|
|
|
idChecked.push(val.id) // 添加
|
|
|
} else {
|
|
|
idChecked.splice(findIndex, 1) // 删除
|
|
|
}
|
|
|
- console.log('idChecked', idChecked)
|
|
|
- if (idChecked?.length) emits('inputChange', idChecked)
|
|
|
-}
|
|
|
-
|
|
|
-// 选中样式判断
|
|
|
-const calcAct = (id) => {
|
|
|
- if (!id) return false
|
|
|
- if (Array.isArray(idChecked)) {
|
|
|
- const index = idChecked.findIndex(itemToCheck => itemToCheck=== id)
|
|
|
- const bool = index !== -1
|
|
|
- return bool ? true : false; // 如果找到返回索引,否则返回 false
|
|
|
- }
|
|
|
- else return false
|
|
|
+ if (idChecked?.length) emits('handleClickIndustry', idChecked)
|
|
|
}
|
|
|
</script>
|
|
|
+
|
|
|
<style lang="scss" scoped>
|
|
|
.card { border-radius: 12px; }
|
|
|
.rightCard {
|
|
@@ -70,7 +63,7 @@ const calcAct = (id) => {
|
|
|
// .categoryName { font-size: 16px; line-height: 28px; margin-top: 6px; color: var(--v-primary-base)}
|
|
|
.categoryName2 { font-size: 14px; color: #000; width: 150px; margin-right: 4px;}
|
|
|
.jobItem { font-size: 14px; color: #333333; }
|
|
|
- .act { color: var(--v-primary-base); }
|
|
|
+ .active { color: var(--v-primary-base); font-weight: 700; }
|
|
|
.rowItem {
|
|
|
padding: 8px 0;
|
|
|
}
|