fast(项目、文档): 项目列表添加标签类型、标签组管理(空间)、项目按钮根据角色显隐,添加文档管理页,解决icon标签报错

This commit is contained in:
fhysy 2024-10-23 10:54:35 +08:00
parent 2cf2efdc72
commit 6ca54a37fe
14 changed files with 1916 additions and 44 deletions

38
src/api/document/index.js Normal file
View File

@ -0,0 +1,38 @@
import request from '@/utils/request'
// 查询文档记录列表
export function getDocumentList(query) {
return request({
url: '/iot/document/list',
method: 'get',
params: query
})
}
// 新增文档记录
export function addDocument(data) {
return request({
url: '/iot/document',
method: 'post',
data: data
})
}
// 修改文档记录
export function editDocument(data) {
return request({
url: '/iot/document',
method: 'put',
data: data
})
}
// 删除文档记录
export function delDocument(id) {
return request({
url: '/iot/document/' + id,
method: 'delete'
})
}

71
src/api/iot/tagGroup.js Normal file
View File

@ -0,0 +1,71 @@
import request from "@/utils/request";
// 查询项目标签组列表
export function listTagGroup(query) {
return request({
url: "/iot/labelData/list",
method: "get",
params: query
});
}
// 查询项目标签组详细
export function getTagGroup(spaceId) {
return request({
url: "/iot/labelData/" + spaceId,
method: "get"
});
}
// 新增项目标签组
export function addTagGroup(data) {
return request({
url: "/iot/labelData",
method: "post",
data: data
});
}
// 修改项目标签组
export function updateTagGroup(data) {
return request({
url: "/iot/labelData",
method: "put",
data: data
});
}
// 删除项目标签组
export function delTagGroup(spaceId) {
return request({
url: "/iot/labelData/" + spaceId,
method: "delete"
});
}
// 导出项目标签组
export function exportTagGroup(query) {
return request({
url: "/iot/space/export",
method: "get",
params: query
});
}
// 查询项目标签组列表
export function listTagGroupDevice(query) {
return request({
url: "/iot/space_device/list",
method: "get",
params: query
});
}
// 获取项目标签组下拉树列表
export function listTagGroupTree(query) {
return request({
url: "/iot/space/tree-list",
method: "get",
params: query
});
}

View File

@ -0,0 +1,71 @@
import request from '@/utils/request'
// 查询标签设备列表
export function listTagGroupdevice(query) {
return request({
url: '/iot/label/device-list',
method: 'get',
params: query
})
}
// 查询标签设备详细
export function getTagGroupdevice(spaceId) {
return request({
url: '/iot/spacedevice/' + spaceId,
method: 'get'
})
}
// 新增标签设备
export function addTagGroupdevice(data) {
return request({
url: '/iot/label/bind',
method: 'post',
data: data
})
}
// 修改标签设备
export function updateTagGroupdevice(data) {
return request({
url: '/iot/spacedevice',
method: 'put',
data: data
})
}
// 删除标签设备
export function delTagGroupdevice(data) {
return request({
url: '/iot/label/remove',
method: 'delete',
data: data
})
}
// 项目中删除设备
export function delTagdevice(data) {
return request({
url: '/iot/label/remove',
method: 'delete',
data: data
})
}
// 导出标签设备
export function exportTagGroupdevice(query) {
return request({
url: '/iot/spacedevice/export',
method: 'get',
params: query
})
}
// 查询指定标签下的设备
export function listRootTagDevice(data) {
return request({
url: '/iot/label/unAssign-list',
method: 'get',
params: data
})
}

70
src/api/iot/tagType.js Normal file
View File

@ -0,0 +1,70 @@
import request from "@/utils/request";
// 查询项目标签类型列表
export function listTagType(projectId) {
return request({
url: "/iot/labelType/list?projectId=" + projectId,
method: "get",
});
}
// 查询项目标签类型详细
export function getTagType(spaceId) {
return request({
url: "/iot/labelType/" + spaceId,
method: "get"
});
}
// 新增项目标签类型
export function addTagType(data) {
return request({
url: "/iot/labelType",
method: "post",
data: data
});
}
// 修改项目标签类型
export function updateTagType(data) {
return request({
url: "/iot/labelType",
method: "put",
data: data
});
}
// 删除项目标签类型
export function delTagType(id) {
return request({
url: "/iot/labelType/" + id,
method: "delete"
});
}
// 导出项目标签类型
export function exportTagType(query) {
return request({
url: "/iot/space/export",
method: "get",
params: query
});
}
// 查询项目标签类型列表
export function listTagTypeDevice(query) {
return request({
url: "/iot/space_device/list",
method: "get",
params: query
});
}
// 获取项目标签类型下拉树列表
export function listTagTypeTree(query) {
return request({
url: "/iot/space/tree-list",
method: "get",
params: query
});
}

View File

