10/15
1. 工作人员账号添加
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
v-model="inputText"
|
||||
:autosize="{ minRows:5, maxRows:8 }"
|
||||
placeholder="请输入回复内容"
|
||||
:disabled="disable"
|
||||
type="textarea"
|
||||
@keydown="handleKeyDown"
|
||||
/>
|
||||
@@ -27,6 +28,7 @@
|
||||
class="btn-img"
|
||||
plain
|
||||
type="info"
|
||||
:disabled="disable"
|
||||
@click="handleSelectImage"
|
||||
>
|
||||
上传图片
|
||||
@@ -52,6 +54,12 @@ const props = defineProps({
|
||||
sending: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
|
||||
/** 是否禁用输入框 */
|
||||
disable: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
})
|
||||
|
||||
@@ -68,7 +76,7 @@ const inputText = ref('')
|
||||
|
||||
// 是否可以发送
|
||||
const canSend = computed(() => {
|
||||
return !!inputText.value.trim()
|
||||
return !!inputText.value.trim() && !props.disable
|
||||
})
|
||||
|
||||
// 点击图片图标,唤起文件选择
|
||||
|
||||
@@ -1,68 +1,27 @@
|
||||
<template>
|
||||
<div :class="currentClass" class="chat-tip-bar">
|
||||
<div class="chat-tip-bar agent">
|
||||
<!-- 提示条区域,放在MessageList内部最顶部,跟随滚动 -->
|
||||
<span>{{ currentText }}</span>
|
||||
<span>{{ msg }}</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {computed} from 'vue'
|
||||
import {ChatNavBarType} from './types'
|
||||
import type {PropType} from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
type: {
|
||||
type: Number as PropType<ChatNavBarType>,
|
||||
defineProps({
|
||||
msg: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
time: String,
|
||||
awaitNum: Number,
|
||||
agentInfo: {
|
||||
type: Object as PropType<{
|
||||
name: string,
|
||||
no: string,
|
||||
}>,
|
||||
}
|
||||
})
|
||||
|
||||
// 根据type自动切换文本
|
||||
const currentText = computed(() => {
|
||||
switch (props.type) {
|
||||
case ChatNavBarType.agent:
|
||||
return `${props.time} 用户点击「仍未解决,转人工」`
|
||||
case ChatNavBarType.await:
|
||||
return `排队提醒:当前排队第 ${props.awaitNum} 位,已等待 ${props.time}`
|
||||
case ChatNavBarType.accept:
|
||||
return `客服${props.agentInfo?.name}(工号 ${props.agentInfo?.no})已接入会话`
|
||||
default:
|
||||
return ''
|
||||
}
|
||||
})
|
||||
|
||||
// 样式类
|
||||
const currentClass = computed(() => {
|
||||
switch (props.type) {
|
||||
case ChatNavBarType.agent:
|
||||
return 'agent'
|
||||
case ChatNavBarType.await:
|
||||
return 'await'
|
||||
case ChatNavBarType.accept:
|
||||
return 'accept'
|
||||
default:
|
||||
return ''
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.chat-tip-bar {
|
||||
min-width: 250px;
|
||||
max-width: 250px;
|
||||
max-width: 280px;
|
||||
overflow: hidden;
|
||||
margin: 7px auto;
|
||||
min-height: 24px;
|
||||
padding: 5px 12px;
|
||||
text-align: left;
|
||||
text-align: center;
|
||||
border-radius: 12px;
|
||||
text-wrap: wrap;
|
||||
}
|
||||
|
||||
@@ -8,20 +8,23 @@
|
||||
<span class="time">{{ time }}</span>
|
||||
</div>
|
||||
<!-- 文本消息 -->
|
||||
<div v-if="type === 'text'" class="bubble" v-html="content"></div>
|
||||
<div v-if="type === 'text'" class="bubble text-bubble" v-html="content"></div>
|
||||
<!-- 图片消息 -->
|
||||
<div v-else-if="type === 'image'" class="bubble img-bubble">
|
||||
<img :src="content" class="chat-img" @click="$emit('preview', content)"/>
|
||||
<el-image :preview-src-list="[url]" :src="url" class="chat-img" @click="$emit('preview', url)"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
defineProps({
|
||||
import avatar from '@/assets/images/avatar.png'
|
||||
|
||||
const props = defineProps({
|
||||
name: {type: String, default: '客服'},
|
||||
avatar: {type: String, default: ''},
|
||||
content: {type: String, required: true},
|
||||
avatar: {type: String, default: avatar},
|
||||
content: {type: String, default: ''},
|
||||
url: {type: String, default: ''},
|
||||
type: {type: String as () => 'text' | 'image', default: 'text'},
|
||||
tag: {type: String, default: '人工客服'},
|
||||
time: {type: String, default: ''}
|
||||
@@ -83,13 +86,17 @@ defineEmits(['preview'])
|
||||
color: rgba(31, 41, 55, 1);
|
||||
}
|
||||
|
||||
.text-bubble {
|
||||
display: inline-block;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.img-bubble {
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
.chat-img {
|
||||
max-width: 200px;
|
||||
max-height: 200px;
|
||||
border-radius: 8px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
@@ -101,9 +101,9 @@ defineEmits(['quickAction'])
|
||||
line-height: 1.6;
|
||||
color: #333;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
|
||||
.quick-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
|
||||
@@ -5,20 +5,23 @@
|
||||
<div v-if="type === 'text'" class="bubble" v-html="content"></div>
|
||||
<!-- 图片消息 -->
|
||||
<div v-else-if="type === 'image'" class="bubble img-bubble">
|
||||
<img :src="content" class="chat-img"/>
|
||||
<el-image :preview-src-list="[url]" :src="url" class="chat-img"/>
|
||||
</div>
|
||||
<div class="time">{{ time }}</div>
|
||||
</div>
|
||||
<img :src="avatar" class="avatar"/>
|
||||
<el-image :src="avatar" class="avatar"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import avatar from '@/assets/images/avatar.png'
|
||||
|
||||
defineProps({
|
||||
content: {type: String, required: true},
|
||||
type: {type: String as () => 'text' | 'image', default: 'text'},
|
||||
avatar: {type: String, default: ''},
|
||||
time: {type: String, default: ''}
|
||||
avatar: {type: String, default: avatar},
|
||||
time: {type: String, default: ''},
|
||||
url: {type: String, default: ''}
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -58,12 +61,11 @@ defineProps({
|
||||
}
|
||||
|
||||
.img-bubble {
|
||||
padding: 4px;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.chat-img {
|
||||
max-width: 200px;
|
||||
max-height: 200px;
|
||||
border-radius: 8px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
@@ -1,83 +1,72 @@
|
||||
<template>
|
||||
<div
|
||||
ref="listRef"
|
||||
class="message-list "
|
||||
class="message-list"
|
||||
@scroll.passive="handleScroll"
|
||||
>
|
||||
<!-- 加载历史消息提示 -->
|
||||
<div v-if="loadingHistory" class="load-more-tip">
|
||||
<span class="spinner"></span> 加载中...
|
||||
</div>
|
||||
|
||||
<!-- 消息列表:key 必须用唯一 id,禁止 index -->
|
||||
<template v-for="msg in messages" :key="msg.id">
|
||||
<!-- 2. 用户消息 -->
|
||||
<template v-for="msg in messages" :key="msg.seq">
|
||||
<ChatNavBar v-if="msg.senderType === 'system'" :msg="msg.content"/>
|
||||
<UserMessage
|
||||
v-if="msg.role === 'user'"
|
||||
v-else-if="msg.senderType === 'user'"
|
||||
:avatar="userAvatar"
|
||||
:content="msg.content"
|
||||
:msg-type="msg.msgType"
|
||||
:status="msg.status"
|
||||
:time="msg.time"
|
||||
:time="msg.createTime"
|
||||
:type="msg.msgType"
|
||||
:url="msg.url"
|
||||
@retry="handleRetry(msg)"
|
||||
/>
|
||||
|
||||
<!-- 3. 机器人消息 -->
|
||||
<RobotMessage
|
||||
v-else-if="msg.agentType === 'robot'"
|
||||
:avatar="msg.avatar"
|
||||
v-else-if="msg.senderType === 'bot'"
|
||||
:content="msg.content"
|
||||
:msg-type="msg.msgType"
|
||||
:name="msg.agentName"
|
||||
:quick-actions="msg.quickActions"
|
||||
:time="msg.time"
|
||||
:time="msg.createTime"
|
||||
@quick-action="handleQuickAction"
|
||||
/>
|
||||
|
||||
<!-- 4. 人工客服消息 -->
|
||||
<AgentMessage
|
||||
v-else
|
||||
:avatar="msg.avatar"
|
||||
v-else-if="msg.senderType === 'agent'"
|
||||
:content="msg.content"
|
||||
:msg-type="msg.msgType"
|
||||
:name="msg.agentName"
|
||||
:time="msg.time"
|
||||
:time="msg.createTime"
|
||||
:type="msg.msgType"
|
||||
:url="msg.url"
|
||||
@preview="handlePreview"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<!-- 底部占位 -->
|
||||
<div class="bottom-space"></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {ref, watch, nextTick, onMounted} from 'vue'
|
||||
import SystemMessage from './SystemMessage.vue'
|
||||
import UserMessage from './UserMessage.vue'
|
||||
import RobotMessage from './RobotMessage.vue'
|
||||
import AgentMessage from './AgentMessage.vue'
|
||||
import ChatNavBar from '@/views/system/conversation/compontents/ChatNavBar.vue'
|
||||
|
||||
interface ChatMessage {
|
||||
id: string | number
|
||||
type: 'system' | 'chat'
|
||||
role?: 'user' | 'agent'
|
||||
agentType?: 'robot' | 'human'
|
||||
senderType: 'user' | 'agent' | 'system' | 'bot'
|
||||
content: string
|
||||
msgType?: 'text' | 'image'
|
||||
agentName?: string
|
||||
avatar?: string
|
||||
time: string
|
||||
status?: 'sending' | 'sent' | 'failed'
|
||||
msgType: 'text' | 'image'
|
||||
createTime: string
|
||||
quickActions?: { label: string; action: string; primary?: boolean }[]
|
||||
clientMsgId: string
|
||||
messageId: string
|
||||
ossId: string
|
||||
url: string
|
||||
senderId: string
|
||||
seq: number
|
||||
sessionId: string
|
||||
}
|
||||
|
||||
const props = defineProps<{
|
||||
messages: ChatMessage[]
|
||||
userAvatar: string
|
||||
loadingHistory?: boolean
|
||||
/** 是否还有更多历史可加载(可选,建议父组件传) */
|
||||
hasMoreHistory?: boolean
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -89,122 +78,68 @@ const emit = defineEmits<{
|
||||
|
||||
const listRef = ref<HTMLElement>()
|
||||
|
||||
/** 用户是否贴近底部(阈值 50px) */
|
||||
const isAtBottom = ref(true)
|
||||
|
||||
/** 首屏标记:首次渲染不走平滑滚动 */
|
||||
let isFirstRender = true
|
||||
|
||||
/** 加载历史前的 scrollHeight 快照 */
|
||||
let prevScrollHeight = 0
|
||||
|
||||
/** 加载历史防抖锁 */
|
||||
let isLoadingMore = false
|
||||
|
||||
/** 阈值常量 */
|
||||
const BOTTOM_THRESHOLD = 50
|
||||
const TOP_THRESHOLD = 30
|
||||
|
||||
/* ========== 判断是否贴近底部 ========== */
|
||||
const checkAtBottom = (): boolean => {
|
||||
const el = listRef.value
|
||||
if (!el) return true
|
||||
return el.scrollHeight - el.scrollTop - el.clientHeight < BOTTOM_THRESHOLD
|
||||
}
|
||||
|
||||
/* ========== 滚动到底部 ========== */
|
||||
const scrollToBottom = (smooth = false) => {
|
||||
const scrollToBottom = async () => {
|
||||
await nextTick()
|
||||
const el = listRef.value
|
||||
if (!el) return
|
||||
el.scrollTo({
|
||||
top: el.scrollHeight,
|
||||
behavior: smooth ? 'smooth' : 'auto'
|
||||
await new Promise<void>(resolve => {
|
||||
requestAnimationFrame(() => {
|
||||
el.scrollTop = el.scrollHeight
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/* ========== 滚动事件 ========== */
|
||||
const handleScroll = () => {
|
||||
const el = listRef.value
|
||||
if (!el) return
|
||||
|
||||
// 1. 更新底部状态
|
||||
isAtBottom.value = checkAtBottom()
|
||||
|
||||
// 2. 触顶加载历史
|
||||
if (
|
||||
el.scrollTop <= TOP_THRESHOLD &&
|
||||
!isLoadingMore &&
|
||||
!props.loadingHistory &&
|
||||
props.hasMoreHistory !== false
|
||||
) {
|
||||
if (el.scrollTop <= TOP_THRESHOLD && !isLoadingMore) {
|
||||
isLoadingMore = true
|
||||
// 关键:在 emit 之前记录当前 scrollHeight 快照
|
||||
prevScrollHeight = el.scrollHeight
|
||||
emit('loadMore')
|
||||
}
|
||||
}
|
||||
|
||||
/* ========== 首屏 + 新消息滚动 ========== */
|
||||
watch(
|
||||
() => props.messages?.length ?? 0,
|
||||
async (newLen, oldLen) => {
|
||||
await nextTick()
|
||||
() => props.messages.length,
|
||||
async (newLen) => {
|
||||
isLoadingMore = false
|
||||
|
||||
if (newLen === 0) return
|
||||
|
||||
if (isFirstRender) {
|
||||
// 场景 ①:首次进入页面,无动画直接滚到底
|
||||
scrollToBottom(false)
|
||||
await scrollToBottom()
|
||||
isFirstRender = false
|
||||
isAtBottom.value = true
|
||||
return
|
||||
}
|
||||
|
||||
// 场景 ②:新消息到达 && 用户在底部 → 平滑滚到底
|
||||
// 场景 ③:用户在翻历史 → 不滚动
|
||||
if (newLen > oldLen && isAtBottom.value) {
|
||||
scrollToBottom(true)
|
||||
if (isAtBottom.value) {
|
||||
await scrollToBottom()
|
||||
}
|
||||
},
|
||||
{immediate: true}
|
||||
)
|
||||
|
||||
/* ========== 加载历史后,保持视觉位置 ========== */
|
||||
watch(
|
||||
() => props.loadingHistory,
|
||||
async (loading, wasLoading) => {
|
||||
// 只在 loading 从 true → false 的瞬间处理
|
||||
if (wasLoading && !loading) {
|
||||
await nextTick()
|
||||
const el = listRef.value
|
||||
if (!el) return
|
||||
|
||||
// 场景 ④:内容变高了,把 scrollTop 平移到等价位置
|
||||
const delta = el.scrollHeight - prevScrollHeight
|
||||
el.scrollTop = el.scrollTop + delta
|
||||
|
||||
// 重算底部状态(此时肯定不在底部)
|
||||
isAtBottom.value = checkAtBottom()
|
||||
|
||||
// 解锁,允许下一次加载
|
||||
isLoadingMore = false
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
/* ========== 挂载后兜底:图片等异步内容渲染后可能改变 scrollHeight ========== */
|
||||
onMounted(() => {
|
||||
nextTick(() => {
|
||||
scrollToBottom(false)
|
||||
isAtBottom.value = true
|
||||
isFirstRender = false
|
||||
})
|
||||
isAtBottom.value = true
|
||||
})
|
||||
|
||||
/* ========== 对外暴露手动滚底(如发送消息成功后) ========== */
|
||||
defineExpose({
|
||||
scrollToBottom: (smooth = true) => scrollToBottom(smooth)
|
||||
})
|
||||
defineExpose({scrollToBottom})
|
||||
|
||||
/* ========== 事件转发 ========== */
|
||||
const handleQuickAction = (action: string) => emit('quickAction', action)
|
||||
const handleRetry = (msg: ChatMessage) => emit('retry', msg)
|
||||
const handlePreview = (url: string) => emit('preview', url)
|
||||
@@ -213,13 +148,12 @@ const handlePreview = (url: string) => emit('preview', url)
|
||||
<style scoped>
|
||||
.message-list {
|
||||
flex: 1;
|
||||
min-height: 0; /* ⚠️ 关键:flex 子项内滚动必须加 */
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
padding: 12px;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
|
||||
/* 隐藏滚动条(Chrome / Firefox / IE) */
|
||||
scrollbar-width: none;
|
||||
-ms-overflow-style: none;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,10 @@
|
||||
import cardNav from '@/components/cardNav/index.vue';
|
||||
import {getDevice} from "@/api/system/device";
|
||||
import {DeviceForm} from "@/api/system/device/types";
|
||||
import {useUserStore} from "@/store/modules/user";
|
||||
|
||||
|
||||
const userStore = useUserStore();
|
||||
const router = useRouter();
|
||||
|
||||
function backList() {
|
||||
@@ -65,7 +68,6 @@ const form = ref();
|
||||
|
||||
function init() {
|
||||
form.value = {...initFormData};
|
||||
console.log(form.value);
|
||||
if (route.query.id) {
|
||||
getDevice(route.query.id as string).then(res => {
|
||||
Object.assign(form.value, res.data);
|
||||
@@ -82,7 +84,9 @@ init()
|
||||
<nav class="flex justify-between" style="padding-top: 22px;">
|
||||
<Pagecrumb></Pagecrumb>
|
||||
<div>
|
||||
<el-button plain type="info" @click="backList">返回设备列表</el-button>
|
||||
<el-button v-if="!userStore.roles.includes('customer_service')" plain type="info" @click="backList">
|
||||
返回设备列表
|
||||
</el-button>
|
||||
<el-button type="primary" @click="editDevice">编辑设备</el-button>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
@@ -347,7 +347,7 @@ const handleOrderChange = (prop: string, order: string) => {
|
||||
};
|
||||
/** 任务日志列表查询 */
|
||||
const handleOssConfig = () => {
|
||||
router.push('/system/oss-config/index.vue');
|
||||
router.push('/system/oss-config/index');
|
||||
};
|
||||
/** 文件按钮操作 */
|
||||
const handleFile = () => {
|
||||
|
||||
@@ -1,31 +1,126 @@
|
||||
<script lang="ts" setup>
|
||||
import {ArrowLeft, InfoFilled} from "@element-plus/icons-vue";
|
||||
import FormItemTip from '@/components/FormItemTip/index.vue'
|
||||
import {listRole, addRole} from "@/api/system/role";
|
||||
import {useRouter} from "vue-router";
|
||||
|
||||
const roleslist = [
|
||||
const router = useRouter()
|
||||
|
||||
const rolesList = [
|
||||
{
|
||||
label: '超级管理员',
|
||||
sutTitle: "拥有系统所有功能权限"
|
||||
sutTitle: "拥有系统所有功能权限",
|
||||
color: '#2563eb'
|
||||
},
|
||||
{
|
||||
label: '设备管理员',
|
||||
sutTitle: "管理设备列表、OTA升级等"
|
||||
sutTitle: "管理设备列表、OTA升级等",
|
||||
color: '#3b82f6'
|
||||
},
|
||||
{
|
||||
label: '普通用户',
|
||||
sutTitle: "仅可查看设备信息"
|
||||
sutTitle: "仅可查看设备信息",
|
||||
color: '#22c55e'
|
||||
},
|
||||
{
|
||||
label: '审计员',
|
||||
sutTitle: "查看操作日志与审计"
|
||||
sutTitle: "查看操作日志与审计",
|
||||
color: '#a855f7'
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
const initForm = {
|
||||
userId: undefined,
|
||||
userName: '',
|
||||
nickName: undefined,
|
||||
gender: '1',
|
||||
password: '',
|
||||
confirmPassword: '',
|
||||
phoneNumber: undefined,
|
||||
email: undefined,
|
||||
status: '0',
|
||||
remark: '',
|
||||
roleIds: []
|
||||
}
|
||||
|
||||
const formRef = ref<ElFormInstance>()
|
||||
const form = ref(initForm);
|
||||
const rules = {
|
||||
userName: [
|
||||
{required: true, message: '用户名称不能为空', trigger: 'blur'},
|
||||
{min: 4, max: 20, message: '用户名称长度必须介于 4 和 20 之间', trigger: 'blur'}
|
||||
],
|
||||
nickName: [{required: true, message: '用户昵称不能为空', trigger: 'blur'}],
|
||||
password: [
|
||||
{required: true, message: '用户密码不能为空', trigger: 'blur'},
|
||||
{min: 5, max: 20, message: '用户密码长度必须介于 5 和 20 之间', trigger: 'blur'},
|
||||
{pattern: /^[^<>"'|\\]+$/, message: '不能包含非法字符:< > " \' \\ |', trigger: 'blur'}
|
||||
],
|
||||
phoneNumber: [
|
||||
{required: true, message: '用户手机号不能为空', trigger: 'blur'},
|
||||
{pattern: /^1[3456789][0-9]\d{8}$/, message: '请输入正确的手机号码', trigger: 'blur'}
|
||||
],
|
||||
email: [
|
||||
{type: 'email', message: '请输入正确的邮箱地址', trigger: ['blur', 'change']},
|
||||
{pattern: /^[^@]+@[^@]+\.[^@]+$/, message: '请输入正确的邮箱地址', trigger: 'blur'}
|
||||
],
|
||||
confirmPassword: [
|
||||
{required: true, message: '确认密码不能为空', trigger: 'blur'},
|
||||
{
|
||||
validator: (rule, value, callback) => {
|
||||
if (value !== form.value.password) {
|
||||
callback(new Error('两次输入密码不一致'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
roleIds: [{required: true, message: '用户角色不能为空', trigger: 'blur'}]
|
||||
};
|
||||
|
||||
const roleList = ref([])
|
||||
|
||||
function getRoleList() {
|
||||
listRole({pageNum: 1, pageSize: undefined,}).then((res) => {
|
||||
roleList.value = res.data.rows || []
|
||||
})
|
||||
}
|
||||
|
||||
function reset() {
|
||||
form.value = {...initForm};
|
||||
formRef.value?.resetFields();
|
||||
}
|
||||
|
||||
function addRoleAction() {
|
||||
console.log(form.value);
|
||||
formRef.value?.validate().then((valid) => {
|
||||
if (valid) {
|
||||
addRole(form.value).then((res) => {
|
||||
if (res.code === 200) {
|
||||
ElMessage.success('新增成功')
|
||||
} else {
|
||||
ElMessage.error(res.msg || '新增失败')
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function reBack() {
|
||||
router.back()
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getRoleList()
|
||||
})
|
||||
</script>
|
||||
<template>
|
||||
<div class="Add">
|
||||
<div class="Add beautify_scroll">
|
||||
<div class="AddNav">
|
||||
<div class="addItem">
|
||||
<div class="arrowBox">
|
||||
<div class="arrowBox" @click="reBack">
|
||||
<el-icon>
|
||||
<arrow-left></arrow-left>
|
||||
</el-icon>
|
||||
@@ -36,14 +131,15 @@ const roleslist = [
|
||||
</div>
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="17">
|
||||
<el-form label-position="top">
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-position="top">
|
||||
<div class="commonCard">
|
||||
<card-nav :show-line="false" title="基本信息"></card-nav>
|
||||
<card-nav :show-line="false" style="margin-bottom: 10px" title="基本信息"></card-nav>
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
<FormItemTip
|
||||
v-model="form.userName"
|
||||
:inputAttrs="{placeholder:'请输入登录用户名'}"
|
||||
:required="true"
|
||||
prop="userName"
|
||||
label="登录用户名"
|
||||
tip="4-20位字母、数字或下划线,创建后不可修改"
|
||||
type="input"
|
||||
@@ -51,23 +147,27 @@ const roleslist = [
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<FormItemTip
|
||||
v-model="form.nickName"
|
||||
:inputAttrs="{placeholder:'请输入真实姓名'}"
|
||||
:required="true"
|
||||
prop="nickName"
|
||||
label="用户姓名"
|
||||
type="input"
|
||||
></FormItemTip>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<FormItemTip
|
||||
v-model="form.phoneNumber"
|
||||
:inputAttrs="{placeholder:'请输入手机号码'}"
|
||||
:required="true"
|
||||
prop="phoneNumber"
|
||||
label="手机号码"
|
||||
type="input"
|
||||
></FormItemTip>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<FormItemTip
|
||||
v-model="form.email"
|
||||
:inputAttrs="{placeholder:'请输入邮箱'}"
|
||||
prop="email"
|
||||
:required="false"
|
||||
label="邮箱"
|
||||
type="input"
|
||||
@@ -75,11 +175,12 @@ const roleslist = [
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<FormItemTip
|
||||
v-model="form.gender"
|
||||
:radio-options="[
|
||||
{label:'男',value:1},
|
||||
{label:'女',value:0},
|
||||
{label:'男',value:'1'},
|
||||
{label:'女',value:'0'},
|
||||
]"
|
||||
:required="false"
|
||||
prop="gender"
|
||||
label="性别"
|
||||
type="radio"
|
||||
></FormItemTip>
|
||||
@@ -90,8 +191,14 @@ const roleslist = [
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
<FormItemTip
|
||||
:required="true"
|
||||
v-model="form.roleIds"
|
||||
:disabled-values="['superadmin']"
|
||||
:radioOptions="roleList"
|
||||
labelKey="roleName"
|
||||
prop="roleIds"
|
||||
tip="角色决定用户的功能权限范围"
|
||||
label="角色"
|
||||
valueKey="roleKey"
|
||||
type="select"
|
||||
></FormItemTip>
|
||||
</el-col>
|
||||
@@ -99,29 +206,31 @@ const roleslist = [
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<FormItemTip
|
||||
:input-attrs="{maxlength:20,minlength:8}"
|
||||
:required="true"
|
||||
v-model="form.password"
|
||||
:input-attrs="{maxlength:20,minlength:8,placeholder:'请再次输入密码'}"
|
||||
prop="password"
|
||||
label="初始密码"
|
||||
tip="8-20位,包含字母和数字"
|
||||
type="input"
|
||||
type="password"
|
||||
></FormItemTip>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<FormItemTip
|
||||
v-model="form.confirmPassword"
|
||||
:input-attrs="{placeholder:'请再次输入密码',maxlength:20,minlength:8}"
|
||||
:required="true"
|
||||
prop="confirmPassword"
|
||||
label="重复初始密码"
|
||||
type="input"
|
||||
type="password"
|
||||
></FormItemTip>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<FormItemTip
|
||||
v-model="form.status"
|
||||
:radio-options="[
|
||||
{label:'启用',value:1},
|
||||
{label:'禁用',value:0},
|
||||
{label:'启用',value:'0'},
|
||||
{label:'禁用',value:'1'},
|
||||
]"
|
||||
:required="false"
|
||||
label="性别"
|
||||
label="状态"
|
||||
type="radio"
|
||||
></FormItemTip>
|
||||
</el-col>
|
||||
@@ -133,9 +242,9 @@ const roleslist = [
|
||||
<div class="commonCard roleInfoBox">
|
||||
<card-nav :show-line="false" title="角色说明"></card-nav>
|
||||
<ul class="roleInfoListBox">
|
||||
<li v-for="(item,index) in roleslist" :key="index" class="roleInfoListItem">
|
||||
<li v-for="(item,index) in rolesList" :key="index" class="roleInfoListItem">
|
||||
<div class="item">
|
||||
<i class="circle"></i>
|
||||
<i :style="{backgroundColor: item.color}" class="circle"></i>
|
||||
<span class="title">{{ item.label }}</span>
|
||||
</div>
|
||||
<div class="subTitle">{{ item.sutTitle }}</div>
|
||||
@@ -143,20 +252,24 @@ const roleslist = [
|
||||
</ul>
|
||||
</div>
|
||||
<div class="commonCard tipBox">
|
||||
<div>
|
||||
<el-icon>
|
||||
<div class="tipTitle">
|
||||
<el-icon :size="18">
|
||||
<InfoFilled/>
|
||||
</el-icon>
|
||||
<span>操作提示</span>
|
||||
</div>
|
||||
<ul>
|
||||
<li>1. 带 * 号为必填项</li>
|
||||
<li>1. 带 <strong>*</strong> 号为必填项</li>
|
||||
<li>2. 用户名创建后不可修改</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div>
|
||||
<el-button>确认创建</el-button>
|
||||
<el-button>取消</el-button>
|
||||
<div class="actionBox">
|
||||
<div style="width:100%;">
|
||||
<el-button size="large" style="width:100%;" type="primary" @click="addRoleAction">确认创建</el-button>
|
||||
</div>
|
||||
<div style="width:100%;margin-top:10px">
|
||||
<el-button size="large" style="width:100%;" @click="reset">取消</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
@@ -184,7 +297,7 @@ const roleslist = [
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
cursor: pointer;
|
||||
margin-right: 12px;
|
||||
}
|
||||
|
||||
@@ -248,11 +361,39 @@ const roleslist = [
|
||||
}
|
||||
|
||||
.tipBox {
|
||||
margin-top: 20px;
|
||||
padding: 15px 17px;
|
||||
border-radius: 8px 8px 8px 8px;
|
||||
background-color: rgba(239, 246, 255, 1);
|
||||
border: 1px solid rgba(191, 219, 254, 1);
|
||||
padding: 17px;
|
||||
margin-bottom: 20px;
|
||||
|
||||
.tipTitle {
|
||||
line-height: 16px;
|
||||
color: rgba(30, 64, 175, 1);
|
||||
font-size: 13px;
|
||||
|
||||
span {
|
||||
margin-left: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
ul {
|
||||
margin-top: 10px;
|
||||
|
||||
li {
|
||||
height: 18px;
|
||||
line-height: 14px;
|
||||
color: rgba(30, 64, 175, 1);
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.actionBox {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<div style="margin-top:24px">
|
||||
<pagecrumb>
|
||||
<template #rightSlot>
|
||||
<el-button size="large" type="primary">新增账号</el-button>
|
||||
<el-button size="large" type="primary" @click="handleAdd">新增账号</el-button>
|
||||
</template>
|
||||
</pagecrumb>
|
||||
</div>
|
||||
@@ -72,9 +72,6 @@
|
||||
<h3>用户列表</h3>
|
||||
</div>
|
||||
<div class="toolbar-actions">
|
||||
<el-button v-has-permi="['system:user:add']" type="primary" plain icon="Plus" @click="handleAdd()">
|
||||
新增
|
||||
</el-button>
|
||||
<right-toolbar
|
||||
v-model:show-search="showSearch"
|
||||
:columns="columns"
|
||||
@@ -94,24 +91,20 @@
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<el-table-column align="center" type="selection" width="50"/>
|
||||
<el-table-column align="center" label="用户名" prop="userId"/>
|
||||
<el-table-column align="center" label="用户名" prop="userName"/>
|
||||
<el-table-column
|
||||
key="userName"
|
||||
label="姓名"
|
||||
align="center"
|
||||
:show-overflow-tooltip="true"
|
||||
>
|
||||
<template #default="scope">
|
||||
<el-link type="primary" underline="never" @click="handleViewDetail(scope.row)">
|
||||
{{ scope.row.userName }}
|
||||
</el-link>
|
||||
{{ scope.row.nickName }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
key="nickName"
|
||||
label="角色"
|
||||
align="center"
|
||||
prop="nickName"
|
||||
prop="roleIds"
|
||||
:show-overflow-tooltip="true"
|
||||
></el-table-column>
|
||||
<el-table-column
|
||||
@@ -128,14 +121,14 @@
|
||||
<el-table-column align="center" label="账号状态" width="100">
|
||||
<template #default="scope">
|
||||
<div class="flex justify-center">
|
||||
<div class="open tag"><i class="circle"></i><span>启用</span></div>
|
||||
<!-- <div class="close tag"><i class="circle"></i><span>已禁用</span></div>-->
|
||||
<div v-if="scope.row.status === '0'" class="open tag"><i class="circle"></i><span>启用</span></div>
|
||||
<div v-else class="close tag"><i class="circle"></i><span>已禁用</span></div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="最后登录" prop="createTime" width="160">
|
||||
<el-table-column align="center" label="最后登录" prop="loginDate" width="160">
|
||||
<template #default="scope">
|
||||
<span style="color:#64748B;">{{ scope.row.createTime }}</span>
|
||||
<span style="color:#64748B;">{{ scope.row.loginDate }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="创建时间" prop="createTime" width="160">
|
||||
@@ -145,43 +138,47 @@
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="center" class-name="small-padding fixed-width" fixed="right" label="操作"
|
||||
width="300">
|
||||
width="220">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
v-hasPermi="['system:user:edit']"
|
||||
link
|
||||
type="primary"
|
||||
@click="handleUpdate(scope.row)"
|
||||
>编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
v-hasPermi="['system:user:resetPwd']"
|
||||
link
|
||||
type="primary"
|
||||
@click="handleResetPwd(scope.row)"
|
||||
>重置密码
|
||||
</el-button>
|
||||
<el-button
|
||||
v-hasPermi="['system:user:edit']"
|
||||
link
|
||||
type="danger"
|
||||
@click="handleAuthRole(scope.row)"
|
||||
>禁用
|
||||
</el-button>
|
||||
<el-button
|
||||
v-hasPermi="['system:user:edit']"
|
||||
link
|
||||
type="success"
|
||||
@click="handleAuthRole(scope.row)"
|
||||
>启用
|
||||
</el-button>
|
||||
<el-button
|
||||
v-hasPermi="['system:user:remove']"
|
||||
link
|
||||
type="danger"
|
||||
@click="handleDelete(scope.row)"
|
||||
>删除
|
||||
</el-button>
|
||||
<div v-if="scope.row.userId !== '1761100000000000001'">
|
||||
<el-button
|
||||
v-hasPermi="['system:user:edit']"
|
||||
link
|
||||
type="primary"
|
||||
@click="handleUpdate(scope.row)"
|
||||
>编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
v-hasPermi="['system:user:resetPwd']"
|
||||
link
|
||||
type="primary"
|
||||
@click="handleResetPwd(scope.row)"
|
||||
>重置密码
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="scope.row.status === '0'"
|
||||
v-hasPermi="['system:user:edit']"
|
||||
link
|
||||
type="danger"
|
||||
@click="handleAuthRole(scope.row)"
|
||||
>禁用
|
||||
</el-button>
|
||||
<el-button
|
||||
v-else
|
||||
v-hasPermi="['system:user:edit']"
|
||||
link
|
||||
type="success"
|
||||
@click="handleAuthRole(scope.row)"
|
||||
>启用
|
||||
</el-button>
|
||||
<el-button
|
||||
v-hasPermi="['system:user:remove']"
|
||||
link
|
||||
type="danger"
|
||||
@click="handleDelete(scope.row)"
|
||||
>删除
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -704,13 +701,16 @@ const cancel = () => {
|
||||
|
||||
/** 新增按钮操作 */
|
||||
const handleAdd = async () => {
|
||||
reset();
|
||||
const {data} = await api.getUser();
|
||||
setDialogTitle('新增用户');
|
||||
openUserDialog();
|
||||
postOptions.value = data.posts;
|
||||
roleOptions.value = data.roles;
|
||||
form.value.password = initPassword.value.toString();
|
||||
router.push({
|
||||
path: '/system/addUser'
|
||||
})
|
||||
// reset();
|
||||
// const {data} = await api.getUser();
|
||||
// setDialogTitle('新增用户');
|
||||
// openUserDialog();
|
||||
// postOptions.value = data.posts;
|
||||
// roleOptions.value = data.roles;
|
||||
// form.value.password = initPassword.value.toString();
|
||||
};
|
||||
|
||||
/** 修改按钮操作 */
|
||||
|
||||
Reference in New Issue
Block a user