alarmDetail.vue 20.3 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 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 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 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 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563
<template>
  <div class="alarm_detail_page">

    <!-- 基本信息 开始 -->
    <div class="base_box">
      <div class="title">基本信息</div>
      <div class="cell_list">
        <div class="cell">
          <div class="name">姓名:</div>
          <div class="txt">{{detailInfo.ownerName || '--'}}</div>
        </div>
        <div class="cell">
          <div class="name">门店名称:</div>
          <div class="txt">{{detailInfo.shopName || '--'}}</div>
        </div>
        <div class="cell cell_address">
          <div class="name">门店地址:</div>
          <div class="txt">{{detailInfo.shopAddress || '--'}}</div>
        </div>
        <div class="cell">
          <div class="name">车架号:</div>
          <div class="txt">{{detailInfo.vin || '--'}}</div>
        </div>
        <div class="cell">
          <div class="name">门店联系方式:</div>
          <div class="txt">{{detailInfo.shopTelephone || '--'}}</div>
        </div>
        <div class="cell">
          <div class="name">业务工单号:</div>
          <div class="txt">{{detailInfo.workOrderNo || '--'}}</div>
        </div>
        <div class="cell">
          <div class="name">激活时间:</div>
          <div class="txt">{{detailInfo.activeTime || '--'}}</div>
        </div>
        <!-- <div class="cell" v-for="(item, index) in detailInfo.deviceStatus" :key="index">
          <div class="name">设备号({{item.source === 1 ? '有线' : '无线'}}):</div>
          <div class="txt">{{item.sn || '--'}}</div>
        </div> -->
        <div class="cell">
          <div class="name">设备号(有线):</div>
          <div class="txt">{{(detailInfo.wiredSns && detailInfo.wiredSns[0] && detailInfo.wiredSns[0].sn) || '--'}}</div>
        </div>
        <div class="cell">
          <div class="name">设备号(无线):</div>
          <div class="txt">{{(detailInfo.wirelessSns && detailInfo.wirelessSns[0] && detailInfo.wirelessSns[0].sn) || '--'}}</div>
        </div>
        <div class="cell">
          <div class="name">客户联系方式:</div>
          <div class="txt">{{detailInfo.lesseePhone || '--'}}</div>
        </div>
      </div>
    </div>
    <!-- 基本信息 end -->

    <!-- 设备信息 开始 -->
    <div class="base_box">
      <div class="title">设备信息</div>
      <div class="cell_list">
        <!-- <div class="cell" v-for="(item, index) in detailInfo.deviceStatus" :key="index">
          <div class="name">设备状态({{item.source === 1 ? '有线' : '无线'}}):</div>
          <div class="txt">
            <span>{{item.deviceStatus || '--'}}</span>
            <el-button type="primary" size="mini" class="btn" v-if="item.source === 1" @click="goMonitor">监控车辆</el-button>
          </div>
        </div> -->
        <div class="cell">
          <div class="name">设备状态(有线):</div>
          <div class="txt">
            <span>{{(detailInfo.wiredSns && detailInfo.wiredSns[0] && detailInfo.wiredSns[0].deviceStatus) || '--'}}</span>
            <el-button type="primary" size="mini" class="btn" v-if="(detailInfo.wiredSns && detailInfo.wiredSns[0] && detailInfo.wiredSns[0].deviceStatus)" @click="goMonitor">监控车辆</el-button>
          </div>
        </div>
        <div class="cell">
          <div class="name">设备状态(无线):</div>
          <div class="txt">
            <span>{{(detailInfo.wirelessSns && detailInfo.wirelessSns[0] && detailInfo.wirelessSns[0].deviceStatus) || '--'}}</span>
          </div>
        </div>
        <div class="cell">
          <div class="name">行驶里程:</div>
          <div class="txt">
            <span>{{detailInfo.distance || '--'}}</span>
            <el-button type="primary" size="mini" :disabled="!detailInfo.distance || !(detailInfo.wiredSns && detailInfo.wiredSns[0] && detailInfo.wiredSns[0].deviceStatus)" @click="goMileageGeneralDetail" v-if="Object.keys(detailInfo).length" class="btn">详情</el-button>
          </div>
        </div>
        <div class="cell">
          <div class="name">是否产生断电报警:</div>
          <div class="txt">
            <span>{{detailInfo.isPowerOff === 1 && detailInfo.alarmStatus === 0 ? '是' : detailInfo.isPowerOff !== 1 || detailInfo.alarmStatus !== 0 ? '否' : '--'}}</span>
            <el-button type="primary" size="mini" @click="goTamper" v-if="Object.keys(detailInfo).length" :disabled="detailInfo.isPowerOff !== 1 || detailInfo.alarmStatus !== 0" class="btn">详情</el-button>
          </div>
        </div>
      </div>
    </div>
    <!-- 设备信息 end -->

    <!-- 警情日历 开始 -->
    <div class="base_box">
      <div class="title">
        <span>警情日历</span>
        <div class="sub_desc">
          <span>首次报警日期:{{calendarData.alarmFirst}}</span>
          <span>累计报警次数:{{calendarData.alarmTotalCount}}次</span>
        </div>
      </div>

      <div class="filter_date_box">
        <el-date-picker class="el_date_picker" :editable="false" v-model="month" type="month" :clearable="false" placeholder="选择月" size="small"></el-date-picker>
        <el-button-group class="el_btn_group">
          <el-button :type="alarmLevel == item.id?'primary':'default'" plain size="small" v-for="(item,index) in alarmLevelList" :key="index" @click="alarmEvenet(item)">{{item.name}}</el-button>
        </el-button-group>
        <el-checkbox class="el_checkbox" v-model="checked">仅显示未处理的报警</el-checkbox>
      </div>

      <div class="calendar_box">
        <el-calendar class="el_calendar" v-model="defaultDate">
          <template
            slot="dateCell"
            slot-scope="{date, data}">
            <div class="date" @click="dateClick(data)">
              <div>
                {{ data.day.split("-").slice(1)[1] }}{{ data.isSelected ? '✔️' : ''}}
              </div>
              <div v-if="hasAlarm(data)" class="alarm-box">
                <span>{{data.alarmLevel}}</span>
              </div>
            </div>
          </template>
        </el-calendar>
      </div>

      <div class="alarm-wrap" v-show="calendarData.calendarList.length" v-if="currItem.length">
        <div class="alarm-main">
            <h3><i class="el-icon-bell"></i>风险预警</h3>
            <p><label>风险等级:</label>{{currItem[currIdx].alarmLevel || '--'}}级</p>
            <p><label>报警说明:</label>{{currItem[currIdx].alarmExplain || '--'}}</p>
            <p><label>情况建议:</label>{{currItem[currIdx].alarmSuggest || '--'}}</p>
        </div>
        <div class="alarm-box">
          <p class="alarm-item" v-show="Object.keys(alarmHandleResult).length"><label>采取措施:</label><span>{{alarmHandleResult.resolvent}}</span></p>
          <p class="alarm-item" v-show="Object.keys(alarmHandleResult).length"><label>备注:</label><span>{{alarmHandleResult.remark}}</span></p>
          <p v-show="Object.keys(alarmHandleResult).length"><label class="user_class">{{alarmHandleResult.operatorName}}</label>{{alarmHandleResult.processTime}}</p>
          <p class="cmd-row">
            <el-button 
              type="primary" 
              size="small" 
              icon="el-icon-edit" 
              v-popover:popover 
              @click="editResolve">{{Object.keys(alarmHandleResult).length ? '修改' : '处理'}}
            </el-button>
            <!-- <el-button 
              type="warning" 
              size="small" 
              icon="el-icon-star-off" 
              v-show="detailInfo.isAttention===0"
              @click="operation(1)">关注
            </el-button>
            <el-button 
              type="warning" 
              size="small" 
              icon="el-icon-star-off" 
              v-show="detailInfo.isAttention===1"
              @click="operation(0, detailInfo.isAttention)">取消关注
            </el-button>
            <el-button 
              type="info" 
              size="small" 
              icon="el-icon-remove-outline" 
              v-show="detailInfo.isAttention===0"
              @click="operation(2)">忽略
            </el-button>
            <el-button 
              type="info" 
              size="small" 
              icon="el-icon-remove-outline" 
              v-show="detailInfo.isAttention===2"
              @click="operation(0, detailInfo.isAttention)">取消忽略
            </el-button> -->
          </p>
        </div>
        <p v-show="currItem.length>1">
          <el-button size="mini" :disabled="currIdx===0" @click="prev"><i class="el-icon-arrow-left"></i>前一条</el-button>
          <el-button size="mini" :disabled="currIdx===currItem.length-1" @click="next">后一条<i class="el-icon-arrow-right"></i></el-button>
        </p>
        <!--弹框 -->
        <el-popover
          ref="popover"
          placement="bottom-start"
          width="400"
          v-model="editModalVisible"
          trigger="manual">
          <div class="popover-header">
          </div>
          <el-form :model="form" :rules="rules" ref="form" :inline="false" size="mini" @submit.native.prevent label-width="90px">
            <el-form-item label="采取措施" prop="actionText">
              <el-input type="text" ref="actionRefs" v-model="form.actionText" show-word-limit maxlength="20" placeholder="请选择或输入采取措施"></el-input>
              <el-tag type="info" size="mini" @click.native="addActionText('暂无异常')">暂无异常</el-tag>
              <el-tag type="info" size="mini" @click.native="addActionText('待观察')">待观察</el-tag>
              <el-tag type="info" size="mini" @click.native="addActionText('安排检修')">安排检修</el-tag>
              <el-tag type="info" size="mini" @click.native="addActionText('安排收车')">安排收车</el-tag>
            </el-form-item>
            <el-form-item label="备注" prop="remark">
              <el-input type="textarea" @keydown.enter.native="textareaKeydown" v-model="form.remark" show-word-limit maxlength="200" rows="10" placeholder="请输入至少五个字符"></el-input>
            </el-form-item>
          </el-form>
          <div style="text-align: right;">
            <el-button type="primary" size="small" @click="editSure">确认</el-button>
            <el-button size="small" @click="cancelEdit">取消</el-button>
          </div>
        </el-popover>
        <!-- 弹框 /-->
      </div>
    </div>
    <!-- 警情日历 end -->

  </div>
