Эх сурвалжийг харах

Merge branch 'v2.0' of eta_forum/eta_forum_admin_front into debug

leichen 2 сар өмнө
parent
commit
0fd9ca68e2

+ 3 - 3
src/views/business_manage/addBusiness.vue

@@ -3,7 +3,7 @@
     <div class="add-business">
       <!-- 自定义步骤条 -->
       <div class="add-steps">
-        <Steps :activeStep="currentStep"
+        <Steps :activeStep="currentStep" :allowStepClick="currentRoute !== 'addBusiness'"
           @changeActiveStep="changeActiveStep">
         </Steps>
       </div>
@@ -101,10 +101,10 @@
             class="second-step-form">
             <div class="form-line">
               <t-form-item label="签约日期" name="signDate">
-                <t-date-picker v-model="secondFormData.signDate" placeholder="选择日期" />
+                <t-date-picker :disabled="currentRoute === 'businessDetail'" v-model="secondFormData.signDate" placeholder="选择日期" />
               </t-form-item>
               <t-form-item label="到期日期" name="expirationDate">
-                <t-date-picker v-model="secondFormData.expirationDate" placeholder="选择日期" />
+                <t-date-picker :disabled="currentRoute === 'businessDetail'" v-model="secondFormData.expirationDate" placeholder="选择日期" />
               </t-form-item>
             </div>
           </t-form>

+ 44 - 2
src/views/business_manage/components/SetPermission.vue

@@ -78,11 +78,46 @@ const treeKeys = reactive({
     label: 'ChartClassifyName',
 });
 
+const filterNodes = (arr) => {
+  arr.length && arr.forEach((item) => {
+    console.log(item);
+    props.allCheckedList.includes(item.ChartClassifyId) && (item.expanded = true);
+    item.Children&&item.Children.length && containsAnyValue(item.Children, props.allCheckedList) && (item.expanded = true);
+    item.Children&&item.Children.length && filterNodes(item.Children);
+  });
+  return arr;
+}
+
+const containsAnyValue = (multiDimArray, targetArray) => {
+    // 辅助函数,用于递归遍历数组
+    function recursiveCheck(subArray) {
+        for (let item of subArray) {
+            if (Array.isArray(item)) {
+                // 如果当前元素是数组,递归检查
+                if (recursiveCheck(item)) {
+                    return true;
+                }
+            } else {
+                // 检查当前元素是否在目标数组中
+                if (targetArray.includes(item.ChartClassifyId)) {
+                    return true;
+                }
+            }
+        }
+        // 如果没有找到任何匹配的值,返回false
+        return false;
+    }
+    // 从外层数组开始递归检查
+    return recursiveCheck(multiDimArray);
+}
+
 // 监听renewalForm的变化
 watch(
   () => props.PermissionList,
   (newValue) => {
-    treeList.value = newValue;
+    console.log('newValue', newValue);
+    treeList.value = newValue.length !== 0 ? filterNodes(newValue) : [];
+    
     if (!props.isSearch) {                           // 如果不是搜索,则直接把后端返回的赋值为选中项
       allChecked.value = props.allCheckedList;
       actuallyAllChecked.value = props.allCheckedList;
@@ -92,6 +127,10 @@ watch(
   },
   { immediate: true }
 );
+
+
+
+
 watch(
   () => props.currentStep,
   (newValue) => {
@@ -114,7 +153,10 @@ watch(
 
 // tree相关
 const onChange = (checked, context) => {
-  console.info('context:', tree.value.setItem());
+  // console.info('context:', );
+  // tree.value.setItem('12', {
+  //   expanded: true,
+  // })
   const { node } = context;
   if (node.checked) {
     if (node.data.Children.length) {                    // 如果当前节点有子节点,则把所有子节点的id都加上去