若依微服务1.3.1

1、电子围栏完善
2、设备模型完善
3、监控单元完善
4、监控单元类型完善
dev 1.3.1
xins 1 year ago
parent 71d7663982
commit fbf71525ae

@ -83,7 +83,7 @@ public class HwDeviceController extends BaseController
@PostMapping("/export")
public void export(HttpServletResponse response, HwDevice hwDevice)
{
List<HwDevice> list = hwDeviceService.selectHwDeviceList(hwDevice);
List<HwDevice> list = hwDeviceService.selectHwDeviceJoinList(hwDevice);
ExcelUtil<HwDevice> util = new ExcelUtil<HwDevice>(HwDevice.class);
util.exportExcel(response, list, "设备信息数据");
}
@ -148,9 +148,6 @@ public class HwDeviceController extends BaseController
@GetMapping("/getEditedScenes")
public AjaxResult getEditedScenes(HwScene scene)
{
LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser user = loginUser.getSysUser();
scene.setTenantId(user.getTenantId());
return success(hwSceneService.selectHwSceneList4Select(scene));
}

@ -1,39 +1,29 @@
package com.ruoyi.business.controller;
import java.util.HashMap;
import java.util.List;
import java.io.IOException;
import java.util.Map;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.business.domain.HwDeviceMode;
import com.ruoyi.business.domain.HwDeviceModeFunction;
import com.ruoyi.business.domain.HwScene;
import com.ruoyi.business.service.IHwDeviceModeService;
import com.ruoyi.business.service.IHwSceneService;
import com.ruoyi.common.core.constant.HwDictConstants;
import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.context.SecurityContextHolder;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.business.domain.HwDeviceMode;
import com.ruoyi.business.service.IHwDeviceModeService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* Controller
@ -69,7 +59,7 @@ public class HwDeviceModeController extends BaseController {
@Log(title = "设备模型", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, HwDeviceMode hwDeviceMode) {
List<HwDeviceMode> list = hwDeviceModeService.selectHwDeviceModeList(hwDeviceMode);
List<HwDeviceMode> list = hwDeviceModeService.selectHwDeviceModeJoinList(hwDeviceMode);
ExcelUtil<HwDeviceMode> util = new ExcelUtil<HwDeviceMode>(HwDeviceMode.class);
util.exportExcel(response, list, "设备模型数据");
}
@ -134,10 +124,7 @@ public class HwDeviceModeController extends BaseController {
@RequiresPermissions("business:deviceMode:list")
@GetMapping("/getEditedScenes")
public AjaxResult getEditedScenes(HwScene scene) {
LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser user = loginUser.getSysUser();
scene.setTenantId(user.getTenantId());
return success(hwSceneService.selectHwSceneList4Select(scene));
}
}

@ -25,7 +25,7 @@ public class HwDeviceModeFunctionController extends BaseController {
/**
*
*/
@RequiresPermissions("business:deviceModeFunction:add")
@RequiresPermissions("business:deviceMode:add")
@Log(title = "设备模型功能", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody HwDeviceModeFunction hwDeviceModeFunction) {
@ -35,7 +35,7 @@ public class HwDeviceModeFunctionController extends BaseController {
/**
*
*/
@RequiresPermissions("business:deviceModeFunction:edit")
@RequiresPermissions("business:deviceMode:edit")
@Log(title = "设备模型功能", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody HwDeviceModeFunction hwDeviceModeFunction) {
@ -45,7 +45,7 @@ public class HwDeviceModeFunctionController extends BaseController {
/**
*
*/
@RequiresPermissions("business:deviceModeFunction:remove")
@RequiresPermissions("business:deviceMode:remove")
@Log(title = "设备模型功能", businessType = BusinessType.DELETE)
@DeleteMapping("/{modeFunctionId}")
public AjaxResult remove(@PathVariable Long modeFunctionId) {

@ -2,6 +2,7 @@ package com.ruoyi.business.service;
import java.util.List;
import com.ruoyi.business.domain.HwMonitorUnitType;
import com.ruoyi.common.datascope.annotation.DataScope;
/**
* Service
@ -62,4 +63,20 @@ public interface IHwMonitorUnitTypeService
* @return
*/
public int deleteHwMonitorUnitTypeByMonitorUnitTypeId(Long monitorUnitTypeId);
/**
* 使
*
* @param hwMonitorUnitType
* @return
*/
public List<HwMonitorUnitType> selectHwMonitorUnitTypeList4Select(HwMonitorUnitType hwMonitorUnitType);
/**
* ,Join
*
* @param hwMonitorUnitType
* @return
*/
public List<HwMonitorUnitType> selectHwMonitorUnitTypeJoinList(HwMonitorUnitType hwMonitorUnitType);
}

@ -5,19 +5,35 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.business.domain.HwDevice;
import com.ruoyi.business.domain.HwSceneMode;
import com.ruoyi.business.domain.VO.HwSceneVo;
import com.ruoyi.business.mapper.HwDeviceMapper;
import com.ruoyi.common.core.constant.Constants;
import com.ruoyi.common.core.constant.HwDictConstants;
import com.ruoyi.common.core.constant.TdEngineConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.datascope.annotation.DataScope;
import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.model.LoginUser;
import com.ruoyi.tdengine.api.RemoteTdEngineService;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import com.ruoyi.business.mapper.HwSceneMapper;
import com.ruoyi.business.domain.HwScene;
import com.ruoyi.business.service.IHwSceneService;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
/**
* Service
@ -26,12 +42,15 @@ import com.ruoyi.business.service.IHwSceneService;
* @date 2023-08-23
*/
@Service
public class HwSceneServiceImpl implements IHwSceneService
{
public class HwSceneServiceImpl implements IHwSceneService {
@Autowired
private HwSceneMapper hwSceneMapper;
@Autowired
private RedisService redisService;
private HwDeviceMapper hwDeviceMapper;
@Resource
private RemoteTdEngineService remoteTdEngineService;
@Autowired
private StringRedisTemplate redisTemplate;
/**
@ -41,8 +60,7 @@ public class HwSceneServiceImpl implements IHwSceneService
* @return
*/
@Override
public HwScene selectHwSceneBySceneId(Long sceneId)
{
public HwScene selectHwSceneBySceneId(Long sceneId) {
return hwSceneMapper.selectHwSceneBySceneId(sceneId);
}
@ -53,17 +71,6 @@ public class HwSceneServiceImpl implements IHwSceneService
return hwScenes;
}
@Override
public List<HwScene> selectHwSceneByTenantId(Long tenantId) {
if (tenantId == 0){
return hwSceneMapper.selectHwSceneByTenantId0(tenantId);
}
else
return hwSceneMapper.selectHwSceneByTenantIdNot0(tenantId);
}
/**
*
*
@ -71,24 +78,28 @@ public class HwSceneServiceImpl implements IHwSceneService
* @return
*/
@Override
public List<HwScene> selectHwSceneList(HwScene hwScene)
{
return hwSceneMapper.selectHwSceneList(hwScene);
@DataScope(tenantAlias = "hs")
public List<HwScene> selectHwSceneList(HwScene hwScene) {
List<HwScene> scenes = hwSceneMapper.selectHwSceneList(hwScene);
boolean defaultFlag = false;
for (HwScene scene : scenes) {
if (defaultFlag) {
scene.setDefaultFlag(HwDictConstants.SCENE_DEFAULT_FLAG_NO);
} else {
if (scene.getDefaultFlag().equalsIgnoreCase(HwDictConstants.SCENE_DEFAULT_FLAG_YES)) {
defaultFlag = true;
}
}
scene.setRouter(HwDictConstants.SCENE_MODE_ROUTER_MAP.get(scene.getSceneModeId()));
}
return scenes;
}
@Override
public List<HwSceneVo> selectHwSceneList2(HwSceneVo hwScene) {
LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser sysUser = loginUser.getSysUser();
if (sysUser.getUserName().equals("admin"))
public List<HwSceneVo> selectHwSceneJoinList(HwSceneVo hwScene) {
return hwSceneMapper.selectHwSceneVoList(hwScene);
else
{
return hwSceneMapper.selectHwSceneVoListByTenantId(sysUser.getTenantId());
}
}
/**
*
*
@ -96,35 +107,36 @@ public class HwSceneServiceImpl implements IHwSceneService
* @return
*/
@Override
public int insertHwScene(HwScene hwScene)
{
if(hwScene.getDefaultFlag() == "1"){
hwSceneMapper.updateDefaultFlag(hwScene.getTenantId());
}
hwScene.setDefaultFlag("1");
@Transactional
public int insertHwScene(HwScene hwScene) {
LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser sysUser = loginUser.getSysUser();
hwScene.setSceneStatus("1");
Long lon = new Long(10);
hwScene.setSceneId(lon);
hwScene.setCreateBy(sysUser.getNickName());
hwScene.setCreateBy(sysUser.getUserName());
hwScene.setTenantId(sysUser.getTenantId());
if (hwScene.getPreserveTime()==null){
if (hwScene.getPreserveTime() == null) {
hwScene.setPreserveTime(new BigDecimal(90));
}
if (hwScene.getTestPreserveTime()==null){
if (hwScene.getTestPreserveTime() == null) {
hwScene.setTestPreserveTime(new BigDecimal(30));
}
String randomKey = RandomStringUtils.random(12, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789");
String randomSecret = RandomStringUtils.random(16,"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789");
hwScene.setModeKey(randomKey);
hwScene.setModeSecret(randomSecret);
// String randomKey = RandomStringUtils.random(12, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789");
// String randomSecret = RandomStringUtils.random(16, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789");
// hwScene.setModeKey(randomKey);
// hwScene.setModeSecret(randomSecret);
hwScene.setCreateTime(DateUtils.getNowDate());
List<HwScene> list = new ArrayList<HwScene>();
list.add(hwScene);
redisService.setCacheList(hwScene.getSceneId()+"",list);
return hwSceneMapper.insertHwScene(hwScene);
int rows = hwSceneMapper.insertHwScene(hwScene);
this.createTdDatabase(hwScene);
return rows;
}
private void createTdDatabase(HwScene hwScene) {
String databaseName = TdEngineConstants.getDatabaseName(hwScene.getSceneId());
R<?> tdReturnMsg = this.remoteTdEngineService.createDataBase(databaseName);
if (tdReturnMsg.getCode() != Constants.SUCCESS) {//抛出异常,回滚事务
throw new RuntimeException(tdReturnMsg.getMsg());
}
}
/**
@ -134,19 +146,74 @@ public class HwSceneServiceImpl implements IHwSceneService
* @return
*/
@Override
public int updateHwScene(HwScene hwScene)
{
if(hwScene.getDefaultFlag() == "1"){
hwSceneMapper.updateDefaultFlag(hwScene.getTenantId());
@Transactional
public int updateHwScene(HwScene hwScene) {
if (hwScene.getDefaultFlag().equals(HwDictConstants.SCENE_DEFAULT_FLAG_YES)) {
HwScene queryScene = new HwScene();
queryScene.setTenantId(hwScene.getTenantId());
List<HwScene> dbScenes = hwSceneMapper.selectHwSceneList(queryScene);
if (dbScenes != null && dbScenes.isEmpty()) {
dbScenes.forEach(dbScene -> {
dbScene.setDefaultFlag(HwDictConstants.SCENE_DEFAULT_FLAG_NO);
hwSceneMapper.updateHwScene(dbScene);
});
}
}
hwScene.setDefaultFlag("1");
hwScene.setUpdateTime(DateUtils.getNowDate());
List<HwScene> list = new ArrayList<HwScene>();
list.add(hwScene);
redisService.setCacheList(hwScene.getSceneId()+"",list);
return hwSceneMapper.updateHwScene(hwScene);
int rows = hwSceneMapper.updateHwScene(hwScene);
this.updateRedisAuth(hwScene);
return rows;
}
/**
* redisauth
*/
private void updateRedisAuth(HwScene hwScene) {
try {
HwScene dbScene = hwSceneMapper.selectHwSceneBySceneId(hwScene.getSceneId());
if (dbScene.getModeAccount().equals(hwScene.getModeAccount()) ||
dbScene.getModeKey().equals(hwScene.getModeKey())) {
String modeAccount = hwScene.getModeAccount();
String modeKey = hwScene.getModeKey();
HwDevice queryDevice = new HwDevice();
queryDevice.setSceneId(hwScene.getSceneId());
List<HwDevice> devices = hwDeviceMapper.selectHwDeviceList(queryDevice);
if (devices != null && !devices.isEmpty()) {
String deviceInfoStr = redisTemplate.opsForValue().get(HwDictConstants.REDIS_KEY_DEVICE_INFO);
JSONArray deviceInfoJsonArr = new JSONArray();
if (StringUtils.isNotEmpty(deviceInfoStr)) {
deviceInfoJsonArr = JSON.parseArray(deviceInfoStr);
}
for (HwDevice device : devices) {
boolean redisUpdated = false;//是否更新已有的值
for (Object deviceInfoObj : deviceInfoJsonArr) {
JSONObject deviceInfoJson = (JSONObject) deviceInfoObj;
if (deviceInfoJson.getString("deviceCode").equals(device.getDeviceCode())) {
deviceInfoJson.put("username", modeAccount);
deviceInfoJson.put("password", modeKey);
redisUpdated = true;
}
}
if (!redisUpdated) {
JSONObject deviceInfoJson = new JSONObject();
deviceInfoJson.put("deviceCode", device.getDeviceCode());
deviceInfoJson.put("username", modeAccount);
deviceInfoJson.put("password", modeKey);
deviceInfoJsonArr.add(deviceInfoJson);
}
}
redisTemplate.opsForValue().set(HwDictConstants.REDIS_KEY_DEVICE_INFO, deviceInfoJsonArr.toString());
}
}
} catch (Exception e) {
throw new RuntimeException(e.getMessage());
}
}
/**
*
*
@ -154,13 +221,11 @@ public class HwSceneServiceImpl implements IHwSceneService
* @return
*/
@Override
public int deleteHwSceneBySceneIds(Long[] sceneIds)
{
public int deleteHwSceneBySceneIds(Long[] sceneIds) {
List<Long> list = new ArrayList<>();
for (int i = 0; i < sceneIds.length;i++){
for (int i = 0; i < sceneIds.length; i++) {
list.add(sceneIds[i]);
}
redisService.deleteObject(sceneIds+"");
return hwSceneMapper.deleteHwSceneBySceneIds(sceneIds);
}
@ -171,9 +236,30 @@ public class HwSceneServiceImpl implements IHwSceneService
* @return
*/
@Override
public int deleteHwSceneBySceneId(Long sceneId)
{
redisService.deleteObject(sceneId+"");
public int deleteHwSceneBySceneId(Long sceneId) {
return hwSceneMapper.deleteHwSceneBySceneId(sceneId);
}
/**
* 使
*
* @param hwScene
* @return
*/
@Override
public List<HwScene> selectHwSceneList4Select(HwScene hwScene) {
LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser user = loginUser.getSysUser();
hwScene.setTenantId(user.getTenantId());
List<HwScene> scenes = hwSceneMapper.selectHwSceneList(hwScene);
scenes.forEach(s ->{
if(!s.getTenantId().equals( user.getTenantId())){
s.setSelectedDisable("1");
}
});
return scenes;
}
}

@ -77,7 +77,11 @@
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-swagger</artifactId>
</dependency>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>hw-api-tdengine</artifactId>
</dependency>
</dependencies>
<build>

@ -1,28 +1,76 @@
package com.ruoyi.job.task;
import com.ruoyi.common.core.constant.TdEngineConstants;
import com.ruoyi.tdengine.api.RemoteTdEngineService;
import com.ruoyi.tdengine.api.domain.DeviceStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import com.ruoyi.common.core.utils.StringUtils;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
*
*
*
* @author ruoyi
*/
@Component("ryTask")
public class RyTask
{
public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i)
{
public class RyTask {
@Resource
private RemoteTdEngineService remoteTdEngineService;
@Autowired
private StringRedisTemplate redisTemplate;
public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) {
System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i));
}
public void ryParams(String params)
{
public void ryParams(String params) {
System.out.println("执行有参方法:" + params);
}
public void ryNoParams()
{
public void ryNoParams() {
System.out.println("执行无参方法");
}
public void updateDeviceStatusData(Long days) {
Long startTime = 0L;//先是昨天
Long endTime = 1L;
DeviceStatus queryGroupStatus = new DeviceStatus();
queryGroupStatus.setStartTime(startTime);
queryGroupStatus.setEndTime(endTime);
DeviceStatus queryLastStatus = new DeviceStatus();
queryLastStatus.setEndTime(startTime);
Map<Long, List<DeviceStatus>> groupDeviceStatuMapList =
(Map<Long, List<DeviceStatus>>) this.remoteTdEngineService.getOnlineDevicesGroupByDay(queryGroupStatus).getData();
List<Map<String, Object>> lastDeviceStatuMapList =
(List<Map<String, Object>>) this.remoteTdEngineService.getLastOnlineDevices(queryLastStatus).getData();
for (Map<String, Object> groupDeviceStatuMap : lastDeviceStatuMapList) {
DeviceStatus ds = new DeviceStatus();
for (Map.Entry<String, Object> entry : groupDeviceStatuMap.entrySet()) {
if (entry.getKey().equals(TdEngineConstants.ST_TAG_DEVICEID)) {
ds.setDeviceId((Long) entry.getValue());
} else if (entry.getKey().equals(TdEngineConstants.ST_TAG_DEVICETYPE)) {
ds.setDeviceType((Integer) entry.getValue());
} else if (entry.getKey().equals(TdEngineConstants.ST_TAG_ONLINESTATUS)) {
ds.setOnlineStatus((Integer) entry.getValue());
}
}
if(groupDeviceStatuMapList.get(ds.getDeviceId())==null){
// groupDeviceStatuMapList.put(ds.getDeviceId(), Lists.newArrayList());
}
}
}
}

@ -42,3 +42,50 @@ export function delMonitorUnit(monitorUnitId) {
method: 'delete'
})
}
// 查询场景信息列表供查询页面选择使用(例如下拉列表)
export function getScenes(query) {
return request({
url: '/business/monitorUnit/getScenes',
method: 'get',
params: query
})
}
// 查询场景信息列表供编辑页面选择使用(例如下拉列表)
export function getEditedScenes(query) {
return request({
url: '/business/monitorUnit/getEditedScenes',
method: 'get',
params: query
})
}
// 查询监控单元类型供查询页面选择使用
export function getMonitorUnitTypes(query) {
return request({
url: '/business/monitorUnit/getMonitorUnitTypes',
method: 'get',
params: query
})
}
// 查询监控单元类型供编辑页面选择使用
export function getEditedMonitorUnitTypes(query) {
return request({
url: '/business/monitorUnit/getEditedMonitorUnitTypes',
method: 'get',
params: query
})
}
// 查询监控单元列表供编辑页面选择使用
export function getEditedMonitorUnits(query) {
return request({
url: '/business/monitorUnit/getEditedMonitorUnits',
method: 'get',
params: query
})
}

@ -42,3 +42,21 @@ export function delMonitorUnitType(monitorUnitTypeId) {
method: 'delete'
})
}
// 查询场景信息列表供查询页面选择使用(例如下拉列表)
export function getScenes(query) {
return request({
url: '/business/monitorUnitType/getScenes',
method: 'get',
params: query
})
}
// 查询场景信息列表供编辑页面选择使用(例如下拉列表)
export function getEditedScenes(query) {
return request({
url: '/business/monitorUnitType/getEditedScenes',
method: 'get',
params: query
})
}

@ -20,6 +20,7 @@
:key="index"
:label="scene.sceneName"
:value="scene.sceneId"
:disabled="scene.selectedDisable && scene.selectedDisable == 1"
></el-option>
</el-select>
</el-form-item>
@ -44,7 +45,7 @@
v-for="dict in dict.type.hw_mode_function_mode_classfication"
:key="dict.value"
:label="dict.label"
:value="dict.value"
:value="parseInt(dict.value)"
></el-option>
</el-select>

@ -6,12 +6,13 @@
<el-input v-model="form.electronicFenceName" placeholder="请输入电子围栏名称"/>
</el-form-item>
<el-form-item label="所属场景" prop="sceneId">
<el-select v-model="form.sceneId" placeholder="请选择">
<el-select v-model="form.sceneId" placeholder="请选择" :disabled="sceneDisable">
<el-option
v-for="(scene, index) in editedScenes"
:key="index"
:label="scene.sceneName"
:value="scene.sceneId"
:disabled="scene.selectedDisable && scene.selectedDisable == 1"
></el-option>
</el-select>
</el-form-item>
@ -49,11 +50,10 @@
<script>
import {
listElectronicFence,
getElectronicFence,
delElectronicFence,
addElectronicFence,
updateElectronicFence,
getEditedScenes
} from "@/api/business/electronicFence";
let map = null
@ -72,6 +72,7 @@ export default {
},
//
editedScenes: [],
sceneDisable: true,
//
rules: {
electronicFenceName: [
@ -102,7 +103,7 @@ export default {
}
},
created() {
this.getEditedScenes();
},
async mounted() {
await this.isAMap()
@ -144,25 +145,30 @@ export default {
})
},
methods: {
isAMap(){
return new Promise((a,b)=>{
let fun = ()=>{
if(typeof AMap ==='object'){
getEditedScenes() {
getEditedScenes().then(response => {
this.editedScenes = response.data;
});
},
isAMap() {
return new Promise((a, b) => {
let fun = () => {
if (typeof AMap === 'object') {
a()
}else{
setTimeout(fun,100)
} else {
setTimeout(fun, 100)
}
}
fun()
})
},
isMapLoading(){
return new Promise((a,b)=>{
let fun = ()=>{
if(map){
isMapLoading() {
return new Promise((a, b) => {
let fun = () => {
if (map) {
a()
}else{
setTimeout(fun,100)
} else {
setTimeout(fun, 100)
}
}
fun()
@ -203,7 +209,7 @@ export default {
map.setFitView()
},
setCircle(e) {
let thisCircle = new AMap.Circle({center: e.center,radius: e.radius});
let thisCircle = new AMap.Circle({center: e.center, radius: e.radius});
thisCircle.on('dblclick', () => {
CircleEditor.setTarget(thisCircle);
CircleEditor.open();
@ -244,44 +250,44 @@ export default {
})
})
if (params.length > 0) {
this.form.polygonAreaListStr = JSON.stringify(params);
}
if (params1.length > 0) {
this.form.circleAreaListStr = JSON.stringify(params1);
}
this.form.polygonAreaListStr = JSON.stringify(params);
this.form.circleAreaListStr = JSON.stringify(params1);
},
getEditedElectronicFence(){
getEditedElectronicFence() {
const electronicFenceId = this.$route.params && this.$route.params.electronicFenceId;
if(electronicFenceId!=undefined){
if (electronicFenceId != undefined) {
this.sceneDisable = true;
getElectronicFence(electronicFenceId).then(response => {
this.form = response.data;
let circleAreaList = JSON.parse(response.data.circleAreaListStr)
let polygonAreaList = JSON.parse(response.data.polygonAreaListStr)
let polygonData1 = {}
let polygonData = []
polygonAreaList.forEach(e=>{
if(polygonData1[e.index]){
polygonData1[e.index].push([e.longitude,e.latitude])
}else{
polygonData1[e.index] = [[e.longitude,e.latitude]]
polygonAreaList.forEach(e => {
if (polygonData1[e.index]) {
polygonData1[e.index].push([e.longitude, e.latitude])
} else {
polygonData1[e.index] = [[e.longitude, e.latitude]]
}
})
Object.keys(polygonData1).forEach(e=>{
Object.keys(polygonData1).forEach(e => {
polygonData[e] = polygonData1[e]
})
polygonData.forEach(e=>{
polygonData.forEach(e => {
this.setPolygon(e)
})
circleAreaList.forEach(e=>{
circleAreaList.forEach(e => {
let center = JSON.parse(e.center)
let radius = e.radius
this.setCircle({center,radius})
this.setCircle({center, radius})
})
});
} else {
this.sceneDisable = false;
}
},
@ -293,7 +299,6 @@ export default {
if (this.form.electronicFenceId != null) {
updateElectronicFence(this.form).then(response => {
this.$modal.msgSuccess(response.msg);
alert(response.code)
if (response.code === 200) {
this.close();
}
@ -310,6 +315,14 @@ export default {
});
},
/** 关闭按钮 */
close() {
// alert(this.$route.query.pageNum);
const obj = {path: "/alarm/electronicFence", query: {t: Date.now(), pageNum: this.$route.query.pageNum}};
this.$tab.closeOpenPage(obj);
},
}
};
</script>

@ -1,6 +1,6 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="108px">
<el-form-item label="监控单元名称" prop="monitorUnitName">
<el-input
v-model="queryParams.monitorUnitName"
@ -9,72 +9,30 @@
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="所属场景关联hw_scene表的scene_id字段" prop="sceneId">
<el-input
v-model="queryParams.sceneId"
placeholder="请输入所属场景关联hw_scene表的scene_id字段"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="父级监控单元ID" prop="parentId">
<el-input
v-model="queryParams.parentId"
placeholder="请输入父级监控单元ID"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="监控单元类型ID" prop="monitorUnitTypeId">
<el-input
v-model="queryParams.monitorUnitTypeId"
placeholder="请输入监控单元类型ID"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="区域ID,关联表hw_area字段area_id" prop="areaId">
<el-input
v-model="queryParams.areaId"
placeholder="请输入区域ID,关联表hw_area字段area_id"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="详细地址" prop="monitorAddress">
<el-input
v-model="queryParams.monitorAddress"
placeholder="请输入详细地址"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="监控单元图片地址" prop="monitorPic">
<el-input
v-model="queryParams.monitorPic"
placeholder="请输入监控单元图片地址"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="保存周期(单位:天),暂时不用,在场景中创建测试环境。" prop="preserveTime">
<el-input
v-model="queryParams.preserveTime"
placeholder="请输入保存周期(单位:天),暂时不用,在场景中创建测试环境。"
clearable
@keyup.enter.native="handleQuery"
/>
<el-form-item label="所属场景" prop="sceneId">
<el-select v-model="queryParams.sceneId" placeholder="请选择">
<el-option
v-for="(scene, index) in scenes"
:key="index"
:label="scene.sceneName"
:value="scene.sceneId"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="预留字段" prop="monitorUnitField">
<el-input
v-model="queryParams.monitorUnitField"
placeholder="请输入预留字段"
clearable
@keyup.enter.native="handleQuery"
/>
<el-form-item label="监控单元类型" prop="monitorUnitTypeId">
<el-select v-model="queryParams.monitorUnitTypeId" placeholder="请选择">
<el-option
v-for="(monitorUnitType, index) in monitorUnitTypes"
:key="index"
:label="monitorUnitType.monitorUnitTypeName"
:value="monitorUnitType.monitorUnitTypeId"
></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>
<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>
@ -88,7 +46,8 @@
size="mini"
@click="handleAdd"
v-hasPermi="['business:monitorUnit:add']"
>新增</el-button>
>新增
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
@ -97,7 +56,8 @@
icon="el-icon-sort"
size="mini"
@click="toggleExpandAll"
>展开/折叠</el-button>
>展开/折叠
</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
@ -110,17 +70,9 @@
:default-expand-all="isExpandAll"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
>
<el-table-column label="监控单元名称" prop="monitorUnitName" />
<el-table-column label="所属场景关联hw_scene表的scene_id字段" align="center" prop="sceneId" />
<el-table-column label="父级监控单元ID" align="center" prop="parentId" />
<el-table-column label="监控单元类型ID" align="center" prop="monitorUnitTypeId" />
<el-table-column label="区域ID,关联表hw_area字段area_id" align="center" prop="areaId" />
<el-table-column label="详细地址" align="center" prop="monitorAddress" />
<el-table-column label="监控单元图片地址" align="center" prop="monitorPic" />
<el-table-column label="保存周期(单位:天),暂时不用,在场景中创建测试环境。" align="center" prop="preserveTime" />
<el-table-column label="场景描述" align="center" prop="remark" />
<el-table-column label="状态" align="center" prop="monitorUnitStatus" />
<el-table-column label="预留字段" align="center" prop="monitorUnitField" />
<el-table-column label="监控单元名称" prop="monitorUnitName"/>
<el-table-column label="所属场景" align="center" prop="sceneName"/>
<el-table-column label="监控单元类型" align="center" prop="monitorUnitTypeName"/>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
@ -129,58 +81,115 @@
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['business:monitorUnit:edit']"
>修改</el-button>
>修改
</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-plus"
@click="handleAdd(scope.row)"
v-hasPermi="['business:monitorUnit:add']"
>新增</el-button>
>新增
</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['business:monitorUnit:remove']"
>删除</el-button>
>删除
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 添加或修改监控单元对话框 -->
<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 ref="form" :model="form" :rules="rules" label-width="108px">
<el-form-item label="监控单元名称" prop="monitorUnitName">
<el-input v-model="form.monitorUnitName" placeholder="请输入监控单元名称" />
<el-input v-model="form.monitorUnitName" placeholder="请输入监控单元名称"/>
</el-form-item>
<el-form-item label="所属场景关联hw_scene表的scene_id字段" prop="sceneId">
<el-input v-model="form.sceneId" placeholder="请输入所属场景关联hw_scene表的scene_id字段" />
<el-form-item label="所属场景" prop="sceneId">
<el-select v-model="form.sceneId" placeholder="请选择" :disabled="sceneDisable">
<el-option
v-for="(scene, index) in editedScenes"
:key="index"
:label="scene.sceneName"
:value="scene.sceneId"
:disabled="scene.selectedDisable && scene.selectedDisable == 1"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="父级监控单元ID" prop="parentId">
<treeselect v-model="form.parentId" :options="monitorUnitOptions" :normalizer="normalizer" placeholder="请选择父级监控单元ID" />
<el-form-item label="父级监控单元" prop="parentId">
<treeselect v-model="form.parentId" :options="monitorUnitOptions" :normalizer="normalizer"
placeholder="请选择父级监控单元ID"/>
</el-form-item>
<el-form-item label="监控单元类型ID" prop="monitorUnitTypeId">
<el-input v-model="form.monitorUnitTypeId" placeholder="请输入监控单元类型ID" />
<el-form-item label="监控单元类型" prop="monitorUnitTypeId">
<el-select v-model="form.monitorUnitTypeId" placeholder="请选择">
<el-option
v-for="(monitorUnitType, index) in editedMonitorUnitTypes"
:key="index"
:label="monitorUnitType.monitorUnitTypeName"
:value="monitorUnitType.monitorUnitTypeId"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="区域ID,关联表hw_area字段area_id" prop="areaId">
<!--el-form-item label="区域ID,关联表hw_area字段area_id" prop="areaId">
<el-input v-model="form.areaId" placeholder="请输入区域ID,关联表hw_area字段area_id" />
</el-form-item>
</el-form-item-->
<el-form-item label="详细地址" prop="monitorAddress">
<el-input v-model="form.monitorAddress" placeholder="请输入详细地址" />
</el-form-item>
<el-form-item label="监控单元图片地址" prop="monitorPic">
<el-input v-model="form.monitorPic" placeholder="请输入监控单元图片地址" />
</el-form-item>
<el-form-item label="保存周期(单位:天),暂时不用,在场景中创建测试环境。" prop="preserveTime">
<el-input v-model="form.preserveTime" placeholder="请输入保存周期(单位:天),暂时不用,在场景中创建测试环境。" />
<el-input v-model="form.monitorAddress" placeholder="请输入详细地址"/>
</el-form-item>
<el-form-item label="场景描述" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容"/>
</el-form-item>
<el-form-item label="预留字段" prop="monitorUnitField">
<el-input v-model="form.monitorUnitField" placeholder="请输入预留字段" />
<el-form-item label="监控单元图片" prop="monitorPic">
<el-upload
single
:action="uploadImgUrl"
list-type="picture-card"
:limit="limit"
:on-success="handleUploadSuccess"
:before-upload="handleBeforeUpload"
:on-error="handleUploadError"
:on-exceed="handleExceed"
ref="imageUpload"
:on-remove="handleDeletePicture"
:show-file-list="true"
:headers="headers"
:file-list="fileList"
:on-preview="handlePictureCardPreview"
:class="{hide: this.fileList.length >= 1}"
>
<i class="el-icon-plus"></i>
</el-upload>
<!-- 上传提示 -->
<div class="el-upload__tip" slot="tip" v-if="showTip">
请上传
<template v-if="fileSize"> <b style="color: #f56c6c">{{ fileSize }}MB</b></template>
<template v-if="fileType"> <b style="color: #f56c6c">{{ fileType.join("/") }}</b></template>
的文件
</div>
<el-dialog
:visible.sync="dialogVisible"
title="预览"
width="800"
append-to-body
>
<img
:src="dialogImageUrl"
style="display: block; max-width: 100%; margin: 0 auto"
/>
</el-dialog>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
@ -191,15 +200,42 @@
</template>
<script>
import { listMonitorUnit, getMonitorUnit, delMonitorUnit, addMonitorUnit, updateMonitorUnit } from "@/api/business/monitorUnit";
import {
listMonitorUnit, getMonitorUnit, delMonitorUnit, addMonitorUnit, updateMonitorUnit
, getMonitorUnitTypes, getEditedMonitorUnitTypes, getScenes, getEditedScenes,getEditedMonitorUnits
} from "@/api/business/monitorUnit";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import {getToken} from "@/utils/auth";
export default {
name: "MonitorUnit",
components: {
Treeselect
},
props: {
value: [String, Object, Array],
//
limit: {
type: Number,
default: 1,
},
// (MB)
fileSize: {
type: Number,
default: 5,
},
// , ['png', 'jpg', 'jpeg']
fileType: {
type: Array,
default: () => ["png", "jpg", "jpeg"],
},
//
isShowTip: {
type: Boolean,
default: true
}
},
data() {
return {
//
@ -210,6 +246,14 @@ export default {
monitorUnitList: [],
//
monitorUnitOptions: [],
//
scenes: [],
//
editedScenes: [],
sceneDisable: true,
monitorUnitTypes: [],
editedMonitorUnitTypes: [],
//
title: "",
//
@ -236,24 +280,58 @@ export default {
//
rules: {
monitorUnitName: [
{ required: true, message: "监控单元名称不能为空", trigger: "blur" }
{required: true, message: "监控单元名称不能为空", trigger: "blur"}
],
sceneId: [
{ required: true, message: "所属场景关联hw_scene表的scene_id字段不能为空", trigger: "blur" }
{required: true, message: "所属场景不能为空", trigger: "change"}
],
monitorUnitTypeId: [
{ required: true, message: "监控单元类型ID不能为空", trigger: "blur" }
],
monitorUnitStatus: [
{ required: true, message: "状态不能为空", trigger: "change" }
],
}
{required: true, message: "监控单元类型不能为空", trigger: "change"}
]
},
number: 0,
uploadList: [],
dialogImageUrl: "",
dialogVisible: false,
hideUpload: false,
uploadImgUrl: process.env.VUE_APP_BASE_API + "/file/upload", //
headers: {
Authorization: "Bearer " + getToken(),
},
fileList: [],
};
},
created() {
this.getList();
this.getScenes();
this.getMonitorUnitTypes();
},
methods: {
getScenes() {
getScenes().then(response => {
this.scenes = response.data;
});
},
getEditedScenes() {
getEditedScenes().then(response => {
this.editedScenes = response.data;
});
},
getMonitorUnitTypes() {
getMonitorUnitTypes().then(response => {
this.monitorUnitTypes = response.data;
});
},
getEditedMonitorUnitTypes() {
getEditedMonitorUnitTypes().then(response => {
this.editedMonitorUnitTypes = response.data;
});
},
/** 查询监控单元列表 */
getList() {
this.loading = true;
@ -273,11 +351,11 @@ export default {
children: node.children
};
},
/** 查询监控单元下拉树结构 */
/** 查询监控单元下拉树结构 */
getTreeselect() {
listMonitorUnit().then(response => {
getEditedMonitorUnits().then(response => {
this.monitorUnitOptions = [];
const data = { monitorUnitId: 0, monitorUnitName: '顶级节点', children: [] };
const data = {monitorUnitId: 0, monitorUnitName: '顶级节点', children: []};
data.children = this.handleTree(response.data, "monitorUnitId", "parentId");
this.monitorUnitOptions.push(data);
});
@ -320,6 +398,9 @@ export default {
},
/** 新增按钮操作 */
handleAdd(row) {
this.sceneDisable= false;
this.getEditedScenes();
this.getEditedMonitorUnitTypes();
this.reset();
this.getTreeselect();
if (row != null && row.monitorUnitId) {
@ -340,6 +421,9 @@ export default {
},
/** 修改按钮操作 */
handleUpdate(row) {
this.sceneDisable= true;
this.getEditedScenes();
this.getEditedMonitorUnitTypes();
this.reset();
this.getTreeselect();
if (row != null) {
@ -349,6 +433,11 @@ export default {
this.form = response.data;
this.open = true;
this.title = "修改监控单元";
if (response.data.monitorPic != null) {
let previewFile = {};
previewFile.url = response.data.monitorPic
this.fileList.push(previewFile);
}
});
},
/** 提交按钮 */
@ -373,13 +462,113 @@ export default {
},
/** 删除按钮操作 */
handleDelete(row) {
this.$modal.confirm('是否确认删除监控单元编号为"' + row.monitorUnitId + '"的数据项?').then(function() {
this.$modal.confirm('是否确认删除监控单元编号为"' + row.monitorUnitId + '"的数据项?').then(function () {
return delMonitorUnit(row.monitorUnitId);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
}
}).catch(() => {
});
},
/**上传图片处理*/
// loading
handleBeforeUpload(file) {
let isImg = false;
if (this.fileType.length) {
let fileExtension = "";
if (file.name.lastIndexOf(".") > -1) {
fileExtension = file.name.slice(file.name.lastIndexOf(".") + 1);
}
isImg = this.fileType.some(type => {
if (file.type.indexOf(type) > -1) return true;
if (fileExtension && fileExtension.indexOf(type) > -1) return true;
return false;
});
} else {
isImg = file.type.indexOf("image") > -1;
}
if (!isImg) {
this.$modal.msgError(`文件格式不正确, 请上传${this.fileType.join("/")}图片格式文件!`);
return false;
}
if (this.fileSize) {
const isLt = file.size / 1024 / 1024 < this.fileSize;
if (!isLt) {
this.$modal.msgError(`上传头像图片大小不能超过 ${this.fileSize} MB!`);
return false;
}
}
this.$modal.loading("正在上传图片,请稍候...");
this.number++;
},
checkPicture(file) {
},
//
handleExceed() {
this.$modal.msgError(`上传文件数量不能超过 ${this.limit} !`);
},
//
handleUploadSuccess(res, file) {
if (res.code === 200) {
this.uploadList.push(res.data.url);
this.uploadedSuccessfully();
} else {
this.number--;
this.$modal.closeLoading();
this.$modal.msgError(res.msg);
this.$refs.imageUpload.handleRemove(file);
this.uploadedSuccessfully();
}
},
//
uploadedSuccessfully() {
if (this.number > 0 && this.uploadList.length === this.number) {
this.fileList = this.fileList.concat(this.uploadList);
this.uploadList = [];
this.number = 0;
this.form.monitorPic = this.fileList[0];
// this.$emit("input", this.listToString(this.fileList));
this.$modal.closeLoading();
}
},
//
handleDeletePicture(file) {
const findex = this.fileList.map(f => f.name).indexOf(file.name);
if (findex > -1) {
this.fileList.splice(findex, 1);
// this.$emit("input", this.listToString(this.fileList));
}
this.form.monitorPic = '';
},
//
handleUploadError() {
this.$modal.msgError("上传图片失败,请重试");
this.$modal.closeLoading();
},
//
handlePictureCardPreview(file) {
this.dialogImageUrl = file.url;
this.dialogVisible = true;
},
//
listToString(list, separator) {
let strs = "";
separator = separator || ",";
for (let i in list) {
if (list[i].url) {
strs += list[i].url.replace(this.baseUrl, "") + separator;
}
}
return strs != '' ? strs.substr(0, strs.length - 1) : '';
},
}
};
</script>

@ -1,7 +1,7 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="监控单元类型名称" prop="monitorUnitTypeName">
<el-form-item label="类型名称" prop="monitorUnitTypeName">
<el-input
v-model="queryParams.monitorUnitTypeName"
placeholder="请输入监控单元类型名称"
@ -9,54 +9,30 @@
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="虚拟标识" prop="vitualFlag">
<el-input
v-model="queryParams.vitualFlag"
placeholder="请输入虚拟标识"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="语言code" prop="languageCode">
<el-input
v-model="queryParams.languageCode"
placeholder="请输入语言code"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="通用标识" prop="commonFlag">
<el-input
v-model="queryParams.commonFlag"
placeholder="请输入通用标识"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="所属场景" prop="sceneId">
<el-input
v-model="queryParams.sceneId"
placeholder="请输入所属场景"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="监控单元类型图标" prop="unitTypeIcon">
<el-input
v-model="queryParams.unitTypeIcon"
placeholder="请输入监控单元类型图标"
clearable
@keyup.enter.native="handleQuery"
/>
<el-select v-model="queryParams.sceneId" placeholder="请选择">
<el-option
v-for="(scene, index) in scenes"
:key="index"
:label="scene.sceneName"
:value="scene.sceneId"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="预留字段" prop="unitTypeField">
<el-input
v-model="queryParams.unitTypeField"
placeholder="请输入预留字段"
clearable
@keyup.enter.native="handleQuery"
/>
<el-form-item label="虚拟标识" prop="vitualFlag">
<el-select v-model="queryParams.vitualFlag" placeholder="请选择虚拟标识">
<el-option
v-for="dict in dict.type.hw_unit_type_vitual_flag"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</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>
@ -74,17 +50,6 @@
v-hasPermi="['business:monitorUnitType: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="['business:monitorUnitType:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
@ -111,16 +76,13 @@
<el-table v-loading="loading" :data="monitorUnitTypeList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="监控单元类型ID" align="center" prop="monitorUnitTypeId" />
<el-table-column label="监控单元类型名称" align="center" prop="monitorUnitTypeName" />
<el-table-column label="虚拟标识" align="center" prop="vitualFlag" />
<el-table-column label="状态" align="center" prop="monitorUnitTypeStatus" />
<el-table-column label="语言code" align="center" prop="languageCode" />
<el-table-column label="通用标识" align="center" prop="commonFlag" />
<el-table-column label="所属场景" align="center" prop="sceneId" />
<el-table-column label="类型描述" align="center" prop="remark" />
<el-table-column label="监控单元类型图标" align="center" prop="unitTypeIcon" />
<el-table-column label="预留字段" align="center" prop="unitTypeField" />
<el-table-column label="类型名称" align="center" prop="monitorUnitTypeName" />
<el-table-column label="虚拟标识" align="center" prop="vitualFlag" >
<template slot-scope="scope">
<dict-tag :options="dict.type.hw_unit_type_vitual_flag" :value="scope.row.vitualFlag"/>
</template>
</el-table-column>
<el-table-column label="所属场景" align="center" prop="sceneName" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
@ -140,7 +102,7 @@
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
@ -152,30 +114,37 @@
<!-- 添加或修改监控单元类型对话框 -->
<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="monitorUnitTypeName">
<el-form-item label="类型名称" prop="monitorUnitTypeName">
<el-input v-model="form.monitorUnitTypeName" placeholder="请输入监控单元类型名称" />
</el-form-item>
<el-form-item label="虚拟标识" prop="vitualFlag">
<el-input v-model="form.vitualFlag" placeholder="请输入虚拟标识" />
</el-form-item>
<el-form-item label="语言code" prop="languageCode">
<el-input v-model="form.languageCode" placeholder="请输入语言code" />
</el-form-item>
<el-form-item label="通用标识" prop="commonFlag">
<el-input v-model="form.commonFlag" placeholder="请输入通用标识" />
</el-form-item>
<el-form-item label="所属场景" prop="sceneId">
<el-input v-model="form.sceneId" placeholder="请输入所属场景" />
<el-select v-model="form.sceneId" placeholder="请选择" :disabled="sceneDisable">
<el-option
v-for="(scene, index) in editedScenes"
:key="index"
:label="scene.sceneName"
:value="scene.sceneId"
:disabled="scene.selectedDisable && scene.selectedDisable == 1"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="虚拟标识" prop="vitualFlag">
<el-radio-group v-model="form.vitualFlag">
<el-radio
v-for="dict in dict.type.hw_unit_type_vitual_flag"
:key="dict.value"
:label="dict.value"
v-model="vitualFlag"
>{{ dict.label }}
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="类型描述" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
</el-form-item>
<el-form-item label="监控单元类型图标" prop="unitTypeIcon">
<el-input v-model="form.unitTypeIcon" placeholder="请输入监控单元类型图标" />
</el-form-item>
<el-form-item label="预留字段" prop="unitTypeField">
<el-input v-model="form.unitTypeField" placeholder="请输入预留字段" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
@ -186,10 +155,11 @@
</template>
<script>
import { listMonitorUnitType, getMonitorUnitType, delMonitorUnitType, addMonitorUnitType, updateMonitorUnitType } from "@/api/business/monitorUnitType";
import { listMonitorUnitType, getMonitorUnitType, delMonitorUnitType, addMonitorUnitType, updateMonitorUnitType,getScenes,getEditedScenes } from "@/api/business/monitorUnitType";
export default {
name: "MonitorUnitType",
dicts: ['hw_unit_type_vitual_flag'],
data() {
return {
//
@ -206,6 +176,11 @@ export default {
total: 0,
//
monitorUnitTypeList: [],
//
scenes: [],
//
editedScenes:[],
sceneDisable:true,
//
title: "",
//
@ -233,12 +208,6 @@ export default {
vitualFlag: [
{ required: true, message: "虚拟标识不能为空", trigger: "blur" }
],
monitorUnitTypeStatus: [
{ required: true, message: "状态不能为空", trigger: "change" }
],
commonFlag: [
{ required: true, message: "通用标识不能为空", trigger: "blur" }
],
sceneId: [
{ required: true, message: "所属场景不能为空", trigger: "blur" }
],
@ -247,6 +216,7 @@ export default {
},
created() {
this.getList();
this.getScenes();
},
methods: {
/** 查询监控单元类型列表 */
@ -299,14 +269,27 @@ export default {
this.single = selection.length!==1
this.multiple = !selection.length
},
getScenes(){
getScenes().then(response => {
this.scenes = response.data;
});
},
/** 新增按钮操作 */
handleAdd() {
this.sceneDisable=false;
getEditedScenes().then(response => {
this.editedScenes = response.data;
});
this.reset();
this.open = true;
this.title = "添加监控单元类型";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.sceneDisable = true;
getEditedScenes().then(response => {
this.editedScenes = response.data;
});
this.reset();
const monitorUnitTypeId = row.monitorUnitTypeId || this.ids
getMonitorUnitType(monitorUnitTypeId).then(response => {

Loading…
Cancel
Save