mirror of
https://github.com/kerwincui/FastBee.git
synced 2025-10-07 17:12:04 +08:00
分享单个或全部设备功能实现,用户设备列表接口调整,新增别人分享给自己的设备
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
package com.ruoyi.iot.controller;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.ruoyi.iot.domain.Firmware;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -22,7 +20,6 @@ import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.iot.domain.DeviceUser;
|
||||
import com.ruoyi.iot.service.IDeviceUserService;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
@@ -53,7 +50,7 @@ public class DeviceUserController extends BaseController
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备用户详细信息
|
||||
* 获取设备用户详细信息 根据deviceId 查询的话可能会查出多个
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:device:query')")
|
||||
@GetMapping(value = "/{deviceId}")
|
||||
@@ -63,6 +60,17 @@ public class DeviceUserController extends BaseController
|
||||
return AjaxResult.success(deviceUserService.selectDeviceUserByDeviceId(deviceId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备用户详细信息 双主键 device_id 和 user_id
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:device:query')")
|
||||
@GetMapping(value = "/{deviceId}/{userId}")
|
||||
@ApiOperation("获取设备用户详情,根据用户id 和 设备id")
|
||||
public AjaxResult getInfo(@PathVariable("deviceId") Long deviceId, @PathVariable("userId") Long userId)
|
||||
{
|
||||
return AjaxResult.success(deviceUserService.selectDeviceUserByDeviceIdAndUserId(deviceId, userId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增设备用户
|
||||
*/
|
||||
@@ -75,6 +83,18 @@ public class DeviceUserController extends BaseController
|
||||
return toAjax(deviceUserService.insertDeviceUser(deviceUser));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增多个设备用户
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:device:add')")
|
||||
@Log(title = "设备用户", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/addDeviceUsers")
|
||||
@ApiOperation("添加设备用户")
|
||||
public AjaxResult addDeviceUsers(@RequestBody List<DeviceUser> deviceUsers)
|
||||
{
|
||||
return toAjax(deviceUserService.insertDeviceUserList(deviceUsers));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改设备用户
|
||||
*/
|
||||
@@ -91,13 +111,13 @@ public class DeviceUserController extends BaseController
|
||||
/**
|
||||
* 删除设备用户
|
||||
*/
|
||||
@ApiOperation("批量删除设备用户")
|
||||
@ApiOperation("删除设备用户")
|
||||
@PreAuthorize("@ss.hasPermi('iot:device:remove')")
|
||||
@Log(title = "设备用户", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{deviceIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] deviceIds)
|
||||
@DeleteMapping
|
||||
public AjaxResult remove(@RequestBody DeviceUser deviceUser)
|
||||
{
|
||||
int count=deviceUserService.deleteDeviceUserByDeviceIds(deviceIds);
|
||||
int count=deviceUserService.deleteDeviceUser(deviceUser);
|
||||
if(count==0){
|
||||
return AjaxResult.error("设备所有者不能删除");
|
||||
}else{
|
||||
|
@@ -2,6 +2,7 @@ package com.ruoyi.iot.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.iot.domain.DeviceUser;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
@@ -19,7 +20,7 @@ public interface DeviceUserMapper
|
||||
* @param deviceId 设备用户主键
|
||||
* @return 设备用户
|
||||
*/
|
||||
public DeviceUser selectDeviceUserByDeviceId(Long deviceId);
|
||||
public List<DeviceUser> selectDeviceUserByDeviceId(Long deviceId);
|
||||
|
||||
/**
|
||||
* 查询设备用户列表
|
||||
@@ -60,4 +61,21 @@ public interface DeviceUserMapper
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDeviceUserByDeviceIds(Long[] deviceIds);
|
||||
|
||||
/**
|
||||
* 批量添加设备用户
|
||||
* @param deviceUsers 设备用户
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertDeviceUserList(List<DeviceUser> deviceUsers);
|
||||
|
||||
/**
|
||||
* 根据deviceId 和 userId 查询
|
||||
* @param deviceId 设备id
|
||||
* @param userId 用户id
|
||||
* @return 结果
|
||||
*/
|
||||
public DeviceUser selectDeviceUserByDeviceIdAndUserId(@Param("deviceId") Long deviceId, @Param("userId") Long userId);
|
||||
|
||||
public int deleteDeviceUser(DeviceUser deviceUser);
|
||||
}
|
||||
|
@@ -17,7 +17,7 @@ public interface IDeviceUserService
|
||||
* @param deviceId 设备用户主键
|
||||
* @return 设备用户
|
||||
*/
|
||||
public DeviceUser selectDeviceUserByDeviceId(Long deviceId);
|
||||
public List<DeviceUser> selectDeviceUserByDeviceId(Long deviceId);
|
||||
|
||||
/**
|
||||
* 查询设备用户列表
|
||||
@@ -58,4 +58,21 @@ public interface IDeviceUserService
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDeviceUserByDeviceId(Long deviceId);
|
||||
|
||||
/**
|
||||
* 批量添加设备用户
|
||||
* @param deviceUsers 设备用户
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertDeviceUserList(List<DeviceUser> deviceUsers);
|
||||
|
||||
/**
|
||||
* 查询设备用户
|
||||
*
|
||||
* @param deviceId 设备用户主键
|
||||
* @return 设备用户
|
||||
*/
|
||||
public DeviceUser selectDeviceUserByDeviceIdAndUserId(Long deviceId, Long userId);
|
||||
|
||||
public int deleteDeviceUser(DeviceUser deviceUser);
|
||||
}
|
||||
|
@@ -544,7 +544,7 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
public List<DeviceAllShortOutput> selectAllDeviceShortListAccurate(String userName) {
|
||||
return deviceMapper.selectAllDeviceShortListAccurate(userName);
|
||||
}
|
||||
// 精准查询
|
||||
// 精准查询 新增别人分享给自己的设备
|
||||
@Override
|
||||
public List<Device> selectDeviceListAccurate(Device device) {
|
||||
return deviceMapper.selectDeviceListAccurate(device);
|
||||
|
@@ -6,8 +6,10 @@ import com.ruoyi.iot.domain.DeviceUser;
|
||||
import com.ruoyi.iot.mapper.DeviceUserMapper;
|
||||
import com.ruoyi.iot.service.IDeviceUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.sql.SQLIntegrityConstraintViolationException;
|
||||
import java.util.List;
|
||||
|
||||
import static com.ruoyi.common.utils.SecurityUtils.getLoginUser;
|
||||
@@ -31,7 +33,7 @@ public class DeviceUserServiceImpl implements IDeviceUserService
|
||||
* @return 设备用户
|
||||
*/
|
||||
@Override
|
||||
public DeviceUser selectDeviceUserByDeviceId(Long deviceId)
|
||||
public List<DeviceUser> selectDeviceUserByDeviceId(Long deviceId)
|
||||
{
|
||||
return deviceUserMapper.selectDeviceUserByDeviceId(deviceId);
|
||||
}
|
||||
@@ -57,6 +59,8 @@ public class DeviceUserServiceImpl implements IDeviceUserService
|
||||
@Override
|
||||
public int insertDeviceUser(DeviceUser deviceUser)
|
||||
{
|
||||
List<DeviceUser> deviceUsers = selectDeviceUserList(deviceUser);
|
||||
if (!deviceUsers.isEmpty()) throw new RuntimeException("该用户已添加, 禁止重复添加");
|
||||
deviceUser.setCreateTime(DateUtils.getNowDate());
|
||||
deviceUser.setIsOwner(0);
|
||||
SysUser sysUser = getLoginUser().getUser();
|
||||
@@ -101,4 +105,30 @@ public class DeviceUserServiceImpl implements IDeviceUserService
|
||||
{
|
||||
return deviceUserMapper.deleteDeviceUserByDeviceId(deviceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertDeviceUserList(List<DeviceUser> deviceUsers) {
|
||||
try {
|
||||
deviceUsers.forEach(deviceUser -> {
|
||||
deviceUser.setCreateTime(DateUtils.getNowDate());
|
||||
deviceUser.setIsOwner(0);
|
||||
SysUser sysUser = getLoginUser().getUser();
|
||||
deviceUser.setTenantId(sysUser.getUserId());
|
||||
deviceUser.setTenantName(sysUser.getUserName());
|
||||
});
|
||||
return deviceUserMapper.insertDeviceUserList(deviceUsers);
|
||||
} catch (DuplicateKeyException e) {
|
||||
throw new RuntimeException("存在设备已经与用户绑定");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceUser selectDeviceUserByDeviceIdAndUserId(Long deviceId, Long userId) {
|
||||
return deviceUserMapper.selectDeviceUserByDeviceIdAndUserId(deviceId, userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteDeviceUser(DeviceUser deviceUser) {
|
||||
return deviceUserMapper.deleteDeviceUser(deviceUser);
|
||||
}
|
||||
}
|
||||
|
@@ -129,6 +129,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectDeviceListAccurate" parameterType="com.ruoyi.iot.domain.Device" resultMap="DeviceResult">
|
||||
<include refid="selectDeviceVo"/>
|
||||
<where>
|
||||
@@ -166,7 +167,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="deviceName != null and deviceName != ''"> and device_name like concat('%', #{deviceName}, '%')</if>
|
||||
<if test="productId != null "> and product_id = #{productId}</if>
|
||||
<if test="productName != null and productName != ''"> and product_name like concat('%', #{productName}, '%')</if>
|
||||
<if test="userId != null "> and user_id = #{userId}</if>
|
||||
<if test="userId != null ">
|
||||
and user_id = #{userId}
|
||||
or device_id in (select device_id from iot_device_user where iot_device_user.user_name = #{userName})
|
||||
</if>
|
||||
<if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
|
||||
<if test="tenantId != null "> and tenant_id = #{tenantId}</if>
|
||||
<if test="tenantName != null and tenantName != ''"> and tenant_name like concat('%', #{tenantName}, '%')</if>
|
||||
@@ -183,7 +187,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="productId != null "> and product_id = #{productId}</if>
|
||||
<if test="productName != null and productName != ''"> and product_name = #{productName}</if>
|
||||
<if test="userId != null "> and user_id = #{userId}</if>
|
||||
<if test="userName != null and userName != ''"> and user_name = #{userName}</if>
|
||||
<if test="userName != null and userName != ''">
|
||||
and user_name = #{userName}
|
||||
or device_id in (select device_id from iot_device_user where iot_device_user.user_name = #{userName})
|
||||
</if>
|
||||
<if test="tenantId != null "> and tenant_id = #{tenantId}</if>
|
||||
<if test="tenantName != null and tenantName != ''"> and tenant_name=#{tenantName}</if>
|
||||
<if test="serialNumber != null and serialNumber != ''"> and serial_number = #{serialNumber}</if>
|
||||
|
@@ -37,9 +37,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where device_id = #{deviceId}
|
||||
</select>
|
||||
|
||||
<insert id="insertDeviceUser" parameterType="com.ruoyi.iot.domain.DeviceUser" useGeneratedKeys="true" keyProperty="deviceId">
|
||||
<select id="selectDeviceUserByDeviceIdAndUserId" resultMap="DeviceUserResult">
|
||||
<include refid="selectDeviceUserVo"/>
|
||||
where device_id = #{deviceId} and user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<insert id="insertDeviceUser" parameterType="com.ruoyi.iot.domain.DeviceUser" keyProperty="deviceId">
|
||||
insert into iot_device_user
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="deviceId != null">device_id,</if>
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="deviceName != null and deviceName != ''">device_name,</if>
|
||||
<if test="userName != null and userName != ''">user_name,</if>
|
||||
@@ -55,6 +61,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="remark != null">remark,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="deviceId != null">#{deviceId},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="deviceName != null and deviceName != ''">#{deviceName},</if>
|
||||
<if test="userName != null and userName != ''">#{userName},</if>
|
||||
@@ -71,6 +78,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<insert id="insertDeviceUserList" parameterType="java.util.ArrayList">
|
||||
insert into iot_device_user
|
||||
(device_id, user_id, device_name, user_name, is_owner,tenant_id,tenant_name,phonenumber, create_time) values
|
||||
<foreach collection="list" item="item" index="index" separator=",">
|
||||
(#{item.deviceId},#{item.userId},#{item.deviceName}, #{item.userName}, #{item.isOwner}, #{item.tenantId},#{item.tenantName},#{item.phonenumber}, #{item.createTime})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<update id="updateDeviceUser" parameterType="com.ruoyi.iot.domain.DeviceUser">
|
||||
update iot_device_user
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
@@ -88,7 +103,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
</trim>
|
||||
where device_id = #{deviceId}
|
||||
where device_id = #{deviceId} and user_id = #{userId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteDeviceUserByDeviceId" parameterType="Long">
|
||||
@@ -101,4 +116,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
#{deviceId}
|
||||
</foreach>
|
||||
</delete>
|
||||
<delete id="deleteDeviceUser">
|
||||
delete from iot_device_user where device_id = #{deviceId} and is_owner !=1 and user_id = #{userId}
|
||||
</delete>
|
||||
</mapper>
|
@@ -10,9 +10,9 @@ export function listDeviceUser(query) {
|
||||
}
|
||||
|
||||
// 查询设备用户详细
|
||||
export function getDeviceUser(deviceId) {
|
||||
export function getDeviceUser(deviceId, userId) {
|
||||
return request({
|
||||
url: '/iot/deviceUser/' + deviceId,
|
||||
url: '/iot/deviceUser/' + deviceId + '/' + userId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
@@ -26,6 +26,15 @@ export function addDeviceUser(data) {
|
||||
})
|
||||
}
|
||||
|
||||
// 新增多个设备用户
|
||||
export function addDeviceUsers(data) {
|
||||
return request({
|
||||
url: '/iot/deviceUser/addDeviceUsers',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改设备用户
|
||||
export function updateDeviceUser(data) {
|
||||
return request({
|
||||
@@ -36,9 +45,10 @@ export function updateDeviceUser(data) {
|
||||
}
|
||||
|
||||
// 删除设备用户
|
||||
export function delDeviceUser(deviceId) {
|
||||
export function delDeviceUser(device) {
|
||||
return request({
|
||||
url: '/iot/deviceUser/' + deviceId,
|
||||
method: 'delete'
|
||||
url: '/iot/deviceUser',
|
||||
method: 'delete',
|
||||
data: device
|
||||
})
|
||||
}
|
||||
|
@@ -108,12 +108,12 @@
|
||||
<device-timer ref="deviceTimer" :device="form" />
|
||||
</el-tab-pane>
|
||||
|
||||
<!--
|
||||
|
||||
<el-tab-pane name="deviceUser" :disabled="form.deviceId==0">
|
||||
<span slot="label">设备用户</span>
|
||||
<device-user ref="deviceUser" :device="form" @userEvent="getUserData($event)" />
|
||||
</el-tab-pane>
|
||||
-->
|
||||
|
||||
|
||||
<el-tab-pane name="deviceLog" :disabled="form.deviceId==0">
|
||||
<span slot="label">设备日志</span>
|
||||
|
@@ -3,6 +3,7 @@
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="selectUser" v-hasPermi="['iot:deviceUser:add']">分享设备</el-button>
|
||||
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="selectUserShareAllDevice" v-hasPermi="['iot:deviceUser:add']">分享所有设备</el-button>
|
||||
</el-col>
|
||||
<right-toolbar @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
@@ -43,7 +44,7 @@
|
||||
</el-dialog>
|
||||
|
||||
<!-- 选择用户 -->
|
||||
<user-list ref="userList" :device="device" />
|
||||
<user-list ref="userList" :device="devices" />
|
||||
|
||||
</div>
|
||||
</template>
|
||||
@@ -56,6 +57,9 @@ import {
|
||||
delDeviceUser,
|
||||
updateDeviceUser
|
||||
} from "@/api/iot/deviceuser";
|
||||
import {
|
||||
listDeviceShort,
|
||||
} from "@/api/iot/device";
|
||||
|
||||
export default {
|
||||
name: "device-user",
|
||||
@@ -73,6 +77,7 @@ export default {
|
||||
// 获取到父组件传递的device后,刷新列表
|
||||
device: function (newVal, oldVal) {
|
||||
this.deviceInfo = newVal;
|
||||
this.devices = [newVal];
|
||||
if (this.deviceInfo && this.deviceInfo.deviceId != 0) {
|
||||
this.queryParams.deviceId = this.deviceInfo.deviceId;
|
||||
this.getList();
|
||||
@@ -81,6 +86,8 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 设备列表
|
||||
devices: [],
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
@@ -189,7 +196,7 @@ export default {
|
||||
handleUpdate(row) {
|
||||
this.reset();
|
||||
const deviceId = row.deviceId || this.ids
|
||||
getDeviceUser(deviceId).then(response => {
|
||||
getDeviceUser(deviceId, row.userId).then(response => {
|
||||
this.form = response.data;
|
||||
this.open = true;
|
||||
this.title = "用户备注";
|
||||
@@ -207,9 +214,9 @@ export default {
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const deviceIds = row.deviceId || this.ids;
|
||||
this.$modal.confirm('是否确认删除设备用户编号为"' + deviceIds + '"的数据项?').then(function () {
|
||||
return delDeviceUser(deviceIds);
|
||||
const deviceUser = row;
|
||||
this.$modal.confirm('是否确认删除设备用户编号为"' + deviceUser.deviceId + "-" + deviceUser.userId + '"的数据项?').then(function () {
|
||||
return delDeviceUser(deviceUser);
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
@@ -223,8 +230,24 @@ export default {
|
||||
},
|
||||
// 选择用户
|
||||
selectUser() {
|
||||
this.devices = [this.device]
|
||||
this.$refs.userList.openSelectUser = true;
|
||||
},
|
||||
selectUserShareAllDevice() {
|
||||
this.loading = true;
|
||||
// 获取设备列表
|
||||
// 判断是否是admin角色
|
||||
if (this.$store.state.user.roles.indexOf("admin") === -1) {
|
||||
this.queryParams.userName = this.$store.state.user.name
|
||||
}
|
||||
listDeviceShort(this.queryParams).then(response => {
|
||||
let deviceList = response.rows;
|
||||
this.devices = deviceList
|
||||
this.loading = false;
|
||||
this.$refs.userList.openSelectUser = true;
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<el-dialog title="选择产品" :visible.sync="openSelectUser" width="800px">
|
||||
<el-dialog title="选择用户" :visible.sync="openSelectUser" width="800px">
|
||||
<div style="margin-top:-50px;">
|
||||
<el-divider></el-divider>
|
||||
</div>
|
||||
@@ -41,13 +41,14 @@ import {
|
||||
} from "@/api/system/user";
|
||||
import {
|
||||
addDeviceUser,
|
||||
addDeviceUsers,
|
||||
} from "@/api/iot/deviceuser";
|
||||
|
||||
export default {
|
||||
name: "user-list",
|
||||
props: {
|
||||
device: {
|
||||
type: Object,
|
||||
type: Array,
|
||||
default: null
|
||||
}
|
||||
},
|
||||
@@ -148,10 +149,11 @@ export default {
|
||||
},
|
||||
// 添加设备用户
|
||||
addDeviceUser() {
|
||||
if (this.deviceInfo.deviceId != null) {
|
||||
if (this.deviceInfo != null && this.deviceInfo.length > 0 && this.user != null) {
|
||||
if (this.deviceInfo.length == 1) {
|
||||
var form = {};
|
||||
form.deviceId = this.deviceInfo.deviceId;
|
||||
form.deviceName = this.deviceInfo.deviceName;
|
||||
form.deviceId = this.deviceInfo[0].deviceId;
|
||||
form.deviceName = this.deviceInfo[0].deviceName;
|
||||
form.userId = this.user.userId;
|
||||
form.userName = this.user.userName;
|
||||
form.phonenumber=this.user.phonenumber;
|
||||
@@ -161,6 +163,28 @@ export default {
|
||||
this.openSelectUser = false;
|
||||
this.$parent.getList();
|
||||
});
|
||||
} else {
|
||||
var form = [];
|
||||
this.deviceInfo.forEach(device => {
|
||||
let data = {};
|
||||
data.deviceId = device.deviceId;
|
||||
data.deviceName = device.deviceName
|
||||
data.userId = this.user.userId;
|
||||
data.userName = this.user.userName;
|
||||
data.phonenumber=this.user.phonenumber;
|
||||
form.push(data);
|
||||
});
|
||||
|
||||
addDeviceUsers(form).then(response => {
|
||||
this.$modal.msgSuccess("新增成功");
|
||||
this.resetQuery();
|
||||
this.openSelectUser = false;
|
||||
this.$parent.getList();
|
||||
});
|
||||
|
||||
}
|
||||
} else {
|
||||
this.openSelectUser = false;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
Reference in New Issue
Block a user