sdw
This commit is contained in:
parent
4bbf595d2b
commit
bf6b7f5fcb
@ -2,3 +2,5 @@ NODE_ENV = 'development'
|
||||
|
||||
VITE_APP_BASE_API = 'https://mini-chat.1024tool.vip/api'
|
||||
VITE_SERVE = "https://mini-chat.1024tool.vip/api/"
|
||||
|
||||
VITE_APP_BASE_API_img = "https://mini-chat.1024tool.vip/"
|
||||
|
||||
@ -125,13 +125,13 @@
|
||||
<el-dialog v-model="dialogLog" title="绑定小程序" width="1000px" align-center :before-close="handleClose" destroy-on-close>
|
||||
<div class="dialog-box">
|
||||
|
||||
<el-table :data="logList" style="width: 100%" max-height="500px" row-key="id"
|
||||
<el-table ref="appTableRef" :data="logList" style="width: 100%" max-height="500px" row-key="id"
|
||||
@selection-change="appSelectionChange">
|
||||
<template #empty>
|
||||
<span v-if="tableLoading">加载中...</span>
|
||||
<span v-if="!tableLoading">暂无数据</span>
|
||||
</template>
|
||||
<el-table-column type="selection" width="55" :reserve-selection="true" />
|
||||
<el-table-column type="selection" width="55" :reserve-selection="true" :selectable="isSelectable" />
|
||||
<el-table-column prop="avatar" label="头像" align="center">
|
||||
<template #default="scoped">
|
||||
<el-image style="width: 30px;display: block;margin: auto;border-radius: 4px;"
|
||||
@ -381,15 +381,46 @@ const logList = ref([])
|
||||
let robot_data = ''
|
||||
const tableLoading = ref(false)
|
||||
let appSelects = []
|
||||
const appTableRef = ref(null)
|
||||
|
||||
|
||||
const bandAppIds = ref([])
|
||||
|
||||
// 设置已绑定小程序的选中状态
|
||||
const setSelectedApps = () => {
|
||||
nextTick(() => {
|
||||
if (appTableRef.value && logList.value.length > 0) {
|
||||
logList.value.forEach(row => {
|
||||
if (bandAppIds.value.includes(row.id)) {
|
||||
appTableRef.value.toggleRowSelection(row, true)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const openLog = async () => {
|
||||
dialogLog.value = true
|
||||
appSelects = []
|
||||
tableLoading.value = true
|
||||
const res = await appList(logQuery)
|
||||
tableLoading.value = false
|
||||
logList.value = res.list
|
||||
total.value = res.total
|
||||
|
||||
// 只在第一次打开时获取已绑定的小程序列表
|
||||
if (bandAppIds.value.length === 0 || logQuery.page === 1) {
|
||||
const res2 = await appList({
|
||||
admin_id: robot_data.id,
|
||||
page: 1,
|
||||
page_size: 100
|
||||
})
|
||||
bandAppIds.value = res2.list.map(item => item.id)
|
||||
// 初始化 appSelects 包含已绑定的小程序
|
||||
appSelects = [...bandAppIds.value]
|
||||
}
|
||||
|
||||
// 默认选中已绑定的小程序
|
||||
setSelectedApps()
|
||||
}
|
||||
|
||||
const handleBindApp = (row) => {
|
||||
@ -397,11 +428,28 @@ const handleBindApp = (row) => {
|
||||
dialogLog.value = true
|
||||
logQuery.page = 1
|
||||
logQuery.page_size = 10
|
||||
// 重置已绑定列表和选中列表,因为切换了客服
|
||||
bandAppIds.value = []
|
||||
appSelects = []
|
||||
// 清空表格选中状态
|
||||
nextTick(() => {
|
||||
if (appTableRef.value) {
|
||||
appTableRef.value.clearSelection()
|
||||
}
|
||||
})
|
||||
openLog()
|
||||
}
|
||||
|
||||
const isSelectable = (row) => {
|
||||
// 如果小程序ID在已绑定列表中,则不可选择
|
||||
return !bandAppIds.value.includes(row.id)
|
||||
}
|
||||
|
||||
const appSelectionChange = (e) => {
|
||||
appSelects = e.map(item => item.id)
|
||||
// 获取当前选中的小程序ID
|
||||
const selectedIds = e.map(item => item.id)
|
||||
// 合并已绑定的小程序ID,确保已绑定的小程序始终在选中列表中
|
||||
appSelects = [...new Set([...bandAppIds.value, ...selectedIds])]
|
||||
}
|
||||
|
||||
const saveBind = (val) => {
|
||||
|
||||
@ -404,7 +404,7 @@ const submitRobot = async () => {
|
||||
}
|
||||
|
||||
|
||||
const handleDelete = (item, index) => {
|
||||
const handeleDelete = (item, index) => {
|
||||
ElMessageBox.confirm(
|
||||
'确认删除该小程序吗?',
|
||||
'提示',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user