feat:用户tag

This commit is contained in:
dzc committed 2026-02-13 11:46:32 +08:00
1 parent 220c7e95d5
commit bdafbb754a
5 files changed
+311 -16

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
import request from "/@/utils/request"
export function fetchList(query?: Object) {
return request({
url: "/admin/sys-user-tag/page",
method: "get",
params: query,
})
}
export function addObj(obj?: Object) {
return request({
url: "/admin/sys-user-tag",
method: "post",
data: obj,
})
}
export function getObj(id?: string) {
return request({
url: "/admin/sys-user-tag/" + id,
method: "get",
})
}
export function delObjs(ids?: Object) {
return request({
url: "/admin/sys-user-tag",
method: "delete",
data: ids,
})
}
export function putObj(obj?: Object) {
return request({
url: "/admin/sys-user-tag",
method: "put",
data: obj,
})
}
+24 -15
View File
@@ -112,37 +112,45 @@
</el-table-column>
<el-table-column label="所属商户" prop="merchantName" show-overflow-tooltip min-width="150" />
<el-table-column v-auths="['sys_user_edit', 'userFace_sysUserFace_view', 'sys_user_del']"
label="操作" min-width="300" width="300" fixed="right">
label="操作" min-width="250" width="250" fixed="right">
<template #default="{ row }">
<div style="display: flex; justify-content: center">
<div
style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; justify-items: start;">
<!-- 重置密码 -->
<popover-input v-if="row.processStatus == '2'" v-model="inputPassword"
@confirm="changePassword(row)">
<template #default>
<el-button v-auth="'sys_user_edit'" icon="RefreshLeft" text type="primary"
class="mr-4">密码</el-button>
<el-button style="margin: 0 !important;" v-auth="'sys_user_edit'"
icon="RefreshLeft" text type="primary" class="mr-4">密码</el-button>
</template>
</popover-input>
<!-- 修改信息 -->
<el-button v-if="row.processStatus == '2'" v-auth="'sys_user_edit'" icon="edit-pen"
text type="primary" @click="userDialogRef.openDialog(row.userId)">
<el-button style="margin: 0 !important;" v-if="row.processStatus == '2'"
v-auth="'sys_user_edit'" icon="edit-pen" text type="primary"
@click="userDialogRef.openDialog(row.userId)">
修改
</el-button>
<!-- 修改信息 -->
<el-button style="margin: 0 !important;" v-if="row.processStatus == '2'"
icon="SetUp" text type="primary" @click="tagTableRef.openDialog(row.userId)">
用户标签
</el-button>
<!-- 人脸管理 -->
<el-button v-if="row.processStatus == '2'" v-auth="'userFace_sysUserFace_view'"
icon="User" text type="primary" @click="faceManageRef.openDialog(row.userId)">
<el-button style="margin: 0 !important;" v-if="row.processStatus == '2'"
v-auth="'userFace_sysUserFace_view'" icon="User" text type="primary"
@click="faceManageRef.openDialog(row.userId)">
人脸管理
</el-button>
<el-button v-if="row.processStatus == 1" type="primary" size="small" link
icon="VideoPlay" @click="deal(row)">
<el-button style="margin: 0 !important;" v-if="row.processStatus == 1"
type="primary" size="small" link icon="VideoPlay" @click="deal(row)">
开始处理
</el-button>
<!-- 删除用户 -->
<el-tooltip content="admin 不允许被删除" :disabled="row.userId !== '1'" placement="top">
<span style="margin-left: 12px">
<el-button icon="delete" v-auth="'sys_user_del'"
:disabled="row.username === 'admin'" text type="primary"
@click="handleDelete([row.userId])">
<el-button style="margin: 0 !important;" icon="delete"
v-auth="'sys_user_del'" :disabled="row.username === 'admin'" text
type="primary" @click="handleDelete([row.userId])">
删除
</el-button>
</span>
@@ -161,12 +169,11 @@
<face-manage ref="faceManageRef" @refresh="getDataList(false)" />
<upload-excel ref="excelUploadRef" title="用户导入" temp-url="/admin/sys-file/local/file/user.xlsx"
url="/admin/user/import-face" @refreshDataList="getDataList" />
<!-- 审批抽屉 -->
<process-drawer ref="processDrawerRef" @task-submit-event="taskSubmitEvent" />
<!-- 批量审批对话框 -->
<batch-deal ref="batchDealRef" @task-submit-event="taskSubmitEvent" />
<tag-table ref="tagTableRef" />
</div>
</template>
@@ -185,6 +192,7 @@ const UserForm = defineAsyncComponent(() => import("./form.vue"))
const FaceManage = defineAsyncComponent(() => import("./face-manage.vue"))
const PopoverInput = defineAsyncComponent(() => import("/@/components/PopoverInput/index.vue"))
const BatchDeal = defineAsyncComponent(() => import("./batchDeal.vue"))
const TagTable = defineAsyncComponent(() => import("./tag-table.vue"))
const { t } = useI18n()
@@ -199,6 +207,7 @@ const activeName = ref("2")
const tabItems = ref<any>([{}])
const processDrawerRef = ref()
const batchDealRef = ref()
const tagTableRef = ref()
// 多选rows
const selectObjs = ref([]) as any
+123
View File
@@ -0,0 +1,123 @@
<template>
<el-dialog :title="form.id ? '编辑' : '新增'" v-model="visible" :close-on-click-modal="false" draggable>
<el-form ref="dataFormRef" :model="form" :rules="dataRules" formDialogRef label-width="90px"
v-loading="loading">
<el-row :gutter="24">
<el-col :span="24" class="mb20">
<el-form-item label="用户" prop="userId">
<select-user v-model="form.userId" placeholder="请选择用户" />
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item label="标签类型" prop="bizType">
<dict-select v-model="form.bizType" dict-code="user_tag_type" />
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item label="标签名" prop="title">
<el-input v-model="form.title" placeholder="请输入tag名" />
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item label="标签图片" prop="img">
<upload-img v-model:imageUrl="form.img" />
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item label="过期时间" prop="expireTime">
<el-date-picker value-format="YYYY-MM-DD HH:mm:ss" v-model="form.expireTime" type="date"
placeholder="请选择过期时间" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="visible = false">取消</el-button>
<el-button type="primary" @click="onSubmit" :disabled="loading">确认</el-button>
</span>
</template>
</el-dialog>
</template>
<script setup lang="ts" name="SysUserTagDialog">
import { useDict } from '/@/hooks/dict';
import { useMessage } from "/@/hooks/message";
import * as sysUserTagApi from "/@/api/admin/sysUserTag"
import { rule } from '/@/utils/validate';
const emit = defineEmits(['refresh']);
// 定义变量内容
const dataFormRef = ref();
const visible = ref(false)
const loading = ref(false)
// 定义字典
// 提交表单数据
const form = reactive({
id: '',
userId: '',
title: '',
img: '',
bizType: '',
expireTime: '',
status: '',
});
// 定义校验规则
const dataRules = ref({
userId: [{ required: true, message: "请选择用户", trigger: "change" }],
title: [{ required: true, message: "请输入标签", trigger: "blur" }],
bizType: [{ required: true, message: "请选择标签类型", trigger: "change" }],
})
// 打开弹窗
const openDialog = ({ id, userId }: any) => {
visible.value = true
form.id = ''
form.userId = userId
// 重置表单数据
nextTick(() => {
dataFormRef.value?.resetFields();
});
// 获取sysUserTag信息
if (id) {
form.id = id
getsysUserTagData(id)
}
};
// 提交
const onSubmit = async () => {
const valid = await dataFormRef.value.validate().catch(() => { });
if (!valid) return false;
try {
loading.value = true;
form.id ? await sysUserTagApi.putObj(form) : await sysUserTagApi.addObj(form);
useMessage().success(form.id ? '修改成功' : '添加成功');
visible.value = false;
emit('refresh');
} catch (err: any) {
useMessage().error(err.msg);
} finally {
loading.value = false;
}
};
// 初始化表单数据
const getsysUserTagData = (id: string) => {
// 获取数据
loading.value = true
sysUserTagApi.getObj(id).then((res: any) => {
Object.assign(form, res.data)
}).finally(() => {
loading.value = false
})
};
// 暴露变量
defineExpose({
openDialog
});
</script>
+123
View File
@@ -0,0 +1,123 @@
<template>
<el-dialog width="60%" :close-on-click-modal="false" title="用户标签" draggable v-model="visible">
<el-row>
<div class="mb8" style="width: 100%">
<el-button v-auth="'sys_user_add'" icon="folder-add" type="primary"
@click="tagFormRef.openDialog({ userId })">
新增
</el-button>
</div>
</el-row>
<el-table :data="state.dataList" v-loading="state.loading" border :cell-style="tableStyle.cellStyle"
:header-cell-style="tableStyle.headerCellStyle" @selection-change="selectionChangHandle"
@sort-change="sortChangeHandle">
<el-table-column type="selection" width="40" align="center" />
<el-table-column type="index" label="#" width="40" />
<el-table-column prop="title" label="标签名" show-overflow-tooltip />
<el-table-column prop="bizType" label="标签类型">
<template #default="{ row }">
<dict-tag :options="user_tag_type" :value="row.bizType" />
</template>
</el-table-column>
<el-table-column prop="img" label="标签图片">
<template #default="{ row }">
<preview-image width="20px" height="20px" :src="row.img" />
</template>
</el-table-column>
<el-table-column prop="expireTime" width="180" label="过期时间">
<template #default="{ row }">
<div v-if="row.expireTime">{{ row.expireTime }}</div>
<div class="color-success">永不过期</div>
</template>
</el-table-column>
<el-table-column prop="status" label="状态">
<template #default="{ row }">
<dict-tag :options="user_tag_status" :value="row.status" />
</template>
</el-table-column>
<el-table-column prop="createTime" label="创建时间" width="180" />
<el-table-column label="操作" width="150">
<template #default="{ row }">
<el-button icon="edit-pen" text type="primary" v-auth="'admin_sysUserTag_edit'"
@click="tagFormRef.openDialog({ id: row.id, userId })">编辑</el-button>
<el-button icon="delete" text type="primary" v-auth="'admin_sysUserTag_del'"
@click="handleDelete([row.id])">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-dialog>
<tag-form ref="tagFormRef" @refresh="getDataList()" />
</template>
<script lang="ts" name="tagTableDialog" setup>
import { BasicTableProps, useTable } from "/@/hooks/table";
import { useMessage, useMessageBox } from "/@/hooks/message";
import { useDict } from '/@/hooks/dict';
import * as sysUserTagApi from "/@/api/admin/sysUserTag"
const TagForm = defineAsyncComponent(() => import("./tag-form.vue"))
// 定义变量内容
const tagFormRef = ref()
const userId = ref()
const visible = ref(false)
const { user_tag_status, user_tag_type } = useDict("user_tag_status", "user_tag_type")
const state: BasicTableProps = reactive<BasicTableProps>({
queryForm: {},
createdIsNeed: false,
pageList: sysUserTagApi.fetchList
})
// 多选变量
const selectObjs = ref([]) as any
const multiple = ref(true)
// table hook
const {
getDataList,
currentChangeHandle,
sizeChangeHandle,
sortChangeHandle,
downBlobFile,
tableStyle
} = useTable(state)
// 多选事件
const selectionChangHandle = (objs: { id: string }[]) => {
selectObjs.value = objs.map(({ id }) => id);
multiple.value = !objs.length;
};
// 打开弹窗
const openDialog = async (id: string) => {
userId.value = id
visible.value = true
state.queryForm.userId = id
getDataList()
}
// 删除操作
const handleDelete = async (ids: string[]) => {
try {
await useMessageBox().confirm('此操作将永久删除');
} catch {
return;
}
try {
await sysUserTagApi.delObjs(ids);
useMessage().success('删除成功');
getDataList();
} catch (err: any) {
useMessage().error(err.msg);
}
};
// 暴露变量
defineExpose({
openDialog,
})
</script>
+1 -1
View File
@@ -60,7 +60,7 @@
<preview-json :json="row.res" />
</template>
</el-table-column>
<el-table-column prop="startTime" label="开始时间">
<el-table-column prop="startTime" label="请求时间">
<el-table-column prop="startTime" label="开始时间" width="180" />
<el-table-column prop="endTime" label="结束时间" width="180" />
<el-table-column prop="cost" label="耗时(秒)" width="100">