index.vue 16.7 KB
Newer Older
1 2 3
<template>
  <div class="app-container detail" style="background-color: rgb(238, 241, 245);">
    <div style="padding-top: 10px;background: #fff;height: 100%;">
4
      <el-row>
yaqizhang's avatar
yaqizhang committed
5
        <el-col :span="24" style="padding-left: 15px;margin-bottom: -10px;">
6 7 8
          <div style="height: 45px;" @click="$router.go(-1)">
            <el-button size="medium" type="text" style="font-size: 18px; color: rgb(7, 63, 112);float: left;">返回
            </el-button>
yaqizhang's avatar
yaqizhang committed
9 10
            <div style="float: left;margin-top: 8px;margin-left: 5px;"><img src="../../../assets/logo/fanhui.png"
                style="width: 25px;" alt=""></div>
11 12 13
          </div>
        </el-col>
      </el-row>
yaqizhang's avatar
yaqizhang committed
14
      <el-row style="width: 100%;height: 40px;">
yaqizhang's avatar
yaqizhang committed
15 16
        <el-col :span="24">
          <div style="">
yaqizhang's avatar
yaqizhang committed
17 18 19
            <ul>
              <li style="list-style: none;font-weight: 900;font-size: 20px;color: #053b6a;">设备信息管理详情</li>
            </ul>
yaqizhang's avatar
yaqizhang committed
20 21 22
          </div>
        </el-col>
      </el-row>
23
      <el-divider></el-divider>
yaqizhang's avatar
yaqizhang committed
24
      <el-row style="width: 100%;margin-top: -15px;margin-bottom: -5px;">
25 26
        <el-col :span="24">
          <div style="color: #31EAEA;height: 25px;">
yaqizhang's avatar
yaqizhang committed
27 28 29
            <ul>
              <li>详细信息</li>
            </ul>
30
          </div>
31
        </el-col>
32 33
      </el-row>

yaqizhang's avatar
yaqizhang committed
34
      <el-row style="width: 100%;padding: 10px;">
35
        <el-col :span="5">
yaqizhang's avatar
yaqizhang committed
36
          <el-form ref="form" v-model="form" label-width="100px" style="width: 100%;">
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
            <el-form-item label="设备名称:" prop="deviceName">
              <font>{{form.deviceName}}</font>
            </el-form-item>
            <el-form-item label="设备编号:" prop="deviceCode">
              <font>{{form.deviceCode}}</font>
            </el-form-item>
            <el-form-item label="设备类型:" prop="deviceType">
              <font v-if="form.deviceType == 1">调压阀</font>
              <font v-if="form.deviceType == 2">阀门井</font>
              <font v-if="form.deviceType == 3">流量计</font>
              <font v-if="form.deviceType == 4">压力表</font>
            </el-form-item>
            <el-form-item label="设备型号:" prop="deviceModel">
              <font>{{form.deviceModel}}</font>
            </el-form-item>
yaqizhang's avatar
yaqizhang committed
52 53 54
            <el-form-item label="所属管道:" prop="pipeName">
              <font>{{form.pipeName}}</font>
            </el-form-item>
55
            <el-form-item label="物联网编号:" prop="iotNo">
56 57 58 59 60 61 62 63
              <font>{{form.iotNo}}</font>
            </el-form-item>
            <el-form-item label="联系人:" prop="linkman">
              <font>{{form.linkman}}</font>
            </el-form-item>
            <el-form-item label="联系电话:" prop="phone">
              <font>{{form.phone}}</font>
            </el-form-item>
yaqizhang's avatar
yaqizhang committed
64
            <el-form-item label="备注信息:" prop="remarks" style="width: 170%;">
65 66 67
              <font>{{form.remarks}}</font>
            </el-form-item>
          </el-form>
68 69
        </el-col>
        <el-col :span="6">
yaqizhang's avatar
yaqizhang committed
70
          <el-form ref="form" v-model="form" label-width="100px" style="width: 100%;">
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
            <el-form-item label="所在地址:" prop="deviceAddr">
              <font>{{form.deviceAddr}}</font>
            </el-form-item>
            <el-form-item label="经度:" prop="longitude">
              <font>{{form.longitude}}</font>
            </el-form-item>
            <el-form-item label="经度:" prop="latitude">
              <font>{{form.latitude}}</font>
            </el-form-item>
            <el-form-item label="安装时间:" prop="installationTime">
              <font>{{form.installationTime}}</font>
            </el-form-item>
            <el-form-item label="最后巡检时间:" prop="inspectionTime">
              <font>{{form.inspectionTime}}</font>
            </el-form-item>
