فهرست منبع

feat:报告页面修改。

ljc 1 ماه پیش
والد
کامیت
12e705c152
2فایلهای تغییر یافته به همراه111 افزوده شده و 57 حذف شده
  1. 1 1
      components/cwg-complex-search.vue
  2. 110 56
      pages/ib/report.vue

+ 1 - 1
components/cwg-complex-search.vue

@@ -14,7 +14,7 @@
                             <template v-else-if="field.type === 'select'">
                                 <cwg-combox v-model:value="formData[field.key]" :options="field.options"
                                     :placeholder="field.placeholder || '请选择'" :clearable="false"
-                                    @change="handleSearch" />
+                                    @change="(e) => field.onChange?.(e) || handleSearch()" />
                             </template>
                             <template v-else-if="field.type === 'date'">
                                 <uni-datetime-picker v-model="formData[field.key]" type="date"

+ 110 - 56
pages/ib/report.vue

@@ -1,11 +1,12 @@
 <template>
   <cwg-page-wrapper class="create-page" :isHeaderFixed="true">
     <cwg-header :title="t('Home.page_ib.item3')" />
-
-    <view class="account-content">
+    <uni-loading v-if="loading"/>
+    <view v-else class="account-content">
       <view class="search-content">
         <view class="search-bar">
-          <cwg-complex-search :fields="filterFields" v-model="searchParams" @search="handleSearch" @reset="handleReset" />
+          <cwg-complex-search :fields="filterFields" v-model="searchParams" @search="handleSearch"
+                              @reset="handleReset" />
         </view>
       </view>
 
@@ -27,7 +28,7 @@
 
 <script setup lang="ts">
   // 报告
-  import { ref, computed, onMounted, watch } from 'vue'
+  import { ref, computed, onMounted, watch, nextTick } from 'vue'
   import { useI18n } from 'vue-i18n'
   import Config from '@/config/index'
   import { ibApi } from '@/service/ib'
@@ -42,6 +43,7 @@
   let { Code } = Config
   const { userInfo } = useUserStore()
   const tableRef = ref(null)
+  const loading = ref(false)
 
   const typeList = computed(() => [
     { text: t('Ib.Report.Title1'), value: 1 },
@@ -85,6 +87,8 @@
     date: defaultDateRange,
   })
 
+  const filterFields = ref([])
+
   const search = ref({
     reportType: 1,
     detail_type: null as number | null,
@@ -108,14 +112,14 @@
       options: [
         { value: 0, text: t('news_add_field.IbReport.ALL') },
         { value: -1, text: t('news_add_field.IbReport.DirectlyUnder') },
-      ]
-    }
+      ],
+    },
   ])
 
   const handleAgentChange = async (val: any, levelIndex: number) => {
     // 截断当前层级之后的所有层级
     agentLevels.value.splice(levelIndex + 1)
-    
+
     // 清理 searchParams 中被移除层级的值
     for (let key in searchParams.value) {
       if (key.startsWith('agentId_')) {
@@ -138,17 +142,18 @@
           if (item.ibNo) {
             nextOptions.push({
               value: item.id,
-              text: item.name ? `${item.ibNo} - ${item.name}` : item.ibNo
+              text: item.name ? `${item.ibNo} - ${item.name}` : item.ibNo,
             })
           }
         })
-        if (nextOptions.length > 1) {
+        if (nextOptions.length > 0) {
           agentLevels.value.push({
             key: `agentId_${levelIndex + 1}`,
-            options: nextOptions
+            options: nextOptions,
           })
         }
       }
+      setFields()
     } catch (error) {
       uni.showToast({ title: 'Error', icon: 'none' })
     }
