修改测试bug,优化页面

This commit is contained in:
guanj
2026-01-07 13:14:26 +08:00
parent 7a81c008c3
commit 02a95c1dcd
11 changed files with 378 additions and 293 deletions

View File

@@ -18,7 +18,13 @@
<OverLimitDetails ref="OverLimitDetailsRef" /> <OverLimitDetails ref="OverLimitDetailsRef" />
<!-- 上传对话框 --> <!-- 上传对话框 -->
<el-dialog v-model="uploadDialogVisible" title="上传报告" append-to-body width="500px" @closed="handleDialogClosed"> <el-dialog
v-model="uploadDialogVisible"
title="上传报告"
append-to-body
width="500px"
@closed="handleDialogClosed"
>
<el-upload <el-upload
ref="uploadRef" ref="uploadRef"
class="upload-demo" class="upload-demo"
@@ -163,6 +169,15 @@ const tableStore: any = new TableStore({
} }
} }
}, },
{
title: '报告',
field: 'lineId',
minWidth: '120',
render: 'customTemplate',
customTemplate: (row: any) => {
return `<span style='cursor: pointer;text-decoration: underline;'>${row.lineId}</span>`
}
},
{ {
title: '操作', title: '操作',
minWidth: 80, minWidth: 80,
@@ -183,19 +198,19 @@ const tableStore: any = new TableStore({
} }
}, },
{ // {
name: 'productSetting', // name: 'productSetting',
title: '下载报告', // title: '下载报告',
type: 'primary', // type: 'primary',
icon: 'el-icon-EditPen', // icon: 'el-icon-EditPen',
render: 'basicButton', // render: 'basicButton',
click: row => { // click: row => {
downloadTheReport(row.lineId) // downloadTheReport(row.lineId)
}, // },
disabled: row => { // disabled: row => {
return row.reportFilePath == null || row.reportFilePath.length == 0 // return row.reportFilePath == null || row.reportFilePath.length == 0
} // }
}, // },
{ {
name: 'productSetting', name: 'productSetting',
title: '重新上传', title: '重新上传',
@@ -252,6 +267,8 @@ const cellClickEvent = ({ row, column }: any) => {
tableStore.table.params.searchBeginTime || prop.timeValue?.[0], tableStore.table.params.searchBeginTime || prop.timeValue?.[0],
tableStore.table.params.searchEndTime || prop.timeValue?.[1] tableStore.table.params.searchEndTime || prop.timeValue?.[1]
) )
}else if (column.field == 'lineId') {
downloadTheReport(row.lineId)
} }
} }

View File

@@ -300,7 +300,6 @@ const chooseNode = (value: string, data: any, node: any) => {
} }
const changeDevice = (val: any) => { const changeDevice = (val: any) => {
console.log('changeDevice', val)
let arr1: any = [] let arr1: any = []
//zlDeviceData //zlDeviceData
@@ -331,22 +330,30 @@ const changeDevice = (val: any) => {
arr2.map((item: any) => { arr2.map((item: any) => {
item.checked = false item.checked = false
}) })
treeRef1.value && treeRef1.value.setCurrentKey(arr1[0]?.id)
emit('changeDeviceType', activeName.value, arr1[0]) emit('changeDeviceType', activeName.value, arr1[0])
setTimeout(() => {
treeRef1.value?.setCurrentKey(arr1[0]?.id)
}, 100)
} }
if (val == '1') { if (val == '1') {
arr1.map((item: any) => { arr1.map((item: any) => {
item.checked = false item.checked = false
}) })
treeRef2.value && treeRef2.value.setCurrentKey(arr2[0]?.id)
emit('changeDeviceType', activeName.value, arr2[0]) emit('changeDeviceType', activeName.value, arr2[0])
setTimeout(() => {
treeRef2.value?.setCurrentKey(arr2[0]?.id)
}, 100)
} }
if (val == '2') { if (val == '2') {
arr3.map((item: any) => { arr3.map((item: any) => {
item.checked = false item.checked = false
}) })
treeRef3.value && treeRef3.value.setCurrentKey(arr3[0]?.id)
emit('changeDeviceType', activeName.value, arr3[0]) emit('changeDeviceType', activeName.value, arr3[0])
setTimeout(() => {
treeRef3.value?.setCurrentKey(arr3[0]?.id)
}, 100)
} }
} }
//治理 //治理

View File

