设备安装单/维修单优化,一级联营商合伙人登录之后可以看到别人给他创建的安装单和他给别人创建的安装单20231128wmz
15个文件已修改
2001 ■■■■ 已修改文件
wumei-smart-master/springboot/wumei-common/src/main/java/com/ruoyi/common/filter/RepeatableFilter.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/controller/DeviceOrderController.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/domain/Product.java 222 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/mapper/DeviceOrderMapper.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/mapper/ProductMapper.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/mqtt/EmqxCallback.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/mqtt/EmqxClient.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/impl/ProductServiceImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/impl/ToolServiceImpl.java 90 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-iot/src/main/resources/mapper/iot/DeviceMapper.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-iot/src/main/resources/mapper/iot/DeviceOrderMapper.xml 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-iot/src/main/resources/mapper/iot/ProductMapper.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/vue/src/views/equipmentManagement/installation.vue 1412 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/vue/src/views/equipmentManagement/maintenance.vue 154 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-common/src/main/java/com/ruoyi/common/filter/RepeatableFilter.java
@@ -8,45 +8,38 @@
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import org.springframework.http.MediaType;
import com.ruoyi.common.utils.StringUtils;
/**
 * Repeatable 过滤器
 *
 *
 * @author ruoyi
 */
public class RepeatableFilter implements Filter
{
public class RepeatableFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException
    {
    public void init(FilterConfig filterConfig) throws ServletException {
    }
    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
            throws IOException, ServletException
    {
            throws IOException, ServletException {
        ServletRequest requestWrapper = null;
        if (request instanceof HttpServletRequest
                && StringUtils.startsWithIgnoreCase(request.getContentType(), MediaType.APPLICATION_JSON_VALUE))
        {
                && StringUtils.startsWithIgnoreCase(request.getContentType(), MediaType.APPLICATION_JSON_VALUE)) {
            requestWrapper = new RepeatedlyRequestWrapper((HttpServletRequest) request, response);
        }
        if (null == requestWrapper)
        {
        if (null == requestWrapper) {
            chain.doFilter(request, response);
        }
        else
        {
        } else {
            chain.doFilter(requestWrapper, response);
        }
    }
    @Override
    public void destroy()
    {
    public void destroy() {
    }
}
wumei-smart-master/springboot/wumei-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java
@@ -20,6 +20,7 @@
 * @author ruoyi
 */
public class FileUploadUtils {
    /**
     * 默认大小 50M
     */
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/controller/DeviceOrderController.java
@@ -67,6 +67,8 @@
        return getDataTable(list);
    }
    /**
     * 添加安装设备订单信息
     *
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/domain/Product.java
@@ -7,52 +7,73 @@
/**
 * 产品对象 iot_product
 *
 *
 * @author kerwincui
 * @date 2021-12-16
 */
public class Product extends BaseEntity
{
public class Product extends BaseEntity {
    private static final long serialVersionUID = 1L;
    /** 产品ID */
    /**
     * 产品ID
     */
    private Long productId;
    /** 产品名称 */
    /**
     * 产品名称
     */
    @Excel(name = "产品名称")
    private String productName;
    /** 产品分类ID */
    /**
     * 产品分类ID
     */
    @Excel(name = "产品分类ID")
    private Long categoryId;
    /** 产品分类名称 */
    /**
     * 产品分类名称
     */
    @Excel(name = "产品分类名称")
    private String categoryName;
    /** 租户ID */
    /**
     * 租户ID
     */
    @Excel(name = "租户ID")
    private Long tenantId;
    /** 租户名称 */
    /**
     * 租户名称
     */
    @Excel(name = "租户名称")
    private String tenantName;
    /** 是否系统通用(0-否,1-是) */
    /**
     * 是否系统通用(0-否,1-是)
     */
    @Excel(name = "是否系统通用", readConverterExp = "0=-否,1-是")
    private Integer isSys;
    /** 是否启用授权码(0-否,1-是) */
    /**
     * 是否启用授权码(0-否,1-是)
     */
    @Excel(name = "是否启用授权码", readConverterExp = "0=-否,1-是")
    private Integer isAuthorize;
    /** mqtt账号 */
    /**
     * mqtt账号
     */
    private String mqttAccount;
    /** mqtt密码 */
    /**
     * mqtt密码
     */
    private String mqttPassword;
    /** 产品秘钥 */
    /**
     * 产品秘钥
     */
    private String mqttSecret;
    public String getMqttSecret() {
@@ -63,29 +84,43 @@
        this.mqttSecret = mqttSecret;
    }
    /** 状态(1-未发布,2-已发布,不能修改) */
    /**
     * 状态(1-未发布,2-已发布,不能修改)
     */
    @Excel(name = "状态", readConverterExp = "1==未发布,2=已发布,不能修改")
    private Integer status;
    /** 设备类型(1-直连设备、2-网关子设备、3-网关设备) */
    /**
     * 设备类型(1-直连设备、2-网关子设备、3-网关设备)
     */
    @Excel(name = "设备类型", readConverterExp = "1=直连设备、2=网关子设备、3=网关设备")
    private Integer deviceType;
    /** 联网方式(1=-wifi、2-蜂窝(2G/3G/4G/5G)、3-以太网、4-其他) */
    /**
     * 联网方式(1=-wifi、2-蜂窝(2G/3G/4G/5G)、3-以太网、4-其他)
     */
    @Excel(name = "联网方式", readConverterExp = "1=-wifi、2=蜂窝(2G/3G/4G/5G)、3=以太网、4=其他")
    private Integer networkMethod;
    /** 认证方式(1-账号密码、2-证书、3-Http) */
    /**
     * 认证方式(1-账号密码、2-证书、3-Http)
     */
    @Excel(name = "认证方式", readConverterExp = "1=账号密码、2=证书、3=Http")
    private Integer vertificateMethod;
    /** 图片地址 */
    /**
     * 图片地址
     */
    private String imgUrl;
    /** 删除标志(0代表存在 2代表删除) */
    /**
     * 删除标志(0代表存在 2代表删除)
     */
    private String delFlag;
    /** 物模型Json **/
    /**
     * 物模型Json
     **/
    private String thingsModelsJson;
    public String getThingsModelsJson() {
@@ -104,158 +139,147 @@
        this.imgUrl = imgUrl;
    }
    public void setProductId(Long productId)
    {
    public void setProductId(Long productId) {
        this.productId = productId;
    }
    public Long getProductId()
    {
    public Long getProductId() {
        return productId;
    }
    public void setProductName(String productName)
    {
    public void setProductName(String productName) {
        this.productName = productName;
    }
    public String getProductName()
    {
    public String getProductName() {
        return productName;
    }
    public void setCategoryId(Long categoryId)
    {
    public void setCategoryId(Long categoryId) {
        this.categoryId = categoryId;
    }
    public Long getCategoryId()
    {
    public Long getCategoryId() {
        return categoryId;
    }
    public void setCategoryName(String categoryName)
    {
    public void setCategoryName(String categoryName) {
        this.categoryName = categoryName;
    }
    public String getCategoryName()
    {
    public String getCategoryName() {
        return categoryName;
    }
    public void setTenantId(Long tenantId)
    {
    public void setTenantId(Long tenantId) {
        this.tenantId = tenantId;
    }
    public Long getTenantId()
    {
    public Long getTenantId() {
        return tenantId;
    }
    public void setTenantName(String tenantName)
    {
    public void setTenantName(String tenantName) {
        this.tenantName = tenantName;
    }
    public String getTenantName()
    {
    public String getTenantName() {
        return tenantName;
    }
    public void setIsSys(Integer isSys)
    {
    public void setIsSys(Integer isSys) {
        this.isSys = isSys;
    }
    public Integer getIsSys()
    {
    public Integer getIsSys() {
        return isSys;
    }
    public void setIsAuthorize(Integer isAuthorize) {this.isAuthorize = isAuthorize;}
    public Integer getIsAuthorize() {return isAuthorize;}
    public void setIsAuthorize(Integer isAuthorize) {
        this.isAuthorize = isAuthorize;
    }
    public void setMqttAccount(String mqttAccount)
    {
    public Integer getIsAuthorize() {
        return isAuthorize;
    }
    public void setMqttAccount(String mqttAccount) {
        this.mqttAccount = mqttAccount;
    }
    public String getMqttAccount()
    {
    public String getMqttAccount() {
        return mqttAccount;
    }
    public void setMqttPassword(String mqttPassword)
    {
    public void setMqttPassword(String mqttPassword) {
        this.mqttPassword = mqttPassword;
    }
    public String getMqttPassword()
    {
    public String getMqttPassword() {
        return mqttPassword;
    }
    public void setStatus(Integer status)
    {
    public void setStatus(Integer status) {
        this.status = status;
    }
    public Integer getStatus()
    {
    public Integer getStatus() {
        return status;
    }
    public void setDeviceType(Integer deviceType)
    {
    public void setDeviceType(Integer deviceType) {
        this.deviceType = deviceType;
    }
    public Integer getDeviceType()
    {
    public Integer getDeviceType() {
        return deviceType;
    }
    public void setNetworkMethod(Integer networkMethod)
    {
    public void setNetworkMethod(Integer networkMethod) {
        this.networkMethod = networkMethod;
    }
    public Integer getNetworkMethod()
    {
    public Integer getNetworkMethod() {
        return networkMethod;
    }
    public void setVertificateMethod(Integer vertificateMethod)
    {
    public void setVertificateMethod(Integer vertificateMethod) {
        this.vertificateMethod = vertificateMethod;
    }
    public Integer getVertificateMethod()
    {
    public Integer getVertificateMethod() {
        return vertificateMethod;
    }
    public void setDelFlag(String delFlag)
    {
    public void setDelFlag(String delFlag) {
        this.delFlag = delFlag;
    }
    public String getDelFlag()
    {
    public String getDelFlag() {
        return delFlag;
    }
    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("productId", getProductId())
            .append("productName", getProductName())
            .append("categoryId", getCategoryId())
            .append("categoryName", getCategoryName())
            .append("tenantId", getTenantId())
            .append("tenantName", getTenantName())
            .append("isSys", getIsSys())
            .append("isAuthorize", getIsAuthorize())
            .append("status", getStatus())
            .append("deviceType", getDeviceType())
            .append("networkMethod", getNetworkMethod())
            .append("vertificateMethod", getVertificateMethod())
            .append("delFlag", getDelFlag())
            .append("createBy", getCreateBy())
            .append("createTime", getCreateTime())
            .append("updateBy", getUpdateBy())
            .append("updateTime", getUpdateTime())
            .append("remark", getRemark())
            .toString();
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("productId", getProductId())
                .append("productName", getProductName())
                .append("categoryId", getCategoryId())
                .append("categoryName", getCategoryName())
                .append("tenantId", getTenantId())
                .append("tenantName", getTenantName())
                .append("isSys", getIsSys())
                .append("isAuthorize", getIsAuthorize())
                .append("status", getStatus())
                .append("deviceType", getDeviceType())
                .append("networkMethod", getNetworkMethod())
                .append("vertificateMethod", getVertificateMethod())
                .append("delFlag", getDelFlag())
                .append("createBy", getCreateBy())
                .append("createTime", getCreateTime())
                .append("updateBy", getUpdateBy())
                .append("updateTime", getUpdateTime())
                .append("remark", getRemark())
                .toString();
    }
}
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/mapper/DeviceOrderMapper.java
@@ -24,6 +24,14 @@
    public List<DeviceOrder> selectDeviceOrderList(DeviceOrder deviceOrder) throws Exception;
    /**
     * 查询设备订单分页查询信息
     *
     * @return
     * @throws Exception
     */
    public List<DeviceOrder> selectDeviceOrderList1(DeviceOrder deviceOrder) throws Exception;
    /**
     * 根据id查询安装订单信息
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/mapper/ProductMapper.java
@@ -9,16 +9,15 @@
/**
 * 产品Mapper接口
 *
 *
 * @author kerwincui
 * @date 2021-12-16
 */
@Repository
public interface ProductMapper
{
public interface ProductMapper {
    /**
     * 查询产品
     *
     *
     * @param productId 产品主键
     * @return 产品
     */
@@ -26,7 +25,7 @@
    /**
     * 查询产品列表
     *
     *
     * @param product 产品
     * @return 产品集合
     */
@@ -42,7 +41,7 @@
    /**
     * 新增产品
     *
     *
     * @param product 产品
     * @return 结果
     */
@@ -50,7 +49,7 @@
    /**
     * 修改产品
     *
     *
     * @param product 产品
     * @return 结果
     */
@@ -74,7 +73,7 @@
    /**
     * 删除产品
     *
     *
     * @param productId 产品主键
     * @return 结果
     */
@@ -82,7 +81,7 @@
    /**
     * 批量删除产品
     *
     *
     * @param productIds 需要删除的数据主键集合
     * @return 结果
     */
@@ -98,6 +97,7 @@
    /**
     * 产品下的固件数量
     *
     * @param productIds 需要删除的数据主键集合
     * @return 结果
     */
@@ -105,6 +105,7 @@
    /**
     * 产品下的设备数量
     *
     * @param productIds 需要删除的数据主键集合
     * @return 结果
     */
@@ -112,6 +113,7 @@
    /**
     * 产品下的物模型数量
     *
     * @param productId 需要删除的数据主键集合
     * @return 结果
     */
@@ -119,6 +121,7 @@
    /**
     * 产品下的物模型标识符重复数
     *
     * @param productId 需要删除的数据主键集合
     * @return 结果
     */
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/mqtt/EmqxCallback.java
@@ -1,6 +1,5 @@
package com.ruoyi.iot.mqtt;
import com.ruoyi.framework.web.domain.server.Sys;
import org.eclipse.paho.client.mqttv3.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -23,12 +22,27 @@
    @Autowired
    private EmqxService emqxService;
    /**
     * 客户端丢失了对服务端的连接后触发的方法回调
     *
     * @param throwable
     */
    @Override
    public void connectionLost(Throwable throwable) {
        //资源的清理 重连
        logger.info("mqtt断开连接--");
    }
    /**
     * messageArrived-同步的回调
     * 同步调用就是在这个messageArrived方法未执行正确返回之前,这个mqtt客户端是不会对服务端做出这个任何确认的
     * 一旦该方法向外抛出了异常客户端将异常关闭,当再次连接时;所有QoS1,QoS2且客户端未进行ack确认的消息都将由broker服务器再次发送到客户端
     *
     * @param topic
     * @param mqttMessage
     * @throws Exception
     */
    @Override
    public void messageArrived(String topic, MqttMessage mqttMessage) throws Exception {
        emqxService.subscribeCallback(topic, mqttMessage);
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/mqtt/EmqxClient.java
@@ -157,9 +157,13 @@
     * 重新连接MQTT
     */
    public synchronized void refresh() {
        //断开与mqtt的连接
        disconnect();
        //设置连接属性
        setOptions();
        //创建客户端
        createClient();
        //连接MQTT服务器
        connect();
    }
@@ -174,12 +178,15 @@
     */
    public void publish(int qos, boolean retained, String topic, String pushMessage) {
        logger.info("发布主题" + topic);
        //创建MqttMessage对象
        MqttMessage message = new MqttMessage();
        //设置消息的内容
        message.setQos(qos);
        message.setRetained(retained);
        message.setPayload(pushMessage.getBytes());
        try {
            //mqttclient里面的发布消息
            IMqttDeliveryToken token = client.publish(topic, message);
            token.waitForCompletion();
        } catch (MqttPersistenceException e) {
@@ -201,6 +208,7 @@
    public void subscribe(String topic, int qos) {
        logger.info("=======>>>>>订阅了主题 topic={}", topic);
        try {
            //订阅主题的方法
            IMqttToken token = client.subscribe(topic, qos);
            token.waitForCompletion();
        } catch (MqttException e) {
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/impl/ProductServiceImpl.java
@@ -107,7 +107,7 @@
        // mqtt账号密码
        product.setMqttAccount("wumei-smart");
        product.setMqttPassword("P" + toolService.getStringRandom(15));
        product.setMqttSecret("K" + toolService.getStringRandom(15));
        //product.setMqttSecret("K" + toolService.getStringRandom(15));
        product.setStatus(product.getStatus() == null ? 1 : product.getStatus());
        product.setTenantId(user.getUserId());
        product.setTenantName(user.getUserName());
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/impl/ToolServiceImpl.java
@@ -1,6 +1,5 @@
package com.ruoyi.iot.service.impl;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.domain.entity.SysUser;
@@ -37,13 +36,11 @@
import java.util.Random;
/**
 *
 * @author kerwincui
 * @date 2021-12-16
 */
@Service
public class ToolServiceImpl implements IToolService
{
public class ToolServiceImpl implements IToolService {
    private static final Logger log = LoggerFactory.getLogger(ToolServiceImpl.class);
    @Autowired
@@ -76,14 +73,14 @@
        String val = "";
        Random random = new Random();
        //参数length,表示生成几位随机数
        for(int i = 0; i < length; i++) {
        for (int i = 0; i < length; i++) {
            String charOrNum = random.nextInt(2) % 2 == 0 ? "char" : "num";
            //输出字母还是数字
            if( "char".equalsIgnoreCase(charOrNum) ) {
            if ("char".equalsIgnoreCase(charOrNum)) {
                //输出是大写字母还是小写字母
                // int temp = random.nextInt(2) % 2 == 0 ? 65 : 97;
                val += (char)(random.nextInt(26) + 65);
            } else if( "num".equalsIgnoreCase(charOrNum) ) {
                val += (char) (random.nextInt(26) + 65);
            } else if ("num".equalsIgnoreCase(charOrNum)) {
                val += String.valueOf(random.nextInt(10));
            }
        }
@@ -95,47 +92,33 @@
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public String register(RegisterUserInput registerBody)
    {
    public String register(RegisterUserInput registerBody) {
        String msg = "";
        String username = registerBody.getUsername();
        String password = registerBody.getPassword();
        String phonenumber=registerBody.getPhonenumber();
        String phonenumber = registerBody.getPhonenumber();
        boolean captchaOnOff = configService.selectCaptchaOnOff();
        // 验证码开关
        if (captchaOnOff)
        {
        if (captchaOnOff) {
            validateCaptcha(username, registerBody.getCode(), registerBody.getUuid());
        }
        if (StringUtils.isEmpty(username))
        {
        if (StringUtils.isEmpty(username)) {
            msg = "用户名不能为空";
        }
        else if (StringUtils.isEmpty(password))
        {
        } else if (StringUtils.isEmpty(password)) {
            msg = "用户密码不能为空";
        }
        else if (username.length() < UserConstants.USERNAME_MIN_LENGTH
                || username.length() > UserConstants.USERNAME_MAX_LENGTH)
        {
        } else if (username.length() < UserConstants.USERNAME_MIN_LENGTH
                || username.length() > UserConstants.USERNAME_MAX_LENGTH) {
            msg = "账户长度必须在2到20个字符之间";
        }
        else if (password.length() < UserConstants.PASSWORD_MIN_LENGTH
                || password.length() > UserConstants.PASSWORD_MAX_LENGTH)
        {
        } else if (password.length() < UserConstants.PASSWORD_MIN_LENGTH
                || password.length() > UserConstants.PASSWORD_MAX_LENGTH) {
            msg = "密码长度必须在5到20个字符之间";
        }
        else if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(username)))
        {
        } else if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(username))) {
            msg = "保存用户'" + username + "'失败,注册账号已存在";
        }else if (UserConstants.NOT_UNIQUE.equals(checkPhoneUnique(phonenumber)))
        {
        } else if (UserConstants.NOT_UNIQUE.equals(checkPhoneUnique(phonenumber))) {
            msg = "保存用户'" + username + "'失败,注册手机号码已存在";
        }
        else
        {
        } else {
            SysUser sysUser = new SysUser();
            sysUser.setUserName(username);
            sysUser.setNickName(username);
@@ -143,14 +126,11 @@
            sysUser.setPassword(SecurityUtils.encryptPassword(registerBody.getPassword()));
            boolean regFlag = userService.registerUser(sysUser);
            //分配普通用户角色(1=超级管理员,2=设备租户,3=普通用户,4=游客)
            Long[] roleIds={3L};
            userService.insertUserAuth(sysUser.getUserId(),roleIds);
            if (!regFlag)
            {
            Long[] roleIds = {3L};
            userService.insertUserAuth(sysUser.getUserId(), roleIds);
            if (!regFlag) {
                msg = "注册失败,请联系系统管理人员";
            }
            else
            {
            } else {
                AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.REGISTER,
                        MessageUtils.message("user.register.success")));
            }
@@ -165,8 +145,7 @@
     * @return 用户信息集合信息
     */
    @Override
    public List<SysUser> selectUserList(SysUser user)
    {
    public List<SysUser> selectUserList(SysUser user) {
        return userMapper.selectUserList(user);
    }
@@ -176,11 +155,9 @@
     * @param phonenumber 手机号码
     * @return
     */
    public String checkPhoneUnique(String phonenumber)
    {
    public String checkPhoneUnique(String phonenumber) {
        SysUser info = userMapper.checkPhoneUnique(phonenumber);
        if (StringUtils.isNotNull(info))
        {
        if (StringUtils.isNotNull(info)) {
            return UserConstants.NOT_UNIQUE;
        }
        return UserConstants.UNIQUE;
@@ -190,21 +167,18 @@
     * 校验验证码
     *
     * @param username 用户名
     * @param code 验证码
     * @param uuid 唯一标识
     * @param code     验证码
     * @param uuid     唯一标识
     * @return 结果
     */
    public void validateCaptcha(String username, String code, String uuid)
    {
    public void validateCaptcha(String username, String code, String uuid) {
        String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
        String captcha = redisCache.getCacheObject(verifyKey);
        redisCache.deleteObject(verifyKey);
        if (captcha == null)
        {
        if (captcha == null) {
            throw new CaptchaExpireException();
        }
        if (!code.equalsIgnoreCase(captcha))
        {
        if (!code.equalsIgnoreCase(captcha)) {
            throw new CaptchaException();
        }
    }
@@ -215,7 +189,7 @@
    @Override
    public ResponseEntity simpleMqttAuthentication(MqttAuthenticationModel mqttModel, ProductAuthenticateModel productModel) {
        // 1=简单认证,2=加密认证,3=简单+加密认证
        if(productModel.getVertificateMethod()!=1 && productModel.getVertificateMethod()!=3){
        if (productModel.getVertificateMethod() != 1 && productModel.getVertificateMethod() != 3) {
            return returnUnauthorized(mqttModel, "设备简单认证,设备对应产品不支持简单认证");
        }
        String[] passwordArray = mqttModel.getPassword().split("&");
@@ -265,7 +239,7 @@
    @Override
    public ResponseEntity encryptAuthentication(MqttAuthenticationModel mqttModel, ProductAuthenticateModel productModel) throws Exception {
        // 1=简单认证,2=加密认证,3=简单+加密认证
        if(productModel.getVertificateMethod()!=2 && productModel.getVertificateMethod()!=3){
        if (productModel.getVertificateMethod() != 2 && productModel.getVertificateMethod() != 3) {
            return returnUnauthorized(mqttModel, "设备加密认证,设备对应产品不支持加密认证");
        }
        String decryptPassword = AESUtils.decrypt(mqttModel.getPassword(), productModel.getMqttSecret());
@@ -334,7 +308,7 @@
        }
        if (authorize.getSerialNumber() != null && !authorize.getSerialNumber().equals("")) {
            // 授权码已关联设备
            if (!authorize.getSerialNumber().equals( productModel.getSerialNumber())) {
            if (!authorize.getSerialNumber().equals(productModel.getSerialNumber())) {
                message = "设备认证,设备授权码已经分配给其他设备";
                return message;
            }
wumei-smart-master/springboot/wumei-iot/src/main/resources/mapper/iot/DeviceMapper.xml
@@ -687,7 +687,7 @@
        </foreach>
    </delete>
    <select id="getDeviceNumCount" parameterType="String" resultType="int">
    <select id="getDeviceNumCount " parameterType="String" resultType="int">
        select count(*)
        from iot_device
        where serial_number = #{deviceNum}
wumei-smart-master/springboot/wumei-iot/src/main/resources/mapper/iot/DeviceOrderMapper.xml
@@ -98,13 +98,14 @@
        left join sys_user as u on d.erecto_id = u.user_id
        left join iot_device as de on d.device_id = de.device_id
        where d.order_type = #{orderType}
        <if test=" createUserId  != null and createUserId > 0">
            and d.createuser_id= #{createUserId}
        <if test=" createUserId  != null and createUserId != 0 ">
            and d.createuser_id= #{createUserId} or d.erecto_id = #{createUserId}
        </if>
        <if test=" erectoId  != null and erectoId > 0">
            and d.erecto_id= #{erectoId}
        </if>
        <if test="state != null and state >= 0">
        <if test=" state != null and state >= 0">
            and d.state = #{state}
        </if>
        order by d.create_time desc
@@ -137,6 +138,33 @@
                 left join iot_device as de on d.device_id = de.device_id
        where d.id = #{id}
    </select>
    <select id="selectDeviceOrderList1" resultType="com.ruoyi.iot.domain.DeviceOrder">
        select d.id,
               d.user_id,
               d.erecto_id,
               d.erecto_name,
               d.user_name,
               d.user_phone,
               d.address,
               d.order_type,
               d.appointment_time,
               d.evaluate,
               d.device_id,
               d.remark,
               d.description,
               u.user_id,
               u.user_name,
               u.is_authentication,
               d.score,
               d.state,
               d.createuser_id,
               de.device_id,
               de.device_name
        from iot_device_order as d
                 left join sys_user as u on d.erecto_id = u.user_id
                 left join iot_device as de on d.device_id = de.device_id
        where d.id = #{id}
    </select>
    <insert id="insertDeviceOrder" parameterType="DeviceOrder" useGeneratedKeys="true" keyProperty="id">
        insert into iot_device_order(
wumei-smart-master/springboot/wumei-iot/src/main/resources/mapper/iot/ProductMapper.xml
@@ -15,7 +15,7 @@
        <result property="isAuthorize" column="is_authorize"/>
        <result property="mqttAccount" column="mqtt_account"/>
        <result property="mqttPassword" column="mqtt_password"/>
        <result property="mqttSecret" column="mqtt_secret"/>
<!--        <result property="mqttSecret" column="mqtt_secret"/>-->
        <result property="status" column="status"/>
        <result property="deviceType" column="device_type"/>
        <result property="networkMethod" column="network_method"/>
@@ -42,7 +42,7 @@
               is_authorize,
               mqtt_account,
               mqtt_password,
               mqtt_secret,
--                mqtt_secret,
               status,
               device_type,
               network_method,
wumei-smart-master/vue/src/views/equipmentManagement/installation.vue
@@ -1,50 +1,31 @@
<template>
  <div id="" style="padding: 6px">
    <el-card style="margin-bottom: 6px">
      <el-form :model="queryParams" ref="queryForm" :inline="true">
        <el-form-item label="状态" prop="status">
          <el-select v-model="state" placeholder="菜单状态" size="mini">
            <el-option label="全部" :value="-1" />
            <el-option label="未派单" :value="0" />
            <el-option label="已派单" :value="1" />
            <el-option label="已接单" :value="2" />
            <el-option label="已完成" :value="3" />
          </el-select>
        </el-form-item>
        <el-form-item label="等级" prop="level">
          <el-select
            v-model="level"
            placeholder="菜单状态"
            :disabled="erectoListLevel.length == 0"
            size="mini"
          >
            <el-option label="本级" :value="0" />
            <el-option label="下级" :value="1" />
          </el-select>
        </el-form-item>
        <el-form-item
          v-if="level == 1 && erectoListLevel.length > 0"
          label="下级联营商"
          prop="nextlevel"
        >
          <el-select v-model="nextlevel" placeholder="菜单状态" size="mini">
            <el-option
              v-for="item in erectoListLevel"
              :label="item.dept.deptName"
              :value="item.userId"
            />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button
            size="mini"
            type="primary"
            icon="el-icon-search"
            @click="changePage(1)"
            >搜索</el-button
          ></el-form-item
        >
        <!-- <el-form-item label="状态" prop="status">
    <div id="" style="padding:6px;">
        <el-card style="margin-bottom:6px;">
            <el-form :model="queryParams" ref="queryForm" :inline="true">
                <el-form-item label="状态" prop="status">
                    <el-select v-model="state" placeholder="菜单状态" size="mini">
                        <el-option label="全部" :value="-1" />
                        <el-option label="未派单" :value="0" />
                        <el-option label="已派单" :value="1" />
                        <el-option label="已接单" :value="2" />
                        <el-option label="已完成" :value="3" />
                    </el-select>
                </el-form-item>
                <el-form-item label="等级" prop="level">
                    <el-select v-model="level" placeholder="菜单状态" :disabled="erectoListLevel.length == 0" size="mini">
                        <el-option label="本级" :value="0" />
                        <el-option label="下级" :value="1" />
                    </el-select>
                </el-form-item>
                <el-form-item v-if="level == 1 && erectoListLevel.length > 0" label="下级联营商" prop="nextlevel">
                    <el-select v-model="nextlevel" placeholder="菜单状态" size="mini">
                        <el-option v-for="item in erectoListLevel" :label="item.dept.deptName" :value="item.userId" />
                    </el-select>
                </el-form-item>
                <el-form-item>
                    <el-button size="mini" type="primary" icon="el-icon-search"
                        @click="changePage(1)">搜索</el-button></el-form-item>
                <!-- <el-form-item label="状态" prop="status">
                    <el-select v-model="queryParams.WXBody" placeholder="菜单状态" clearable size="small">
                        <el-option v-for="dict in WXBodyType" :key="dict.value" :label="dict.label" :value="dict.value" />
                    </el-select>
@@ -55,274 +36,183 @@
                        <el-button slot="append" icon="el-icon-search"></el-button>
                    </el-input>
                </el-form-item> -->
        <el-form-item style="float: right" v-if="roleKey !== 'admin'">
          <el-button
            type="primary"
            v-hasPermi="['iot:device:add']"
            plain
            icon="el-icon-plus"
            size="mini"
            @click="openAZModal"
            >新增</el-button
          >
        </el-form-item>
      </el-form>
      <el-table
        :data="tableData"
        style="width: 100%"
        @selection-change="handleSelectionChange"
      >
        <el-table-column type="selection" fixed width="55"> </el-table-column>
        <el-table-column prop="id" label="编号" width="60"> </el-table-column>
        <el-table-column label="安装信息">
          <el-table-column prop="device" label="设备名称" width="120">
            <template slot-scope="scope">
              <div>
                {{
                  scope.row.device && scope.row.device.deviceName
                    ? scope.row.device.deviceName
                    : "--"
                }}
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="erectoName" label="安装工" width="120">
          </el-table-column>
                <el-form-item style="float: right;" v-if="roleKey !== 'admin'">
                    <el-button type="primary" v-hasPermi="['iot:device:add']" plain icon="el-icon-plus" size="mini"
                        @click="openAZModal">新增</el-button>
                </el-form-item>
            </el-form>
            <el-table :data="tableData" style="width: 100%" @selection-change="handleSelectionChange">
                <el-table-column type="selection" fixed width="55">
                </el-table-column>
                <el-table-column prop="id" label="编号" width="60">
                </el-table-column>
                <el-table-column label="安装信息">
                    <el-table-column prop="device" label="设备名称" width="120">
                        <template slot-scope="scope">
                            <div>
                                {{ scope.row.device && scope.row.device.deviceName ? scope.row.device.deviceName : '--' }}
                            </div>
          <el-table-column prop="appointmentTime" label="预约时间" width="150">
            <template slot-scope="scope">
              <div>
                {{
                  scope.row.appointmentTime ? scope.row.appointmentTime : "--"
                }}
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="remark" label="备注">
            <template slot-scope="scope">
              <div>
                {{ scope.row.remark ? scope.row.remark : "--" }}
              </div>
            </template>
          </el-table-column>
        </el-table-column>
        <el-table-column label="状态" prop="state" width="120">
          <template slot-scope="scope">
            <div v-if="scope.row.state == 0">未派单</div>
            <div v-if="scope.row.state == 1">已派单</div>
            <div v-if="scope.row.state == 2">已接单</div>
            <div v-if="scope.row.state == 3">已完成</div>
          </template>
        </el-table-column>
        <el-table-column label="用户信息">
          <el-table-column prop="userName" label="联系人" width="120">
          </el-table-column>
          <el-table-column prop="userPhone" label="联系电话" width="120">
          </el-table-column>
          <el-table-column prop="address" label="地址"> </el-table-column>
        </el-table-column>
        <!-- <el-table-column label="评价信息">
                        </template>
                    </el-table-column>
                    <el-table-column prop="erectoName" label="安装工" width="120">
                    </el-table-column>
                    <el-table-column prop="appointmentTime" label="预约时间" width="150">
                        <template slot-scope="scope">
                            <div>
                                {{ scope.row.appointmentTime ? scope.row.appointmentTime : '--' }}
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column prop="remark" label="备注">
                        <template slot-scope="scope">
                            <div>
                                {{ scope.row.remark ? scope.row.remark : '--' }}
                            </div>
                        </template>
                    </el-table-column>
                </el-table-column>
                <el-table-column label="状态" prop="state" width="120">
                    <template slot-scope="scope">
                        <div v-if="scope.row.state == 0">
                            未派单
                        </div>
                        <div v-if="scope.row.state == 1">
                            已派单
                        </div>
                        <div v-if="scope.row.state == 2">
                            已接单
                        </div>
                        <div v-if="scope.row.state == 3">
                            已完成
                        </div>
                    </template>
                </el-table-column>
                <el-table-column label="用户信息">
                    <el-table-column prop="userName" label="联系人" width="120">
                    </el-table-column>
                    <el-table-column prop="userPhone" label="联系电话" width="120">
                    </el-table-column>
                    <el-table-column prop="address" label="地址">
                    </el-table-column>
                </el-table-column>
                <!-- <el-table-column label="评价信息">
                    <el-table-column prop="score" label="评分" width="120">
                    </el-table-column>
                    <el-table-column prop="evaluate" label="评价" minWidth="120">
                    </el-table-column>
                </el-table-column> -->
        <el-table-column
          label="操作"
          fixed="right"
          align="center"
          width="150"
          class-name="small-padding fixed-width"
          v-if="roleKey !== 'admin'"
        >
          <template slot-scope="scope">
            <div style="display: flex; justify-content: space-around">
              <el-button
                v-if="scope.row.state != 3"
                size="small"
                type="primary"
                style="padding: 5px"
                icon="el-icon-edit"
                v-hasPermi="['iot:device:edit']"
                @click="editModal(scope.row)"
                >修改</el-button
              >
              <el-button
                v-if="scope.row.state == 0"
                size="small"
                type="danger"
                style="padding: 5px"
                icon="el-icon-delete"
                v-hasPermi="['iot:device:remove']"
                @click="delModal(scope.row)"
                >删除</el-button
              >
              <el-button
                v-if="scope.row.state == 1 && scope.row.erectoName == nickName"
                size="small"
                type="success"
                style="padding: 5px"
                icon="el-icon-odometer"
                @click="JDModal(scope.row)"
                >接单</el-button
              >
              <el-button
                v-if="scope.row.state == 2 && scope.row.erectoName == nickName"
                size="small"
                type="success"
                style="padding: 5px"
                icon="el-icon-check"
                @click="jdModal(scope.row)"
                >结单</el-button
              >
            </div>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        background
        :current-page="pageIndex"
        @current-change="changePage"
        :page-size="pageSize"
        layout="prev, pager, next"
        :total="total"
        style="margin-top: 12px"
      >
      </el-pagination>
    </el-card>
                <el-table-column label="操作" fixed="right" align="center" width="150" class-name="small-padding fixed-width"
                    v-if="roleKey !== 'admin'">
                    <template slot-scope="scope">
                        <div style="display: flex;justify-content: space-around;">
                            <el-button v-if="scope.row.state != 3" size="small" type="primary" style="padding:5px;"
                                icon="el-icon-edit" v-hasPermi="['iot:device:edit']"
                                @click="editModal(scope.row)">修改</el-button>
                            <el-button v-if="scope.row.state == 0" size="small" type="danger" style="padding:5px;"
                                icon="el-icon-delete" v-hasPermi="['iot:device:remove']"
                                @click="delModal(scope.row)">删除</el-button>
                            <el-button v-if="scope.row.state == 1 && scope.row.erectoName == nickName" size="small"
                                type="success" style="padding:5px;" icon="el-icon-odometer"
                                @click="JDModal(scope.row)">接单</el-button>
                            <el-button v-if="scope.row.state == 2 && scope.row.erectoName == nickName" size="small"
                                type="success" style="padding:5px;" icon="el-icon-check"
                                @click="jdModal(scope.row)">结单</el-button>
                            <el-button v-if="scope.row.state == 3" size="small" type="success" style="padding:5px;"
                                icon="el-icon-view" @click="viewModal(scope.row)">查看</el-button>
                        </div>
                    </template>
                </el-table-column>
            </el-table>
            <el-pagination background :current-page="pageIndex" @current-change="changePage" :page-size="pageSize"
                layout="prev, pager, next" :total="total" style="margin-top: 12px;">
            </el-pagination>
        </el-card>
    <el-dialog :title="title" :visible.sync="AZModal">
      <el-form :model="form" :rules="rules" ref="form">
        <el-form-item
          label="设备"
          :label-width="formLabelWidth"
          prop="deviceId"
        >
          <el-select
            v-model="form.deviceId"
            placeholder="请选择"
            :disabled="title == '修改安装单'"
          >
            <el-option
              v-for="item in deviceList"
              :label="item.deviceName"
              :value="item.deviceId"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item
          label="安装工"
          :label-width="formLabelWidth"
          prop="erectoId"
        >
          <el-select
            v-model="form.erectoId"
            placeholder="请选择"
            :disabled="form.state > 1 || roleKey == 'tenantservice'"
          >
            <el-option
              v-for="item in erectoList"
              :label="item.nickName"
              :value="item.userId"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="状态" :label-width="formLabelWidth" prop="state">
          <el-radio-group v-model="form.state" disabled>
            <el-radio :label="0">未指派</el-radio>
            <el-radio :label="1">已派单</el-radio>
            <el-radio :label="2">已接单</el-radio>
            <el-radio :label="3">已完成</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item
          label="用户姓名"
          :label-width="formLabelWidth"
          prop="userName"
        >
          <el-input v-model="form.userName" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item
          label="手机号"
          :label-width="formLabelWidth"
          prop="userPhone"
        >
          <el-input v-model="form.userPhone" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item
          label="安装地址"
          :label-width="formLabelWidth"
          prop="address"
        >
          <el-input v-model="form.address" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="预约时间" :label-width="formLabelWidth">
          <el-date-picker
            v-model="form.appointmentTime"
            type="datetime"
            placeholder="选择日期时间"
            :disabled="form.state == 3"
            value-format="yyyy-MM-dd HH:mm:ss"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="备注" :label-width="formLabelWidth">
          <el-input type="textarea" v-model="form.remark"></el-input>
        </el-form-item>
        <el-form-item
          label="上传图片"
          v-if="form.state == 3"
          :label-width="formLabelWidth"
        >
          <el-upload
            ref="uploadImg"
            action="#"
            :on-change="handleChange"
            list-type="picture-card"
            :multiple="false"
            :auto-upload="false"
            :on-preview="handlePictureCardPreview"
            :headers="headerObj"
            :limit="1"
            :on-exceed="exceed"
            :on-remove="handleRemove"
          >
            <i class="el-icon-plus"></i>
          </el-upload>
          <el-dialog :visible.sync="dialogVisible">
            <img width="100%" :src="dialogImageUrl" alt="" />
          </el-dialog>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="AZModal = false" size="mini">取 消</el-button>
        <el-button type="primary" @click="submitForm('form')" size="mini"
          >确 定</el-button
        >
      </div>
    </el-dialog>
    <el-dialog title="删除数据" :visible.sync="deleteModal" width="30%">
      <span>是否删除该条数据</span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="deleteModal = false" size="mini">取 消</el-button>
        <el-button type="primary" @click="delDate" size="mini">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog title="接单" :visible.sync="acceptModal" width="30%">
      <span>是否确认接单?此操作不可恢复!</span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="acceptModal = false" size="mini">取 消</el-button>
        <el-button type="primary" @click="add" size="mini">确 定</el-button>
      </span>
    </el-dialog>
  </div>
        <el-dialog :title="title" :visible.sync="AZModal">
            <el-form :model="form" :rules="rules" ref="form">
                <el-form-item label="设备" :label-width="formLabelWidth" prop="deviceId">
                    <el-select v-model="form.deviceId" placeholder="请选择" :disabled="title == '修改安装单'||view">
                        <el-option v-for="item in deviceList" :label="item.deviceName" :value="item.deviceId"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="安装工" :label-width="formLabelWidth" prop="erectoId">
                    <el-select v-model="form.erectoId" placeholder="请选择"
                        :disabled="form.state > 1 || roleKey == 'tenantservice'">
                        <el-option v-for="item in erectoList" :label="item.nickName" :value="item.userId"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="状态" :label-width="formLabelWidth" prop="state">
                    <el-radio-group v-model="form.state" disabled>
                        <el-radio :label="0">未指派</el-radio>
                        <el-radio :label="1">已派单</el-radio>
                        <el-radio :label="2">已接单</el-radio>
                        <el-radio :label="3">已完成</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="用户姓名" :label-width="formLabelWidth" prop="userName">
                    <el-input v-model="form.userName" autocomplete="off" :disabled="view"></el-input>
                </el-form-item>
                <el-form-item label="手机号" :label-width="formLabelWidth" prop="userPhone">
                    <el-input v-model="form.userPhone" autocomplete="off" :disabled="view"></el-input>
                </el-form-item>
                <el-form-item label="安装地址" :label-width="formLabelWidth" prop="address">
                    <el-input v-model="form.address" autocomplete="off" :disabled="view"></el-input>
                </el-form-item>
                <el-form-item label="预约时间" :label-width="formLabelWidth">
                    <el-date-picker v-model="form.appointmentTime" type="datetime" placeholder="选择日期时间"
                        :disabled="form.state == 3" value-format="yyyy-MM-dd HH:mm:ss">
                    </el-date-picker>
                </el-form-item>
                <el-form-item label="备注" :label-width="formLabelWidth">
                    <el-input type="textarea" v-model="form.remark" :disabled="view"></el-input>
                </el-form-item>
                <el-form-item label="图片" v-if="view" :label-width="formLabelWidth">
                    <img :src="form.imgUrl" alt="">
                </el-form-item>
                <el-form-item label="上传图片" v-if=" form.state == 3 && !view " :label-width=" formLabelWidth ">
                    <el-upload ref="uploadImg" action="#" :on-change=" handleChange " list-type="picture-card"
                        :multiple=" false " :auto-upload=" false " :on-preview=" handlePictureCardPreview " :headers=" headerObj "
                        :limit=" 1 " :on-exceed=" exceed " :on-remove=" handleRemove ">
                        <i class="el-icon-plus"></i>
                    </el-upload>
                    <el-dialog :visible.sync=" dialogVisible ">
                        <img width="100%" :src=" dialogImageUrl " alt="">
                    </el-dialog>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="AZModal = false" :disabled="view" size="mini">取 消</el-button>
                <el-button type="primary" @click="submitForm('form')" :disabled="view" size="mini">确 定</el-button>
            </div>
        </el-dialog>
        <el-dialog title="删除数据" :visible.sync=" deleteModal " width="30%">
            <span>是否删除该条数据</span>
            <span slot="footer" class="dialog-footer">
                <el-button @click="deleteModal = false" size="mini">取 消</el-button>
                <el-button type="primary" @click=" delDate " size="mini">确 定</el-button>
            </span>
        </el-dialog>
        <el-dialog title="接单" :visible.sync=" acceptModal " width="30%">
            <span>是否确认接单?此操作不可恢复!</span>
            <span slot="footer" class="dialog-footer">
                <el-button @click="acceptModal = false" size="mini">取 消</el-button>
                <el-button type="primary" @click=" add " size="mini">确 定</el-button>
            </span>
        </el-dialog>
    </div>
</template>
<script>
import request from "@/utils/request";
import request from '@/utils/request'
import FileUpload from "@/components/FileUpload/index.vue";
import { getToken } from "@/utils/auth";
import {
    getToken
} from "@/utils/auth";
// import {
//     listAlertLog,
//     getAlertLog,
@@ -332,477 +222,485 @@
// } from "@/api/iot/alertLog";
export default {
  // name: "AlertLog",
  // dicts: ['iot_alert_level', 'iot_process_status'],
  components: {
    FileUpload,
  },
  data() {
    return {
      nickName: localStorage.getItem("nickName"),
      headerObj: {
        Authorization: "Bearer " + getToken(),
      },
      acceptModal: false,
      acceptDateParams: {},
      nextlevel: 0,
      level: 0,
      title: "创建安装单",
      deleteModal: false,
      pageIndex: 1,
      pageSize: 10,
      total: 20,
      searchName: "",
      queryParams: {
        WXBody: "未派单",
        PDBody: "未派单",
      },
      WXBodyType: [
        { label: "全部工单", value: "全部工单" },
        { label: "未派单", value: "未派单" },
        { label: "num1", value: "num1" },
      ],
      rules: {
        deviceId: [
          { required: true, message: "请选择设备", trigger: "change" },
        ],
        erectoId: [
          { required: true, message: "请选择安装工", trigger: "change" },
        ],
        userName: [
          { required: true, message: "用户姓名不能为空", trigger: "blur" },
        ],
        userPhone: [
          { required: true, trigger: "blur", message: "请输入您的手机号码" },
          {
            pattern: /^1[3456789]\d{9}$/,
            message: "手机号码格式不正确",
            trigger: "blur",
          },
        ],
        address: [
          { required: true, message: "安装地址不能为空", trigger: "blur" },
        ],
      },
      form: {},
      tableData: [],
      formLabelWidth: "120px",
      AZModal: false,
      deviceList: [],
      state: -1,
      id: 0,
      erectoList: [],
      erectoListLevel: [],
      roleKey: localStorage.getItem("roleKey"),
      dialogImageUrl: "",
      dialogVisible: false,
    };
  },
    // name: "AlertLog",
    // dicts: ['iot_alert_level', 'iot_process_status'],
    components: {
        FileUpload
    },
    data() {
        return {
            nickName: localStorage.getItem('nickName'),
            headerObj: {
                Authorization: "Bearer " + getToken()
            },
            acceptModal: false,
            acceptDateParams: {},
            nextlevel: 0,
            level: 0,
            title: '创建安装单',
            deleteModal: false,
            pageIndex: 1,
            pageSize: 10,
            total: 20,
            searchName: '',
            queryParams: {
                WXBody: '未派单',
                PDBody: '未派单'
            },
            WXBodyType: [{ label: '全部工单', value: '全部工单' }, { label: '未派单', value: '未派单' }, { label: 'num1', value: 'num1' }],
            rules: {
                deviceId: [
                    { required: true, message: '请选择设备', trigger: 'change' }
                ],
                erectoId: [
                    { required: true, message: "请选择安装工", trigger: "change" }
                ],
                userName: [
                    { required: true, message: "用户姓名不能为空", trigger: "blur" }
                ],
                userPhone: [
                    { required: true, trigger: "blur", message: "请输入您的手机号码" },
                    { pattern: /^1[3456789]\d{9}$/, message: '手机号码格式不正确', trigger: 'blur' }
                ],
                address: [
                    { required: true, message: "安装地址不能为空", trigger: "blur" }
                ],
            },
            form: {},
            tableData: [
            ],
            formLabelWidth: '120px',
            AZModal: false,
            deviceList: [],
            state: -1,
            id: 0,
            erectoList: [],
            erectoListLevel: [],
            roleKey: localStorage.getItem('roleKey'),
            dialogImageUrl: '',
            dialogVisible: false,
            view: false
  mounted() {
    console.log(this.nickName);
    this.getList();
    this.getErectoList();
    this.getErectoListLevel();
  },
  methods: {
    exceed(e) {
      console.log(e);
      this.$message({
        message: "图片最多上传一张",
        type: "error",
      });
    },
    handleRemove(file, fileList) {
      this.form.imgUrl = "";
      console.log(file, fileList);
    },
    handleChange(file) {
      console.log(file);
      this.dialogImageUrl = file.url;
      // this.dialogVisible = true;
      let formData = new FormData();
      formData.append("avatarfile", file.raw);
      request({
        url: "/iot/deviceOrder/profile/avatar",
        method: "post",
        data: formData,
      })
        .then((res) => {
          console.log(res);
          if (res.code == 200) {
            this.$message({
              message: "上传成功",
              type: "success",
            });
            this.form.imgUrl = "https://puyue.yhupai.com/prod-api" + res.imgUrl;
          } else {
            this.$message({
              message: "上传失败",
              type: "error",
            });
          }
        })
        .catch((res) => {
          this.$message({
            message: "上传失败",
            type: "error",
          });
        });
    },
    handlePictureCardPreview() {},
    // uploadImg
    getErectoList() {
      let data = {
        pageNum: 1,
        pageSize: 10000,
        deptId: localStorage.getItem("deptId"),
        isAuthentication: 1,
      };
      request({
        url: "/system/user/list",
        method: "get",
        params: data,
      })
        .then((res) => {
          console.log(res);
          if (res.code == 200) {
            this.erectoList = res.rows;
            this.erectoList.unshift({
              nickName: "未指派",
              userId: -1,
            });
          } else {
            this.erectoList = [];
          }
        })
        .catch((res) => {
          this.erectoList = [];
        });
    },
    getErectoListLevel() {
      this.erectoListLevel = [];
      let data = {
        pageNum: 1,
        pageSize: 10000,
        deptId: localStorage.getItem("deptId"),
        // isAuthentication: 1,
        roleKey: "tenanthelper",
      };
      request({
        url: "/system/user/list",
        method: "get",
        params: data,
      })
        .then((res) => {
          console.log(res);
          if (res.code == 200 && res.rows.length > 0) {
            this.erectoListLevel = res.rows;
            this.nextlevel = res.rows[0].userId;
          } else {
            this.erectoListLevel = [];
          }
        })
        .catch((res) => {
          this.erectoListLevel = [];
        });
    },
    // 获取设备列表
    getDeviceList() {
      let data = {
        status: 1,
      };
      request({
        url: "/iot/device/shortList",
        method: "get",
        params: data,
      })
        .then((res) => {
          if (res.code == 200) {
            this.deviceList = res.rows;
          } else {
            this.deviceList = [];
          }
        })
        .catch((res) => {
          this.deviceList = [];
        });
    },
    // 获取安装列表
    getList() {
      this.tableData = [];
      let data = {
        pageNum: this.pageIndex,
        pageSize: this.pageSize,
        state: this.state,
        orderType: 1,
      };
      if (this.roleKey == "tenantservice") {
        data.createUserId = 0;
        data.erectoId = localStorage.getItem("userID");
      }
      if (this.roleKey == "admin") {
        data.createUserId = 0;
        data.erectoId = 0;
      }
      if (this.roleKey == "tenant" || this.roleKey == "tenanthelper") {
        data.createUserId = localStorage.getItem("userID");
        data.erectoId = 0;
      }
      if (this.level == 1) {
        //当选择下级时
        data.createUserId = this.nextlevel;
      }
      request({
        url: "/iot/deviceOrder/list",
        method: "get",
        params: data,
      })
        .then((res) => {
          if (res.code == 200) {
            this.tableData = res.rows;
            this.total = res.total;
          } else {
            this.tableData = [];
            this.total = 0;
          }
        })
        .catch((res) => {
          this.tableData = [];
          this.total = 0;
        });
    },
    handleSelectionChange(e) {
      console.log(1, e);
    },
    filterHandlerBody(e) {
      console.log(2, e);
    },
    filterHandlerStatus(e) {
      console.log(3, e);
    },
    changePage(e) {
      this.pageIndex = e;
      this.getList();
    },
    openAZModal() {
      this.getDeviceList();
      this.form = {
        deviceId: undefined,
        address: "", //地址
        appointmentTime: "", //预约时间
        remark: "", //备注
        erectoId: -1, //安装工
        userName: "", //用户信息,联系人
        userPhone: "", //用户信息联系电话
        erectoName: "未指派",
        state: 0,
      };
      this.title = "创建安装单";
      this.AZModal = true;
    },
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          this.add();
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    add() {
      for (let i = 0; i < this.erectoList.length; i++) {
        if (this.form.erectoId == this.erectoList[i].userId) {
          this.form.erectoName = this.erectoList[i].nickName;
        }
      }
      console.log(this.form);
      let data = {
        deviceId: this.form.deviceId,
        erectoId: this.form.erectoId,
        erectoName: this.form.erectoName,
        userName: this.form.userName,
        userPhone: this.form.userPhone,
        address: this.form.address,
        appointmentTime: this.form.appointmentTime,
        remark: this.form.remark,
        state: this.form.state,
      };
      if (this.form.receiveTime) {
        data.receiveTime = this.form.receiveTime;
      }
      console.log(data);
      if (this.title == "修改安装单") {
        (data.id = this.id), (data.orderType = "1");
        if (this.form.state == 3) {
          if (!this.form.imgUrl) {
    mounted() {
        console.log(this.nickName);
        this.getList();
        this.getErectoList()
        this.getErectoListLevel()
    },
    methods: {
        exceed(e) {
            console.log(e);
            this.$message({
              message: "请上传图片",
              type: "error",
                message: '图片最多上传一张',
                type: 'error'
            });
            return;
          }
          data.imgUrl = this.form.imgUrl;
        }
        console.log(data);
        request({
          url: "/iot/deviceOrder",
          method: "put",
          data: data,
        })
          .then((res) => {
            console.log(res);
            if (res.code == 200) {
              this.state = -1;
              this.pageIndex = 1;
              this.getList();
              this.AZModal = false;
              this.acceptModal = false;
            } else {
              this.state = -1;
              this.pageIndex = 1;
              this.getList();
              this.AZModal = false;
              this.acceptModal = false;
        },
        handleRemove(file, fileList) {
            this.form.imgUrl = ''
            console.log(file, fileList);
        },
        handleChange(file) {
            if (file.size > 1024 * 1024 * 2) {
                this.$refs.uploadImg.uploadFiles.length = 0;
                this.$message({
                    message: '图片大小不能超过2M,请重新上传',
                    type: 'error'
                });
                return
            }
          })
          .catch((res) => {
            this.state = -1;
            this.pageIndex = 1;
            this.getList();
            this.AZModal = false;
            this.acceptModal = false;
          });
      } else {
        request({
          url: "/iot/deviceOrder",
          method: "post",
          data: data,
        })
          .then((res) => {
            if (res.code == 200) {
              this.state = -1;
              this.pageIndex = 1;
              this.getList();
              this.AZModal = false;
            } else {
              this.state = -1;
              this.pageIndex = 1;
              this.getList();
              this.AZModal = false;
            this.dialogImageUrl = file.url;
            let formData = new FormData();
            formData.append('avatarfile', file.raw);
            request({
                url: '/iot/deviceOrder/profile/avatar',
                method: "post",
                data: formData
            }).then((res) => {
                console.log(res);
                if (res.code == 200) {
                    this.$message({
                        message: '上传成功',
                        type: 'success'
                    });
                    this.form.imgUrl = 'https://puyue.yhupai.com/prod-api' + res.imgUrl
                } else {
                    this.$message({
                        message: '上传失败',
                        type: 'error'
                    });
                }
            }).catch((res) => {
                this.$message({
                    message: '上传失败',
                    type: 'error'
                });
            })
        },
        handlePictureCardPreview(file) {
            this.dialogImageUrl = file.url;
            this.dialogVisible = true;
        },
        // uploadImg
        getErectoList() {
            let data = {
                pageNum: 1,
                pageSize: 10000,
                deptId: localStorage.getItem('deptId'),
                isAuthentication: 1,
            }
          })
          .catch((res) => {
            this.state = -1;
            this.pageIndex = 1;
            this.getList();
            this.AZModal = false;
          });
      }
            request({
                url: '/system/user/list',
                method: "get",
                params: data
            }).then((res) => {
                console.log(res);
                if (res.code == 200) {
                    this.erectoList = res.rows
                    this.erectoList.unshift({
                        nickName: '未指派',
                        userId: -1
                    })
                } else {
                    this.erectoList = []
                }
            }).catch((res) => {
                this.erectoList = []
            })
        },
        getErectoListLevel() {
            this.erectoListLevel = []
            let data = {
                pageNum: 1,
                pageSize: 10000,
                deptId: localStorage.getItem('deptId'),
                // isAuthentication: 1,
                roleKey: 'tenanthelper',
            }
            request({
                url: '/system/user/list',
                method: "get",
                params: data
            }).then((res) => {
                console.log(res);
                if (res.code == 200 && res.rows.length > 0) {
                    this.erectoListLevel = res.rows
                    this.nextlevel = res.rows[0].userId
                } else {
                    this.erectoListLevel = []
                }
            }).catch((res) => {
                this.erectoListLevel = []
            })
        },
        // 获取设备列表
        getDeviceList() {
            let data = {
                status: 1
            }
            request({
                url: '/iot/device/shortList',
                method: "get",
                params: data
            }).then((res) => {
                if (res.code == 200) {
                    this.deviceList = res.rows
                } else {
                    this.deviceList = []
                }
            }).catch((res) => {
                this.deviceList = []
            })
        },
        // 获取安装列表
        getList() {
            this.tableData = []
            let data = {
                pageNum: this.pageIndex,
                pageSize: this.pageSize,
                state: this.state,
                orderType: 1,
            }
            if (this.roleKey == 'tenantservice') {
                data.createUserId = 0
                data.erectoId = localStorage.getItem('userID')
            }
            if (this.roleKey == 'admin') {
                data.createUserId = 0;
                data.erectoId = 0;
            }
            if (this.roleKey == 'tenant' || this.roleKey == 'tenanthelper') {
                data.createUserId = localStorage.getItem('userID');
                data.erectoId = 0;
            }
            if (this.level == 1) { //当选择下级时
                data.createUserId = this.nextlevel
            }
            request({
                url: '/iot/deviceOrder/list',
                method: "get",
                params: data
            }).then((res) => {
                if (res.code == 200) {
                    this.tableData = res.rows
                    this.total = res.total
                } else {
                    this.tableData = []
                    this.total = 0
                }
            }).catch((res) => {
                this.tableData = []
                this.total = 0
            })
        },
        handleSelectionChange(e) {
            console.log(1, e);
        },
        filterHandlerBody(e) {
            console.log(2, e);
        },
        filterHandlerStatus(e) {
            console.log(3, e);
        },
        changePage(e) {
            this.pageIndex = e
            this.getList()
        },
        openAZModal() {
            this.getDeviceList();
            this.form = {
                deviceId: undefined,
                address: '',//地址
                appointmentTime: '',//预约时间
                remark: '',//备注
                erectoId: -1,//安装工
                userName: '', //用户信息,联系人
                userPhone: '',//用户信息联系电话
                erectoName: '未指派',
                state: 0
            }
            this.title = '创建安装单'
            this.AZModal = true
        },
        submitForm() {
            this.$refs['form'].validate((valid) => {
                if (valid) {
                    this.add()
                } else {
                    console.log('error submit!!');
                    return false;
                }
            });
        },
        add() {
            for (let i = 0; i < this.erectoList.length; i++) {
                if (this.form.erectoId == this.erectoList[i].userId) {
                    this.form.erectoName = this.erectoList[i].nickName
                }
            }
            console.log(this.form);
            let data = {
                deviceId: this.form.deviceId,
                erectoId: this.form.erectoId,
                erectoName: this.form.erectoName,
                userName: this.form.userName,
                userPhone: this.form.userPhone,
                address: this.form.address,
                appointmentTime: this.form.appointmentTime,
                remark: this.form.remark,
                state: this.form.state,
            }
            if (this.form.receiveTime) {
                data.receiveTime = this.form.receiveTime
            }
            console.log(data);
            if (this.title == '修改安装单') {
                data.id = this.id,
                    data.orderType = '1'
                if (this.form.state == 3) {
                    if (!this.form.imgUrl) {
                        this.$message({
                            message: '请上传图片',
                            type: 'error'
                        });
                        return
                    }
                    data.imgUrl = this.form.imgUrl
                }
                console.log(data);
                request({
                    url: '/iot/deviceOrder',
                    method: "put",
                    data: data
                }).then((res) => {
                    console.log(res);
                    if (res.code == 200) {
                        this.state = -1
                        this.pageIndex = 1
                        this.getList()
                        this.AZModal = false
                        this.acceptModal = false
                    } else {
                        this.state = -1
                        this.pageIndex = 1
                        this.getList()
                        this.AZModal = false
                        this.acceptModal = false
                    }
                }).catch((res) => {
                    this.state = -1
                    this.pageIndex = 1
                    this.getList()
                    this.AZModal = false
                    this.acceptModal = false
                })
            } else {
                request({
                    url: '/iot/deviceOrder',
                    method: "post",
                    data: data
                }).then((res) => {
                    if (res.code == 200) {
                        this.state = -1
                        this.pageIndex = 1
                        this.getList()
                        this.AZModal = false
                    } else {
                        this.state = -1
                        this.pageIndex = 1
                        this.getList()
                        this.AZModal = false
                    }
                }).catch((res) => {
                    this.state = -1
                    this.pageIndex = 1
                    this.getList()
                    this.AZModal = false
                })
            }
        },
        editModal(item) {
            this.title = '修改安装单'
            this.form = item
            this.form = JSON.parse(JSON.stringify(item))
            this.deviceList = [{ deviceName: item.device.deviceName, deviceId: item.device.deviceId }]
            console.log(this.form);
            this.AZModal = true
            this.id = item.id
        },
        delModal(item) {
            this.id = item.id
            this.deleteModal = true
        },
        delDate() {
            let that = this
            let data = {
                id: this.id
            }
            request({
                url: `/iot/deviceOrder/${this.id}`,
                method: "DELETE",
                // params: data
            }).then((res) => {
                if (res.code == 200) {
                    that.pageIndex = 1
                    that.getList()
                    that.deleteModal = false
                } else {
                    that.pageIndex = 1
                    that.getList()
                    that.deleteModal = false
                }
            }).catch((res) => {
                that.pageIndex = 1
                that.getList()
                that.deleteModal = false
            })
        },
        // 接单
        JDModal(item) {
            this.title = '修改安装单'
            this.form = JSON.parse(JSON.stringify(item))
            this.form.state = 2
            this.deviceList = [{ deviceName: item.device.deviceName, deviceId: item.device.deviceId }]
            this.id = item.id
            this.form.receiveTime = this.formatNow()
            this.view = false
            this.acceptModal = true
        },
        formatNow() {
            let now = new Date();
            let year = now.getFullYear();
            let month = (now.getMonth() + 1).toString().padStart(2, '0');  // 注意:月份是从 0 开始的,所以需要 +1
            let day = now.getDate().toString().padStart(2, '0');
            let hour = now.getHours().toString().padStart(2, '0');
            let minute = now.getMinutes().toString().padStart(2, '0');
            let second = now.getSeconds().toString().padStart(2, '0');
            let millisecond = now.getMilliseconds().toString().padStart(3, '0');
            return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
        },
        // 结单
        jdModal(item) {
            this.title = '修改安装单'
            this.form = JSON.parse(JSON.stringify(item))
            this.form.state = 3
            this.deviceList = [{ deviceName: item.device.deviceName, deviceId: item.device.deviceId }]
            this.id = item.id
            this.view = false
            // this.form.receiveTime = this.formatNow()
            this.AZModal = true
        },
        // 结单查看
        viewModal(item) {
            this.title = '查看安装单'
            this.form = JSON.parse(JSON.stringify(item))
            this.deviceList = [{ deviceName: item.device.deviceName, deviceId: item.device.deviceId }]
            this.id = item.id
            this.view = true
            // this.form.receiveTime = this.formatNow()
            this.AZModal = true
        },
    },
    editModal(item) {
      this.title = "修改安装单";
      this.form = item;
      this.form = JSON.parse(JSON.stringify(item));
      this.deviceList = [
        { deviceName: item.device.deviceName, deviceId: item.device.deviceId },
      ];
      console.log(this.form);
      this.AZModal = true;
      this.id = item.id;
    },
    delModal(item) {
      this.id = item.id;
      this.deleteModal = true;
    },
    delDate() {
      let that = this;
      let data = {
        id: this.id,
      };
      request({
        url: `/iot/deviceOrder/${this.id}`,
        method: "DELETE",
        // params: data
      })
        .then((res) => {
          if (res.code == 200) {
            that.pageIndex = 1;
            that.getList();
            that.deleteModal = false;
          } else {
            that.pageIndex = 1;
            that.getList();
            that.deleteModal = false;
          }
        })
        .catch((res) => {
          that.pageIndex = 1;
          that.getList();
          that.deleteModal = false;
        });
    },
    JDModal(item) {
      this.title = "修改安装单";
      this.form = JSON.parse(JSON.stringify(item));
      this.form.state = 2;
      this.deviceList = [
        { deviceName: item.device.deviceName, deviceId: item.device.deviceId },
      ];
      this.id = item.id;
      this.form.receiveTime = this.formatNow();
      this.acceptModal = true;
    },
    formatNow() {
      let now = new Date();
      let year = now.getFullYear();
      let month = (now.getMonth() + 1).toString().padStart(2, "0"); // 注意:月份是从 0 开始的,所以需要 +1
      let day = now.getDate().toString().padStart(2, "0");
      let hour = now.getHours().toString().padStart(2, "0");
      let minute = now.getMinutes().toString().padStart(2, "0");
      let second = now.getSeconds().toString().padStart(2, "0");
      let millisecond = now.getMilliseconds().toString().padStart(3, "0");
      return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
    },
    jdModal(item) {
      this.title = "修改安装单";
      this.form = JSON.parse(JSON.stringify(item));
      this.form.state = 3;
      this.deviceList = [
        { deviceName: item.device.deviceName, deviceId: item.device.deviceId },
      ];
      this.id = item.id;
      // this.form.receiveTime = this.formatNow()
      this.AZModal = true;
    },
  },
  watch: {
    "form.erectoId": {
      handler(newVal, oldVal) {
        if (this.form.state < 2) {
          if (newVal && newVal == -1) {
            this.form.state = 0;
          } else {
            this.form.state = 1;
          }
        }
      },
      deep: true,
    },
  },
};
    watch: {
        'form.erectoId': {
            handler(newVal, oldVal) {
                if (this.form.state < 2) {
                    if (newVal && newVal == -1) {
                        this.form.state = 0
                    } else {
                        this.form.state = 1
                    }
                }
            },
            deep: true,
        },
    }
}
</script>
<style lang="scss" scoped>
.title {
  display: flex;
    display: flex;
}
.el-select .el-input {
  width: 130px;
    width: 130px;
}
.input-with-select .el-input-group__prepend {
  background-color: #fff;
    background-color: #fff;
}
</style>
wumei-smart-master/vue/src/views/equipmentManagement/maintenance.vue
@@ -3,7 +3,7 @@
        <el-card style="margin-bottom:6px;">
            <el-form :model="queryParams" ref="queryForm" :inline="true">
                <el-form-item label="状态" prop="status">
                    <el-select v-model="state" placeholder="菜单状态"  size="mini">
                    <el-select v-model="state" placeholder="菜单状态" size="mini">
                        <el-option label="全部" :value="-1" />
                        <el-option label="未派单" :value="0" />
                        <el-option label="已派单" :value="1" />
@@ -11,9 +11,9 @@
                        <el-option label="已完成" :value="3" />
                    </el-select>
                </el-form-item>
                <el-form-item >
                <el-button type="primary" icon="el-icon-search"  size="mini" @click="changePage(1)">搜索</el-button>
            </el-form-item>
                <el-form-item>
                    <el-button type="primary" icon="el-icon-search" size="mini" @click="changePage(1)">搜索</el-button>
                </el-form-item>
                <!-- <el-form-item label="状态" prop="status">
                    <el-select v-model="queryParams.WXBody" placeholder="菜单状态" clearable size="small">
                        <el-option v-for="dict in WXBodyType" :key="dict.value" :label="dict.label" :value="dict.value" />
@@ -26,7 +26,7 @@
                    </el-input>
                </el-form-item> -->
                <el-form-item style="float: right;" v-if="roleKey !== 'admin'">
                    <el-button type="primary" v-hasPermi="['iot:device:add']" plain icon="el-icon-plus"  size="mini"
                    <el-button type="primary" v-hasPermi="['iot:device:add']" plain icon="el-icon-plus" size="mini"
                        @click="openAZModal">新增</el-button>
                </el-form-item>
            </el-form>
@@ -97,15 +97,24 @@
                    </el-table-column>
                </el-table-column> -->
                <el-table-column label="操作" fixed="right" align="center" width="150" class-name="small-padding fixed-width" v-if="roleKey !== 'admin'">
                <el-table-column label="操作" fixed="right" align="center" width="150" class-name="small-padding fixed-width"
                    v-if="roleKey !== 'admin'">
                    <template slot-scope="scope">
                        <div style="display: flex;justify-content: space-around;">
                            <el-button v-if="scope.row.state != 3" size="small" type="primary" style="padding:5px;" icon="el-icon-edit"
                                v-hasPermi="['iot:device:edit']" @click="editModal(scope.row)">修改</el-button>
                            <el-button v-if="scope.row.state == 0" size="small" type="danger" style="padding:5px;" icon="el-icon-delete"
                                v-hasPermi="['iot:device:remove']" @click="delModal(scope.row)">删除</el-button>
                            <el-button v-if="scope.row.state == 1" size="small" type="success" style="padding:5px;"
                                icon="el-icon-odometer" @click="JDModal(scope.row)">接单</el-button>
                            <el-button v-if="scope.row.state != 3" size="small" type="primary" style="padding:5px;"
                                icon="el-icon-edit" v-hasPermi="['iot:device:edit']"
                                @click="editModal(scope.row)">修改</el-button>
                            <el-button v-if="scope.row.state == 0" size="small" type="danger" style="padding:5px;"
                                icon="el-icon-delete" v-hasPermi="['iot:device:remove']"
                                @click="delModal(scope.row)">删除</el-button>
                            <el-button v-if="scope.row.state == 1 && scope.row.erectoName == nickName" size="small"
                                type="success" style="padding:5px;" icon="el-icon-odometer"
                                @click="JDModal(scope.row)">接单</el-button>
                            <el-button v-if="scope.row.state == 2 && scope.row.erectoName == nickName" size="small"
                                type="success" style="padding:5px;" icon="el-icon-check"
                                @click="jdModal(scope.row)">结单</el-button>
                            <el-button v-if="scope.row.state == 3" size="small" type="success" style="padding:5px;"
                                icon="el-icon-view" @click="viewModal(scope.row)">查看</el-button>
                        </div>
                    </template>
                </el-table-column>
@@ -119,7 +128,7 @@
        <el-dialog :title="title" :visible.sync="AZModal">
            <el-form :model="form" :rules="rules" ref="form">
                <el-form-item label="设备" :label-width="formLabelWidth" prop="deviceId">
                    <el-select v-model="form.deviceId" placeholder="请选择" :disabled="title == '修改维修单'">
                    <el-select v-model="form.deviceId" placeholder="请选择" :disabled="title == '修改维修单'||view">
                        <el-option v-for="item in deviceList" :label="item.deviceName" :value="item.deviceId"></el-option>
                    </el-select>
                </el-form-item>
@@ -138,26 +147,39 @@
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="用户姓名" :label-width="formLabelWidth" prop="userName">
                    <el-input v-model="form.userName" autocomplete="off"></el-input>
                    <el-input v-model="form.userName" autocomplete="off" :disabled="view"></el-input>
                </el-form-item>
                <el-form-item label="手机号" :label-width="formLabelWidth" prop="userPhone">
                    <el-input v-model="form.userPhone" autocomplete="off"></el-input>
                    <el-input v-model="form.userPhone" autocomplete="off" :disabled="view"></el-input>
                </el-form-item>
                <el-form-item label="维修地址" :label-width="formLabelWidth" prop="address">
                    <el-input v-model="form.address" autocomplete="off"></el-input>
                    <el-input v-model="form.address" autocomplete="off" :disabled="view"></el-input>
                </el-form-item>
                <el-form-item label="预约时间" :label-width="formLabelWidth">
                    <el-date-picker v-model="form.appointmentTime" type="datetime" placeholder="选择日期时间"
                    <el-date-picker v-model="form.appointmentTime" type="datetime" placeholder="选择日期时间" :disabled="view"
                        value-format="yyyy-MM-dd HH:mm:ss">
                    </el-date-picker>
                </el-form-item>
                <el-form-item label="故障描述" :label-width="formLabelWidth">
                    <el-input type="textarea" v-model="form.description"></el-input>
                    <el-input type="textarea" v-model="form.description" :disabled="view"></el-input>
                </el-form-item>
                <el-form-item label="图片" v-if="view" :label-width="formLabelWidth">
                    <img :src="form.imgUrl" alt="">
                </el-form-item>
                <el-form-item label="上传图片" v-if=" form.state == 3 && !view " :label-width="formLabelWidth">
                    <el-upload ref="uploadImg" action="#" :on-change="handleChange" list-type="picture-card"
                        :multiple="false" :auto-upload="false" :on-preview="handlePictureCardPreview" :limit="1"
                        :on-exceed="exceed" :on-remove="handleRemove">
                        <i class="el-icon-plus"></i>
                    </el-upload>
                    <el-dialog :visible.sync="dialogVisible">
                        <img width="100%" :src="dialogImageUrl" alt="">
                    </el-dialog>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="AZModal = false">取 消</el-button>
                <el-button type="primary" @click="submitForm('form')">确 定</el-button>
                <el-button @click="AZModal = false" :disabled="view">取 消</el-button>
                <el-button type="primary" @click="submitForm('form')" :disabled="view">确 定</el-button>
            </div>
        </el-dialog>
        <el-dialog title="删除数据" :visible.sync="deleteModal" width="30%">
@@ -183,6 +205,7 @@
export default {
    data() {
        return {
            nickName: localStorage.getItem('nickName'),
            acceptModal: false,
            acceptDateParams: {},
            title: '创建维修单',
@@ -225,6 +248,10 @@
            erectoList: [],
            erectoListLevel: [],
            roleKey: localStorage.getItem('roleKey'),
            dialogImageUrl: '',
            dialogVisible: false,
            view: false
        }
    },
@@ -234,6 +261,60 @@
        this.getErectoListLevel()
    },
    methods: {
        exceed(e) {
            console.log(e);
            this.$message({
                message: '图片最多上传一张',
                type: 'error'
            });
        },
        handleRemove(file, fileList) {
            this.form.imgUrl = ''
            console.log(file, fileList);
        },
        handleChange(file) {
            console.log(file);
            if (file.size > 1024 * 1024 * 2) {
                this.$refs.uploadImg.uploadFiles.length = 0;
                this.$message({
                    message: '图片大小不能超过2M,请重新上传',
                    type: 'error'
                });
                return false
            }
            this.dialogImageUrl = file.url;
            let formData = new FormData();
            formData.append('avatarfile', file.raw);
            request({
                url: '/iot/deviceOrder/profile/avatar',
                method: "post",
                data: formData
            }).then((res) => {
                console.log(res);
                if (res.code == 200) {
                    this.$message({
                        message: '上传成功',
                        type: 'success'
                    });
                    this.form.imgUrl = 'https://puyue.yhupai.com/prod-api' + res.imgUrl
                } else {
                    this.$message({
                        message: '上传失败',
                        type: 'error'
                    });
                }
            }).catch((res) => {
                this.$message({
                    message: '上传失败',
                    type: 'error'
                });
            })
        },
        handlePictureCardPreview(file) {
            this.dialogImageUrl = file.url;
            this.dialogVisible = true;
        },
        getErectoList() {
            let data = {
                pageNum: 1,
@@ -403,7 +484,7 @@
                description: this.form.description,
                state: this.form.state,
                orderType: '2',
                repairFlag:1,
                repairFlag: 1,
            }
            if (this.form.receiveTime) {
                data.receiveTime = this.form.receiveTime
@@ -411,6 +492,17 @@
            console.log(data);
            if (this.title == '修改维修单') {
                data.id = this.id
                if (this.form.state == 3) {
                    if (!this.form.imgUrl) {
                        this.$message({
                            message: '请上传图片',
                            type: 'error'
                        });
                        return
                    }
                    data.imgUrl = this.form.imgUrl
                }
                request({
                    url: '/iot/deviceOrder',
                    method: "put",
@@ -514,8 +606,18 @@
            this.form.state = 2
            this.deviceList = [{ deviceName: item.device.deviceName, deviceId: item.device.deviceId }]
            this.id = item.id
            this.view = false
            this.form.receiveTime = this.formatNow()
            this.acceptModal = true
        },
        jdModal(item) {
            this.title = '修改维修单'
            this.form = JSON.parse(JSON.stringify(item))
            this.form.state = 3
            this.deviceList = [{ deviceName: item.device.deviceName, deviceId: item.device.deviceId }]
            this.id = item.id
            this.view = false
            this.AZModal = true
        },
        formatNow() {
            let now = new Date();
@@ -528,6 +630,16 @@
            let millisecond = now.getMilliseconds().toString().padStart(3, '0');
            return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
        },
        // 结单查看
        viewModal(item) {
            this.title = '查看维修单'
            this.form = JSON.parse(JSON.stringify(item))
            this.deviceList = [{ deviceName: item.device.deviceName, deviceId: item.device.deviceId }]
            this.id = item.id
            this.view = true
            // this.form.receiveTime = this.formatNow()
            this.AZModal = true
        },
    },
    watch: {
        'form.erectoId': {