@ -0,0 +1,478 @@
<template>
<!-- 告警记录功能 -->
<div class="app-container alarm-record">
<el-form
v-show="showSearch"
ref="queryForm"
:inline="true"
:model="queryParams"
label-width="68px"
>
<el-form-item label="文件名" prop="docName">
<el-input
v-model="queryParams.docName"
clearable
placeholder="请输入文件名"
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button
icon="el-icon-search"
size="mini"
type="primary"
@click="handleQuery"
>搜索</el-button
>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
>重置</el-button
>
<!-- <el-button-->
<!-- icon="el-icon-download"-->
<!-- plain-->
<!-- size="mini"-->
<!-- type="warning"-->
<!-- @click="handleExport"-->
<!-- >导出</el-button-->
<!-- >-->
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
v-hasPermi="['iot:document:add']"
icon="el-icon-plus"
plain
size="mini"
type="primary"
@click="openAddDocumentModel"
>新增</el-button
>
</el-col>
</el-row>
<el-table
v-loading="loading"
:data="recordList"
:default-sort="{ prop: 'alarmTime', order: 'descending' }"
@sort-change="sortChange"
>
<el-table-column
:index="indexFormatter"
align="center"
label="序号"
type="index"
width="80px"
></el-table-column>
<el-table-column
align="left"
label="文件名"
prop="docName"
/>
<el-table-column align="left" label="文件类型" prop="docType" />
<el-table-column align="left" label="文件大小" prop="docSize" >
<template slot-scope="scope">
{{formatFileSize(scope.row.docSize)}}
</template>
</el-table-column>
<el-table-column align="left" label="文件信息" prop="docInfo" />
<el-table-column align="left" label="更新时间" prop="updateTime" width="150" />
<el-table-column
align="center"
class-name="small-padding fixed-width"
label="操作"
width="200"
>
<template slot-scope="scope">
<el-button
v-if="judgeLook(scope.row.docType)"
icon="el-icon-view"
size="mini"
type="text"
@click="handleLook(scope.row)"
>查看</el-button>
<el-button
icon="el-icon-download"
size="mini"
type="text"
@click="handleDownload(scope.row)"
>下载</el-button>
<el-button
v-hasPermi="['iot:document:edit']"
icon="el-icon-edit"
size="mini"
type="text"
@click="handleUpdate(scope.row)"
>编辑</el-button>
<el-button
v-hasPermi="['iot:document:remove']"
icon="el-icon-delete"
size="mini"
style="color: #f56c6c"
type="text"
@click="handleDelete(scope.row)"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total > 0"
:limit.sync="queryParams.pageSize"
:page.sync="queryParams.pageNum"
:total="total"
@pagination="getList"
/>
<el-dialog
:close-on-click-modal="false"
:title="title"
:visible.sync="open"
class="eldialog-wrap"
width="600px"
>
<el-form
ref="dialogForm"
:model="form"
:rules="rules"
label-width="100px"
>
<el-form-item label="文件:">
<el-upload
ref="upload"
:http-request="upload"
:show-file-list="false"
action
drag
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">
将文件拖到此处
<em>点击上传</em>
</div>
</el-upload>
</el-form-item>
<div v-if="form.docUrl">
<el-form-item label="文件名称:" prop="docName">
<el-input v-model="form.docName" placeholder="请输入文件名称" />
</el-form-item>
<el-form-item label="文件类型:">
{{form.docType}}
</el-form-item>
<el-form-item label="文件大小:">
{{formatFileSize(form.docSize)}}
</el-form-item>
<el-form-item label="文件信息:" prop="docInfo">
<el-input v-model="form.docInfo" placeholder="请输入文件信息" />
</el-form-item>
</div>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button size="mini" type="primary" @click="submitForm"
> </el-button
>
<el-button size="mini" @click="open = false"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
listRecord,
getRecord,
exportRecord,
updateRecord,
delRecord,
addAlarmRecord,
} from "@/api/alarm/tenantAlarm";
import { handlerRecord } from "@/api/alarm/record";
import Editor from "@/components/Editor";
import { addDocument, delDocument, editDocument, getDocumentList } from "@/api/document";
import { uploadFile } from "@/api/file";
export default {
name: "DocumentList",
components: {
Editor,
},
data() {
return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
recordList: [],
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
docName: null,
// typeCode: null,
// beginTime: null,
// endTime: null,
// alarmDivide: "ALARM",
// isAsc: 'desc',
// orderByColumn: 'alarmTime'
},
//
form: {
docId:null,
docSize:null,
docUrl:null,
docType:null,
docInfo:null,
docName:null,
},
//
rules: {
docName: [
{ required: true, message: "文件名称不能为空", trigger: "blur" },
],
},
time: [],
};
},
created() {
// this.newTime();
this.getList();
},
methods: {
//
handleUpdate(row) {
this.form = row;
this.open = true;
this.title = `编辑文件`;
},
sortChange(column) {
const sort = {
isAsc: column.order === "descending" ? "desc" : "asc",
orderByColumn: column.prop,
};
this.queryParams = Object.assign(this.queryParams, sort);
this.handleQuery();
},
upload(file) {
var formData = new FormData();
formData.append("file", file.file);
console.log("formData",formData)
console.log("file",file)
uploadFile(formData)
.then((response) => {
console.log("response",response)
if (response.code === 200) {
this.form.docSize = file.file.size;
this.form.docName = this.getFileName(file.file.name) || '';
this.form.docType = this.getFileType(file.file.name) || '';
this.form.docUrl = response.url;
}else{
this.msgError(response.msg);
}
})
.catch((e) => {
console.log(e);
this.msgError(e.msg);
});
},
getFileName(fileName) {
const parts = fileName.split('.');
if (parts.length > 1) {
parts.pop(); //
return parts.join('.'); //
}
return fileName;
},
getFileType(fileName) {
const parts = fileName.split('.');
if (parts.length > 1) {
return parts.pop().toLowerCase();
}
return '';
},
formatFileSize(size) {
if (size === 0) return '0 B';
const k = 1024;
const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
const i = Math.floor(Math.log(size) / Math.log(k));
return parseFloat((size / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
},
/** 删除按钮操作 */
handleDelete(row) {
const recordId = row.docId;
this.$confirm("是否删除该文件?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
})
.then(function () {
return delDocument(recordId);
})
.then(() => {
this.getList();
this.msgSuccess("删除成功");
});
},
submitForm() {
this.$refs["dialogForm"].validate((v) => {
if (v) {
if(this.form.docId){
editDocument(this.form).then((response) => {
this.msgSuccess("编辑成功");
this.open = false;
this.getList();
});
}else{
addDocument(this.form).then((response) => {
this.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
handleLook(row) {
const link = document.createElement('a');
link.href = row.docUrl;
link.setAttribute('download', `${row.docName}.${row.docType}`);
link.target = "_blank";
// DOM
document.body.appendChild(link);
//
link.click();
//
document.body.removeChild(link);
},
judgeLook(docType) {
return docType === 'pdf' || docType === 'png' || docType === 'jpg' || docType === 'jpeg' || docType === 'gif' || docType === 'txt'
// return true
},
handleDownload(row) {
fetch(row.docUrl)
.then(response => response.blob())
.then(blob => {
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.style.display = 'none';
a.href = url;
a.download = `${row.docName}.${row.docType}`;
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(url);
document.body.removeChild(a);
})
.catch(error => {
console.error('下载失败:', error);
});
},
//
handleWork(row) {
console.log("addWork:", row);
this.$confirm("是否创建告警工单?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(function () {
return addAlarmRecord({
recordId: row.recordId, //id
deviceId: row.deviceId,
deviceName: row.deviceName,
faultType: "3", //
maintenanceStatus: "-1", //
tenantId: null,
faultTypeName: "告警工单", //
});
})
.then(() => {
this.msgSuccess("报警工单已创建!");
this.$router.push("/power/maintenancet");
});
},
resetFomr() {
this.form = {
processResult: "",
processStatus: "",
processTime: "",
recordId: "",
};
},
stateFormatter(val) {
switch (val.processStatus) {
case "1":
return "已处理";
case "0":
return "未处理";
case "2":
return "误报";
default:
return "未处理";
}
},
indexFormatter(val) {
return (
val + 1 + (this.queryParams.pageNum - 1) * this.queryParams.pageSize
);
},
/** 查询报警记录列表 */
getList() {
this.loading = true;
getDocumentList(this.queryParams).then((response) => {
this.recordList = response.rows;
this.total = response.total;
this.loading = false;
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
openAddDocumentModel() {
this.form = {
docSize:null,
docUrl:null,
docType:null,
docInfo:null,
docName:null,
};
this.open = true;
this.title = `新增文件`;
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.time = [];
this.queryParams.docName = null;
this.handleQuery();
},
},
};
</script>

View File

@ -10,12 +10,20 @@
</el-tab-pane>
<el-tab-pane v-if="!isShowUserTable" label="项目成员" name="user">
<e-tenant-user v-if="activeName === 'user'" :projectId="projectInfo.projectId"></e-tenant-user>
<e-tenant-user v-if="activeName === 'user'" :infoData="projectInfo || {}" :projectId="projectInfo.projectId"></e-tenant-user>
</el-tab-pane>
<el-tab-pane label="空间" name="space">
<e-object-space v-if="activeName === 'space'" :infoData="projectInfo || {}"/>
</el-tab-pane>
<el-tab-pane v-if="isShowUserTable" label="标签类型" name="tagType">
<tag-type v-if="activeName === 'tagType'" :infoData="projectInfo || {}" @changeTagType="changeTagType"/>
</el-tab-pane>
<el-tab-pane label="标签组" name="tagGroup">
<tag-group v-if="activeName === 'tagGroup'" :activeLabelType="activeLabelType" :infoData="projectInfo || {}"/>
</el-tab-pane>
</el-tabs>
</div>
</template>
@ -24,13 +32,17 @@ import EObjectInfo from './EObjectInfo'
import ETenantUser from './ETenantUser'
import EObjectSpace from './EObjectSpace'
import EObjectTenant from './EObjectTenant'
import TagGroup from "@/views/iot/project/profileV2/TagGroup";
import TagType from "@/views/iot/project/profileV2/TagType";
export default {
name: 'EObjectContainer',
components: {
EObjectInfo,
EObjectSpace,
EObjectTenant,
ETenantUser
ETenantUser,
TagGroup,
TagType
},
props: {
projectInfo: {
@ -48,12 +60,16 @@ export default {
},
data() {
return {
activeName: 'info'
activeName: 'info',
activeLabelType: null
}
},
methods: {
handleClick(tab, event) {
console.log(tab, event);
},
changeTagType(e){
this.activeName = 'tagGroup';
this.activeLabelType = e;
}
}
}

View File

@ -60,8 +60,9 @@
type="text"
@click="handleDetails(scope.row)"
>空间设备</el-button>
<el-button v-hasPermi="['project:space:edit']" icon="el-icon-edit" size="mini" type="text" @click="handleUpdate(scope.row)">修改</el-button>
<el-button v-if="infoData.projectRole === 'root'" v-hasPermi="['project:space:edit']" icon="el-icon-edit" size="mini" type="text" @click="handleUpdate(scope.row)">修改</el-button>
<el-button
v-if="infoData.projectRole === 'root'"
v-hasPermi="['project:space:remove']"
icon="el-icon-delete"
size="mini"
@ -99,16 +100,17 @@
</dialog-template>
<el-dialog
:append-to-body="true"
:close-on-click-modal="false"
:title="spaceDeviceTitle"
:visible.sync="selectTableShow"
append-to-body='true'
class="eldialog-wrap"
top="10vh"
width="75%"
>
<e-object-space-device
v-if="selectTableShow"
:infoData="infoData"
:projectId="infoData.projectId"
:sourceId="sourceId"
/>

View File

@ -22,7 +22,7 @@
<el-table-column align="center" class-name="small-padding fixed-width" label="操作" width="150">
<template slot-scope="scope">
<el-button
v-if="scope.row.deviceType !== 'MINIATURE_BREAKER'"
v-if="scope.row.deviceType !== 'MINIATURE_BREAKER' && infoData.projectRole !== 'personal'"
v-hasPermi="['project:device:relieve']"
icon="el-icon-delete"
size="mini"
@ -94,7 +94,7 @@ import DialogTemplate from "@/components/DialogTemplate";
export default {
name: "SpaceDeviceWrap",
props: ["sourceId", "projectId"],
props: ["sourceId", "projectId","infoData"],
components: {
SelectTableWrap,
DialogTemplate

View File

@ -20,7 +20,7 @@
<el-form-item>
<el-button icon="el-icon-search" type="primary" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
<el-button v-hasPermi="['project:user:add']" icon="el-icon-plus" plain type="primary" @click="handleAdd">新增</el-button>
<el-button v-if="infoData.projectRole === 'root'" v-hasPermi="['project:user:add']" icon="el-icon-plus" plain type="primary" @click="handleAdd">新增</el-button>
</el-form-item>
</el-form>
@ -52,7 +52,7 @@
label="操作"
width="300px"
>
<template v-if="scope.row.roleKey!='root'" slot-scope="scope">
<template v-if="scope.row.roleKey!='root' && infoData.projectRole === 'root'" slot-scope="scope">
<!-- <el-popconfirm-->
<!-- v-hasPermi="['project:user:relieve']"-->
<!-- title="确认要将项目移交给该用户吗?"-->
@ -68,6 +68,7 @@
<!-- </el-popconfirm>-->
<el-button
v-if="infoData.projectRole === 'root'"
v-hasPermi="['project:user:relieve']"
icon="el-icon-edit-outline"
size="mini"
@ -214,7 +215,7 @@ export default {
components: {
SelectTableWrap
},
props: ["projectId"],
props: ["projectId","infoData"],
data() {
return {
selectTableShow: false,

View File

@ -0,0 +1,475 @@
<template>
<div class="app-container e-project-space">
<el-form
v-show="showSearch"
ref="queryForm"
:inline="true"
:model="queryParams"
label-width="68px"
>
<!-- <el-form-item label="上级标签" prop="parentId">-->
<!-- <treeselect-->
<!-- v-model="queryParams.parentId"-->
<!-- :normalizer="normalizer"-->
<!-- :options="querySpaceOptions"-->
<!-- placeholder="请选择上级标签"-->
<!-- style="width: 200px;"-->
<!-- />-->
<!-- </el-form-item>-->
<el-form-item label="标签类型" prop="labelType">
<el-select v-model="queryParams.labelType" placeholder="标签类型" @change="handleQuery">
<el-option
v-for="dict in labelTypeOptions"
:key="dict.labelType"
:label="dict.labelName"
:value="dict.labelType"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="标签名称" prop="spaceName">
<el-input
v-model="queryParams.spaceName"
clearable
placeholder="标签名称"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button icon="el-icon-search" type="primary" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
<el-button v-if="infoData.projectRole !== 'personal'" v-hasPermi="['iot:label:edit']" icon="el-icon-plus" plain type="primary" @click="handleAdd">新增</el-button>
</el-form-item>
</el-form>
<el-table
v-loading="loading"
:data="spaceList"
:default-sort = "{prop: 'orderNum', order: 'ascending'}"
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
default-expand-all
row-key="labelCode"
>
<el-table-column :index="indexFormatter" align="center" label="序号" type="index" width="80px"></el-table-column>
<el-table-column align="left" label="标签名称" prop="labelKey" />
<el-table-column :formatter="statusFormat" align="center" label="标签类型" prop="labelType" />
<el-table-column align="center" label="排序" prop="orderNum" sortable/>
<el-table-column align="left" class-name="small-padding fixed-width" label="操作" width="200">
<template slot-scope="scope">
<el-button
v-hasPermi="['iot:label:edit']"
icon="el-icon-search"
size="mini"
type="text"
@click="handleDetails(scope.row)"
>标签设备</el-button>
<el-button v-if="infoData.projectRole !== 'personal'" icon="el-icon-edit" size="mini" type="text" @click="handleUpdate(scope.row)">修改</el-button>
<el-button
v-if="scope.row.isDefault!='Y' && infoData.projectRole !== 'personal'"
v-hasPermi="['iot:label:edit']"
icon="el-icon-delete"
size="mini"
type="text"
@click="handleDelete(scope.row)"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<!-- 添加或修改项目标签对话框 -->
<dialog-template :title="title" :visible.sync="open" class="eldialog-wrap" width="500px" @close="open = false">
<el-form ref="form" slot="dialog-center" :model="form" :rules="rules" label-width="100px">
<el-form-item label="上级标签:" prop="parentId">
<span v-if="form.parentId==0">顶级节点</span>
<treeselect v-else v-model="form.parentId" :disabled="modelType=='edit'" :normalizer="normalizer" :options="querySpaceOptions" placeholder="请选择上级标签" @input="handleTreeInput" />
</el-form-item>
<el-form-item label="标签名称:" prop="labelKey">
<el-input v-model="form.labelKey" placeholder="请输入标签名称" />
</el-form-item>
<el-form-item label="排序:" prop="orderNum">
<el-input-number v-model="form.orderNum" :min="1" label="排序"></el-input-number>
</el-form-item>
<el-form-item label="类型:" prop="labelType">
{{form.labelName}}
<!-- <el-select v-model="form.labelType" disabled placeholder="请选择标签类型" style="width: 100%;" >-->
<!-- <el-option-->
<!-- v-for="dict in labelTypeOptions"-->
<!-- :key="dict.labelType"-->
<!-- :label="dict.labelName"-->
<!-- :value="dict.labelType"-->
<!-- ></el-option>-->
<!-- </el-select>-->
</el-form-item>
</el-form>
<div slot="dialog-footer" class="dialog-footer">
<el-button size="mini" type="primary" @click="submitForm"> </el-button>
<el-button size="mini" @click="cancel"> </el-button>
</div>
</dialog-template>
<el-dialog
:append-to-body="true"
:close-on-click-modal="false"
:title="spaceDeviceTitle"
:visible.sync="selectTableShow"
class="eldialog-wrap"
top="10vh"
width="75%"
>
<tag-group-device
v-if="selectTableShow"
:labelCode="activelabelCode"
:projectId="infoData.projectId"
:sourceId="sourceId"
:tagData="activeTagData"
/>
<div slot="footer" class="dialog-footer">
<el-button size="mini" type="primary" @click="() =>{selectTableShow = false}"> </el-button>
<el-button size="mini" @click="() =>{selectTableShow = false}"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
listSpace,
getSpace,
delSpace,
addSpace,
updateSpace,
listSpaceTree
} from "@/api/iot/space";
import EObjectSpaceDevice from "./EObjectSpaceDevice";
import TagGroupDevice from "./TagGroupDevice"
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import DialogTemplate from "@/components/DialogTemplate";
import { addTagGroup, delTagGroup, listTagGroup, updateTagGroup } from "@/api/iot/tagGroup";
import { listTagType } from "@/api/iot/tagType";
export default {
name: "TagGroup",
components: {
Treeselect,
EObjectSpaceDevice,
DialogTemplate,
TagGroupDevice
},
props: ["infoData","activeLabelType"],
data() {
return {
modelType:'add',
selectTableShow: false,
//
loading: true,
//
showSearch: true,
dataList:[],
//
spaceList: [],
//
spaceOptions: [],
//
title: "",
//
open: false,
//
queryParams: {
projectId: null,
spaceName: null,
labelType: null
},
//
form: {
labelCode: null,
parentId: null,
labelKey: null,
orderNum: 50,
labelType: null,
},
//
rules: {
parentId: [
{ required: true, message: "请选择上级标签", trigger: "blur" },
],
labelKey: [
{ required: true, message: "标签名称不能为空", trigger: "blur" },
],
orderNum: [
{ required: true, message: "排序不能为空", trigger: "blur" },
],
labelType: [
{ required: true, message: "请选择标签类型", trigger: "blur" },
],
},
labelTypeOptions: [],
querySpaceOptions: [],
sourceId: "",
spaceDeviceTitle: "",
activelabelCode: "",
activeTagData: {}
};
},
watch: {
infoData: {
handler(newValue) {
if (newValue) {
this.getList()
}
},
deep:true, //
immediate: false, //
},
activeLabelType: {
handler(newValue) {
if (newValue) {
this.queryParams.labelType = newValue;
this.getList()
}
},
}
},
created() {
if(this.activeLabelType){
this.queryParams.labelType = this.activeLabelType
}
this.getTagTypeList();
// this.getQueryTreeselect();
},
methods: {
getTagTypeList(){
listTagType(this.infoData.projectId).then(response => {
this.labelTypeOptions = response.rows;
if(response.rows.length>0){
this.queryParams.labelType = response.rows[0].labelType
this.getList();
}
});
},
indexFormatter(val) {
return val + 1;
},
//
handleDetails(row) {
this.activelabelCode = row.labelCode;
this.activeTagData = row;
this.spaceDeviceTitle = `[ ${row.labelKey} ] 标签--设备管理`;
this.selectTableShow = true;
},
//
statusFormat(row, column) {
let label = '';
this.labelTypeOptions.forEach(item=>{
if(item.labelType === row.labelType){
label = item.labelName;
}
})
return label;
},
/** 查询项目标签列表 */
getList() {
if(this.queryParams.labelType==null){
this.msgError("请选择标签类型");
return;
}
this.loading = true;
this.queryParams.projectId = this.infoData.projectId;
listTagGroup(this.queryParams).then(response => {
this.dataList = response.rows || [];
this.spaceList = this.handleTree(response.rows, "labelCode", "parentId");
this.querySpaceOptions = this.handleTree(response.rows, "labelCode", "parentId");
this.loading = false;
});
},
/** 转换项目标签数据结构 */
normalizer(node) {
if (node.children && !node.children.length) {
delete node.children;
}
return {
id: node.labelCode,
label: node.labelKey,
children: node.children
};
},
handleTreeInput(e){
if(e!=undefined){
this.dataList.forEach(item=>{
if(item.labelCode == e){
this.form.labelName = item.labelKey;
this.form.labelType = item.labelType;
}
})
}
},
/** 查询部门下拉树结构 */
getTreeselect(param) {
listSpaceTree(param).then(response => {
this.spaceOptions = [];
const data = { id: 0, label: "顶级节点", children: [] };
// data.children = this.handleTree(response.data, "spaceId", "parentId");
data.children = response.data;
this.spaceOptions.push(data);
});
},
/** 查询部门下拉树结构 */
getQueryTreeselect() {
let param = {
projectId: this.infoData.projectId
};
listTagGroup(param).then(response => {
this.querySpaceOptions = [];
const data = { labelCode: 0, labelKey: "顶级节点", children: [] };
data.children = this.handleTree(response.rows, "labelCode", "parentId");
this.querySpaceOptions.push(data);
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
labelCode: null,
parentId: null,
labelKey: null,
orderNum: 50,
labelType: null,
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.queryParams={
projectId: null,
spaceName: null,
...this.queryParams
}
this.handleQuery();
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
let param = {
projectId: this.infoData.projectId
};
this.getTreeselect(param);
this.open = true;
this.modelType = 'add';
this.title = "添加项目标签";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
let labelName = this.statusFormat({labelType:row.labelType})
this.form = {
labelName,
...row
};
this.modelType = 'edit';
this.open = true;
this.title = "修改项目标签";
// });
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.labelCode != null) {
updateTagGroup(this.form).then(response => {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addTagGroup(this.form).then(response => {
this.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
getAllLabelCodes(obj) {
const labelCodes = [];
function traverse(node) {
if (node && node.labelCode !== undefined) {
labelCodes.push(node.labelCode);
}
if (node && node.children && Array.isArray(node.children)) {
node.children.forEach(child => {
traverse(child);
});
}
}
traverse(obj);
return labelCodes;
},
/** 删除按钮操作 */
handleDelete(row) {
console.log("删除",row)
let arr = this.getAllLabelCodes(row)
let labelCode = arr.join(',');
console.log('数组',arr)
this.$confirm(
'是否确认删除标签"' + row.labelKey + '"及他的所有子标签?',
"警告",
{
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}
)
.then(function() {
return delTagGroup(labelCode);
})
.then(() => {
this.getList();
this.msgSuccess("删除成功");
});
}
}
};
</script>
<style lang="scss">
.e-project-space {
.eldialog-wrap {
.el-dialog__header {
border-bottom: 1px solid #747373;
}
.el-dialog__body {
padding: 0px;
height: calc(100vh - 200px);
overflow: auto;
}
.el-form {
padding: 20px;
padding-right: 40px;
}
.el-dialog__footer {
height: 60px;
border-top: 1px solid #747373;
text-align: right;
width: 100%;
padding: 0px;
padding-top: 15px;
.el-button + .el-button {
margin-right: 10px;
}
.el-button {
padding-top: 8px;
}
}
}
}
</style>

View File

@ -0,0 +1,406 @@
<template>
<div class="app-container">
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button v-if="tagData.isDefault !=='Y' && infoData.projectRole !== 'personal'" v-hasPermi="['iot:label:edit']" icon="el-icon-plus" plain size="mini" type="primary" @click="handleAdd" >新增标签</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table
v-loading="loading"
:data="tag_deviceList"
:default-sort="{prop: 'createTime', order: 'descending'}"
@sort-change="sortChange"
>
<el-table-column :index="indexFormatter" align="center" label="序号" type="index" width="80px"></el-table-column>
<el-table-column align="left" label="设备名称" prop="deviceName" width="200px" />
<el-table-column align="left" label="所属型号" prop="modelName" />
<el-table-column align="left" label="设备key" prop="deviceKey" />
<el-table-column align="left" label="设备类型" prop="deviceTypeName" width="120px" />
<el-table-column align="center" label="创建时间" prop="createTime" sortable="custom" width="200" />
<el-table-column align="center" class-name="small-padding fixed-width" label="操作" width="150">
<template slot-scope="scope">
<el-button
v-if="scope.row.deviceType !== 'MINIATURE_BREAKER' && tagData.isDefault !=='Y' && infoData.projectRole !== 'personal'"
v-hasPermi="['iot:label:edit']"
icon="el-icon-delete"
size="mini"
type="text"
@click="handleDelete(scope.row)"
>移出标签</el-button>
<!-- <el-button-->
<!-- v-if="tagData.isDefault ==='Y'"-->
<!-- v-hasPermi="['project:device:relieve']"-->
<!-- icon="el-icon-delete"-->
<!-- size="mini"-->
<!-- type="text"-->
<!-- @click="handleDeviceDelete(scope.row)"-->
<!-- >删除设备</el-button>-->
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:limit.sync="queryParams.pageSize"
:page.sync="queryParams.pageNum"
:total="total"
@pagination="getList"
/>
<!-- 添加或修改空间设备对话框 -->
<dialog-template :title="title" :visible.sync="open" width="500px" @close="open = false" >
<el-form ref="form" slot="dialog-center" :model="form" :rules="rules" label-width="80px"></el-form>
<div slot="dialog-footer" class="dialog-footer">
<el-button size="mini" type="primary" @click="submitForm"> </el-button>
<el-button size="mini" @click="cancel"> </el-button>
</div>
</dialog-template>
<el-dialog
:close-on-click-modal="false"
:visible.sync="selectTableShow"
append-to-body
class="select-table-dialog"
title="选择设备"
top="10vh"
width="75%"
>
<select-table-wrap
v-if="selectTableShow"
:otherOption="tableSelectOption.otherOption"
:queryOption="tableSelectOption.queryOpt"
:tableList="tableSelectOption.tableList"
:tableOption="tableSelectOption.tableOpt"
@parentGetList="childGetList($event)"
@returnEvent="returnEvent($event)"
/>
<div slot="footer" class="dialog-footer">
<el-button size="mini" type="primary" @click="submitForm"> </el-button>
<el-button size="mini" @click="() =>{selectTableShow = false}"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
listSpace_device,
getSpace_device,
delSpace_device,
addSpace_device,
updateSpace_device,
exportSpace_device,
listProjectDevice
} from "@/api/iot/spaceDevice";
import { listSpaceDevice } from "@/api/iot/space";
import SelectTableWrap from "@/components/SelectTable/index";
import DialogTemplate from "@/components/DialogTemplate";
import {
addTagGroupdevice,
delTagdevice,
delTagGroupdevice,
listRootTagDevice,
listTagGroupdevice
} from "@/api/iot/tagGroupDevice";
export default {
name: "TagGroupDevice",
props: ["sourceId", "projectId", "labelCode", "tagData"],
components: {
SelectTableWrap,
DialogTemplate
},
data() {
return {
selectTableShow: false,
tableSelectOption: {},
selectResult: {},
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
tag_deviceList: [],
//
title: "",
//
open: false,
//
queryParams: {
labelCode: "",
pageNum: 1,
pageSize: 10,
orderByColumn: "createTime",
isAsc: "desc"
},
//
form: {},
//
rules: {}
};
},
created() {
this.getList();
},
methods: {
sortChange(column) {
const sort = {
isAsc: column.order === "descending" ? "desc" : "asc",
orderByColumn: column.prop
};
this.queryParams = Object.assign(this.queryParams, sort);
this.handleQuery();
},
indexFormatter(val) {
return (
val + 1 + (this.queryParams.pageNum - 1) * this.queryParams.pageSize
);
},
//
handleDetails() {
this.selectResult = {};
this.tableSelectOption = {
otherOption: {
tableType: "device"
},
queryOpt: {
disable: false,
labelWidth: "68px",
params: {
deviceName: "",
projectId: this.projectId,
labelType: this.tagData.labelType,
deviceType: "GATEWAY_CONTROLLER"
},
page: {
pageSize: 10,
pageNum: 1,
total: 0
},
inline: true,
queryChilds: [
{
style: "",
placeholder: "设备名称",
clearable: true,
label: "设备名称",
type: "input",
key: "deviceName",
size: "small",
value: ""
}
]
},
tableOpt: {
loading: false,
rowKey: "deviceId",
selection: false,
maxHeight: "45vh",
childs: [
{
style: "",
label: "所属型号",
type: "",
prop: "modelName",
align: "left",
width: "",
"show-overflow-tooltip": false,
tempType: "span"
},
{
style: "",
label: "设备名称",
type: "",
prop: "deviceName",
align: "left",
width: "",
"show-overflow-tooltip": false,
tempType: "span"
},
{
style: "",
label: "设备Key",
type: "",
prop: "deviceKey",
align: "left",
width: "",
"show-overflow-tooltip": false,
tempType: "span"
},
{
style: "",
label: "设备类型",
type: "",
prop: "deviceTypeName",
align: "left",
width: "",
"show-overflow-tooltip": false,
tempType: "span"
},
{
style: "",
label: "创建时间",
type: "time",
prop: "createTime",
align: "center",
width: "180",
"show-overflow-tooltip": false,
tempType: "span"
}
],
tableList: {
type: Array
}
},
tableList: []
};
this.selectTableShow = true;
},
childGetList(data) {
console.log(data.param)
listRootTagDevice(data.param).then(response => {
this.tableSelectOption.tableList = response.data;
// this.tableSelectOption.queryOpt.page.total = Number(response.total);
});
},
returnEvent(data) {
if (data.type === "dblclick") {
this.form.deviceKey = data.value.deviceKey;
this.submitForm();
} else if (data.type === "click") {
this.form.deviceKey = data.value.deviceKey;
}
},
/** 查询空间设备列表 */
getList() {
this.loading = true;
this.queryParams.labelCode = this.labelCode;
listTagGroupdevice(this.queryParams).then(response => {
this.tag_deviceList = response.rows;
this.total = response.total;
this.loading = false;
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
deviceKey: null
};
let arr = this.tagData.ancestors.split(',');
arr.shift()
arr.shift()
arr.push(this.tagData.labelCode);
this.form.labelCodes = arr;
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.spaceId);
this.single = selection.length !== 1;
this.multiple = !selection.length;
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.handleDetails();
},
/** 提交按钮 */
submitForm() {
addTagGroupdevice(this.form).then(response => {
this.msgSuccess("新增成功");
this.selectTableShow = false;
this.getList();
});
},
getAllLabelCodes(obj) {
const labelCodes = [];
function traverse(node) {
if (node && node.labelCode !== undefined) {
labelCodes.push(node.labelCode);
}
if (node && node.children && Array.isArray(node.children)) {
node.children.forEach(child => {
traverse(child);
});
}
}
traverse(obj);
return labelCodes;
},
/** 删除按钮操作 */
handleDelete(row) {
let labelCodes = this.getAllLabelCodes(this.tagData)
this.$confirm("是否将该设备移出该标签?", "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
})
.then(function() {
return delTagGroupdevice({ deviceKey: row.deviceKey,labelCodes});
})
.then(() => {
this.getList();
this.msgSuccess("移出成功");
});
},
handleDeviceDelete(row) {
const spaceIds = row.deviceId;
this.$confirm("是否将该设备从项目中删除?", "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
})
.then(function() {
return delTagdevice(spaceIds);
})
.then(() => {
this.getList();
this.msgSuccess("删除成功");
});
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm("是否确认导出所有空间设备数据项?", "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
})
.then(function() {
return exportSpace_device(queryParams);
})
.then(response => {
this.download(response.msg);
});
}
}
};
</script>

View File

@ -0,0 +1,231 @@
<template>
<div class="app-container">
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
v-hasPermi="['project:tenant:add']"
icon="el-icon-plus"
plain
size="mini"
type="primary"
@click="handleAdd"
>新增</el-button
>
</el-col>
<right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
></right-toolbar>
</el-row>
<el-table
v-loading="loading"
:data="project_tenantList"
row-key="labelType"
@sort-change="sortChange"
>
<el-table-column
align="center"
label="序号"
type="index"
width="80px"
></el-table-column>
<el-table-column align="center" label="标签类型名称" prop="labelName" >
<template slot-scope="scope">
<span style="color: #0d8afd;cursor: pointer" @click="clickType(scope.row)">{{ scope.row.labelName }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="创建时间" prop="createTime" />
<el-table-column
align="center"
class-name="small-padding fixed-width"
label="操作"
width="200px"
>
<template slot-scope="scope">
<el-button icon="el-icon-edit" size="mini" type="text" @click="handleUpdate(scope.row)">修改</el-button>
<el-button
icon="el-icon-delete"
size="mini"
type="text"
@click="handleDelete(scope.row)"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<el-dialog
:close-on-click-modal="false"
:title="modelTitle"
:visible.sync="modelShow"
append-to-body
class="select-table-dialog"
top="30vh"
width="600px"
>
<el-form ref="form" :model="form" :rules="rules" class="phone-box" label-width="120px">
<el-form-item label="标签类型名称" prop="labelName">
<el-input v-model="form.labelName" placeholder="请输入标签类型名称" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="() => {modelShow = false;}"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import SelectTableWrap from "@/components/SelectTable/index";
import { addTagType, delTagType, listTagType, updateTagType } from "@/api/iot/tagType";
export default {
name: "TagType",
components: {
SelectTableWrap,
},
props: ["infoData"],
data() {
return {
modelTitle:'',
modelShow: false,
//
loading: true,
//
showSearch: true,
//
total: 0,
//
project_tenantList: [],
//
queryParams: {
},
//
form: {
project_id:null,
labelName:null,
labelType:null,
},
//
rules: {
labelName: [
{ required: true, message: "标签类型名称不能为空", trigger: "blur" },
],
},
};
},
watch: {
infoData: {
handler(newVal) {
if (newVal) {
this.getList();
}
},
deep: true, //
immediate: false, //
},
},
created() {
this.getList();
},
methods: {
sortChange(column) {
const sort = {
isAsc: column.order === "descending" ? "desc" : "asc",
orderByColumn: column.prop,
};
this.queryParams = Object.assign(this.queryParams, sort);
this.handleQuery();
},
/** 查询项目用户关系列表 */
getList() {
this.loading = true;
listTagType(this.infoData.projectId).then((response) => {
this.project_tenantList = response.rows;
this.total = response.total;
this.loading = false;
});
},
clickType(e){
this.$emit("changeTagType", e.labelType)
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
projectId: this.infoData.projectId,
labelName: null,
labelType: null,
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.modelTitle = '添加标签类型'
this.modelShow = true;
// this.handleDetails();
},
/** 修改按钮操作 */
handleUpdate(row) {
console.log("row",row)
this.reset();
this.form = row;
this.modelTitle = "修改标签类型";
this.modelShow = true;
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.labelType != null) {
updateTagType(this.form).then(response => {
this.msgSuccess("修改成功");
this.modelShow = false;
this.getList();
});
} else {
addTagType(this.form).then(response => {
this.msgSuccess("新增成功");
this.modelShow = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const labelId = row.labelId;
this.$confirm("删除该类型会删除所有该类型下的设备标签,确认删除吗?", "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(function () {
return delTagType(labelId);
})
.then(() => {
this.getList();
this.msgSuccess("删除成功");
});
},
},
};
</script>

View File

@ -55,7 +55,7 @@
align-items: center;
"
>
<icon class="iconfont iconT but-icon" />
<i class="iconfont iconT but-icon" />
合闸
</div>
</el-button>
@ -74,7 +74,7 @@
align-items: center;
"
>
<icon class="iconfont iconF but-icon" />
<i class="iconfont iconF but-icon" />
分闸
</div>
</el-button>
@ -87,7 +87,7 @@
align-items: center;
"
>
<icon class="iconfont iconhezha but-icon" />
<i class="iconfont iconhezha but-icon" />
一键合闸
</div>
</el-button>
@ -105,7 +105,7 @@
align-items: center;
"
>
<icon class="iconfont iconfenzha but-icon" />
<i class="iconfont iconfenzha but-icon" />
一键分闸
</div></el-button
>
@ -124,7 +124,7 @@
align-items: center;
"
>
<icon class="iconfont el-icon-search but-icon" />
<i class="iconfont el-icon-search but-icon" />
查找设备
</div>
</el-button>
@ -137,7 +137,7 @@
align-items: center;
"
>
<icon class="iconfont iconquanxuan but-icon" />
<i class="iconfont iconquanxuan but-icon" />
{{ childDeviceList.length > tSelectList.length ? "全选" : "取消" }}
</div>
</el-button>
@ -225,11 +225,11 @@
: 'dev-info-state off-line'
"
>
<icon
<i
v-if="deviceInfo['deviceState'] == 'ONLINE'"
class="iconfont iconSYS_STA_1"
/>
<icon v-else class="iconfont iconlixian" />
<i v-else class="iconfont iconlixian" />
<span style="margin-left: 1px">{{
deviceInfo["deviceState"] == "ONLINE" ? "在线" : "离线"
}}</span>
@ -301,11 +301,11 @@
"
style="width: 60px"
>
<icon
<i
v-if="item['deviceState'] === 'ONLINE'"
class="iconfont iconSYS_STA_1"
/>
<icon v-else class="iconfont iconlixian" />
<i v-else class="iconfont iconlixian" />
<span style="margin-left: 1px; margin-top: 1px">{{
getDeviceState(item["deviceState"])
}}</span>
@ -319,12 +319,12 @@
font-size: 14px;
"
>
<icon
<i
v-if="item['switch'] == '1'"
class="iconfont iconT"
style="color: #76bbff; font-size: 16px"
/>
<icon
<i
v-else
class="iconfont iconF"
style="font-size: 16px; color: #878686"

View File

@ -108,10 +108,10 @@ export default {
methods: {
formatTime(date){
//
if (date.toString().length === 10) {
if (date && date.toString().length === 10) {
// 10
return moment(date * 1000).format('YYYY-MM-DD HH:mm:ss');
} else if (date.toString().length === 13) {
} else if (date && date.toString().length === 13) {
// 13
return moment(date).format('YYYY-MM-DD HH:mm:ss');
} else {
@ -178,6 +178,7 @@ export default {
// // }
// } else {
if (result["cmd"] && list[i]["cmdKey"] === result["cmd"]) {
console.log("list[i].children",list[i])
for (var v = 0; v < list[i].children.length; v++) {
if (
result.params[list[i].children[v]["funKey"]] !== null &&
@ -203,37 +204,38 @@ export default {
}, 10000);
}
},
forGetParmas(row, index) {
async forGetParams(row, index) {
const param = {
cmdId: row.cmdId,
deviceId: this.deviceInfo.deviceId,
cmdKey: row.cmdKey,
deviceKey: this.deviceInfo.deviceKey
};
getDeviceFunList(param).then(res => {
// row["children"] = res.data.filter(item => item.show === true) || [];
if(res.data.length > 0){
let list = res.data.filter(item => item.show == true) || [];
row["children"] = list.map(item => {
if(item.dataFormat){
try {
const res = await getDeviceFunList(param);
if (res.data.length > 0) {
let list = res.data.filter(item => item.show === true) || [];
row.children = list.map(item => {
if (item.dataFormat) {
let dataFormat = JSON.parse(item.dataFormat);
item.dataFormatType = dataFormat.type;
if(dataFormat.list && dataFormat.type == 'ENUM'){
try{
if (dataFormat.list && dataFormat.type === 'ENUM') {
try {
item.dataFormatObj = JSON.parse(dataFormat.list.replace(/\\/g, ''));
}catch(e){
} catch (e) {
item.dataFormatObj = {};
}
}
}
return item;
});
}else{
row["children"] = [];
} else {
row.children = [];
}
this.$forceUpdate();
});
} catch (error) {
console.error(`Error fetching data for row ${index}:`, error);
}
},
lengthReSize(str) {
if (str.toString().length < 18 && str.toString().length > 12) {
@ -261,7 +263,17 @@ export default {
this.socket_flag = false;
this.stompClient = null;
clearTimeout(this.setTimeOut_flag);
}
},
async processAllRequests(data) {
try {
await Promise.all(data.map(async (row, index) => {
await this.forGetParams(row, index);
}));
this.connection();
} catch (error) {
console.error('Error processing all requests:', error);
}
},
},
destroyed() {
this.closeWebscoket();
@ -269,11 +281,12 @@ export default {
watch: {
cmdList(val) {
if (val) {
val.forEach((v, index) => {
this.forGetParmas(v, index);
});
// val.forEach((v, index) => {
// this.forGetParmas(v, index);
// });
// setTimeout(this.connection, 3000);
this.connection()
// this.connection()
this.processAllRequests(val);
}
},
realTimeData: {