Parcourir la source

refactor: 管理后台代码改成静态模块

runphp il y a 1 semaine
Parent
commit
efe634d96a

+ 56 - 0
frontend/admin/index.js

@@ -0,0 +1,56 @@
+/**
+ * Lakala Module - 拉卡拉支付模块
+ */
+
+export default {
+  // 路由配置
+  routes: {
+    path: '/lakala',
+    name: 'LakalaModule',
+    component: () => import('@/layout/index.vue'),
+    redirect: '/lakala/index',
+    meta: {
+      title: '拉卡拉管理',
+      icon: 'Money',
+      permission: 'lakala'
+    },
+    children: [
+      {
+        path: 'index',
+        name: 'LakalaIndex',
+        component: () => import('./index.vue'),
+        meta: {
+          title: '拉卡拉管理',
+          keepAlive: true
+        }
+      }
+    ]
+  },
+
+  // 菜单配置
+  menus: [
+    {
+      path: '/lakala',
+      title: '拉卡拉管理',
+      icon: 'Money',
+      permission: 'lakala',
+      children: [
+        {
+          path: '/lakala/index?tab=profitShareReceiver',
+          title: '分账接收方申请',
+          icon: 'UserFilled'
+        },
+        {
+          path: '/lakala/index?tab=profitShareOrder',
+          title: '分帐申请',
+          icon: 'Document'
+        },
+        {
+          path: '/lakala/index?tab=tradeOrder',
+          title: '拉卡拉交易记录',
+          icon: 'List'
+        }
+      ]
+    }
+  ]
+}

+ 97 - 0
frontend/admin/index.vue

@@ -0,0 +1,97 @@
+<template>
+  <div class="lakala-container">
+    <el-header height="60px">
+      <el-menu
+        :default-active="activeMenu"
+        mode="horizontal"
+        @select="handleMenuSelect"
+        class="el-menu-horizontal"
+      >
+        <el-menu-item index="profitShareReceiver">
+          <span>分账接收方申请</span>
+        </el-menu-item>
+        <el-menu-item index="profitShareOrder">
+          <span>分帐申请</span>
+        </el-menu-item>
+        <el-menu-item index="tradeOrder">
+          <span>拉卡拉交易记录</span>
+        </el-menu-item>
+      </el-menu>
+    </el-header>
+
+    <el-main>
+      <component :is="currentComponent" />
+    </el-main>
+  </div>
+</template>
+
+<script>
+import ProfitShareReceiver from './views/ProfitShareReceiver.vue'
+import ProfitShareOrder from './views/ProfitShareOrder.vue'
+import TradeOrder from './views/TradeOrder.vue'
+
+const componentMap = {
+  profitShareReceiver: ProfitShareReceiver,
+  profitShareOrder: ProfitShareOrder,
+  tradeOrder: TradeOrder
+}
+
+export default {
+  name: 'LakalaIndex',
+  components: {
+    ProfitShareReceiver,
+    ProfitShareOrder,
+    TradeOrder
+  },
+  data() {
+    return {
+      activeMenu: this.$route.query.tab || 'profitShareReceiver'
+    }
+  },
+  computed: {
+    currentComponent() {
+      return componentMap[this.activeMenu] || ProfitShareReceiver
+    }
+  },
+  watch: {
+    '$route.query.tab'(val) {
+      if (val && componentMap[val]) {
+        this.activeMenu = val
+      }
+    }
+  },
+  methods: {
+    handleMenuSelect(index) {
+      this.activeMenu = index
+      this.$router.replace({ query: { tab: index } })
+    }
+  }
+}
+</script>
+
+<style scoped>
+.lakala-container {
+  padding: 0;
+  height: calc(100vh - 120px);
+}
+
+.el-header {
+  padding: 0;
+  background-color: #fff;
+  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
+}
+
+.el-menu-horizontal {
+  height: 60px;
+  font-size: 16px;
+}
+
+.el-main {
+  padding: 30px;
+  background: #fff;
+  margin: 20px;
+  border-radius: 8px;
+  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
+  flex: 1;
+}
+</style>