@@ -11,10 +11,11 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, nextTick, defineEmits } from 'vue' import { ref, nextTick } from 'vue'
import Tree from '../device.vue' import Tree from '../device.vue'
import { getDeviceTree } from '@/api/cs-device-boot/csLedger' import { getDeviceTree } from '@/api/cs-device-boot/csLedger'
import { useConfig } from '@/stores/config' import { useConfig } from '@/stores/config'
import { throttle } from 'lodash'
defineOptions({ defineOptions({
name: 'govern/deviceTree' name: 'govern/deviceTree'
}) })
@@ -27,7 +28,7 @@ const props = withDefaults(
{ {
showCheckbox: false, showCheckbox: false,
defaultCheckedKeys: [], defaultCheckedKeys: [],
height:0 height: 0
} }
) )
const emit = defineEmits(['init', 'checkChange', 'deviceTypeChange']) const emit = defineEmits(['init', 'checkChange', 'deviceTypeChange'])
@@ -67,14 +68,15 @@ getDeviceTree().then(res => {
item.color = config.getColorVal('elementUiPrimary') item.color = config.getColorVal('elementUiPrimary')
item.color = '#e26257 !important' item.color = '#e26257 !important'
item.color = item.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important' item.color = item.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
// item.disabled =true
item.pName = '便携式设备'
if (item.type == 'device') { if (item.type == 'device') {
arr2.push(item) arr2.push(item)
} }
item.children.forEach((item2: any) => { item.children.forEach((item2: any) => {
item2.icon = 'el-icon-Platform' item2.icon = 'el-icon-Platform'
item2.color = item2.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important' item2.color = item2.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
item2.pName = '便携式设备'
// item2.children.forEach((item3: any) => { // item2.children.forEach((item3: any) => {
// item3.icon = 'el-icon-Platform' // item3.icon = 'el-icon-Platform'
// item3.color = config.getColorVal('elementUiPrimary') // item3.color = config.getColorVal('elementUiPrimary')
@@ -141,6 +143,22 @@ getDeviceTree().then(res => {
}, 500) }, 500)
}) })
}) })
throttle(
(data: any, checked: any, indeterminate: any) => {
emit('checkChange', {
data,
checked,
indeterminate
})
},
300,
{
leading: true, // 首次触发立即执行(可选,默认 true
trailing: false // 节流结束后是否执行最后一次(可选,默认 true根据需求调整
}
)
const handleCheckChange = (data: any, checked: any, indeterminate: any) => { const handleCheckChange = (data: any, checked: any, indeterminate: any) => {
emit('checkChange', { emit('checkChange', {
data, data,
@@ -148,4 +166,7 @@ const handleCheckChange = (data: any, checked: any, indeterminate: any) => {
indeterminate indeterminate
}) })
} }
defineExpose({
treRef
})
</script> </script>

View File

@@ -205,7 +205,7 @@ watch(filterText, val => {
} }
}) })
watch(process, val => { watch(process, val => {
if (val == '' || val == undefined) { if (val == '' || val == undefined) {
zlDevList.value = JSON.parse(JSON.stringify(zlDeviceData.value)) zlDevList.value = JSON.parse(JSON.stringify(zlDeviceData.value))
} else { } else {
zlDevList.value = filterProcess(JSON.parse(JSON.stringify(zlDeviceData.value))) zlDevList.value = filterProcess(JSON.parse(JSON.stringify(zlDeviceData.value)))
@@ -251,22 +251,28 @@ const changeDevice = (val: any) => {
arr2.map((item: any) => { arr2.map((item: any) => {
item.checked = false item.checked = false
}) })
treeRef1?.value && treeRef1.value.setCurrentKey(arr1[0]?.id)
emit('changePointType', activeName.value, arr1[0]) emit('changePointType', activeName.value, arr1[0])
setTimeout(() => {
treeRef1.value?.setCurrentKey(arr1[0]?.id)
}, 100)
} }
if (val == '1') { if (val == '1') {
arr1.map((item: any) => { arr1.map((item: any) => {
item.checked = false item.checked = false
}) })
treeRef2?.value && treeRef2.value.setCurrentKey(arr2[0]?.id)
emit('changePointType', activeName.value, arr2[0]) emit('changePointType', activeName.value, arr2[0])
setTimeout(() => {
treeRef2.value?.setCurrentKey(arr2[0]?.id)
}, 100)
} }
if (val == '2') { if (val == '2') {
arr3.map((item: any) => { arr3.map((item: any) => {
item.checked = false item.checked = false
}) })
treeRef3?.value && treeRef3.value.setCurrentKey(arr3[0]?.id)
emit('changePointType', activeName.value, arr3[0]) emit('changePointType', activeName.value, arr3[0])
setTimeout(() => {
treeRef3.value?.setCurrentKey(arr3[0]?.id)
}, 100)
} }
// if(activeName.value){ // if(activeName.value){
// emit('changePointType', activeName.value) // emit('changePointType', activeName.value)

View File

@@ -2,7 +2,7 @@
<template> <template>
<div class="realtrend" v-loading="loading"> <div class="realtrend" v-loading="loading">
<div class="select" v-if="!loading"> <div class="select" v-if="!loading">
<div class="mr10">谐波次数</div> <div class="mr10">次数</div>
<el-select v-model.trim="selectValue" style="width: 100px" @change="selectChange"> <el-select v-model.trim="selectValue" style="width: 100px" @change="selectChange">
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" /> <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
</el-select> </el-select>
@@ -292,7 +292,7 @@ const setRealTrendData = (val: any) => {
if (selectValue.value != '3') { if (selectValue.value != '3') {
if (selectValue.value == '2') { if (selectValue.value == '2') {
if (activeName.value == 2) { if (activeName.value == 2) {
if (numberPart % 2 !== 0) { if (numberPart % 2 !== 0 && numberPart < 17) {
tableData.value[key] = val[key] tableData.value[key] = val[key]
} }
} else { } else {
@@ -302,7 +302,7 @@ const setRealTrendData = (val: any) => {
} }
} else { } else {
if (activeName.value == 2) { if (activeName.value == 2) {
if (numberPart % 2 === 0) { if (numberPart % 2 === 0 && numberPart < 17) {
tableData.value[key] = val[key] tableData.value[key] = val[key]
} }
} else { } else {
@@ -312,7 +312,13 @@ const setRealTrendData = (val: any) => {
} }
} }
} else { } else {
tableData.value[key] = val[key] if (activeName.value == 2) {
if (numberPart < 17) {
tableData.value[key] = val[key]
}
} else {
tableData.value[key] = val[key]
}
} }
} }
} }

View File

@@ -1,212 +1,215 @@
<!-- 设备文件下载 --> <!-- 设备文件下载 -->
<template> <template>
<div :class="downLoading ? 'all_disabled' : ''"> <div :class="downLoading ? 'all_disabled' : ''">
<el-dialog v-model.trim="dialogVisible" title="文件信息" width="50%" @closed="handleClose"> <el-dialog v-model.trim="dialogVisible" title="文件信息" width="50%" @closed="handleClose">
<div v-loading="loading"> <div v-loading="loading">
<div class="download_progress" <div
v-if="mqttFileName.includes(fileNameInfoMation) && status != 0 && status != 100"> class="download_progress"
<div class="progress_left"> v-if="mqttFileName.includes(fileNameInfoMation) && status != 0 && status != 100"
正在下载 >
{{ <div class="progress_left">
// fileData?.prjDataPath 正在下载
// ? fileData?.prjDataPath.split('/')[fileData?.prjDataPath.split('/').length - 1] {{
// : '/' // fileData?.prjDataPath
mqttFileName // ? fileData?.prjDataPath.split('/')[fileData?.prjDataPath.split('/').length - 1]
}} // : '/'
</div> mqttFileName
<div class="progress_right"> }}
<el-progress :percentage="status" /> </div>
</div> <div class="progress_right">
</div> <el-progress :percentage="status" />
<el-descriptions title="" style="margin: 10px 0" :column="2" :border="true"> </div>
<el-descriptions-item label="文件名称"> </div>
{{ <el-descriptions title="" style="margin: 10px 0" :column="2" :border="true">
fileData?.prjDataPath <el-descriptions-item label="文件名称">
? fileData?.prjDataPath.split('/')[fileData?.prjDataPath.split('/').length - 1] {{
: '/' fileData?.prjDataPath
}} ? fileData?.prjDataPath.split('/')[fileData?.prjDataPath.split('/').length - 1]
</el-descriptions-item> : '/'
<el-descriptions-item label="文件大小"> }}
{{ fileData?.size ? fileData?.size + '字节' : '/' }} </el-descriptions-item>
</el-descriptions-item> <el-descriptions-item label="文件大小">
<el-descriptions-item label="文件时间"> {{ fileData?.size ? fileData?.size + '字节' : '/' }}
{{ fileData?.startTime ? fileData?.startTime : '/' }} </el-descriptions-item>
</el-descriptions-item> <el-descriptions-item label="文件时间">
<el-descriptions-item label="文件校验码"> {{ fileData?.startTime ? fileData?.startTime : '/' }}
{{ fileData?.fileCheck ? fileData?.fileCheck : '/' }} </el-descriptions-item>
</el-descriptions-item> <el-descriptions-item label="文件校验码">
</el-descriptions> {{ fileData?.fileCheck ? fileData?.fileCheck : '/' }}
</div> </el-descriptions-item>
</el-descriptions>
<template #footer> </div>
<div class="dialog-footer download_status">
<el-button @click="handleClose">取消</el-button> <template #footer>
<el-button type="primary" @click="handleDownLoad" :disabled="loading" :loading="downLoading"> <div class="dialog-footer download_status">
{{ downLoading ? '下载中...' : '下载' }} <el-button @click="handleClose">取消</el-button>
</el-button> <el-button type="primary" @click="handleDownLoad" :disabled="loading" :loading="downLoading">
</div> {{ downLoading ? '下载中...' : '下载' }}
</template> </el-button>
</el-dialog> </div>
</div> </template>
</template> </el-dialog>
<script lang="ts" setup> </div>
import { ref, onMounted, defineExpose, onUnmounted, defineEmits } from 'vue' </template>
import { <script lang="ts" setup>
getFileServiceFileOrDir, import { ref, onMounted, defineExpose, onUnmounted, defineEmits } from 'vue'
downLoadDeviceFile, import {
downLoadDeviceFilePath getFileServiceFileOrDir,
} from '@/api/cs-device-boot/fileService.ts' downLoadDeviceFile,
import { ElMessage } from 'element-plus' downLoadDeviceFilePath
import { useAdminInfo } from '@/stores/adminInfo' } from '@/api/cs-device-boot/fileService.ts'
import { downLoadFile } from '@/api/cs-system-boot/manage.ts' import { ElMessage } from 'element-plus'
const dialogVisible = ref(false) import { useAdminInfo } from '@/stores/adminInfo'
const loading = ref(false) import { downLoadFile } from '@/api/cs-system-boot/manage.ts'
const adminInfo = useAdminInfo() import { log } from 'console'
const downLoading = ref(false) const dialogVisible = ref(false)
const emit = defineEmits(['downLoadFile']) const loading = ref(false)
const handleClose = () => { const adminInfo = useAdminInfo()
status.value = 0 const downLoading = ref(false)
mqttFileName.value = '' const emit = defineEmits(['downLoadFile'])
downLoading.value = false const handleClose = () => {
dialogVisible.value = false status.value = 0
} mqttFileName.value = ''
//文件信息 downLoading.value = false
const fileData: any = ref({}) dialogVisible.value = false
//文件名称信息 }
const fileNameInfoMation = ref<any>('') //文件信息
const open = async (row: any, id: any) => { const fileData: any = ref({})
status.value = 0 //文件名称信息
fileData.value = {} const fileNameInfoMation = ref<any>('')
dialogVisible.value = true const open = async (row: any, id: any) => {
loading.value = true status.value = 0
const obj = { fileData.value = {}
nDid: id, dialogVisible.value = true
name: row.prjDataPath, loading.value = true
type: row.type const obj = {
} nDid: id,
await getFileServiceFileOrDir(obj).then((res: any) => { name: row.prjDataPath,
if (res.code == 'A0000') { type: row.type
if (res.data && res.data.length != 0) { }
fileData.value = res.data[0] await getFileServiceFileOrDir(obj).then((res: any) => {
fileData.value.nDid = id if (res.code == 'A0000') {
if (fileData.value && fileData.value.prjDataPath) { if (res.data && res.data.length != 0) {
fileNameInfoMation.value = fileData.value = res.data[0]
fileData.value.prjDataPath.split('/')[fileData.value.prjDataPath.split('/').length - 1] fileData.value.nDid = id
} else { if (fileData.value && fileData.value.prjDataPath) {
fileNameInfoMation.value = '/' fileNameInfoMation.value =
} fileData.value.prjDataPath.split('/')[fileData.value.prjDataPath.split('/').length - 1]
} } else {
loading.value = false fileNameInfoMation.value = '/'
} }
}) }
} loading.value = false
const handleDownLoad = () => { }
const obj = { })
nDid: fileData.value.nDid, }
name: fileData.value.prjDataPath, const handleDownLoad = () => {
size: fileData.value.size, const obj = {
fileCheck: fileData.value.fileCheck nDid: fileData.value.nDid,
} name: fileData.value.prjDataPath,
downLoading.value = true size: fileData.value.size,
downLoadDeviceFile(obj) fileCheck: fileData.value.fileCheck
.then((res: any) => { }
if (res.code == 'A0000') { downLoading.value = true
// downLoadFile(res.data).then((resp: any) => { downLoadDeviceFile(obj)
// if (resp.type != 'application/json') { .then((res: any) => {
// // 'application/vnd.ms-excel' if (res.code == 'A0000') {
// let blob = new Blob([resp], { type: resp.type }) // downLoadFile(res.data).then((resp: any) => {
// const url = window.URL.createObjectURL(blob) // if (resp.type != 'application/json') {
// const link = document.createElement('a') // // 'application/vnd.ms-excel'
// link.href = url // let blob = new Blob([resp], { type: resp.type })
// link.download = fileData.value?.prjDataPath // const url = window.URL.createObjectURL(blob)
// ? fileData.value?.prjDataPath.split('/')[fileData.value?.prjDataPath.split('/').length - 1] // const link = document.createElement('a')
// : '/' // link.href = url
// document.body.appendChild(link) // link.download = fileData.value?.prjDataPath
// downLoading.value = false // ? fileData.value?.prjDataPath.split('/')[fileData.value?.prjDataPath.split('/').length - 1]
// link.click() // : '/'
// status.value = 100 // document.body.appendChild(link)
// ElMessage.success('文件下载成功') // downLoading.value = false
// link.remove() // link.click()
// handleClose() // status.value = 100
// } else { // ElMessage.success('文件下载成功')
// if (resp.code == 'A0000') { // link.remove()
// window.open(res.data, '_blank') // handleClose()
// downLoading.value = false // } else {
// ElMessage.success(resp.message) // if (resp.code == 'A0000') {
// handleClose() // window.open(res.data, '_blank')
// } // downLoading.value = false
// } // ElMessage.success(resp.message)
// }) // handleClose()
} // }
}) // }
.catch(e => { // })
console.log(e, '0000000') }
if (e) { })
downLoading.value = false .catch(e => {
} console.log(e, '0000000')
}) if (e) {
} downLoading.value = false
onMounted(() => { }) }
onUnmounted(() => { }) })
const status = ref(0) }
const mqttFileName = ref('') onMounted(() => {})
const setStatus = (val: any) => { onUnmounted(() => {})
status.value = parseInt(Number((val.nowStep / val.allStep) * 100)) || 0 const status = ref(0)
const mqttFileName = ref('')
mqttFileName.value = val.fileName const setStatus = (val: any) => {
if (adminInfo.userIndex != val.userId) return status.value = parseInt(Number((val.nowStep / val.allStep) * 100)) || 0
downLoading.value = true
if (status.value == 100) { mqttFileName.value = val.fileName
downLoadDeviceFilePath({ nDid: fileData.value.nDid, name: fileData.value.prjDataPath }).then((ress: any) => { if (adminInfo.userIndex != val.userId) return
if (ress.code == 'A0000') { downLoading.value = true
downLoadFile(ress.data).then((resp: any) => { if (status.value == 100) {
if (resp.type != 'application/json') { downLoadDeviceFilePath({ nDid: fileData.value.nDid, name: fileData.value.prjDataPath }).then((ress: any) => {
// 'application/vnd.ms-excel' if (ress.code == 'A0000') {
let blob = new Blob([resp], { type: resp.type }) downLoadFile(ress.data).then((resp: any) => {
const url = window.URL.createObjectURL(blob) if (resp.type != 'application/json') {
const link = document.createElement('a') // 'application/vnd.ms-excel'
link.href = url let blob = new Blob([resp], { type: resp.type })
link.download = fileData.value?.prjDataPath const url = window.URL.createObjectURL(blob)
? fileData.value?.prjDataPath.split('/')[fileData.value?.prjDataPath.split('/').length - 1] const link = document.createElement('a')
: '/' link.href = url
document.body.appendChild(link) link.download = fileData.value?.prjDataPath
downLoading.value = false ? fileData.value?.prjDataPath.split('/')[fileData.value?.prjDataPath.split('/').length - 1]
link.click() : '/'
status.value = 100 document.body.appendChild(link)
ElMessage.success('文件下载成功') downLoading.value = false
link.remove() link.click()
handleClose() status.value = 100
} else { ElMessage.success('文件下载成功')
if (resp.code == 'A0000') { link.remove()
window.open(ress.data, '_blank') handleClose()
downLoading.value = false } else {
ElMessage.success(resp.message) if (resp.code == 'A0000') {
handleClose() window.open(ress.data, '_blank')
} downLoading.value = false
} ElMessage.success(resp.message)
}) handleClose()
} }
}) }
} })
} }
defineExpose({ open, setStatus }) })
</script> }
<style lang="scss" scoped> }
.download_progress { defineExpose({ open, setStatus })
display: flex; </script>
width: 100%; <style lang="scss" scoped>
margin: 10px 0; .download_progress {
align-items: center; display: flex;
justify-content: space-between; width: 100%;
margin: 10px 0;
.progress_left { align-items: center;
width: auto; justify-content: space-between;
}
.progress_left {
.progress_right { width: auto;
flex: 1; }
padding-left: 10px;
box-sizing: border-box; .progress_right {
} flex: 1;
} padding-left: 10px;
</style> box-sizing: border-box;
}
}
</style>

