Преглед на файлове

perf(views): 优化"用户管理"模块添加主题色异常问题

wangshun преди 1 ден
родител
ревизия
333235d66a
променени са 3 файла, в които са добавени 17 реда и са изтрити 17 реда
  1. 1 0
      src/types/index.ts
  2. 9 15
      src/views/create-customer/EstablishOrganization.vue
  3. 7 2
      src/views/organization-manage/OrganizationManage.vue

+ 1 - 0
src/types/index.ts

@@ -137,6 +137,7 @@ export type UseGuideStepItemExpose = {
    */
   goBack?: () => boolean | Promise<boolean>;
   finish?: () => void | Promise<void>;
+  getInfoListByOrg?: () => void | Promise<void>;
 };
 
 export type UseGuideStepItemInstance = ComponentPublicInstance<unknown, UseGuideStepItemExpose>;

+ 9 - 15
src/views/create-customer/EstablishOrganization.vue

@@ -1,5 +1,5 @@
 <script setup lang="ts">
-import { inject, onMounted, ref, watch } from 'vue';
+import { inject, onMounted, ref } from 'vue';
 import { ColorPicker } from 'vue-color-kit';
 import { message } from 'ant-design-vue';
 
@@ -193,17 +193,15 @@ const handleChange = () => {
   }
 };
 
-defineExpose<UseGuideStepItemExpose>({
-  finish,
-});
-
 const getInfoListByOrg = () => {
   handleRequest(async () => {
     if (props.form.id) {
       equipmentLimitationsList.value = [];
       const data = await getInfoListByOrgId(props.form.id);
       setTimeout(() => {
-        setColorPrimary?.(props.form.themeColor);
+        if (props.form.themeColor) {
+          setColorPrimary?.(props.form.themeColor);
+        }
       }, 500);
       if (data.length) {
         data.forEach((item) => {
@@ -226,15 +224,10 @@ const getInfoListByOrg = () => {
     }
   });
 };
-
-watch(
-  () => props.form.id,
-  (count) => {
-    if (count) {
-      getInfoListByOrg();
-    }
-  },
-);
+defineExpose<UseGuideStepItemExpose>({
+  finish,
+  getInfoListByOrg,
+});
 
 onMounted(() => {
   handleRequest(async () => {
@@ -243,6 +236,7 @@ onMounted(() => {
       dataType: 1,
     });
   });
+  getInfoListByOrg();
 });
 </script>
 

+ 7 - 2
src/views/organization-manage/OrganizationManage.vue

@@ -113,6 +113,7 @@ const rules = computed<FormRules<RegisterGatewayForm>>(() => {
 const addOrganization = () => {
   organizationOpen.value = true;
   organizationTitle.value = true;
+  setColorPrimary?.('#32BAC0');
   useForm.id = undefined;
   useForm.orgName = '';
   useForm.themeColor = '#32BAC0';
@@ -170,6 +171,7 @@ const organizationEditor = (id: number) => {
       dayjs(endTenancy ? endTenancy : getFormattedDate(), 'YYYY-MM-DD'),
     ];
     useForm.dataValidityPeriod = dataValidityPeriod;
+    establishOrganizationRef.value?.getInfoListByOrg?.();
   });
 };
 // const organizationDelete = (id: number) => {
@@ -180,14 +182,16 @@ const clickOrganizationChange = () => {
   getOrganizationAll();
 };
 const cancelOrganization = () => {
+  organizationOpen.value = false;
+};
+
+const handleClose = () => {
   handleRequest(async () => {
     const { orgThemeColor } = await getLoginData();
     setTimeout(() => {
       setColorPrimary?.(orgThemeColor);
     }, 500);
   });
-
-  organizationOpen.value = false;
 };
 const saveOrganization = async () => {
   try {
@@ -284,6 +288,7 @@ onMounted(() => {
       width="920px"
       :mask-closable="false"
       :footer="null"
+      :after-close="handleClose"
     >
       <AForm ref="organizationRefs" class="organization-form" :model="useForm" label-align="left" :rules="rules">
         <EstablishOrganization