Explorar o código

[Mod 0000] 修改矿号级联选择器的id初始化规则

houzekong hai 3 meses
pai
achega
2a98e009a2

+ 2 - 2
src/components/Form/src/jeecg/components/MineCascader/MineCascader.vue

@@ -40,7 +40,7 @@
     setup(props, { emit }) {
       // const { createMessage } = useMessage();
       const mineStore = useMineStore();
-      const { getMine, getMineCode, getMinePath, getMineTree } = storeToRefs(mineStore);
+      const { getMine, getMinePath, getMineTree, getMineId } = storeToRefs(mineStore);
 
       // const shownText = computed(() => getMine.value.departName || '-');
       const innerValue = computed(() => getMinePath.value.map((e) => e.id));
@@ -57,7 +57,7 @@
         if (props.valueField) {
           val = get(getMine.value, props.valueField);
         } else {
-          val = getMineCode.value;
+          val = getMineId.value;
         }
         emit('update:value', val);
         emit('change', val);

+ 13 - 10
src/store/modules/mine.ts

@@ -25,7 +25,7 @@ export interface MineState {
   /** 当前选中的矿井ID,可能为空 */
   mineId?: MineDepartment['id'];
   /** 当前选中的矿井编号,可能为空 */
-  mineCode?: MineDepartment['fax'];
+  // mineCode?: MineDepartment['fax'];
   /** 当前选中的矿井在组织树中的访问路径 */
   minePath: MineDepartment[];
   /** 矿井组织树 */
@@ -43,7 +43,7 @@ export const useMineStore = defineStore({
   state: (): MineState => ({
     mine: undefined,
     mineId: undefined,
-    mineCode: undefined,
+    // mineCode: undefined,
     minePath: [],
     mineTree: [],
   }),
@@ -54,9 +54,9 @@ export const useMineStore = defineStore({
     getMineId(): MineState['mineId'] {
       return this.getMine?.id;
     },
-    getMineCode(): MineState['mineCode'] {
-      return this.getMine?.fax;
-    },
+    // getMineCode(): MineState['mineCode'] {
+    //   return this.getMine?.fax;
+    // },
     getMineTree(): MineState['mineTree'] {
       return this.mineTree;
     },
@@ -78,10 +78,10 @@ export const useMineStore = defineStore({
       this.setMine(node);
     },
     /** 根据传入的code设置当前选中的矿井,更新id、code、path三项 */
-    setMineByCode(code: string = '') {
-      const node = findNode(this.getMineTree, (item) => item.fax === code, DEFAULT_CONFIG);
-      this.setMine(node);
-    },
+    // setMineByCode(code: string = '') {
+    //   const node = findNode(this.getMineTree, (item) => item.fax === code, DEFAULT_CONFIG);
+    //   this.setMine(node);
+    // },
     setMinePath(path: any[] = []) {
       this.minePath = path;
     },
@@ -92,7 +92,10 @@ export const useMineStore = defineStore({
       const r1 = await getEnfMineTree();
       const r2 = await getUserMinePermissionData({});
       r1.forEach((e) => (e.isLeaf = false));
-      r2.forEach((e) => (e.isLeaf = true));
+      r2.forEach((e) => {
+        e.isLeaf = true;
+        e.id = e.fax;
+      });
       const tree = listToTree([...r1, ...r2], DEFAULT_CONFIG);
       // 使用查找方法而不是选中r2中第一个“叶节点”是因为:
       // r2返回的矿名不具备权限控制,r1返回的父节点才有权限控制