王晓倩's avatar
王晓倩 committed
86 87 88 89
            <el-form-item label="设备图片:" prop="iconUrl">
              <div style="width: 20%;">
                <el-image :src="form.iconUrl" :preview-src-list="[form.iconUrl]" style="width: auto;height: auto;"></el-image>
              </div>
90 91
            </el-form-item>
          </el-form>
92 93
        </el-col>
        <el-col :span="11">
yaqizhang's avatar
yaqizhang committed
94
          <div id="marbox"
yaqizhang's avatar
yaqizhang committed
95
            style="width: 100%;height: 390px;margin-top: -25px; border: 1px solid rgb(218, 213, 213);margin-bottom: 10px;">
96 97 98 99
            <div style="width: 100%;height: 100%" id="container"></div>
          </div>
        </el-col>
      </el-row>
100

yaqizhang's avatar
yaqizhang committed
101
      <div class="" style="width: 95%; height: 60px;margin-left: 50px;text-align: center;margin-top: 5px;">
yaqizhang's avatar
yaqizhang committed
102 103 104 105
        <el-button size="normal" type="primary" icon="el-icon-edit" @click="handleUpdate(form)"
          v-hasPermi="['device:deviceInfo:edit']">修改</el-button>
        <el-button size="normal" type="primary" icon="el-icon-delete" @click="handleDelete(form)"
          v-hasPermi="['device:deviceInfo:remove']">删除</el-button>
106 107 108 109 110

        <el-dialog :title="title" :visible.sync="open" append-to-body @close="cancel">
          <el-form ref="editForm" :model="editForm" :rules="rules" label-width="135px">
            <el-col :span="11">
              <el-form-item label="所属管道" prop="pipeId">
yaqizhang's avatar
yaqizhang committed
111 112
                <el-select v-model="editForm.pipeId" placeholder="请选择所属管道" filterable style="width: 100%">
                  <el-option v-for="item in options" :key="item.pipeId" :label="item.pipeName" :value="item.pipeId">
113 114 115 116 117 118 119 120 121 122 123 124 125
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="设备编号" prop="deviceCode">
                <el-input v-model="editForm.deviceCode" placeholder="请输入设备编号" />
              </el-form-item>
            </el-col>

            <el-col :span="11">
              <el-form-item label="设备类型" prop="deviceType">
yaqizhang's avatar
yaqizhang committed
126 127 128
                <el-select v-model="editForm.deviceType" placeholder="请选择设备类型" filterable style="width: 100%">
                  <el-option v-for="dict in typeOptions" :key="dict.dictValue" :label="dict.dictLabel"
                    :value="dict.dictValue"></el-option>
129 130 131 132 133 134
                </el-select>
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="设备名称" prop="deviceName">
yaqizhang's avatar
yaqizhang committed
135
                <el-input v-model="editForm.deviceName" placeholder="请输入设备名称" />
136 137 138 139 140
              </el-form-item>
            </el-col>

            <el-col :span="11">
              <el-form-item label="设备型号" prop="deviceModel">
yaqizhang's avatar
yaqizhang committed
141
                <el-input v-model="editForm.deviceModel" placeholder="请输入设备型号" />
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="物联网编号" prop="iotNo">
                <el-input v-model="editForm.iotNo" placeholder="请输入物联网编号" />
              </el-form-item>
            </el-col>

            <el-col :span="23">
              <el-form-item label="所在地址" prop="deviceAddr">
                <el-input v-model="editForm.deviceAddr" placeholder="请输入所在地址" />
              </el-form-item>
            </el-col>

            <el-col :span="23">
              <el-form-item label="经纬度坐标" prop="longitude">
                <el-row>
                  <el-col :span="8">
                    <el-input v-model.number="editForm.longitude" placeholder="请输入经度" />
                  </el-col>
                  <el-col :span="8" style="margin-left: 10px">
yaqizhang's avatar
yaqizhang committed
164
                    <el-input v-model.number="editForm.latitude" placeholder="请输入纬度" />
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
                  </el-col>
                  <el-col :span="5" style="margin-left: 10px">
                    <el-button type="primary" plain @click="MapdialogFun">选择经纬度</el-button>
                  </el-col>
                </el-row>
              </el-form-item>
            </el-col>

            <el-col :span="11">
              <el-form-item label="联系人" prop="linkman">
                <el-input v-model="editForm.linkman" placeholder="请输入联系人" />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="联系电话" prop="phone">
yaqizhang's avatar
yaqizhang committed
181
                <el-input type="number" maxlength="12" v-model="editForm.phone" placeholder="请输入联系电话" />
182 183 184 185 186
              </el-form-item>
            </el-col>

            <el-col>
              <el-form-item label="设备图片上传" prop="iconUrl">
yaqizhang's avatar
yaqizhang committed
187
                <MyFileUpload listType="picture-card" @resFun="getFileInfo" @remove="listRemove" :fileArr="fileList" />
