Browse Source

修复显示问题

lex-xin 1 month ago
parent
commit
4e461fdadc
2 changed files with 15 additions and 11 deletions
  1. 14 10
      src/components/CCascader/index.tsx
  2. 1 1
      vite.config.ts

+ 14 - 10
src/components/CCascader/index.tsx

@@ -93,7 +93,11 @@ export default defineComponent({
       let columnName = '';
       if (subject.children) {
         children = [...subject.children];
-        let activeIndex = children.length > 0 ? children[0].id : '';
+        let activeIndex = subject.activeIndex
+          ? subject.activeIndex
+          : children.length > 0
+          ? children[0].id
+          : '';
         if (props.childShowAllCheck) {
           children.unshift({
             columnName: subject.children[0].columnName,
@@ -121,21 +125,22 @@ export default defineComponent({
       () => {
         if (!state.popoverShow || !props.value) return;
         let ids = formatParentId(props.value, props.options);
-        console.log(ids, 'ids');
-        state.tagActiveId = ids[0].id;
-        props.options.forEach((item: any) => {
-          if (item.id === state.tagActiveId) {
-            initParentSelect(item);
-          }
-        });
 
-        //
         const index = ids.findIndex((child: any) => child.id === props.value);
         ids = ids.slice(0, index + 1);
         const values = ids.map((item: any) => {
           return item.id;
         });
+        // 格式化数据
         formatParentCurrentValue(values, props.options);
+
+        // 初始化选中数据
+        state.tagActiveId = ids[0].id;
+        props.options.forEach((item: any) => {
+          if (item.id === state.tagActiveId) {
+            initParentSelect(item);
+          }
+        });
       }
     );
 
@@ -422,7 +427,6 @@ const ChildNodeSearch = defineComponent({
   setup(props, { emit }) {
     const { activeRow } = toRefs(props);
     const selectItem = ref({});
-
     watch(
       () => props.activeRow,
       () => {

+ 1 - 1
vite.config.ts

@@ -23,7 +23,7 @@ function resolve(dir: string) {
 }
 // https://vitejs.dev/config/
 // https://github.com/vitejs/vite/issues/1930 .env
-const proxyUrl = 'https://dev.kt.colexiu.com/';
+const proxyUrl = 'https://test.kt.colexiu.com/';
 // const proxyUrl = 'https://test.kt.colexiu.com';
 // const proxyUrl = 'http://192.168.3.14:7989';
 const now = new Date().getTime();