+ 7 - 21
resource/admin/ProfitShareOrder.vue → frontend/admin/views/ProfitShareOrder.vue

@@ -277,15 +277,11 @@
 </template>
 
 <script>
+import request from '@/utils/request'
+
 export default {
   name: "ProfitShareOrder",
   inheritAttrs: false,
-  props: {
-    axiosInstance: {
-      type: Object,
-      default: null
-    }
-  },
   data() {
     return {
       loading: false,
@@ -358,11 +354,6 @@ export default {
 
     // 获取列表数据
     async fetchData() {
-      if (!this.axiosInstance) {
-        this.$message.error('无法获取请求实例')
-        return
-      }
-      
       this.loading = true
       try {
         const params = {
@@ -372,7 +363,7 @@ export default {
           status: this.searchForm.status
         }
         
-        const res = await this.axiosInstance.get('/lakala/profit_share_order', { params })
+        const res = await request.get('/lakala/profit_share_order', { params })
         if (res.code === 200) {
           this.tableData = res.page.data
           this.pagination.total = res.page.total
@@ -422,7 +413,7 @@ export default {
           type: 'warning'
         });
         
-        const res = await this.axiosInstance.put(`/lakala/profit_share_order/${row.id}/approve`);
+        const res = await request.put(`/lakala/profit_share_order/${row.id}/approve`);
         if (res.code === 200) {
           this.$message.success('操作成功');
           this.fetchData(); // 刷新列表
@@ -453,7 +444,7 @@ export default {
       
       this.rejectLoading = true;
       try {
-        const res = await this.axiosInstance.put(`/lakala/profit_share_order/${this.rejectForm.orderId}/reject`, {
+        const res = await request.put(`/lakala/profit_share_order/${this.rejectForm.orderId}/reject`, {
           reason: this.rejectForm.reason
         });
         
@@ -502,11 +493,6 @@ export default {
 
     // 获取资金明细
     async getBalanceRecords() {
-      if (!this.axiosInstance) {
-        this.$message.error('无法获取请求实例');
-        return;
-      }
-      
       try {
         this.balanceRecordLoading = true;
         
@@ -516,7 +502,7 @@ export default {
           limit: this.balanceRecordPagination.limit
         };
         
-        const res = await this.axiosInstance.get('/balpay/log', { params });
+        const res = await request.get('/balpay/log', { params });
         if (res.code === 200) {
           this.balanceRecords = res.page?.data || [];
           this.balanceRecordPagination.total = res.page?.total || 0;
@@ -860,4 +846,4 @@ export default {
   justify-content: flex-end;
   margin-top: 20px;
 }
-</style>
+</style>

+ 10 - 41
resource/admin/ProfitShareReceiver.vue → frontend/admin/views/ProfitShareReceiver.vue

@@ -217,14 +217,10 @@
 </template>
 
 <script>
+import request from '@/utils/request'
+
 export default {
   name: 'ProfitShareReceiver',
-  props: {
-    axiosInstance: {
-      type: Object,
-      default: null
-    }
-  },
   data() {
     return {
       loading: false,
@@ -279,12 +275,6 @@ export default {
     
     // 获取列表数据
     async fetchData() {
-      // 优先使用通过props传递的axios实例
-      if (!this.axiosInstance) {
-        this.$message.error('无法获取请求实例')
-        return
-      }
-      
       this.loading = true
       try {
         const params = {
@@ -294,7 +284,7 @@ export default {
           status: this.searchForm.status
         }
         
-        const res = await this.axiosInstance.get('/lakala/profit_share_receiver', { params })
+        const res = await request.get('/lakala/profit_share_receiver', { params })
         if (res.code === 200) {
           // 根据接口返回结构调整数据处理
           this.tableData = res.page.data
@@ -313,23 +303,17 @@ export default {
 
     // 获取详情数据
     async fetchDetail(id) {
-      if (!this.axiosInstance) {
-        this.$message.error('无法获取请求实例')
-        return
-      }
-
       this.detailLoading = true
       try {
-        const res = await this.axiosInstance.get(`/lakala/profit_share_receiver/${id}`)
+        const res = await request.get(`/lakala/profit_share_receiver/${id}`)
         if (res.code === 200) {
           this.detailData = res.data
           // 处理合作协议文件路径
           if (this.detailData.entrust_local_path) {
             // 如果是相对路径,则拼接VITE_API_BASE_URL
             if (!this.detailData.entrust_local_path.startsWith('http')) {
-              const { VITE_API_BASE_URL } = this.axiosInstance.defaults.baseURL ? 
-                { VITE_API_BASE_URL: this.axiosInstance.defaults.baseURL.replace('/admin', '') } : 
-                { VITE_API_BASE_URL: '' }
+              const baseURL = request.defaults.baseURL || ''
+              const VITE_API_BASE_URL = baseURL.replace('/admin', '')
               this.detailData.entrust_local_full_url = VITE_API_BASE_URL + this.detailData.entrust_local_path
             } else {
               // 如果是绝对路径,直接使用
@@ -377,14 +361,9 @@ export default {
     
     // 分账接收方创建申请
     async handleCreateApplication() {
-      if (!this.axiosInstance) {
-        this.$message.error('无法获取请求实例')
-        return
-      }
-
       this.applyLoading = true
       try {
-        const res = await this.axiosInstance.put(`/lakala/profit_share_receiver/${this.detailData.id}/apply`)
+        const res = await request.put(`/lakala/profit_share_receiver/${this.detailData.id}/apply`)
         if (res.code === 200) {
           this.$message.success('分账接收方创建申请已提交')
           this.handleCloseDetailDialog()
@@ -403,14 +382,9 @@ export default {
     
     // 分账关系绑定申请
     async handleBindApplication() {
-      if (!this.axiosInstance) {
-        this.$message.error('无法获取请求实例')
-        return
-      }
-
       this.applyLoading = true
       try {
-        const res = await this.axiosInstance.put(`/lakala/profit_share_receiver/${this.detailData.id}/bind`)
+        const res = await request.put(`/lakala/profit_share_receiver/${this.detailData.id}/bind`)
         if (res.code === 200) {
           this.$message.success('分账关系绑定申请已提交')
           this.handleCloseDetailDialog()
@@ -429,14 +403,9 @@ export default {
     
     // 分账接收方信息变更申请
     async handleUpdateApplication() {
-      if (!this.axiosInstance) {
-        this.$message.error('无法获取请求实例')
-        return
-      }
-
       this.applyLoading = true
       try {
-        const res = await this.axiosInstance.put(`/lakala/profit_share_receiver/${this.detailData.id}/modify`)
+        const res = await request.put(`/lakala/profit_share_receiver/${this.detailData.id}/modify`)
         if (res.code === 200) {
           this.$message.success('分账接收方信息变更申请已提交')
           this.handleCloseDetailDialog()
@@ -521,4 +490,4 @@ export default {
   flex-grow: 1;
 }
 
-</style>
+</style>

+ 6 - 15
resource/admin/TradeOrder.vue → frontend/admin/views/TradeOrder.vue

@@ -183,14 +183,10 @@
 </template>
 
 <script>
+import request from '@/utils/request'
+
 export default {
   name: "TradeOrder",
-  props: {
-    axiosInstance: {
-      type: Object,
-      default: null
-    }
-  },
   data() {
     return {
       loading: false,
@@ -267,11 +263,6 @@ export default {
 
     // 获取列表数据
     async fetchData() {
-      if (!this.axiosInstance) {
-        this.$message.error('无法获取请求实例')
-        return
-      }
-      
       this.loading = true
       try {
         const params = {
@@ -289,7 +280,7 @@ export default {
           params.order_state = this.searchForm.order_state
         }
         
-        const res = await this.axiosInstance.get('/lakala/trade_order', { params })
+        const res = await request.get('/lakala/trade_order', { params })
         if (res.code === 200) {
           this.tableData = res.page.data
           this.pagination.total = res.page.total
@@ -346,7 +337,7 @@ export default {
       this.currentRow = row;
       // 获取快递公司列表
       try {
-        const res = await this.axiosInstance.get('/wechat/delivery');
+        const res = await request.get('/wechat/delivery');
         if (res.code === 200) {
           this.expressList = res.page.data;
           this.dialogVisible = true;
@@ -371,7 +362,7 @@ export default {
           express_company: this.selectedExpress
         };
         
-        const res = await this.axiosInstance.put(`/lakala/trade_order/${this.currentRow.wechat_payment_id}/express_company`, params);
+        const res = await request.put(`/lakala/trade_order/${this.currentRow.wechat_payment_id}/express_company`, params);
         if (res.code === 200) {
           this.$message.success('纠正成功');
           this.dialogVisible = false;
@@ -528,4 +519,4 @@ export default {
   word-break: break-all;
   margin-left: 8px;
 }
-</style>
+</style>

+ 0 - 101
resource/admin/index.vue

@@ -1,101 +0,0 @@
-<template>
-  <div class="lakala-container">
-    <el-container>
-      <el-header height="60px">
-        <el-menu
-          :default-active="activeMenu"
-          mode="horizontal"
-          @select="handleMenuSelect"
-          class="el-menu-horizontal"
-        >
-          <el-menu-item index="profitShareReceiver">
-            <span>分账接收方申请</span>
-          </el-menu-item>
-          <el-menu-item index="profitShareOrder">
-            <span>分帐申请</span>
-          </el-menu-item>
-          <el-menu-item index="tradeOrder">
-            <span>拉卡拉交易记录</span>
-          </el-menu-item>
-        </el-menu>
-      </el-header>
-      
-      <el-main>
-        <component 
-          :is="currentComponent" 
-          :axios-instance="axiosInstance" 
-        />
-      </el-main>
-    </el-container>
-  </div>
-</template>
-
-<script>
-import ProfitShareReceiver from './ProfitShareReceiver.vue'
-import ProfitShareOrder from './ProfitShareOrder.vue'
-import TradeOrder from './TradeOrder.vue'
-
-export default {
-  name: 'LakalaAdmin',
-  components: {
-    ProfitShareReceiver,
-    ProfitShareOrder,
-    TradeOrder
-  },
-  props: {
-    axiosInstance: {
-      type: Object,
-      default: null
-    }
-  },
-  data() {
-    return {
-      activeMenu: 'profitShareReceiver'
-    }
-  },
-  computed: {
-    currentComponent() {
-      if (this.activeMenu === 'profitShareReceiver') {
-        return 'ProfitShareReceiver'
-      } else if (this.activeMenu === 'profitShareOrder') {
-        return 'ProfitShareOrder'
-      } else if (this.activeMenu === 'tradeOrder') {
-        return 'TradeOrder'
-      }
-      return 'ProfitShareReceiver'
-    }
-  },
-  methods: {
-    handleMenuSelect(key) {
-      this.activeMenu = key
-    }
-  }
-}
-</script>
-
-<style scoped>
-.lakala-container {
-  padding: 0;
-  height: calc(100vh - 120px);
-}
-
-.el-menu-horizontal {
-  height: 60px;
-  font-size: 16px;
-}
-
-.el-header {
-  padding: 0;
-  background-color: #fff;
-  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
-}
-
-.el-main {
-  padding: 30px;
-  background: #fff;
-  margin: 20px;
-  border-radius: 8px;
-  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
-  flex: 1;
-}
-</style>