mirror of
https://github.com/kerwincui/FastBee.git
synced 2025-10-06 00:27:32 +08:00
界面和细节优化
This commit is contained in:
@@ -150,7 +150,7 @@ public class DeviceController extends BaseController
|
|||||||
@ApiOperation("修改设备")
|
@ApiOperation("修改设备")
|
||||||
public AjaxResult edit(@RequestBody Device device)
|
public AjaxResult edit(@RequestBody Device device)
|
||||||
{
|
{
|
||||||
return toAjax(deviceService.updateDevice(device));
|
return deviceService.updateDevice(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package com.ruoyi.iot.service;
|
package com.ruoyi.iot.service;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.iot.domain.Device;
|
import com.ruoyi.iot.domain.Device;
|
||||||
import com.ruoyi.iot.model.*;
|
import com.ruoyi.iot.model.*;
|
||||||
import com.ruoyi.iot.model.ThingsModels.ThingsModelShadow;
|
import com.ruoyi.iot.model.ThingsModels.ThingsModelShadow;
|
||||||
@@ -129,7 +130,7 @@ public interface IDeviceService
|
|||||||
* @param device 设备
|
* @param device 设备
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int updateDevice(Device device);
|
public AjaxResult updateDevice(Device device);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新设备状态
|
* 更新设备状态
|
||||||
|
@@ -3,8 +3,10 @@ package com.ruoyi.iot.service.impl;
|
|||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.ruoyi.common.constant.Constants;
|
import com.ruoyi.common.constant.Constants;
|
||||||
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.http.HttpUtils;
|
import com.ruoyi.common.utils.http.HttpUtils;
|
||||||
@@ -447,6 +449,12 @@ public class DeviceServiceImpl implements IDeviceService {
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Device insertDevice(Device device) {
|
public Device insertDevice(Device device) {
|
||||||
|
// 设备编号唯一检查
|
||||||
|
Device existDevice=deviceMapper.selectDeviceBySerialNumber(device.getSerialNumber());
|
||||||
|
if(existDevice!=null){
|
||||||
|
log.error("设备编号:"+device.getSerialNumber()+"已经存在了,新增设备失败");
|
||||||
|
return device;
|
||||||
|
}
|
||||||
SysUser sysUser = getLoginUser().getUser();
|
SysUser sysUser = getLoginUser().getUser();
|
||||||
//添加设备
|
//添加设备
|
||||||
device.setCreateTime(DateUtils.getNowDate());
|
device.setCreateTime(DateUtils.getNowDate());
|
||||||
@@ -492,6 +500,12 @@ public class DeviceServiceImpl implements IDeviceService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int insertDeviceAuto(String serialNumber,Long userId,Long productId) {
|
public int insertDeviceAuto(String serialNumber,Long userId,Long productId) {
|
||||||
|
// 设备编号唯一检查
|
||||||
|
Device existDevice=deviceMapper.selectDeviceBySerialNumber(serialNumber);
|
||||||
|
if(existDevice!=null){
|
||||||
|
log.error("设备编号:"+serialNumber+"已经存在了,新增设备失败");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Device device = new Device();
|
Device device = new Device();
|
||||||
int random = (int) (Math.random() * (9000)) + 1000;
|
int random = (int) (Math.random() * (9000)) + 1000;
|
||||||
device.setDeviceName("设备" + random);
|
device.setDeviceName("设备" + random);
|
||||||
@@ -599,7 +613,16 @@ public class DeviceServiceImpl implements IDeviceService {
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int updateDevice(Device device) {
|
public AjaxResult updateDevice(Device device) {
|
||||||
|
// 设备编号唯一检查
|
||||||
|
Device oldDevice=deviceMapper.selectDeviceByDeviceId(device.getDeviceId());
|
||||||
|
if(!oldDevice.getSerialNumber().equals(device.getSerialNumber())){
|
||||||
|
Device existDevice=deviceMapper.selectDeviceBySerialNumber(device.getSerialNumber());
|
||||||
|
if(existDevice!=null){
|
||||||
|
log.error("设备编号:"+device.getSerialNumber()+" 已经存在,新增设备失败");
|
||||||
|
return AjaxResult.success("设备编号:"+device.getSerialNumber()+" 已经存在,修改失败",0);
|
||||||
|
}
|
||||||
|
}
|
||||||
device.setUpdateTime(DateUtils.getNowDate());
|
device.setUpdateTime(DateUtils.getNowDate());
|
||||||
// 未激活状态,可以修改产品以及物模型值
|
// 未激活状态,可以修改产品以及物模型值
|
||||||
if (device.getStatus() == 1) {
|
if (device.getStatus() == 1) {
|
||||||
@@ -608,7 +631,8 @@ public class DeviceServiceImpl implements IDeviceService {
|
|||||||
device.setProductId(null);
|
device.setProductId(null);
|
||||||
device.setProductName(null);
|
device.setProductName(null);
|
||||||
}
|
}
|
||||||
return deviceMapper.updateDevice(device);
|
deviceMapper.updateDevice(device);
|
||||||
|
return AjaxResult.success("修改成功",1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -617,7 +641,9 @@ public class DeviceServiceImpl implements IDeviceService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String generationDeviceNum() {
|
public String generationDeviceNum() {
|
||||||
String number= "D"+toolService.getStringRandom(15);
|
// 设备编号:D + userId + 15位随机字母和数字
|
||||||
|
SysUser user = getLoginUser().getUser();
|
||||||
|
String number= "D"+user.getUserId().toString()+toolService.getStringRandom(10);
|
||||||
int count= deviceMapper.getDeviceNumCount(number);
|
int count= deviceMapper.getDeviceNumCount(number);
|
||||||
if(count==0) {
|
if(count==0) {
|
||||||
return number;
|
return number;
|
||||||
|
@@ -29,6 +29,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="firmwareName != null and firmwareName != ''"> and firmware_name like concat('%', #{firmwareName}, '%')</if>
|
<if test="firmwareName != null and firmwareName != ''"> and firmware_name like concat('%', #{firmwareName}, '%')</if>
|
||||||
<if test="productName != null and productName != ''"> and product_name like concat('%', #{productName}, '%')</if>
|
<if test="productName != null and productName != ''"> and product_name like concat('%', #{productName}, '%')</if>
|
||||||
<if test="tenantId != null and tenantId != ''"> and tenant_id = #{tenantId}</if>
|
<if test="tenantId != null and tenantId != ''"> and tenant_id = #{tenantId}</if>
|
||||||
|
<if test="productId != null"> and product_id = #{productId}</if>
|
||||||
</where>
|
</where>
|
||||||
order by create_time desc
|
order by create_time desc
|
||||||
</select>
|
</select>
|
||||||
|
@@ -350,19 +350,25 @@ export default {
|
|||||||
this.setDeviceStatus();
|
this.setDeviceStatus();
|
||||||
console.log(this.form);
|
console.log(this.form);
|
||||||
updateDevice(this.form).then(response => {
|
updateDevice(this.form).then(response => {
|
||||||
|
if (response.data == 0) {
|
||||||
|
this.$modal.alertError(response.msg);
|
||||||
|
} else {
|
||||||
this.$modal.alertSuccess("修改成功");
|
this.$modal.alertSuccess("修改成功");
|
||||||
this.open = false;
|
|
||||||
this.loadMap();
|
this.loadMap();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
addDevice(this.form).then(response => {
|
addDevice(this.form).then(response => {
|
||||||
this.$modal.alertSuccess("新增成功, 可以烧录sdk到设备了");
|
|
||||||
this.open = false;
|
|
||||||
this.form = response.data;
|
this.form = response.data;
|
||||||
|
if (this.form.deviceId == null || this.form.deviceId == 0) {
|
||||||
|
this.$modal.alertError("设备编号已经存在,添加设备失败");
|
||||||
|
} else {
|
||||||
if (this.form.status == 2) {
|
if (this.form.status == 2) {
|
||||||
this.deviceStatus = 1;
|
this.deviceStatus = 1;
|
||||||
}
|
}
|
||||||
|
this.$modal.alertSuccess("新增成功, 可以烧录sdk到设备了");
|
||||||
this.loadMap();
|
this.loadMap();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -230,6 +230,8 @@ export default {
|
|||||||
open: false,
|
open: false,
|
||||||
// 激活时间范围
|
// 激活时间范围
|
||||||
daterangeActiveTime: [],
|
daterangeActiveTime: [],
|
||||||
|
// 根路径
|
||||||
|
baseUrl: process.env.VUE_APP_BASE_API,
|
||||||
// 查询参数
|
// 查询参数
|
||||||
queryParams: {
|
queryParams: {
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
|
@@ -67,8 +67,9 @@
|
|||||||
|
|
||||||
<!-- 添加或修改设备告警对话框 -->
|
<!-- 添加或修改设备告警对话框 -->
|
||||||
<el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
|
<el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
|
||||||
|
<div class="el-divider el-divider--horizontal" style="margin-top: -25px;"></div>
|
||||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||||
<el-row style="border-bottom:1px solid #ddd;margin-bottom:20px;" :gutter="50">
|
<el-row :gutter="50">
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="告警名称" prop="alertName">
|
<el-form-item label="告警名称" prop="alertName">
|
||||||
<el-input v-model="form.alertName" placeholder="请输入告警名称" />
|
<el-input v-model="form.alertName" placeholder="请输入告警名称" />
|
||||||
@@ -89,8 +90,7 @@
|
|||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<el-row style="border-bottom:1px solid #ddd;margin-bottom:20px;">
|
<el-divider></el-divider>
|
||||||
<el-col :span="24">
|
|
||||||
<el-form-item label="触发器" prop="griggers">
|
<el-form-item label="触发器" prop="griggers">
|
||||||
<el-select v-model="form.condition" placeholder="请选择" size="small" style="margin-bottom:10px;">
|
<el-select v-model="form.condition" placeholder="请选择" size="small" style="margin-bottom:10px;">
|
||||||
<el-option v-for="item in triggerConditions" :key="item.value" :label="item.label" :value="item.value">
|
<el-option v-for="item in triggerConditions" :key="item.value" :label="item.label" :value="item.value">
|
||||||
@@ -179,11 +179,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div>+ <a style="color:#409EFF" @click="addTriggerItem()">添加触发器</a></div>
|
<div>+ <a style="color:#409EFF" @click="addTriggerItem()">添加触发器</a></div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
|
|
||||||
<el-row>
|
<el-divider></el-divider>
|
||||||
<el-col :span="24">
|
|
||||||
<el-form-item label="执行动作">
|
<el-form-item label="执行动作">
|
||||||
<el-row v-for="(item,index) in form.actions" :key="index" style="margin-bottom:10px;">
|
<el-row v-for="(item,index) in form.actions" :key="index" style="margin-bottom:10px;">
|
||||||
<el-col :span="4">
|
<el-col :span="4">
|
||||||
@@ -205,8 +202,6 @@
|
|||||||
</el-row>
|
</el-row>
|
||||||
<div>+ <a style="color:#409EFF" @click="addActionItem()">添加执行动作</a></div>
|
<div>+ <a style="color:#409EFF" @click="addActionItem()">添加执行动作</a></div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
|
|
||||||
</el-form>
|
</el-form>
|
||||||
<div slot="footer" class="dialog-footer">
|
<div slot="footer" class="dialog-footer">
|
||||||
@@ -380,6 +375,8 @@ export default {
|
|||||||
triggers: [],
|
triggers: [],
|
||||||
actions: []
|
actions: []
|
||||||
},
|
},
|
||||||
|
// 产品
|
||||||
|
productInfo: {},
|
||||||
// 表单校验
|
// 表单校验
|
||||||
rules: {
|
rules: {
|
||||||
alertName: [{
|
alertName: [{
|
||||||
|
@@ -70,6 +70,8 @@ export default {
|
|||||||
type: 4,
|
type: 4,
|
||||||
},
|
},
|
||||||
form: {},
|
form: {},
|
||||||
|
// 产品
|
||||||
|
productInfo:{},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@@ -116,7 +118,7 @@ export default {
|
|||||||
top: 45px;
|
top: 45px;
|
||||||
left: 12px;
|
left: 12px;
|
||||||
border: 1px solid #888;
|
border: 1px solid #888;
|
||||||
background-color:rgb(245, 245, 255);
|
background: linear-gradient(303deg, #b2e9fc 50%, #b5c4f8 50%);
|
||||||
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
@@ -1,6 +1,6 @@
|
|||||||
<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="70px">
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
<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>
|
||||||
@@ -168,6 +168,8 @@ export default {
|
|||||||
},
|
},
|
||||||
// 表单参数
|
// 表单参数
|
||||||
form: {},
|
form: {},
|
||||||
|
// 产品
|
||||||
|
productInfo:{},
|
||||||
// 表单校验
|
// 表单校验
|
||||||
rules: {
|
rules: {
|
||||||
|
|
||||||
|
@@ -59,6 +59,7 @@
|
|||||||
<el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8">
|
<el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8">
|
||||||
<el-form-item label="产品图片">
|
<el-form-item label="产品图片">
|
||||||
<imageUpload ref="image-upload" :value="form.imgUrl" :limit="form.status==2 ? 0 : 1" :fileSize="1" @input="getImagePath($event)"></imageUpload>
|
<imageUpload ref="image-upload" :value="form.imgUrl" :limit="form.status==2 ? 0 : 1" :fileSize="1" @input="getImagePath($event)"></imageUpload>
|
||||||
|
<div class="el-upload__tip" style="color:#f56c6c">提示:上传后需要提交保存</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
@@ -75,9 +76,9 @@
|
|||||||
<span slot="label"><span style="color:red;">* </span>产品模型</span>
|
<span slot="label"><span style="color:red;">* </span>产品模型</span>
|
||||||
<product-things-model ref="productThingsModel" :product="form" />
|
<product-things-model ref="productThingsModel" :product="form" />
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane label="" name="firmware" :disabled="form.productId==0">
|
<el-tab-pane label="" name="productFirmware" :disabled="form.productId==0">
|
||||||
<span slot="label">固件管理</span>
|
<span slot="label">固件管理</span>
|
||||||
<product-things-model ref="productThingsModel" :product="form" />
|
<product-firmware ref="productFirmware" :product="form" />
|
||||||
</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">
|
||||||
@@ -91,7 +92,7 @@
|
|||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
|
|
||||||
<el-tab-pane label="" name="productApp">
|
<el-tab-pane label="" name="productApp">
|
||||||
<span slot="label">产品界面</span>
|
<span slot="label">控制界面</span>
|
||||||
<product-app ref="productApp" :product="form" />
|
<product-app ref="productApp" :product="form" />
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
|
|
||||||
@@ -120,6 +121,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import productThingsModel from "./product-things-model";
|
import productThingsModel from "./product-things-model";
|
||||||
|
import productFirmware from "./product-firmware";
|
||||||
import productApp from "./product-app"
|
import productApp from "./product-app"
|
||||||
import productAlert from "./product-alert"
|
import productAlert from "./product-alert"
|
||||||
import productAuthorize from "./product-authorize"
|
import productAuthorize from "./product-authorize"
|
||||||
@@ -142,6 +144,7 @@ export default {
|
|||||||
productApp,
|
productApp,
|
||||||
productAlert,
|
productAlert,
|
||||||
productAuthorize,
|
productAuthorize,
|
||||||
|
productFirmware,
|
||||||
imageUpload,
|
imageUpload,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
322
vue/src/views/iot/product/product-firmware.vue
Normal file
322
vue/src/views/iot/product/product-firmware.vue
Normal file
@@ -0,0 +1,322 @@
|
|||||||
|
<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-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-table v-loading="loading" :data="firmwareList" @selection-change="handleSelectionChange">
|
||||||
|
<el-table-column label="固件名称" align="center" prop="firmwareName" />
|
||||||
|
<el-table-column label="固件版本" align="center" prop="version">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>Version </span> {{scope.row.version}}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="下载地址" align="center" prop="filePath" width="400">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-link :href="getDownloadUrl(scope.row.filePath)" :underline="false" type="primary">{{getDownloadUrl(scope.row.filePath)}}</el-link>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="创建时间" align="center" prop="createTime">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="备注" align="center" prop="remark" />
|
||||||
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="200">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button size="small" type="primary" style="padding:5px;" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['iot:firmware:edit']">修改</el-button>
|
||||||
|
<el-button size="small" type="danger" style="padding:5px;" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['iot:firmware:remove']">删除</el-button>
|
||||||
|
</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>
|
||||||
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||||
|
<el-form-item label="固件名称" prop="firmwareName">
|
||||||
|
<el-input v-model="form.firmwareName" placeholder="请输入固件名称" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="固件版本" prop="version">
|
||||||
|
<el-input v-model="form.version" placeholder="请输入固件版本" type="number" step="0.1" />
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="固件上传" prop="filePath">
|
||||||
|
<fileUpload ref="file-upload" :value="form.filePath" :limit="1" :fileSize="10" :fileType='["bin", "zip", "pdf"]' @input="getFilePath($event)"></fileUpload>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="备注" prop="remark">
|
||||||
|
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||||
|
<el-button @click="cancel">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import fileUpload from '../../../components/FileUpload/index'
|
||||||
|
import {
|
||||||
|
listFirmware,
|
||||||
|
getFirmware,
|
||||||
|
delFirmware,
|
||||||
|
addFirmware,
|
||||||
|
updateFirmware
|
||||||
|
} from "@/api/iot/firmware";
|
||||||
|
import {
|
||||||
|
getToken
|
||||||
|
} from "@/utils/auth";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "product-firmware",
|
||||||
|
dicts: ["iot_yes_no"],
|
||||||
|
components: {
|
||||||
|
fileUpload
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
product: {
|
||||||
|
type: Object,
|
||||||
|
default: null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
// 获取到父组件传递的productId后,刷新列表
|
||||||
|
product: function (newVal, oldVal) {
|
||||||
|
this.productInfo = newVal;
|
||||||
|
if (this.productInfo && this.productInfo.productId != 0) {
|
||||||
|
this.queryParams.productId = this.productInfo.productId;
|
||||||
|
this.form.productId=this.productInfo.productId;
|
||||||
|
this.form.productName=this.productInfo.productName;
|
||||||
|
console.log(this.form)
|
||||||
|
this.getList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
// 遮罩层
|
||||||
|
loading: true,
|
||||||
|
// 选中数组
|
||||||
|
ids: [],
|
||||||
|
// 非单个禁用
|
||||||
|
single: true,
|
||||||
|
// 非多个禁用
|
||||||
|
multiple: true,
|
||||||
|
// 显示搜索条件
|
||||||
|
showSearch: true,
|
||||||
|
// 总条数
|
||||||
|
total: 0,
|
||||||
|
// 产品固件表格数据
|
||||||
|
firmwareList: [],
|
||||||
|
// 弹出层标题
|
||||||
|
title: "",
|
||||||
|
// 是否显示弹出层
|
||||||
|
open: false,
|
||||||
|
// 查询参数
|
||||||
|
queryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
firmwareName: null,
|
||||||
|
productName: null,
|
||||||
|
productId: 0,
|
||||||
|
isSys: null,
|
||||||
|
},
|
||||||
|
// 产品
|
||||||
|
productInfo: {},
|
||||||
|
// 表单参数
|
||||||
|
form: {
|
||||||
|
version: 1.0
|
||||||
|
},
|
||||||
|
// 表单校验
|
||||||
|
rules: {
|
||||||
|
firmwareName: [{
|
||||||
|
required: true,
|
||||||
|
message: "固件名称不能为空",
|
||||||
|
trigger: "blur"
|
||||||
|
}],
|
||||||
|
version: [{
|
||||||
|
required: true,
|
||||||
|
message: "固件版本不能为空",
|
||||||
|
trigger: "blur"
|
||||||
|
}],
|
||||||
|
filePath: [{
|
||||||
|
required: true,
|
||||||
|
message: "文件路径不能为空",
|
||||||
|
trigger: "blur"
|
||||||
|
}],
|
||||||
|
},
|
||||||
|
// 上传参数
|
||||||
|
upload: {
|
||||||
|
// 是否禁用上传
|
||||||
|
isUploading: false,
|
||||||
|
// 设置上传的请求头部
|
||||||
|
headers: {
|
||||||
|
Authorization: "Bearer " + getToken()
|
||||||
|
},
|
||||||
|
// 上传的地址
|
||||||
|
url: process.env.VUE_APP_BASE_API + "/iot/tool/upload",
|
||||||
|
// 上传的文件列表
|
||||||
|
fileList: []
|
||||||
|
},
|
||||||
|
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
getDownloadUrl(path) {
|
||||||
|
return window.location.origin + process.env.VUE_APP_BASE_API + path;
|
||||||
|
},
|
||||||
|
/** 查询产品固件列表 */
|
||||||
|
getList() {
|
||||||
|
this.loading = true;
|
||||||
|
listFirmware(this.queryParams).then(response => {
|
||||||
|
this.firmwareList = response.rows;
|
||||||
|
this.total = response.total;
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 取消按钮
|
||||||
|
cancel() {
|
||||||
|
this.open = false;
|
||||||
|
this.reset();
|
||||||
|
},
|
||||||
|
// 表单重置
|
||||||
|
reset() {
|
||||||
|
this.form = {
|
||||||
|
firmwareId: null,
|
||||||
|
firmwareName: null,
|
||||||
|
tenantId: null,
|
||||||
|
tenantName: null,
|
||||||
|
productId:this.form.productId,
|
||||||
|
productName:this.form.productName,
|
||||||
|
isSys: null,
|
||||||
|
version: 1.0,
|
||||||
|
filePath: null,
|
||||||
|
delFlag: null,
|
||||||
|
createBy: null,
|
||||||
|
createTime: null,
|
||||||
|
updateBy: null,
|
||||||
|
updateTime: null,
|
||||||
|
remark: null
|
||||||
|
};
|
||||||
|
this.resetForm("form");
|
||||||
|
},
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
handleQuery() {
|
||||||
|
this.queryParams.pageNum = 1;
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
resetQuery() {
|
||||||
|
this.resetForm("queryForm");
|
||||||
|
this.handleQuery();
|
||||||
|
},
|
||||||
|
// 多选框选中数据
|
||||||
|
handleSelectionChange(selection) {
|
||||||
|
this.ids = selection.map(item => item.firmwareId)
|
||||||
|
this.single = selection.length !== 1
|
||||||
|
this.multiple = !selection.length
|
||||||
|
},
|
||||||
|
/** 新增按钮操作 */
|
||||||
|
handleAdd() {
|
||||||
|
this.reset();
|
||||||
|
this.open = true;
|
||||||
|
this.title = "添加产品固件";
|
||||||
|
this.upload.fileList = [];
|
||||||
|
},
|
||||||
|
/** 修改按钮操作 */
|
||||||
|
handleUpdate(row) {
|
||||||
|
this.reset();
|
||||||
|
const firmwareId = row.firmwareId || this.ids
|
||||||
|
getFirmware(firmwareId).then(response => {
|
||||||
|
this.form = response.data;
|
||||||
|
this.open = true;
|
||||||
|
this.title = "修改产品固件";
|
||||||
|
this.upload.fileList = [{
|
||||||
|
name: this.form.firmwareName,
|
||||||
|
url: this.form.filePath
|
||||||
|
}];
|
||||||
|
});
|
||||||
|
|
||||||
|
},
|
||||||
|
/** 提交按钮 */
|
||||||
|
submitForm() {
|
||||||
|
this.$refs["form"].validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
if (this.form.firmwareId != null) {
|
||||||
|
updateFirmware(this.form).then(response => {
|
||||||
|
this.$modal.msgSuccess("修改成功");
|
||||||
|
this.open = false;
|
||||||
|
this.getList();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
addFirmware(this.form).then(response => {
|
||||||
|
this.$modal.msgSuccess("新增成功");
|
||||||
|
this.open = false;
|
||||||
|
this.getList();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
handleDelete(row) {
|
||||||
|
const firmwareIds = row.firmwareId || this.ids;
|
||||||
|
this.$modal.confirm('是否确认删除产品固件编号为"' + firmwareIds + '"的数据项?').then(function () {
|
||||||
|
return delFirmware(firmwareIds);
|
||||||
|
}).then(() => {
|
||||||
|
this.getList();
|
||||||
|
this.$modal.msgSuccess("删除成功");
|
||||||
|
}).catch(() => {});
|
||||||
|
},
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
handleExport() {
|
||||||
|
this.download('iot/firmware/export', {
|
||||||
|
...this.queryParams
|
||||||
|
}, `firmware_${new Date().getTime()}.xlsx`)
|
||||||
|
},
|
||||||
|
// 获取文件路径
|
||||||
|
getFilePath(data) {
|
||||||
|
console.log(data);
|
||||||
|
this.form.filePath = data;
|
||||||
|
},
|
||||||
|
|
||||||
|
// 文件提交处理
|
||||||
|
submitUpload() {
|
||||||
|
this.$refs.upload.submit();
|
||||||
|
},
|
||||||
|
// 文件上传中处理
|
||||||
|
handleFileUploadProgress(event, file, fileList) {
|
||||||
|
this.upload.isUploading = true;
|
||||||
|
},
|
||||||
|
// 文件上传成功处理
|
||||||
|
handleFileSuccess(response, file, fileList) {
|
||||||
|
this.upload.isUploading = false;
|
||||||
|
this.form.filePath = response.url;
|
||||||
|
this.$modal.msgSuccess(response.msg);
|
||||||
|
},
|
||||||
|
// 文件下载处理
|
||||||
|
handleDownload(row) {
|
||||||
|
window.open(process.env.VUE_APP_BASE_API + row.filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
};
|
||||||
|
</script>
|
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div style="margin-top:-35px;">
|
<div style="margin-top:-50px;">
|
||||||
<el-divider></el-divider>
|
<el-divider></el-divider>
|
||||||
<el-form :model="queryParams" ref="product-select-template" :inline="true" label-width="48px">
|
<el-form :model="queryParams" ref="product-select-template" :inline="true" label-width="48px">
|
||||||
<el-form-item label="名称" prop="templateName">
|
<el-form-item label="名称" prop="templateName">
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
<el-table v-loading="loading" :data="templateList" @selection-change="handleSelectionChange" ref="selectTemplateTable" border>
|
<el-table v-loading="loading" :data="templateList" @selection-change="handleSelectionChange" ref="selectTemplateTable" size="small">
|
||||||
<el-table-column type="selection" width="55" align="center" />
|
<el-table-column type="selection" width="55" align="center" />
|
||||||
<el-table-column label="名称" align="center" prop="templateName" />
|
<el-table-column label="名称" align="center" prop="templateName" />
|
||||||
<el-table-column label="标识符" align="center" prop="identifier" />
|
<el-table-column label="标识符" align="center" prop="identifier" />
|
||||||
@@ -27,12 +27,12 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="首页显示" align="center" prop="isTop">
|
<el-table-column label="首页显示" align="center" prop="isTop">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-switch v-model="scope.row.isTop" :active-value="1" :inactive-value="0" active-color="#81c0fb" disabled></el-switch>
|
<dict-tag :options="dict.type.iot_yes_no" :value="scope.row.isTop" />
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="监测值" align="center" prop="isMonitor">
|
<el-table-column label="监测值" align="center" prop="isMonitor">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-switch v-model="scope.row.isMonitor" :active-value="1" :inactive-value="0" active-color="#81c0fb" disabled></el-switch>
|
<dict-tag :options="dict.type.iot_yes_no" :value="scope.row.isMonitor" />
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="数据类型" align="center" prop="datatype">
|
<el-table-column label="数据类型" align="center" prop="datatype">
|
||||||
|
Reference in New Issue
Block a user