188 189 190 191 192 193 194
                <el-input v-show="false" disabled v-model="editForm.iconUrl"></el-input>
              </el-form-item>
            </el-col>

            <el-col>
              <el-form-item label="安装日期" prop="installationTime">
                <el-col :span="11">
yaqizhang's avatar
yaqizhang committed
195 196
                  <el-date-picker clearable size="small" style="width: 100%" v-model="editForm.installationTime"
                    type="date" value-format="yyyy-MM-dd" placeholder="请选择安装日期">
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
                  </el-date-picker>
                </el-col>
              </el-form-item>
            </el-col>

            <el-col :span="23">
              <el-form-item label="备注信息" prop="remarks">
                <el-input type="textarea" v-model="editForm.remarks" placeholder="请输入备注信息" />
              </el-form-item>
            </el-col>
          </el-form>
          <div slot="footer" class="dialog-footer">
            <el-button type="primary" @click="submitForm">确 定</el-button>
            <el-button @click="cancel">取 消</el-button>
          </div>
        </el-dialog>

yaqizhang's avatar
yaqizhang committed
214 215
        <Mapdialog v-if="loadmap" :dialogTableVisible="dialogTableVisible" @dialogcancelFun="dialogcancelFun"
          :slat="editForm.latitude" :slng="editForm.longitude" @confirmFun="confirmFun($event)"></Mapdialog>
216
      </div>
217 218 219 220 221 222
    </div>
  </div>
</template>

<script>

223 224 225 226
  import { updateDeviceInfo, getDeviceInfo } from "@/api/device/deviceInfo";
  import { pipeAllInfoList } from "@/api/device/pipe";
  import MyFileUpload from '@/components/MyFileUpload';
  import Mapdialog from "@/components/mapDialog/checkDeviceLoaction.vue";