View File

@@ -40,6 +40,7 @@
<!-- 对话框为左右布局 --> <!-- 对话框为左右布局 -->
<el-dialog <el-dialog
v-model.trim="dialogVisible" v-model.trim="dialogVisible"
draggable
title="添加工程 / 设备" title="添加工程 / 设备"
class="cn-operate-dialog" class="cn-operate-dialog"
:close-on-click-modal="false" :close-on-click-modal="false"

View File

@@ -14,6 +14,9 @@ import Disposition from '@/views/govern/device/disposition/index.vue'
import OfficialUser from '@/views/govern/device/officialUser/index.vue' import OfficialUser from '@/views/govern/device/officialUser/index.vue'
import Tourist from '@/views/govern/device/tourist/index.vue' import Tourist from '@/views/govern/device/tourist/index.vue'
const activeName = ref('1') const activeName = ref('1')
defineOptions({
name: 'permission'
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
:deep(.el-tabs--border-card > .el-tabs__content) { :deep(.el-tabs--border-card > .el-tabs__content) {

View File

@@ -1,6 +1,7 @@
<template> <template>
<div class=" device-manage" :style="{ height: pageHeight.height }" v-loading="loading"> <div class="device-manage" :style="{ height: pageHeight.height }" v-loading="loading">
<DeviceTree <DeviceTree
ref="treeRef"
:showCheckbox="true" :showCheckbox="true"
:default-checked-keys="defaultCheckedKeys" :default-checked-keys="defaultCheckedKeys"
@checkChange="checkChange" @checkChange="checkChange"
@@ -25,13 +26,24 @@ import DeviceTree from '@/components/tree/govern/deviceTree.vue'
import { mainHeight } from '@/utils/layout' import { mainHeight } from '@/utils/layout'
import { getVisitorConfig, updateVisitorConfig } from '@/api/cs-device-boot/user' import { getVisitorConfig, updateVisitorConfig } from '@/api/cs-device-boot/user'
import { ref, onMounted } from 'vue' import { ref, onMounted } from 'vue'
import { ElMessage } from 'element-plus'
const pageHeight = mainHeight(60) const pageHeight = mainHeight(60)
const loading = ref(true) const loading = ref(true)
const defaultCheckedKeys: any = ref([]) const defaultCheckedKeys: any = ref([])
const tableData = ref([]) const tableData = ref([])
const treeRef = ref(null)
const ignoreCheckChange = ref(false)
const checkChange = (data: any) => { const checkChange = (data: any) => {
if (data.data.pName == '便携式设备') {
if (ignoreCheckChange.value) {
ignoreCheckChange.value = false // 清除标记,不影响后续正常触发
return
}
ignoreCheckChange.value = true
ElMessage.warning('便携式设备暂时无法分配给游客!')
return treeRef.value?.treRef?.treeRef2?.setCheckedKeys([])
}
if (data.data.level === 2) { if (data.data.level === 2) {
if (data.checked) { if (data.checked) {
defaultCheckedKeys.value.push(data.data.id) defaultCheckedKeys.value.push(data.data.id)
@@ -57,13 +69,13 @@ const updateVisitorConfigs = () => {
}) })
} }
const getVisitorConfigs = () => { const getVisitorConfigs = () => {
getVisitorConfig().then((res:any) => { getVisitorConfig().then((res: any) => {
if (res.code === 'A0000') { if (res.code === 'A0000') {
tableData.value = res.data tableData.value = res.data
loading.value = false loading.value = false
if (defaultCheckedKeys.value.length > 0) return if (defaultCheckedKeys.value.length > 0) return
defaultCheckedKeys.value = [] // 清空 defaultCheckedKeys.value = [] // 清空
res.data.forEach((item:any) => { res.data.forEach((item: any) => {
defaultCheckedKeys.value.push(item.deviceId) defaultCheckedKeys.value.push(item.deviceId)
}) })
} }

View File

@@ -13,32 +13,16 @@
<el-input v-model="form.name" placeholder="请输入组件名称"></el-input> <el-input v-model="form.name" placeholder="请输入组件名称"></el-input>
</el-form-item> </el-form-item>
<el-form-item class="top" label="父组件节点" prop="system"> <el-form-item class="top" label="父组件节点" prop="system">
<!-- <el-cascader <el-cascader
v-model="form.system" v-model="form.system"
:options="customDeptOption" :options="customDeptOption"
:props="props" :props="props"
placeholder="请选择父组件节点"
style="width: 100%"
/> -->
<el-select v-model="form.systemType" placeholder="请选择父组件节点">
<el-option
v-for="item in customDeptOption"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item class="top" label="组件绑定系统" prop="systemIds">
<el-select
v-model="form.systemIds"
multiple
collapse-tags collapse-tags
collapse-tags-tooltip collapse-tags-tooltip
placeholder="请选择组件绑定系统" clearable
> placeholder="请选择父组件节点"
<el-option v-for="item in systemList" :key="item.id" :label="item.name" :value="item.id" /> style="width: 100%"
</el-select> />
</el-form-item> </el-form-item>
<el-form-item label="组件图标" prop="icon"> <el-form-item label="组件图标" prop="icon">
<IconSelector v-model="form.icon" placeholder="请选择图标" /> <IconSelector v-model="form.icon" placeholder="请选择图标" />
@@ -58,7 +42,17 @@
<el-checkbox-button value="5"></el-checkbox-button> <el-checkbox-button value="5"></el-checkbox-button>
</el-checkbox-group> </el-checkbox-group>
</el-form-item> </el-form-item>
<el-form-item class="top" label="组件绑定系统" prop="systemIds">
<el-select
v-model="form.systemIds"
multiple
collapse-tags
collapse-tags-tooltip
placeholder="请选择组件绑定系统"
>
<el-option v-for="item in systemList" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
</el-form-item>
<el-form-item class="top" label="组件排序" prop="sort"> <el-form-item class="top" label="组件排序" prop="sort">
<el-input v-model.number="form.sort" placeholder="请输入组件排序"></el-input> <el-input v-model.number="form.sort" placeholder="请输入组件排序"></el-input>
</el-form-item> </el-form-item>
@@ -112,7 +106,7 @@ const form = ref<anyObj>({
systemIds: [], systemIds: [],
path: '' path: ''
}) })
const props = { label: 'name', value: 'id' } const props = { label: 'name', value: 'id', multiple: true }
const rules = { const rules = {
code: [{ required: true, message: '请输入组件标识', trigger: 'blur' }], code: [{ required: true, message: '请输入组件标识', trigger: 'blur' }],
name: [{ required: true, message: '请输输入组件名称', trigger: 'blur' }], name: [{ required: true, message: '请输输入组件名称', trigger: 'blur' }],
@@ -128,11 +122,11 @@ const systemList = dictData.getBasicData('System_Type')
onMounted(() => { onMounted(() => {
customDeptOption.value = dictData.getBasicData('Component_Type') customDeptOption.value = dictData.getBasicData('Component_Type')
// customDeptOption.value.forEach((item: any) => { customDeptOption.value.forEach((item: any) => {
// getFatherComponent({ systemType: item.id }).then(res => { getFatherComponent({ systemType: item.id }).then(res => {
// item.children = res.data.filter(item => item.name != '无') item.children = res.data.filter(item => item.name != '无')
// }) })
// }) })
}) })
const open = (text: string, data?: anyObj) => { const open = (text: string, data?: anyObj) => {
@@ -142,12 +136,14 @@ const open = (text: string, data?: anyObj) => {
if (data) { if (data) {
let Data = JSON.parse(JSON.stringify(data)) let Data = JSON.parse(JSON.stringify(data))
form.value = Data form.value = Data
form.value.system = [Data.systemType] form.value.system = [Data.systemType, Data.pid]
// form.value.timeKeys = Data.timeKeys.split(',').map(Number) // form.value.timeKeys = Data.timeKeys.split(',').map(Number)
form.value.timeKeys = Data.timeKeys || [] form.value.timeKeys = Data.timeKeys || []
} }
} }
const submit = () => { const submit = () => {
console.log('🚀 ~ submit ~ form.value:', form.value)
formRef.value.validate(async (valid: boolean) => { formRef.value.validate(async (valid: boolean) => {
if (valid) { if (valid) {
let url = '' let url = ''
@@ -172,8 +168,11 @@ const submit = () => {
if (title.value == '新增组件') { if (title.value == '新增组件') {
await componentAdd({ await componentAdd({
...form.value, ...form.value,
systemType: form.value.system
.map(subArr => (subArr.length > 1 ? subArr.at(-1) : null))
.filter(item => item !== null),
// systemType: form.value.system[0], // systemType: form.value.system[0],
pid: '', pid: form.value.system[1],
image: url image: url
}).then(res => { }).then(res => {
ElMessage.success('新增成功!') ElMessage.success('新增成功!')
@@ -184,7 +183,10 @@ const submit = () => {
await componentEdit({ await componentEdit({
...form.value, ...form.value,
// systemType: form.value.system[0], // systemType: form.value.system[0],
pid: '', systemType: form.value.system
.map(subArr => (subArr.length > 1 ? subArr.at(-1) : null))
.filter(item => item !== null),
pid: form.value.system[1],
image: url image: url
}).then(res => { }).then(res => {
ElMessage.success('修改成功!') ElMessage.success('修改成功!')

View File

@@ -1,11 +1,12 @@
<template> <template>
<div class="default-main"> <div class="default-main pd10">
<TableHeader :showSearch="false"> <div class="elButton">
<template v-slot:operation> <el-button type="primary" @click="addTree" icon="el-icon-Plus">新增树</el-button>
<!-- <el-button type="primary" @click="addTree" icon="el-icon-Plus">新增</el-button> --> <el-button type="primary" @click="add" icon="el-icon-Plus">新增组件</el-button>
<el-button type="primary" @click="add" icon="el-icon-Plus">新增组件</el-button> </div>
</template> <!-- <TableHeader :showSearch="false">
</TableHeader>
</TableHeader> -->
<!-- <Table <!-- <Table
ref="tableRef" ref="tableRef"
:tree-config="{ transform: true, parentField: 'uPid', rowField: 'uId' }" :tree-config="{ transform: true, parentField: 'uPid', rowField: 'uId' }"
@@ -13,14 +14,14 @@
/> --> /> -->
<el-tabs v-model="tableName" type="border-card" @tab-change="changeTab"> <el-tabs v-model="tableName" type="border-card" @tab-change="changeTab">
<el-tab-pane v-for="item in tableStore.table.data" :key="item.name" :label="item.name" :name="item.name"> <el-tab-pane v-for="item in tableStore.table.data" :key="item.name" :label="item.name" :name="item.name">
<el-tabs v-model="tableName1" tab-position="left" class="componentList"> <el-tabs v-model="tableName1" tab-position="left" class="componentList">
<el-tab-pane v-for="k in item?.children" :key="k.name" :label="k.name" :name="k.name"> <el-tab-pane v-for="k in item?.children" :key="k.name" :label="k.name" :name="k.name">
<template #label> <template #label>
<span class="custom-tabs-label"> <span class="custom-tabs-label">
<p>{{ k.name }}</p> <p>{{ k.name }}</p>
<!-- <el-icon><Edit /></el-icon> --> <!-- <el-icon><Edit /></el-icon> -->
<!-- <el-button <el-button
type="primary" type="primary"
icon="el-icon-Edit" icon="el-icon-Edit"
link link
@@ -33,13 +34,13 @@
link link
class="ml0" class="ml0"
@click.stop="del(k)" @click.stop="del(k)"
></el-button> --> ></el-button>
</span> </span>
</template> </template>
<div :style="height" style="overflow-y: auto; overflow-x: hidden"> <div :style="height" style="overflow-y: auto; overflow-x: hidden">
<el-row :gutter="10" class="pl5 pr5 pt5"> <el-row :gutter="10" class="pl5 pr5 pt5">
<el-col :span="6" v-for="component in k.children" :key="component.id" class="mb10"> <el-col :span="6" v-for="component in k.children" :key="component.id" class="mb10">
<el-card class="box-card" shadow="hover"> <el-card class="box-card" shadow="hover">
<div slot="header" class="clearfix"> <div slot="header" class="clearfix">
<span style="display: flex; align-items: center"> <span style="display: flex; align-items: center">
{{ component.name }} {{ component.name }}
@@ -104,7 +105,7 @@ defineOptions({
const addRef = ref() const addRef = ref()
const addFlag = ref(false) const addFlag = ref(false)
const tableRef = ref() const tableRef = ref()
const height = ref(mainHeight(140)) const height = ref(mainHeight(100))
const treeRef = ref() const treeRef = ref()
const tableName = ref('') const tableName = ref('')
const tableName1 = ref('') const tableName1 = ref('')
@@ -356,9 +357,15 @@ span {
min-width: 128px; min-width: 128px;
} }
} }
:deep(.componentList){ :deep(.componentList) {
.el-tabs__header{ .el-tabs__header {
height: calc(100vh - 250px)!important; height: calc(100vh - 210px) !important;
} }
} }
.elButton{
position: absolute;
top: 13px;
right: 10px;
z-index: 1;
}
</style> </style>