Browse Source

✨ feat: 增加赠送次数免审功能

Pchen0 1 month ago
parent
commit
9c2f049c73
3 changed files with 53 additions and 2 deletions
  1. 9 0
      src/api/user.js
  2. 1 1
      src/components/userCard/userCard.vue
  3. 43 1
      src/pages/admin/user/userList.vue

+ 9 - 0
src/api/user.js

@@ -7,6 +7,7 @@ const api = {
   BindEmail: '/User/BindEmail',
   BindEmail: '/User/BindEmail',
   GetRepos: '/User/GetRepos',
   GetRepos: '/User/GetRepos',
   AdminUserList: '/Admin/User/GetUserList',
   AdminUserList: '/Admin/User/GetUserList',
+  AdminSetSendCountAutoApprove: '/Admin/User/SetSendCountAutoApprove',
   AdminChangeLepaoCount: '/Admin/User/ChangeLepaoCount',
   AdminChangeLepaoCount: '/Admin/User/ChangeLepaoCount',
   AdminGetReqLog: '/Admin/User/GetReqLog',
   AdminGetReqLog: '/Admin/User/GetReqLog',
   AdminGetReqLogDetail: '/Admin/User/GetReqLogDetail'
   AdminGetReqLogDetail: '/Admin/User/GetReqLogDetail'
@@ -44,6 +45,14 @@ export function adminChangeLepaoCount(parameter) {
   })
   })
 }
 }
 
 
+export function adminSetSendCountAutoApprove(parameter) {
+  return request({
+    url: api.AdminSetSendCountAutoApprove,
+    method: 'post',
+    data: parameter
+  })
+}
+
 export function BindEmail(parameter) {
 export function BindEmail(parameter) {
   return request({
   return request({
     url: api.BindEmail,
     url: api.BindEmail,

+ 1 - 1
src/components/userCard/userCard.vue

@@ -83,7 +83,7 @@ const handleBeforeOk = async (done) => {
       return false
       return false
     }
     }
 
 
-    Message.success('已提交审核,审核通过后接收方将到账')
+    Message.success(res.msg || '操作成功')
     done()
     done()
     GetCount()
     GetCount()
   } catch (error) {
   } catch (error) {

+ 43 - 1
src/pages/admin/user/userList.vue

@@ -99,6 +99,13 @@
                 <template #last_login_type="{ record }">
                 <template #last_login_type="{ record }">
                     <span>{{ formatLastLoginType(record.last_login_type) }}</span>
                     <span>{{ formatLastLoginType(record.last_login_type) }}</span>
                 </template>
                 </template>
+                <template #send_count_auto_approve="{ record }">
+                    <a-switch
+                        :model-value="isSendCountAutoApprove(record)"
+                        :loading="whitelistLoadingUuid === record.uuid"
+                        @change="(checked) => onSendCountAutoApproveChange(record, checked)"
+                    />
+                </template>
                 <template #optional="{ record }">
                 <template #optional="{ record }">
                     <a-button @click="changeCount(record)">更改次数</a-button>
                     <a-button @click="changeCount(record)">更改次数</a-button>
                 </template>
                 </template>
@@ -125,7 +132,7 @@
 
 
 <script setup>
 <script setup>
 import { ref, reactive, onMounted } from 'vue'
 import { ref, reactive, onMounted } from 'vue'
-import { adminGetUserList, adminChangeLepaoCount } from '@/api/user'
+import { adminGetUserList, adminChangeLepaoCount, adminSetSendCountAutoApprove } from '@/api/user'
 import { Notification, Message } from '@arco-design/web-vue'
 import { Notification, Message } from '@arco-design/web-vue'
 
 
 const visible = ref(false)
 const visible = ref(false)
@@ -151,6 +158,37 @@ const pagination = reactive({
 
 
 const loading = ref(false)
 const loading = ref(false)
 const data = ref([])
 const data = ref([])
+const whitelistLoadingUuid = ref('')
+
+const isSendCountAutoApprove = (record) => Number(record?.send_count_auto_approve) === 1
+
+const onSendCountAutoApproveChange = async (record, checked) => {
+    if (!record?.uuid || whitelistLoadingUuid.value) return
+    const next = checked === true ? 1 : 0
+    whitelistLoadingUuid.value = record.uuid
+    try {
+        const res = await adminSetSendCountAutoApprove({
+            userid: record.uuid,
+            send_count_auto_approve: next
+        })
+        if (!res || res.code !== 0) {
+            Notification.error({
+                title: '保存失败',
+                content: res?.msg ?? '请稍后再试'
+            })
+            return
+        }
+        record.send_count_auto_approve = next
+        Message.success(next ? '已加入赠送免审白名单' : '已关闭赠送免审')
+    } catch (error) {
+        Notification.error({
+            title: '保存失败',
+            content: error.message || '请稍后再试'
+        })
+    } finally {
+        whitelistLoadingUuid.value = ''
+    }
+}
 
 
 const columns = [
 const columns = [
 
 
@@ -193,6 +231,10 @@ const columns = [
         title: '剩余乐跑次数',
         title: '剩余乐跑次数',
         dataIndex: 'lepao_count',
         dataIndex: 'lepao_count',
         width: 120,
         width: 120,
+    }, {
+        title: '赠送免审',
+        slotName: 'send_count_auto_approve',
+        width: 110,
     }, {
     }, {
         title: '操作',
         title: '操作',
         slotName: 'optional',
         slotName: 'optional',