小程序端用户登录创建维修单修改代码优化,在DeviceController新加接口shortListRepair对不同的用户登录后看到自己的设备20231207wmz
22个文件已修改
2446 ■■■■ 已修改文件
wumei-smart-master/springboot/wumei-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java 58 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/controller/DeviceController.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/domain/Device.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/domain/DeviceOrder.java 36 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/mapper/DeviceLogMapper.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/mapper/DeviceUserMapper.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/IDeviceService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/impl/DeviceOrderServiceImpl.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/impl/DeviceServiceImpl.java 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/task/DeviceOrderTask.java 70 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-iot/src/main/resources/mapper/iot/DeviceMapper.xml 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-iot/src/main/resources/mapper/iot/DeviceOrderMapper.xml 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-quartz/src/main/java/com/ruoyi/quartz/util/JobInvokeUtil.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java 37 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-system/src/main/java/com/ruoyi/system/service/ISysPostService.java 28 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-system/src/main/java/com/ruoyi/system/service/ISysUserService.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-system/src/main/resources/mapper/system/SysDeptMapper.xml 303 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-system/src/main/resources/mapper/system/SysUserMapper.xml 59 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/vue/src/views/equipmentManagement/installation.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/vue/src/views/equipmentManagement/maintenance.vue 1760 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java
@@ -2,6 +2,7 @@
import java.util.Iterator;
import java.util.List;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -25,13 +26,12 @@
/**
 * 部门信息
 *
 *
 * @author ruoyi
 */
