联调设备文件
This commit is contained in:
@@ -15,7 +15,23 @@ export function getFileServiceFileOrDir(data) {
|
|||||||
method: 'POST'
|
method: 'POST'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
// 监测设备-目录信息询问
|
||||||
|
export function listDir(data) {
|
||||||
|
return createAxios({
|
||||||
|
url: `/zl-event-boot/file/listDir`,
|
||||||
|
method: 'POST',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 下载文件
|
||||||
|
export function downloadFileFromFrontr(data: any) {
|
||||||
|
return createAxios({
|
||||||
|
url: `/zl-event-boot/file/downloadFileFromFront`,
|
||||||
|
method: 'POST',
|
||||||
|
data: data,
|
||||||
|
responseType: 'blob'
|
||||||
|
})
|
||||||
|
}
|
||||||
//设备文件下载
|
//设备文件下载
|
||||||
export function downLoadDeviceFile(data) {
|
export function downLoadDeviceFile(data) {
|
||||||
return createAxios({
|
return createAxios({
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ export const portableDeviceRegister = (params: any) => {
|
|||||||
export const portableDeviceAccess = (data: any) => {
|
export const portableDeviceAccess = (data: any) => {
|
||||||
return createAxios({
|
return createAxios({
|
||||||
url: `/access-boot/device/wlAccess?nDid=${data.nDid}`,
|
url: `/access-boot/device/wlAccess?nDid=${data.nDid}`,
|
||||||
method: 'POST',
|
method: 'POST'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// 下载模版
|
// 下载模版
|
||||||
@@ -96,3 +96,10 @@ export function getExcelTemplate() {
|
|||||||
responseType: 'blob'
|
responseType: 'blob'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
// 查询工程信息列表
|
||||||
|
export function engineeringProject() {
|
||||||
|
return createAxios({
|
||||||
|
url: '/cs-device-boot/engineeringProjectRelation/list',
|
||||||
|
method: 'post'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,11 +1,19 @@
|
|||||||
<template>
|
<template>
|
||||||
<Tree ref="treRef" :width="width" :showPush="props.showPush" :data="tree" default-expand-all @changePointType="changePointType" @onAdd="onAdd"/>
|
<Tree
|
||||||
|
ref="treRef"
|
||||||
|
:width="width"
|
||||||
|
:showPush="props.showPush"
|
||||||
|
:data="tree"
|
||||||
|
default-expand-all
|
||||||
|
@changePointType="changePointType"
|
||||||
|
@onAdd="onAdd"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, nextTick, onMounted, defineProps } from 'vue'
|
import { ref, nextTick, onMounted, defineProps } from 'vue'
|
||||||
import Tree from '../index.vue'
|
import Tree from '../index.vue'
|
||||||
import { getLineTree,lineTree } from '@/api/cs-device-boot/csLedger'
|
import { getLineTree, lineTree } from '@/api/cs-device-boot/csLedger'
|
||||||
import { useConfig } from '@/stores/config'
|
import { useConfig } from '@/stores/config'
|
||||||
import { querySysExcel } from '@/api/harmonic-boot/luckyexcel'
|
import { querySysExcel } from '@/api/harmonic-boot/luckyexcel'
|
||||||
import { useDictData } from '@/stores/dictData'
|
import { useDictData } from '@/stores/dictData'
|
||||||
@@ -22,27 +30,26 @@ defineOptions({
|
|||||||
name: 'govern/deviceTree'
|
name: 'govern/deviceTree'
|
||||||
})
|
})
|
||||||
|
|
||||||
const emit = defineEmits(['init', 'checkChange', 'pointTypeChange', 'Policy','onAdd'])
|
const emit = defineEmits(['init', 'checkChange', 'pointTypeChange', 'Policy', 'onAdd'])
|
||||||
const config = useConfig()
|
const config = useConfig()
|
||||||
const tree = ref()
|
const tree = ref()
|
||||||
const dictData = useDictData()
|
const dictData = useDictData()
|
||||||
const treRef = ref()
|
const treRef = ref()
|
||||||
const width = ref('')
|
const width = ref('')
|
||||||
|
|
||||||
|
|
||||||
const info = (selectedNodeId?: string) => {
|
const info = (selectedNodeId?: string) => {
|
||||||
tree.value = []
|
tree.value = []
|
||||||
let arr1: any[] = []
|
let arr1: any[] = []
|
||||||
lineTree().then(res => {
|
lineTree().then(res => {
|
||||||
try {
|
try {
|
||||||
// 检查响应数据结构
|
// 检查响应数据结构
|
||||||
let rootData = null;
|
let rootData = null
|
||||||
if (Array.isArray(res.data)) {
|
if (Array.isArray(res.data)) {
|
||||||
// 旧的数据结构 - 数组
|
// 旧的数据结构 - 数组
|
||||||
rootData = res.data.find((item: any) => item.name == '监测设备');
|
rootData = res.data.find((item: any) => item.name == '监测设备')
|
||||||
} else if (res.data && res.data.name == '监测设备') {
|
} else if (res.data && res.data.name == '监测设备') {
|
||||||
// 新的数据结构 - 单个对象
|
// 新的数据结构 - 单个对象
|
||||||
rootData = res.data;
|
rootData = res.data
|
||||||
}
|
}
|
||||||
|
|
||||||
// 治理设备
|
// 治理设备
|
||||||
@@ -97,50 +104,51 @@ const info = (selectedNodeId?: string) => {
|
|||||||
tree.value = []
|
tree.value = []
|
||||||
}
|
}
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
|
|
||||||
if (arr1.length) {
|
if (arr1.length) {
|
||||||
// 安全检查 treRef 和 treeRef 是否存在
|
// 安全检查 treRef 和 treeRef 是否存在
|
||||||
console.log("🚀 ~ info ~ treRef.value && treRef.value.treeRef && treRef.value.treeRef.setCurrentKey:", treRef.value && treRef.value.treeRef1 && treRef.value.treeRef1.setCurrentKey)
|
console.log(
|
||||||
|
'🚀 ~ info ~ treRef.value && treRef.value.treeRef && treRef.value.treeRef.setCurrentKey:',
|
||||||
|
treRef.value && treRef.value.treeRef1 && treRef.value.treeRef1.setCurrentKey
|
||||||
|
)
|
||||||
|
|
||||||
if (treRef.value && treRef.value.treeRef && treRef.value.treeRef.setCurrentKey) {
|
if (treRef.value && treRef.value.treeRef && treRef.value.treeRef.setCurrentKey) {
|
||||||
// 如果传入了要选中的节点ID,则选中该节点,否则选中第一个节点
|
// 如果传入了要选中的节点ID,则选中该节点,否则选中第一个节点
|
||||||
console.log('selectedNodeId:', selectedNodeId);
|
console.log('selectedNodeId:', selectedNodeId)
|
||||||
if (selectedNodeId) {
|
if (selectedNodeId) {
|
||||||
treRef.value.treeRef.setCurrentKey(selectedNodeId);
|
treRef.value.treeRef.setCurrentKey(selectedNodeId)
|
||||||
// 查找对应的节点数据并触发事件
|
// 查找对应的节点数据并触发事件
|
||||||
let selectedNode = null;
|
let selectedNode = null
|
||||||
const findNode = (nodes: any[]) => {
|
const findNode = (nodes: any[]) => {
|
||||||
for (const node of nodes) {
|
for (const node of nodes) {
|
||||||
if (node.id === selectedNodeId) {
|
if (node.id === selectedNodeId) {
|
||||||
selectedNode = node;
|
selectedNode = node
|
||||||
return true;
|
return true
|
||||||
}
|
}
|
||||||
if (node.children && findNode(node.children)) {
|
if (node.children && findNode(node.children)) {
|
||||||
return true;
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false
|
||||||
};
|
}
|
||||||
|
|
||||||
findNode(tree.value);
|
findNode(tree.value)
|
||||||
|
|
||||||
if (selectedNode) {
|
if (selectedNode) {
|
||||||
emit('init', {
|
emit('init', {
|
||||||
level: selectedNode.level,
|
level: selectedNode.level,
|
||||||
...selectedNode
|
...selectedNode
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 初始化选中第一个节点
|
// 初始化选中第一个节点
|
||||||
treRef.value.treeRef.setCurrentKey(arr1[0].id);
|
treRef.value.treeRef.setCurrentKey(arr1[0].id)
|
||||||
emit('init', {
|
emit('init', {
|
||||||
level: 2,
|
level: 2,
|
||||||
...arr1[0]
|
...arr1[0]
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -149,7 +157,6 @@ const info = (selectedNodeId?: string) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const changePointType = (val: any, obj: any) => {
|
const changePointType = (val: any, obj: any) => {
|
||||||
emit('pointTypeChange', val, obj)
|
emit('pointTypeChange', val, obj)
|
||||||
}
|
}
|
||||||
@@ -158,7 +165,8 @@ const onAdd = () => {
|
|||||||
emit('onAdd')
|
emit('onAdd')
|
||||||
}
|
}
|
||||||
if (props.template) {
|
if (props.template) {
|
||||||
querySysExcel({ id: dictData.state.area[0]?.id })
|
// id: dictData.state.area[0]?.id
|
||||||
|
querySysExcel({})
|
||||||
.then((res: any) => {
|
.then((res: any) => {
|
||||||
emit('Policy', res.data)
|
emit('Policy', res.data)
|
||||||
info()
|
info()
|
||||||
|
|||||||
@@ -188,7 +188,8 @@ const changePointType = (val: any, obj: any) => {
|
|||||||
emit('pointTypeChange', val, obj)
|
emit('pointTypeChange', val, obj)
|
||||||
}
|
}
|
||||||
if (props.template) {
|
if (props.template) {
|
||||||
querySysExcel({ id: dictData.state.area[0]?.id })
|
// id: dictData.state.area[0]?.id
|
||||||
|
querySysExcel({})
|
||||||
.then((res: any) => {
|
.then((res: any) => {
|
||||||
emit('Policy', res.data)
|
emit('Policy', res.data)
|
||||||
info()
|
info()
|
||||||
|
|||||||
@@ -3,13 +3,7 @@
|
|||||||
<div style="transition: all 0.3s; overflow: hidden; height: 100%">
|
<div style="transition: all 0.3s; overflow: hidden; height: 100%">
|
||||||
<div class="cn-tree">
|
<div class="cn-tree">
|
||||||
<div style="display: flex; align-items: center" class="mb10">
|
<div style="display: flex; align-items: center" class="mb10">
|
||||||
<el-input
|
<el-input maxlength="32" v-model.trim="filterText" placeholder="请输入内容" clearable>
|
||||||
maxlength="32"
|
|
||||||
|
|
||||||
v-model.trim="filterText"
|
|
||||||
placeholder="请输入内容"
|
|
||||||
clearable
|
|
||||||
>
|
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
<Icon name="el-icon-Search" style="font-size: 16px" />
|
<Icon name="el-icon-Search" style="font-size: 16px" />
|
||||||
</template>
|
</template>
|
||||||
@@ -37,7 +31,7 @@
|
|||||||
:style="{ color: data.color }"
|
:style="{ color: data.color }"
|
||||||
v-if="data.icon"
|
v-if="data.icon"
|
||||||
/>
|
/>
|
||||||
<span style="margin-left: 5px;">{{ node.label }}</span>
|
<span style="margin-left: 5px">{{ node.label }}</span>
|
||||||
</div>
|
</div>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
@@ -157,7 +151,8 @@ const clickNode = (e: anyObj) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (props.template) {
|
if (props.template) {
|
||||||
querySysExcel({ id: dictData.state.area[0]?.id })
|
// id: dictData.state.area[0]?.id
|
||||||
|
querySysExcel({})
|
||||||
.then((res: any) => {
|
.then((res: any) => {
|
||||||
emit('Policy', res.data)
|
emit('Policy', res.data)
|
||||||
getTreeList()
|
getTreeList()
|
||||||
|
|||||||
103
src/utils/downloadFile.ts
Normal file
103
src/utils/downloadFile.ts
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
import { ElMessage, ElMessageBox, ElInput, ElSegmented } from 'element-plus'
|
||||||
|
export const downLoadFile = (name: string, key: string, res: any) => {
|
||||||
|
let blob = new Blob([res], {
|
||||||
|
type: getFileType(key)
|
||||||
|
})
|
||||||
|
const url = window.URL.createObjectURL(blob)
|
||||||
|
const link = document.createElement('a') // 创建a标签
|
||||||
|
link.href = url
|
||||||
|
link.download = name // 设置下载的文件名
|
||||||
|
document.body.appendChild(link)
|
||||||
|
link.click() //执行下载
|
||||||
|
document.body.removeChild(link)
|
||||||
|
ElMessage.success('下载成功')
|
||||||
|
}
|
||||||
|
|
||||||
|
const getFileType = (url: string) => {
|
||||||
|
const ext = url.split('.').pop()?.toLowerCase() || ''
|
||||||
|
const mimeMap: Record<string, string> = {
|
||||||
|
// Excel
|
||||||
|
xls: 'application/vnd.ms-excel',
|
||||||
|
xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||||
|
// CSV
|
||||||
|
csv: 'text/csv',
|
||||||
|
// Word
|
||||||
|
doc: 'application/msword',
|
||||||
|
docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||||
|
// PDF
|
||||||
|
pdf: 'application/pdf',
|
||||||
|
// PowerPoint
|
||||||
|
ppt: 'application/vnd.ms-powerpoint',
|
||||||
|
pptx: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
||||||
|
// 图片
|
||||||
|
png: 'image/png',
|
||||||
|
gif: 'image/gif',
|
||||||
|
jpeg: 'image/jpeg',
|
||||||
|
jpg: 'image/jpeg',
|
||||||
|
bmp: 'image/bmp',
|
||||||
|
ico: 'image/vnd.microsoft.icon',
|
||||||
|
tif: 'image/tiff',
|
||||||
|
tiff: 'image/tiff',
|
||||||
|
svg: 'image/svg+xml',
|
||||||
|
webp: 'image/webp',
|
||||||
|
// 音频
|
||||||
|
mp3: 'audio/mpeg',
|
||||||
|
aac: 'audio/aac',
|
||||||
|
mid: 'audio/midi',
|
||||||
|
midi: 'audio/midi',
|
||||||
|
oga: 'audio/ogg',
|
||||||
|
wav: 'audio/wav',
|
||||||
|
weba: 'audio/webm',
|
||||||
|
// 视频
|
||||||
|
avi: 'video/x-msvideo',
|
||||||
|
mpeg: 'video/mpeg',
|
||||||
|
ogv: 'video/ogg',
|
||||||
|
webm: 'video/webm',
|
||||||
|
'3gp': 'video/3gpp',
|
||||||
|
'3g2': 'video/3gpp2',
|
||||||
|
// 网页/代码
|
||||||
|
html: 'text/html',
|
||||||
|
css: 'text/css',
|
||||||
|
js: 'text/javascript',
|
||||||
|
mjs: 'text/javascript',
|
||||||
|
json: 'application/json',
|
||||||
|
jsonld: 'application/ld+json',
|
||||||
|
xhtml: 'application/xhtml+xml',
|
||||||
|
xml: 'application/xml',
|
||||||
|
xul: 'application/vnd.mozilla.xul+xml',
|
||||||
|
// 文档
|
||||||
|
abw: 'application/x-abiword',
|
||||||
|
odp: 'application/vnd.oasis.opendocument.presentation',
|
||||||
|
ods: 'application/vnd.oasis.opendocument.spreadsheet',
|
||||||
|
odt: 'application/vnd.oasis.opendocument.text',
|
||||||
|
rtf: 'application/rtf',
|
||||||
|
txt: 'text/plain',
|
||||||
|
vsd: 'application/vnd.visio',
|
||||||
|
// 字体
|
||||||
|
otf: 'font/otf',
|
||||||
|
ttf: 'font/ttf',
|
||||||
|
woff: 'font/woff',
|
||||||
|
woff2: 'font/woff2',
|
||||||
|
eot: 'application/vnd.ms-fontobject',
|
||||||
|
// 压缩/归档
|
||||||
|
arc: 'application/x-freearc',
|
||||||
|
bz: 'application/x-bzip',
|
||||||
|
bz2: 'application/x-bzip2',
|
||||||
|
rar: 'application/x-rar-compressed',
|
||||||
|
tar: 'application/x-tar',
|
||||||
|
zip: 'application/zip',
|
||||||
|
'7z': 'application/x-7z-compressed',
|
||||||
|
// 其他
|
||||||
|
bin: 'application/octet-stream',
|
||||||
|
csh: 'application/x-csh',
|
||||||
|
epub: 'application/epub+zip',
|
||||||
|
azw: 'application/vnd.amazon.ebook',
|
||||||
|
ics: 'text/calendar',
|
||||||
|
jar: 'application/java-archive',
|
||||||
|
mpkg: 'application/vnd.apple.installer+xml',
|
||||||
|
ogx: 'application/ogg',
|
||||||
|
sh: 'application/x-sh',
|
||||||
|
swf: 'application/x-shockwave-flash'
|
||||||
|
}
|
||||||
|
return mimeMap[ext] || ''
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="default-main main" :style="{ height: pageHeight.height }">
|
<div class="default-main main" :style="{ height: pageHeight.height }">
|
||||||
<div class="main_left">
|
<div class="main_left">
|
||||||
<DeviceTree @node-click="nodeClick" @init="nodeClick"></DeviceTree>
|
<DeviceTree @node-click="nodeClick" @deviceTypeChange="deviceTypeChange"></DeviceTree>
|
||||||
</div>
|
</div>
|
||||||
<div class="main_right" v-loading="loading">
|
<div class="main_right" v-loading="loading">
|
||||||
<div class="right_nav">
|
<div class="right_nav">
|
||||||
@@ -197,22 +197,25 @@
|
|||||||
import DeviceTree from '@/components/tree/govern/deviceTree.vue'
|
import DeviceTree from '@/components/tree/govern/deviceTree.vue'
|
||||||
import { mainHeight } from '@/utils/layout'
|
import { mainHeight } from '@/utils/layout'
|
||||||
import { ref, watch, onMounted, onBeforeUnmount, h, inject } from 'vue'
|
import { ref, watch, onMounted, onBeforeUnmount, h, inject } from 'vue'
|
||||||
import { ElMessage, ElMessageBox, ElInput } from 'element-plus'
|
import { ElMessage, ElMessageBox, ElInput, ElSegmented } from 'element-plus'
|
||||||
import {
|
import {
|
||||||
getFileServiceFileOrDir,
|
getFileServiceFileOrDir,
|
||||||
uploadDeviceFile,
|
uploadDeviceFile,
|
||||||
reStartDevice,
|
reStartDevice,
|
||||||
addDeviceDir,
|
addDeviceDir,
|
||||||
delDeviceDir
|
delDeviceDir,
|
||||||
} from '@/api/cs-device-boot/fileService.ts'
|
listDir,
|
||||||
|
downloadFileFromFrontr
|
||||||
|
} from '@/api/cs-device-boot/fileService'
|
||||||
import { defaultAttribute } from '@/components/table/defaultAttribute'
|
import { defaultAttribute } from '@/components/table/defaultAttribute'
|
||||||
import { Delete, Download, Upload, Plus, Refresh, Search } from '@element-plus/icons-vue'
|
import { Delete, Download, Upload, Plus, Refresh, Search } from '@element-plus/icons-vue'
|
||||||
import popup from './popup.vue'
|
import popup from './popup.vue'
|
||||||
import mqtt from 'mqtt'
|
import mqtt from 'mqtt'
|
||||||
import { useAdminInfo } from '@/stores/adminInfo'
|
import { useAdminInfo } from '@/stores/adminInfo'
|
||||||
import { passwordConfirm } from '@/api/user-boot/user'
|
import { passwordConfirm } from '@/api/user-boot/user'
|
||||||
|
import { downLoadFile } from '@/utils/downloadFile.ts'
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: 'govern/device/fileService'
|
name: 'govern/device/fileService/index'
|
||||||
})
|
})
|
||||||
const pageHeight = mainHeight(20)
|
const pageHeight = mainHeight(20)
|
||||||
const tableHeight = mainHeight(130)
|
const tableHeight = mainHeight(130)
|
||||||
@@ -220,31 +223,53 @@ const adminInfo = useAdminInfo()
|
|||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
//nDid
|
//nDid
|
||||||
const nDid = ref<string>('')
|
const nDid = ref<string>('')
|
||||||
|
const devId = ref<string>('')
|
||||||
//当前目录
|
//当前目录
|
||||||
const activePath = ref<string>('')
|
const activePath = ref<string>('')
|
||||||
//判断是否是根目录
|
//判断是否是根目录
|
||||||
const isRoot = ref<boolean>(true)
|
const isRoot = ref<boolean>(true)
|
||||||
//储存所有点击过的目录
|
//储存所有点击过的目录
|
||||||
const activePathList: any = ref([])
|
const activePathList: any = ref([])
|
||||||
|
const devConType = ref<string>('')
|
||||||
|
const deviceTypeChange = (val: any, obj: any) => {
|
||||||
|
nodeClick(obj)
|
||||||
|
}
|
||||||
const nodeClick = (e: any) => {
|
const nodeClick = (e: any) => {
|
||||||
if (e && (e.level == 2 || e.type == 'device')) {
|
if (e && (e.level == 2 || e.type == 'device')) {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
nDid.value = e.ndid
|
nDid.value = e.ndid
|
||||||
|
devId.value = e.id
|
||||||
dirList.value = []
|
dirList.value = []
|
||||||
activePathList.value = []
|
activePathList.value = []
|
||||||
activePath.value = '/'
|
activePath.value = '/'
|
||||||
getFileServiceFileOrDir({ nDid: nDid.value, name: activePath.value, type: 'dir' })
|
devConType.value = e.devConType
|
||||||
.then((resp: any) => {
|
if (devConType.value == 'CLD') {
|
||||||
if (resp.code == 'A0000') {
|
listDir({ devId: devId.value, filePath: activePath.value })
|
||||||
dirList.value = resp.data
|
.then((resp: any) => {
|
||||||
currentDirList.value = resp.data
|
if (resp.code == 'A0000') {
|
||||||
activePathList.value = [{ path: activePath.value }]
|
dirList.value = resp.data
|
||||||
|
currentDirList.value = resp.data
|
||||||
|
activePathList.value = [{ path: activePath.value }]
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(e => {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
})
|
||||||
})
|
} else {
|
||||||
.catch(e => {
|
getFileServiceFileOrDir({ nDid: nDid.value, name: activePath.value, type: 'dir' })
|
||||||
loading.value = false
|
.then((resp: any) => {
|
||||||
})
|
if (resp.code == 'A0000') {
|
||||||
|
dirList.value = resp.data
|
||||||
|
currentDirList.value = resp.data
|
||||||
|
activePathList.value = [{ path: activePath.value }]
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(e => {
|
||||||
|
loading.value = false
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//搜索文件或文件夹
|
//搜索文件或文件夹
|
||||||
@@ -360,21 +385,41 @@ const handleIntoDir = (row: any) => {
|
|||||||
if (activePathList.value.indexOf(obj.name) == -1) {
|
if (activePathList.value.indexOf(obj.name) == -1) {
|
||||||
activePathList.value.push({ path: obj.name })
|
activePathList.value.push({ path: obj.name })
|
||||||
}
|
}
|
||||||
getFileServiceFileOrDir(obj)
|
|
||||||
.then(res => {
|
if (devConType.value == 'CLD') {
|
||||||
dirList.value = res.data
|
listDir({ devId: devId.value, filePath: row.prjDataPath })
|
||||||
loading.value = false
|
.then((resp: any) => {
|
||||||
currentDirList.value = res.data
|
if (resp.code == 'A0000') {
|
||||||
activePathList.value.map((item: any, index: any) => {
|
dirList.value = resp.data
|
||||||
if (item.path.includes(activePath.value) && item.path.length > activePath.value.length) {
|
currentDirList.value = resp.data
|
||||||
activePathList.value.splice(index, 1)
|
activePathList.value.map((item: any, index: any) => {
|
||||||
|
if (item.path.includes(activePath.value) && item.path.length > activePath.value.length) {
|
||||||
|
activePathList.value.splice(index, 1)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
loading.value = false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
isRoot.value = false
|
.catch(e => {
|
||||||
})
|
loading.value = false
|
||||||
.catch(e => {
|
})
|
||||||
loading.value = false
|
} else {
|
||||||
})
|
getFileServiceFileOrDir(obj)
|
||||||
|
.then(res => {
|
||||||
|
dirList.value = res.data
|
||||||
|
loading.value = false
|
||||||
|
currentDirList.value = res.data
|
||||||
|
activePathList.value.map((item: any, index: any) => {
|
||||||
|
if (item.path.includes(activePath.value) && item.path.length > activePath.value.length) {
|
||||||
|
activePathList.value.splice(index, 1)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
isRoot.value = false
|
||||||
|
})
|
||||||
|
.catch(e => {
|
||||||
|
loading.value = false
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//处理导航栏路径
|
//处理导航栏路径
|
||||||
@@ -406,19 +451,38 @@ const handleIntoByPath = async (val: any) => {
|
|||||||
}
|
}
|
||||||
activePath.value = val.path
|
activePath.value = val.path
|
||||||
loading.value = true
|
loading.value = true
|
||||||
getFileServiceFileOrDir(obj)
|
if (devConType.value == 'CLD') {
|
||||||
.then(res => {
|
listDir({ devId: devId.value, filePath: val.path })
|
||||||
dirList.value = res.data
|
.then((resp: any) => {
|
||||||
activePathList.value.map((item: any, index: any) => {
|
if (resp.code == 'A0000') {
|
||||||
if (item.path.includes(activePath.value) && item.path.length > activePath.value.length) {
|
dirList.value = resp.data
|
||||||
activePathList.value.splice(index, 1)
|
|
||||||
|
activePathList.value.map((item: any, index: any) => {
|
||||||
|
if (item.path.includes(activePath.value) && item.path.length > activePath.value.length) {
|
||||||
|
activePathList.value.splice(index, 1)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
loading.value = false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
loading.value = false
|
.catch(e => {
|
||||||
})
|
loading.value = false
|
||||||
.catch(e => {
|
})
|
||||||
loading.value = false
|
} else {
|
||||||
})
|
getFileServiceFileOrDir(obj)
|
||||||
|
.then(res => {
|
||||||
|
dirList.value = res.data
|
||||||
|
activePathList.value.map((item: any, index: any) => {
|
||||||
|
if (item.path.includes(activePath.value) && item.path.length > activePath.value.length) {
|
||||||
|
activePathList.value.splice(index, 1)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
loading.value = false
|
||||||
|
})
|
||||||
|
.catch(e => {
|
||||||
|
loading.value = false
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const form = ref({
|
const form = ref({
|
||||||
path: ''
|
path: ''
|
||||||
@@ -437,26 +501,48 @@ const formRef = ref()
|
|||||||
//重新加载当前页面菜单
|
//重新加载当前页面菜单
|
||||||
const reloadCurrentMenu = (msg: string) => {
|
const reloadCurrentMenu = (msg: string) => {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
getFileServiceFileOrDir({ nDid: nDid.value, name: activePath.value, type: 'dir' })
|
|
||||||
.then((resp: any) => {
|
|
||||||
if (resp.code == 'A0000') {
|
|
||||||
loading.value = false
|
|
||||||
dirList.value = resp.data
|
|
||||||
currentDirList.value = resp.data
|
|
||||||
activePathList.value.map((item: any, index: any) => {
|
|
||||||
if (item.path.includes(activePath.value) && item.path.length > activePath.value.length) {
|
|
||||||
activePathList.value.splice(index, 1)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
loading.value = false
|
|
||||||
|
|
||||||
if (!msg) return
|
if (devConType.value == 'CLD') {
|
||||||
ElMessage({ message: msg, type: 'success', duration: 5000 })
|
listDir({ devId: devId.value, filePath: activePath.value })
|
||||||
}
|
.then((resp: any) => {
|
||||||
})
|
if (resp.code == 'A0000') {
|
||||||
.catch(e => {
|
dirList.value = resp.data
|
||||||
loading.value = false
|
currentDirList.value = resp.data
|
||||||
})
|
activePathList.value.map((item: any, index: any) => {
|
||||||
|
if (item.path.includes(activePath.value) && item.path.length > activePath.value.length) {
|
||||||
|
activePathList.value.splice(index, 1)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
loading.value = false
|
||||||
|
if (!msg) return
|
||||||
|
ElMessage({ message: msg, type: 'success', duration: 5000 })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(e => {
|
||||||
|
loading.value = false
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
getFileServiceFileOrDir({ nDid: nDid.value, name: activePath.value, type: 'dir' })
|
||||||
|
.then((resp: any) => {
|
||||||
|
if (resp.code == 'A0000') {
|
||||||
|
loading.value = false
|
||||||
|
dirList.value = resp.data
|
||||||
|
currentDirList.value = resp.data
|
||||||
|
activePathList.value.map((item: any, index: any) => {
|
||||||
|
if (item.path.includes(activePath.value) && item.path.length > activePath.value.length) {
|
||||||
|
activePathList.value.splice(index, 1)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
loading.value = false
|
||||||
|
|
||||||
|
if (!msg) return
|
||||||
|
ElMessage({ message: msg, type: 'success', duration: 5000 })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(e => {
|
||||||
|
loading.value = false
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//新建文件夹
|
//新建文件夹
|
||||||
const submitDeviceDir = () => {
|
const submitDeviceDir = () => {
|
||||||
@@ -526,11 +612,21 @@ const changeType = ref<any>('')
|
|||||||
//下载文件
|
//下载文件
|
||||||
const fileRef = ref()
|
const fileRef = ref()
|
||||||
const handleDownLoad = async (row: any) => {
|
const handleDownLoad = async (row: any) => {
|
||||||
;(await nDid.value) && fileRef.value && fileRef.value.open(row, nDid.value)
|
if (devConType.value == 'CLD') {
|
||||||
// fileName.value = row?.prjDataPath.split('/')[row?.prjDataPath.split('/').length - 1]
|
ElMessage.info('下载中,请稍等...')
|
||||||
// localStorage.setItem('fileName', fileName.value)
|
downloadFileFromFrontr({
|
||||||
changeType.value = 'download'
|
devId: devId.value,
|
||||||
localStorage.setItem('changeType', changeType.value)
|
filePath: row.prjDataPath
|
||||||
|
}).then(res => {
|
||||||
|
downLoadFile(row.name, row.name, res)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
;(await nDid.value) && fileRef.value && fileRef.value.open(row, nDid.value)
|
||||||
|
// fileName.value = row?.prjDataPath.split('/')[row?.prjDataPath.split('/').length - 1]
|
||||||
|
// localStorage.setItem('fileName', fileName.value)
|
||||||
|
changeType.value = 'download'
|
||||||
|
localStorage.setItem('changeType', changeType.value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//上传文件
|
//上传文件
|
||||||
const fileName = ref<any>('')
|
const fileName = ref<any>('')
|
||||||
|
|||||||
@@ -118,12 +118,15 @@ const open = (text: string, List: any, data?: anyObj, id?: string) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const submit = async () => {
|
const submit = async () => {
|
||||||
|
if (form.topoIds == '') {
|
||||||
|
return ElMessage.warning('请选择拓扑图!')
|
||||||
|
}
|
||||||
formRef.value.validate(async valid => {
|
formRef.value.validate(async valid => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
if (form.id) {
|
if (form.id) {
|
||||||
await updateProjects({ ...form, topoIds: form.topoIds == '' ? [] : [form.topoIds] })
|
await updateProjects({ ...form, topoIds: [form.topoIds] })
|
||||||
} else {
|
} else {
|
||||||
await addProject({ ...form, topoIds: form.topoIds == '' ? [] : [form.topoIds] })
|
await addProject({ ...form, topoIds: [form.topoIds] })
|
||||||
}
|
}
|
||||||
ElMessage.success('保存成功')
|
ElMessage.success('保存成功')
|
||||||
tableStore.index()
|
tableStore.index()
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
:preview-teleported="true"
|
:preview-teleported="true"
|
||||||
v-if="row.topologyInfo"
|
v-if="row.topologyInfo"
|
||||||
:preview-src-list="[row.topologyImageUrl]"
|
:preview-src-list="[row.topologyImageUrl]"
|
||||||
:src="getUrl(row) ? row.topologyImageUrl : ''"
|
:src="row.topologyImageUrl"
|
||||||
></el-image>
|
></el-image>
|
||||||
<span v-else>/</span>
|
<span v-else>/</span>
|
||||||
</template>
|
</template>
|
||||||
@@ -199,6 +199,11 @@ const setTableRow = () => {
|
|||||||
let list = tableStore.table.data.filter((item: any) => item.engineeringId == engineeringId.value)
|
let list = tableStore.table.data.filter((item: any) => item.engineeringId == engineeringId.value)
|
||||||
tableRef.value.getRef().setCurrentRow(list[0] ?? {})
|
tableRef.value.getRef().setCurrentRow(list[0] ?? {})
|
||||||
itemList.value = list?.[0]?.projectInfoList ?? []
|
itemList.value = list?.[0]?.projectInfoList ?? []
|
||||||
|
if (itemList.value.length > 0) {
|
||||||
|
itemList.value.forEach((item: any) => {
|
||||||
|
item.topologyImageUrl = getUrl(item)
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 修改模版
|
// 修改模版
|
||||||
const itemModification = (row: any) => {
|
const itemModification = (row: any) => {
|
||||||
@@ -223,6 +228,11 @@ const add = () => {
|
|||||||
const currentChange = (data: any) => {
|
const currentChange = (data: any) => {
|
||||||
engineeringId.value = data.row.engineeringId
|
engineeringId.value = data.row.engineeringId
|
||||||
itemList.value = data.row.projectInfoList
|
itemList.value = data.row.projectInfoList
|
||||||
|
if (itemList.value.length > 0) {
|
||||||
|
itemList.value.forEach((item: any) => {
|
||||||
|
item.topologyImageUrl = getUrl(item)
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 保存模版
|
// 保存模版
|
||||||
const save = () => {
|
const save = () => {
|
||||||
@@ -238,14 +248,11 @@ const save = () => {
|
|||||||
const imgList = ref([])
|
const imgList = ref([])
|
||||||
// 获取拓扑图
|
// 获取拓扑图
|
||||||
const getUrl = async (row: any) => {
|
const getUrl = async (row: any) => {
|
||||||
if (!row.topologyInfo || row.topologyInfo === '/') return false
|
if (!row.topologyInfo || row.topologyInfo === '/') return ''
|
||||||
try {
|
|
||||||
const res = await getFileUrl({ filePath: row.topologyInfo })
|
const res = await getFileUrl({ filePath: row.topologyInfo })
|
||||||
row.topologyImageUrl = res.data
|
row.topologyImageUrl = res.data
|
||||||
return true
|
return res.data
|
||||||
} catch (error) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
|||||||
@@ -151,7 +151,7 @@
|
|||||||
<el-form-item label="设备型号:" prop="devModel" class="top">
|
<el-form-item label="设备型号:" prop="devModel" class="top">
|
||||||
<el-select v-model.trim="form.devModel" filterable placeholder="请选择" clearable>
|
<el-select v-model.trim="form.devModel" filterable placeholder="请选择" clearable>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in formDevModelOptionsFilter "
|
v-for="item in formDevModelOptionsFilter"
|
||||||
:key="item.value"
|
:key="item.value"
|
||||||
:label="item.label"
|
:label="item.label"
|
||||||
:value="item.value"
|
:value="item.value"
|
||||||
@@ -164,6 +164,15 @@
|
|||||||
<el-option label="CLD" value="CLD"></el-option>
|
<el-option label="CLD" value="CLD"></el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="关联项目:" class="top">
|
||||||
|
<el-cascader
|
||||||
|
v-model.trim="form.association"
|
||||||
|
filterable
|
||||||
|
:options="engineeringList"
|
||||||
|
:props="props"
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item label="排序:" class="top" prop="sort">
|
<el-form-item label="排序:" class="top" prop="sort">
|
||||||
<el-input maxlength="32" show-word-limit-number v-model.trim="form.sort" :min="0" />
|
<el-input maxlength="32" show-word-limit-number v-model.trim="form.sort" :min="0" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -198,7 +207,7 @@ import TableHeader from '@/components/table/header/index.vue'
|
|||||||
import { queryByCode, queryByid, queryCsDictTree } from '@/api/system-boot/dictTree'
|
import { queryByCode, queryByid, queryCsDictTree } from '@/api/system-boot/dictTree'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import { activateUser, deluser, passwordConfirm } from '@/api/user-boot/user'
|
import { activateUser, deluser, passwordConfirm } from '@/api/user-boot/user'
|
||||||
import { downLoadFile } from '@/api/cs-system-boot/manage.ts'
|
import { downLoadFile } from '@/api/cs-system-boot/manage'
|
||||||
import {
|
import {
|
||||||
addEquipmentDelivery,
|
addEquipmentDelivery,
|
||||||
deleteEquipmentDelivery,
|
deleteEquipmentDelivery,
|
||||||
@@ -208,7 +217,8 @@ import {
|
|||||||
governDeviceRegister,
|
governDeviceRegister,
|
||||||
portableDeviceRegister,
|
portableDeviceRegister,
|
||||||
portableDeviceAccess,
|
portableDeviceAccess,
|
||||||
getExcelTemplate
|
getExcelTemplate,
|
||||||
|
engineeringProject
|
||||||
} from '@/api/cs-system-boot/device'
|
} from '@/api/cs-system-boot/device'
|
||||||
import html2canvas from 'html2canvas'
|
import html2canvas from 'html2canvas'
|
||||||
import { fullUrl } from '@/utils/common'
|
import { fullUrl } from '@/utils/common'
|
||||||
@@ -221,17 +231,27 @@ const showQrCode = ref(false)
|
|||||||
const devTypeOptions: any = ref([])
|
const devTypeOptions: any = ref([])
|
||||||
const devTypeOptions2: any = ref([])
|
const devTypeOptions2: any = ref([])
|
||||||
const devModelOptions2: any = ref([])
|
const devModelOptions2: any = ref([])
|
||||||
|
const engineeringList: any = ref([])
|
||||||
|
|
||||||
const deivce: any = ref({})
|
const deivce: any = ref({})
|
||||||
const ruleFormRef = ref()
|
const ruleFormRef = ref()
|
||||||
const form = reactive({
|
const form: any = reactive({
|
||||||
cntractNo: '',
|
cntractNo: '',
|
||||||
devAccessMethod: 'MQTT',
|
devAccessMethod: 'MQTT',
|
||||||
devModel: '',
|
devModel: '',
|
||||||
devType: '',
|
devType: '',
|
||||||
name: '',
|
name: '',
|
||||||
ndid: '',
|
ndid: '',
|
||||||
|
associatedEngineering: '',
|
||||||
|
associatedProject: '',
|
||||||
|
association: [],
|
||||||
sort: 0
|
sort: 0
|
||||||
})
|
})
|
||||||
|
const props = {
|
||||||
|
label: 'projectName',
|
||||||
|
value: 'projectId',
|
||||||
|
children: 'projectInfoList'
|
||||||
|
}
|
||||||
const rules = reactive({
|
const rules = reactive({
|
||||||
name: [{ required: true, message: '请输入设备名', trigger: 'blur' }],
|
name: [{ required: true, message: '请输入设备名', trigger: 'blur' }],
|
||||||
ndid: [{ required: true, message: '请输入网络设备id', trigger: 'blur' }],
|
ndid: [{ required: true, message: '请输入网络设备id', trigger: 'blur' }],
|
||||||
@@ -248,19 +268,21 @@ const dialogTitle = ref('新增设备')
|
|||||||
const loading = ref<boolean>(false)
|
const loading = ref<boolean>(false)
|
||||||
const devModelOptions: any = ref([])
|
const devModelOptions: any = ref([])
|
||||||
const queryTheDictionary = () => {
|
const queryTheDictionary = () => {
|
||||||
queryByCode('DEV_CLD').then(res => {
|
queryByCode('DEV_CLD')
|
||||||
|
.then(res => {
|
||||||
devTypeOptions2.value = res.data
|
devTypeOptions2.value = res.data
|
||||||
return queryCsDictTree(res.data.id).then(res => {
|
return queryCsDictTree(res.data.id).then(res => {
|
||||||
devModelOptions2.value = res.data.map((item: any) => {
|
devModelOptions2.value = res.data.map((item: any) => {
|
||||||
return {
|
return {
|
||||||
value: item.id,
|
value: item.id,
|
||||||
label: item.name,
|
label: item.name,
|
||||||
...item
|
...item
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}).then(() => {
|
})
|
||||||
queryByCode('Device_Type').then(async res => {
|
.then(() => {
|
||||||
|
queryByCode('Device_Type').then(async res => {
|
||||||
const id = res.data.id
|
const id = res.data.id
|
||||||
await queryCsDictTree(id).then(res => {
|
await queryCsDictTree(id).then(res => {
|
||||||
devTypeOptions.value = res.data.map((item: any) => {
|
devTypeOptions.value = res.data.map((item: any) => {
|
||||||
@@ -292,10 +314,10 @@ const queryTheDictionary = () => {
|
|||||||
})
|
})
|
||||||
await tableStore.index()
|
await tableStore.index()
|
||||||
})
|
})
|
||||||
}).catch(error => {
|
})
|
||||||
|
.catch(error => {
|
||||||
console.error('查询过程中出现错误:', error)
|
console.error('查询过程中出现错误:', error)
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
const devModelOptionsFilter = computed(() => {
|
const devModelOptionsFilter = computed(() => {
|
||||||
return devModelOptions.value.filter((item: any) => {
|
return devModelOptions.value.filter((item: any) => {
|
||||||
@@ -308,7 +330,7 @@ const devModelOptionsFilter = computed(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const formDevModelOptionsFilter = computed(() => {
|
const formDevModelOptionsFilter = computed(() => {
|
||||||
if(form.devAccessMethod === 'CLD'){
|
if (form.devAccessMethod === 'CLD') {
|
||||||
return devModelOptions2.value.filter((item: any) => {
|
return devModelOptions2.value.filter((item: any) => {
|
||||||
if (form.devType) {
|
if (form.devType) {
|
||||||
return item.pid == form.devType
|
return item.pid == form.devType
|
||||||
@@ -316,18 +338,17 @@ const formDevModelOptionsFilter = computed(() => {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}else{
|
} else {
|
||||||
return devModelOptions.value.filter((item: any) => {
|
return devModelOptions.value.filter((item: any) => {
|
||||||
if (form.devType) {
|
if (form.devType) {
|
||||||
return item.pid == form.devType
|
return item.pid == form.devType
|
||||||
} else {
|
} else {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
const formDevTypeOptions = computed(() => {
|
const formDevTypeOptions = computed(() => {
|
||||||
// 如果协议是CLD,使用devTypeOptions2,否则使用devTypeOptions
|
// 如果协议是CLD,使用devTypeOptions2,否则使用devTypeOptions
|
||||||
if (form.devAccessMethod === 'CLD') {
|
if (form.devAccessMethod === 'CLD') {
|
||||||
@@ -367,8 +388,8 @@ const tableStore = new TableStore({
|
|||||||
}
|
}
|
||||||
// 如果是MQTT协议,使用devTypeOptions查找
|
// 如果是MQTT协议,使用devTypeOptions查找
|
||||||
else if (row.row.devAccessMethod === 'MQTT') {
|
else if (row.row.devAccessMethod === 'MQTT') {
|
||||||
const item = devTypeOptions.value.find((item: any) => item.value == row.cellValue);
|
const item = devTypeOptions.value.find((item: any) => item.value == row.cellValue)
|
||||||
return item ? item.label : '/';
|
return item ? item.label : '/'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
minWidth: 120
|
minWidth: 120
|
||||||
@@ -378,8 +399,8 @@ const tableStore = new TableStore({
|
|||||||
field: 'devModel',
|
field: 'devModel',
|
||||||
formatter: row => {
|
formatter: row => {
|
||||||
const options = row.row.devAccessMethod === 'MQTT' ? devModelOptions.value : devModelOptions2.value
|
const options = row.row.devAccessMethod === 'MQTT' ? devModelOptions.value : devModelOptions2.value
|
||||||
const item = options.find((item: any) => item.value == row.cellValue);
|
const item = options.find((item: any) => item.value == row.cellValue)
|
||||||
return item ? item.label : '/';
|
return item ? item.label : '/'
|
||||||
},
|
},
|
||||||
minWidth: 120
|
minWidth: 120
|
||||||
},
|
},
|
||||||
@@ -488,7 +509,8 @@ const tableStore = new TableStore({
|
|||||||
minWidth: 80
|
minWidth: 80
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '操作', fixed: 'right',
|
title: '操作',
|
||||||
|
fixed: 'right',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
width: 220,
|
width: 220,
|
||||||
render: 'buttons',
|
render: 'buttons',
|
||||||
@@ -677,7 +699,6 @@ const tableStore = new TableStore({
|
|||||||
useCORS: true
|
useCORS: true
|
||||||
}).then(canvas => {
|
}).then(canvas => {
|
||||||
let url = canvas.toDataURL('image/png')
|
let url = canvas.toDataURL('image/png')
|
||||||
console.log('🚀 ~ html2canvas ~ url:', url)
|
|
||||||
// 下载图片
|
// 下载图片
|
||||||
let a = document.createElement('a')
|
let a = document.createElement('a')
|
||||||
let event = new MouseEvent('click')
|
let event = new MouseEvent('click')
|
||||||
@@ -701,6 +722,10 @@ const tableStore = new TableStore({
|
|||||||
for (let key in form) {
|
for (let key in form) {
|
||||||
form[key] = row[key]
|
form[key] = row[key]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
form.association = row.associatedProject
|
||||||
|
? [row.associatedEngineering, row.associatedProject]
|
||||||
|
: []
|
||||||
form.id = row.id
|
form.id = row.id
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -741,7 +766,6 @@ const tableStore = new TableStore({
|
|||||||
: ''
|
: ''
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
console.log('🚀 ~ loadCallback ~ tableStore.table:', tableStore.table)
|
|
||||||
tableKey.value += 1
|
tableKey.value += 1
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -877,6 +901,9 @@ const add = () => {
|
|||||||
const onSubmit = () => {
|
const onSubmit = () => {
|
||||||
ruleFormRef.value.validate((valid: any) => {
|
ruleFormRef.value.validate((valid: any) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
form.associatedEngineering = form.association ? form.association[0] : ''
|
||||||
|
form.associatedProject = form.association ? form.association[1] : ''
|
||||||
|
|
||||||
if (dialogTitle.value == '新增设备') {
|
if (dialogTitle.value == '新增设备') {
|
||||||
addEquipmentDelivery(form).then(res => {
|
addEquipmentDelivery(form).then(res => {
|
||||||
ElMessage.success('新增成功')
|
ElMessage.success('新增成功')
|
||||||
@@ -923,6 +950,9 @@ const resetForm = () => {
|
|||||||
devModel: '',
|
devModel: '',
|
||||||
devType: '',
|
devType: '',
|
||||||
name: '',
|
name: '',
|
||||||
|
associatedEngineering: '',
|
||||||
|
associatedProject: '',
|
||||||
|
association: [],
|
||||||
ndid: ''
|
ndid: ''
|
||||||
}
|
}
|
||||||
Object.assign(form, user)
|
Object.assign(form, user)
|
||||||
@@ -939,6 +969,15 @@ provide('tableStore', tableStore)
|
|||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
queryTheDictionary()
|
queryTheDictionary()
|
||||||
|
engineeringProject().then(res => {
|
||||||
|
engineeringList.value = res.data.filter(item => {
|
||||||
|
item.projectName = item.engineeringName
|
||||||
|
item.projectId = item.engineeringId
|
||||||
|
item.disabled = item.projectInfoList ? false : true
|
||||||
|
return item
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
setTimeout(() => {}, 100)
|
setTimeout(() => {}, 100)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -3,347 +3,324 @@ import Excel from 'exceljs'
|
|||||||
|
|
||||||
import FileSaver from 'file-saver'
|
import FileSaver from 'file-saver'
|
||||||
|
|
||||||
const exportExcel = function(luckysheet, value) {
|
const exportExcel = function (luckysheet, value) {
|
||||||
// 参数为luckysheet.getluckysheetfile()获取的对象
|
// 参数为luckysheet.getluckysheetfile()获取的对象
|
||||||
// 1.创建工作簿,可以为工作簿添加属性
|
// 1.创建工作簿,可以为工作簿添加属性
|
||||||
const workbook = new Excel.Workbook()
|
const workbook = new Excel.Workbook()
|
||||||
// 2.创建表格,第二个参数可以配置创建什么样的工作表
|
// 2.创建表格,第二个参数可以配置创建什么样的工作表
|
||||||
if (Object.prototype.toString.call(luckysheet) === '[object Object]') {
|
if (Object.prototype.toString.call(luckysheet) === '[object Object]') {
|
||||||
luckysheet = [luckysheet]
|
luckysheet = [luckysheet]
|
||||||
}
|
}
|
||||||
luckysheet.forEach(function(table) {
|
luckysheet.forEach(function (table) {
|
||||||
if (table.data.length === 0) return true
|
if (table.data.length === 0) return true
|
||||||
// ws.getCell('B2').fill = fills.
|
// ws.getCell('B2').fill = fills.
|
||||||
const worksheet = workbook.addWorksheet(table.name)
|
const worksheet = workbook.addWorksheet(table.name)
|
||||||
const merge = (table.config && table.config.merge) || {}
|
const merge = (table.config && table.config.merge) || {}
|
||||||
const borderInfo = (table.config && table.config.borderInfo) || {}
|
const borderInfo = (table.config && table.config.borderInfo) || {}
|
||||||
// 3.设置单元格合并,设置单元格边框,设置单元格样式,设置值
|
// 3.设置单元格合并,设置单元格边框,设置单元格样式,设置值
|
||||||
setStyleAndValue(table.data, worksheet)
|
setStyleAndValue(table.data, worksheet)
|
||||||
setMerge(merge, worksheet)
|
setMerge(merge, worksheet)
|
||||||
setBorder(borderInfo, worksheet)
|
setBorder(borderInfo, worksheet)
|
||||||
return true
|
return true
|
||||||
})
|
|
||||||
|
|
||||||
// return
|
|
||||||
// 4.写入 buffer
|
|
||||||
const buffer = workbook.xlsx.writeBuffer().then(data => {
|
|
||||||
// console.log('data', data)
|
|
||||||
const blob = new Blob([data], {
|
|
||||||
type: 'application/vnd.ms-excel;charset=utf-8'
|
|
||||||
})
|
})
|
||||||
console.log("导出成功!")
|
|
||||||
FileSaver.saveAs(blob, `${value}.xlsx`)
|
|
||||||
})
|
|
||||||
return buffer
|
|
||||||
}
|
|
||||||
|
|
||||||
var setMerge = function(luckyMerge = {}, worksheet) {
|
// return
|
||||||
const mergearr = Object.values(luckyMerge)
|
// 4.写入 buffer
|
||||||
mergearr.forEach(function(elem) {
|
const buffer = workbook.xlsx.writeBuffer().then(data => {
|
||||||
// elem格式:{r: 0, c: 0, rs: 1, cs: 2}
|
// console.log('data', data)
|
||||||
// 按开始行,开始列,结束行,结束列合并(相当于 K10:M12)
|
const blob = new Blob([data], {
|
||||||
worksheet.mergeCells(
|
type: 'application/vnd.ms-excel;charset=utf-8'
|
||||||
elem.r + 1,
|
|
||||||
elem.c + 1,
|
|
||||||
elem.r + elem.rs,
|
|
||||||
elem.c + elem.cs
|
|
||||||
)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
var setBorder = function(luckyBorderInfo, worksheet) {
|
|
||||||
if (!Array.isArray(luckyBorderInfo)) return
|
|
||||||
// console.log('luckyBorderInfo', luckyBorderInfo)
|
|
||||||
luckyBorderInfo.forEach(function(elem) {
|
|
||||||
// 现在只兼容到borderType 为range的情况
|
|
||||||
// console.log('ele', elem)
|
|
||||||
if (elem.rangeType === 'range') {
|
|
||||||
let border = borderConvert(elem.borderType, elem.style, elem.color)
|
|
||||||
let rang = elem.range[0]
|
|
||||||
// console.log('range', rang)
|
|
||||||
let row = rang.row
|
|
||||||
let column = rang.column
|
|
||||||
for (let i = row[0] + 1; i < row[1] + 2; i++) {
|
|
||||||
for (let y = column[0] + 1; y < column[1] + 2; y++) {
|
|
||||||
worksheet.getCell(i, y).border = border
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (elem.rangeType === 'cell') {
|
|
||||||
// col_index: 2
|
|
||||||
// row_index: 1
|
|
||||||
// b: {
|
|
||||||
// color: '#d0d4e3'
|
|
||||||
// style: 1
|
|
||||||
// }
|
|
||||||
const { col_index, row_index } = elem.value
|
|
||||||
const borderData = Object.assign({}, elem.value)
|
|
||||||
delete borderData.col_index
|
|
||||||
delete borderData.row_index
|
|
||||||
let border = addborderToCell(borderData, row_index, col_index)
|
|
||||||
// console.log('bordre', border, borderData)
|
|
||||||
worksheet.getCell(row_index + 1, col_index + 1).border = border
|
|
||||||
}
|
|
||||||
// console.log(rang.column_focus + 1, rang.row_focus + 1)
|
|
||||||
// worksheet.getCell(rang.row_focus + 1, rang.column_focus + 1).border = border
|
|
||||||
})
|
|
||||||
}
|
|
||||||
var setStyleAndValue = function(cellArr, worksheet) {
|
|
||||||
if (!Array.isArray(cellArr)) return
|
|
||||||
cellArr.forEach(function(row, rowid) {
|
|
||||||
row.every(function(cell, columnid) {
|
|
||||||
if (!cell) return true
|
|
||||||
let fill = fillConvert(cell.bg)
|
|
||||||
|
|
||||||
let font = fontConvert(
|
|
||||||
cell.ff,
|
|
||||||
cell.fc,
|
|
||||||
cell.bl,
|
|
||||||
cell.it,
|
|
||||||
cell.fs,
|
|
||||||
cell.cl,
|
|
||||||
cell.ul
|
|
||||||
)
|
|
||||||
let alignment = alignmentConvert(cell.vt, cell.ht, cell.tb, cell.tr)
|
|
||||||
let value = ''
|
|
||||||
|
|
||||||
if (cell.f) {
|
|
||||||
value = { formula: cell.f, result: cell.v }
|
|
||||||
} else if (!cell.v && cell.ct && cell.ct.s) {
|
|
||||||
// xls转为xlsx之后,内部存在不同的格式,都会进到富文本里,即值不存在与cell.v,而是存在于cell.ct.s之后
|
|
||||||
// value = cell.ct.s[0].v
|
|
||||||
cell.ct.s.forEach(arr => {
|
|
||||||
value += arr.v
|
|
||||||
})
|
})
|
||||||
} else {
|
console.log('导出成功!')
|
||||||
value = cell.v
|
FileSaver.saveAs(blob, `${value}.xlsx`)
|
||||||
}
|
|
||||||
// style 填入到_value中可以实现填充色
|
|
||||||
let letter = createCellPos(columnid)
|
|
||||||
let target = worksheet.getCell(letter + (rowid + 1))
|
|
||||||
// console.log('1233', letter + (rowid + 1))
|
|
||||||
for (const key in fill) {
|
|
||||||
target.fill = fill
|
|
||||||
break
|
|
||||||
}
|
|
||||||
target.font = font
|
|
||||||
target.alignment = alignment
|
|
||||||
target.value = value
|
|
||||||
|
|
||||||
return true
|
|
||||||
})
|
})
|
||||||
})
|
return buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
var fillConvert = function(bg) {
|
var setMerge = function (luckyMerge = {}, worksheet) {
|
||||||
if (!bg) {
|
const mergearr = Object.values(luckyMerge)
|
||||||
return {}
|
mergearr.forEach(function (elem) {
|
||||||
}
|
// elem格式:{r: 0, c: 0, rs: 1, cs: 2}
|
||||||
// const bgc = bg.replace('#', '')
|
// 按开始行,开始列,结束行,结束列合并(相当于 K10:M12)
|
||||||
let fill = {
|
worksheet.mergeCells(elem.r + 1, elem.c + 1, elem.r + elem.rs, elem.c + elem.cs)
|
||||||
type: 'pattern',
|
})
|
||||||
pattern: 'solid',
|
|
||||||
fgColor: { argb: bg.replace('#', '') }
|
|
||||||
}
|
|
||||||
return fill
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var fontConvert = function(
|
var setBorder = function (luckyBorderInfo, worksheet) {
|
||||||
ff = 0,
|
if (!Array.isArray(luckyBorderInfo)) return
|
||||||
fc = '#000000',
|
// console.log('luckyBorderInfo', luckyBorderInfo)
|
||||||
bl = 0,
|
luckyBorderInfo.forEach(function (elem) {
|
||||||
it = 0,
|
// 现在只兼容到borderType 为range的情况
|
||||||
fs = 10,
|
// console.log('ele', elem)
|
||||||
cl = 0,
|
if (elem.rangeType === 'range') {
|
||||||
ul = 0
|
let border = borderConvert(elem.borderType, elem.style, elem.color)
|
||||||
) {
|
let rang = elem.range[0]
|
||||||
// luckysheet:ff(样式), fc(颜色), bl(粗体), it(斜体), fs(大小), cl(删除线), ul(下划线)
|
// console.log('range', rang)
|
||||||
const luckyToExcel = {
|
let row = rang.row
|
||||||
0: '微软雅黑',
|
let column = rang.column
|
||||||
1: '宋体(Song)',
|
for (let i = row[0] + 1; i < row[1] + 2; i++) {
|
||||||
2: '黑体(ST Heiti)',
|
for (let y = column[0] + 1; y < column[1] + 2; y++) {
|
||||||
3: '楷体(ST Kaiti)',
|
worksheet.getCell(i, y).border = border
|
||||||
4: '仿宋(ST FangSong)',
|
}
|
||||||
5: '新宋体(ST Song)',
|
}
|
||||||
6: '华文新魏',
|
}
|
||||||
7: '华文行楷',
|
if (elem.rangeType === 'cell') {
|
||||||
8: '华文隶书',
|
// col_index: 2
|
||||||
9: 'Arial',
|
// row_index: 1
|
||||||
10: 'Times New Roman ',
|
// b: {
|
||||||
11: 'Tahoma ',
|
// color: '#d0d4e3'
|
||||||
12: 'Verdana',
|
// style: 1
|
||||||
num2bl: function(num) {
|
// }
|
||||||
return num === 0 ? false : true
|
const { col_index, row_index } = elem.value
|
||||||
|
const borderData = Object.assign({}, elem.value)
|
||||||
|
delete borderData.col_index
|
||||||
|
delete borderData.row_index
|
||||||
|
let border = addborderToCell(borderData, row_index, col_index)
|
||||||
|
// console.log('bordre', border, borderData)
|
||||||
|
worksheet.getCell(row_index + 1, col_index + 1).border = border
|
||||||
|
}
|
||||||
|
// console.log(rang.column_focus + 1, rang.row_focus + 1)
|
||||||
|
// worksheet.getCell(rang.row_focus + 1, rang.column_focus + 1).border = border
|
||||||
|
})
|
||||||
|
}
|
||||||
|
var setStyleAndValue = function (cellArr, worksheet) {
|
||||||
|
if (!Array.isArray(cellArr)) return
|
||||||
|
cellArr.forEach(function (row, rowid) {
|
||||||
|
row.every(function (cell, columnid) {
|
||||||
|
if (!cell) return true
|
||||||
|
let fill = fillConvert(cell.bg)
|
||||||
|
|
||||||
|
let font = fontConvert(cell.ff, cell.fc, cell.bl, cell.it, cell.fs, cell.cl, cell.ul)
|
||||||
|
let alignment = alignmentConvert(cell.vt, cell.ht, cell.tb, cell.tr)
|
||||||
|
let value = ''
|
||||||
|
|
||||||
|
if (cell.f) {
|
||||||
|
value = { formula: cell.f, result: cell.v }
|
||||||
|
} else if (!cell.v && cell.ct && cell.ct.s) {
|
||||||
|
// xls转为xlsx之后,内部存在不同的格式,都会进到富文本里,即值不存在与cell.v,而是存在于cell.ct.s之后
|
||||||
|
// value = cell.ct.s[0].v
|
||||||
|
cell.ct.s.forEach(arr => {
|
||||||
|
value += arr.v
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
value = cell.v
|
||||||
|
}
|
||||||
|
// style 填入到_value中可以实现填充色
|
||||||
|
let letter = createCellPos(columnid)
|
||||||
|
let target = worksheet.getCell(letter + (rowid + 1))
|
||||||
|
// console.log('1233', letter + (rowid + 1))
|
||||||
|
for (const key in fill) {
|
||||||
|
target.fill = fill
|
||||||
|
break
|
||||||
|
}
|
||||||
|
target.font = font
|
||||||
|
target.alignment = alignment
|
||||||
|
target.value = value
|
||||||
|
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
var fillConvert = function (bg) {
|
||||||
|
if (!bg) {
|
||||||
|
return {}
|
||||||
}
|
}
|
||||||
}
|
// const bgc = bg.replace('#', '')
|
||||||
// 出现Bug,导入的时候ff为luckyToExcel的val
|
let fill = {
|
||||||
|
type: 'pattern',
|
||||||
let font = {
|
pattern: 'solid',
|
||||||
name: typeof ff === 'number' ? luckyToExcel[ff] : ff,
|
fgColor: { argb: bg.replace('#', '') }
|
||||||
family: 1,
|
}
|
||||||
size: fs,
|
return fill
|
||||||
color: { argb: fc.replace('#', '') },
|
|
||||||
bold: luckyToExcel.num2bl(bl),
|
|
||||||
italic: luckyToExcel.num2bl(it),
|
|
||||||
underline: luckyToExcel.num2bl(ul),
|
|
||||||
strike: luckyToExcel.num2bl(cl)
|
|
||||||
}
|
|
||||||
|
|
||||||
return font
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var alignmentConvert = function(
|
var fontConvert = function (ff = 0, fc = '#000000', bl = 0, it = 0, fs = 10, cl = 0, ul = 0) {
|
||||||
vt = 'default',
|
// luckysheet:ff(样式), fc(颜色), bl(粗体), it(斜体), fs(大小), cl(删除线), ul(下划线)
|
||||||
ht = 'default',
|
const luckyToExcel = {
|
||||||
tb = 'default',
|
0: '微软雅黑',
|
||||||
tr = 'default'
|
1: '宋体(Song)',
|
||||||
) {
|
2: '黑体(ST Heiti)',
|
||||||
// luckysheet:vt(垂直), ht(水平), tb(换行), tr(旋转)
|
3: '楷体(ST Kaiti)',
|
||||||
const luckyToExcel = {
|
4: '仿宋(ST FangSong)',
|
||||||
vertical: {
|
5: '新宋体(ST Song)',
|
||||||
0: 'middle',
|
6: '华文新魏',
|
||||||
1: 'top',
|
7: '华文行楷',
|
||||||
2: 'bottom',
|
8: '华文隶书',
|
||||||
default: 'top'
|
9: 'Arial',
|
||||||
},
|
10: 'Times New Roman ',
|
||||||
horizontal: {
|
11: 'Tahoma ',
|
||||||
0: 'center',
|
12: 'Verdana',
|
||||||
1: 'left',
|
num2bl: function (num) {
|
||||||
2: 'right',
|
return num === 0 ? false : true
|
||||||
default: 'left'
|
}
|
||||||
},
|
|
||||||
wrapText: {
|
|
||||||
0: false,
|
|
||||||
1: false,
|
|
||||||
2: true,
|
|
||||||
default: false
|
|
||||||
},
|
|
||||||
textRotation: {
|
|
||||||
0: 0,
|
|
||||||
1: 45,
|
|
||||||
2: -45,
|
|
||||||
3: 'vertical',
|
|
||||||
4: 90,
|
|
||||||
5: -90,
|
|
||||||
default: 0
|
|
||||||
}
|
}
|
||||||
}
|
// 出现Bug,导入的时候ff为luckyToExcel的val
|
||||||
|
|
||||||
let alignment = {
|
let font = {
|
||||||
vertical: luckyToExcel.vertical[vt],
|
name: typeof ff === 'number' ? luckyToExcel[ff] : ff,
|
||||||
horizontal: luckyToExcel.horizontal[ht],
|
family: 1,
|
||||||
wrapText: luckyToExcel.wrapText[tb],
|
size: fs,
|
||||||
textRotation: luckyToExcel.textRotation[tr]
|
color: { argb: fc.replace('#', '') },
|
||||||
}
|
bold: luckyToExcel.num2bl(bl),
|
||||||
return alignment
|
italic: luckyToExcel.num2bl(it),
|
||||||
|
underline: luckyToExcel.num2bl(ul),
|
||||||
|
strike: luckyToExcel.num2bl(cl)
|
||||||
|
}
|
||||||
|
|
||||||
|
return font
|
||||||
}
|
}
|
||||||
|
|
||||||
var borderConvert = function(borderType, style = 1, color = '#000') {
|
var alignmentConvert = function (vt = 'default', ht = 'default', tb = 'default', tr = 'default') {
|
||||||
// 对应luckysheet的config中borderinfo的的参数
|
// luckysheet:vt(垂直), ht(水平), tb(换行), tr(旋转)
|
||||||
if (!borderType) {
|
const luckyToExcel = {
|
||||||
return {}
|
vertical: {
|
||||||
}
|
0: 'middle',
|
||||||
const luckyToExcel = {
|
1: 'top',
|
||||||
type: {
|
2: 'bottom',
|
||||||
'border-all': 'all',
|
default: 'top'
|
||||||
'border-top': 'top',
|
},
|
||||||
'border-right': 'right',
|
horizontal: {
|
||||||
'border-bottom': 'bottom',
|
0: 'center',
|
||||||
'border-left': 'left'
|
1: 'left',
|
||||||
},
|
2: 'right',
|
||||||
style: {
|
default: 'left'
|
||||||
0: 'none',
|
},
|
||||||
1: 'thin',
|
wrapText: {
|
||||||
2: 'hair',
|
0: false,
|
||||||
3: 'dotted',
|
1: false,
|
||||||
4: 'dashDot', // 'Dashed',
|
2: true,
|
||||||
5: 'dashDot',
|
default: false
|
||||||
6: 'dashDotDot',
|
},
|
||||||
7: 'double',
|
textRotation: {
|
||||||
8: 'medium',
|
0: 0,
|
||||||
9: 'mediumDashed',
|
1: 45,
|
||||||
10: 'mediumDashDot',
|
2: -45,
|
||||||
11: 'mediumDashDotDot',
|
3: 'vertical',
|
||||||
12: 'slantDashDot',
|
4: 90,
|
||||||
13: 'thick'
|
5: -90,
|
||||||
|
default: 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
let template = {
|
let alignment = {
|
||||||
style: luckyToExcel.style[style],
|
vertical: luckyToExcel.vertical[vt],
|
||||||
color: { argb: color.replace('#', '') }
|
horizontal: luckyToExcel.horizontal[ht],
|
||||||
}
|
wrapText: luckyToExcel.wrapText[tb],
|
||||||
let border = {}
|
textRotation: luckyToExcel.textRotation[tr]
|
||||||
if (luckyToExcel.type[borderType] === 'all') {
|
}
|
||||||
border['top'] = template
|
return alignment
|
||||||
border['right'] = template
|
}
|
||||||
border['bottom'] = template
|
|
||||||
border['left'] = template
|
var borderConvert = function (borderType, style = 1, color = '#000') {
|
||||||
} else {
|
// 对应luckysheet的config中borderinfo的的参数
|
||||||
border[luckyToExcel.type[borderType]] = template
|
if (!borderType) {
|
||||||
}
|
return {}
|
||||||
// console.log('border', border)
|
}
|
||||||
return border
|
const luckyToExcel = {
|
||||||
|
type: {
|
||||||
|
'border-all': 'all',
|
||||||
|
'border-top': 'top',
|
||||||
|
'border-right': 'right',
|
||||||
|
'border-bottom': 'bottom',
|
||||||
|
'border-left': 'left'
|
||||||
|
},
|
||||||
|
style: {
|
||||||
|
0: 'none',
|
||||||
|
1: 'thin',
|
||||||
|
2: 'hair',
|
||||||
|
3: 'dotted',
|
||||||
|
4: 'dashDot', // 'Dashed',
|
||||||
|
5: 'dashDot',
|
||||||
|
6: 'dashDotDot',
|
||||||
|
7: 'double',
|
||||||
|
8: 'medium',
|
||||||
|
9: 'mediumDashed',
|
||||||
|
10: 'mediumDashDot',
|
||||||
|
11: 'mediumDashDotDot',
|
||||||
|
12: 'slantDashDot',
|
||||||
|
13: 'thick'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let template = {
|
||||||
|
style: luckyToExcel.style[style],
|
||||||
|
color: { argb: color.replace('#', '') }
|
||||||
|
}
|
||||||
|
let border = {}
|
||||||
|
if (luckyToExcel.type[borderType] === 'all') {
|
||||||
|
border['top'] = template
|
||||||
|
border['right'] = template
|
||||||
|
border['bottom'] = template
|
||||||
|
border['left'] = template
|
||||||
|
} else {
|
||||||
|
border[luckyToExcel.type[borderType]] = template
|
||||||
|
}
|
||||||
|
// console.log('border', border)
|
||||||
|
return border
|
||||||
}
|
}
|
||||||
|
|
||||||
function addborderToCell(borders, row_index, col_index) {
|
function addborderToCell(borders, row_index, col_index) {
|
||||||
let border = {}
|
let border = {}
|
||||||
const luckyExcel = {
|
const luckyExcel = {
|
||||||
type: {
|
type: {
|
||||||
l: 'left',
|
l: 'left',
|
||||||
r: 'right',
|
r: 'right',
|
||||||
b: 'bottom',
|
b: 'bottom',
|
||||||
t: 'top'
|
t: 'top'
|
||||||
},
|
},
|
||||||
style: {
|
style: {
|
||||||
0: 'none',
|
0: 'none',
|
||||||
1: 'thin',
|
1: 'thin',
|
||||||
2: 'hair',
|
2: 'hair',
|
||||||
3: 'dotted',
|
3: 'dotted',
|
||||||
4: 'dashDot', // 'Dashed',
|
4: 'dashDot', // 'Dashed',
|
||||||
5: 'dashDot',
|
5: 'dashDot',
|
||||||
6: 'dashDotDot',
|
6: 'dashDotDot',
|
||||||
7: 'double',
|
7: 'double',
|
||||||
8: 'medium',
|
8: 'medium',
|
||||||
9: 'mediumDashed',
|
9: 'mediumDashed',
|
||||||
10: 'mediumDashDot',
|
10: 'mediumDashDot',
|
||||||
11: 'mediumDashDotDot',
|
11: 'mediumDashDotDot',
|
||||||
12: 'slantDashDot',
|
12: 'slantDashDot',
|
||||||
13: 'thick'
|
13: 'thick'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
// console.log('borders', borders)
|
||||||
// console.log('borders', borders)
|
for (const bor in borders) {
|
||||||
for (const bor in borders) {
|
const borderItem = borders[bor]
|
||||||
// console.log(bor)
|
// 同时判断边框对象 和 color 属性都存在
|
||||||
if (borders[bor].color.indexOf('rgb') === -1) {
|
if (!borderItem || !borderItem.color) {
|
||||||
border[luckyExcel.type[bor]] = {
|
continue
|
||||||
style: luckyExcel.style[borders[bor].style],
|
}
|
||||||
color: { argb: borders[bor].color.replace('#', '') }
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
border[luckyExcel.type[bor]] = {
|
|
||||||
style: luckyExcel.style[borders[bor].style],
|
|
||||||
color: { argb: borders[bor].color }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return border
|
if (borderItem.color.indexOf('rgb') === -1) {
|
||||||
|
border[luckyExcel.type[bor]] = {
|
||||||
|
style: luckyExcel.style[borderItem.style],
|
||||||
|
color: { argb: borderItem.color.replace('#', '') }
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
border[luckyExcel.type[bor]] = {
|
||||||
|
style: luckyExcel.style[borderItem.style],
|
||||||
|
color: { argb: borderItem.color }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return border
|
||||||
}
|
}
|
||||||
|
|
||||||
function createCellPos(n) {
|
function createCellPos(n) {
|
||||||
let ordA = 'A'.charCodeAt(0)
|
let ordA = 'A'.charCodeAt(0)
|
||||||
|
|
||||||
let ordZ = 'Z'.charCodeAt(0)
|
let ordZ = 'Z'.charCodeAt(0)
|
||||||
let len = ordZ - ordA + 1
|
let len = ordZ - ordA + 1
|
||||||
let s = ''
|
let s = ''
|
||||||
while (n >= 0) {
|
while (n >= 0) {
|
||||||
s = String.fromCharCode((n % len) + ordA) + s
|
s = String.fromCharCode((n % len) + ordA) + s
|
||||||
|
|
||||||
n = Math.floor(n / len) - 1
|
n = Math.floor(n / len) - 1
|
||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
export { exportExcel }
|
||||||
exportExcel
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user