feat(store): 添加更新功能列表和事件列表的排序功能、调整字典和用户页面、删除无用代码

- 在 attribute.js 中添加了 UpdateFunctionList 和 UpdateEventList 两个 action
This commit is contained in:
fhysy 2025-05-26 17:42:33 +08:00
parent a23c97c513
commit fccb5033a7
10 changed files with 938 additions and 1103 deletions

View File

@ -177,6 +177,14 @@ const attribute = {
EditEvent({ commit, state }, param) {
commit('UPDATE_EVENT', param)
},
// 修改 列表
UpdateFunctionList({ commit, state }, param) {
commit('SET_FUNCTION_LIST', param)
},
// 修改 列表
UpdateEventList({ commit, state }, param) {
commit('SET_EVENT_LIST', param)
},
// 删除分组 删除分组 判断分组是否有属性,有属性就不能删除
DeleteGroup({ commit, state }, idx) {
let groupItem = state.groupList[idx];

View File

@ -877,7 +877,7 @@ export default {
}
],
deviceTag: [
{ required: true, message: "设备标签不能为空", trigger: "change" }
// { required: true, message: "", trigger: "change" }
]
},
deviceTypeList: {},

View File

@ -333,14 +333,12 @@
</div>
</template>
<script>
import { updateDevice, resetPssword, setSwitchControl, setFunctionControl } from "@/api/iot/device";
import { setSwitchControl, setFunctionControl } from "@/api/iot/device";
import DialogTemplate from "@/components/DialogTemplate";
import DeviceAlarmConfig from "@/views/profile/DeviceAlarmConfig/DeviceAlarmConfig";
import DeviceTimingConfig from "@/views/profile/DeviceTimingConfig/DeviceTimingConfig";
import { addCard, delCard, getCard, setCardQuery } from "@/api/iot/cardNumber";
import MyMonacoEditor from '@/views/components/my-monaco-editor'
// import JsonEditor from "@/components/JsonEditor";
// import { callFunction } from "@/api/iot/function";
export default {
name: "functionWrap",
@ -427,43 +425,6 @@ export default {
}
return this.currentFunction.inputs.map(input => {
//
let typeName = "";
// switch (input.valueType.type) {
// case "int":
// typeName = "";
// break;
// case "long":
// typeName = "";
// break;
// case "float":
// typeName = "";
// break;
// case "double":
// typeName = "";
// break;
// case "string":
// typeName = "";
// break;
// case "boolean":
// typeName = "";
// break;
// case "date":
// typeName = "";
// break;
// case "enum":
// typeName = "";
// break;
// case "array":
// typeName = "";
// break;
// case "object":
// typeName = "";
// break;
// default:
// typeName = input.valueType.type;
// }
return {
...input,
type: input.valueType.type
@ -619,42 +580,7 @@ export default {
} else {
this.$message.error("功能执行失败");
}
});
// API
// setTimeout(() => {
// this.loading = false;
//
// //
// const result = {
// time: new Date().toLocaleString(),
// functionName: item.name,
// success: Math.random() > 0.2, // /
// data: JSON.stringify(processedData, null, 2)
// };
//
// this.executionResults.unshift(result);
//
// //
// if (this.executionResults.length > 20) {
// this.executionResults.pop();
// }
//
// //
// if (result.success) {
// this.$message.success("");
// } else {
// this.$message.error("");
// }
//
// //
// this.$nextTick(() => {
// if (this.$refs.resultContent) {
// this.$refs.resultContent.scrollTop = 0;
// }
// });
// }, 1000);
}
});
}else{

View File

@ -100,8 +100,7 @@
</template>
<script>
import { listDeviceEventLogList, listDeviceLogList } from "@/api/iot/device";
import SelectTableWrap from "@/components/SelectTable/index";
import { listDeviceEventLogList } from "@/api/iot/device";
import {formatDate} from "@/utils";
import JsonViewer from "vue-json-viewer";
import "vue-json-viewer/style.css";
@ -110,12 +109,10 @@ export default {
name: 'EventLog',
props: ['sourceId', 'pDevcieInfo'],
components: {
SelectTableWrap,
JsonViewer
},
data() {
return {
direction,
//
pickerValue: null,
queryParams: {
@ -124,7 +121,6 @@ export default {
orderType: 2,
deviceId: null,
deviceName: null,
direction: direction[0].value,
eventType: '',
beginTime: null,
endTime: null
@ -201,10 +197,6 @@ export default {
resetQuery() {
this.resetForm("queryForm");
this.resetPicker();
// if (this.eventTypeList && this.eventTypeList.length > 0) {
// this.queryParams.eventType = this.eventTypeList[0].id;
// this.activeEventObj = this.eventTypeList[0];
// }
this.handleQuery();
},
resetPicker() {
@ -228,20 +220,6 @@ export default {
this.queryParams = Object.assign(this.queryParams, sort);
this.handleQuery();
},
copyOnClick(val) {
let self = this;
this.$copyText(val).then(
function () {
self.$message({
message: "复制成功",
type: "success",
});
},
function () {
self.$message.error("复制失败");
}
);
},
openDetail(item){
let eventContent = '';
try {

File diff suppressed because it is too large Load Diff

View File

@ -33,9 +33,23 @@
align="center"
class-name="small-padding fixed-width"
label="操作"
width="180px"
width="200px"
>
<template slot-scope="scope">
<el-button
:disabled="scope.$index === 0"
icon="el-icon-arrow-up"
size="mini"
type="text"
@click="handleMoveUp(scope.$index)"
>上移</el-button>
<el-button
:disabled="scope.$index === eventList.length - 1"
icon="el-icon-arrow-down"
size="mini"
type="text"
@click="handleMoveDown(scope.$index)"
>下移</el-button>
<el-button
icon="el-icon-edit"
size="mini"
@ -55,21 +69,13 @@
</el-table-column>
</el-table>
<pagination
v-show="total > 0"
:limit.sync="queryParams.pageSize"
:page.sync="queryParams.pageNum"
:total="total"
@pagination="getList"
/>
<event-form-model
ref="eventForm"
:eventList="eventList"
:paramIdx="eventFormObj.paramIdx"
:row="eventFormObj.eventForm"
:tempType="eventFormObj.modelType"
:title="eventFormObj.modelType == 'add' ? '新增' : '编辑'"
:title="eventFormObj.modelType === 'add' ? '新增' : '编辑'"
:visible.sync="eventOpen"
@ok="handleFormOk"
></event-form-model>
@ -77,7 +83,6 @@
</template>
<script>
import JsonEditor from "./jsonEditor.vue";
import ParamsJsonWrap from "./paramsJson";
import eventFormModel from "@/views/profile/attribute/eventFormModel";
@ -90,7 +95,6 @@ const eventLevel = {
export default {
name: "EventView",
components: {
JsonEditor,
ParamsJsonWrap,
eventFormModel
},
@ -110,42 +114,14 @@ export default {
eventOpen: false,
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
total: 0,
//
eventList: [],
//
title: "",
//
attributeopen: false,
//
queryParams: {},
//
form: {},
//
rules: {
funName: [{ required: true, message: "名称不能为空", trigger: "blur" }],
funKey: [
{ required: true, message: "标识符不能为空", trigger: "blur" }
],
funDataType: [
{ required: true, message: "数据类型不能为空", trigger: "blur" }
],
funRwType: [
{ required: true, message: "传输类型不能为空", trigger: "blur" }
],
funValidType: [
{ required: true, message: "校验方式不能为空", trigger: "blur" }
]
},
baseModelId: "",
tempType: "",
eventFormObj: {
id: "",
name: "",
@ -164,26 +140,6 @@ export default {
this.getList();
},
methods: {
//
funDataTypeChange(val) {
this.form.funValAcc = null;
this.form.funValidType = "";
},
addJsonObj() {
this.$refs["jsonEditors"].addHandel();
},
jsonEvent(data) {
this.form.funObj = data;
},
//
funValidTypeChange(val) {
this.form.funValMax = "";
this.form.funValMin = "";
this.form.funObj = "";
if (val === "ENUM") {
this.form.funObj = '{"0":""}';
}
},
/** 查询功能定义列表 */
getList() {
this.loading = true;
@ -197,41 +153,6 @@ export default {
});
}, 50);
},
setList(list) {
this.loading = true;
this.eventList = [];
setTimeout(() => {
this.eventList = list;
this.$forceUpdate();
this.loading = false;
}, 50);
},
//
cancel() {
this.attributeopen = false;
this.reset();
},
//
reset() {
this.form = {
sourceId: this.sourceId,
mainId: undefined,
funName: undefined,
funKey: undefined,
funDataType: undefined,
funValAcc: undefined,
funRwType: undefined,
funValidType: undefined,
funValMin: undefined,
funValMax: undefined,
funObj: {},
unitName: ""
};
this.resetForm("form");
},
handleParams() {
this.$emit("handleClick", { type: "param", idx: 0 });
},
/** 新增按钮操作 */
handleAdd() {
this.eventFormObj = {
@ -252,6 +173,55 @@ export default {
};
this.eventOpen = true;
},
/**
* 上移功能
* @param {Number} index 当前功能索引
*/
handleMoveUp(index) {
if (index === 0) return; //
//
const temp = this.eventList[index];
this.$set(this.eventList, index, this.eventList[index - 1]);
this.$set(this.eventList, index - 1, temp);
// store
this.$store.dispatch("UpdateEventList", this.eventList).then(() => {
this.$message({
type: 'success',
message: '上移成功!'
});
}).catch(err => {
this.$message.error("操作失败:" + err);
//
this.getList();
});
},
/**
* 下移功能
* @param {Number} index 当前功能索引
*/
handleMoveDown(index) {
if (index === this.eventList.length - 1) return; //
//
const temp = this.eventList[index];
this.$set(this.eventList, index, this.eventList[index + 1]);
this.$set(this.eventList, index + 1, temp);
// store
this.$store.dispatch("UpdateEventList", this.eventList).then(() => {
this.$message({
type: 'success',
message: '下移成功!'
});
}).catch(err => {
this.$message.error("操作失败:" + err);
//
this.getList();
});
},
/** 修改按钮操作 */
handleUpdate(row, idx) {
@ -301,88 +271,11 @@ export default {
}
};
</script>
<style lang="scss">
<style lang="scss" scoped>
.product-customparams-wrap {
.nl-dialog .el-dialog:not(.is-fullscreen) {
margin-top: 3vh !important;
}
.eldialog-wrap {
.el-dialog__header {
border-bottom: 1px solid #bdbdbd;
}
.el-dialog__body {
padding: 0px;
}
.form-button-div {
margin-top: 20px;
height: 60px;
border-top: 1px solid #bdbdbd;
text-align: right;
width: 100%;
padding-top: 15px;
.el-button + .el-button {
margin-right: 10px;
}
.el-button {
padding-top: 8px;
}
}
.el-select {
width: 100%;
}
.el-input-number {
width: 100%;
}
.item-title-wrap {
font-size: 15px;
font-weight: 600;
height: 30px;
}
.custom-wrap {
border: 1px solid #d8d7d7;
padding-top: 20px;
background: #f0f0f0;
padding-right: 10px;
.el-form-item {
border-bottom: 1px dashed #bdbdbd;
padding-bottom: 12px;
margin-bottom: 10px;
margin-left: 10px;
}
.el-form-item--medium .el-form-item__label {
width: 90px !important;
}
.el-form-item--medium .el-form-item__content {
margin-left: 90px !important;
}
.enumTypeDiv {
display: flex;
justify-content: flex-end;
max-height: 200px;
overflow: auto;
.enum-item {
width: 90%;
display: flex;
justify-content: space-around;
align-items: center;
}
}
.max-min-row {
width: 90%;
padding: 0;
margin-left: 5% !important;
margin-right: 0 !important;
.el-form-item {
border: 0;
margin-left: 0;
}
.el-form-item--medium .el-form-item__content {
margin-left: 0px !important;
}
}
}
}
.params-eldialog {
.el-dialog__header {
}

File diff suppressed because it is too large Load Diff

View File

@ -31,9 +31,23 @@
align="center"
class-name="small-padding fixed-width"
label="操作"
width="180px"
width="200px"
>
<template slot-scope="scope">
<el-button
:disabled="scope.$index === 0"
icon="el-icon-arrow-up"
size="mini"
type="text"
@click="handleMoveUp(scope.$index)"
>上移</el-button>
<el-button
:disabled="scope.$index === functionList.length - 1"
icon="el-icon-arrow-down"
size="mini"
type="text"
@click="handleMoveDown(scope.$index)"
>下移</el-button>
<el-button
icon="el-icon-edit"
size="mini"
@ -128,7 +142,6 @@ export default {
this.functionList = [];
setTimeout(() => {
this.$store.dispatch("GetFunctionList").then(res => {
console.log("功能列表数据", res);
this.functionList = res;
this.$forceUpdate();
this.loading = false;
@ -186,6 +199,55 @@ export default {
};
this.functionOpen = true;
},
/**
* 上移功能
* @param {Number} index 当前功能索引
*/
handleMoveUp(index) {
if (index === 0) return; //
//
const temp = this.functionList[index];
this.$set(this.functionList, index, this.functionList[index - 1]);
this.$set(this.functionList, index - 1, temp);
// store
this.$store.dispatch("UpdateFunctionList", this.functionList).then(() => {
this.$message({
type: 'success',
message: '上移成功!'
});
}).catch(err => {
this.$message.error("操作失败:" + err);
//
this.getList();
});
},
/**
* 下移功能
* @param {Number} index 当前功能索引
*/
handleMoveDown(index) {
if (index === this.functionList.length - 1) return; //
//
const temp = this.functionList[index];
this.$set(this.functionList, index, this.functionList[index + 1]);
this.$set(this.functionList, index + 1, temp);
// store
this.$store.dispatch("UpdateFunctionList", this.functionList).then(() => {
this.$message({
type: 'success',
message: '下移成功!'
});
}).catch(err => {
this.$message.error("操作失败:" + err);
//
this.getList();
});
},
/** 修改按钮操作 */
handleUpdate(row, idx) {
@ -318,8 +380,6 @@ export default {
}
}
.params-eldialog {
.el-dialog__header {
}
.el-dialog__body {
height: 100%;
max-height: calc(100vh - 200px);

View File

@ -1,10 +1,11 @@
<template>
<div class="app-container">
<el-form
:model="queryParams"
v-show="showSearch"
ref="queryForm"
:inline="true"
v-show="showSearch"
:model="queryParams"
class="main-search-card"
label-width="68px"
>
<el-form-item label="字典名称" prop="dictType">
@ -20,14 +21,14 @@
<el-form-item label="字典标签" prop="dictLabel">
<el-input
v-model="queryParams.dictLabel"
placeholder="请输入字典标签"
clearable
placeholder="请输入字典标签"
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-select v-model="queryParams.status" placeholder="数据状态" clearable size="small">
<el-select v-model="queryParams.status" clearable placeholder="数据状态" size="small">
<el-option
v-for="dict in statusOptions"
:key="dict.dictValue"
@ -37,20 +38,20 @@
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<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-form-item>
</el-form>
<div class="main-content-card">
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['system:dict:add']"
icon="el-icon-plus"
plain
size="mini"
type="primary"
@click="handleAdd"
>新增</el-button>
</el-col>
<!-- <el-col :span="1.5">
@ -66,12 +67,12 @@
</el-col> -->
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['system:dict:export']"
icon="el-icon-download"
plain
size="mini"
type="warning"
@click="handleExport"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
@ -83,43 +84,43 @@
:default-sort="{prop: 'createTime', order: 'descending'}"
@sort-change="sortChange"
>
<el-table-column type="index" label="序号" align="center" :index="indexFormatter" width="80px"></el-table-column>
<el-table-column label="字典标签" align="left" prop="dictLabel" />
<el-table-column label="字典键值" align="left" prop="dictValue" />
<el-table-column label="字典排序" align="center" width="100" prop="dictSort" />
<el-table-column :index="indexFormatter" align="center" label="序号" type="index" width="80px"></el-table-column>
<el-table-column align="left" label="字典标签" prop="dictLabel" />
<el-table-column align="left" label="字典键值" prop="dictValue" />
<el-table-column align="center" label="字典排序" prop="dictSort" width="100" />
<el-table-column
label="状态"
align="center"
width="100"
prop="status"
:formatter="statusFormat"
align="center"
label="状态"
prop="status"
width="100"
/>
<el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" />
<el-table-column label="创建时间" align="center" sortable="custom" prop="createTime" width="160">
<el-table-column :show-overflow-tooltip="true" align="center" label="备注" prop="remark" />
<el-table-column align="center" label="创建时间" prop="createTime" sortable="custom" width="160">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column
label="操作"
align="center"
width="100px"
class-name="small-padding fixed-width"
label="操作"
width="100px"
>
<template slot-scope="scope">
<el-button
v-hasPermi="['system:dict:edit']"
icon="el-icon-edit"
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['system:dict:edit']"
>修改</el-button>
<el-button
v-hasPermi="['system:dict:remove']"
icon="el-icon-delete"
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['system:dict:remove']"
>删除</el-button>
</template>
</el-table-column>
@ -127,14 +128,14 @@
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
:page.sync="queryParams.pageNum"
:total="total"
@pagination="getList"
/>
</div>
<!-- 添加或修改参数配置对话框 -->
<el-dialog class="eldialog-wrap" :close-on-click-modal="false" :title="title" :visible.sync="open" width="500px">
<el-dialog :close-on-click-modal="false" :title="title" :visible.sync="open" class="eldialog-wrap" width="500px">
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-form-item label="字典类型:">
<el-input v-model="form.dictType" :disabled="true" />
@ -147,10 +148,10 @@
</el-form-item>
<el-form-item label="显示排序:" prop="dictSort">
<el-input-number
style="width: 100%;"
v-model="form.dictSort"
controls-position="right"
:min="0"
controls-position="right"
style="width: 100%;"
/>
</el-form-item>
<el-form-item label="状态:" prop="status">
@ -163,7 +164,7 @@
</el-radio-group>
</el-form-item>
<el-form-item label="备注:" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容"></el-input>
<el-input v-model="form.remark" placeholder="请输入内容" type="textarea"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">

View File

@ -1,8 +1,8 @@
<template>
<div class="app-container">
<el-row :gutter="40">
<el-row :gutter="20">
<!--部门数据-->
<el-col :span="4" :xs="24" class="main-search-card">
<el-col :span="4" :xs="24" class="main-search-card" style="min-height: 500px">
<div class="head-container">
<el-input
v-model="deptName"