zhengyiming
5 天以前 acd6c55ea7b11e06130c20bcd5ffd98c8e880a1f
packages/components/src/AreaTreeSelect/PositionSelectView.vue
@@ -1,15 +1,16 @@
<template>
  <Category :category="provinceList" @change="change" class="position-select-view">
  <Category :category="_industryList" @change="change" class="position-select-view">
    <CategoryPane :max="max" :categoryChild="categoryChild" :multiple="multiple" v-model="model">
    </CategoryPane>
  </Category>
</template>
<script setup lang="ts">
import { useAllAreaList } from '@12333/hooks';
import { useDictionaryDataSelect, useGetDictionaryCategorySelect } from '@12333/hooks';
import Category from './Category.vue';
import CategoryPane from './CategoryPane.vue';
import { reactive, computed, watch } from 'vue';
import { CategoryCode } from '@12333/constants';
defineOptions({
  name: 'PositionSelectView',
@@ -24,29 +25,47 @@
  multiple: true,
});
const model = defineModel<number[]>();
const model = defineModel<string[]>();
const state = reactive({
  provinceIndex: 0,
  industryIndex: 0,
});
const { areaTreeList } = useAllAreaList();
const { dictionaryDataList: industryList } = useDictionaryDataSelect({
  categoryCode: CategoryCode.IndustryCategory,
});
const provinceList = computed(() => areaTreeList.value.map((x) => ({ ...x, name: x.areaName })));
const _industryList = computed(() =>
  industryList.value.map((x) => ({
    ...x,
    name: x.label,
    id: x.value,
  }))
);
const { dictionaryDataList: positionList } = useDictionaryDataSelect({
  categoryCode: CategoryCode.Position,
});
const _positionList = computed(() =>
  positionList.value.map((x) => ({
    ...x,
    name: x.label,
    id: x.value,
  }))
);
const categoryChild = computed(() => {
  if (!provinceList.value.length) {
  if (!_industryList.value.length) {
    return [];
  }
  return provinceList.value[state.provinceIndex].children.map((x) => ({
    ...x,
    name: x.areaName,
    value: x.areaCode,
  }));
  return _positionList.value?.filter(
    (x) => x.data.field1 === _industryList.value[state.industryIndex]?.code
  );
});
const change = (index: number) => {
  state.provinceIndex = index;
  state.industryIndex = index;
};
</script>