commit
a99a125c2b
36
src/api/member/tag/index.ts
Normal file
36
src/api/member/tag/index.ts
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import request from '@/config/axios'
|
||||||
|
|
||||||
|
export interface TagVO {
|
||||||
|
id: number
|
||||||
|
name: string
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询会员标签列表
|
||||||
|
export const getMemberTagPage = async (params) => {
|
||||||
|
return await request.get({ url: `/member/tag/page`, params })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询会员标签详情
|
||||||
|
export const getMemberTag = async (id: number) => {
|
||||||
|
return await request.get({ url: `/member/tag/get?id=` + id })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增会员标签
|
||||||
|
export const createMemberTag = async (data: TagVO) => {
|
||||||
|
return await request.post({ url: `/member/tag/create`, data })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改会员标签
|
||||||
|
export const updateMemberTag = async (data: TagVO) => {
|
||||||
|
return await request.put({ url: `/member/tag/update`, data })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除会员标签
|
||||||
|
export const deleteMemberTag = async (id: number) => {
|
||||||
|
return await request.delete({ url: `/member/tag/delete?id=` + id })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 导出会员标签 Excel
|
||||||
|
export const exportMemberTag = async (params) => {
|
||||||
|
return await request.download({ url: `/member/tag/export-excel`, params })
|
||||||
|
}
|
91
src/views/member/tag/TagForm.vue
Normal file
91
src/views/member/tag/TagForm.vue
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
<template>
|
||||||
|
<Dialog :title="dialogTitle" v-model="dialogVisible">
|
||||||
|
<el-form
|
||||||
|
ref="formRef"
|
||||||
|
:model="formData"
|
||||||
|
:rules="formRules"
|
||||||
|
label-width="100px"
|
||||||
|
v-loading="formLoading"
|
||||||
|
>
|
||||||
|
<el-form-item label="标签名称" prop="name">
|
||||||
|
<el-input v-model="formData.name" placeholder="请输入标签名称" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
|
||||||
|
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||||
|
</template>
|
||||||
|
</Dialog>
|
||||||
|
</template>
|
||||||
|
<script setup lang="ts">
|
||||||
|
import * as TagApi from '@/api/member/tag'
|
||||||
|
|
||||||
|
const { t } = useI18n() // 国际化
|
||||||
|
const message = useMessage() // 消息弹窗
|
||||||
|
|
||||||
|
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||||
|
const dialogTitle = ref('') // 弹窗的标题
|
||||||
|
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||||
|
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
||||||
|
const formData = ref({
|
||||||
|
id: undefined,
|
||||||
|
name: undefined
|
||||||
|
})
|
||||||
|
const formRules = reactive({
|
||||||
|
name: [{ required: true, message: '标签名称不能为空', trigger: 'blur' }]
|
||||||
|
})
|
||||||
|
const formRef = ref() // 表单 Ref
|
||||||
|
|
||||||
|
/** 打开弹窗 */
|
||||||
|
const open = async (type: string, id?: number) => {
|
||||||
|
dialogVisible.value = true
|
||||||
|
dialogTitle.value = t('action.' + type)
|
||||||
|
formType.value = type
|
||||||
|
resetForm()
|
||||||
|
// 修改时,设置数据
|
||||||
|
if (id) {
|
||||||
|
formLoading.value = true
|
||||||
|
try {
|
||||||
|
formData.value = await TagApi.getMemberTag(id)
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||||
|
|
||||||
|
/** 提交表单 */
|
||||||
|
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||||
|
const submitForm = async () => {
|
||||||
|
// 校验表单
|
||||||
|
if (!formRef) return
|
||||||
|
const valid = await formRef.value.validate()
|
||||||
|
if (!valid) return
|
||||||
|
// 提交请求
|
||||||
|
formLoading.value = true
|
||||||
|
try {
|
||||||
|
const data = formData.value as unknown as TagApi.TagVO
|
||||||
|
if (formType.value === 'create') {
|
||||||
|
await TagApi.createMemberTag(data)
|
||||||
|
message.success(t('common.createSuccess'))
|
||||||
|
} else {
|
||||||
|
await TagApi.updateMemberTag(data)
|
||||||
|
message.success(t('common.updateSuccess'))
|
||||||
|
}
|
||||||
|
dialogVisible.value = false
|
||||||
|
// 发送操作成功的事件
|
||||||
|
emit('success')
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置表单 */
|
||||||
|
const resetForm = () => {
|
||||||
|
formData.value = {
|
||||||
|
id: undefined,
|
||||||
|
name: undefined
|
||||||
|
}
|
||||||
|
formRef.value?.resetFields()
|
||||||
|
}
|
||||||
|
</script>
|
69
src/views/member/tag/components/MemberTagSelect.vue
Normal file
69
src/views/member/tag/components/MemberTagSelect.vue
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
<template>
|
||||||
|
<el-select v-model="tagIds" placeholder="请选择用户标签" clearable multiple class="!w-240px">
|
||||||
|
<el-option v-for="tag in tags" :key="tag.id" :label="tag.name" :value="tag.id" />
|
||||||
|
</el-select>
|
||||||
|
<el-button
|
||||||
|
v-if="showAdd"
|
||||||
|
type="primary"
|
||||||
|
class="ml-2"
|
||||||
|
link
|
||||||
|
@click="openForm('create')"
|
||||||
|
v-hasPermi="['member:tag:create']"
|
||||||
|
>
|
||||||
|
新增标签
|
||||||
|
</el-button>
|
||||||
|
|
||||||
|
<!-- 表单弹窗:添加 -->
|
||||||
|
<TagForm ref="formRef" @success="getList" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import * as TagApi from '@/api/member/tag'
|
||||||
|
import TagForm from '@/views/member/tag/TagForm.vue'
|
||||||
|
|
||||||
|
defineOptions({ name: 'MemberTagSelect' })
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
/** 下拉框选中值 **/
|
||||||
|
modelValue: {
|
||||||
|
type: Array,
|
||||||
|
default: undefined
|
||||||
|
},
|
||||||
|
/** 是否显示“新增标签”按钮 **/
|
||||||
|
showAdd: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const emit = defineEmits(['update:modelValue'])
|
||||||
|
defineExpose({
|
||||||
|
showAdd: props.showAdd
|
||||||
|
})
|
||||||
|
|
||||||
|
const tagIds = computed({
|
||||||
|
get() {
|
||||||
|
return props.modelValue
|
||||||
|
},
|
||||||
|
set(value: any) {
|
||||||
|
emit('update:modelValue', value)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const tags = ref<TagApi.TagVO[]>([])
|
||||||
|
|
||||||
|
const getList = async () => {
|
||||||
|
const data = await TagApi.getMemberTagPage({})
|
||||||
|
tags.value = data.list
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 添加用户标签表单弹框 */
|
||||||
|
const formRef = ref()
|
||||||
|
const openForm = (type: string, id?: number) => {
|
||||||
|
formRef.value.open(type, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 初始化 */
|
||||||
|
onMounted(() => {
|
||||||
|
getList()
|
||||||
|
})
|
||||||
|
</script>
|
179
src/views/member/tag/index.vue
Normal file
179
src/views/member/tag/index.vue
Normal file
@ -0,0 +1,179 @@
|
|||||||
|
<template>
|
||||||
|
<ContentWrap>
|
||||||
|
<!-- 搜索工作栏 -->
|
||||||
|
<el-form
|
||||||
|
class="-mb-15px"
|
||||||
|
:model="queryParams"
|
||||||
|
ref="queryFormRef"
|
||||||
|
:inline="true"
|
||||||
|
label-width="68px"
|
||||||
|
>
|
||||||
|
<el-form-item label="标签名称" prop="name">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.name"
|
||||||
|
placeholder="请输入标签名称"
|
||||||
|
clearable
|
||||||
|
@keyup.enter="handleQuery"
|
||||||
|
class="!w-240px"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="创建时间" prop="createTime">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="queryParams.createTime"
|
||||||
|
value-format="YYYY-MM-DD HH:mm:ss"
|
||||||
|
type="daterange"
|
||||||
|
start-placeholder="开始日期"
|
||||||
|
end-placeholder="结束日期"
|
||||||
|
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
|
||||||
|
class="!w-240px"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
||||||
|
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
||||||
|
<el-button type="primary" @click="openForm('create')" v-hasPermi="['member:tag:create']">
|
||||||
|
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="success"
|
||||||
|
plain
|
||||||
|
@click="handleExport"
|
||||||
|
:loading="exportLoading"
|
||||||
|
v-hasPermi="['member:tag:export']"
|
||||||
|
>
|
||||||
|
<Icon icon="ep:download" class="mr-5px" /> 导出
|
||||||
|
</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</ContentWrap>
|
||||||
|
|
||||||
|
<!-- 列表 -->
|
||||||
|
<ContentWrap>
|
||||||
|
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
||||||
|
<el-table-column label="序号" type="index" width="70px" />
|
||||||
|
<el-table-column label="编号" align="center" prop="id" width="150px" />
|
||||||
|
<el-table-column label="标签名称" align="center" prop="name" />
|
||||||
|
<el-table-column
|
||||||
|
label="创建时间"
|
||||||
|
align="center"
|
||||||
|
prop="createTime"
|
||||||
|
:formatter="dateFormatter"
|
||||||
|
width="180px"
|
||||||
|
/>
|
||||||
|
<el-table-column label="操作" align="center" width="150px">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="primary"
|
||||||
|
@click="openForm('update', scope.row.id)"
|
||||||
|
v-hasPermi="['member:tag:update']"
|
||||||
|
>
|
||||||
|
编辑
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="danger"
|
||||||
|
@click="handleDelete(scope.row.id)"
|
||||||
|
v-hasPermi="['member:tag:delete']"
|
||||||
|
>
|
||||||
|
删除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<!-- 分页 -->
|
||||||
|
<Pagination
|
||||||
|
:total="total"
|
||||||
|
v-model:page="queryParams.pageNo"
|
||||||
|
v-model:limit="queryParams.pageSize"
|
||||||
|
@pagination="getList"
|
||||||
|
/>
|
||||||
|
</ContentWrap>
|
||||||
|
|
||||||
|
<!-- 表单弹窗:添加/修改 -->
|
||||||
|
<TagForm ref="formRef" @success="getList" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts" name="MemberTag">
|
||||||
|
import { dateFormatter } from '@/utils/formatTime'
|
||||||
|
import download from '@/utils/download'
|
||||||
|
import * as TagApi from '@/api/member/tag'
|
||||||
|
import TagForm from './TagForm.vue'
|
||||||
|
const message = useMessage() // 消息弹窗
|
||||||
|
const { t } = useI18n() // 国际化
|
||||||
|
|
||||||
|
const loading = ref(true) // 列表的加载中
|
||||||
|
const total = ref(0) // 列表的总页数
|
||||||
|
const list = ref([]) // 列表的数据
|
||||||
|
const queryParams = reactive({
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
name: null,
|
||||||
|
createTime: []
|
||||||
|
})
|
||||||
|
const queryFormRef = ref() // 搜索的表单
|
||||||
|
const exportLoading = ref(false) // 导出的加载中
|
||||||
|
|
||||||
|
/** 查询列表 */
|
||||||
|
const getList = async () => {
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
const data = await TagApi.getMemberTagPage(queryParams)
|
||||||
|
list.value = data.list
|
||||||
|
total.value = data.total
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
const handleQuery = () => {
|
||||||
|
queryParams.pageNo = 1
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
const resetQuery = () => {
|
||||||
|
queryFormRef.value.resetFields()
|
||||||
|
handleQuery()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 添加/修改操作 */
|
||||||
|
const formRef = ref()
|
||||||
|
const openForm = (type: string, id?: number) => {
|
||||||
|
formRef.value.open(type, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
const handleDelete = async (id: number) => {
|
||||||
|
try {
|
||||||
|
// 删除的二次确认
|
||||||
|
await message.delConfirm()
|
||||||
|
// 发起删除
|
||||||
|
await TagApi.deleteMemberTag(id)
|
||||||
|
message.success(t('common.delSuccess'))
|
||||||
|
// 刷新列表
|
||||||
|
await getList()
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
const handleExport = async () => {
|
||||||
|
try {
|
||||||
|
// 导出的二次确认
|
||||||
|
await message.exportConfirm()
|
||||||
|
// 发起导出
|
||||||
|
exportLoading.value = true
|
||||||
|
const data = await TagApi.exportMemberTag(queryParams)
|
||||||
|
download.excel(data, '会员标签.xls')
|
||||||
|
} catch {
|
||||||
|
} finally {
|
||||||
|
exportLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 初始化 **/
|
||||||
|
onMounted(() => {
|
||||||
|
getList()
|
||||||
|
})
|
||||||
|
</script>
|
@ -57,6 +57,9 @@
|
|||||||
:render-after-expand="true"
|
:render-after-expand="true"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="用户标签" prop="tagIds">
|
||||||
|
<MemberTagSelect v-model="formData.tagIds" show-add />
|
||||||
|
</el-form-item>
|
||||||
<el-form-item label="会员备注" prop="mark">
|
<el-form-item label="会员备注" prop="mark">
|
||||||
<el-input type="textarea" v-model="formData.mark" placeholder="请输入会员备注" />
|
<el-input type="textarea" v-model="formData.mark" placeholder="请输入会员备注" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@ -72,6 +75,7 @@ import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
|||||||
import * as UserApi from '@/api/member/user'
|
import * as UserApi from '@/api/member/user'
|
||||||
import * as AreaApi from '@/api/system/area'
|
import * as AreaApi from '@/api/system/area'
|
||||||
import { defaultProps } from '@/utils/tree'
|
import { defaultProps } from '@/utils/tree'
|
||||||
|
import MemberTagSelect from '@/views/member/tag/components/MemberTagSelect.vue'
|
||||||
|
|
||||||
const { t } = useI18n() // 国际化
|
const { t } = useI18n() // 国际化
|
||||||
const message = useMessage() // 消息弹窗
|
const message = useMessage() // 消息弹窗
|
||||||
@ -90,7 +94,8 @@ const formData = ref({
|
|||||||
sex: undefined,
|
sex: undefined,
|
||||||
areaId: undefined,
|
areaId: undefined,
|
||||||
birthday: undefined,
|
birthday: undefined,
|
||||||
mark: undefined
|
mark: undefined,
|
||||||
|
tagIds: []
|
||||||
})
|
})
|
||||||
const formRules = reactive({
|
const formRules = reactive({
|
||||||
mobile: [{ required: true, message: '手机号不能为空', trigger: 'blur' }],
|
mobile: [{ required: true, message: '手机号不能为空', trigger: 'blur' }],
|
||||||
@ -163,7 +168,8 @@ const resetForm = () => {
|
|||||||
areaId: undefined,
|
areaId: undefined,
|
||||||
birthday: undefined,
|
birthday: undefined,
|
||||||
mark: undefined,
|
mark: undefined,
|
||||||
createTime: undefined
|
createTime: undefined,
|
||||||
|
tagIds: []
|
||||||
}
|
}
|
||||||
formRef.value?.resetFields()
|
formRef.value?.resetFields()
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,9 @@
|
|||||||
class="!w-240px"
|
class="!w-240px"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="用户标签" prop="tagIds">
|
||||||
|
<MemberTagSelect v-model="queryParams.tagIds" />
|
||||||
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
||||||
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
||||||
@ -69,6 +72,16 @@
|
|||||||
<!-- TODO 芋艿:待接入 -->
|
<!-- TODO 芋艿:待接入 -->
|
||||||
<el-table-column label="等级" align="center" width="100px" />
|
<el-table-column label="等级" align="center" width="100px" />
|
||||||
<el-table-column label="分组" align="center" width="100px" />
|
<el-table-column label="分组" align="center" width="100px" />
|
||||||
|
<el-table-column
|
||||||
|
label="用户标签"
|
||||||
|
align="center"
|
||||||
|
prop="tagNames"
|
||||||
|
:show-overflow-tooltip="false"
|
||||||
|
>
|
||||||
|
<template #default="scope">
|
||||||
|
<el-tag v-for="(tagName, index) in scope.row.tagNames" :key="index">{{ tagName }}</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column label="积分" align="center" width="100px" />
|
<el-table-column label="积分" align="center" width="100px" />
|
||||||
<el-table-column label="状态" align="center" prop="status" width="100px">
|
<el-table-column label="状态" align="center" prop="status" width="100px">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
@ -119,6 +132,7 @@ import { dateFormatter } from '@/utils/formatTime'
|
|||||||
import * as UserApi from '@/api/member/user'
|
import * as UserApi from '@/api/member/user'
|
||||||
import UserForm from './UserForm.vue'
|
import UserForm from './UserForm.vue'
|
||||||
import { DICT_TYPE } from '@/utils/dict'
|
import { DICT_TYPE } from '@/utils/dict'
|
||||||
|
import MemberTagSelect from '@/views/member/tag/components/MemberTagSelect.vue'
|
||||||
|
|
||||||
defineOptions({ name: 'MemberUser' })
|
defineOptions({ name: 'MemberUser' })
|
||||||
|
|
||||||
@ -134,7 +148,8 @@ const queryParams = reactive({
|
|||||||
nickname: null,
|
nickname: null,
|
||||||
mobile: null,
|
mobile: null,
|
||||||
loginDate: [],
|
loginDate: [],
|
||||||
createTime: []
|
createTime: [],
|
||||||
|
tagIds: []
|
||||||
})
|
})
|
||||||
const queryFormRef = ref() // 搜索的表单
|
const queryFormRef = ref() // 搜索的表单
|
||||||
const exportLoading = ref(false) // 导出的加载中
|
const exportLoading = ref(false) // 导出的加载中
|
||||||
|
Loading…
Reference in New Issue
Block a user