1.0.3 的相关功能
This commit is contained in:
@@ -46,6 +46,13 @@
|
|||||||
systemUpgrade()
|
systemUpgrade()
|
||||||
// 获取用户信息
|
// 获取用户信息
|
||||||
getUserInfo()
|
getUserInfo()
|
||||||
|
// 初始化 WebSocket
|
||||||
|
const { accessToken } = useUserStore()
|
||||||
|
// if (accessToken) {
|
||||||
|
// import('@/utils/sys/wsClient').then(({ initWebSocket }) => {
|
||||||
|
// initWebSocket(accessToken)
|
||||||
|
// })
|
||||||
|
// }
|
||||||
})
|
})
|
||||||
|
|
||||||
// 获取用户信息
|
// 获取用户信息
|
||||||
|
|||||||
@@ -85,4 +85,11 @@ export class UserService {
|
|||||||
params
|
params
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
//离职分配
|
||||||
|
static leaveUser(params: any) {
|
||||||
|
return request.get<Api.Work.AddResponse>({
|
||||||
|
url: '/admin/crm/customer/allocation',
|
||||||
|
params
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
<slot name="left"></slot>
|
<slot name="left"></slot>
|
||||||
</div>
|
</div>
|
||||||
<div class="right">
|
<div class="right">
|
||||||
|
<slot name="right"></slot>
|
||||||
<div class="btn" @click="refresh">
|
<div class="btn" @click="refresh">
|
||||||
<i class="iconfont-sys"></i>
|
<i class="iconfont-sys"></i>
|
||||||
</div>
|
</div>
|
||||||
@@ -68,7 +69,6 @@
|
|||||||
}}</ElCheckbox>
|
}}</ElCheckbox>
|
||||||
</div>
|
</div>
|
||||||
</ElPopover>
|
</ElPopover>
|
||||||
<slot name="right"></slot>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -0,0 +1,124 @@
|
|||||||
|
import mittBus from './mittBus'
|
||||||
|
import { useUserStore } from '@/store/modules/user'
|
||||||
|
|
||||||
|
type JsonValue = Record<string, any> | any[]
|
||||||
|
|
||||||
|
const WS_BASE = 'wss://mzl.dev.hnxinyouhe.com/ws?token='
|
||||||
|
|
||||||
|
let socket: WebSocket | null = null
|
||||||
|
let reconnectTimer: any = null
|
||||||
|
let heartbeatTimer: any = null
|
||||||
|
let reconnectAttempts = 0
|
||||||
|
const maxReconnectDelayMs = 30000
|
||||||
|
const heartbeatIntervalMs = 30000
|
||||||
|
|
||||||
|
const getReconnectDelay = () => {
|
||||||
|
const base = 1000 * Math.pow(2, reconnectAttempts)
|
||||||
|
return Math.min(base, maxReconnectDelayMs)
|
||||||
|
}
|
||||||
|
|
||||||
|
const cleanup = () => {
|
||||||
|
if (reconnectTimer) {
|
||||||
|
clearTimeout(reconnectTimer)
|
||||||
|
reconnectTimer = null
|
||||||
|
}
|
||||||
|
if (heartbeatTimer) {
|
||||||
|
clearTimeout(heartbeatTimer)
|
||||||
|
heartbeatTimer = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const startHeartbeat = () => {
|
||||||
|
// 清理上一次的心跳
|
||||||
|
if (heartbeatTimer) {
|
||||||
|
clearTimeout(heartbeatTimer)
|
||||||
|
heartbeatTimer = null
|
||||||
|
}
|
||||||
|
// 递归 setTimeout,确保固定间隔执行
|
||||||
|
heartbeatTimer = setTimeout(() => {
|
||||||
|
try {
|
||||||
|
if (socket && socket.readyState === WebSocket.OPEN) {
|
||||||
|
socket.send(JSON.stringify({ type: 'ping' }))
|
||||||
|
}
|
||||||
|
} catch (_) {}
|
||||||
|
// 下一次心跳
|
||||||
|
startHeartbeat()
|
||||||
|
}, heartbeatIntervalMs)
|
||||||
|
}
|
||||||
|
|
||||||
|
const scheduleReconnect = () => {
|
||||||
|
cleanup()
|
||||||
|
const delay = getReconnectDelay()
|
||||||
|
reconnectTimer = setTimeout(() => {
|
||||||
|
const { accessToken } = useUserStore()
|
||||||
|
if (accessToken) initWebSocket(accessToken)
|
||||||
|
}, delay)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const initWebSocket = (token: string) => {
|
||||||
|
try {
|
||||||
|
if (!token) return
|
||||||
|
if (socket) {
|
||||||
|
try {
|
||||||
|
socket.close()
|
||||||
|
} catch (_) {}
|
||||||
|
socket = null
|
||||||
|
}
|
||||||
|
cleanup()
|
||||||
|
|
||||||
|
const url = `${WS_BASE}${token}`
|
||||||
|
socket = new WebSocket(url)
|
||||||
|
|
||||||
|
socket.onopen = () => {
|
||||||
|
reconnectAttempts = 0
|
||||||
|
startHeartbeat()
|
||||||
|
mittBus.emit('ws:open')
|
||||||
|
try {
|
||||||
|
socket?.send(JSON.stringify({ type: 'ping' }))
|
||||||
|
} catch (_) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
socket.onmessage = (event) => {
|
||||||
|
const dataStr = event.data
|
||||||
|
let data: any = dataStr
|
||||||
|
try {
|
||||||
|
data = JSON.parse(dataStr)
|
||||||
|
} catch (_) {}
|
||||||
|
mittBus.emit('ws:message', data)
|
||||||
|
}
|
||||||
|
|
||||||
|
socket.onerror = (err) => {
|
||||||
|
mittBus.emit('ws:error', err)
|
||||||
|
}
|
||||||
|
|
||||||
|
socket.onclose = () => {
|
||||||
|
mittBus.emit('ws:close')
|
||||||
|
reconnectAttempts += 1
|
||||||
|
scheduleReconnect()
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
mittBus.emit('ws:error', e)
|
||||||
|
scheduleReconnect()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const closeWebSocket = () => {
|
||||||
|
cleanup()
|
||||||
|
try {
|
||||||
|
socket?.close()
|
||||||
|
} catch (_) {}
|
||||||
|
socket = null
|
||||||
|
}
|
||||||
|
|
||||||
|
export const sendWebSocket = (payload: string | JsonValue) => {
|
||||||
|
if (!socket || socket.readyState !== WebSocket.OPEN) return false
|
||||||
|
try {
|
||||||
|
const data = typeof payload === 'string' ? payload : JSON.stringify(payload)
|
||||||
|
socket.send(data)
|
||||||
|
return true
|
||||||
|
} catch (_) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -70,20 +70,80 @@
|
|||||||
<el-dialog v-model="detailDialogVisible" title="详情">
|
<el-dialog v-model="detailDialogVisible" title="详情">
|
||||||
<div v-if="detailRow" v-html="detailRow.desc_collect" class="detils-content"></div>
|
<div v-if="detailRow" v-html="detailRow.desc_collect" class="detils-content"></div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
<el-dialog v-model="audetDialogVisible" title="审核" width="360px">
|
<el-dialog v-model="audetDialogVisible" title="审核" width="700px">
|
||||||
<el-form :model="audetForm" label-width="0">
|
<!-- 客户标记无效 原因与附件回显 -->
|
||||||
<el-form-item>
|
<div style="margin-bottom: 16px">
|
||||||
|
<div style="margin-bottom: 8px">
|
||||||
|
<span>标记原因:</span>
|
||||||
|
<span>{{ reportRemark || '-' }}</span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<span>附件说明:</span>
|
||||||
|
<div
|
||||||
|
v-if="reportAttachments.length"
|
||||||
|
style="margin-top: 8px; display: flex; flex-wrap: wrap; gap: 8px"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
v-for="(att, idx) in reportAttachments"
|
||||||
|
:key="idx"
|
||||||
|
style="
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
border: 1px solid #f0f0f0;
|
||||||
|
padding: 6px 8px;
|
||||||
|
border-radius: 6px;
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<template v-if="/\.(jpg|jpeg|png|gif|webp|bmp)(\?.*)?$/i.test(att.url)">
|
||||||
|
<img
|
||||||
|
:src="att.url"
|
||||||
|
:alt="att.name"
|
||||||
|
style="
|
||||||
|
width: 56px;
|
||||||
|
height: 56px;
|
||||||
|
object-fit: cover;
|
||||||
|
border-radius: 4px;
|
||||||
|
cursor: pointer;
|
||||||
|
"
|
||||||
|
@click="openImagePreview(att.url)"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<i class="iconfont-sys"></i>
|
||||||
|
</template>
|
||||||
|
<el-link
|
||||||
|
v-if="!/\.(jpg|jpeg|png|gif|webp|bmp)(\?.*)?$/i.test(att.url)"
|
||||||
|
type="primary"
|
||||||
|
:underline="false"
|
||||||
|
@click="downloadAttachment(att)"
|
||||||
|
>下载</el-link
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<el-empty v-else description="暂无附件" style="--el-empty-padding: 10px 0" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<el-form :model="audetForm" label-width="50px">
|
||||||
|
<el-form-item label="操作">
|
||||||
<el-select v-model="audetForm.scene" filterable placeholder="请选择" style="width: 100%">
|
<el-select v-model="audetForm.scene" filterable placeholder="请选择" style="width: 100%">
|
||||||
<el-option label="彻底删除" value="delete" />
|
<el-option label="彻底删除" value="delete" />
|
||||||
<el-option label="恢复至公海" value="report" />
|
<el-option label="恢复至公海" value="report" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<div style="display: flex; justify-content: space-around; margin-top: 24px">
|
<div style="display: flex; justify-content: flex-end; margin-top: 24px">
|
||||||
<el-button @click="audetDialogVisible = false">取消</el-button>
|
<el-button @click="audetDialogVisible = false">取消</el-button>
|
||||||
<el-button type="primary" @click="handleAudetSubmit">确定</el-button>
|
<el-button type="primary" @click="handleAudetSubmit">确定</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
<!-- 图片预览 -->
|
||||||
|
<el-image-viewer
|
||||||
|
v-if="imageViewerVisible"
|
||||||
|
:url-list="imageViewerUrls"
|
||||||
|
:initial-index="imageViewerIndex"
|
||||||
|
@close="imageViewerVisible = false"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
@@ -96,6 +156,33 @@
|
|||||||
const detailDialogVisible = ref(false)
|
const detailDialogVisible = ref(false)
|
||||||
const audetDialogVisible = ref(false)
|
const audetDialogVisible = ref(false)
|
||||||
const detailRow = ref<any>(null)
|
const detailRow = ref<any>(null)
|
||||||
|
// 回显的无效原因与附件
|
||||||
|
const reportRemark = ref<string>('')
|
||||||
|
const reportAttachments = ref<Array<{ name: string; url: string }>>([])
|
||||||
|
const imageViewerVisible = ref(false)
|
||||||
|
const imageViewerUrls = ref<string[]>([])
|
||||||
|
const imageViewerIndex = ref(0)
|
||||||
|
// 规范化 URL:去除前缀 @,清理空白
|
||||||
|
const normalizeUrl = (url: string): string => {
|
||||||
|
return (url || '').trim().replace(/^@+/, '')
|
||||||
|
}
|
||||||
|
// 从 URL 提取文件名(忽略查询参数)
|
||||||
|
const fileNameFromUrl = (url: string): string => {
|
||||||
|
const u = normalizeUrl(url)
|
||||||
|
try {
|
||||||
|
const parsed = new URL(u)
|
||||||
|
const name = parsed.pathname.split('/').pop() || ''
|
||||||
|
return decodeURIComponent(name)
|
||||||
|
} catch (_) {
|
||||||
|
const path = u.split('?')[0]
|
||||||
|
const name = path.split('/').pop() || u
|
||||||
|
try {
|
||||||
|
return decodeURIComponent(name)
|
||||||
|
} catch {
|
||||||
|
return name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
const pagination = reactive({
|
const pagination = reactive({
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
@@ -163,8 +250,53 @@
|
|||||||
//审核
|
//审核
|
||||||
const goaudit = async (row: any) => {
|
const goaudit = async (row: any) => {
|
||||||
audetForm.id = row.id
|
audetForm.id = row.id
|
||||||
|
// 保存行数据用于展示
|
||||||
|
detailRow.value = row
|
||||||
|
// 兼容字段:优先 remark,其次 report_desc/desc
|
||||||
|
reportRemark.value = row.audit?.remark || ''
|
||||||
|
// 映射为可用的 {name, url}
|
||||||
|
reportAttachments.value = (row.audit?.img || [])
|
||||||
|
.map((it: any) => {
|
||||||
|
if (typeof it === 'string') {
|
||||||
|
const url = normalizeUrl(it)
|
||||||
|
return { name: fileNameFromUrl(url) || url, url }
|
||||||
|
}
|
||||||
|
const url = normalizeUrl(it.storage_path_full || it.url || it.file_url || '')
|
||||||
|
const name = it.original_name || it.name || it.file_name || fileNameFromUrl(url) || ''
|
||||||
|
return { name, url }
|
||||||
|
})
|
||||||
|
.filter((x: { url: any }) => x.url)
|
||||||
|
// 仅图片列表用于预览
|
||||||
|
imageViewerUrls.value = reportAttachments.value
|
||||||
|
.map((x) => normalizeUrl(x.url))
|
||||||
|
.filter((u) => /\.(jpg|jpeg|png|gif|webp|bmp)(\?.*)?$/i.test(u))
|
||||||
audetDialogVisible.value = true
|
audetDialogVisible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const openImagePreview = (url: string) => {
|
||||||
|
const nurl = normalizeUrl(url)
|
||||||
|
// 按当前附件重建预览列表(确保与点击地址一致且包含查询参数的图片)
|
||||||
|
const imgs = reportAttachments.value
|
||||||
|
.map((x) => normalizeUrl(x.url))
|
||||||
|
.filter((u) => /\.(jpg|jpeg|png|gif|webp|bmp)(\?.*)?$/i.test(u))
|
||||||
|
imageViewerUrls.value = imgs.length > 0 ? imgs : [nurl]
|
||||||
|
const idx = imageViewerUrls.value.findIndex((u) => u === nurl)
|
||||||
|
imageViewerIndex.value = idx >= 0 ? idx : 0
|
||||||
|
imageViewerVisible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
const downloadAttachment = (att: { name: string; url: string }) => {
|
||||||
|
try {
|
||||||
|
const a = document.createElement('a')
|
||||||
|
a.href = att.url
|
||||||
|
a.download = att.name || '附件'
|
||||||
|
document.body.appendChild(a)
|
||||||
|
a.click()
|
||||||
|
document.body.removeChild(a)
|
||||||
|
} catch (e) {
|
||||||
|
console.error('下载失败', e)
|
||||||
|
}
|
||||||
|
}
|
||||||
const handleAudetSubmit = async () => {
|
const handleAudetSubmit = async () => {
|
||||||
const res = await manageService.crmCustomerAudit(audetForm)
|
const res = await manageService.crmCustomerAudit(audetForm)
|
||||||
ElMessage.success(res?.message || '设置成功!')
|
ElMessage.success(res?.message || '设置成功!')
|
||||||
|
|||||||
@@ -195,8 +195,11 @@
|
|||||||
跟进状态:<span>{{ detailRow.follow_txt }}</span>
|
跟进状态:<span>{{ detailRow.follow_txt }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div>备注:{{ detailRow.describe }}</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="dtitle">详情内容</div>
|
<div v-if="detailRow.desc_collect != ''" class="dtitle">详情内容</div>
|
||||||
<div v-if="detailRow" v-html="detailRow.desc_collect" class="detils-content"></div>
|
<div v-if="detailRow" v-html="detailRow.desc_collect" class="detils-content"></div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
<!-- 转移跟单对话框 -->
|
<!-- 转移跟单对话框 -->
|
||||||
@@ -247,7 +250,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
<!-- 跟进记录对话框 -->
|
<!-- 跟进记录对话框 -->
|
||||||
<el-dialog v-model="followRecordDialogVisible" title="跟进记录" width="800px">
|
<el-dialog v-model="followRecordDialogVisible" title="跟进记录" width="800px">
|
||||||
<!-- 跟进记录列表 -->
|
<!-- 跟进记录列表 -->
|
||||||
@@ -280,7 +282,7 @@
|
|||||||
class="timeline-img"
|
class="timeline-img"
|
||||||
alt="图片"
|
alt="图片"
|
||||||
@click="handleImageClick(item.picture_full)"
|
@click="handleImageClick(item.picture_full)"
|
||||||
style="cursor: pointer;"
|
style="cursor: pointer"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -297,7 +299,6 @@
|
|||||||
</ElScrollbar>
|
</ElScrollbar>
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
<!-- 图片预览对话框 -->
|
<!-- 图片预览对话框 -->
|
||||||
<el-image-viewer
|
<el-image-viewer
|
||||||
v-if="imageViewerVisible"
|
v-if="imageViewerVisible"
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
</template> -->
|
</template> -->
|
||||||
</el-segmented>
|
</el-segmented>
|
||||||
<!-- 按钮权限:后端控制模式,使用自定义指令 -->
|
<!-- 按钮权限:后端控制模式,使用自定义指令 -->
|
||||||
<ElButton
|
<!-- <ElButton
|
||||||
v-auth="'system@menu_add'"
|
v-auth="'system@menu_add'"
|
||||||
@click="showModel('menu', null)"
|
@click="showModel('menu', null)"
|
||||||
v-ripple
|
v-ripple
|
||||||
@@ -37,12 +37,17 @@
|
|||||||
</ElButton>
|
</ElButton>
|
||||||
<ElButton @click="toggleExpand" v-ripple>
|
<ElButton @click="toggleExpand" v-ripple>
|
||||||
{{ isExpanded ? '收起' : '展开' }}
|
{{ isExpanded ? '收起' : '展开' }}
|
||||||
</ElButton>
|
</ElButton> -->
|
||||||
<!-- 按钮权限:前端控制模式,使用 hasAuth 方法 -->
|
<!-- 按钮权限:前端控制模式,使用 hasAuth 方法 -->
|
||||||
<!-- <ElButton v-if="hasAuth('B_CODE1')" @click="showModel('menu', null, true)" v-ripple>
|
<!-- <ElButton v-if="hasAuth('B_CODE1')" @click="showModel('menu', null, true)" v-ripple>
|
||||||
添加菜单
|
添加菜单
|
||||||
</ElButton> -->
|
</ElButton> -->
|
||||||
</template>
|
</template>
|
||||||
|
<template #right>
|
||||||
|
<div class="btnadds" @click="showModel('menu', null)" v-auth="'system@menu_add'">
|
||||||
|
<i class="iconfont-sys"></i>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
</ArtTableHeader>
|
</ArtTableHeader>
|
||||||
<!-- 表格 -->
|
<!-- 表格 -->
|
||||||
<ArtTable
|
<ArtTable
|
||||||
@@ -748,4 +753,18 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.btnadds {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
margin-left: 10px;
|
||||||
|
color: var(--art-gray-700);
|
||||||
|
cursor: pointer;
|
||||||
|
background-color: rgba(var(--art-gray-200-rgb), 0.8);
|
||||||
|
border-radius: 6px;
|
||||||
|
transition: color 0.3s;
|
||||||
|
transition: all 0.3s;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -7,7 +7,9 @@
|
|||||||
<div style="width: 12px"></div>
|
<div style="width: 12px"></div>
|
||||||
<ElCol :xs="24" :sm="12" :lg="6" class="el-col2">
|
<ElCol :xs="24" :sm="12" :lg="6" class="el-col2">
|
||||||
<ElButton v-ripple>搜索</ElButton>
|
<ElButton v-ripple>搜索</ElButton>
|
||||||
<ElButton @click="showDialog('add')" v-ripple v-if="hasAuth('system@role_add')">新增角色</ElButton>
|
<ElButton @click="showDialog('add')" v-ripple v-if="hasAuth('system@role_add')"
|
||||||
|
>新增角色</ElButton
|
||||||
|
>
|
||||||
</ElCol>
|
</ElCol>
|
||||||
</ElRow>
|
</ElRow>
|
||||||
|
|
||||||
@@ -36,11 +38,12 @@
|
|||||||
<ElTableColumn fixed="right" label="操作" width="200px">
|
<ElTableColumn fixed="right" label="操作" width="200px">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<ElRow>
|
<ElRow>
|
||||||
<el-button
|
<el-button link @click="showPermissionDialog(scope.row)">
|
||||||
|
<!-- <el-button
|
||||||
link
|
link
|
||||||
@click="showPermissionDialog(scope.row)"
|
@click="showPermissionDialog(scope.row)"
|
||||||
v-if="hasAuth('system@role_perm')"
|
v-if="hasAuth('system@role_perm')"
|
||||||
>
|
> -->
|
||||||
菜单权限
|
菜单权限
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
@@ -92,39 +95,38 @@
|
|||||||
</template>
|
</template>
|
||||||
</ElDialog>
|
</ElDialog>
|
||||||
|
|
||||||
<ElDialog
|
<ElDialog v-model="permissionDialog" title="菜单权限" align-center>
|
||||||
v-model="permissionDialog"
|
<el-tabs v-model="activeName" class="demo-tabs">
|
||||||
title="菜单权限"
|
<el-tab-pane
|
||||||
width="520px"
|
v-for="sys in systemsList"
|
||||||
align-center
|
:key="sys.id"
|
||||||
class="el-dialog-border"
|
:label="sys.name"
|
||||||
>
|
:name="String(sys.id)"
|
||||||
<ElScrollbar height="70vh">
|
|
||||||
<ElTree
|
|
||||||
ref="treeRef"
|
|
||||||
:data="processedMenuList"
|
|
||||||
show-checkbox
|
|
||||||
node-key="id"
|
|
||||||
:default-expand-all="isExpandAll"
|
|
||||||
:props="defaultProps"
|
|
||||||
@check="handleTreeCheck"
|
|
||||||
>
|
>
|
||||||
<template #default="{ data }">
|
<ElScrollbar height="70vh">
|
||||||
<div style="display: flex; align-items: center">
|
<ElTree
|
||||||
<span v-if="data.isAuth">
|
:ref="(el:any) => setTreeRef(sys.id, el)"
|
||||||
{{ data.label }}
|
:data="processedMenuBySystem[sys.id] || []"
|
||||||
</span>
|
show-checkbox
|
||||||
<span v-else>{{ defaultProps.label(data) }}</span>
|
node-key="id"
|
||||||
</div>
|
:default-expand-all="isExpandAll"
|
||||||
</template>
|
:props="defaultProps"
|
||||||
</ElTree>
|
@check="() => handleTreeCheck(sys.id)"
|
||||||
</ElScrollbar>
|
>
|
||||||
|
<template #default="{ data }">
|
||||||
|
<div style="display: flex; align-items: center">
|
||||||
|
<span v-if="data.isAuth">
|
||||||
|
{{ data.label }}
|
||||||
|
</span>
|
||||||
|
<span v-else>{{ defaultProps.label(data) }}</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</ElTree>
|
||||||
|
</ElScrollbar>
|
||||||
|
</el-tab-pane>
|
||||||
|
</el-tabs>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<div class="dialog-footer">
|
<div class="dialog-footer">
|
||||||
<ElButton @click="toggleExpandAll">{{ isExpandAll ? '全部收起' : '全部展开' }}</ElButton>
|
|
||||||
<ElButton @click="toggleSelectAll" style="margin-left: 8px">{{
|
|
||||||
isSelectAll ? '取消全选' : '全部选择'
|
|
||||||
}}</ElButton>
|
|
||||||
<ElButton type="primary" @click="savePermission">保存</ElButton>
|
<ElButton type="primary" @click="savePermission">保存</ElButton>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -138,17 +140,29 @@
|
|||||||
import { formatMenuTitle } from '@/router/utils/utils'
|
import { formatMenuTitle } from '@/router/utils/utils'
|
||||||
import { systemService } from '@/api/systemApi'
|
import { systemService } from '@/api/systemApi'
|
||||||
import { useAuth } from '@/composables/useAuth'
|
import { useAuth } from '@/composables/useAuth'
|
||||||
|
import { UserService } from '@/api/usersApi'
|
||||||
const { hasAuth } = useAuth()
|
const { hasAuth } = useAuth()
|
||||||
// import { ButtonMoreItem } from '@/components/core/forms/ArtButtonMore.vue'
|
// import { ButtonMoreItem } from '@/components/core/forms/ArtButtonMore.vue'
|
||||||
// import { Role, ROLE_LIST_DATA } from '@/mock/temp/formData'
|
// import { Role, ROLE_LIST_DATA } from '@/mock/temp/formData'
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
defineOptions({ name: 'Role' })
|
defineOptions({ name: 'Role' })
|
||||||
|
const activeName = ref('1')
|
||||||
const dialogVisible = ref(false)
|
const dialogVisible = ref(false)
|
||||||
const permissionDialog = ref(false)
|
const permissionDialog = ref(false)
|
||||||
// 权限树数据(来自接口 getPermissionMenuList)
|
// 权限树数据(来自接口 getPermissionMenuList)
|
||||||
const permissionMenuList = ref<any[]>([])
|
const permissionMenuList = ref<any[]>([])
|
||||||
|
const permissionMenuListwork = ref<any[]>([])
|
||||||
|
const permissionMenuListcrm = ref<any[]>([])
|
||||||
|
// 精简后的多系统映射
|
||||||
|
const permissionMenuBySystem = reactive<Record<number, any[]>>({})
|
||||||
|
const processedMenuBySystem = reactive<Record<number, any[]>>({})
|
||||||
|
const treeRefs = reactive<Record<number, any>>({})
|
||||||
|
const setTreeRef = (systemId: number, el: any) => {
|
||||||
|
if (el) treeRefs[systemId] = el
|
||||||
|
}
|
||||||
const treeRef = ref()
|
const treeRef = ref()
|
||||||
|
const treeRefwork = ref()
|
||||||
|
const treeRefcrm = ref()
|
||||||
const isExpandAll = ref(true)
|
const isExpandAll = ref(true)
|
||||||
const isSelectAll = ref(false)
|
const isSelectAll = ref(false)
|
||||||
const pagination = reactive({
|
const pagination = reactive({
|
||||||
@@ -162,7 +176,12 @@
|
|||||||
name: [{ required: true, message: '请输入角色名称', trigger: 'blur' }],
|
name: [{ required: true, message: '请输入角色名称', trigger: 'blur' }],
|
||||||
des: [{ required: true, message: '请输入角色描述', trigger: 'blur' }]
|
des: [{ required: true, message: '请输入角色描述', trigger: 'blur' }]
|
||||||
})
|
})
|
||||||
|
//系统
|
||||||
|
const systemsList = ref<any>()
|
||||||
|
const getsystemsList = async () => {
|
||||||
|
const response = await UserService.getsystemsList()
|
||||||
|
systemsList.value = response || []
|
||||||
|
}
|
||||||
const form = reactive<any>({
|
const form = reactive<any>({
|
||||||
id: '',
|
id: '',
|
||||||
name: '',
|
name: '',
|
||||||
@@ -234,25 +253,46 @@
|
|||||||
permissionDialog.value = true
|
permissionDialog.value = true
|
||||||
roleId.value = row.id
|
roleId.value = row.id
|
||||||
try {
|
try {
|
||||||
const res = await systemService.getPermissionMenuList({ role_id: row.id })
|
await getsystemsList()
|
||||||
// 兼容不同返回结构(data/records/直接数组)
|
// 并行请求所选用户的各系统权限
|
||||||
const list = (res as any)?.data ?? (res as any)?.records ?? (res as any)
|
const sysIds = (systemsList.value || []).map((s: any) => s.id)
|
||||||
permissionMenuList.value = Array.isArray(list) ? list : []
|
const results = await Promise.all(
|
||||||
// 根据接口返回的 selected 字段设置默认选中
|
sysIds.map((id: number) =>
|
||||||
|
systemService.getPermissionMenuList({ role_id: row.id, system_id: id })
|
||||||
|
)
|
||||||
|
)
|
||||||
|
sysIds.forEach((id: number, idx: number) => {
|
||||||
|
const raw = results[idx] as any
|
||||||
|
const list = raw?.data ?? raw?.records ?? raw
|
||||||
|
permissionMenuBySystem[id] = Array.isArray(list) ? list : []
|
||||||
|
processedMenuBySystem[id] = buildProcessedMenu(permissionMenuBySystem[id])
|
||||||
|
})
|
||||||
|
// 兼容旧变量,避免其它逻辑引用报错
|
||||||
|
permissionMenuList.value = permissionMenuBySystem[1] || []
|
||||||
|
permissionMenuListwork.value = permissionMenuBySystem[2] || []
|
||||||
|
permissionMenuListcrm.value = permissionMenuBySystem[3] || []
|
||||||
|
// 设置默认选中
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
const keys = buildDefaultCheckedKeys(permissionMenuList.value)
|
sysIds.forEach((id: number) => {
|
||||||
treeRef.value?.setCheckedKeys(keys)
|
const keys = buildDefaultCheckedKeys(permissionMenuBySystem[id] || [])
|
||||||
handleTreeCheck()
|
treeRefs[id]?.setCheckedKeys?.(keys)
|
||||||
|
handleTreeCheck(id)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
permissionMenuList.value = []
|
permissionMenuList.value = []
|
||||||
|
permissionMenuListwork.value = []
|
||||||
|
permissionMenuListcrm.value = []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 构建默认选中的 key 列表(与 node-key="id" 一致)
|
// 构建默认选中的 key 列表(与 node-key="id" 一致)
|
||||||
const buildDefaultCheckedKeys = (source: any[]): Array<string | number> => {
|
const buildDefaultCheckedKeys = (source: any[]): Array<string | number> => {
|
||||||
const keys: Array<string | number> = []
|
const keys: Array<string | number> = []
|
||||||
const walk = (node: any) => {
|
const walk = (node: any) => {
|
||||||
if (node?.meta?.selected) {
|
const hasChildren = Array.isArray(node?.children) && node.children.length > 0
|
||||||
|
const hasAuths = Array.isArray(node?.meta?.authList) && node.meta.authList.length > 0
|
||||||
|
// 仅当没有子节点且没有权限子项时,才勾选父节点,避免联动导致子级被全选
|
||||||
|
if (node?.meta?.selected && !hasChildren && !hasAuths) {
|
||||||
keys.push(node.id)
|
keys.push(node.id)
|
||||||
}
|
}
|
||||||
if (Array.isArray(node?.meta?.authList)) {
|
if (Array.isArray(node?.meta?.authList)) {
|
||||||
@@ -262,7 +302,7 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (Array.isArray(node?.children)) node.children.forEach(walk)
|
if (hasChildren) node.children.forEach(walk)
|
||||||
}
|
}
|
||||||
source.forEach(walk)
|
source.forEach(walk)
|
||||||
return keys
|
return keys
|
||||||
@@ -272,7 +312,6 @@
|
|||||||
const processNode = (node: any) => {
|
const processNode = (node: any) => {
|
||||||
// 规范化 id,确保树节点唯一键与 node-key 对应
|
// 规范化 id,确保树节点唯一键与 node-key 对应
|
||||||
const processed: any = { ...node, id: node.id }
|
const processed: any = { ...node, id: node.id }
|
||||||
|
|
||||||
// 如果有 authList,将其转换为子节点
|
// 如果有 authList,将其转换为子节点
|
||||||
if (node.meta && node.meta.authList && node.meta.authList.length) {
|
if (node.meta && node.meta.authList && node.meta.authList.length) {
|
||||||
const authNodes = node.meta.authList.map((auth: any) => ({
|
const authNodes = node.meta.authList.map((auth: any) => ({
|
||||||
@@ -285,27 +324,97 @@
|
|||||||
isAuth: true,
|
isAuth: true,
|
||||||
checked: auth.selected || false
|
checked: auth.selected || false
|
||||||
}))
|
}))
|
||||||
|
|
||||||
processed.children = processed.children ? [...processed.children, ...authNodes] : authNodes
|
processed.children = processed.children ? [...processed.children, ...authNodes] : authNodes
|
||||||
}
|
}
|
||||||
|
|
||||||
// 递归处理子节点
|
// 递归处理子节点
|
||||||
if (processed.children) {
|
if (processed.children) {
|
||||||
processed.children = processed.children.map(processNode)
|
processed.children = processed.children.map(processNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
return processed
|
return processed
|
||||||
}
|
}
|
||||||
|
|
||||||
const source = permissionMenuList.value || []
|
const source = permissionMenuList.value || []
|
||||||
return source.map(processNode)
|
return source.map(processNode)
|
||||||
})
|
})
|
||||||
|
const processedMenuListwork = computed(() => {
|
||||||
|
const processNode = (node: any) => {
|
||||||
|
// 规范化 id,确保树节点唯一键与 node-key 对应
|
||||||
|
const processed: any = { ...node, id: node.id }
|
||||||
|
// 如果有 authList,将其转换为子节点
|
||||||
|
if (node.meta && node.meta.authList && node.meta.authList.length) {
|
||||||
|
const authNodes = node.meta.authList.map((auth: any) => ({
|
||||||
|
// 为权限子节点提供稳定唯一 id(数字+字符串),与 node-key="id" 匹配
|
||||||
|
id: `${node.id}__auth__${auth.authMark}`,
|
||||||
|
name: `${node.name}_${auth.authMark}`,
|
||||||
|
label: auth.title,
|
||||||
|
auth_mark: auth.authMark,
|
||||||
|
auth_id: auth.id,
|
||||||
|
isAuth: true,
|
||||||
|
checked: auth.selected || false
|
||||||
|
}))
|
||||||
|
processed.children = processed.children ? [...processed.children, ...authNodes] : authNodes
|
||||||
|
}
|
||||||
|
// 递归处理子节点
|
||||||
|
if (processed.children) {
|
||||||
|
processed.children = processed.children.map(processNode)
|
||||||
|
}
|
||||||
|
return processed
|
||||||
|
}
|
||||||
|
const source = permissionMenuListwork.value || []
|
||||||
|
return source.map(processNode)
|
||||||
|
})
|
||||||
|
const processedMenuListcrm = computed(() => {
|
||||||
|
const processNode = (node: any) => {
|
||||||
|
// 规范化 id,确保树节点唯一键与 node-key 对应
|
||||||
|
const processed: any = { ...node, id: node.id }
|
||||||
|
// 如果有 authList,将其转换为子节点
|
||||||
|
if (node.meta && node.meta.authList && node.meta.authList.length) {
|
||||||
|
const authNodes = node.meta.authList.map((auth: any) => ({
|
||||||
|
// 为权限子节点提供稳定唯一 id(数字+字符串),与 node-key="id" 匹配
|
||||||
|
id: `${node.id}__auth__${auth.authMark}`,
|
||||||
|
name: `${node.name}_${auth.authMark}`,
|
||||||
|
label: auth.title,
|
||||||
|
auth_mark: auth.authMark,
|
||||||
|
auth_id: auth.id,
|
||||||
|
isAuth: true,
|
||||||
|
checked: auth.selected || false
|
||||||
|
}))
|
||||||
|
processed.children = processed.children ? [...processed.children, ...authNodes] : authNodes
|
||||||
|
}
|
||||||
|
// 递归处理子节点
|
||||||
|
if (processed.children) {
|
||||||
|
processed.children = processed.children.map(processNode)
|
||||||
|
}
|
||||||
|
return processed
|
||||||
|
}
|
||||||
|
const source = permissionMenuListcrm.value || []
|
||||||
|
return source.map(processNode)
|
||||||
|
})
|
||||||
|
|
||||||
const defaultProps = {
|
const defaultProps = {
|
||||||
children: 'children',
|
children: 'children',
|
||||||
label: (data: any) => formatMenuTitle(data.meta?.title) || ''
|
label: (data: any) => formatMenuTitle(data.meta?.title) || ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 通用:处理节点,展开权限为子节点
|
||||||
|
const processNode = (node: any) => {
|
||||||
|
const processed: any = { ...node, id: node.id }
|
||||||
|
if (node.meta && node.meta.authList && node.meta.authList.length) {
|
||||||
|
const authNodes = node.meta.authList.map((auth: any) => ({
|
||||||
|
id: `${node.id}__auth__${auth.authMark}`,
|
||||||
|
name: `${node.name}_${auth.authMark}`,
|
||||||
|
label: auth.title,
|
||||||
|
auth_mark: auth.authMark,
|
||||||
|
auth_id: auth.id,
|
||||||
|
isAuth: true,
|
||||||
|
checked: auth.selected || false
|
||||||
|
}))
|
||||||
|
processed.children = processed.children ? [...processed.children, ...authNodes] : authNodes
|
||||||
|
}
|
||||||
|
if (processed.children) processed.children = processed.children.map(processNode)
|
||||||
|
return processed
|
||||||
|
}
|
||||||
|
const buildProcessedMenu = (source: any[]) => (source || []).map(processNode)
|
||||||
|
|
||||||
const deleteRole = async (row: any) => {
|
const deleteRole = async (row: any) => {
|
||||||
ElMessageBox.confirm('确定删除该角色吗?', '删除确认', {
|
ElMessageBox.confirm('确定删除该角色吗?', '删除确认', {
|
||||||
confirmButtonText: '确定',
|
confirmButtonText: '确定',
|
||||||
@@ -335,46 +444,33 @@
|
|||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
formEl.resetFields()
|
formEl.resetFields()
|
||||||
}
|
}
|
||||||
|
const getSelectedIdsBySystem = (systemId: number) => {
|
||||||
const getSelectedIds = () => {
|
const tree = treeRefs[systemId]
|
||||||
const tree = treeRef.value
|
if (!tree) return [] as (string | number)[]
|
||||||
if (!tree) return { menuIds: [], authIds: [] }
|
|
||||||
|
|
||||||
const checkedNodes = tree.getCheckedNodes?.(false) || []
|
const checkedNodes = tree.getCheckedNodes?.(false) || []
|
||||||
const halfCheckedNodes = tree.getHalfCheckedNodes?.() || []
|
const halfCheckedNodes = tree.getHalfCheckedNodes?.() || []
|
||||||
const allNodes = [...checkedNodes, ...halfCheckedNodes]
|
const allNodes = [...checkedNodes, ...halfCheckedNodes]
|
||||||
|
|
||||||
const menuIds = Array.from(
|
const menuIds = Array.from(
|
||||||
new Set(
|
new Set(allNodes.filter((n: any) => !n.isAuth && n.id != null).map((n: any) => n.id))
|
||||||
allNodes
|
|
||||||
.filter((n: any) => !n.isAuth && n.id !== undefined && n.id !== null)
|
|
||||||
.map((n: any) => n.id)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
const authIds = Array.from(
|
const authIds = Array.from(
|
||||||
new Set(
|
new Set(
|
||||||
checkedNodes.filter((n: any) => n.isAuth && n.auth_id != null).map((n: any) => n.auth_id)
|
checkedNodes.filter((n: any) => n.isAuth && n.auth_id != null).map((n: any) => n.auth_id)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
return Array.from(new Set([...(menuIds as any[]), ...(authIds as any[])]))
|
||||||
const ids = Array.from(new Set([...(menuIds as any[]), ...(authIds as any[])]))
|
|
||||||
return { menuIds, authIds, ids }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const savePermission = async () => {
|
const savePermission = async () => {
|
||||||
const { ids } = getSelectedIds()
|
const sysIds = (systemsList.value || []).map((s: any) => s.id)
|
||||||
// console.log('选中的菜单ID:', menuIds)
|
const idall = Array.from(new Set(sysIds.flatMap((id: number) => getSelectedIdsBySystem(id))))
|
||||||
// console.log('选中的权限ID:', authIds)
|
console.log('idall:', idall)
|
||||||
// console.log('合并后的全部ID:', ids)
|
|
||||||
|
|
||||||
const res = await systemService.roleAuth({
|
const res = await systemService.roleAuth({
|
||||||
role_id: roleId.value,
|
role_id: roleId.value,
|
||||||
resources: ids
|
resources: idall
|
||||||
})
|
})
|
||||||
ElMessage.success(res?.message || '权限保存成功')
|
ElMessage.success(res?.message || '权限保存成功')
|
||||||
permissionDialog.value = false
|
permissionDialog.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
const toggleExpandAll = () => {
|
const toggleExpandAll = () => {
|
||||||
const tree = treeRef.value
|
const tree = treeRef.value
|
||||||
if (!tree) return
|
if (!tree) return
|
||||||
@@ -420,13 +516,32 @@
|
|||||||
return keys
|
return keys
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleTreeCheck = () => {
|
const handleTreeCheck = (systemId?: number) => {
|
||||||
const tree = treeRef.value
|
const sysId = systemId ?? Number(activeName.value)
|
||||||
|
const tree = treeRefs[sysId] || treeRef.value
|
||||||
|
if (!tree) return
|
||||||
|
const checkedKeys = tree.getCheckedKeys?.() || []
|
||||||
|
const allKeys = getAllNodeKeys(processedMenuBySystem[sysId] || [])
|
||||||
|
isSelectAll.value = checkedKeys.length === allKeys.length && allKeys.length > 0
|
||||||
|
}
|
||||||
|
const handleTreeCheckwork = () => {
|
||||||
|
const tree = treeRefwork.value
|
||||||
if (!tree) return
|
if (!tree) return
|
||||||
|
|
||||||
// 使用树组件的getCheckedKeys方法获取选中的节点
|
// 使用树组件的getCheckedKeys方法获取选中的节点
|
||||||
const checkedKeys = tree.getCheckedKeys()
|
const checkedKeys = tree.getCheckedKeys()
|
||||||
const allKeys = getAllNodeKeys(processedMenuList.value)
|
const allKeys = getAllNodeKeys(processedMenuListwork.value)
|
||||||
|
|
||||||
|
// 判断是否全选:选中的节点数量等于总节点数量
|
||||||
|
isSelectAll.value = checkedKeys.length === allKeys.length && allKeys.length > 0
|
||||||
|
}
|
||||||
|
const handleTreeCheckcrm = () => {
|
||||||
|
const tree = treeRefcrm.value
|
||||||
|
if (!tree) return
|
||||||
|
|
||||||
|
// 使用树组件的getCheckedKeys方法获取选中的节点
|
||||||
|
const checkedKeys = tree.getCheckedKeys()
|
||||||
|
const allKeys = getAllNodeKeys(processedMenuListcrm.value)
|
||||||
|
|
||||||
// 判断是否全选:选中的节点数量等于总节点数量
|
// 判断是否全选:选中的节点数量等于总节点数量
|
||||||
isSelectAll.value = checkedKeys.length === allKeys.length && allKeys.length > 0
|
isSelectAll.value = checkedKeys.length === allKeys.length && allKeys.length > 0
|
||||||
|
|||||||
+217
-69
@@ -14,6 +14,9 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</div>
|
</div>
|
||||||
|
<el-button type="primary" @click="leaveUserfn">
|
||||||
|
<i class="iconfont-sys"></i> 离职客户分配
|
||||||
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
<div class="boxshadow">
|
<div class="boxshadow">
|
||||||
<!-- 表格 -->
|
<!-- 表格 -->
|
||||||
@@ -27,7 +30,7 @@
|
|||||||
:total="pagination.total"
|
:total="pagination.total"
|
||||||
@size-change="handleSizeChange"
|
@size-change="handleSizeChange"
|
||||||
@current-change="handleCurrentChange"
|
@current-change="handleCurrentChange"
|
||||||
lass="customer-table"
|
class="customer-table"
|
||||||
>
|
>
|
||||||
<template #default>
|
<template #default>
|
||||||
<!-- <el-table-column prop="id" label="用户ID" align="center" /> -->
|
<!-- <el-table-column prop="id" label="用户ID" align="center" /> -->
|
||||||
@@ -117,7 +120,7 @@
|
|||||||
@selection-change="handleSelectionChange"
|
@selection-change="handleSelectionChange"
|
||||||
@size-change="handleSizeChangekh"
|
@size-change="handleSizeChangekh"
|
||||||
@current-change="handleCurrentChangekh"
|
@current-change="handleCurrentChangekh"
|
||||||
lass="customer-table"
|
class="customer-table"
|
||||||
>
|
>
|
||||||
<template #default>
|
<template #default>
|
||||||
<el-table-column type="selection" width="55px" align="center"></el-table-column>
|
<el-table-column type="selection" width="55px" align="center"></el-table-column>
|
||||||
@@ -227,39 +230,38 @@
|
|||||||
:hide-on-click-modal="true"
|
:hide-on-click-modal="true"
|
||||||
@close="showImageViewer = false"
|
@close="showImageViewer = false"
|
||||||
/>
|
/>
|
||||||
<ElDialog
|
<ElDialog v-model="permissionDialog" title="菜单权限" align-center>
|
||||||
v-model="permissionDialog"
|
<el-tabs v-model="activeName" class="demo-tabs">
|
||||||
title="菜单权限"
|
<el-tab-pane
|
||||||
width="520px"
|
v-for="sys in systemsList"
|
||||||
align-center
|
:key="sys.id"
|
||||||
class="el-dialog-border"
|
:label="sys.name"
|
||||||
>
|
:name="String(sys.id)"
|
||||||
<ElScrollbar height="70vh">
|
|
||||||
<ElTree
|
|
||||||
ref="treeRef"
|
|
||||||
:data="processedMenuList"
|
|
||||||
show-checkbox
|
|
||||||
node-key="id"
|
|
||||||
:default-expand-all="isExpandAll"
|
|
||||||
:props="defaultProps"
|
|
||||||
@check="handleTreeCheck"
|
|
||||||
>
|
>
|
||||||
<template #default="{ data }">
|
<ElScrollbar height="70vh">
|
||||||
<div style="display: flex; align-items: center">
|
<ElTree
|
||||||
<span v-if="data.isAuth">
|
:ref="(el: any) => setTreeRef(sys.id, el)"
|
||||||
{{ data.label }}
|
:data="processedMenuBySystem[sys.id] || []"
|
||||||
</span>
|
show-checkbox
|
||||||
<span v-else>{{ defaultProps.label(data) }}</span>
|
node-key="id"
|
||||||
</div>
|
:default-expand-all="isExpandAll"
|
||||||
</template>
|
:props="defaultProps"
|
||||||
</ElTree>
|
@check="() => handleTreeCheck(sys.id)"
|
||||||
</ElScrollbar>
|
>
|
||||||
|
<template #default="{ data }">
|
||||||
|
<div style="display: flex; align-items: center">
|
||||||
|
<span v-if="data.isAuth">
|
||||||
|
{{ data.label }}
|
||||||
|
</span>
|
||||||
|
<span v-else>{{ defaultProps.label(data) }}</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</ElTree>
|
||||||
|
</ElScrollbar>
|
||||||
|
</el-tab-pane>
|
||||||
|
</el-tabs>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<div class="dialog-footer">
|
<div class="dialog-footer">
|
||||||
<ElButton @click="toggleExpandAll">{{ isExpandAll ? '全部收起' : '全部展开' }}</ElButton>
|
|
||||||
<ElButton @click="toggleSelectAll" style="margin-left: 8px">{{
|
|
||||||
isSelectAll ? '取消全选' : '全部选择'
|
|
||||||
}}</ElButton>
|
|
||||||
<ElButton type="primary" @click="savePermission">保存</ElButton>
|
<ElButton type="primary" @click="savePermission">保存</ElButton>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -318,17 +320,69 @@
|
|||||||
</div>
|
</div>
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
<!-- 离职客户分配对话框 -->
|
||||||
|
<el-dialog
|
||||||
|
title="离职客户分配"
|
||||||
|
v-model="leaveUserDialogVisible"
|
||||||
|
width="500px"
|
||||||
|
:close-on-click-modal="false"
|
||||||
|
>
|
||||||
|
<el-form :model="leaveUserForm" ref="leaveUserFormRef" label-width="80px" class="add-form">
|
||||||
|
<el-row :gutter="16">
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="公司" prop="corp_id">
|
||||||
|
<el-select
|
||||||
|
v-model="leaveUserForm.corp_id"
|
||||||
|
filterable
|
||||||
|
placeholder="请选择公司"
|
||||||
|
style="width: 100%"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in companyList"
|
||||||
|
:key="item.id"
|
||||||
|
:label="item.name"
|
||||||
|
:value="item.id"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="用户" prop="user_id">
|
||||||
|
<el-select
|
||||||
|
v-model="leaveUserForm.user_id"
|
||||||
|
multiple
|
||||||
|
filterable
|
||||||
|
placeholder="请选择要分配的用户"
|
||||||
|
style="width: 100%"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in companyUserList"
|
||||||
|
:key="item.id"
|
||||||
|
:label="item.name"
|
||||||
|
:value="item.id"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<div class="form-submit-row">
|
||||||
|
<el-button @click="leaveUserDialogVisible = false">取消</el-button>
|
||||||
|
<el-button type="primary" @click="handleLeaveUserSubmit">确定</el-button>
|
||||||
|
</div>
|
||||||
|
</el-form>
|
||||||
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, reactive, onMounted, watch } from 'vue'
|
import { ref, reactive, onMounted, watch, computed, nextTick } from 'vue'
|
||||||
import { ElImageViewer } from 'element-plus'
|
import { ElImageViewer, ElMessage } from 'element-plus'
|
||||||
import { manageService } from '@/api/adminApi'
|
import { manageService } from '@/api/adminApi'
|
||||||
import { useAuth } from '@/composables/useAuth'
|
import { useAuth } from '@/composables/useAuth'
|
||||||
import { systemService } from '@/api/systemApi'
|
import { systemService } from '@/api/systemApi'
|
||||||
import { formatMenuTitle } from '@/router/utils/utils'
|
import { formatMenuTitle } from '@/router/utils/utils'
|
||||||
import { UserService } from '@/api/usersApi'
|
import { UserService } from '@/api/usersApi'
|
||||||
const { hasAuth } = useAuth()
|
const { hasAuth } = useAuth()
|
||||||
|
const activeName = ref('1')
|
||||||
const selectValue = ref<string[]>([])
|
const selectValue = ref<string[]>([])
|
||||||
const keyword = ref<string>('')
|
const keyword = ref<string>('')
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
@@ -338,8 +392,18 @@
|
|||||||
const AddDialogVisible = ref(false)
|
const AddDialogVisible = ref(false)
|
||||||
const permissionDialog = ref(false)
|
const permissionDialog = ref(false)
|
||||||
const roleDialogVisible = ref(false)
|
const roleDialogVisible = ref(false)
|
||||||
|
const leaveUserDialogVisible = ref(false)
|
||||||
// 权限树数据(来自接口 getPermissionMenuList)
|
// 权限树数据(来自接口 getPermissionMenuList)
|
||||||
const permissionMenuList = ref<any[]>([])
|
const permissionMenuList = ref<any[]>([])
|
||||||
|
const permissionMenuListwork = ref<any[]>([])
|
||||||
|
const permissionMenuListcrm = ref<any[]>([])
|
||||||
|
// 精简后的多系统映射
|
||||||
|
const permissionMenuBySystem = reactive<Record<number, any[]>>({})
|
||||||
|
const processedMenuBySystem = reactive<Record<number, any[]>>({})
|
||||||
|
const treeRefs = reactive<Record<number, any>>({})
|
||||||
|
const setTreeRef = (systemId: number, el: any) => {
|
||||||
|
if (el) treeRefs[systemId] = el
|
||||||
|
}
|
||||||
const treeRef = ref()
|
const treeRef = ref()
|
||||||
const isExpandAll = ref(true)
|
const isExpandAll = ref(true)
|
||||||
const isSelectAll = ref(false)
|
const isSelectAll = ref(false)
|
||||||
@@ -373,13 +437,29 @@
|
|||||||
role_ids: '',
|
role_ids: '',
|
||||||
system_ids: ''
|
system_ids: ''
|
||||||
})
|
})
|
||||||
|
const leaveUserForm = reactive({
|
||||||
|
corp_id: '',
|
||||||
|
user_id: []
|
||||||
|
})
|
||||||
const userOptions = ref<any>()
|
const userOptions = ref<any>()
|
||||||
//系统
|
//系统
|
||||||
const systemsList = ref<any>()
|
const systemsList = ref<any>()
|
||||||
|
const companyList = ref<any>()
|
||||||
|
const companyUserList = ref<any>()
|
||||||
const getsystemsList = async () => {
|
const getsystemsList = async () => {
|
||||||
const response = await UserService.getsystemsList()
|
const response = await UserService.getsystemsList()
|
||||||
systemsList.value = response || []
|
systemsList.value = response || []
|
||||||
}
|
}
|
||||||
|
// 获取公司列表
|
||||||
|
const getCompanyList = async () => {
|
||||||
|
const response = await UserService.getCompanyList()
|
||||||
|
companyList.value = response || []
|
||||||
|
}
|
||||||
|
// 获取用户列表
|
||||||
|
const getCompanyUserList = async () => {
|
||||||
|
const response = await manageService.presetusers()
|
||||||
|
companyUserList.value = response || []
|
||||||
|
}
|
||||||
//角色下拉框
|
//角色下拉框
|
||||||
const roleOptions = ref<any>()
|
const roleOptions = ref<any>()
|
||||||
const getroleOptions = async () => {
|
const getroleOptions = async () => {
|
||||||
@@ -502,25 +582,50 @@
|
|||||||
permissionDialog.value = true
|
permissionDialog.value = true
|
||||||
userId.value = row.id
|
userId.value = row.id
|
||||||
try {
|
try {
|
||||||
const res = await systemService.getPermissionMenuList({ user_id: row.id })
|
await getsystemsList()
|
||||||
// 兼容不同返回结构(data/records/直接数组)
|
// 并行请求所选用户的各系统权限
|
||||||
const list = (res as any)?.data ?? (res as any)?.records ?? (res as any)
|
const sysIds = (systemsList.value || []).map((s: any) => s.id)
|
||||||
permissionMenuList.value = Array.isArray(list) ? list : []
|
const results = await Promise.all(
|
||||||
// 根据接口返回的 selected 字段设置默认选中
|
sysIds.map((id: number) =>
|
||||||
|
systemService.getPermissionMenuList({ user_id: row.id, system_id: id })
|
||||||
|
)
|
||||||
|
)
|
||||||
|
sysIds.forEach((id: number, idx: number) => {
|
||||||
|
const raw = results[idx] as any
|
||||||
|
const list = raw?.data ?? raw?.records ?? raw
|
||||||
|
permissionMenuBySystem[id] = Array.isArray(list) ? list : []
|
||||||
|
processedMenuBySystem[id] = buildProcessedMenu(permissionMenuBySystem[id])
|
||||||
|
})
|
||||||
|
// 兼容旧变量,避免其它逻辑引用报错
|
||||||
|
permissionMenuList.value = permissionMenuBySystem[1] || []
|
||||||
|
permissionMenuListwork.value = permissionMenuBySystem[2] || []
|
||||||
|
permissionMenuListcrm.value = permissionMenuBySystem[3] || []
|
||||||
|
// 设置默认选中
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
const keys = buildDefaultCheckedKeys(permissionMenuList.value)
|
sysIds.forEach((id: number) => {
|
||||||
treeRef.value?.setCheckedKeys(keys)
|
const keys = buildDefaultCheckedKeys(permissionMenuBySystem[id] || [])
|
||||||
handleTreeCheck()
|
treeRefs[id]?.setCheckedKeys?.(keys)
|
||||||
|
handleTreeCheck(id)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
;(systemsList.value || []).forEach((s: any) => {
|
||||||
|
permissionMenuBySystem[s.id] = []
|
||||||
|
processedMenuBySystem[s.id] = []
|
||||||
|
})
|
||||||
permissionMenuList.value = []
|
permissionMenuList.value = []
|
||||||
|
permissionMenuListwork.value = []
|
||||||
|
permissionMenuListcrm.value = []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 构建默认选中的 key 列表(与 node-key="id" 一致)
|
// 构建默认选中的 key 列表(与 node-key="id" 一致)
|
||||||
const buildDefaultCheckedKeys = (source: any[]): Array<string | number> => {
|
const buildDefaultCheckedKeys = (source: any[]): Array<string | number> => {
|
||||||
const keys: Array<string | number> = []
|
const keys: Array<string | number> = []
|
||||||
const walk = (node: any) => {
|
const walk = (node: any) => {
|
||||||
if (node?.meta?.selected) {
|
const hasChildren = Array.isArray(node?.children) && node.children.length > 0
|
||||||
|
const hasAuths = Array.isArray(node?.meta?.authList) && node.meta.authList.length > 0
|
||||||
|
// 仅当没有子节点且没有权限子项时,才勾选父节点,避免级联误选
|
||||||
|
if (node?.meta?.selected && !hasChildren && !hasAuths) {
|
||||||
keys.push(node.id)
|
keys.push(node.id)
|
||||||
}
|
}
|
||||||
if (Array.isArray(node?.meta?.authList)) {
|
if (Array.isArray(node?.meta?.authList)) {
|
||||||
@@ -530,7 +635,7 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (Array.isArray(node?.children)) node.children.forEach(walk)
|
if (hasChildren) node.children.forEach(walk)
|
||||||
}
|
}
|
||||||
source.forEach(walk)
|
source.forEach(walk)
|
||||||
return keys
|
return keys
|
||||||
@@ -568,11 +673,29 @@
|
|||||||
const source = permissionMenuList.value || []
|
const source = permissionMenuList.value || []
|
||||||
return source.map(processNode)
|
return source.map(processNode)
|
||||||
})
|
})
|
||||||
|
|
||||||
const defaultProps = {
|
const defaultProps = {
|
||||||
children: 'children',
|
children: 'children',
|
||||||
label: (data: any) => formatMenuTitle(data.meta?.title) || ''
|
label: (data: any) => formatMenuTitle(data.meta?.title) || ''
|
||||||
}
|
}
|
||||||
|
// 通用:处理节点,展开权限为子节点
|
||||||
|
const processNode = (node: any) => {
|
||||||
|
const processed: any = { ...node, id: node.id }
|
||||||
|
if (node.meta && node.meta.authList && node.meta.authList.length) {
|
||||||
|
const authNodes = node.meta.authList.map((auth: any) => ({
|
||||||
|
id: `${node.id}__auth__${auth.authMark}`,
|
||||||
|
name: `${node.name}_${auth.authMark}`,
|
||||||
|
label: auth.title,
|
||||||
|
auth_mark: auth.authMark,
|
||||||
|
auth_id: auth.id,
|
||||||
|
isAuth: true,
|
||||||
|
checked: auth.selected || false
|
||||||
|
}))
|
||||||
|
processed.children = processed.children ? [...processed.children, ...authNodes] : authNodes
|
||||||
|
}
|
||||||
|
if (processed.children) processed.children = processed.children.map(processNode)
|
||||||
|
return processed
|
||||||
|
}
|
||||||
|
const buildProcessedMenu = (source: any[]) => (source || []).map(processNode)
|
||||||
const toggleExpandAll = () => {
|
const toggleExpandAll = () => {
|
||||||
const tree = treeRef.value
|
const tree = treeRef.value
|
||||||
if (!tree) return
|
if (!tree) return
|
||||||
@@ -616,47 +739,36 @@
|
|||||||
traverse(nodes)
|
traverse(nodes)
|
||||||
return keys
|
return keys
|
||||||
}
|
}
|
||||||
const handleTreeCheck = () => {
|
const handleTreeCheck = (systemId?: number) => {
|
||||||
const tree = treeRef.value
|
const sysId = systemId ?? Number(activeName.value)
|
||||||
|
const tree = treeRefs[sysId] || treeRef.value
|
||||||
if (!tree) return
|
if (!tree) return
|
||||||
|
const checkedKeys = tree.getCheckedKeys?.() || []
|
||||||
// 使用树组件的getCheckedKeys方法获取选中的节点
|
const allKeys = getAllNodeKeys(processedMenuBySystem[sysId] || [])
|
||||||
const checkedKeys = tree.getCheckedKeys()
|
|
||||||
const allKeys = getAllNodeKeys(processedMenuList.value)
|
|
||||||
|
|
||||||
// 判断是否全选:选中的节点数量等于总节点数量
|
|
||||||
isSelectAll.value = checkedKeys.length === allKeys.length && allKeys.length > 0
|
isSelectAll.value = checkedKeys.length === allKeys.length && allKeys.length > 0
|
||||||
}
|
}
|
||||||
const getSelectedIds = () => {
|
const getSelectedIdsBySystem = (systemId: number) => {
|
||||||
const tree = treeRef.value
|
const tree = treeRefs[systemId]
|
||||||
if (!tree) return { menuIds: [], authIds: [] }
|
if (!tree) return [] as (string | number)[]
|
||||||
|
|
||||||
const checkedNodes = tree.getCheckedNodes?.(false) || []
|
const checkedNodes = tree.getCheckedNodes?.(false) || []
|
||||||
const halfCheckedNodes = tree.getHalfCheckedNodes?.() || []
|
const halfCheckedNodes = tree.getHalfCheckedNodes?.() || []
|
||||||
const allNodes = [...checkedNodes, ...halfCheckedNodes]
|
const allNodes = [...checkedNodes, ...halfCheckedNodes]
|
||||||
|
|
||||||
const menuIds = Array.from(
|
const menuIds = Array.from(
|
||||||
new Set(
|
new Set(allNodes.filter((n: any) => !n.isAuth && n.id != null).map((n: any) => n.id))
|
||||||
allNodes
|
|
||||||
.filter((n: any) => !n.isAuth && n.id !== undefined && n.id !== null)
|
|
||||||
.map((n: any) => n.id)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
const authIds = Array.from(
|
const authIds = Array.from(
|
||||||
new Set(
|
new Set(
|
||||||
checkedNodes.filter((n: any) => n.isAuth && n.auth_id != null).map((n: any) => n.auth_id)
|
checkedNodes.filter((n: any) => n.isAuth && n.auth_id != null).map((n: any) => n.auth_id)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
return Array.from(new Set([...(menuIds as any[]), ...(authIds as any[])]))
|
||||||
const ids = Array.from(new Set([...(menuIds as any[]), ...(authIds as any[])]))
|
|
||||||
return { menuIds, authIds, ids }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const savePermission = async () => {
|
const savePermission = async () => {
|
||||||
const { ids } = getSelectedIds()
|
const sysIds = (systemsList.value || []).map((s: any) => s.id)
|
||||||
|
const idall = Array.from(new Set(sysIds.flatMap((id: number) => getSelectedIdsBySystem(id))))
|
||||||
const res = await manageService.userMenuAuth({
|
const res = await manageService.userMenuAuth({
|
||||||
user_id: userId.value,
|
user_id: userId.value,
|
||||||
resources: ids
|
resources: idall
|
||||||
})
|
})
|
||||||
ElMessage.success(res?.message || '权限保存成功')
|
ElMessage.success(res?.message || '权限保存成功')
|
||||||
permissionDialog.value = false
|
permissionDialog.value = false
|
||||||
@@ -714,6 +826,42 @@
|
|||||||
showImageViewer.value = true
|
showImageViewer.value = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//离职客户分配
|
||||||
|
const leaveUserfn = () => {
|
||||||
|
getCompanyList()
|
||||||
|
getCompanyUserList()
|
||||||
|
leaveUserDialogVisible.value = true
|
||||||
|
leaveUserForm.corp_id = ''
|
||||||
|
leaveUserForm.user_id = []
|
||||||
|
companyUserList.value = []
|
||||||
|
}
|
||||||
|
// 提交离职客户分配
|
||||||
|
const handleLeaveUserSubmit = async () => {
|
||||||
|
if (!leaveUserForm.corp_id) {
|
||||||
|
ElMessage.warning('请选择公司')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!leaveUserForm.user_id || leaveUserForm.user_id.length === 0) {
|
||||||
|
ElMessage.warning('请选择用户')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 将 user_id 数组转换为逗号分隔的字符串
|
||||||
|
const submitData = {
|
||||||
|
...leaveUserForm,
|
||||||
|
user_id: leaveUserForm.user_id.join(',')
|
||||||
|
}
|
||||||
|
|
||||||
|
// 这里调用离职客户分配的API
|
||||||
|
const res = await UserService.leaveUser(submitData)
|
||||||
|
ElMessage.success(res?.message || '离职客户分配成功')
|
||||||
|
leaveUserDialogVisible.value = false
|
||||||
|
gettableList()
|
||||||
|
} catch (error) {
|
||||||
|
console.error('离职客户分配失败:', error)
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|||||||
@@ -179,6 +179,41 @@
|
|||||||
<el-dialog v-model="detailDialogVisible" title="详情">
|
<el-dialog v-model="detailDialogVisible" title="详情">
|
||||||
<div v-if="detailRow" v-html="detailRow.desc_collect" class="detils-content"></div>
|
<div v-if="detailRow" v-html="detailRow.desc_collect" class="detils-content"></div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
<el-dialog v-model="reportDialogVisible" title="标记无效" width="600px">
|
||||||
|
<el-form :model="reportForm" label-width="80px">
|
||||||
|
<el-form-item label="描述">
|
||||||
|
<el-input
|
||||||
|
v-model="reportForm.desc"
|
||||||
|
type="textarea"
|
||||||
|
:rows="4"
|
||||||
|
placeholder="请输入无效原因或说明"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="附件">
|
||||||
|
<el-upload
|
||||||
|
v-model:file-list="reportFileList"
|
||||||
|
:headers="uploadHeaders"
|
||||||
|
:action="reportUploadAction"
|
||||||
|
multiple
|
||||||
|
:limit="9"
|
||||||
|
:on-success="handleReportUploadSuccess"
|
||||||
|
:on-exceed="handleReportExceed"
|
||||||
|
:on-remove="removeReportFile"
|
||||||
|
>
|
||||||
|
<el-button type="primary">上传附件</el-button>
|
||||||
|
<!-- <template #tip>
|
||||||
|
<div class="el-upload__tip">支持图片、视频或文件</div>
|
||||||
|
</template> -->
|
||||||
|
</el-upload>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<div class="dialog-footer">
|
||||||
|
<el-button @click="reportDialogVisible = false">取消</el-button>
|
||||||
|
<el-button type="primary" @click="submitReport">确定</el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
@@ -186,6 +221,7 @@
|
|||||||
import { Plus } from '@element-plus/icons-vue'
|
import { Plus } from '@element-plus/icons-vue'
|
||||||
import { CrmService } from '@/api/crmApi'
|
import { CrmService } from '@/api/crmApi'
|
||||||
import { useAuth } from '@/composables/useAuth'
|
import { useAuth } from '@/composables/useAuth'
|
||||||
|
import { useUploadHeaders } from '@/composables/useUploadHeaders'
|
||||||
const { hasAuth } = useAuth()
|
const { hasAuth } = useAuth()
|
||||||
const searchValue = ref('')
|
const searchValue = ref('')
|
||||||
const selectValue = ref('')
|
const selectValue = ref('')
|
||||||
@@ -195,6 +231,11 @@
|
|||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const detailDialogVisible = ref(false)
|
const detailDialogVisible = ref(false)
|
||||||
const detailRow = ref<any>(null)
|
const detailRow = ref<any>(null)
|
||||||
|
const reportDialogVisible = ref(false)
|
||||||
|
const reportForm = reactive({ id: '', desc: '' })
|
||||||
|
const reportFileList = ref<any[]>([])
|
||||||
|
const { uploadHeaders } = useUploadHeaders()
|
||||||
|
const reportUploadAction = `${import.meta.env.VITE_API_URL}/ticket/upload`
|
||||||
const pagination = reactive({
|
const pagination = reactive({
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
@@ -335,19 +376,32 @@
|
|||||||
}
|
}
|
||||||
// 标记无效
|
// 标记无效
|
||||||
const reportfn = (row: any) => {
|
const reportfn = (row: any) => {
|
||||||
ElMessageBox.confirm('确定要标记无效吗?', '提示', {
|
reportForm.id = row.id
|
||||||
confirmButtonText: '确定',
|
reportForm.desc = ''
|
||||||
cancelButtonText: '取消',
|
reportFileList.value = []
|
||||||
type: 'warning'
|
reportDialogVisible.value = true
|
||||||
|
}
|
||||||
|
const handleReportUploadSuccess = (_response: any, _file: any, fileList: any[]) => {
|
||||||
|
reportFileList.value = fileList
|
||||||
|
}
|
||||||
|
const handleReportExceed = () => {
|
||||||
|
ElMessage.warning('最多可上传 9 个附件')
|
||||||
|
}
|
||||||
|
const removeReportFile = (_file: any, fileList: any[]) => {
|
||||||
|
reportFileList.value = fileList
|
||||||
|
}
|
||||||
|
const submitReport = async () => {
|
||||||
|
const attachments = reportFileList.value
|
||||||
|
.map((f: any) => f?.response?.data?.file_name)
|
||||||
|
.filter(Boolean)
|
||||||
|
const res = await CrmService.customerReport({
|
||||||
|
id: reportForm.id,
|
||||||
|
remark: reportForm.desc,
|
||||||
|
img: attachments
|
||||||
})
|
})
|
||||||
.then(async () => {
|
ElMessage.success(res?.message || '提交成功!')
|
||||||
const res = await CrmService.customerReport({ id: row.id })
|
reportDialogVisible.value = false
|
||||||
ElMessage.success(res?.message || '提交成功!')
|
gettableList()
|
||||||
gettableList()
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
// 用户点击了取消
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
function processImages(html: string) {
|
function processImages(html: string) {
|
||||||
const parser = new DOMParser()
|
const parser = new DOMParser()
|
||||||
|
|||||||
Reference in New Issue
Block a user