Quellcode durchsuchen

feat:客户管理,系统切换,

ljc vor 1 Monat
Ursprung
Commit
c9b4fde9e8

+ 1 - 0
components/cwg-pc-header.vue

@@ -8,6 +8,7 @@
 			<image class="left-img" src="/static/images/logo.png" mode="widthFix" alt="logo" />
 		</div>
 		<div class="right">
+      <cwg-system />
 			<cwg-notice />
 			<cwg-right-drawer />
 		</div>

+ 174 - 0
components/cwg-system.vue

@@ -0,0 +1,174 @@
+<template>
+  <cwg-dropdown :menu-list="systemMenuList" @menuClick="handleMenuClick">
+    <view class="pc-header-btn">
+      <text class="current-system-name">{{ currentSystemName }}</text>
+      <cwg-icon name="crm-chevron-down" color="#000" :size="14" />
+    </view>
+  </cwg-dropdown>
+</template>
+
+<script setup lang="ts">
+import { computed, ref, onMounted } from 'vue'
+import { useI18n } from 'vue-i18n'
+import Config from '@/config/index'
+import { customApi } from '@/service/custom'
+
+const props = defineProps({
+})
+
+const { Code } = Config
+const { locale } = useI18n()
+
+type SystemItem = {
+  sysCode: string
+  sysUrl: string
+  sysName?: string
+  sysNameEn?: string
+  localSystem?: number
+}
+
+const systemList = ref<SystemItem[]>([])
+const currentSystemCode = ref<string | null>(null)
+
+const systemMenuList = computed(() =>
+  systemList.value.map((item) => ({
+    ...item,
+    label: getSystemDisplayName(item),
+  })),
+)
+
+const currentSystemName = computed(() => {
+  if (!currentSystemCode.value || systemList.value.length === 0) {
+    return '系统切换'
+  }
+  const currentSystem = systemList.value.find((item) => item.sysCode === currentSystemCode.value)
+  if (!currentSystem) return '系统切换'
+  
+  return getSystemDisplayName(currentSystem)
+})
+
+const CACHE_KEY = 'systemListCache'
+// 4 * 60 * 60 * 1000
+const CACHE_DURATION = 14400000
+
+const getCache = () => {
+  const cached = uni.getStorageSync(CACHE_KEY)
+  if (!cached) return null
+  try {
+    return typeof cached === 'string' ? JSON.parse(cached) : cached
+  } catch (e) {
+    return null
+  }
+}
+
+const setCache = (data: any) => {
+  uni.setStorageSync(CACHE_KEY, JSON.stringify({ data, timestamp: Date.now() }))
+}
+
+const applySystemList = (data: any[]) => {
+  systemList.value = Array.isArray(data) ? data : []
+  if (systemList.value.length > 0) {
+    const localSystem = systemList.value.find((item) => item && item.localSystem === 1)
+    currentSystemCode.value = localSystem ? localSystem.sysCode : null
+  } else {
+    currentSystemCode.value = null
+  }
+}
+
+async function getSystemList() {
+  const cached = getCache()
+  if (cached && cached.timestamp && Date.now() - cached.timestamp < CACHE_DURATION) {
+    applySystemList(cached.data || [])
+    return
+  }
+
+  try {
+    const res: any = await customApi.getSystemList({})
+    if (res && res.code === Code.StatusOK) {
+      const data = res.data || []
+      applySystemList(data)
+      setCache(data)
+    } else {
+      uni.showToast({ title: (res && (res.msg || res.message)) || '获取系统列表失败', icon: 'none' })
+    }
+  } catch (e) {
+    uni.showToast({ title: '获取系统列表失败', icon: 'none' })
+  }
+}
+
+function getSystemDisplayName(item: SystemItem) {
+  if (!item) return ''
+  if (locale.value === 'en') return item.sysNameEn || item.sysName || item.sysCode
+  return item.sysName || item.sysNameEn || item.sysCode
+}
+
+function switchSystem(item: SystemItem) {
+  if (!item || !item.sysCode) return
+  if (item.sysCode === currentSystemCode.value) return
+
+  uni.showModal({
+    title: '系统提示',
+    content: '是否切换系统?',
+    confirmText: '确认',
+    cancelText: '取消',
+    success: async (res) => {
+      if (!res.confirm) return
+      await confirmSwitchSystem(item)
+    },
+  })
+}
+
+async function confirmSwitchSystem(item: SystemItem) {
+  try {
+    const res: any = await customApi.switchSystem({ sysCode: item.sysCode })
+    if (res && res.code === Code.StatusOK) {
+      const accessToken = res.data
+      const token = typeof accessToken === 'string' ? accessToken : String(accessToken || '')
+      const baseUrl = `${item.sysUrl}/#/signin?sysLoginToken=${btoa(token)}`
+      console.log(baseUrl)
+      // #ifdef H5
+      window.location.replace(baseUrl)
+      // #endif
+
+      // #ifndef H5
+      uni.showToast({ title: '仅支持在H5端切换系统', icon: 'none' })
+      // #endif
+    } else {
+      uni.showToast({ title: (res && (res.msg || res.message)) || '切换系统失败', icon: 'none' })
+    }
+  } catch (e) {
+    uni.showToast({ title: '切换系统失败', icon: 'none' })
+  }
+}
+
+function handleMenuClick({ value }: { value: any }) {
+  switchSystem(value)
+}
+
+onMounted(() => {
+  getSystemList()
+})
+</script>
+
+<style scoped lang="scss">
+@import "@/uni.scss";
+
+.pc-header-btn {
+  display: flex;
+  align-items: center;
+  cursor: pointer;
+  gap: px2rpx(4);
+}
+
+.current-system-name {
+  font-size: px2rpx(14);
+}
+
+:deep(.cwg-dropdown-menu-container .menu .menu-item) {
+  min-height: px2rpx(36);
+}
+
+:deep(.cwg-dropdown) {
+  overflow: visible !important;
+}
+</style>

