diff --git a/web/src/api/index.js b/web/src/api/index.js index 926c13d..134468f 100644 --- a/web/src/api/index.js +++ b/web/src/api/index.js @@ -44,68 +44,68 @@ export default { // Mock 数据 const mockUsers = [ { - id: 1, - phone: '13800138001', - email: 'zhang.wei@example.com', + id: 11111111, + phone: '15021982682', + wechat: 'f1498480844', created_at: '2024-01-15T10:30:00Z', - last_login: '2024-11-13T09:15:00Z', - is_active: true + notes: '测试用户1', + remaining_count: 1 }, { - id: 2, + id: 11111112, phone: '13800138002', - email: 'li.ming@example.com', + wechat: 'wx_limming2024', created_at: '2024-02-20T14:20:00Z', - last_login: '2024-11-12T16:45:00Z', - is_active: true + notes: '付费用户', + remaining_count: 5 }, { - id: 3, + id: 11111113, phone: '13800138003', - email: 'wang.fang@example.com', + wechat: null, created_at: '2024-03-10T08:45:00Z', - last_login: null, - is_active: false + notes: null, + remaining_count: 0 }, { - id: 4, + id: 11111114, phone: '13800138004', - email: 'chen.jun@example.com', + wechat: 'chenjun_vip', created_at: '2024-04-05T11:30:00Z', - last_login: '2024-11-10T13:20:00Z', - is_active: true + notes: 'VIP用户', + remaining_count: 10 }, { - id: 5, + id: 11111115, phone: '13800138005', - email: 'liu.xia@example.com', + wechat: 'liuxia888', created_at: '2024-05-12T16:15:00Z', - last_login: '2024-11-11T10:30:00Z', - is_active: true + notes: '体验用户', + remaining_count: 3 }, { - id: 6, + id: 11111116, phone: '13800138006', - email: null, + wechat: null, created_at: '2024-06-18T09:00:00Z', - last_login: null, - is_active: false + notes: '新注册用户', + remaining_count: 2 }, { - id: 7, + id: 11111117, phone: '13800138007', - email: 'zhao.lei@example.com', + wechat: 'zhaolei2024', created_at: '2024-07-22T12:45:00Z', - last_login: '2024-11-13T08:30:00Z', - is_active: true + notes: null, + remaining_count: 0 }, { - id: 8, + id: 11111118, phone: '13800138008', - email: 'sun.mei@example.com', + wechat: 'sunmei_user', created_at: '2024-08-30T15:20:00Z', - last_login: '2024-11-09T14:15:00Z', - is_active: true + notes: '活跃用户', + remaining_count: 7 } ] @@ -119,10 +119,10 @@ export default { ) } - // 邮箱搜索 - if (params.email) { + // 微信号搜索 + if (params.wechat) { filteredUsers = filteredUsers.filter(user => - user.email && user.email.includes(params.email) + user.wechat && user.wechat.includes(params.wechat) ) } diff --git a/web/src/components/user-management/LimitSettingModal.vue b/web/src/components/user-management/LimitSettingModal.vue new file mode 100644 index 0000000..3ff94fb --- /dev/null +++ b/web/src/components/user-management/LimitSettingModal.vue @@ -0,0 +1,208 @@ + + + + + diff --git a/web/src/views/user-management/user-list/index.vue b/web/src/views/user-management/user-list/index.vue index 69ea06d..e240460 100644 --- a/web/src/views/user-management/user-list/index.vue +++ b/web/src/views/user-management/user-list/index.vue @@ -9,18 +9,13 @@ import { NSwitch, NTag, NPopconfirm, - NModal, - NCard, - NSelect, - NInputNumber, - NText, - NDivider, } from 'naive-ui' import CommonPage from '@/components/page/CommonPage.vue' import QueryBarItem from '@/components/query-bar/QueryBarItem.vue' import CrudModal from '@/components/table/CrudModal.vue' import CrudTable from '@/components/table/CrudTable.vue' +import LimitSettingModal from '@/components/user-management/LimitSettingModal.vue' import { formatDate, renderIcon } from '@/utils' import { useCRUD } from '@/composables' @@ -35,21 +30,8 @@ const vPermission = resolveDirective('permission') // 次数设置弹窗相关状态 const limitModalVisible = ref(false) -const limitForm = ref({ - remainingCount: 0, - type: '免费体验', - experienceCount: 1, - notes: '' -}) const currentUser = ref(null) -// 类型选项 -const typeOptions = [ - { label: '免费体验', value: '免费体验' }, - { label: '付费用户', value: '付费用户' }, - { label: 'VIP用户', value: 'VIP用户' } -] - const { modalVisible, modalTitle, @@ -90,13 +72,13 @@ const columns = [ ellipsis: { tooltip: true }, }, { - title: '邮箱', - key: 'email', + title: '微信号', + key: 'wechat', width: 120, align: 'center', ellipsis: { tooltip: true }, render(row) { - return row.email || '-' + return row.wechat || '-' }, }, { @@ -106,48 +88,26 @@ const columns = [ width: 160, ellipsis: { tooltip: true }, render(row) { - return h( - NButton, - { size: 'small', type: 'text', ghost: true }, - { - default: () => (row.created_at ? formatDate(row.created_at) : '-'), - icon: renderIcon('mdi:calendar', { size: 16 }), - } - ) + return row.created_at ? formatDate(row.created_at) : '-' }, }, { - title: '最后登录', - key: 'last_login', + title: '备注', + key: 'notes', align: 'center', - width: 160, + width: 120, ellipsis: { tooltip: true }, render(row) { - return h( - NButton, - { size: 'small', type: 'text', ghost: true }, - { - default: () => (row.last_login ? formatDate(row.last_login) : '未登录'), - icon: renderIcon('mdi:login', { size: 16 }), - } - ) + return row.notes || '-' }, }, { - title: '状态', - key: 'is_active', - width: 80, + title: '剩余体验次数', + key: 'remaining_count', + width: 120, align: 'center', render(row) { - return h(NSwitch, { - size: 'small', - rubberBand: false, - value: row.is_active, - loading: !!row.publishing, - checkedValue: true, - uncheckedValue: false, - onUpdateValue: () => handleUpdateStatus(row), - }) + return row.remaining_count || 0 }, }, { @@ -204,24 +164,13 @@ function handleViewDetail(row) { // 次数设置 function handleSetLimit(row) { currentUser.value = row - // 初始化表单数据,这里可以从后端获取用户当前的次数设置 - limitForm.value = { - remainingCount: row.remaining_count || 0, - type: row.user_type || '免费体验', - experienceCount: row.experience_count || 1, - notes: row.notes || '' - } limitModalVisible.value = true } // 保存次数设置 -async function handleSaveLimitSetting() { +async function handleSaveLimitSetting(data) { try { // 这里调用API保存次数设置 - const data = { - user_id: currentUser.value.id, - ...limitForm.value - } // await api.setUserLimit(data) $message.success('次数设置保存成功') limitModalVisible.value = false @@ -231,26 +180,6 @@ async function handleSaveLimitSetting() { } } -// 取消次数设置 -function handleCancelLimitSetting() { - limitModalVisible.value = false - limitForm.value = { - remainingCount: 0, - type: '免费体验', - experienceCount: 1, - notes: '' - } - currentUser.value = null -} - -// 体验次数增减 -function handleExperienceCountChange(delta) { - const newCount = limitForm.value.experienceCount + delta - if (newCount >= 0) { - limitForm.value.experienceCount = newCount - } -} - const validateForm = { phone: [ { @@ -298,12 +227,12 @@ const validateForm = { @keypress.enter="$table?.handleSearch()" /> - + @@ -337,128 +266,11 @@ const validateForm = { - -
- -
- 剩余估值次数: - {{ limitForm.remainingCount }} -
- - - - -
- 类型: - -
- - -
- 体验次数: -
- - - - - {{ limitForm.experienceCount }} - - + - -
-
- - -
- 备注: -
- - - -
- - 取消 - - - 确定 - -
-
-
+ -