Przeglądaj źródła

feat(用户管理): 新增扣减余额功能

在客户列表页面添加了“扣减余额”按钮,用户点击后可输入扣减金额并提交请求,成功后会显示操作结果。此功能增强了用户账户管理的灵活性。
ylong 2 tygodni temu
rodzic
commit
e3adf2a092
1 zmienionych plików z 38 dodań i 0 usunięć
  1. 38 0
      src/views/customer/list/index.vue

+ 38 - 0
src/views/customer/list/index.vue

@@ -55,6 +55,14 @@
                     >
                         [账户明细]
                     </el-button>
+                    <el-button
+                        type="danger"
+                        link
+                        v-permission="'customer:list:reduceUserAccount'"
+                        @click="handleReduceAccount(row)"
+                    >
+                        [扣减余额]
+                    </el-button>
                     <el-button
                         type="success"
                         link
@@ -195,6 +203,36 @@
         });
     }
 
+    //扣减余额
+    function handleReduceAccount(row) {
+        ElMessageBox.prompt(
+            `请输入用户"${row.nickName}"(ID: ${row.id})的扣减金额`,
+            '扣减余额',
+            {
+                confirmButtonText: '确定',
+                cancelButtonText: '取消',
+                inputPlaceholder: '请输入扣减金额',
+                inputPattern: /^([1-9]\d*)(\.\d{1,2})?$/,
+                inputErrorMessage: '请输入大于0的金额,最多两位小数',
+                draggable: true
+            }
+        ).then(({ value }) => {
+            request
+                .post('/user/userAccountInfo/reduceUserAccount', {
+                    userId: row.id,
+                    reduceMoney: Number(value)
+                })
+                .then((res) => {
+                    if (res.data.code == 200) {
+                        EleMessage.success('操作成功');
+                        reload();
+                    } else {
+                        EleMessage.error(res.data.msg);
+                    }
+                });
+        });
+    }
+
     //编辑页面
     const editRef = ref(null);
     function handleUpdate(row) {