Bladeren bron

财务-提现管理

Alex 9 maanden geleden
bovenliggende
commit
662e776da6

+ 67 - 0
src/views/finance/withdrawal/components/audit-dialog.vue

@@ -0,0 +1,67 @@
+<!-- 审核弹窗 -->
+<template>
+  <ele-modal v-model="visible" title="提现审核" width="500">
+    <el-form ref="formRef" :model="form" label-width="100px">
+      <el-form-item label="审核结果" required>
+        <el-radio-group v-model="form.auditResult">
+          <el-radio :label="1">通过</el-radio>
+          <el-radio :label="2">拒绝</el-radio>
+        </el-radio-group>
+      </el-form-item>
+    </el-form>
+
+    <template #footer>
+      <el-button @click="visible = false">取消</el-button>
+      <el-button type="primary" @click="handleSubmit">确定</el-button>
+    </template>
+  </ele-modal>
+</template>
+
+<script setup>
+  import { ref, reactive } from 'vue';
+  import request from '@/utils/request';
+  import { ElMessage } from 'element-plus';
+
+  const emit = defineEmits(['success']);
+  const visible = defineModel({ type: Boolean });
+
+  const form = reactive({
+    auditResult: 1,
+    idList: []
+  });
+
+  const formRef = ref();
+
+  // 打开弹窗
+  const handleOpen = (ids) => {
+    form.idList = Array.isArray(ids) ? ids : [ids];
+    form.auditResult = 1;
+    visible.value = true;
+  };
+
+  // 提交审核
+  const handleSubmit = async () => {
+    try {
+      request
+        .post('/sys/finance/withdrawAudit', {
+          idList: form.idList,
+          auditResult: form.auditResult
+        })
+        .then((res) => {
+          if (res.data.code === 200) {
+            ElMessage.success('审核成功');
+            visible.value = false;
+            emit('success');
+          } else {
+            ElMessage.error(res.data.msg);
+          }
+        });
+    } catch (error) {
+      console.error('审核失败:', error);
+    }
+  };
+
+  defineExpose({
+    handleOpen
+  });
+</script>

+ 35 - 7
src/views/finance/withdrawal/components/page-search.vue

@@ -17,26 +17,54 @@
   let { proxy } = getCurrentInstance();
   const emit = defineEmits(['search']);
 
+  const props = defineProps({
+    status: {
+      type: String,
+      default: ''
+    }
+  });
+
   const formItems = reactive([
-    { type: 'input', label: '用户UID', prop: 'uid' },
-    { type: 'dictSelect', label: '状态', prop: 'status' },
+    { type: 'input', label: '用户名', prop: 'nickName' },
     {
-      type: 'date',
+      type: 'dictSelect',
+      label: '状态',
+      prop: 'status',
+      props: { code: 'withdrawal_status' }
+    },
+    {
+      type: 'daterange',
       label: '时间',
-      prop: 'time',
+      prop: 'timeRange',
       props: {
+        valueFormat: 'YYYY-MM-DD',
         format: 'YYYY-MM-DD',
-        valueFormat: 'YYYY-MM-DD'
+        startPlaceholder: '开始日期',
+        endPlaceholder: '结束日期',
+        onChange: (value) => {
+          initKeys.startTime = value ? value[0] : '';
+          initKeys.endTime = value ? value[1] : '';
+          searchRef.value?.setData(initKeys);
+        }
       }
     }
   ]);
 
   const initKeys = reactive({
-    date: '',
-    uid: '',
+    startTime: '',
+    endTime: '',
+    nickName: '',
     status: ''
   });
 