227 228 229 230 231 232
  import gaodeMap from "utils/gaodeMap.js";
  import { DEVICE_TYPE } from "utils/gaodeMap.js";

  export default {
    name: "DeviceInfoDetail",
    components: {
233 234
      MyFileUpload,
      Mapdialog
235 236 237
    },
    data() {
      return {
238 239 240 241 242 243 244 245 246 247 248 249 250
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 管道列表
        options: [],
        // 上传文件列表
        fileList: [],
        // 地图
        loadmap: false,
        dialogTableVisible: false,
        // 设备类型字典
        typeOptions: [],
251
        // 表单参数
yaqizhang's avatar
yaqizhang committed
252
        form: {},
253
        editForm: {},
254
        // 表单校验
yaqizhang's avatar
yaqizhang committed
255
        rules: {
256 257 258
          pipeId: [
            { required: true, message: "请选择所属管道", trigger: "blur" },
          ],
yaqizhang's avatar
yaqizhang committed
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293
          deviceType: [
            { required: true, message: "请选择设备类型", trigger: "blur" },
          ],
          deviceName: [
            { required: true, message: "请输入设备名称", trigger: "blur" },
          ],
          deviceCode: [
            { required: true, message: "请输入设备编号", trigger: "blur" },
          ],
          deviceModel: [
            { required: true, message: "请输入设备型号", trigger: "blur" },
          ],
          deviceAddr: [
            { required: true, message: "请输入所在地址", trigger: "blur" },
          ],
          longitude: [
            { required: true, message: "请输入经纬度", trigger: "blur" },
          ],
          iotNo: [
            { required: true, message: "请输入物联网编号", trigger: "blur" },
          ],
          linkman: [
            { required: true, message: "请输入联系人", trigger: "blur" }
          ],
          phone: [
            { required: true, message: "请输入联系电话", trigger: "blur" },
            { min: 11, max: 11, message: "长度11个数字", trigger: "blur" },
          ],
          iconUrl: [
            { required: true, message: "请上传图片", trigger: "change" }
          ],
          installationTime: [
            { required: true, message: "请选择日期", trigger: "change" },
          ],
        }
294 295 296 297 298
      };
    },
    created() {
      // 如果是跳转来的,则接受初始化参数
      this.deviceId = this.$route.query.deviceId;
299

300 301 302
      this.getDicts("t_device_type").then(response => {
        this.typeOptions = response.data;
      });
303
    },
yaqizhang's avatar
yaqizhang committed
304 305 306 307
    mounted() {
      this.getDetail();
      // let gaoMap = new gaodeMap("石家庄");
      // this.gaoMap = gaoMap;
308 309
    },
    methods: {
yaqizhang's avatar
yaqizhang committed
310 311
      getDetail() {
        getDeviceInfo(this.deviceId).then(response => {
312
          this.form = response.data;
yaqizhang's avatar
yaqizhang committed
313 314 315
          console.log(this.form, "this.form")
          const obj =this.form;
          // this.gaoMap.resetMapCenter([this.form.longitude, this.form.latitude]);let obj = this.form.deviceList[0];
316
          let gaoMap = new gaodeMap(process.env.VUE_APP_MAP_CENTER, [obj.longitude, obj.latitude]);
yaqizhang's avatar
yaqizhang committed
317
          this.gaoMap = gaoMap;
yaqizhang's avatar
yaqizhang committed
318 319 320 321 322 323 324 325 326 327 328 329 330
          if("1" == obj.deviceType){
            this.gaoMap.addMarker(DEVICE_TYPE.REGEULATORBOX, obj,"false")
          }
          if("2" == obj.deviceType){
            this.gaoMap.addMarker(DEVICE_TYPE.VALUEWELL, obj,"false")
          }
          if("3" == obj.deviceType){
            this.gaoMap.addMarker(DEVICE_TYPE.FLOWMETER, obj,"false")
          }
          if("4" == obj.deviceType){
            this.gaoMap.addMarker(DEVICE_TYPE.PRESSUREGAGE, obj,"false")
          }
          // this.gaoMap.addMarker(DEVICE_TYPE.WORKORDER, this.form)
331 332
        });
      },
yaqizhang's avatar
yaqizhang committed
333
      getFileInfo(res) {
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401
        this.editForm.iconUrl = res.url;
      },
      listRemove(e) {
        this.editForm.iconUrl = "";
        this.fileList = [];
      },
      confirmFun(res) {
        //确认选择经纬度
        this.editForm.longitude = res.lng;
        this.editForm.latitude = res.lat;
      },
      MapdialogFun() {
        this.loadmap = true;
        this.dialogTableVisible = true;
      },
      dialogcancelFun() {
        this.loadmap = false;
        this.dialogTableVisible = false;
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.fileList = [];
      },
      /** 修改按钮操作 */
      handleUpdate(res) {
        pipeAllInfoList().then(response => {
          this.options = response.data;
        });
        getDeviceInfo(res.deviceId).then(response => {
          this.editForm = response.data;
          if (this.editForm.iconUrl) {
            this.fileList.push({
              url: this.editForm.iconUrl,
            });
          }
          this.open = true;
          this.title = "修改设备信息";
        });
      },
      /** 提交按钮 */
      submitForm() {
        this.$refs["editForm"].validate(valid => {
          if (valid) {
            console.log(this.editForm);
            updateDeviceInfo(this.editForm).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              location.reload();
            });
          }
        });
      },
      /** 删除按钮操作 */
      handleDelete(res) {
        res.isDel = "1";
        this.$confirm('是否确认删除设备名称为"' + res.deviceName + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function () {
          return updateDeviceInfo(res);
        }).then(() => {
          this.$router.go(-1);
          this.msgSuccess("已删除");
        }).catch(() => {
        });
      },
402 403 404 405 406 407 408 409 410 411
    }
  }
</script>
<style>
  .el-divider--horizontal {
    display: block;
    height: 1px;
    width: 100%;
    margin: 20px 0;
  }
yaqizhang's avatar
yaqizhang committed
412 413 414 415 416

  .feedbackTime-div {
    float: left;
    margin-left: 150px;
    margin-top: 10px;
417
  }
yaqizhang's avatar
yaqizhang committed
418 419

  .feedbackTime {
420 421 422 423 424 425 426 427 428 429
    height: 120px;
    width: 120px;
    float: left;
    margin-left: 15px;
    margin-top: 5px;
    margin-bottom: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
  }
yaqizhang's avatar
yaqizhang committed
430

431 432 433
  .el-card__body {
    padding: 5px 20px 20px 20px;
  }
yaqizhang's avatar
yaqizhang committed
434 435

  .detail .el-form {
436 437
    width: 20%;
  }
yaqizhang's avatar
yaqizhang committed
438 439

  .detail .el-form-item {
440 441
    margin-bottom: 0px;
  }
yaqizhang's avatar
yaqizhang committed
442 443

  .avatar-uploader {
444 445 446
    width: 25%;
    float: left;
  }
yaqizhang's avatar
yaqizhang committed
447

448 449 450 451 452 453 454
  .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
yaqizhang's avatar
yaqizhang committed
455

456 457 458
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
yaqizhang's avatar
yaqizhang committed
459

460 461 462 463 464 465 466 467
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
  }
yaqizhang's avatar
yaqizhang committed
468

469 470 471 472 473
  .avatar {
    width: 178px;
    height: 178px;
    display: block;
  }
yaqizhang's avatar
yaqizhang committed
474 475

  li {
476 477 478
    font-size: 15px;
    font-weight: 900;
  }
479
</style>