@RestController
@RequestMapping("/system/dept")
public class SysDeptController extends BaseController
{
public class SysDeptController extends BaseController {
    @Autowired
    private ISysDeptService deptService;
@@ -40,8 +40,7 @@
     */
    @PreAuthorize("@ss.hasPermi('system:dept:list')")
    @GetMapping("/list")
    public AjaxResult list(SysDept dept)
    {
    public AjaxResult list(SysDept dept) {
        List<SysDept> depts = deptService.selectDeptList(dept);
        return AjaxResult.success(depts);
    }
@@ -51,16 +50,13 @@
     */
    @PreAuthorize("@ss.hasPermi('system:dept:list')")
    @GetMapping("/list/exclude/{deptId}")
    public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId)
    {
    public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) {
        List<SysDept> depts = deptService.selectDeptList(new SysDept());
        Iterator<SysDept> it = depts.iterator();
        while (it.hasNext())
        {
        while (it.hasNext()) {
            SysDept d = (SysDept) it.next();
            if (d.getDeptId().intValue() == deptId
                    || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""))
            {
                    || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + "")) {
                it.remove();
            }
        }
@@ -72,8 +68,7 @@
     */
    @PreAuthorize("@ss.hasPermi('system:dept:query')")
    @GetMapping(value = "/{deptId}")
    public AjaxResult getInfo(@PathVariable Long deptId)
    {
    public AjaxResult getInfo(@PathVariable Long deptId) {
        deptService.checkDeptDataScope(deptId);
        return AjaxResult.success(deptService.selectDeptById(deptId));
    }
@@ -82,8 +77,7 @@
     * 获取部门下拉树列表
     */
    @GetMapping("/treeselect")
    public AjaxResult treeselect(SysDept dept)
    {
    public AjaxResult treeselect(SysDept dept) {
        List<SysDept> depts = deptService.selectDeptList(dept);
        return AjaxResult.success(deptService.buildDeptTreeSelect(depts));
    }
@@ -92,8 +86,7 @@
     * 加载对应角色部门列表树
     */
    @GetMapping(value = "/roleDeptTreeselect/{roleId}")
    public AjaxResult roleDeptTreeselect(@PathVariable("roleId") Long roleId)
    {
    public AjaxResult roleDeptTreeselect(@PathVariable("roleId") Long roleId) {
        List<SysDept> depts = deptService.selectDeptList(new SysDept());
        AjaxResult ajax = AjaxResult.success();
        ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
@@ -107,10 +100,8 @@
    @PreAuthorize("@ss.hasPermi('system:dept:add')")
    @Log(title = "部门管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody SysDept dept)
    {
        if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
        {
    public AjaxResult add(@Validated @RequestBody SysDept dept) {
        if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) {
            return AjaxResult.error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
        }
        dept.setCreateBy(getUsername());
@@ -123,19 +114,13 @@
    @PreAuthorize("@ss.hasPermi('system:dept:edit')")
    @Log(title = "部门管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody SysDept dept)
    {
        if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
        {
    public AjaxResult edit(@Validated @RequestBody SysDept dept) {
        if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) {
            return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
        }
        else if (dept.getParentId().equals(dept.getDeptId()))
        {
        } else if (dept.getParentId().equals(dept.getDeptId())) {
            return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
        }
        else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus())
                && deptService.selectNormalChildrenDeptById(dept.getDeptId()) > 0)
        {
        } else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus())
                && deptService.selectNormalChildrenDeptById(dept.getDeptId()) > 0) {
            return AjaxResult.error("该部门包含未停用的子部门!");
        }
        dept.setUpdateBy(getUsername());
@@ -148,14 +133,11 @@
    @PreAuthorize("@ss.hasPermi('system:dept:remove')")
    @Log(title = "部门管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{deptId}")
    public AjaxResult remove(@PathVariable Long deptId)
    {
        if (deptService.hasChildByDeptId(deptId))
        {
    public AjaxResult remove(@PathVariable Long deptId) {
        if (deptService.hasChildByDeptId(deptId)) {
            return AjaxResult.error("存在下级部门,不允许删除");
        }
        if (deptService.checkDeptExistUser(deptId))
        {
        if (deptService.checkDeptExistUser(deptId)) {
            return AjaxResult.error("部门存在用户,不允许删除");
        }
        return toAjax(deptService.deleteDeptById(deptId));
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/controller/DeviceController.java
@@ -108,7 +108,18 @@
    @ApiOperation("设备分页简短列表")
    public TableDataInfo shortList(Device device) {
        startPage();
        return getDataTable(deviceService.selectDeviceShortList(device));
        return getDataTable(deviceService.selectDeviceShortList(device, false));
    }
    /**
     * 查询设备简短列表,主页列表数据
     */
    @PreAuthorize("@ss.hasPermi('iot:device:list')")
    @GetMapping("/shortListRepair")
    @ApiOperation("设备分页简短列表")
    public TableDataInfo shortListRepair(Device device) {
        startPage();
        return getDataTable(deviceService.selectDeviceShortList(device, true));
    }
    /**
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/domain/Device.java
@@ -184,6 +184,7 @@
     */
    private Integer installFlag;
    public Integer getLocationWay() {
        return locationWay;
    }
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/domain/DeviceOrder.java
@@ -172,12 +172,12 @@
    /**
     * 接单超时标识
     */
    private Boolean receiveTimeoutFlag;
    private Integer receiveTimeoutFlag;
    /**
     * 结单超时标识
     */
    private Boolean finishTimeoutFlag;
    private Integer finishTimeoutFlag;
    /**
     * 是否用户创建标识
@@ -388,22 +388,6 @@
        this.description = description;
    }
    public Boolean getReceiveTimeoutFlag() {
        return receiveTimeoutFlag;
    }
    public void setReceiveTimeoutFlag(Boolean receiveTimeoutFlag) {
        this.receiveTimeoutFlag = receiveTimeoutFlag;
    }
    public Boolean getFinishTimeoutFlag() {
        return finishTimeoutFlag;
    }
    public void setFinishTimeoutFlag(Boolean finishTimeoutFlag) {
        this.finishTimeoutFlag = finishTimeoutFlag;
    }
    public Integer getIsRate() {
        return isRate;
    }
@@ -420,6 +404,22 @@
        this.customFlag = customFlag;
    }
    public Integer getReceiveTimeoutFlag() {
        return receiveTimeoutFlag;
    }
    public void setReceiveTimeoutFlag(Integer receiveTimeoutFlag) {
        this.receiveTimeoutFlag = receiveTimeoutFlag;
    }
    public Integer getFinishTimeoutFlag() {
        return finishTimeoutFlag;
    }
    public void setFinishTimeoutFlag(Integer finishTimeoutFlag) {
        this.finishTimeoutFlag = finishTimeoutFlag;
    }
    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/mapper/DeviceLogMapper.java
@@ -16,8 +16,7 @@
 * @date 2022-01-13
 */
@Repository
public interface DeviceLogMapper
{
public interface DeviceLogMapper {
    /**
     * 查询设备日志
     *
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/mapper/DeviceUserMapper.java
@@ -36,7 +36,8 @@
     *
     * @param deviceUser 设备用户
     * @return 结果
 D    */
     * D
     */
    public int insertDeviceUser(DeviceUser deviceUser);
    /**
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/IDeviceService.java
@@ -127,7 +127,7 @@
     * @param device 设备
     * @return 设备集合
     */
    public List<DeviceShortOutput> selectDeviceShortList(Device device);
    public List<DeviceShortOutput> selectDeviceShortList(Device device, boolean repairFlag);
    /**
     * 新增设备
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/impl/DeviceOrderServiceImpl.java
@@ -156,7 +156,7 @@
        //普通用户创建维修单的时候userid=他本身登录的userid,create_userid=联营商的id
        //更新订单的用户信息
        //判断userId是否大于0就执行SysUser sysUser = getLoginUser().getUser();deviceOrder.setCreateUserId(sysUser.getUserId());
        //判断userId是否大于0,大于0就执行SysUser sysUser = getLoginUser().getUser();deviceOrder.setCreateUserId(sysUser.getUserId());
        if (deviceOrder.getUserId() != null) {
            //用户在小程序创建维修单的情况,userId=2,createUserId=140
            deviceOrder.setUserId(deviceOrder.getUserId());
@@ -237,7 +237,7 @@
            }
            return toAjax(rows);
        } else {
            //判断传过来的orderType的值是否为2-维修,并且维修单的状态为为已完成,修改设备的是否维修为0-已维修
            //判断传过来的orderType的值是否为2-维修,并且维修单的状态为为已完成,修改设备的是否维修为1-已维修
            if ("2".equals(deviceOrder.getOrderType()) && deviceOrder.getState() == 3) {
                //获取修改订单的用户信息
                //拿到修维修单的用户id
@@ -247,7 +247,7 @@
                if (rows > 0) {
                    Device deviceRepairOrder = deviceService.selectDeviceByDeviceId(deviceOrder.getDeviceId());
                    device.setDeviceId(deviceOrder.getDeviceId());
                    device.setRepairFlag(0);
                    device.setRepairFlag(1);
                    device.setStatus(deviceRepairOrder.getStatus());
                    deviceService.updateDevice(device);
                }
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/impl/DeviceServiceImpl.java
@@ -4,6 +4,7 @@
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
@@ -26,6 +27,7 @@
import com.ruoyi.iot.service.IDeviceService;
import com.ruoyi.iot.service.IProductService;
import com.ruoyi.iot.service.IToolService;
import com.ruoyi.system.mapper.SysDeptMapper;
import com.ruoyi.system.service.ISysUserService;
import org.quartz.SchedulerException;
import org.slf4j.Logger;
@@ -37,6 +39,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Comparator;
@@ -85,6 +88,9 @@
    @Autowired
    @Lazy
    private EmqxService emqxService;
    @Autowired
    private SysDeptMapper sysDeptMapper;
    /**
     * 查询设备
@@ -389,17 +395,39 @@
     * @return 设备
     */
    @Override
    public List<DeviceShortOutput> selectDeviceShortList(Device device) {
    public List<DeviceShortOutput> selectDeviceShortList(Device device, boolean repairFlag) {
        SysUser user = getLoginUser().getUser();
        List<SysRole> roles = user.getRoles();
        for (int i = 0; i < roles.size(); i++) {
            if (roles.get(i).getRoleKey().equals("tenant")) {
                // 租户查看产品下所有设备
                device.setTenantId(user.getUserId());
                if (repairFlag == true) {
                    device.setInstallFlag(1);
                }
                break;
            } else if (roles.get(i).getRoleKey().equals("general")) {
                // 用户查看自己设备
                device.setUserId(user.getUserId());
                if (repairFlag == true) {
                    device.setInstallFlag(1);
                }
                break;
            } else if (roles.get(i).getRoleKey().equals("tenanthelper")) {
                //联营商合伙人查看设备
                //联营商合伙人需要根据他自己的userid去查询他上级的用户信息,tenantid是租户id和他的一级联营商所拥有的设备
                //根据当前登录的联营商合伙人去查询他的上级部门id是几,再通过他的上级部门id去查询所对应的一级联营商和所对应的tenantid
                //通过用户ID查询用户
                SysUser sysUser = userService.selectUserById(user.getUserId());//拿到所在的部门id
                SysDept sysDept = sysDeptMapper.selectDeptById(sysUser.getDeptId());  //根据部门id去查询信息得到父级的部门id
                SysDept sysDeptParent = sysDeptMapper.selectDeptById(sysDept.getParentId());  //根据父级部门的id去查询信息
//                SysUser sysUserA = new SysUser();  //创建用户对象
//                sysUserA.setDeptId(sysDeptParent.getDeptId());
                SysUser sysUserDept = userService.selectUserByDeptId(sysDeptParent.getDeptId());//根据得到的父级的部门id去sys_user表里面查询他的用户信息
                device.setTenantId(sysUserDept.getUserId());
                if (repairFlag == true) {
                    device.setInstallFlag(1);
                }
                break;
            }
        }
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/task/DeviceOrderTask.java
@@ -3,8 +3,10 @@
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.iot.domain.DeviceOrder;
import com.ruoyi.iot.domain.DeviceOrderTime;
import com.ruoyi.iot.mapper.DeviceOrderMapper;
import com.ruoyi.iot.service.IDeviceOrderService;
import com.ruoyi.iot.service.IDeviceOrderTimeService;
import io.lettuce.core.ScriptOutputType;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
@@ -27,6 +29,8 @@
    @Resource
    private IDeviceOrderService iDeviceOrderService;
    @Resource
    private DeviceOrderMapper deviceOrderMapper;
    @Resource
    private IDeviceOrderTimeService iDeviceOrderTimeService;
@@ -59,17 +63,39 @@
            int finishTimeout = 0;
            //遍历deviceOrderList集合取出每一条数据的receive_time,如果receive_time不为空,计算receive_time接单时间和assgin_time派单时间之间相差多少分钟
            for (DeviceOrderTime deviceOrderTimes : deviceOrderTimeList) {
                if (deviceOrders.getReceiveTime() != null && deviceOrders.getAssginTime() != null) {
                if (deviceOrders.getAssginTime() != null) {
                    //拿到设备订单表里面订单的创建者的id
                    int createUser_Id = deviceOrders.getCreateUserId().intValue();
                    //拿到设备订单超时时间表的userid
                    Integer userId = deviceOrderTimes.getUserId();
                    Integer userId = deviceOrderTimes.getUserId();  //14
                    Integer orderType = deviceOrderTimes.getOrderType();
                    Integer deviceOrderType = Integer.valueOf(deviceOrders.getOrderType());
                    //拿到两个receive_timeout一个是 order_type = 1的和order_type=2的,finish_timeout拿到两个
                    if (createUser_Id == userId && deviceOrderTimes.getOrderType() == 1) {
                        receiveTimeout = deviceOrderTimes.getReceiveTimeout();  //600
                    if (createUser_Id == userId && deviceOrderTimes.getOrderType() == 1 && deviceOrderType == deviceOrderTimes.getOrderType()) {
                        receiveTimeout = deviceOrderTimes.getReceiveTimeout();
                        finishTimeout = deviceOrderTimes.getFinishTimeout();
                        break;
                    }
                    if (createUser_Id == userId && deviceOrderTimes.getOrderType() == 2) {
                    if (createUser_Id == userId && deviceOrderTimes.getOrderType() == 2 && deviceOrderType == deviceOrderTimes.getOrderType()) {
                        receiveTimeout = deviceOrderTimes.getReceiveTimeout();
                        finishTimeout = deviceOrderTimes.getFinishTimeout();
                        break;
                    }
                }
                if (deviceOrders.getReceiveTime() != null) {
                    //拿到设备订单表里面订单的创建者的id
                    int createUser_Id = deviceOrders.getCreateUserId().intValue();
                    //拿到设备订单超时时间表的userid
                    Integer userId = deviceOrderTimes.getUserId();  //14
                    Integer orderType = deviceOrderTimes.getOrderType();
                    Integer deviceOrderType = Integer.valueOf(deviceOrders.getOrderType());
                    //拿到两个receive_timeout一个是 order_type = 1的和order_type=2的,finish_timeout拿到两个
                    if (createUser_Id == userId && deviceOrderTimes.getOrderType() == 1 && deviceOrderType.equals(deviceOrderTimes.getOrderType())) {
                        receiveTimeout = deviceOrderTimes.getReceiveTimeout();
                        finishTimeout = deviceOrderTimes.getFinishTimeout();
                        break;
                    }
                    if (createUser_Id == userId && deviceOrderTimes.getOrderType() == 2 && deviceOrderType.equals(deviceOrderTimes.getOrderType())) {
                        receiveTimeout = deviceOrderTimes.getReceiveTimeout();
                        finishTimeout = deviceOrderTimes.getFinishTimeout();
                        break;
@@ -79,26 +105,26 @@
            //拿到当前时间的年月日时分秒去减——接单时间receive_time和派单时间assign_time 得到时间间隔分钟,
            //并判断得到的这个时间间隔大不大于receive_timeout和finish_timeout的值
            SimpleDateFormat targetFormatA = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
            String timeStrA = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"));  //当前时间
            String formatA = targetFormatA.format(deviceOrders.getReceiveTime());  //接单时间
            LocalDateTime startDateTimeA = LocalDateTime.parse(timeStrA);
            LocalDateTime endDateTimeB = LocalDateTime.parse(formatA);
            String formatA = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"));  //当前时间
            String formatB = targetFormatA.format(deviceOrders.getAssginTime());  //接单时间
            LocalDateTime startDateTimeA = LocalDateTime.parse(formatA);
            LocalDateTime endDateTimeB = LocalDateTime.parse(formatB);
            Duration durationA = Duration.between(startDateTimeA, endDateTimeB);
            long receive_timeMinutes = durationA.toMinutes();
            if (receive_timeMinutes > receiveTimeout) {
                deviceOrders.setReceiveTimeoutFlag(true);
            long finishTimeMinutes = Math.abs(durationA.toMinutes());
            if (finishTimeMinutes > finishTimeout) {
                deviceOrders.setId(deviceOrders.getId());
                deviceOrders.setReceiveTimeoutFlag(1);
                int rows = deviceOrderMapper.updateDeviceOrder(deviceOrders);
            }
            SimpleDateFormat targetFormatB = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
            String timeStrB = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"));  //当前时间
            String formatB = targetFormatB.format(deviceOrders.getAssginTime());
            LocalDateTime startDateTimeC = LocalDateTime.parse(timeStrB);
            LocalDateTime endDateTimeD = LocalDateTime.parse(formatB);
            String formatC = targetFormatA.format(deviceOrders.getAssginTime());
            LocalDateTime startDateTimeC = LocalDateTime.parse(formatA);
            LocalDateTime endDateTimeD = LocalDateTime.parse(formatC);
            Duration durationB = Duration.between(startDateTimeC, endDateTimeD);
            long finish_timeMinutes = durationB.toMinutes();
            if (receive_timeMinutes > finishTimeout) {
                deviceOrders.setFinishTimeoutFlag(true);
            long receiveTimeMinutes = Math.abs(durationB.toMinutes());
            if (receiveTimeMinutes > receiveTimeout) {
                deviceOrders.setId(deviceOrders.getId());
                deviceOrders.setFinishTimeoutFlag(1);
                int rows = deviceOrderMapper.updateDeviceOrder(deviceOrders);
                break;
            }
        }
wumei-smart-master/springboot/wumei-iot/src/main/resources/mapper/iot/DeviceMapper.xml
@@ -375,7 +375,9 @@
            <if test=" repairFlag != null">
                and d.repair_flag = #{repairFlag}
            </if>
            and d.install_flag = 1
            <if test=" installFlag != null">
                and d.install_flag = #{installFlag}
            </if>
            <if test="params.beginActiveTime != null and params.beginActiveTime != '' and params.endActiveTime != null and params.endActiveTime != ''">
                and d.active_time between #{params.beginActiveTime} and #{params.endActiveTime}
            </if>
wumei-smart-master/springboot/wumei-iot/src/main/resources/mapper/iot/DeviceOrderMapper.xml
@@ -337,7 +337,7 @@
        <if test="state != null and state != ''">#{state},</if>
        <if test="createUserId != null and createUserId != 0">#{createUserId},</if>
        <if test="imgUrl != null and imgUrl != ''">#{imgUrl},</if>
        <if test="customFlag != null and customFlag !=''">#{custom_flag},</if>
        <if test="customFlag != null and customFlag !=''">#{customFlag},</if>
        sysdate())
    </insert>
    <update id="updateDeviceOrder" parameterType="DeviceOrder">
@@ -389,6 +389,8 @@
            <if test="isRate != null">is_rate= #{isRate},</if>
            <if test="updateUserId != null and updateUserId != 0">updateuser_id = #{updateUserId},</if>
            <if test="imgUrl != null and imgUrl != ''">imgurl = #{imgUrl},</if>
            <if test="receiveTimeoutFlag != null and receiveTimeoutFlag != ''">receive_timeout_flag = #{receiveTimeoutFlag},</if>
            <if test="finishTimeoutFlag != null and finishTimeoutFlag != ''">finish_timeout_flag = #{finishTimeoutFlag},</if>
            <if test="customFlag != null and customFlag !=''">custom_flag = #{customFlag},</if>
        </set>
        where id = #{id}
wumei-smart-master/springboot/wumei-quartz/src/main/java/com/ruoyi/quartz/util/JobInvokeUtil.java
@@ -57,7 +57,7 @@
    /**
     * 校验是否为为class包名
     *
     * @param str 名称
     * @param invokeTarget 名称
     * @return true是 false否
     */
    public static boolean isValidClassName(String invokeTarget) {
wumei-smart-master/springboot/wumei-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java
@@ -1,28 +1,31 @@
package com.ruoyi.system.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.ruoyi.common.core.domain.entity.SysDept;
/**
 * 部门管理 数据层
 *
 *
 * @author ruoyi
 */
public interface SysDeptMapper
{
@Mapper
public interface SysDeptMapper {
    /**
     * 查询部门管理数据
     *
     *
     * @param dept 部门信息
     * @return 部门信息集合
     */
    public List<SysDept> selectDeptList(SysDept dept);
    /**
     * 根据角色ID查询部门树信息
     *
     * @param roleId 角色ID
     *
     * @param roleId            角色ID
     * @param deptCheckStrictly 部门树选择项是否关联显示
     * @return 选中部门列表
     */
@@ -30,7 +33,7 @@
    /**
     * 根据部门ID查询信息
     *
     *
     * @param deptId 部门ID
     * @return 部门信息
     */
@@ -38,7 +41,7 @@
    /**
     * 根据ID查询所有子部门
     *
     *
     * @param deptId 部门ID
     * @return 部门列表
     */
@@ -46,7 +49,7 @@
    /**
     * 根据ID查询所有子部门(正常状态)
     *
     *
     * @param deptId 部门ID
     * @return 子部门数
     */
@@ -54,7 +57,7 @@
    /**
     * 是否存在子节点
     *
     *
     * @param deptId 部门ID
     * @return 结果
     */
@@ -62,7 +65,7 @@
    /**
     * 查询部门是否存在用户
     *
     *
     * @param deptId 部门ID
     * @return 结果
     */
@@ -70,7 +73,7 @@
    /**
     * 校验部门名称是否唯一
     *
     *
     * @param deptName 部门名称
     * @param parentId 父部门ID
     * @return 结果
@@ -79,7 +82,7 @@
    /**
     * 新增部门信息
     *
     *
     * @param dept 部门信息
     * @return 结果
     */
@@ -87,7 +90,7 @@
    /**
     * 修改部门信息
     *
     *
     * @param dept 部门信息
     * @return 结果
     */
@@ -95,14 +98,14 @@
    /**
     * 修改所在部门正常状态
     *
     *
     * @param deptIds 部门ID组
     */
    public void updateDeptStatusNormal(Long[] deptIds);
    /**
     * 修改子元素关系
     *
     *
     * @param depts 子元素
     * @return 结果
     */
@@ -110,7 +113,7 @@
    /**
     * 删除部门管理信息
     *
     *
     * @param deptId 部门ID
     * @return 结果
     */
wumei-smart-master/springboot/wumei-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java
@@ -19,6 +19,14 @@
    public List<SysUser> selectUserList(SysUser sysUser);
    /**
     * 根据部门Id去查询信息
     *
     * @param deptId
     * @return
     */
    public SysUser selectUserByDeptId(Long deptId);
    /**
     * 根据条件分页查询未已配用户角色列表
     *
     * @param user 用户信息
wumei-smart-master/springboot/wumei-system/src/main/java/com/ruoyi/system/service/ISysPostService.java
@@ -1,18 +1,18 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.SysPost;
/**
 * 岗位信息 服务层
 *
 *
 * @author ruoyi
 */
public interface ISysPostService
{
public interface ISysPostService {
    /**
     * 查询岗位信息集合
     *
     *
     * @param post 岗位信息
     * @return 岗位列表
     */
@@ -20,14 +20,14 @@
    /**
     * 查询所有岗位
     *
     *
     * @return 岗位列表
     */
    public List<SysPost> selectPostAll();
    /**
     * 通过岗位ID查询岗位信息
     *
     *
     * @param postId 岗位ID
     * @return 角色对象信息
     */
@@ -35,7 +35,7 @@
    /**
     * 根据用户ID获取岗位选择框列表
     *
     *
     * @param userId 用户ID
     * @return 选中岗位ID列表
     */
@@ -43,7 +43,7 @@
    /**
     * 校验岗位名称
     *
     *
     * @param post 岗位信息
     * @return 结果
     */
@@ -51,7 +51,7 @@
    /**
     * 校验岗位编码
     *
     *
     * @param post 岗位信息
     * @return 结果
     */
@@ -59,7 +59,7 @@
    /**
     * 通过岗位ID查询岗位使用数量
     *
     *
     * @param postId 岗位ID
     * @return 结果
     */
@@ -67,7 +67,7 @@
    /**
     * 删除岗位信息
     *
     *
     * @param postId 岗位ID
     * @return 结果
     */
@@ -75,7 +75,7 @@
    /**
     * 批量删除岗位信息
     *
     *
     * @param postIds 需要删除的岗位ID
     * @return 结果
     * @throws Exception 异常
@@ -84,7 +84,7 @@
    /**
     * 新增保存岗位信息
     *
     *
     * @param post 岗位信息
     * @return 结果
     */
@@ -92,7 +92,7 @@
    /**
     * 修改保存岗位信息
     *
     *
     * @param post 岗位信息
     * @return 结果
     */
wumei-smart-master/springboot/wumei-system/src/main/java/com/ruoyi/system/service/ISysUserService.java
@@ -5,7 +5,7 @@
import java.util.List;
/**
 * 用户 业务层
 * 用户业务层
 *
 * @author ruoyi
 */
@@ -20,11 +20,17 @@
    public List<SysUser> selectUserList(SysUser user);
    public List<SysUser> selectUserListByRoleKey(String roleKey);
    /**
     * 根据部门Id去查询信息
     *
     * @param deptId
     * @return
     */
    public SysUser selectUserByDeptId(Long deptId);
    /**
     * 根据条件分页查询已分配用户角色列表
     *
     * @param user 用户信息
wumei-smart-master/springboot/wumei-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
@@ -74,6 +74,11 @@
        return userMapper.selectUserListByRoleKey(roleKey);
    }
    @Override
    public SysUser selectUserByDeptId(Long deptId) {
        return userMapper.selectUserByDeptId(deptId);
    }
    /**
     * 根据条件分页查询已分配用户角色列表
     *
wumei-smart-master/springboot/wumei-system/src/main/resources/mapper/system/SysDeptMapper.xml
@@ -1,157 +1,182 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.SysDeptMapper">
    <resultMap type="SysDept" id="SysDeptResult">
        <id     property="deptId"     column="dept_id"     />
        <result property="parentId"   column="parent_id"   />
        <result property="ancestors"  column="ancestors"   />
        <result property="deptName"   column="dept_name"   />
        <result property="orderNum"   column="order_num"   />
        <result property="leader"     column="leader"      />
        <result property="phone"      column="phone"       />
        <result property="email"      column="email"       />
        <result property="status"     column="status"      />
        <result property="delFlag"    column="del_flag"    />
        <result property="parentName" column="parent_name" />
        <result property="createBy"   column="create_by"   />
        <result property="createTime" column="create_time" />
        <result property="updateBy"   column="update_by"   />
        <result property="updateTime" column="update_time" />
    </resultMap>
    <sql id="selectDeptVo">
        select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
    <resultMap type="SysDept" id="SysDeptResult">
        <id property="deptId" column="dept_id"/>
        <result property="parentId" column="parent_id"/>
        <result property="ancestors" column="ancestors"/>
        <result property="deptName" column="dept_name"/>
        <result property="orderNum" column="order_num"/>
        <result property="leader" column="leader"/>
        <result property="phone" column="phone"/>
        <result property="email" column="email"/>
        <result property="status" column="status"/>
        <result property="delFlag" column="del_flag"/>
        <result property="parentName" column="parent_name"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
    </resultMap>
    <sql id="selectDeptVo">
        select d.dept_id,
               d.parent_id,
               d.ancestors,
               d.dept_name,
               d.order_num,
               d.leader,
               d.phone,
               d.email,
               d.status,
               d.del_flag,
               d.create_by,
               d.create_time
        from sys_dept d
    </sql>
    <select id="selectDeptList" parameterType="SysDept" resultMap="SysDeptResult">
    <select id="selectDeptList" parameterType="SysDept" resultMap="SysDeptResult">
        <include refid="selectDeptVo"/>
        where d.del_flag = '0'
        <if test="deptId != null and deptId != 0">
            AND dept_id = #{deptId}
        </if>
        <if test="deptId != null and deptId != 0">
            AND dept_id = #{deptId}
        </if>
        <if test="parentId != null and parentId != 0">
            AND parent_id = #{parentId}
        </if>
        <if test="deptName != null and deptName != ''">
            AND dept_name like concat('%', #{deptName}, '%')
        </if>
        <if test="status != null and status != ''">
            AND status = #{status}
        </if>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
        order by d.parent_id, d.order_num
            AND parent_id = #{parentId}
        </if>
        <if test="deptName != null and deptName != ''">
            AND dept_name like concat('%', #{deptName}, '%')
        </if>
        <if test="status != null and status != ''">
            AND status = #{status}
        </if>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
        order by d.parent_id, d.order_num
    </select>
    <select id="selectDeptListByRoleId" resultType="Integer">
        select d.dept_id
        from sys_dept d
            left join sys_role_dept rd on d.dept_id = rd.dept_id
        select d.dept_id
        from sys_dept d
        left join sys_role_dept rd on d.dept_id = rd.dept_id
        where rd.role_id = #{roleId}
            <if test="deptCheckStrictly">
              and d.dept_id not in (select d.parent_id from sys_dept d inner join sys_role_dept rd on d.dept_id = rd.dept_id and rd.role_id = #{roleId})
            </if>
        order by d.parent_id, d.order_num
    </select>
        <if test="deptCheckStrictly">
            and d.dept_id not in (select d.parent_id from sys_dept d inner join sys_role_dept rd on d.dept_id =
            rd.dept_id and rd.role_id = #{roleId})
        </if>
        order by d.parent_id, d.order_num
    </select>
    <select id="selectDeptById" parameterType="Long" resultMap="SysDeptResult">
        <include refid="selectDeptVo"/>
        where dept_id = #{deptId}
    </select>
        <include refid="selectDeptVo"/>
        where dept_id = #{deptId}
    </select>
    <select id="checkDeptExistUser" parameterType="Long" resultType="int">
        select count(1) from sys_user where dept_id = #{deptId} and del_flag = '0'
    </select>
    <select id="hasChildByDeptId" parameterType="Long" resultType="int">
        select count(1) from sys_dept
        where del_flag = '0' and parent_id = #{deptId} limit 1
    </select>
    <select id="selectChildrenDeptById" parameterType="Long" resultMap="SysDeptResult">
        select * from sys_dept where find_in_set(#{deptId}, ancestors)
    </select>
    <select id="selectNormalChildrenDeptById" parameterType="Long" resultType="int">
        select count(*) from sys_dept where status = 0 and del_flag = '0' and find_in_set(#{deptId}, ancestors)
    </select>
    <select id="checkDeptNameUnique" resultMap="SysDeptResult">
        <include refid="selectDeptVo"/>
        where dept_name=#{deptName} and parent_id = #{parentId} limit 1
    </select>
        select count(1)
        from sys_user
        where dept_id = #{deptId}
          and del_flag = '0'
    </select>
    <select id="hasChildByDeptId" parameterType="Long" resultType="int">
        select count(1)
        from sys_dept
        where del_flag = '0'
          and parent_id = #{deptId} limit 1
    </select>
    <select id="selectChildrenDeptById" parameterType="Long" resultMap="SysDeptResult">
        select *
        from sys_dept
        where find_in_set(#{deptId}, ancestors)
    </select>
    <select id="selectNormalChildrenDeptById" parameterType="Long" resultType="int">
        select count(*)
        from sys_dept
        where status = 0
          and del_flag = '0'
          and find_in_set(#{deptId}, ancestors)
    </select>
    <select id="checkDeptNameUnique" resultMap="SysDeptResult">
        <include refid="selectDeptVo"/>
        where dept_name=#{deptName} and parent_id = #{parentId} limit 1
    </select>
    <insert id="insertDept" parameterType="SysDept">
         insert into sys_dept(
             <if test="deptId != null and deptId != 0">dept_id,</if>
             <if test="parentId != null and parentId != 0">parent_id,</if>
             <if test="deptName != null and deptName != ''">dept_name,</if>
             <if test="ancestors != null and ancestors != ''">ancestors,</if>
             <if test="orderNum != null and orderNum != ''">order_num,</if>
             <if test="leader != null and leader != ''">leader,</if>
             <if test="phone != null and phone != ''">phone,</if>
             <if test="email != null and email != ''">email,</if>
             <if test="status != null">status,</if>
             <if test="createBy != null and createBy != ''">create_by,</if>
             create_time
         )values(
             <if test="deptId != null and deptId != 0">#{deptId},</if>
             <if test="parentId != null and parentId != 0">#{parentId},</if>
             <if test="deptName != null and deptName != ''">#{deptName},</if>
             <if test="ancestors != null and ancestors != ''">#{ancestors},</if>
             <if test="orderNum != null and orderNum != ''">#{orderNum},</if>
             <if test="leader != null and leader != ''">#{leader},</if>
             <if test="phone != null and phone != ''">#{phone},</if>
             <if test="email != null and email != ''">#{email},</if>
             <if test="status != null">#{status},</if>
             <if test="createBy != null and createBy != ''">#{createBy},</if>
             sysdate()
         )
    </insert>
    <update id="updateDept" parameterType="SysDept">
         update sys_dept
         <set>
             <if test="parentId != null and parentId != 0">parent_id = #{parentId},</if>
             <if test="deptName != null and deptName != ''">dept_name = #{deptName},</if>
             <if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>
             <if test="orderNum != null and orderNum != ''">order_num = #{orderNum},</if>
             <if test="leader != null">leader = #{leader},</if>
             <if test="phone != null">phone = #{phone},</if>
             <if test="email != null">email = #{email},</if>
             <if test="status != null and status != ''">status = #{status},</if>
             <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
             update_time = sysdate()
         </set>
         where dept_id = #{deptId}
    </update>
    <update id="updateDeptChildren" parameterType="java.util.List">
        update sys_dept set ancestors =
        <foreach collection="depts" item="item" index="index"
            separator=" " open="case dept_id" close="end">
            when #{item.deptId} then #{item.ancestors}
        </foreach>
        where dept_id in
        <foreach collection="depts" item="item" index="index"
            separator="," open="(" close=")">
            #{item.deptId}
        </foreach>
    </update>
    <update id="updateDeptStatusNormal" parameterType="Long">
         update sys_dept set status = '0' where dept_id in
         <foreach collection="array" item="deptId" open="(" separator="," close=")">
            #{deptId}
        insert into sys_dept(
        <if test="deptId != null and deptId != 0">dept_id,</if>
        <if test="parentId != null and parentId != 0">parent_id,</if>
        <if test="deptName != null and deptName != ''">dept_name,</if>
        <if test="ancestors != null and ancestors != ''">ancestors,</if>
        <if test="orderNum != null and orderNum != ''">order_num,</if>
        <if test="leader != null and leader != ''">leader,</if>
        <if test="phone != null and phone != ''">phone,</if>
        <if test="email != null and email != ''">email,</if>
        <if test="status != null">status,</if>
        <if test="createBy != null and createBy != ''">create_by,</if>
        create_time
        )values(
        <if test="deptId != null and deptId != 0">#{deptId},</if>
        <if test="parentId != null and parentId != 0">#{parentId},</if>
        <if test="deptName != null and deptName != ''">#{deptName},</if>
        <if test="ancestors != null and ancestors != ''">#{ancestors},</if>
        <if test="orderNum != null and orderNum != ''">#{orderNum},</if>
        <if test="leader != null and leader != ''">#{leader},</if>
        <if test="phone != null and phone != ''">#{phone},</if>
        <if test="email != null and email != ''">#{email},</if>
        <if test="status != null">#{status},</if>
        <if test="createBy != null and createBy != ''">#{createBy},</if>
        sysdate()
        )
    </insert>
    <update id="updateDept" parameterType="SysDept">
        update sys_dept
        <set>
            <if test="parentId != null and parentId != 0">parent_id = #{parentId},</if>
            <if test="deptName != null and deptName != ''">dept_name = #{deptName},</if>
            <if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>
            <if test="orderNum != null and orderNum != ''">order_num = #{orderNum},</if>
            <if test="leader != null">leader = #{leader},</if>
            <if test="phone != null">phone = #{phone},</if>
            <if test="email != null">email = #{email},</if>
            <if test="status != null and status != ''">status = #{status},</if>
            <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
            update_time = sysdate()
        </set>
        where dept_id = #{deptId}
    </update>
    <update id="updateDeptChildren" parameterType="java.util.List">
        update sys_dept set ancestors =
        <foreach collection="depts" item="item" index="index"
                 separator=" " open="case dept_id" close="end">
            when #{item.deptId} then #{item.ancestors}
        </foreach>
    </update>
    <delete id="deleteDeptById" parameterType="Long">
        update sys_dept set del_flag = '2' where dept_id = #{deptId}
    </delete>
        where dept_id in
        <foreach collection="depts" item="item" index="index"
                 separator="," open="(" close=")">
            #{item.deptId}
        </foreach>
    </update>
    <update id="updateDeptStatusNormal" parameterType="Long">
        update sys_dept set status = '0' where dept_id in
        <foreach collection="array" item="deptId" open="(" separator="," close=")">
            #{deptId}
        </foreach>
    </update>
    <delete id="deleteDeptById" parameterType="Long">
        update sys_dept
        set del_flag = '2'
        where dept_id = #{deptId}
    </delete>
</mapper> 
wumei-smart-master/springboot/wumei-system/src/main/resources/mapper/system/SysUserMapper.xml
@@ -266,6 +266,65 @@
        <include refid="selectUserVo"/>
        where r.role_key = #{roleKey}
    </select>
    <select id="selectUserByDeptId" resultMap="SysUserResult">
        select
        u.user_id,
        u.dept_id,
        u.nick_name,
        u.user_name,
        u.email,
        u.avatar,
        u.phonenumber,
        u.password,
        u.sex,
        u.status,
        u.del_flag,
        u.login_ip,
        u.login_date,
        u.create_by,
        u.create_time,
        u.remark,
        u.is_authentication,
        d.dept_name,
        d.leader,
        d.parent_id,
        d.ancestors,
        d.dept_name,
        d.order_num,
        d.phone,
        d.email,
        d.status,
        d.create_by,
        d.create_time,
        d.update_by,
        d.update_time,
        u.region,
        u.address,
        u.level,
        u.superior_id,
        d2.dept_name as superior_name,
        u.company,
        r.role_id,
        r.role_name,
        r.role_key,
        r.role_sort,
        r.data_scope,
        r.status as role_status,
        r.create_by,
        r.create_time,
        r.update_by,
        r.update_time,
        r.remark
        from sys_user u
        left join sys_dept d on u.dept_id = d.dept_id
        left join sys_dept d2 on u.superior_id = d2.dept_id
        left join sys_user_role ur on u.user_id = ur.user_id
        left join sys_role r on r.role_id = ur.role_id
        where u.del_flag = '0'
        <if test="deptId != null and deptId != 0">
            and u.dept_id = #{deptId}
        </if>
    </select>
    <insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
        insert into sys_user(
wumei-smart-master/vue/src/views/equipmentManagement/installation.vue
@@ -25,7 +25,7 @@
                <el-form-item>
                    <el-button size="mini" type="primary" icon="el-icon-search"
                        @click="changePage(1)">搜索</el-button></el-form-item>
                <el-form-item v-if="roleKey=='tenantservice'||roleKey=='tenanthelper'">
                <el-form-item v-if="roleKey=='tenant'||roleKey=='tenanthelper'">
                    <el-button size="mini" type="primary" icon="el-icon-message-solid"
                        @click="openTimeOutModal">超时配置</el-button></el-form-item>
                <el-form-item style="float: right;" v-if="roleKey !== 'admin'">
wumei-smart-master/vue/src/views/equipmentManagement/maintenance.vue
@@ -1,1025 +1,801 @@
<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
            type="primary"
            icon="el-icon-search"
            size="mini"
            @click="changePage(1)"
            >搜索</el-button
          >
        </el-form-item>
        <el-form-item
          v-if="roleKey == 'tenantservice' || roleKey == 'tenanthelper'"
        >
          <el-button
            size="mini"
            type="primary"
            icon="el-icon-message-solid"
            @click="openTimeOutModal"
            >超时配置</el-button
          ></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 label="基本信息"> -->
        <el-table-column prop="id" label="编号" width="60"> </el-table-column>
    <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 type="primary" icon="el-icon-search" size="mini" @click="changePage(1)">搜索</el-button>
                </el-form-item>
                <el-form-item v-if="roleKey=='tenant'||roleKey=='tenanthelper'">
                    <el-button size="mini" type="primary" icon="el-icon-message-solid"
                        @click="openTimeOutModal">超时配置</el-button></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 label="基本信息"> -->
                <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> -->
        <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>
                        </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="description" label="故障描述">
            <template slot-scope="scope">
              <div>
                {{ scope.row.description ? scope.row.description : "--" }}
              </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="appointmentTime" label="预约时间" width="150">
                        <template slot-scope="scope">
                            <div>
                                {{ scope.row.appointmentTime ? scope.row.appointmentTime : '--' }}
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column prop="description" label="故障描述">
                        <template slot-scope="scope">
                            <div>
                                {{ scope.row.description ? scope.row.description : '--' }}
                            </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
              >
              <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-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-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="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"
            :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-item
          label="用户评分"
          v-if="form.isRate"
          :label-width="formLabelWidth"
        >
          <el-rate
            disabled
            v-model="form.score"
            style="padding-top: 8px"
          ></el-rate>
        </el-form-item>
        <el-form-item
          label="用户评价"
          v-if="form.isRate"
          :label-width="formLabelWidth"
        >
          <el-input
            type="textarea"
            disabled
            v-model="form.evaluate"
            :disabled="view"
          ></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <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%">
      <span>是否删除该条数据</span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="deleteModal = false">取 消</el-button>
        <el-button type="primary" @click="delDate">确 定</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">取 消</el-button>
        <el-button type="primary" @click="add">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog title="超时配置" :visible.sync="timeOutModal">
      <el-form :model="timeForm" :rules="timeRules" ref="timeForm">
        <el-form-item
          label="派单接单超时间隔(单位:分钟)"
          :label-width="timeformLabelWidth"
          prop="ReceiveTimeout"
        >
          <el-input
            v-model="timeForm.ReceiveTimeout"
            autocomplete="off"
          ></el-input>
        </el-form-item>
        <el-form-item
          label="接单完成超时间隔(单位:分钟)"
          :label-width="timeformLabelWidth"
          prop="FinishTimeout"
        >
          <el-input
            v-model="timeForm.FinishTimeout"
            autocomplete="off"
          ></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="timeOutModal = false" size="mini">取 消</el-button>
        <el-button
          type="primary"
          @click="submitTimeForm('timeForm')"
          size="mini"
          >确 定</el-button
        >
      </div>
    </el-dialog>
  </div>
        </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 == '修改维修单' || 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="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" :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-item label="用户评分" v-if="form.isRate" :label-width="formLabelWidth">
                    <el-rate disabled v-model="form.score" style="padding-top: 8px;"></el-rate>
                </el-form-item>
                <el-form-item label="用户评价" v-if="form.isRate" :label-width="formLabelWidth">
                    <el-input type="textarea" disabled v-model="form.evaluate" :disabled="view"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <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%">
            <span>是否删除该条数据</span>
            <span slot="footer" class="dialog-footer">
                <el-button @click="deleteModal = false">取 消</el-button>
                <el-button type="primary" @click="delDate">确 定</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">取 消</el-button>
                <el-button type="primary" @click="add">确 定</el-button>
            </span>
        </el-dialog>
        <el-dialog title="超时配置" :visible.sync="timeOutModal">
            <el-form :model="timeForm" :rules="timeRules" ref="timeForm">
                <el-form-item label="派单接单超时间隔(单位:分钟)" :label-width="timeformLabelWidth" prop="ReceiveTimeout">
                    <el-input v-model="timeForm.ReceiveTimeout" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="接单完成超时间隔(单位:分钟)" :label-width="timeformLabelWidth" prop="FinishTimeout">
                    <el-input v-model="timeForm.FinishTimeout" autocomplete="off"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="timeOutModal = false" size="mini">取 消</el-button>
                <el-button type="primary" @click="submitTimeForm('timeForm')" size="mini">确 定</el-button>
            </div>
        </el-dialog>
    </div>
</template>
<script>
import request from "@/utils/request";
import request from '@/utils/request'
export default {
  data() {
    return {
      timeForm: {
        ReceiveTimeout: 0,
        FinishTimeout: 0,
      },
      timeRules: {
        ReceiveTimeout: [
          {
            required: true,
            message: "派单接单超时间隔不能为空",
            trigger: "blur",
          },
        ],
        FinishTimeout: [
          {
            required: true,
            message: "接单完成超时间隔不能为空",
            trigger: "blur",
          },
        ],
      },
      timeOutModal: false,
      nextlevel: 0,
      level: 0,
      nickName: localStorage.getItem("nickName"),
      acceptModal: false,
      acceptDateParams: {},
      title: "创建维修单",
      deleteModal: false,
      pageIndex: 1,
      pageSize: 10,
      total: 0,
      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: [],
      timeformLabelWidth: "215px",
      formLabelWidth: "120px",
      AZModal: false,
      deviceList: [],
      state: -1,
      id: 0,
      erectoList: [],
      erectoListLevel: [],
      roleKey: localStorage.getItem("roleKey"),
      dialogImageUrl: "",
      dialogVisible: false,
      view: false,
      delDeviceId: 0,
    };
  },
    data() {
        return {
            timeForm: {
                ReceiveTimeout: 0,
                FinishTimeout: 0,
            },
            timeRules: {
                ReceiveTimeout: [
                    { required: true, message: "派单接单超时间隔不能为空", trigger: "blur" }
                ],
                FinishTimeout: [
                    { required: true, message: "接单完成超时间隔不能为空", trigger: "blur" }
                ],
            },
            timeOutModal: false,
            nextlevel: 0,
            level: 0,
            nickName: localStorage.getItem('nickName'),
            acceptModal: false,
            acceptDateParams: {},
            title: '创建维修单',
            deleteModal: false,
            pageIndex: 1,
            pageSize: 10,
            total: 0,
            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: [
            ],
            timeformLabelWidth: '215px',
            formLabelWidth: '120px',
            AZModal: false,
            deviceList: [],
            state: -1,
            id: 0,
            erectoList: [],
            erectoListLevel: [],
            roleKey: localStorage.getItem('roleKey'),
            dialogImageUrl: '',
            dialogVisible: false,
            view: false,
            delDeviceId:0
  mounted() {
    this.getList();
    this.getErectoList();
    this.getErectoListLevel();
  },
  methods: {
    submitTimeForm() {
      this.$refs["timeForm"].validate((valid) => {
        if (valid) {
          this.editTimeOut();
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    editTimeOut() {
      let data = {
        receiveTimeout: this.timeForm.ReceiveTimeout,
        finishTimeout: this.timeForm.FinishTimeout,
        orderType: 2,
        userId: localStorage.getItem("userID"),
      };
      request({
        url: `/iot/deviceOrder/updatetimeout`,
        method: "put",
        params: data,
      })
        .then((res) => {
          console.log(res);
          if (res.code == 200) {
            this.$message({
              message: "修改成功",
              type: "success",
            });
            this.timeOutModal = false;
          } else {
            this.$message({
              message: "修改失败",
              type: "error",
            });
          }
        })
        .catch((res) => {
          this.$message({
            message: "修改失败",
            type: "error",
          });
        });
    },
    getTimeOut() {
      let data = {
        orderType: 2,
        userId: localStorage.getItem("userID"),
      };
      request({
        url: `/iot/deviceOrder/selecttimeout`,
        method: "get",
        params: data,
      })
        .then((res) => {
          console.log(res);
          if (res.code == 200) {
            this.timeForm.ReceiveTimeout = res.data.receiveTimeout;
            this.timeForm.FinishTimeout = res.data.finishTimeout;
          } else {
            this.timeForm.ReceiveTimeout = 0;
            this.timeForm.FinishTimeout = 0;
          }
        })
        .catch((res) => {
          this.timeForm.ReceiveTimeout = 0;
          this.timeForm.FinishTimeout = 0;
          return false;
        });
    },
    openTimeOutModal() {
      this.getTimeOut();
      this.timeOutModal = true;
    },
    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);
      formData.append("orderType", 2);
      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,
        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 = {
        repairFlag: 0,
        // installFlag: 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: 2,
      };
      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: "", //预约时间
        description: "", //故障描述
        erectoId: -1, //维修工
        userName: "", //用户信息,联系人
        userPhone: "", //用户信息联系电话
        erectoName: "未指派",
        state: 0,
        erectoPhone: "",
      };
      this.title = "创建维修单";
      this.AZModal = true;
    },
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          this.add();
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    add() {
        // let userId=undefined
      console.log(this.erectoList);
      for (let i = 0; i < this.erectoList.length; i++) {
        if (this.form.erectoId == this.erectoList[i].userId) {
          this.form.erectoName = this.erectoList[i].nickName;
          this.form.erectoPhone = this.erectoList[i].phonenumber;
          // userId=this.erectoList[i].userId
        }
      }
      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,
        description: this.form.description,
        state: this.form.state,
        orderType: "2",
        repairFlag: 1,
        erectoPhone: this.form.erectoPhone,
        // userId:userId
      };
      if (this.form.receiveTime) {
        data.receiveTime = this.form.receiveTime;
      }
      console.log(data);
      if (this.title == "修改维修单") {
        data.id = this.id;
        if (this.form.state == 3) {
          if (!this.form.imgUrl) {
            this.$message({
              message: "请上传图片",
              type: "error",
    mounted() {
        this.getList();
        this.getErectoList()
        this.getErectoListLevel()
    },
    methods: {
        submitTimeForm() {
            this.$refs['timeForm'].validate((valid) => {
                if (valid) {
                    this.editTimeOut()
                } else {
                    console.log('error submit!!');
                    return false;
                }
            });
            return;
          }
          data.imgUrl = this.form.imgUrl;
        }
        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;
        },
        editTimeOut() {
            let data = {
                receiveTimeout: this.timeForm.ReceiveTimeout,
                finishTimeout: this.timeForm.FinishTimeout,
                orderType: 2,
                userId: localStorage.getItem('userID')
            }
          })
          .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;
            request({
                url: `/iot/deviceOrder/updatetimeout`,
                method: "put",
                params: data,
            }).then((res) => {
                console.log(res);
                if (res.code == 200) {
                    this.$message({
                        message: '修改成功',
                        type: 'success'
                    });
                    this.timeOutModal = false
                } else {
                    this.$message({
                        message: '修改失败',
                        type: 'error'
                    });
                }
            }).catch((res) => {
                this.$message({
                    message: '修改失败',
                    type: 'error'
                });
            })
        },
        getTimeOut() {
            let data = {
                orderType: 2,
                userId: localStorage.getItem('userID')
            }
          })
          .catch((res) => {
            this.state = -1;
            this.pageIndex = 1;
            this.getList();
            this.AZModal = false;
          });
      }
            request({
                url: `/iot/deviceOrder/selecttimeout`,
                method: "get",
                params: data,
            }).then((res) => {
                console.log(res);
                if (res.code == 200) {
                    this.timeForm.ReceiveTimeout = res.data.receiveTimeout
                    this.timeForm.FinishTimeout = res.data.finishTimeout
                } else {
                    this.timeForm.ReceiveTimeout = 0
                    this.timeForm.FinishTimeout = 0
                }
            }).catch((res) => {
                this.timeForm.ReceiveTimeout = 0
                this.timeForm.FinishTimeout = 0
                return false
            })
        },
        openTimeOutModal() {
            this.getTimeOut()
            this.timeOutModal = true
        },
        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);
            formData.append('orderType', 2);
            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,
                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 = {
                repairFlag: 0,
                // installFlag:1
            }
            request({
                url: '/iot/device/shortListRepair',
                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: 2,
            }
            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: '',//预约时间
                description: '',//故障描述
                erectoId: -1,//维修工
                userName: '', //用户信息,联系人
                userPhone: '',//用户信息联系电话
                erectoName: '未指派',
                state: 0,
                erectoPhone: '',
            }
            this.title = '创建维修单'
            this.AZModal = true
        },
        submitForm() {
            this.$refs['form'].validate((valid) => {
                if (valid) {
                    this.add()
                } else {
                    console.log('error submit!!');
                    return false;
                }
            });
        },
        add() {
            // let userId=undefined
            console.log(this.erectoList);
            for (let i = 0; i < this.erectoList.length; i++) {
                if (this.form.erectoId == this.erectoList[i].userId) {
                    this.form.erectoName = this.erectoList[i].nickName
                    this.form.erectoPhone = this.erectoList[i].phonenumber
                    // userId=this.erectoList[i].userId
                }
            }
            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,
                description: this.form.description,
                state: this.form.state,
                orderType: '2',
                repairFlag: 1,
                erectoPhone: this.form.erectoPhone,
                // userId:userId
            }
            if (this.form.receiveTime) {
                data.receiveTime = this.form.receiveTime
            }
            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",
                    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.view = false
            this.AZModal = true
            this.id = item.id
        },
        delModal(item) {
            this.id = item.id
            this.delDeviceId=item.deviceId
            this.deleteModal = true
        },
        delDate() {
            let that = this
            let data = {
                id: that.id,
                deviceId:that.delDeviceId
            }
            request({
                url: `/iot/deviceOrder/${that.id}/${that.delDeviceId}`,
                method: "DELETE",
                // data: 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) {
            if (!item.appointmentTime) {
                this.$message({
                    message: '请和客户确认预约时间并录入系统再接单!',
                    type: 'error'
                });
                return false
            }
            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.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();
            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}`;
        },
        // 结单查看
        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.view = false;
      this.AZModal = true;
      this.id = item.id;
    },
    delModal(item) {
      this.id = item.id;
      this.delDeviceId = item.deviceId;
      this.deleteModal = true;
    },
    delDate() {
      let that = this;
      let data = {
        id: that.id,
        deviceId: that.delDeviceId,
      };
      request({
        url: `/iot/deviceOrder/${that.id}/${that.delDeviceId}`,
        method: "DELETE",
        //data: 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) {
      if (!item.appointmentTime) {
        this.$message({
          message: "请和客户确认预约时间并录入系统再接单!",
          type: "error",
        });
        return false;
      }
      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.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();
      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}`;
    },
    // 结单查看
    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": {
      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>