</template>
<script>
import moment from "moment";
import { GET_ALARM_INFO, GET_ALARM_INFO_CALENDAR, ALARM_INFO_EDIT, GET_LAST_ALARM_RESULT, ALARM_INFO_EDIT_STATUS } from "@/services/alarmCenter";
export default {
  components: {},
  data() {
    let checkAction = (rules, value, cb) => {
      if (!value) {
        cb(new Error('请输入采取措施'))
      } else if (!/^(?!\s+).*(?<!\s)$/.test(value)) {
        cb(new Error('首尾不可为空格'))
      } else if (!/^.{2,20}$/.test(value)) {
        cb(new Error('请输入2-20个字'))
      } else {
        cb()
      }
    }
    let checkRemark = (rules, value, cb) => {
      if (!value) {
        cb(new Error('请输入备注'))
      } else if (!/^(?!\s+).*(?<!\s)$/.test(value)) {
        cb(new Error('首尾不可为空格'))
      } else if (!/^.{5,200}$/.test(value)) {
        cb(new Error('请输入5-200个字'))
      } else {
        cb()
      }
    }
    return {
      month: "",
      defaultDate: "",
      alarmLevelList:[
        {name:'全部等级',id:''},
        {name:'1级',id:'1'},
        {name:'2级',id:'2'},
        {name:'3级',id:'3'},
        {name:'4级',id:'4'},
        // {name:'5级',id:'5'},
      ],
      alarmLevel:'',
      checked: false,
      selectedInfo: {},
      selectedDay: '',
      detailInfo: {},
      editModalVisible: false,
      form: {
				actionText: '',
				remark: ''
			},
			rules: {
				actionText: [
					{validator: checkAction, trigger: 'blur'}
				],
        remark: [
          {validator: checkRemark, trigger: 'blur'}
				]
      },
      vehicleId: this.$route.query.vehicleId ? this.$route.query.vehicleId : null,
      alarmId: this.$route.query.alarmId ? this.$route.query.alarmId : null,
      alarmTime: this.$route.query.alarmTime ? this.$route.query.alarmTime : null,
      calendarData: {}, // 警情日历数据
      alarmHandleResult: {}, // 警情处理结果数据
      detailForm: [],
      currIdx: 0
    };
  },
  created() {
    this.month = this.alarmTime ? this.alarmTime : new Date()
    // 获取警情研判详情数据
    this.init()
  },
  computed: {
    currItem() {
			return (this.calendarData.calendarList && this.calendarData.calendarList.filter(val => val.alarmTime && val.alarmTime.split(' ')[0] === this.selectedDay)) || []
		}
	},
  mounted() {},
  watch: {
    alarmLevel(newValue, oldValue) {
			this.filterChange()
		},
    checked(newValue, oldValue) {
			this.filterChange()
    },
    month(newValue, oldValue) {
      this.filterChange()
    }
  },
  methods: {
    filterChange() {
      let oParams = this.getParams()
      GET_ALARM_INFO_CALENDAR(oParams).then(res => {
        this.editModalVisible = false
        this.selectedDay = this.month
        this.defaultDate = this.month
        this.calendarData = res.data
        this.currItem.filter((val, index) => {
          if (val.id == this.alarmId) {
            this.currIdx = index
          }
        })
        if (!this.currItem.length) return
        this.getHandleResult()
      })
    },
    getParams() {
      let oParmas = {
        vehicleId: this.vehicleId,
        alarmLevel: this.alarmLevel ? parseInt(this.alarmLevel) : 0,
        year: parseInt(moment(this.month).format('YYYY')),
        month: parseInt(moment(this.month).format('MM')),
        dealStatus: this.checked ? 2 : 0
      }
      return oParmas
    },
    init() {
      GET_ALARM_INFO({ vehicleId: this.vehicleId }).then(res => {
        // 处理设备数据
        let [wiredSns, wirelessSns] = [[], []]
        res.data && res.data.deviceStatus && res.data.deviceStatus.map(val => {
          if (val.source === 1) {
            wiredSns.push(val)
          } else {
            wirelessSns.push(val)
          }
        })
        res.data.wiredSns = wiredSns
        res.data.wirelessSns = wirelessSns
        this.detailInfo = res.data
      })
    },
    // 切换风险等级
    alarmEvenet(row){
      this.alarmLevel = row.id;
    },
    // 是否有风险预警
    hasAlarm(data) {
      if (this.calendarData.calendarList && this.calendarData.calendarList.length > 0) {
        let flag
        let arr = this.calendarData.calendarList.filter(val => val.alarmTime && val.alarmTime.split(' ')[0] === data.day) || []
        if (arr.length > 0) {
          flag = true
          data.alarmLevel = arr[0].alarmLevel
          this.currItem.map(val => {
            arr.map(item => {
              if (val.id === item.id) {
                data.alarmLevel = this.currItem[this.currIdx].alarmLevel
              }
            })
          })
        }
        return flag;
      }
    },
    prev(){
			if(this.currIdx === 0) return;
      this.currIdx--;
      this.getHandleResult()
		},
		next(){
			if(this.currIdx === this.currItem.length-1) return;
      this.currIdx++;
      this.getHandleResult()
		},
    async dateClick(data) {
      this.currIdx = 0
      this.selectedDay = data.day
      this.editModalVisible = false
      let currentMonth = moment(this.month).month() + 1
      if (moment(data.day).month() + 1 !== currentMonth) {
        this.month = data.day
      }
      // 获取最新的警情处理结果
      if (!this.currItem.length) return
      this.getHandleResult()
    },
    getHandleResult() {
      GET_LAST_ALARM_RESULT({ alarmId: this.currItem[this.currIdx].id }).then(res => {
        this.editModalVisible = false
        this.alarmHandleResult = res.data || {}
      })
    },
    // 修改/处理
    editResolve() {
      this.form.actionText = this.alarmHandleResult.resolvent || '';
			this.form.remark = this.alarmHandleResult.remark || '';
      this.editModalVisible = true
    },
    // 文本域不可回车换行
    textareaKeydown() {
      let e = window.event || arguments[0];
      if (e.key == 'Enter' || e.code == 'Enter' || e.keyCode == 13) {
        e.returnValue = false;
        return false;
      }
    },
    // operation(status, num) {
    //   if (status === 2) {
    //     this.$confirm(`<div><p>是否忽略"${this.detail.sqbh}/${this.detail.name}/${this.detail.deviceNoes}<br/>${this.detail.standno}"?</p>
    //     <p style="color: #999;">忽略该车辆后,该车辆的历史警情继续保留,且不会产生新的综合预警。</p></div>`, '提示', {
    //       confirmButtonText: '确定',
    //       cancelButtonText: '取消',
    //       type: 'warning',
    //       dangerouslyUseHTMLString: true
    //     }).then(() => {
    //       this.dispatchEvent(status, num)
    //     })
    //   } else {
    //     this.dispatchEvent(status, num)
    //   }
    // },
    // dispatchEvent(status, num) {
    //   let message = []
    //   switch (status) {
    //     case 1:
    //       message = ['关注成功', '关注失败']
    //       break
    //     case 2:
    //       message = ['忽略成功', '忽略失败']
    //       break
    //     case 0: 
    //       if (num === 1) {
    //         message = ['取消关注成功', '取消关注失败']
    //       } else {
    //         message = ['取消忽略成功', '取消忽略失败']
    //       }
    //       break
    //   }
    //   ALARM_INFO_EDIT_STATUS({
    //     vehicleId: this.vehicleId,
    //     status: status
    //   }).then((result)=>{
    //     if(result.returnCode == 0){
    //       this.$message({
    //       type: 'success',
    //       message: message[0]
    //     });
    //     this.toggleAllItemStatus(1)
    //     }else{
    //       this.$message({
    //       type: 'error',
    //       message: message[1]
    //     });
    //     }
    //   });
    // },
    // toggleAllItemStatus(status){
		// 	this.calendarData.calendarList && this.calendarData.calendarList.forEach((item)=>{
		// 		item.isAttention = status;
		// 	});
		// 	this.detailInfo.isAttention = status;
		// },
    // 采取措施快捷输入
    addActionText(text) {
      this.form.actionText = this.form.actionText + text;
      this.$nextTick(() => {
				this.$refs.actionRefs.focus()
			})
    },
    // 确认修改
    editSure() {
      this.$refs.form.validate((valid) => {
				if(valid){
					ALARM_INFO_EDIT({
						id: this.currItem[this.currIdx].id,
						remark: this.form.remark,
						resolvent: this.form.actionText
					}).then((result)=>{
						if(result.code == 200){
              this.editModalVisible = false;
              // 获取最新的处理记录
              GET_LAST_ALARM_RESULT({ alarmId: this.currItem[this.currIdx].id }).then(res => {
                this.$nextTick(() => {
                  this.alarmHandleResult = res.data
                })
              })
						}
					})
        }
      })
    },
    // 取消修改
    cancelEdit() {
      this.editModalVisible = false
      this.$refs.form.resetFields();
    },
    // 跳转通用防拆报警(断电报警数据)
    goTamper() {
      let o = this.detailInfo;
      let wiredSn  = o.wiredSns && o.wiredSns[0] && o.wiredSns[0].sn // 第一个有线设备类型的 设备号
      let path = `#/alarmCenter/tamper?sn=${wiredSn}&alarmType=1`;
      // window.open(path)
      var newwindow =  window.open('_blank'); 
      newwindow.location = path;
    },
    // 监控车辆
    goMonitor() {
      let o = this.detailInfo;
      let path = `/oEshield#/monitor/monitor?vin=${o.vin}`;
      // window.open(`${path}?vin=${o.vin}`);
      var newwindow =  window.open('_blank'); 
      newwindow.location = path;
    },
    // 跳转通用里程详情
    goMileageGeneralDetail() {
      let o = this.detailInfo;
      let wiredSn  = o.wiredSns && o.wiredSns[0] && o.wiredSns[0].sn
      let path = `/trialRun#/reportManage/mileageGeneralDetail?sn=${wiredSn}`
      // window.open(path)
      var newwindow =  window.open('_blank'); 
      newwindow.location = path;
    }
  },
};
</script>
<style lang="scss">
.el_calendar {
  width: 70%;
  .el-calendar__header {
    display: none !important;
  }
  .el-calendar__body {
    padding: 0;
    thead {
      th {
        border-top: 1px solid #ebeef5;
        border-left: 1px solid #ebeef5;
        font-weight: bold;
      }
      th:last-child {
        border-right: 1px solid #ebeef5;
      }
    }
    .el-calendar-day{
      height: 60px;
    }
  }
}
.el-tag.el-tag--info{
  cursor: pointer;
}
</style>
<style lang="scss" scoped>
@import "@/styles/alarmDetail.scss";
</style>