Parcourir la source

客户管理权限搜索等bug修改

chenlei il y a 2 mois
Parent
commit
56843a99bf

+ 2 - 1
src/layout/components/HeaderWrap.vue

@@ -2,7 +2,8 @@
 import { useLayoutState } from '../hooks/index'
 import { useRoute, useRouter } from 'vue-router'
 import {useUserInfo} from '@/hooks/userInfo'
-const {userInfo} =useUserInfo()
+const {getUserInfo, userInfo} =useUserInfo()
+getUserInfo()
 
 
 const { menuClose, menuCloseChange } = useLayoutState()

+ 18 - 6
src/views/business_manage/addBusiness.vue

@@ -116,7 +116,13 @@
       </template>
       <template v-if="currentStep === 3">
         <div class="second-step-form-wrap tree">
-          <SetPermission :isShowFoot="false" :PermissionList="PermissionList" :allCheckedList="allCheckedList"
+          <SetPermission
+            :isShowFoot="false"
+            :PermissionList="PermissionList"
+            :allCheckedList="allCheckedList"
+
+            :isSearch=isPermissionSearch
+             @getSearch="handleGetSearch"
             ref="permissionRef" />
         </div>
       </template>
@@ -167,6 +173,7 @@ const permissionRef = ref(null);
 const PermissionList = ref([]);
 const allCheckedList = ref([]);
 const handleEtaBusinessId = ref(0);
