设备维修单的功能实现,对超级管理员对安装单和维修单的数据操作做了限制,新添加了description维修描述字段,对应的类做了添加20231121wmz
1个文件已删除
9个文件已修改
790 ■■■■■ 已修改文件
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/controller/DeviceController.java 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/controller/DeviceOrderController.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/controller/DeviceRepairController.java 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/mapper/DeviceMapper.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/IDeviceService.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/impl/DeviceServiceImpl.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-iot/src/main/resources/mapper/iot/DeviceMapper.xml 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/vue/src/views/equipmentManagement/installation.vue 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/vue/src/views/equipmentManagement/maintenance.vue 599 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/vue/src/views/index.vue 42 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/controller/DeviceController.java
@@ -16,6 +16,7 @@
import com.ruoyi.system.service.ISysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.checkerframework.checker.units.qual.A;
import org.quartz.SchedulerException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
@@ -61,22 +62,26 @@
    /**
     * 查询首页的总用户数(人),总设备数(台)
     *
     * @param tenantName
     * @param id
     * @return
     * @throws Exception
     */
    @PreAuthorize("@ss.hasPermi('iot:device:list')")
    @GetMapping(value = {"/", "/{tenantName}"})
    @GetMapping("/select/{id}")
    @ApiOperation(value = "获取总用户数和总设备数")
    public AjaxResult selectCount(@PathVariable("tenantName") String tenantName) throws Exception {
        //根据用户登录的角色身份查询总设备数(台)
        int count = deviceService.selectDeviceCount(tenantName);
        //根据登录用户的角色身份查询设备的使用人数
        int total = deviceService.selectUserDeviceByCount(tenantName);
        AjaxResult ajax = new AjaxResult();
        ajax.put("deviceCount", count);
        ajax.put("userTotal", total);
        return AjaxResult.success("查询成功", ajax);
    public AjaxResult selectCount(@PathVariable("id") int id) throws Exception {
        if (id > 0) {
            //根据用户登录的角色身份查询总设备数(台)
            int count = deviceService.selectDeviceCount(id);
            //根据登录用户的角色身份查询设备的使用人数
            int total = deviceService.selectUserDeviceByCount(id);
            AjaxResult ajax = new AjaxResult();
            ajax.put("deviceCount", count);
            ajax.put("userTotal", total);
            return AjaxResult.success("查询成功", ajax);
        } else {
            return AjaxResult.error("未查询到有关信息,id的值不能小于1");
        }
    }
@@ -139,12 +144,12 @@
    /**
     * 获取设备详细信息
     */
//    @PreAuthorize("@ss.hasPermi('iot:device:query')")
//    @GetMapping(value = "/{deviceId}")
//    @ApiOperation("获取设备详情")
//    public AjaxResult getInfo(@PathVariable("deviceId") Long deviceId) {
//        return AjaxResult.success(deviceService.selectDeviceByDeviceId(deviceId));
//    }
    @PreAuthorize("@ss.hasPermi('iot:device:query')")
    @GetMapping(value = "/{deviceId}")
    @ApiOperation("获取设备详情")
    public AjaxResult getInfo(@PathVariable("deviceId") Long deviceId) {
        return AjaxResult.success(deviceService.selectDeviceByDeviceId(deviceId));
    }
    /**
     * 设备数据同步
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/controller/DeviceOrderController.java
@@ -16,6 +16,7 @@
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
@@ -73,16 +74,20 @@
        //更新订单的用户信息
        SysUser sysUser = getLoginUser().getUser();
        deviceOrder.setCreateUserId(sysUser.getUserId());
        //插入安装订单
        int rows = iDeviceOrderService.insertDeviceOrder(deviceOrder);
        if (rows > 0) {
            //更新当前设备状态信息--安装中
            Device device = new Device();
            device.setDeviceId(deviceOrder.getDeviceId());
            device.setStatus(5);
            deviceService.updateDevice(device);
        if (sysUser.getUserId() != 1) {
            //插入安装订单
            int rows = iDeviceOrderService.insertDeviceOrder(deviceOrder);
            if (rows > 0) {
                //更新当前设备状态信息--安装中
                Device device = new Device();
                device.setDeviceId(deviceOrder.getDeviceId());
                device.setStatus(5);
                deviceService.updateDevice(device);
            }
            return toAjax(rows);
        } else {
            return AjaxResult.error("超级管理员不可以添加设备单信息");
        }
        return toAjax(rows);
    }
    /**
@@ -101,7 +106,11 @@
        SysUser sysUser = getLoginUser().getUser();
        //拿到修改安装单的用户id
        deviceOrder.setUpdateUserId(sysUser.getUserId());
        return toAjax(iDeviceOrderService.updateDeviceOrder(deviceOrder));
        if (sysUser.getUserId() != 1) {
            return toAjax(iDeviceOrderService.updateDeviceOrder(deviceOrder));
        } else {
            return AjaxResult.error("超级管理员不可以修改信息");
        }
    }
    /**
@@ -118,8 +127,9 @@
    public AjaxResult remove(@PathVariable("deviceId") Integer deviceId) throws Exception {
        //根据要删除安装单的id查询出安装单信息
        DeviceOrder deviceOrder = iDeviceOrderService.selectDeviceOrderById(deviceId);
        SysUser user = getLoginUser().getUser();
        //如果根据查询出来的安装单对象不为空的话,并且状态等于未派单才可以删除
        if (deviceOrder != null && deviceOrder.getState() == 0) {
        if (deviceOrder != null && deviceOrder.getState() == 0 && user.getUserId() != 1) {
            //未派单的安装单删除后设备的状态更新为-未激活
            Device device = new Device();
            device.setDeviceId(deviceOrder.getDeviceId());
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/controller/DeviceRepairController.java
File was deleted
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/mapper/DeviceMapper.java
@@ -32,23 +32,23 @@
     */
    public DeviceStatistic selectDeviceProductAlertCount(Device device);
    /**
     * 查询总设备数(台)
     *
     * @param id
     * @return
     * @throws Exception
     */
    public int selectDeviceCount(String tenantName) throws Exception;
    public int selectDeviceCount(int id) throws Exception;
    /**
     * 根据登录用户的id查询设备的使用人数
     *
     * @param tenantName
     * @param id
     * @return
     * @throws Exception
     */
    public int selectUserDeviceByCount(String tenantName) throws Exception;
    public int selectUserDeviceByCount(int id) throws Exception;
    /**
     * 根据设备编号查询设备
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/IDeviceService.java
@@ -43,19 +43,20 @@
    /**
     * 查询总设备数(台)
     *
     * @param id
     * @return
     * @throws Exception
     */
    public int selectDeviceCount(String tenantName)throws Exception;
    public int selectDeviceCount(int id) throws Exception;
    /**
     * 根据登录用户的id查询设备的使用人数
     *
     * @param tenantName
     * @param id
     * @return
     * @throws Exception
     */
    public int selectUserDeviceByCount(String tenantName) throws Exception;
    public int selectUserDeviceByCount(int id) throws Exception;
    /**
     * 根据设备编号查询简介设备
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/impl/DeviceServiceImpl.java
@@ -149,25 +149,26 @@
    /**
     * 查询总设备数(台)
     *
     * @param id
     * @return
     * @throws Exception
     */
    @Override
    public int selectDeviceCount(String tenantName) throws Exception {
        return deviceMapper.selectDeviceCount(tenantName);
    public int selectDeviceCount(int id) throws Exception {
        return deviceMapper.selectDeviceCount(id);
    }
    /**
     * 根据登录用户的id查询设备的使用人数
     *
     * @param tenantName
     * @param id
     * @return
     * @throws Exception
     */
    @Override
    public int selectUserDeviceByCount(String tenantName) throws Exception {
        return deviceMapper.selectUserDeviceByCount(tenantName);
    public int selectUserDeviceByCount(int id) throws Exception {
        return deviceMapper.selectUserDeviceByCount(id);
    }
    /**
wumei-smart-master/springboot/wumei-iot/src/main/resources/mapper/iot/DeviceMapper.xml
@@ -627,8 +627,8 @@
    <select id="selectDeviceCount" resultType="int" parameterType="string">
        select count(*)
        from iot_device d where d.del_flag = '0'
        <if test=" tenantName != null and tanantName != 'admin'">
            AND d.tenant_name = #{tenantName}
        <if test=" tenantId != null and tenantId != 1">
            AND d.tenant_id = #{tenantId}
        </if>
    </select>
    <!--    根据登录用户的id查询设备的使用人数-->
@@ -636,8 +636,8 @@
        select count(DISTINCT d.user_id)
        from iot_device d
        where d.del_flag = '0'
        <if test=" tenantName != null and tanantName != 'admin'">
            AND d.tenant_name = #{tenantName}
        <if test=" tenantId != null and tenantId != 1">
            AND d.tenant_id = #{tenantId}
        </if>
    </select>
wumei-smart-master/vue/src/views/equipmentManagement/installation.vue
@@ -106,16 +106,17 @@
                    </el-table-column>
                </el-table-column> -->
                <el-table-column label="操作" fixed="right" align="center" class-name="small-padding fixed-width" width="150">
                <el-table-column label="操作" fixed="right" align="center" width="190" class-name="small-padding fixed-width" >
                    <template slot-scope="scope">
                        <!-- <el-button @click="editModal(scope.row)" type="text" size="small">编辑</el-button>
                        <el-button @click="delModal(scope.row)" type="text" size="small">删除</el-button> -->
                        <el-button size="small" type="primary" style="padding:5px;" icon="el-icon-edit"
                            v-hasPermi="['iot:device:edit']" @click="editModal(scope.row)">修改</el-button>
                        <el-button size="small" type="danger" style="padding:5px;" icon="el-icon-delete"
                            v-hasPermi="['iot:device:remove']" @click="delModal(scope.row)">删除</el-button>
                        <el-button v-if="scope.row.state == 1" size="small" type="primary" style="padding:5px;"
                            icon="el-icon-edit" @click="JDModal(scope.row)">接单</el-button>
                        <div style="display: flex;justify-content: space-around;flex-wrap: wrap;">
                            <el-button size="small" type="primary" style="padding:5px;" icon="el-icon-edit"
                                v-hasPermi="['iot:device:edit']" @click="editModal(scope.row)">修改</el-button>
                            <el-button size="small" type="danger" style="padding:5px;" icon="el-icon-delete"
                                v-hasPermi="['iot:device:remove']" @click="delModal(scope.row)">删除</el-button>
                            <el-button v-if="scope.row.state == 1" size="small" type="primary" style="padding:5px;"
                                icon="el-icon-edit" @click="JDModal(scope.row)">接单</el-button>
                        </div>
                    </template>
                </el-table-column>
            </el-table>
@@ -491,6 +492,7 @@
        editModal(item) {
            this.title = '修改安装单'
            this.form = item
            this.form = JSON.parse(JSON.stringify(item))
            this.deviceList = [{ deviceName: item.device.deviceName, deviceId: item.device.deviceId }]
            console.log(this.form);
            this.AZModal = true
wumei-smart-master/vue/src/views/equipmentManagement/maintenance.vue
@@ -3,216 +3,344 @@
        <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="菜单状态">
                        <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-button type="primary" icon="el-icon-search" @click="changePage(1)">搜索</el-button>
                <!-- <el-form-item label="状态" prop="status">
                    <el-select v-model="queryParams.WXBody" placeholder="菜单状态" clearable size="small">
                        <el-option v-for="dict in WXBodyType" :key="dict.value" :label="dict.label" :value="dict.value" />
                    </el-select>
                </el-form-item>
                <el-form-item label="状态" prop="status">
                    <el-select v-model="queryParams.WXBody" placeholder="菜单状态" clearable size="small">
                        <el-option v-for="dict in WXBodyType" :key="dict.value" :label="dict.label" :value="dict.value" />
                    </el-select>
                </el-form-item>
                <el-form-item>
                    <el-input placeholder="请输入内容" v-model="searchName" class="input-with-select">
                        <el-button slot="append" icon="el-icon-search"></el-button>
                    </el-input>
                </el-form-item>
                </el-form-item> -->
                <el-form-item style="float: right;">
                    <!-- <el-button @click="AZModal = true">添加</el-button> @click="openAZModal" -->
                    <el-button type="primary" plain icon="el-icon-plus" @click="AZModal = true">新增</el-button>
                    <el-button type="primary" v-hasPermi="['iot:device:add']" plain icon="el-icon-plus"
                        @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="name" label="编号" width="120">
                    </el-table-column>
                    <el-table-column prop="name" label="类型" width="120">
                    </el-table-column>
                    <el-table-column prop="name" label="描述" width="120">
                    </el-table-column>
                    <el-table-column prop="name" label="地区" width="120">
                    </el-table-column>
                    <el-table-column prop="name" label="地址" width="120">
                    </el-table-column>
                <!-- <el-table-column label="基本信息"> -->
                <el-table-column prop="id" label="编号" width="120">
                </el-table-column>
                <!-- </el-table-column> -->
                <el-table-column label="维修信息">
                    <el-table-column prop="name" label="预约时间" width="120">
                    <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="name" label="备注" width="120">
                    <el-table-column prop="erectoName" label="维修工" width="120">
                    </el-table-column>
                    <el-table-column prop="name" label="安装工" width="120"
                        :filters="[{ text: 'body1', value: 'body1' }, { text: 'body12', value: 'body12' }]"
                        :filter-method="filterHandlerBody">
                    <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="name" label="联系人" width="120">
                    <el-table-column prop="userName" label="联系人" width="120">
                    </el-table-column>
                    <el-table-column prop="name" label="联系电话" width="120">
                    <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="name" label="评分" width="120">
                <!-- <el-table-column label="评价信息">
                    <el-table-column prop="score" label="评分" width="120">
                    </el-table-column>
                    <el-table-column prop="name" label="评价" minWidth="120">
                    <el-table-column prop="evaluate" label="评价" minWidth="120">
                    </el-table-column>
                </el-table-column>
                <el-table-column label="状态" prop="zip" width="120"
                    :filters="[{ text: 'status1', value: 'status1' }, { text: 'status2', value: 'status2' }]"
                    :filter-method="filterHandlerStatus">
                </el-table-column> -->
                <el-table-column label="操作" fixed="right" align="center" width="190" class-name="small-padding fixed-width">
                    <template slot-scope="scope">
                        <el-button size="small" type="primary" style="padding:5px;" icon="el-icon-edit"
                            v-hasPermi="['iot:device:edit']" @click="editModal(scope.row)">修改</el-button>
                        <el-button size="small" type="danger" style="padding:5px;" icon="el-icon-delete"
                            v-hasPermi="['iot:device:remove']" @click="delModal(scope.row)">删除</el-button>
                        <el-button v-if="scope.row.state == 1" size="small" type="primary" style="padding:5px;"
                            icon="el-icon-edit" @click="JDModal(scope.row)">接单</el-button>
                    </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 background :current-page="pageIndex" @current-change="changePage" :page-size="pageSize"
                layout="prev, pager, next" :total="total" style="margin-top: 12px;">
            </el-pagination>
        </el-card>
        <el-dialog title="创建维修单" :visible.sync="AZModal">
            <el-form :model="form">
                <el-form-item label="用户名称" :label-width="formLabelWidth">
                    <el-input v-model="form.name" autocomplete="off"></el-input>
        <el-dialog :title="title" :visible.sync="AZModal">
            <el-form :model="form" :rules="rules" ref="form">
                <el-form-item label="设备" :label-width="formLabelWidth" prop="deviceId">
                    <el-select v-model="form.deviceId" placeholder="请选择" :disabled="title == '修改维修单'">
                        <el-option v-for="item in deviceList" :label="item.deviceName" :value="item.deviceId"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="手机号" :label-width="formLabelWidth">
                    <el-input v-model="form.name" autocomplete="off"></el-input>
                <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">
                    <el-input v-model="form.name" autocomplete="off"></el-input>
                <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">
                    <el-input v-model="form.name" autocomplete="off"></el-input>
                <el-form-item label="用户姓名" :label-width="formLabelWidth" prop="userName">
                    <el-input v-model="form.userName" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="地址" :label-width="formLabelWidth">
                    <el-input v-model="form.name" autocomplete="off"></el-input>
                <el-form-item label="手机号" :label-width="formLabelWidth" prop="userPhone">
                    <el-input v-model="form.userPhone" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="维修地址" :label-width="formLabelWidth" prop="address">
                    <el-input v-model="form.address" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="预约时间" :label-width="formLabelWidth">
                    <el-input v-model="form.name" autocomplete="off"></el-input>
                    <el-date-picker v-model="form.appointmentTime" type="datetime" placeholder="选择日期时间"
                        value-format="yyyy-MM-dd HH:mm:ss">
                    </el-date-picker>
                </el-form-item>
                <el-form-item label="备注" :label-width="formLabelWidth">
                    <el-input v-model="form.name" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="安装工" :label-width="formLabelWidth">
                    <el-select v-model="form.region" placeholder="请选择">
                        <el-option label="未指派" value="shanghai"></el-option>
                        <el-option label="安装工1号" value="beijing"></el-option>
                    </el-select>
                <el-form-item label="故障描述" :label-width="formLabelWidth">
                    <el-input type="textarea" v-model="form.description"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="AZModal = false">取 消</el-button>
                <el-button type="primary" @click="AZModal = false">确 定</el-button>
                <el-button type="primary" @click="submitForm('form')">确 定</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>
    </div>
</template>
<script>
// import {
//     listAlertLog,
//     getAlertLog,
//     delAlertLog,
//     addAlertLog,
//     updateAlertLog
// } from "@/api/iot/alertLog";
<script>
import request from '@/utils/request'
export default {
    // name: "AlertLog",
    // dicts: ['iot_alert_level', 'iot_process_status'],
    data() {
        return {
            pageIndex:1,
            pageSize:10,
            total:20,
            acceptModal: false,
            acceptDateParams: {},
            title: '创建维修单',
            deleteModal: false,
            pageIndex: 1,
            pageSize: 10,
            total: 20,
            searchName: '',
            queryParams: {
                WXBody: '未派单',
                PDBody: '未派单'
            },
            WXBodyType: [{ label: '全部工单', value: '全部工单' }, { label: '未派单', value: '未派单' }, { label: 'num1', value: 'num1' }],
            rules: {
                menuName: [
                    { required: true, message: "菜单名称不能为空", trigger: "blur" }
                deviceId: [
                    { required: true, message: '请选择设备', trigger: 'change' }
                ],
                orderNum: [
                    { required: true, message: "菜单顺序不能为空", trigger: "blur" }
                erectoId: [
                    { required: true, message: "请选择维修工", trigger: "change" }
                ],
                path: [
                    { required: true, message: "路由地址不能为空", trigger: "blur" }
                ]
                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: [
                {
                    date: '2016-05-03',
                    name: '王小虎',
                    province: '上海',
                    city: '普陀区',
                    address: '上海市普陀区金沙江路 1518 弄',
                    zip: 200333
                }, {
                    date: '2016-05-02',
                    name: '王小虎',
                    province: '上海',
                    city: '普陀区',
                    address: '上海市普陀区金沙江路 1518 弄',
                    zip: 200333
                }, {
                    date: '2016-05-04',
                    name: '王小虎',
                    province: '上海',
                    city: '普陀区',
                    address: '上海市普陀区金沙江路 1518 弄',
                    zip: 200333
                }, {
                    date: '2016-05-01',
                    name: '王小虎',
                    province: '上海',
                    city: '普陀区',
                    address: '上海市普陀区金沙江路 1518 弄',
                    zip: 200333
                }, {
                    date: '2016-05-08',
                    name: '王小虎',
                    province: '上海',
                    city: '普陀区',
                    address: '上海市普陀区金沙江路 1518 弄',
                    zip: 200333
                }, {
                    date: '2016-05-06',
                    name: '王小虎',
                    province: '上海',
                    city: '普陀区',
                    address: '上海市普陀区金沙江路 1518 弄',
                    zip: 200333
                }, {
                    date: '2016-05-07',
                    name: '王小虎',
                    province: '上海',
                    city: '普陀区',
                    address: '上海市普陀区金沙江路 1518 弄',
                    zip: 200333
                }
            ],
            AZModal:false,
            formLabelWidth: '120px',
            AZModal: false,
            deviceList: [],
            state: -1,
            id: 0,
            erectoList: [],
            erectoListLevel: [],
            roleKey: localStorage.getItem('roleKey'),
        }
    },
    created() {
        // this.getList();
    mounted() {
        this.getList();
        this.getErectoList()
        this.getErectoListLevel()
    },
    methods: {
        getErectoList() {
            let data = {
                pageNum: 1,
                pageSize: 10000,
                deptId: localStorage.getItem('deptId'),
                isAuthentication: 1,
            }
            request({
                url: '/system/user/list',
                method: "get",
                params: data
            }).then((res) => {
                console.log(res);
                if (res.code == 200) {
                    this.erectoList = res.rows
                    this.erectoList.unshift({
                        nickName: '未指派',
                        userId: -1
                    })
                } else {
                    this.erectoList = []
                }
            }).catch((res) => {
                this.erectoList = []
            })
        },
        getErectoListLevel() {
            this.erectoListLevel = []
            let data = {
                pageNum: 1,
                pageSize: 10000,
                deptId: localStorage.getItem('deptId'),
                // isAuthentication: 1,
                roleKey: 'tenanthelper',
            }
            request({
                url: '/system/user/list',
                method: "get",
                params: data
            }).then((res) => {
                console.log(res);
                if (res.code == 200 && res.rows.length > 0) {
                    this.erectoListLevel = res.rows
                    this.nextlevel = res.rows[0].userId
                } else {
                    this.erectoListLevel = []
                }
            }).catch((res) => {
                this.erectoListLevel = []
            })
        },
        // 获取设备列表
        getDeviceList() {
            let data = {
                // status: 1
            }
            request({
                url: '/iot/device/shortList',
                method: "get",
                params: data
            }).then((res) => {
                if (res.code == 200) {
                    this.deviceList = res.rows
                } else {
                    this.deviceList = []
                }
            }).catch((res) => {
                this.deviceList = []
            })
        },
        // 获取维修列表
        getList() {
            this.tableData = []
            let data = {
                pageNum: this.pageIndex,
                pageSize: this.pageSize,
                state: this.state,
                orderType: 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);
        },
@@ -222,19 +350,200 @@
        filterHandlerStatus(e) {
            console.log(3, e);
        },
        changePage(e){
            console.log(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
            }
            this.title = '创建维修单'
            this.AZModal = true
        },
        submitForm() {
            this.$refs['form'].validate((valid) => {
                if (valid) {
                    this.add()
                } else {
                    console.log('error submit!!');
                    return false;
                }
            });
        },
        add() {
            for (let i = 0; i < this.erectoList.length; i++) {
                if (this.form.erectoId == this.erectoList[i].userId) {
                    this.form.erectoName = this.erectoList[i].nickName
                }
            }
            console.log(this.form);
            let data = {
                deviceId: this.form.deviceId,
                erectoId: this.form.erectoId,
                erectoName: this.form.erectoName,
                userName: this.form.userName,
                userPhone: this.form.userPhone,
                address: this.form.address,
                appointmentTime: this.form.appointmentTime,
                description: this.form.description,
                state: this.form.state,
                orderType: '2'
            }
            if (this.form.receiveTime) {
                data.receiveTime = this.form.receiveTime
            }
            console.log(data);
            if (this.title == '修改维修单') {
                data.id = this.id
                request({
                    url: '/iot/deviceOrder',
                    method: "put",
                    data: data
                }).then((res) => {
                    console.log(res);
                    if (res.code == 200) {
                        this.state = -1
                        this.pageIndex = 1
                        this.getList()
                        this.AZModal = false
                        this.acceptModal = false
                    } else {
                        this.state = -1
                        this.pageIndex = 1
                        this.getList()
                        this.AZModal = false
                        this.acceptModal = false
                    }
                }).catch((res) => {
                    this.state = -1
                    this.pageIndex = 1
                    this.getList()
                    this.AZModal = false
                    this.acceptModal = false
                })
            } else {
                request({
                    url: '/iot/deviceOrder',
                    method: "post",
                    data: data
                }).then((res) => {
                    if (res.code == 200) {
                        this.state = -1
                        this.pageIndex = 1
                        this.getList()
                        this.AZModal = false
                    } else {
                        this.state = -1
                        this.pageIndex = 1
                        this.getList()
                        this.AZModal = false
                    }
                }).catch((res) => {
                    this.state = -1
                    this.pageIndex = 1
                    this.getList()
                    this.AZModal = false
                })
            }
        },
        editModal(item) {
            this.title = '修改维修单'
            this.form = item
            this.form = JSON.parse(JSON.stringify(item))
            this.deviceList = [{ deviceName: item.device.deviceName, deviceId: item.device.deviceId }]
            console.log(this.form);
            this.AZModal = true
            this.id = item.id
        },
        delModal(item) {
            this.id = item.id
            this.deleteModal = true
        },
        delDate() {
            let that = this
            let data = {
                id: this.id
            }
            request({
                url: `/iot/deviceOrder/${this.id}`,
                method: "DELETE",
                // params: data
            }).then((res) => {
                if (res.code == 200) {
                    that.pageIndex = 1
                    that.getList()
                    that.deleteModal = false
                } else {
                    that.pageIndex = 1
                    that.getList()
                    that.deleteModal = false
                }
            }).catch((res) => {
                that.pageIndex = 1
                that.getList()
                that.deleteModal = false
            })
        },
        JDModal(item) {
            this.title = '修改维修单'
            this.form = JSON.parse(JSON.stringify(item))
            this.form.state = 2
            this.deviceList = [{ deviceName: item.device.deviceName, deviceId: item.device.deviceId }]
            this.id = item.id
            this.form.receiveTime = this.formatNow()
            this.acceptModal = true
        },
        formatNow() {
            let now = new Date();
            let year = now.getFullYear();
            let month = (now.getMonth() + 1).toString().padStart(2, '0');  // 注意:月份是从 0 开始的,所以需要 +1
            let day = now.getDate().toString().padStart(2, '0');
            let hour = now.getHours().toString().padStart(2, '0');
            let minute = now.getMinutes().toString().padStart(2, '0');
            let second = now.getSeconds().toString().padStart(2, '0');
            let millisecond = now.getMilliseconds().toString().padStart(3, '0');
            return `${year}-${month}-${day}T${hour}:${minute}:${second}.${millisecond}Z`;
        },
    },
    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;
}
.el-select .el-input {
@@ -244,4 +553,4 @@
.input-with-select .el-input-group__prepend {
    background-color: #fff;
}
</style>
</style>
wumei-smart-master/vue/src/views/index.vue
@@ -1,6 +1,14 @@
<template>
  <div style="padding: 10px; background-color: #f8f8f8">
    <el-row :gutter="20" style="margin: 10px 0px 20px 0px">
    <el-row
      :gutter="20"
      style="margin: 10px 0px 20px 0px"
      v-if="
        this.roleKey == 'admin' ||
        this.roleKey == 'tenant' ||
        this.roleKey == 'tenanthelper'
      "
    >
      <el-card style="margin: 10px 10px 0px 10px">
        <ul
          style="
@@ -585,21 +593,6 @@
import * as echarts from "echarts";
require("echarts/theme/macarons"); // echarts theme
import { loadBMap } from "@/utils/map.js";
import request from '@/utils/request'
import {
    getDeviceStatistic,
} from "@/api/iot/device";
import {
    listNotice,
    getNotice,
} from "@/api/system/notice";
import CountTo from 'vue-count-to'
import * as echarts from 'echarts';
require('echarts/theme/macarons') // echarts theme
import {
    loadBMap
} from '@/utils/map.js'
//安装的是echarts完整包,里面包含百度地图扩展,路径为 echarts/extension/bmap/bmap.js,将其引入
//ECharts的百度地图扩展,可以在百度地图上展现点图,线图,热力图等可视化
require("echarts/extension/bmap/bmap");
@@ -679,6 +672,7 @@
      formLabelWidth: "120px",
      peopleNum: 0,
      deviceNum: 0,
      roleKey: localStorage.getItem("roleKey"),
    };
  },
  created() {
@@ -688,23 +682,25 @@
    this.getDeviceStatistic();
  },
  mounted() {
    this.getdeviceInfo();
    if (
      this.roleKey == "admin" ||
      this.roleKey == "tenant" ||
      this.roleKey == "tenanthelper"
    ) {
      this.getdeviceInfo();
    }
  },
  methods: {
    getdeviceInfo() {
      let data = {
        tenantName: localStorage.getItem("roleKey"),
        tenantName: localStorage.getItem("userID"),
      };
      request({
        url: `/iot/device/${localStorage.getItem("roleKey")}`,
        url: `/iot/device/select/${localStorage.getItem("userID")}`,
        method: "get",
        // params: data,
      })
        .then((res) => {
          console.log(res);
          if (res.code == 200) {
            console.log(res.data);
            this.titleInfo[2].num = res.data.userTotal;
            this.titleInfo[3].num = res.data.deviceCount;
          } else {