+ 2 - 2
components/cwg-tabel.vue

@@ -216,7 +216,7 @@ const props = defineProps({
     headerColor: { type: String, default: 'var(--color-slate-800)' },
     headerFontSize: { type: [String, Number], default: '14rpx' },
     headerFontWeight: { type: [String, Number], default: 600 },
-    headerHeight: { type: [String, Number], default: '40rpx' },
+    headerHeight: { type: [String, Number], default: '32rpx' },
     headerClass: { type: [String, Array], default: '' },
     headerStyle: { type: Object, default: () => ({}) },
     stickyHeader: { type: Boolean, default: true },
@@ -837,7 +837,7 @@ defineExpose({
         }
 
         .uni-table-th {
-            padding: px2rpx(14) px2rpx(5);
+            padding: px2rpx(6) px2rpx(5);
             box-sizing: border-box;
             vertical-align: middle;
             font-size: 14px;

+ 1 - 1
pages/ib/components/applyIbDialog.vue

@@ -150,7 +150,7 @@
       loadCustomerList()
       if (props.detail.id) {
         let params = {
-          customerId: props.detail.id,
+          customId: props.detail.id,
         }
         if (props.paramsType == 'vietnam') {
           params = {

+ 7 - 7
pages/ib/components/pointDialog.vue

@@ -203,13 +203,13 @@
       dialogForm.value = {
         cId, id, comPoint1, hide1,
       }
-      if (val.ibId) {
-        loadCommissionAccountTypes(val.ibId).then(
-          () => {
-            return setCommissionDefaultsFromLoginPoint(val.id)
-          },
-        )
-      }
+
+      loadCommissionAccountTypes(val.ibId).then(
+        () => {
+          return setCommissionDefaultsFromLoginPoint(val.id)
+        },
+      )
+
     }
   })
 

+ 4 - 5
pages/ib/customer.vue

@@ -315,11 +315,10 @@
       applyForm.value = item.row
       applyVisible.value = true
     } else if (item.type == 'Point') {
-      const { cId, id, comPoint1, hide1 } = item.row
-      pointForm.value = {
-        cId, id, comPoint1, hide1,
-      }
-      pointVisible.value = true
+      pointForm.value = item.row
+      nextTick(() => {
+        pointVisible.value = true
+      })
     }
   }
 

+ 1 - 0
windows/top-window.vue

@@ -4,6 +4,7 @@
 			<image class="left-img" src="/static/images/logo.png" mode="widthFix" alt="logo" @click="openLeftDrawer" />
 		</div>
 		<div class="right">
+			<cwg-system />
 			<cwg-language />
 			<cwg-notice />
 			<cwg-right-drawer />