+const isPermissionSearch = ref(false);
 const firstFormData = reactive({
   areaType: '国内',
   name: '',
@@ -299,19 +306,26 @@ const getCurrentState = () => {
   }
 }
 
-const getChartPermission = async (EtaBusinessId) => {
+const getChartPermission = async (EtaBusinessId, Keyword, isSearch = false) => {
   try {
     const res = await businessCustomInterence.getChartPermission({
-      EtaBusinessId: EtaBusinessId
+      EtaBusinessId: EtaBusinessId,
+      Keyword
     });
     if (res.Ret !== 200) return;
     PermissionList.value = res.Data.List;
     allCheckedList.value = res.Data.CheckList
+    isPermissionSearch.value = isSearch;
   } catch (error) {
     console.error('获取图表权限失败:', error);
   }
 };
 
+// 权限搜索事件
+const handleGetSearch = (searchTxt) => {
+  getChartPermission(businessId.value, searchTxt, true)
+};
+
 // 获取选择数据
 const fetchChosenData = async () => {
   await getIndustry();
@@ -432,7 +446,7 @@ const handleStepSecond = async (stepName) => {
 
 const handleAddBusiness = async (isEdit = '') => {
   const res = await businessCustomInterence.addChartPermission({
-    ChartClassifyIdStr: permissionRef.value.allChecked.join(',') || '',
+    ChartClassifyIdStr: permissionRef.value.actuallyAllChecked.join(',') || '',
     EtaBusinessId: handleEtaBusinessId.value === 0 ? businessId.value : handleEtaBusinessId.value
   });
   if (res.Ret !== 200) return;
@@ -448,8 +462,6 @@ const selectRegion = (e, context) => {
   if (e === '北京市' || e === '上海市' || e === '天津市' || e === '重庆市') {
     firstFormData.province = e
   }
-  console.log('省份:', firstFormData.province, '城市:', firstFormData.city);
-
 };
 
 const getIndustry = () => {

+ 26 - 6
src/views/business_manage/businessList.vue

@@ -127,12 +127,13 @@
             </div>
           </template>
         </t-table>
-        <div style="text-align: right; margin-top: 20px">
+        <div style="margin-top: 20px">
           <t-pagination
             :current-page="page"
             :page-size="pageSize"
             :total="total"
-            @change="handleCurrentChange"
+            :showPageSize="false"
+            @current-change="handleCurrentChange"
           />
         </div>
       </div>
@@ -171,8 +172,11 @@
       >
           <SetPermission
             @setPermission="handleSetPermission"
+            @getSearch="handleGetSearch"
             @close="showSetPermission = false"
             :isShowFoot="true"
+            :isSearch=isPermissionSearch
+            :showSetPermission="showSetPermission"
             :allCheckedList="allCheckedList"
             :PermissionList="PermissionList" />
       </t-dialog>
@@ -246,6 +250,7 @@
   const PermissionList = ref([]);
   const allCheckedList = ref([]);
   const handleEtaBusinessId = ref(0)
+  const isPermissionSearch = ref(false); // 是否为权限搜索
 
   
   const navigateToAdd = () => {
@@ -359,17 +364,24 @@
     })
   };
   
-  const changePermissionStatus = async ({EtaBusinessId}) => { // 权限设置弹窗
-    handleEtaBusinessId.value = EtaBusinessId;
+  const changePermissionStatus = async (searchTxt, isSearch = false) => { // 权限设置弹窗
     const res = await businessCustomInterence.getChartPermission({
-      EtaBusinessId
+      EtaBusinessId: handleEtaBusinessId.value,
+      Keyword:searchTxt
     });
     if (res.Ret !== 200) return;
     PermissionList.value = res.Data.List;
     allCheckedList.value = res.Data.CheckList;
+    isPermissionSearch.value = isSearch;
     showSetPermission.value = true;
   };
 
+  // 权限搜索事件
+  const handleGetSearch = (searchTxt) => {
+    changePermissionStatus(searchTxt, true)
+  };
+
+  // 权限设置弹窗确认按钮
   const handleSetPermission = async (allCheckedList) => {
     const res = await businessCustomInterence.addChartPermission({
       ChartClassifyIdStr: allCheckedList.join(','),
@@ -385,7 +397,8 @@
       modifyData.value = data;
       showModifySaller.value = true;
     } else if (type === 'permission') {
-      changePermissionStatus(data);
+      handleEtaBusinessId.value = data.EtaBusinessId;
+      changePermissionStatus();
     } else if (type === 'setAuth') {
       // 去设置权限页面
       router.push({ path: '/customer/businessAuth', query: { id: data.EtaBusinessId, name:data.BusinessName } });
@@ -423,6 +436,13 @@
   
   const handleCurrentChange = (newPage) => {
     page.value = newPage;
+    console.log('当前页码:', newPage);
+    
+    fetchBusinessList();
+  };
+  const onPageSizeChange = (newSize) => {
+    pageSize.value = newSize;
+    page.value = 1;
     fetchBusinessList();
   };
   

+ 73 - 17
src/views/business_manage/components/SetPermission.vue

@@ -19,7 +19,6 @@
                 :value-mode="valueMode"
                 hover
                 @change="onChange"
-                @click="onClick"
                 />
         </div>
         <div class="foot-container" v-if="isShowFoot">
@@ -45,18 +44,27 @@ const props = defineProps({
     type: Array,
     default: [],
   },
+  showSetPermission: {
+    type: Boolean,
+    default: false,
+  },
+  isSearch: {
+    type: Boolean,
+    default: false,
+  },
 });
 // emit事件
-const emit = defineEmits(['close', 'setPermission']);
+const emit = defineEmits(['close', 'setPermission', 'getSearch']);
 const searchTxt = ref('');
  
 // tree相关
 const treeList = ref([]);
 const tree = ref();
-const valueMode = ref('onlyLeaf');
+const valueMode = ref('all');
 const checkable = ref(true);
-const checkStrictly = ref(false);
+const checkStrictly = ref(true);
 const allChecked = ref([]);
+const actuallyAllChecked = ref([]);
 const treeKeys = reactive({
     value: 'ChartClassifyId',
     children: 'Children',
@@ -67,33 +75,81 @@ const treeKeys = reactive({
 watch(
   () => props.PermissionList,
   (newValue) => {
-    if (newValue.length > 0) {
-        treeList.value = newValue;
-        allChecked.value = props.allCheckedList;
+    treeList.value = newValue;
+    if (!props.isSearch) {                           // 如果不是搜索,则直接把后端返回的赋值为选中项
+      allChecked.value = props.allCheckedList;
+      actuallyAllChecked.value = props.allCheckedList;
+    } else {                                         // 如果是搜索,则把本地选中项赋值为实际上选中的值
+      allChecked.value = actuallyAllChecked.value
+    }
+  },
+  { immediate: true }
+);
+
+watch(
+  () => props.showSetPermission,
+  (newValue) => {
+    if (newValue) {
+      searchTxt.value = '';
     }
   },
   { immediate: true }
 );
 
 // tree相关
-const onClick = (context) => {
-  console.info('onClick context:', context);
-  const { node } = context;
-  console.info(node.value, 'onClick context.node.checked:', node.checked);
-};
 const onChange = (checked, context) => {
-  console.info('onChange checked:', checked, 'context:', context);
+  // console.info('onChange checked:', checked, 'context:', context);
   const { node } = context;
-  console.info(node.value, 'onChange context.node.checked:', node.checked);
+  if (node.checked) {
+    if (node.data.Children.length) {                    // 如果当前节点有子节点,则把所有子节点的id都加上去  
+      allChecked.value = [...new Set([...allChecked.value, node.value, ...getAllChildIds(node.data.Children)])];
+      actuallyAllChecked.value = [...new Set([...actuallyAllChecked.value, node.value, ...getAllChildIds(node.data.Children)])];
+    }
+  } else {    
+    if (node.data.Children.length) {                    // 如果当前节点有子节点,则直接去掉该节点和子节点的所有id 
+      const temp = [...getAllChildIds(node.data.Children), node.value];
+      allChecked.value = removeChildren(allChecked.value, temp);
+      actuallyAllChecked.value = removeChildren(actuallyAllChecked.value, temp);
+    } else {                                          // 如果当前节点没有子节点,则直接去掉该节点的id
+      actuallyAllChecked.value = actuallyAllChecked.value.filter(item => item !== node.value);                                                  
+    }
+  }
 };
+// 获取所有子节点和子节点的id(递归) --用来实现勾选父节点时,子节点的勾选状态也跟随变化
+const getAllChildIds = (arr) => {
+  const ids = [];
+  function traverse(current) {
+    if (!Array.isArray(current) || !current.length) return;
+    current.forEach(item => {
+      if (item.ChartClassifyId) {
+        ids.push(item.ChartClassifyId);
+      }
+      if (item.Children && Array.isArray(item.Children)) {
+        item.Children.forEach(child => {
+          if (child.ChartClassifyId) {
+            ids.push(child.ChartClassifyId);
+          }
+          traverse(child.Children); // 递归遍历子元素
+        });
+      }
+    });
+  }
+  traverse(arr);
+  return ids;
+}
+const removeChildren = (arrayA, arrayB) => {
+    const setB = new Set(arrayB);
+    return arrayA.filter(item => !setB.has(item));
+}
+
 
 // 保存按钮
 const handleSave = async () => {
-  emit('setPermission', allChecked.value);
+  emit('setPermission', actuallyAllChecked.value);
 };
 // 搜索
 const changeSearchTxt = () => {
-
+  emit('getSearch', searchTxt.value);
 }
 // 关闭弹窗
 const handleClose = () => {
@@ -101,7 +157,7 @@ const handleClose = () => {
 };
 
 defineExpose({
-    allChecked,
+    actuallyAllChecked
 })
 </script>
 <style scoped lang="scss">

+ 1 - 1
src/views/customer/user/Index.vue

@@ -246,7 +246,7 @@ async function handleImportUser(e){
           <t-tag 
             :theme="row.Enabled?'success':'danger'"
             variant="light"
-          >{{row.PositionStatus?'已启用':'已禁用'}}</t-tag>
+          >{{row.Enabled?'已启用':'已禁用'}}</t-tag>
         </template>
         <template #opt="{ row }">
           <t-button size="small" variant="text" theme="primary" @click="handleEditUser(row)">编辑</t-button>

+ 2 - 2
src/views/etaTrial/etaTrialList.vue

@@ -89,13 +89,13 @@
         </template>
       </t-table>
       <t-pagination
-        layout="total,prev,pager,next,jumper"
         background
         :current-page="currentPage"
         @current-change="handleCurrentChange"
         :page-size="pageSize"
+        :showPageSize="false"
         :total="total"
-        style="text-align:right;margin-top:30px;"
+        style="margin-top:30px;"
       ></t-pagination>
     </div>
     <!-- 申请账号审批/申请启用审批 弹窗 -->

+ 9 - 4
src/views/system/updateLog.vue

@@ -19,11 +19,12 @@
                 </template>
             </t-table>
             <t-pagination 
-                layout="prev,pager,next,total" 
                 background
-                :current-page="pageNo"
+                :current="pageNo"
                 @current-change="currentChange"
-                :page-size="pageSize" 
+                :page-size.sync="pageSize"
+                @page-size-change="onPageSizeChange"
+                :pageSizeOptions="[10, 20, 30, 40]"
                 :total="total"
                 >
             </t-pagination>
@@ -77,6 +78,11 @@ const currentChange = (page) => {
     pageNo.value = page;
     getTableData();
 };
+const onPageSizeChange = (size) => {
+    pageSize.value = size;
+    pageNo.value = 1;
+    getTableData();
+};
 
 const sortChangeHandle = (params) => {
     if (params) {
@@ -138,7 +144,6 @@ onMounted(() => {
         margin-top: 30px;
         .t-pagination{
             margin-top: 30px;
-            text-align: right;
         }
     }
 

+ 2 - 2
src/views/training/labelManage.vue

@@ -17,13 +17,13 @@
                 </template>
             </t-table>
             <t-pagination
-                layout="total,prev,pager,next,jumper" 
                 background
                 :current-page="currentPage"
                 @current-change="handleCurrentChange"
                 :page-size="pageSize" 
+                :showPageSize="false"
                 :total="total"
-                style="text-align:right;margin-top:30px;">
+                style="margin-top:30px;">
             </t-pagination>
         </div>
         <!-- 添加标签弹窗 -->

+ 2 - 3
src/views/training/videoManage.vue

@@ -78,13 +78,12 @@
                 </template>
             </t-table>
             <t-pagination
-                layout="total,prev,pager,next,jumper" 
                 background
                 :current-page="currentPage"
                 @current-change="handleCurrentChange"
-                :page-size="pageSize" 
+                :showPageSize="false"
                 :total="total"
-                style="text-align:right;margin-top:30px;">
+                style="margin-top:30px;">
             </t-pagination>
         </div>
         <!-- 预览视频弹窗 -->