+  // watch(
+  //   () => props.status,
+  //   (newVal) => {
+  //     initKeys.status = newVal;
+  //     searchRef.value?.setData(initKeys);
+  //   }
+  // );
+
   const searchRef = ref(null);
   /** 搜索 */
   const search = (data) => {

+ 89 - 41
src/views/finance/withdrawal/index.vue

@@ -1,45 +1,45 @@
 <template>
   <ele-page flex-table>
-    <page-search @search="reload"></page-search>
+    <page-search @search="reload" :status="useStatus"></page-search>
 
     <common-table ref="pageRef" :pageConfig="pageConfig" :columns="columns">
       <template #toolbar>
         <div class="flex items-center mb-4">
           <el-statistic
-            :value="693700"
+            :value="statistics.totalWithdrawMoney"
             title="提现累计金额"
             value-style="font-size:30px"
             class="mr-10"
           ></el-statistic>
           <el-statistic
-            :value="693700"
+            :value="statistics.unWithdrawMoney"
             title="待提现金额"
             value-style="font-size:30px"
             class="mr-10"
           ></el-statistic>
           <el-statistic
-            :value="693700"
+            :value="statistics.auditWithdrawMoney"
             title="提现中金额"
             value-style="font-size:30px"
             class="mr-10"
           ></el-statistic>
           <el-statistic
-            :value="693700"
+            :value="statistics.withdrawSuccessMoney"
             title="已提现金额"
             value-style="font-size:30px"
             class="mr-10"
           ></el-statistic>
           <el-statistic
-            :value="693700"
+            :value="statistics.averageWithdrawDuration"
             title="平均提现时长"
             value-style="font-size:30px"
             class="mr-10"
           ></el-statistic>
           <el-statistic
-            :value="693700"
+            :value="statistics.noWithdrawMoney"
             title="长期不提现金额"
             value-style="font-size:30px"
-            class="mr-10"Audit
+            class="mr-10"
           ></el-statistic>
         </div>
 
@@ -55,14 +55,18 @@
         </div>
 
         <el-radio-group @change="handleStatusChange" v-model="useStatus">
-          <el-radio-button label="全部" value="1" />
+          <el-radio-button label="全部" value="" />
           <el-radio-button label="提现中" value="2" />
-          <el-radio-button label="提现完成" value="3" />
-          <el-radio-button label="提现失败" value="4" />
-          <el-radio-button label="长期不提现用户" value="5" />
+          <el-radio-button label="提现完成" value="4" />
+          <el-radio-button label="提现失败" value="5" />
+          <el-radio-button label="长期不提现用户" value="6" />
         </el-radio-group>
       </template>
 
+      <template #status="{ row }">
+        {{ statusDicts.find((d) => d.value == row.status)?.label }}
+      </template>
+
       <template #action="{ row }">
         <div>
           <el-button
@@ -76,6 +80,7 @@
           <el-button
             type="primary"
             link
+            v-if="row.status == 1"
             v-permission="'finance:withdrawal:audit'"
             @click="handleChangeStatus(row)"
           >
@@ -85,24 +90,65 @@
       </template>
     </common-table>
 
+    <!-- 审核弹窗 -->
+    <audit-dialog ref="auditDialogRef" @success="reload" />
   </ele-page>
 </template>
 
 <script setup>
-  import { ref, reactive } from 'vue';
+  import { ref, reactive, onMounted } from 'vue';
   import CommonTable from '@/components/CommonPage/CommonTable.vue';
   import pageSearch from './components/page-search.vue';
   import { useDictData } from '@/utils/use-dict-data';
   import request from '@/utils/request';
+  import auditDialog from './components/audit-dialog.vue';
 
   defineOptions({ name: 'withdrawal' });
-  const [useStatusDicts] = useDictData(['use_status']);
 
-  const useStatus = ref('1');
+  // 添加统计数据的响应式对象
+  const statistics = reactive({
+    totalWithdrawMoney: 0,
+    unWithdrawMoney: 0,
+    auditWithdrawMoney: 0,
+    withdrawSuccessMoney: 0,
+    averageWithdrawDuration: 0,
+    noWithdrawMoney: 0
+  });
+
+  // 获取统计数据
+  async function fetchStatistics() {
+    try {
+      const res = await request.get('/sys/finance/withdrawSum');
+      if (res.data.code === 200) {
+        Object.assign(statistics, res.data.data);
+      }
+    } catch (error) {
+      console.error('获取统计数据失败:', error);
+    }
+  }
+
+  onMounted(() => {
+    fetchStatistics();
+  });
+
+  const [statusDicts] = useDictData(['withdrawal_status']);
+
+  const useStatus = ref('');
   function handleStatusChange(value) {
-    pageRef.value.reload({ useStatus: value });
+    if (value === '6') {
+      pageConfig.pageUrl = '/sys/finance/noWithdrawList';
+      pageRef.value?.reload();
+    } else {
+      pageConfig.pageUrl = '/sys/finance/withdrawList';
+      pageRef.value.reload({ status: value });
+    }
   }
 
+  //提现类型 	string
+  const withdrawTypeDicts = ref([
+    { label: '微信', value: 1 },
+    { label: '支付宝', value: 2 }
+  ]);
   /** 表格列配置 */
   const columns = ref([
     {
@@ -113,30 +159,34 @@
       fixed: 'left'
     },
     { label: '提现时间', prop: 'createTime', align: 'center', width: 180 },
-    { label: '用户UID', prop: 'uid', align: 'center', minWidth: 140 },
+    { label: '用户名', prop: 'nickName', align: 'center', minWidth: 140 },
     {
       label: '支付单号/流水号',
-      prop: 'paymentCode',
+      prop: 'transferNo',
       align: 'center',
       minWidth: 160
     },
-    { label: '对方账户', prop: 'addressDetail', align: 'center' },
-    { label: '金额', prop: 'money', align: 'center' },
+    {
+      label: '对方账户',
+      prop: 'withdrawType',
+      align: 'center',
+      formatter: (row) =>
+        withdrawTypeDicts.value.find((d) => d.value == row.withdrawType)
+          ?.label
+    },
+    { label: '金额', prop: 'withdrawMoney', align: 'center' },
     {
       label: '交易状态',
-      prop: 'useStatus',
+      prop: 'status',
       align: 'center',
       formatter: (row) =>
-        useStatusDicts.value.find((d) => d.dictValue == row.useStatus)
-          ?.dictLabel
+        statusDicts.value.find((d) => d.dictValue == row.status)?.dictLabel
     },
     {
       label: '交易类型',
-      prop: 'paymentType',
+      prop: 'withdrawType',
       align: 'center',
-      formatter: (row) =>
-        useStatusDicts.value.find((d) => d.dictValue == row.useStatus)
-          ?.dictLabel
+      formatter: (row) => '提现'
     },
     {
       columnKey: 'action',
@@ -150,10 +200,10 @@
 
   /** 页面组件实例 */
   const pageRef = ref(null);
+  const auditDialogRef = ref(null);
 
   const pageConfig = reactive({
-    pageUrl: '/baseinfo/godown/pagelist',
-    exportUrl: '/baseinfo/godown/export',
+    pageUrl: '/sys/finance/withdrawList',
     fileName: '提现管理',
     cacheKey: 'withdrawalTable'
   });
@@ -164,19 +214,17 @@
   }
 
   //审核
-  function handleAudit(row) {
-    pageRef.value?.messageBoxConfirm({
-      message: '确认审核?',
-      fetch: () => {}
-    });
+  function handleChangeStatus(row) {
+    auditDialogRef.value?.handleOpen(row.id);
   }
 
-  //编辑页面
-  const editRef = ref(null);
-  function handleStepAudit(row) {
-    pageRef.value?.messageBoxConfirm({
-      message: '确认一键审核?',
-      fetch: () => {}
-    });
+  //一键审核
+  function handleStepAudit() {
+    const selections = pageRef.value?.getSelections();
+    if (!selections?.length) {
+      ElMessage.warning('请至少选择一条数据');
+      return;
+    }
+    auditDialogRef.value?.handleOpen(selections.map(item => item.id));
   }
 </script>