@@ -161,7 +166,7 @@
 
     columns.forEach((column: any, index: number) => {
       if (index === 0) {
-        sums[index] = t("Label.Total")
+        sums[index] = t('Label.Total')
         return
       }
 
@@ -171,64 +176,64 @@
       // 根据不同的列 prop 进行合计数据显示和格式化
       const prop = column.prop
       if (!prop) {
-        sums[index] = ""
+        sums[index] = ''
         return
       }
 
       if (type == 1) {
         if (['deposit', 'withdrawal', 'credit'].includes(prop)) {
-          sums[index] = summaryData[prop] ? numberFormat(summaryData[prop]) : "0"
+          sums[index] = summaryData[prop] ? numberFormat(summaryData[prop]) : '0'
         } else {
-          sums[index] = ""
+          sums[index] = ''
         }
       } else if (type == 2) {
         if (['volume', 'rebateAmount', 'commissionAmount'].includes(prop)) {
-          sums[index] = summaryData[prop] ? numberFormat(summaryData[prop]) : "0"
+          sums[index] = summaryData[prop] ? numberFormat(summaryData[prop]) : '0'
         } else {
-          sums[index] = ""
+          sums[index] = ''
         }
       } else if (type == 3) {
         if (detailType == 4) {
           if (['volume', 'storage', 'taxes', 'profit'].includes(prop)) {
-            sums[index] = summaryData[prop] ? numberFormat(summaryData[prop]) : "0"
+            sums[index] = summaryData[prop] ? numberFormat(summaryData[prop]) : '0'
           } else {
-            sums[index] = ""
+            sums[index] = ''
           }
         } else {
           if (['commission', 'volume', 'storage', 'taxes', 'profit', 'totalProfit'].includes(prop)) {
-            sums[index] = summaryData[prop] ? numberFormat(summaryData[prop]) : "0"
+            sums[index] = summaryData[prop] ? numberFormat(summaryData[prop]) : '0'
           } else {
-            sums[index] = ""
+            sums[index] = ''
           }
         }
       } else if (type == 4) {
         if (['credit', 'balance', 'equity', 'floating'].includes(prop)) {
-          sums[index] = summaryData[prop] ? numberFormat(summaryData[prop]) : "0"
+          sums[index] = summaryData[prop] ? numberFormat(summaryData[prop]) : '0'
         } else {
-          sums[index] = ""
+          sums[index] = ''
         }
       } else if (type == 6) {
         if (prop === 'amount') {
-          sums[index] = summaryData[prop] ? numberFormat(summaryData[prop]) : "0"
+          sums[index] = summaryData[prop] ? numberFormat(summaryData[prop]) : '0'
         } else {
-          sums[index] = ""
+          sums[index] = ''
         }
       } else if (type == 7) {
         if (['fxVolume', 'cfdVolume', 'indexVolume', 'metalVolume'].includes(prop)) {
-          sums[index] = summaryData[prop] ? numberFormat(summaryData[prop]) : "0"
+          sums[index] = summaryData[prop] ? numberFormat(summaryData[prop]) : '0'
         } else {
-          sums[index] = ""
+          sums[index] = ''
         }
       } else if (type == 24) {
         if (prop === 'volume') {
-          sums[index] = summaryData[prop] ? numberFormat(summaryData[prop]) + " /手" : "0"
+          sums[index] = summaryData[prop] ? numberFormat(summaryData[prop]) + ' /手' : '0'
         } else if (prop === 'rebate') {
-          sums[index] = summaryData[prop] ? "$" + numberFormat(summaryData[prop]) : "0"
+          sums[index] = summaryData[prop] ? '$' + numberFormat(summaryData[prop]) : '0'
         } else {
-          sums[index] = ""
+          sums[index] = ''
         }
       } else {
-        sums[index] = ""
+        sums[index] = ''
       }
     })
 
@@ -268,8 +273,9 @@
       cId: payload.cId,
       isShort: payload.isShort,
     }
-
-    tableRef.value?.refreshTable?.()
+    nextTick(() => {
+      tableRef.value?.refreshTable?.()
+    })
   }
 
   const handleReset = (emptyParams: any) => {
@@ -297,7 +303,6 @@
           title: res.msg, icon: 'none',
         })
       }
-
     }
   }
 
@@ -393,42 +398,82 @@
     search.value.isShort = val
   })
 
