完善设备授权

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

@@ -47,6 +47,18 @@ public class DeviceController extends BaseController
return getDataTable(deviceService.selectDeviceList(device)); return getDataTable(deviceService.selectDeviceList(device));
} }
/**
* 查询未分配授权码设备列表
*/
@PreAuthorize("@ss.hasPermi('iot:device:list')")
@GetMapping("/unAuthlist")
@ApiOperation("设备分页列表")
public TableDataInfo unAuthlist(Device device)
{
startPage();
return getDataTable(deviceService.selectUnAuthDeviceList(device));
}
/** /**
* 查询分组可添加设备 * 查询分组可添加设备
*/ */

View File

@@ -89,6 +89,14 @@ public interface DeviceMapper
*/ */
public List<Device> selectDeviceList(Device device); public List<Device> selectDeviceList(Device device);
/**
* 查询未分配授权码设备列表
*
* @param device 设备
* @return 设备集合
*/
public List<Device> selectUnAuthDeviceList(Device device);
/** /**
* 查询分组可添加设备分页列表 * 查询分组可添加设备分页列表
* *

View File

@@ -79,6 +79,14 @@ public interface IDeviceService
*/ */
public List<Device> selectDeviceList(Device device); public List<Device> selectDeviceList(Device device);
/**
* 查询未分配授权码设备列表
*
* @param device 设备
* @return 设备集合
*/
public List<Device> selectUnAuthDeviceList(Device device);
/** /**
* 查询分组可添加设备分页列表 * 查询分组可添加设备分页列表
* *

View File

@@ -251,6 +251,28 @@ public class DeviceServiceImpl implements IDeviceService {
return deviceMapper.selectDeviceList(device); return deviceMapper.selectDeviceList(device);
} }
/**
* 查询未分配授权码设备列表
*
* @param device 设备
* @return 设备
*/
@Override
public List<Device> selectUnAuthDeviceList(Device device) {
SysUser user = getLoginUser().getUser();
List<SysRole> roles=user.getRoles();
for(int i=0;i<roles.size();i++){
if(roles.get(i).getRoleKey().equals("tenant")){
// 租户查看产品下所有设备
device.setTenantId(user.getUserId());
}else if (roles.get(i).getRoleKey().equals("general")){
// 用户查看自己设备
device.setUserId(user.getUserId());
}
}
return deviceMapper.selectUnAuthDeviceList(device);
}
/** /**
* 查询分组可添加设备分页列表(分组用户与设备用户匹配) * 查询分组可添加设备分页列表(分组用户与设备用户匹配)
* *

View File

@@ -77,8 +77,8 @@ public class ProductAuthorizeServiceImpl implements IProductAuthorizeService {
if(productAuthorize.getDeviceId()!=null && productAuthorize.getDeviceId()!=0){ if(productAuthorize.getDeviceId()!=null && productAuthorize.getDeviceId()!=0){
// 1=未使用2=使用中 // 1=未使用2=使用中
productAuthorize.setStatus(2); productAuthorize.setStatus(2);
}
productAuthorize.setUpdateTime(DateUtils.getNowDate()); productAuthorize.setUpdateTime(DateUtils.getNowDate());
}
return productAuthorizeMapper.updateProductAuthorize(productAuthorize); return productAuthorizeMapper.updateProductAuthorize(productAuthorize);
} }

View File

@@ -126,6 +126,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by create_time desc order by create_time desc
</select> </select>
<select id="selectUnAuthDeviceList" parameterType="com.ruoyi.iot.domain.Device" resultMap="DeviceResult">
select d.device_id, d.device_name, d.product_id, d.product_name, d.user_id, d.user_name, d.tenant_id, d.tenant_name,
d.serial_number, d.firmware_version, d.status,d.is_shadow ,d.location_way,d.active_time, d.img_url,a.device_id as auth_device_id
from iot_device d
left join iot_product_authorize a on a.device_id=d.device_id
<where>
<if test="1==1"> and ISNULL(a.device_id)</if>
<if test="deviceName != null and deviceName != ''"> and d.device_name like concat('%', #{deviceName}, '%')</if>
<if test="productId != null "> and d.product_id = #{productId}</if>
<if test="productName != null and productName != ''"> and d.product_name like concat('%', #{productName}, '%')</if>
<if test="userId != null "> and d.user_id = #{userId}</if>
<if test="userName != null and userName != ''"> and d.user_name like concat('%', #{userName}, '%')</if>
<if test="tenantId != null "> and d.tenant_id = #{tenantId}</if>
<if test="tenantName != null and tenantName != ''"> and d.tenant_name like concat('%', #{tenantName}, '%')</if>
<if test="serialNumber != null and serialNumber != ''"> and d.serial_number = #{serialNumber}</if>
<if test="status != null "> and d.status = #{status}</if>
<if test="params.beginActiveTime != null and params.beginActiveTime != '' and params.endActiveTime != null and params.endActiveTime != ''"> and d.active_time between #{params.beginActiveTime} and #{params.endActiveTime}</if>
</where>
order by d.create_time desc
</select>
<select id="selectDeviceListByGroup" parameterType="com.ruoyi.iot.domain.Device" resultMap="DeviceResult"> <select id="selectDeviceListByGroup" parameterType="com.ruoyi.iot.domain.Device" resultMap="DeviceResult">
select d.device_id, d.device_name, d.product_name, d.user_name, d.serial_number, d.firmware_version, d.status,d.rssi,d.is_shadow , select d.device_id, d.device_name, d.product_name, d.user_name, d.serial_number, d.firmware_version, d.status,d.rssi,d.is_shadow ,
d.location_way, d.active_time,d.network_address,d.longitude,latitude d.location_way, d.active_time,d.network_address,d.longitude,latitude
@@ -152,6 +173,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<where> <where>
<if test="userId != null "> and u.user_id = #{userId}</if> <if test="userId != null "> and u.user_id = #{userId}</if>
<if test="tenantId != null "> and d.tenant_id = #{tenantId}</if> <if test="tenantId != null "> and d.tenant_id = #{tenantId}</if>
<if test="productId != null "> and d.product_id = #{productId}</if>
</where> </where>
</select> </select>

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) { export function listDeviceByGroup(query) {
return request({ return request({

View File

@@ -1,6 +1,6 @@
<template> <template>
<div style="padding:6px;"> <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 :model="queryParams" ref="queryForm" :inline="true" label-width="68px" style="margin-bottom:-20px;">
<el-form-item label="分类名称" prop="categoryName"> <el-form-item label="分类名称" prop="categoryName">
<el-input v-model="queryParams.categoryName" placeholder="请输入产品分类名称" clearable size="small" @keyup.enter.native="handleQuery" /> <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-item>
</el-form> </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"> <el-table-column label="选择" width="50" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<input type="radio" :checked="scope.row.isSelect" name="product" /> <input type="radio" :checked="scope.row.isSelect" name="product" />
@@ -122,7 +122,7 @@ export default {
this.handleQuery(); this.handleQuery();
}, },
/** 单选数据 */ /** 单选数据 */
handleCurrentChange(product) { rowClick(product) {
if (product != null) { if (product != null) {
this.setRadioSelected(product.productId); this.setRadioSelected(product.productId);
this.product = product; this.product = product;

View File

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

View File

@@ -1,38 +1,15 @@
<template> <template>
<div style="padding-left:20px;"> <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-row :gutter="10" class="mb8">
<el-col :span="1.5"> <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-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['iot:alert:add']">新增</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <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>
<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-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 type="selection" width="55" align="center" />
<el-table-column label="告警ID" align="center" prop="alertId" /> <el-table-column label="告警ID" align="center" prop="alertId" />
<el-table-column label="告警名称" align="center" prop="alertName" /> <el-table-column label="告警名称" align="center" prop="alertName" />

View File

@@ -3,7 +3,7 @@
<el-row :gutter="10"> <el-row :gutter="10">
<el-col :span="14"> <el-col :span="14">
<el-tag type="danger" style="margin-left:15px;">该功能暂不可用,后面版本发布</el-tag> <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="modelName" />
<el-table-column label="标识符" align="center" prop="identifier" /> <el-table-column label="标识符" align="center" prop="identifier" />
<el-table-column label="物模型类别" align="center" prop="type"> <el-table-column label="物模型类别" align="center" prop="type">

View File

@@ -4,9 +4,9 @@
<el-form-item label="设备编号" prop="serialNumber"> <el-form-item label="设备编号" prop="serialNumber">
<el-input v-model="queryParams.serialNumber" placeholder="请输入设备编号" clearable size="small" @keyup.enter.native="handleQuery" /> <el-input v-model="queryParams.serialNumber" placeholder="请输入设备编号" clearable size="small" @keyup.enter.native="handleQuery" />
</el-form-item> </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-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-form-item label="授权码" prop="authorizeCode">
<el-input v-model="queryParams.authorizeCode" placeholder="请输入授权码" clearable size="small" @keyup.enter.native="handleQuery" /> <el-input v-model="queryParams.authorizeCode" placeholder="请输入授权码" clearable size="small" @keyup.enter.native="handleQuery" />
</el-form-item> </el-form-item>
@@ -31,15 +31,22 @@
<el-col :span="1.5"> <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-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>
<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-col :span="1.5">
<el-link type="info" style="padding-top:5px" :underline="false">Tips双击可以复制授权码</el-link> <el-link type="info" style="padding-top:5px" :underline="false">Tips双击可以复制授权码</el-link>
</el-col> </el-col>
<right-toolbar @queryTable="getList"></right-toolbar>
</el-row> </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 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"> <template slot-scope="scope">
<dict-tag :options="dict.type.iot_auth_status" :value="scope.row.status" /> <dict-tag :options="dict.type.iot_auth_status" :value="scope.row.status" />
</template> </template>
@@ -47,8 +54,6 @@
<el-table-column label="授权码" width="320" align="center" prop="authorizeCode" /> <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="设备ID" width="75" align="center" prop="deviceId" />
<el-table-column label="设备编号" width="150" align="center" prop="serialNumber" /> <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"> <el-table-column label="授权时间" align="center" prop="updateTime" width="180">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d} {h}:{m}:{s}') }}</span> <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" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope"> <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> <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> </template>
</el-table-column> </el-table-column>
@@ -65,25 +71,43 @@
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" /> <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-dialog :title="title" :visible.sync="open" :width="editWidth" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> <div v-if="editType=='auth'">
<el-form-item label="设备ID" prop="deviceId"> <div class="el-divider el-divider--horizontal" style="margin-top: -25px;"></div>
<el-input v-model="form.deviceId" placeholder="请输入设备ID" onkeyup="value=value.replace(/[^\d]/g,'')" /> <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>
<el-form-item label="设备编号" prop="serialNumber"> <el-form-item label="设备编号" prop="serialNumber" style="margin:0 30px;">
<el-input v-model="form.serialNumber" placeholder="请输入设备编号" /> <el-input v-model="deviceParams.serialNumber" placeholder="请输入设备编号" clearable size="small" @keyup.enter.native="handleQuery" style="width:150px;" />
</el-form-item> </el-form-item>
<el-form-item label="用户ID" prop="userId"> <el-form-item>
<el-input v-model="form.userId" placeholder="请输入用户ID" onkeyup="value=value.replace(/[^\d]/g,'')" max="" /> <el-button type="primary" icon="el-icon-search" size="mini" @click="handleDeviceQuery">搜索</el-button>
</el-form-item> <el-button icon="el-icon-refresh" size="mini" @click="resetDeviceQuery">重置</el-button>
<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-item>
</el-form> </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"> <div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button> <el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button> <el-button @click="cancel"> </el-button>
@@ -103,6 +127,9 @@
</style> </style>
<script> <script>
import {
listUnAuthDevice,
} from "@/api/iot/device";
import { import {
listAuthorize, listAuthorize,
getAuthorize, getAuthorize,
@@ -110,12 +137,9 @@ import {
addProductAuthorizeByNum, addProductAuthorizeByNum,
updateAuthorize updateAuthorize
} from "@/api/iot/authorize"; } from "@/api/iot/authorize";
import {
isNumberStr
} from '@/utils/index'
export default { export default {
name: "product-authorize", name: "product-authorize",
dicts: ['iot_auth_status'], dicts: ['iot_auth_status', 'iot_device_status'],
props: { props: {
product: { product: {
type: Object, type: Object,
@@ -128,12 +152,41 @@ export default {
this.productInfo = newVal; this.productInfo = newVal;
if (this.productInfo && this.productInfo.productId != 0) { if (this.productInfo && this.productInfo.productId != 0) {
this.queryParams.productId = this.productInfo.productId; this.queryParams.productId = this.productInfo.productId;
this.deviceParams.productId = this.productInfo.productId;
this.getList(); this.getList();
this.getDeviceList();
} }
} }
}, },
data() { data() {
return { 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, loading: true,
// 选中数组 // 选中数组
@@ -170,16 +223,56 @@ export default {
form: {}, form: {},
// 产品 // 产品
productInfo: {}, productInfo: {},
// 表单校验
rules: {
}
}; };
}, },
created() { created() {
}, },
methods: { 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() { getList() {
this.loading = true; this.loading = true;
@@ -200,9 +293,9 @@ export default {
authorizeId: null, authorizeId: null,
authorizeCode: null, authorizeCode: null,
productId: "", productId: "",
userId: "",
deviceId: null, deviceId: null,
serialNumber: null, serialNumber: null,
userId: "",
userName: null, userName: null,
delFlag: null, delFlag: null,
createBy: null, createBy: null,
@@ -211,6 +304,7 @@ export default {
updateTime: null, updateTime: null,
remark: null remark: null
}; };
this.device = {};
this.resetForm("form"); this.resetForm("form");
}, },
/** 搜索按钮操作 */ /** 搜索按钮操作 */
@@ -262,28 +356,50 @@ export default {
}); });
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row, editType) {
this.reset(); this.reset();
this.editType = editType;
const authorizeId = row.authorizeId || this.ids const authorizeId = row.authorizeId || this.ids
getAuthorize(authorizeId).then(response => { getAuthorize(authorizeId).then(response => {
this.form = response.data; this.form = response.data;
this.open = true; 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() { submitForm() {
this.$refs["form"].validate(valid => { if (this.editType == 'auth') {
if (valid) { if (this.form.deviceId != null && this.form.deviceId != 0) {
if (this.form.authorizeId != null) {
updateAuthorize(this.form).then(response => { updateAuthorize(this.form).then(response => {
this.$modal.msgSuccess("修改成功"); 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.open = false;
this.getList(); this.getList();
}); });
} }
}
});
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
@@ -301,12 +417,6 @@ export default {
...this.queryParams ...this.queryParams
}, `authorize_${new Date().getTime()}.xlsx`) }, `authorize_${new Date().getTime()}.xlsx`)
}, },
handleChange(e) {
console.log(currentValue)
if (!isNumberStr(currentValue)) {
this.$modal.msgSuccess("只能输入数字");
}
},
//禁用有绑定设备的复选框 //禁用有绑定设备的复选框
selectable(row) { selectable(row) {
return row.deviceId != null ? false : true; return row.deviceId != null ? false : true;

View File

@@ -82,7 +82,7 @@
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="" name="productAuthorize" :disabled="form.productId==0 || form.isAuthorize==0"> <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" /> <product-authorize ref="productAuthorize" :product="form" />
</el-tab-pane> </el-tab-pane>

View File

@@ -1,22 +1,15 @@
<template> <template>
<div style="padding-left:20px;"> <div style="padding-left:20px;">
<el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px" style="margin-bottom:-20px;" v-show="showSearch"> <el-row :gutter="10" class="mb8">
<el-form-item label="固件名称" prop="firmwareName"> <el-col :span="1.5">
<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-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['iot:firmware:add']">新增</el-button> <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['iot:firmware:add']">新增</el-button>
</el-form-item> </el-col>
</el-form> <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="firmwareName" />
<el-table-column label="固件版本" align="center" prop="version"> <el-table-column label="固件版本" align="center" prop="version">
<template slot-scope="scope"> <template slot-scope="scope">
@@ -41,7 +34,6 @@
</template> </template>
</el-table-column> </el-table-column>
</el-table> </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> <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.queryParams.productId = this.productInfo.productId;
this.form.productId=this.productInfo.productId; this.form.productId=this.productInfo.productId;
this.form.productName=this.productInfo.productName; this.form.productName=this.productInfo.productName;
console.log(this.form)
this.getList(); this.getList();
} }
} }
@@ -130,7 +121,7 @@ export default {
// 查询参数 // 查询参数
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 100,
firmwareName: null, firmwareName: null,
productName: null, productName: null,
productId: 0, productId: 0,
@@ -293,7 +284,6 @@ export default {
}, },
// 获取文件路径 // 获取文件路径
getFilePath(data) { getFilePath(data) {
console.log(data);
this.form.filePath = 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-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-if="productInfo.status==1">新增</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <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>
<el-col :span="1.5"> <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-button type="info" plain icon="el-icon-view" size="mini" @click="handleOpenThingsModel">查看物模型</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-link type="danger" style="padding-top:5px" :underline="false"> 注意标识符不能重复</el-link> <el-link type="danger" style="padding-top:5px" :underline="false"> 注意标识符不能重复</el-link>
</el-col> </el-col>
<right-toolbar @queryTable="getList"></right-toolbar>
</el-row> </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="modelName" />
<el-table-column label="标识符" align="center" prop="identifier" /> <el-table-column label="标识符" align="center" prop="identifier" />
<el-table-column label="首页显示" align="center" prop="isTop" width="100"> <el-table-column label="首页显示" align="center" prop="isTop" width="100">