feat: add default user group settings
This commit is contained in:
@@ -125,6 +125,13 @@ export const createTask = (data) => {
|
||||
export const getUserGroupList = (data) => {
|
||||
return http2.get('/api/v1/admin/user_group/list?page=' + data.page + '&count=' + data.count)
|
||||
}
|
||||
export const setDefaultUserGroup = (data) => {
|
||||
return http2.post('/api/v1/admin/user_group/set_default', data, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
})
|
||||
}
|
||||
/**获取用户组成员列表 */
|
||||
export const getUserGroupMemberList = (data) => {
|
||||
return http2.get('/api/v1/admin/user_group/member_list?group_id=' + data.group_id + '&page=' + data.page + '&count=' + data.count)
|
||||
@@ -174,4 +181,4 @@ export const refundBalance = (data) => {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
</el-table-column>
|
||||
<el-table-column label="升级金额" width="120">
|
||||
<template #default="{ row }">
|
||||
<span v-if="row.floor_price || row.FloorPrice" class="price-text">¥{{ row.floor_price || row.FloorPrice }}</span>
|
||||
<span v-if="getFloorPriceYuan(row) !== null" class="price-text">¥{{ getFloorPriceYuan(row).toFixed(2) }}</span>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -66,6 +66,12 @@
|
||||
{{ row.higher_level_id || row.HigherLevelId || '-' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="默认组" width="110" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag v-if="isDefaultGroup(row)" type="success" size="small">默认</el-tag>
|
||||
<span v-else class="muted-text">-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="类型" width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="(row.fixed || row.Fixed) ? 'warning' : 'success'" size="small">
|
||||
@@ -85,9 +91,12 @@
|
||||
{{ row.create_time || row.CreateTime || row.CreatedAt || '-' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="340" fixed="right">
|
||||
<el-table-column label="操作" width="420" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<div class="action-buttons">
|
||||
<el-button v-if="!isDefaultGroup(row)" type="success" link @click="handleSetDefault(row)">
|
||||
<el-icon><CircleCheck /></el-icon>设为默认
|
||||
</el-button>
|
||||
<el-button type="primary" link @click="handleEdit(row)">
|
||||
<el-icon><Edit /></el-icon>编辑
|
||||
</el-button>
|
||||
@@ -465,9 +474,10 @@
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted, nextTick } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { Plus, Refresh, Edit, User, Delete, Connection, Close, Present } from '@element-plus/icons-vue'
|
||||
import { Plus, Refresh, Edit, User, Delete, Connection, Close, Present, CircleCheck } from '@element-plus/icons-vue'
|
||||
import {
|
||||
getUserGroupList,
|
||||
getUserGroupList,
|
||||
setDefaultUserGroup,
|
||||
getUserGroupMemberList,
|
||||
createUserGroup,
|
||||
updateUserGroupInfo,
|
||||
@@ -546,6 +556,14 @@ const memberFormRef = ref(null)
|
||||
const groupSelectorVisible = ref(false)
|
||||
const selectedHigherGroupInfo = ref(null)
|
||||
|
||||
const getGroupId = (row) => row.group_id ?? row.GroupId ?? row.id ?? row.Id
|
||||
const isDefaultGroup = (row) => row.IsDefault === true || row.is_default === true
|
||||
const getFloorPriceCent = (row) => row.floor_price ?? row.FloorPrice
|
||||
const getFloorPriceYuan = (row) => {
|
||||
const value = getFloorPriceCent(row)
|
||||
return value === undefined || value === null || value === '' ? null : Number(value) / 100
|
||||
}
|
||||
|
||||
// 获取用户组列表
|
||||
const fetchGroupList = async () => {
|
||||
loading.value = true
|
||||
@@ -554,10 +572,6 @@ const fetchGroupList = async () => {
|
||||
const code = res.data?.code || res.code
|
||||
if (code === 200) {
|
||||
let responseData = res.data?.data || res.data
|
||||
responseData.data.forEach(item => {
|
||||
item.CreatedAt = formatTime(item.CreatedAt)
|
||||
})
|
||||
|
||||
if (Array.isArray(responseData)) {
|
||||
groupList.value = responseData
|
||||
total.value = responseData.length
|
||||
@@ -571,6 +585,9 @@ const fetchGroupList = async () => {
|
||||
groupList.value = []
|
||||
total.value = 0
|
||||
}
|
||||
groupList.value.forEach(item => {
|
||||
if (item.CreatedAt) item.CreatedAt = formatTime(item.CreatedAt)
|
||||
})
|
||||
} else {
|
||||
ElMessage.error(res.data?.message || '获取用户组列表失败')
|
||||
}
|
||||
@@ -581,6 +598,30 @@ const fetchGroupList = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const handleSetDefault = (row) => {
|
||||
const groupId = getGroupId(row)
|
||||
const groupName = row.group_name || row.name || row.Name || `用户组 ${groupId}`
|
||||
|
||||
ElMessageBox.confirm(`确认将“${groupName}”设为默认用户组吗?设置后原默认组将自动取消默认。`, '设置默认用户组', {
|
||||
confirmButtonText: '确认设置',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(async () => {
|
||||
try {
|
||||
const res = await setDefaultUserGroup({ user_group_id: groupId })
|
||||
const code = res.data?.code || res.code
|
||||
if (code === 200) {
|
||||
ElMessage.success('默认用户组设置成功')
|
||||
await fetchGroupList()
|
||||
} else {
|
||||
ElMessage.error(res.data?.message || '设置默认用户组失败')
|
||||
}
|
||||
} catch (error) {
|
||||
ElMessage.error(error.response?.data?.message || '设置默认用户组失败')
|
||||
}
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
// 获取成员列表
|
||||
const fetchMemberList = async () => {
|
||||
memberLoading.value = true
|
||||
@@ -659,7 +700,7 @@ const handleEdit = (row) => {
|
||||
const groupName = row.group_name || row.name || row.Name
|
||||
const groupAuth = row.auth || row.Auth || ''
|
||||
const higherLevelId = row.higher_level_id || row.HigherLevelId
|
||||
const floorPrice = row.floor_price || row.FloorPrice
|
||||
const floorPrice = getFloorPriceYuan(row)
|
||||
const fixed = row.fixed || row.Fixed || false
|
||||
|
||||
Object.assign(groupForm, {
|
||||
@@ -743,7 +784,7 @@ const submitForm = () => {
|
||||
submitData.higher_level_id = groupForm.higher_level_id
|
||||
}
|
||||
if (groupForm.floor_price !== undefined && groupForm.floor_price !== null) {
|
||||
submitData.floor_price = groupForm.floor_price
|
||||
submitData.floor_price = Math.round(Number(groupForm.floor_price) * 100)
|
||||
}
|
||||
submitData.fixed = groupForm.fixed
|
||||
|
||||
|
||||
Reference in New Issue
Block a user