wuyi 1 жил өмнө
parent
commit
06b6ff3e05

+ 13 - 7
src/views/DealerView.vue

@@ -16,13 +16,13 @@
         <ElTableColumn prop="phone" label="手机" min-width="120" />
         <ElTableColumn prop="phone" label="手机" min-width="120" />
         <ElTableColumn prop="createdAt" label="注册时间" :formatter="timeFormatter" width="150" />
         <ElTableColumn prop="createdAt" label="注册时间" :formatter="timeFormatter" width="150" />
         <ElTableColumn prop="balance" label="余额" />
         <ElTableColumn prop="balance" label="余额" />
-        <ElTableColumn prop="rate" label="费率" />
+        <ElTableColumn v-if="isAdmin" prop="rate" label="费率" />
         <ElTableColumn prop="send" label="已发送" />
         <ElTableColumn prop="send" label="已发送" />
         <ElTableColumn label="操作" align="center" width="300">
         <ElTableColumn label="操作" align="center" width="300">
             <template #default="{ row }">
             <template #default="{ row }">
                 <ElButton plain @click="recharge(row.id)">余额充值</ElButton>
                 <ElButton plain @click="recharge(row.id)">余额充值</ElButton>
-                <ElButton plain @click="rate(row.id)">修改费率</ElButton>
-                <ElButton type="primary" size="small" @click="detail(row)">充值记录</ElButton>
+                <ElButton v-if="isAdmin" plain @click="rate(row.id)">修改费率</ElButton>
+                <ElButton type="primary" size="small" @click="detail(row)">余额记录</ElButton>
             </template>
             </template>
         </ElTableColumn>
         </ElTableColumn>
     </PagingTable>
     </PagingTable>
@@ -42,6 +42,9 @@
         <ElFormItem v-if="isSuperApi" prop="roles" label="角色">
         <ElFormItem v-if="isSuperApi" prop="roles" label="角色">
             <EnumSelect v-model="model.roles" :enum="myUserRole" multiple :multiple-limit="1" />
             <EnumSelect v-model="model.roles" :enum="myUserRole" multiple :multiple-limit="1" />
         </ElFormItem>
         </ElFormItem>
+        <ElFormItem prop="balance" label="初始余额">
+            <ElInput v-model="model.balance" placeholder="请输入初始余额" style="width: 240px" />
+        </ElFormItem>
     </EditDialog>
     </EditDialog>
     <ElDialog v-model="showDetailDialog" title="详情" width="500px">
     <ElDialog v-model="showDetailDialog" title="详情" width="500px">
         <PagingTable url="/balance/records/" :where="{ userId: (selectedRow || {}).id }" :order="{createdAt:'DESC'}"
         <PagingTable url="/balance/records/" :where="{ userId: (selectedRow || {}).id }" :order="{createdAt:'DESC'}"
@@ -75,6 +78,7 @@ import { ElMessage, ElMessageBox } from 'element-plus'
 import { useClipboard } from '@vueuse/core'
 import { useClipboard } from '@vueuse/core'
 import { useUserStore } from '@/stores/user'
 import { useUserStore } from '@/stores/user'
 
 
+const isAdmin = inject('isAdmin')
 const isSuperApi = inject('isSuperApi')
 const isSuperApi = inject('isSuperApi')
 const where = ref({})
 const where = ref({})
 const timeFormatter = useTimeFormatter()
 const timeFormatter = useTimeFormatter()
@@ -95,12 +99,16 @@ const myUserRole = {
 }
 }
 
 
 async function submit() {
 async function submit() {
-    if (!model.value.roles){
+    if (!model.value.roles) {
         model.value.roles = ['user']
         model.value.roles = ['user']
     }
     }
     // 上级
     // 上级
     model.value.invitor = user.id
     model.value.invitor = user.id
-    await http.put('/admin/users', model.value)
+    await http.put('/admin/users', model.value).then(async (res) => {
+        if (model.value.balance) {
+            await http.get('/balance/recharge/' + res.id + '/' + model.value.balance)
+        }
+    })
     ElMessage.success('保存成功')
     ElMessage.success('保存成功')
 }
 }
 
 
@@ -111,8 +119,6 @@ const recharge = async (userId) => {
         inputPattern: /^\d+(\.\d{1,2})?$/,
         inputPattern: /^\d+(\.\d{1,2})?$/,
         inputErrorMessage: '金额不能超出俩位小数!'
         inputErrorMessage: '金额不能超出俩位小数!'
     }).then(async ({ value }) => {
     }).then(async ({ value }) => {
-        console.log(userId)
-        console.log(value)
         const url = '/balance/recharge/' + userId + '/' + value
         const url = '/balance/recharge/' + userId + '/' + value
         await http.get(url)
         await http.get(url)
         table.value.refresh()
         table.value.refresh()