-  onMounted(() => {
-    initIbTree()
+  onMounted(async () => {
+    loading.value = true
+    await initIbTree()
+    setFields()
+    loading.value = false
   })
-
-  const filterFields = computed(() => {
+  const setFields = () => {
     const type = Number(searchParams.value.reportType ?? 1)
     const fields: any[] = [
-      { key: 'reportType', type: 'select', label: t('Home.page_ib.item3'), placeholder: t('placeholder.choose'), options: typeList.value, defaultValue: 1, isSelect: true },
+      {
+        key: 'reportType',
+        type: 'select',
+        label: t('Home.page_ib.item3'),
+        placeholder: t('placeholder.choose'),
+        options: typeList.value,
+        defaultValue: 1,
+        isSelect: true,
+      },
     ]
 
     if (type === 3) {
-      fields.push({ key: 'detail_type', type: 'select', label: t('placeholder.choose'), placeholder: t('placeholder.choose'), options: detailTypeList.value, defaultValue: 1, isSelect: true })
+      fields.push({
+        key: 'detail_type',
+        type: 'select',
+        label: t('placeholder.choose'),
+        placeholder: t('placeholder.choose'),
+        options: detailTypeList.value,
+        defaultValue: 1,
+        isSelect: true,
+      })
     }
 
     if ([1, 3, 4, 7, 24].includes(type)) {
-      fields.push({ key: 'platform', type: 'select', label: t('Label.Platform'), placeholder: t('placeholder.choose'), options: platformOptions, defaultValue: 'MT4' })
+      fields.push({
+        key: 'platform',
+        type: 'select',
+        label: t('Label.Platform'),
+        placeholder: t('placeholder.choose'),
+        options: platformOptions,
+        defaultValue: 'MT4',
+      })
     }
 
     if (type === 24) {
-      fields.push({ key: 'customType', type: 'select', label: t('placeholder.choose'), placeholder: t('placeholder.choose'), options: customTypeList.value, defaultValue: 0, isSelect: true })
+      fields.push({
+        key: 'customType',
+        type: 'select',
+        label: t('placeholder.choose'),
+        placeholder: t('placeholder.choose'),
+        options: customTypeList.value,
+        defaultValue: 0,
+        isSelect: true,
+      })
     }
 
-    // agentLevels.value.forEach((level, index) => {
-    //   fields.push({
-    //     key: level.key,
-    //     type: 'select',
-    //     label: t('State.All'),
-    //     options: level.options,
-    //     placeholder: t('State.All'),
-    //     onChange: (val: any) => handleAgentChange(val, index),
-    //     defaultValue: index === 0 ? 0 : '',
-    //   })
-    // })
+    console.log(agentLevels.value)
+    agentLevels.value.forEach((level, index) => {
+      fields.push({
+        key: level.key,
+        type: 'select',
+        label: t('State.All'),
+        options: level.options,
+        placeholder: t('State.All'),
+        onChange: (val: any) => handleAgentChange(val, index),
+        defaultValue: index === 0 ? 0 : '',
+      })
+    })
 
     if ([1, 2, 3, 4, 7].includes(type)) {
-      fields.push({ key: 'login', type: 'input', label: t('Label.TradingAccount'), placeholder: t('Label.TradingAccount'), defaultValue: '' })
+      fields.push({
+        key: 'login',
+        type: 'input',
+        label: t('Label.TradingAccount'),
+        placeholder: t('Label.TradingAccount'),
+        defaultValue: '',
+      })
     }
 
     if (type === 7) {
@@ -436,12 +481,21 @@
     }
 
     if ([3, 7].includes(type)) {
-      fields.push({ key: 'isShort', type: 'select', label: t('placeholder.choose'), placeholder: t('placeholder.choose'), options: isShortList.value, defaultValue: 0, isSelect: true })
+      fields.push({
+        key: 'isShort',
+        type: 'select',
+        label: t('placeholder.choose'),
+        placeholder: t('placeholder.choose'),
+        options: isShortList.value,
+        defaultValue: 0,
+        isSelect: true,
+      })
     }
 
     fields.push({ key: 'date', label: t('placeholder.Start') + ' - ' + t('placeholder.End'), type: 'daterange' })
-    return fields
-  })
+    filterFields.value = fields
+  }
+
 </script>
 
 <style lang="scss" scoped>