完善设备授权

This commit is contained in:
kerwincui
2022-06-08 23:57:40 +08:00
parent f2b80eaf2f
commit 9dd368c883
16 changed files with 278 additions and 118 deletions

View File

@@ -9,6 +9,15 @@ export function listDevice(query) {
})
}
// 查询未授权设备列表
export function listUnAuthDevice(query) {
return request({
url: '/iot/device/unAuthlist',
method: 'get',
params: query
})
}
// 查询分组可添加设备分页列表
export function listDeviceByGroup(query) {
return request({

View File

@@ -1,6 +1,6 @@
<template>
<div style="padding:6px;">
<el-card v-show="showSearch" style="margin-bottom:6px;">
<el-card v-show="showSearch" style="margin-bottom:5px;">
<el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px" style="margin-bottom:-20px;">
<el-form-item label="分类名称" prop="categoryName">
<el-input v-model="queryParams.categoryName" placeholder="请输入产品分类名称" clearable size="small" @keyup.enter.native="handleQuery" />

View File

@@ -12,7 +12,7 @@
</el-form-item>
</el-form>
<el-table v-loading="loading" ref="singleTable" :data="productList" @current-change="handleCurrentChange" highlight-current-row border size="mini">
<el-table v-loading="loading" ref="singleTable" :data="productList" @row-click="rowClick" highlight-current-row size="mini">
<el-table-column label="选择" width="50" align="center">
<template slot-scope="scope">
<input type="radio" :checked="scope.row.isSelect" name="product" />
@@ -122,7 +122,7 @@ export default {
this.handleQuery();
},
/** 单选数据 */
handleCurrentChange(product) {
rowClick(product) {
if (product != null) {
this.setRadioSelected(product.productId);
this.product = product;

View File

@@ -1,6 +1,6 @@
<template>
<div style="padding:6px;">
<el-card style="margin-bottom:6px;">
<el-card style="margin-bottom:5px;">
<el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px" style="margin-bottom:-20px;">
<el-form-item label="产品名称" prop="productName">
<el-input v-model="queryParams.productName" placeholder="请输入产品名称" clearable size="small" @keyup.enter.native="handleQuery" />

View File

@@ -1,38 +1,15 @@
<template>
<div style="padding-left:20px;">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="告警名称" prop="alertName">
<el-input v-model="queryParams.alertName" placeholder="请输入告警名称" clearable size="small" @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="告警级别" prop="alertLevel">
<el-select v-model="queryParams.alertLevel" placeholder="请选择告警级别" clearable size="small">
<el-option v-for="dict in dict.type.iot_alert_level" :key="dict.value" :label="dict.label" :value="dict.value" />
</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-refresh" size="mini" @click="resetQuery">重置</el-button>
<el-tag type="danger" style="margin-left:15px;">该功能暂不可用,后面版本发布</el-tag>
</el-form-item>
</el-form>
<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="['iot:alert:add']">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate" v-hasPermi="['iot:alert:edit']">修改</el-button>
<el-button type="warning" plain icon="el-icon-refresh" size="mini" @click="getList">刷新</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['iot:alert:remove']">删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['iot:alert:export']">导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="alertList" @selection-change="handleSelectionChange" border>
<el-table v-loading="loading" :data="alertList" @selection-change="handleSelectionChange" border size="mini">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="告警ID" align="center" prop="alertId" />
<el-table-column label="告警名称" align="center" prop="alertName" />

View File

@@ -3,7 +3,7 @@
<el-row :gutter="10">
<el-col :span="14">
<el-tag type="danger" style="margin-left:15px;">该功能暂不可用,后面版本发布</el-tag>
<el-table v-loading="loading" :data="modelList" border style="margin-bottom:60px;margin-top:20px;">
<el-table v-loading="loading" :data="modelList" border style="margin-bottom:60px;margin-top:20px;" size="small">
<el-table-column label="名称" align="center" prop="modelName" />
<el-table-column label="标识符" align="center" prop="identifier" />
<el-table-column label="物模型类别" align="center" prop="type">

View File

@@ -4,9 +4,9 @@
<el-form-item label="设备编号" prop="serialNumber">
<el-input v-model="queryParams.serialNumber" placeholder="请输入设备编号" clearable size="small" @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="用户名称" prop="userName">
<!-- <el-form-item label="用户名称" prop="userName">
<el-input v-model="queryParams.userName" placeholder="请输入用户名称" clearable size="small" @keyup.enter.native="handleQuery" />
</el-form-item>
</el-form-item> -->
<el-form-item label="授权码" prop="authorizeCode">
<el-input v-model="queryParams.authorizeCode" placeholder="请输入授权码" clearable size="small" @keyup.enter.native="handleQuery" />
</el-form-item>
@@ -31,15 +31,22 @@
<el-col :span="1.5">
<el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple || productInfo.status==2" @click="handleDelete" v-hasPermi="['iot:authorize:remove']">删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['iot:category:export']">导出</el-button>
</el-col>
<el-col :span="1.5">
<el-link type="info" style="padding-top:5px" :underline="false">Tips双击可以复制授权码</el-link>
</el-col>
<right-toolbar @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="authorizeList" @selection-change="handleSelectionChange" @cell-dblclick="celldblclick">
<el-table v-loading="loading" :data="authorizeList" @selection-change="handleSelectionChange" @cell-dblclick="celldblclick" size="small">
<el-table-column type="selection" :selectable="selectable" width="55" align="center" />
<el-table-column label="状态" align="center" prop="active" width="80">
<el-table-column label="状态" align="center" prop="active" width="100">
<template slot-scope="scope">
<dict-tag :options="dict.type.iot_auth_status" :value="scope.row.status" />
</template>
</el-table-column>
<el-table-column label="状态" align="center" prop="active" width="100">
<template slot-scope="scope">
<dict-tag :options="dict.type.iot_auth_status" :value="scope.row.status" />
</template>
@@ -47,8 +54,6 @@
<el-table-column label="授权码" width="320" align="center" prop="authorizeCode" />
<el-table-column label="设备ID" width="75" align="center" prop="deviceId" />
<el-table-column label="设备编号" width="150" align="center" prop="serialNumber" />
<el-table-column label="用户ID" width="75" align="center" prop="userId" />
<el-table-column label="用户名称" align="center" prop="userName" />
<el-table-column label="授权时间" align="center" prop="updateTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d} {h}:{m}:{s}') }}</span>
@@ -57,7 +62,8 @@
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['iot:authorize:edit']">修改</el-button>
<el-button size="mini" type="text" icon="el-icon-s-check" @click="handleUpdate(scope.row,'auth')" v-hasPermi="['iot:authorize:edit']" v-if="scope.row.status==1 && !scope.row.deviceId">设备授权</el-button>
<el-button size="mini" type="text" icon="el-icon-notebook-1" @click="handleUpdate(scope.row,'remark')" v-hasPermi="['iot:authorize:edit']">备注</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['iot:authorize:remove']" v-if="!scope.row.deviceId">删除</el-button>
</template>
</el-table-column>
@@ -65,25 +71,43 @@
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
<!-- 添加或修改产品授权码对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="设备ID" prop="deviceId">
<el-input v-model="form.deviceId" placeholder="请输入设备ID" onkeyup="value=value.replace(/[^\d]/g,'')" />
</el-form-item>
<el-form-item label="设备编号" prop="serialNumber">
<el-input v-model="form.serialNumber" placeholder="请输入设备编号" />
</el-form-item>
<el-form-item label="用户ID" prop="userId">
<el-input v-model="form.userId" placeholder="请输入用户ID" onkeyup="value=value.replace(/[^\d]/g,'')" max="" />
</el-form-item>
<el-form-item label="用户名称" prop="userName">
<el-input v-model="form.userName" placeholder="请输入用户名称" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
</el-form-item>
</el-form>
<!-- 设备授权和授权备注对话框 -->
<el-dialog :title="title" :visible.sync="open" :width="editWidth" append-to-body>
<div v-if="editType=='auth'">
<div class="el-divider el-divider--horizontal" style="margin-top: -25px;"></div>
<el-form :model="deviceParams" ref="queryDeviceForm" :inline="true" label-width="68px">
<el-form-item label="设备名称" prop="deviceName">
<el-input v-model="deviceParams.deviceName" placeholder="请输入设备名称" clearable size="small" @keyup.enter.native="handleQuery" style="width:150px;" />
</el-form-item>
<el-form-item label="设备编号" prop="serialNumber" style="margin:0 30px;">
<el-input v-model="deviceParams.serialNumber" placeholder="请输入设备编号" clearable size="small" @keyup.enter.native="handleQuery" style="width:150px;" />
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleDeviceQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetDeviceQuery">重置</el-button>
</el-form-item>
</el-form>
<el-table v-loading="deviceLoading" :data="deviceList" ref="singleTable" size="mini" @row-click="rowClick" highlight-current-row>
<el-table-column label="选择" width="50" align="center">
<template slot-scope="scope">
<input type="radio" :checked="scope.row.isSelect" name="device" />
</template>
</el-table-column>
<el-table-column label="设备名称" align="center" prop="deviceName" />
<el-table-column label="设备ID" align="center" prop="deviceId" />
<el-table-column label="设备编号" align="center" prop="serialNumber" />
<el-table-column label="用户名称" align="center" prop="userName" />
<el-table-column label="设备状态" align="center" prop="status">
<template slot-scope="scope">
<dict-tag :options="dict.type.iot_device_status" :value="scope.row.status" />
</template>
</el-table-column>
</el-table>
<pagination v-show="deviceTotal>0" :total="deviceTotal" :page.sync="deviceParams.pageNum" :limit.sync="deviceParams.pageSize" @pagination="getDeviceList" />
</div>
<div v-if="editType=='remark'">
<el-input v-model="form.remark" type="textarea" rows="4" placeholder="请输入内容" />
</div>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
@@ -103,6 +127,9 @@
</style>
<script>
import {
listUnAuthDevice,
} from "@/api/iot/device";
import {
listAuthorize,
getAuthorize,
@@ -110,12 +137,9 @@ import {
addProductAuthorizeByNum,
updateAuthorize
} from "@/api/iot/authorize";
import {
isNumberStr
} from '@/utils/index'
export default {
name: "product-authorize",
dicts: ['iot_auth_status'],
dicts: ['iot_auth_status', 'iot_device_status'],
props: {
product: {
type: Object,
@@ -128,12 +152,41 @@ export default {
this.productInfo = newVal;
if (this.productInfo && this.productInfo.productId != 0) {
this.queryParams.productId = this.productInfo.productId;
this.deviceParams.productId = this.productInfo.productId;
this.getList();
this.getDeviceList();
}
}
},
data() {
return {
// 设备遮罩层
deviceLoading: true,
// 总条数
deviceTotal: 0,
// 设备表格数据
deviceList: [],
// 查询参数
deviceParams: {
pageNum: 1,
pageSize: 10,
userId: null,
deviceName: null,
productId: 0,
productName: null,
userId: null,
userName: null,
tenantId: null,
tenantName: null,
serialNumber: null,
status: null,
networkAddress: null,
activeTime: null,
},
// 编辑类型remark=备注、auth=设备授权
editType: '',
// 编辑界面宽度
editWidth:'500px',
// 遮罩层
loading: true,
// 选中数组
@@ -169,17 +222,57 @@ export default {
// 表单参数
form: {},
// 产品
productInfo:{},
// 表单校验
rules: {
}
productInfo: {},
};
},
created() {
},
methods: {
/** 查询设备列表 */
getDeviceList() {
this.deviceLoading = true;
this.deviceParams.params = {};
listUnAuthDevice(this.deviceParams).then(response => {
this.deviceList = response.rows;
this.deviceTotal = response.total;
this.deviceLoading = false;
});
},
/** 搜索按钮操作 */
handleDeviceQuery() {
this.deviceParams.pageNum = 1;
this.getDeviceList();
},
/** 重置按钮操作 */
resetDeviceQuery() {
this.resetForm("queryDeviceForm");
this.handleDeviceQuery();
},
/** 单选数据 */
rowClick(device) {
if (device != null) {
this.setRadioSelected(device.deviceId);
// 赋值
this.form.userId = device.userId;
this.form.userName = device.userName;
this.form.deviceId = device.deviceId;
this.form.serialNumber = device.serialNumber;
}
},
/** 设置单选按钮选中 */
setRadioSelected(deviceId) {
for (let i = 0; i < this.deviceList.length; i++) {
let device = this.deviceList[i];
if (this.deviceList[i].deviceId == deviceId) {
device.isSelect = true;
this.$set(this.deviceList, i, device);
} else {
device.isSelect = false;
this.$set(this.deviceList, i, device);
}
}
},
/** 查询产品授权码列表 */
getList() {
this.loading = true;
@@ -200,9 +293,9 @@ export default {
authorizeId: null,
authorizeCode: null,
productId: "",
userId: "",
deviceId: null,
serialNumber: null,
userId: "",
userName: null,
delFlag: null,
createBy: null,
@@ -211,6 +304,7 @@ export default {
updateTime: null,
remark: null
};
this.device = {};
this.resetForm("form");
},
/** 搜索按钮操作 */
@@ -262,28 +356,50 @@ export default {
});
},
/** 修改按钮操作 */
handleUpdate(row) {
handleUpdate(row, editType) {
this.reset();
this.editType = editType;
const authorizeId = row.authorizeId || this.ids
getAuthorize(authorizeId).then(response => {
this.form = response.data;
this.open = true;
this.title = "编辑授权码";
if (this.editType == 'auth') {
this.title = "选择设备";
this.editWidth="800px";
} else {
this.title = "备注信息";
this.editWidth="500px";
}
// 取消选中
for (let i = 0; i < this.deviceList.length; i++) {
// this.deviceList[i].isSelect=false;
let device = this.deviceList[i];
device.isSelect = false;
// this.deviceList.splice(i,1,device )
this.$set(this.deviceList, i, device);
}
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.authorizeId != null) {
updateAuthorize(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
}
if (this.editType == 'auth') {
if (this.form.deviceId != null && this.form.deviceId != 0) {
updateAuthorize(this.form).then(response => {
this.$modal.msgSuccess("设备授权成功");
this.open = false;
this.getList();
});
} else {
this.$modal.msg("请选择要授权的设备");
}
});
} else if (this.form.authorizeId != null) {
updateAuthorize(this.form).then(response => {
this.$modal.msgSuccess("备注成功");
this.open = false;
this.getList();
});
}
},
/** 删除按钮操作 */
handleDelete(row) {
@@ -301,12 +417,6 @@ export default {
...this.queryParams
}, `authorize_${new Date().getTime()}.xlsx`)
},
handleChange(e) {
console.log(currentValue)
if (!isNumberStr(currentValue)) {
this.$modal.msgSuccess("只能输入数字");
}
},
//禁用有绑定设备的复选框
selectable(row) {
return row.deviceId != null ? false : true;

View File

@@ -82,7 +82,7 @@
</el-tab-pane>
<el-tab-pane label="" name="productAuthorize" :disabled="form.productId==0 || form.isAuthorize==0">
<span slot="label">设备授权</span>
<span slot="label">产品授权</span>
<product-authorize ref="productAuthorize" :product="form" />
</el-tab-pane>

View File

@@ -1,22 +1,15 @@
<template>
<div style="padding-left:20px;">
<el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px" style="margin-bottom:-20px;" v-show="showSearch">
<el-form-item label="固件名称" prop="firmwareName">
<el-input v-model="queryParams.firmwareName" placeholder="请输入固件名称" clearable size="small" @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="产品名称" prop="productName">
<el-input v-model="queryParams.productName" placeholder="请输入产品名称" clearable size="small" @keyup.enter.native="handleQuery" />
</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-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
<el-form-item style="float:right;">
<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="['iot:firmware:add']">新增</el-button>
</el-form-item>
</el-form>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-refresh" size="mini" @click="getList">刷新</el-button>
</el-col>
</el-row>
<el-table v-loading="loading" :data="firmwareList" @selection-change="handleSelectionChange">
<el-table v-loading="loading" :data="firmwareList" @selection-change="handleSelectionChange" size="small">
<el-table-column label="固件名称" align="center" prop="firmwareName" />
<el-table-column label="固件版本" align="center" prop="version">
<template slot-scope="scope">
@@ -41,7 +34,6 @@
</template>
</el-table-column>
</el-table>
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
<!-- 添加或修改产品固件对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
@@ -102,7 +94,6 @@ export default {
this.queryParams.productId = this.productInfo.productId;
this.form.productId=this.productInfo.productId;
this.form.productName=this.productInfo.productName;
console.log(this.form)
this.getList();
}
}
@@ -130,7 +121,7 @@ export default {
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
pageSize: 100,
firmwareName: null,
productName: null,
productId: 0,
@@ -293,7 +284,6 @@ export default {
},
// 获取文件路径
getFilePath(data) {
console.log(data);
this.form.filePath = data;
},

View File

@@ -5,18 +5,20 @@
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-if="productInfo.status==1">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="el-icon-plus" size="mini" @click="handleSelect" v-if="productInfo.status==1">导入通用物模型</el-button>
<el-button type="warning" plain icon="el-icon-refresh" size="mini" @click="getList">刷新</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="info" plain icon="el-icon-plus" size="mini" @click="handleOpenThingsModel">查看物模型</el-button>
<el-button type="success" plain icon="el-icon-upload2" size="mini" @click="handleSelect" v-if="productInfo.status==1">导入通用物模型</el-button>
</el-col>
<el-col :span="1.5">
<el-link type="danger" style="padding-top:5px" :underline="false">注意标识符不能重复</el-link>
<el-button type="info" plain icon="el-icon-view" size="mini" @click="handleOpenThingsModel">查看物模型</el-button>
</el-col>
<el-col :span="1.5">
<el-link type="danger" style="padding-top:5px" :underline="false"> 注意标识符不能重复</el-link>
</el-col>
<right-toolbar @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="modelList" border>
<el-table v-loading="loading" :data="modelList" size="mini">
<el-table-column label="名称" align="center" prop="modelName" />
<el-table-column label="标识符" align="center" prop="identifier" />
<el-table-column label="首页显示" align="center" prop="isTop" width="100">
@@ -143,11 +145,11 @@
<div v-if="form.datatype == 'string'">
<el-form-item label="最大长度" prop="">
<el-row>
<el-col :span="9">
<el-input v-model="form.specs.maxLength" placeholder="例如1024" type="number"/>
</el-col>
<el-col :span="14" :offset="1">字符串的最大长度</el-col>
</el-row>
<el-col :span="9">
<el-input v-model="form.specs.maxLength" placeholder="例如1024" type="number" />
</el-col>
<el-col :span="14" :offset="1">字符串的最大长度</el-col>
</el-row>
</el-form-item>
</div>
@@ -366,7 +368,7 @@ export default {
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const modelId = row.modelId;;
const modelId = row.modelId;;
getModel(modelId).then((response) => {
let tempForm = response.data;
this.open = true;
@@ -382,7 +384,7 @@ export default {
if (!tempForm.specs.arrayType) {
tempForm.specs.arrayType = "int";
}
this.form=tempForm;
this.form = tempForm;
});
},
/**查看物模型 */