CarStatusList.vue 19.6 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 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582
<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div v-if="selectedRowKeys.length > 0" class="table-operator">
      <a-button @click="operate(1)" type="primary" icon="">上线</a-button>

      <a-button @click="operate(2)" type="primary" icon="">下线</a-button>

      <a-button @click="operate(3)" type="primary" icon="">启动</a-button>

      <a-button @click="operate(4)" type="primary" icon="">停止</a-button>

      <a-button @click="operate(5)" type="primary" icon="">跳步</a-button>

      <a-input id="command" placeholder="请输入测试命令名称" style="width: 10%; margin-left: 20px" />
      <a-input id="value" placeholder="请输入测试命令参数" style="width: 20%; margin-left: 20px" />
      <a-button @click="operate(6)" type="primary" icon="" style=" margin-left: 20px">发送测试命令</a-button>
    </div>

    <!-- table区域-begin -->
    <div>


      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="number"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">

      </a-table>
    </div>

    <car-status-modal ref="modalForm" @ok="modalFormOk"></car-status-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import CarStatusModal from './modules/CarStatusModal'
  import {getAction, postAction, putAction} from "../../api/manage";
  import Switch from "ant-design-vue/lib/switch";
  import {filterDictText, initDictOptions} from "../../components/dict/JDictSelectUtil";

  export default {
    name: 'CarStatusList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      CarStatusModal
    },
    data () {
      return {
        description: 'agv状态存储(设备关机后记录状态)管理页面',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'在线状态',
            align:"center",
            dataIndex: 'isOnline',
            customRender: (text, record, index) => {
              //todo 字典值替换通用方法
              return filterDictText(this.isOnlineDictOptions, text);
            }
          },
          {
            title:'任务状态',
            align:"center",
            dataIndex: 'taskFlag',
            customRender: (text, record, index) => {
              //todo 字典值替换通用方法
              return filterDictText(this.taskStatusDictOptions, text);
            }
          },
          {
            title:'当前步骤',
            align:"center",
            dataIndex: 'nowStep',
            customRender: (text, record, index) => {
              //todo 字典值替换通用方法
              return filterDictText(this.nowStepDictOptions, text);
            }
          },
          {
            title:'当前步骤值',
            align:"center",
            dataIndex: 'nowStepValue'
          },
          {
            title:'小车类型',
            align:"center",
            dataIndex: 'type'
          },
          {
            title:'小车编号',
            align:"center",
            dataIndex: 'number'
          },
          {
            title:'速度',
            align:"center",
            dataIndex: 'speed'
          },
          {
            title:'地标位置',
            align:"center",
            dataIndex: 'landmark'
          },
          {
            title:'X坐标',
            align:"center",
            dataIndex: 'coordX'
          },
          {
            title:'Y坐标',
            align:"center",
            dataIndex: 'coordY'
          },
          {
            title:'W角度',
            align:"center",
            dataIndex: 'angleW'
          },
          {
            title:'方向',
            align:"center",
            dataIndex: 'direction',
            customRender: (text, record, index) => {
              //todo 字典值替换通用方法
              return filterDictText(this.directionDictOptions, text);
            }
          },
          {
            title:'插销',
            align:"center",
            dataIndex: 'bolt'
          },
          {
            title:'充电',
            align:"center",
            dataIndex: 'charge',
            customRender: (text, record, index) => {
              //todo 字典值替换通用方法
              return filterDictText(this.chargeStatusDictOptions, text);
            }
          },
          {
            title:'雷达状态',
            align:"center",
            dataIndex: 'radarStatus',
            customRender: (text, record, index) => {
              //todo 字典值替换通用方法
              return filterDictText(this.radarStatusDictOptions, text);
            }
          },
          {
            title:'避让状态',
            align:"center",
            dataIndex: 'avoidStatus',
            customRender: (text, record, index) => {
              //todo 字典值替换通用方法
              return filterDictText(this.avoidStatusDictOptions, text);
            }
          },
          {
            title:'操作状态',
            align:"center",
            dataIndex: 'oprateStatus',
            customRender: (text, record, index) => {
              //todo 字典值替换通用方法
              return filterDictText(this.oprateStatusDictOptions, text);
            }
          },
          {
            title:'电池电量',
            align:"center",
            dataIndex: 'battery'
          },
          {
            title:'雷达区域',
            align:"center",
            dataIndex: 'radarArea'
          },
          {
            title:'线路号',
            align:"center",
            dataIndex: 'lineNum'
          },
          {
            title:'接收时间',
            align:"center",
            dataIndex: 'reciveTime'
          },
          {
            title:'socket连接状态',
            align:"center",
            dataIndex: 'isScoket'
          },
          {
            title:'超时状态',
            align:"center",
            dataIndex: 'isOverTime',
            customRender: (text, record, index) => {
              //todo 字典值替换通用方法
              return filterDictText(this.overTimeDictOptions, text);
            }
          },
          {
            title:'升降高度',
            align:"center",
            dataIndex: 'lifter'
          },
          {
            title:'处理时间',
            align:"center",
            dataIndex: 'handingTime'
          },
          {
            title:'完成时间',
            align:"center",
            dataIndex: 'finishTime'
          },
          {
            title:'异常处理标识',
            align:"center",
            dataIndex: 'expFlag'
          },
          {
            title:'运行状态',
            align:"center",
            dataIndex: 'travelStatus'
          },
          {
            title:'脱线异常',
            align:"center",
            dataIndex: 'derailAbnormal',
            customRender: (text, record, index) => {
              //todo 字典值替换通用方法
              return filterDictText(this.abnormalDictOptions, text);
            }
          },
          {
            title:'低电量异常',
            align:"center",
            dataIndex: 'batteryAbnormal',
            customRender: (text, record, index) => {
              //todo 字典值替换通用方法
              return filterDictText(this.abnormalDictOptions, text);
            }
          },
          {
            title:'急停异常',
            align:"center",
            dataIndex: 'emergencyStopAbnormal',
            customRender: (text, record, index) => {
              //todo 字典值替换通用方法
              return filterDictText(this.abnormalDictOptions, text);
            }
          },
          {
            title:'升降销异常',
            align:"center",
            dataIndex: 'lifterAbnormal',
            customRender: (text, record, index) => {
              //todo 字典值替换通用方法
              return filterDictText(this.abnormalDictOptions, text);
            }
          },
          {
            title:'保险杠异常',
            align:"center",
            dataIndex: 'bumperAbnormal',
            customRender: (text, record, index) => {
              //todo 字典值替换通用方法
              return filterDictText(this.abnormalDictOptions, text);
            }
          },
          {
            title:'充电异常',
            align:"center",
            dataIndex: 'chargeAbnormal',
            customRender: (text, record, index) => {
              //todo 字典值替换通用方法
              return filterDictText(this.abnormalDictOptions, text);
            }
          },
          {
            title:'触须异常',
            align:"center",
            dataIndex: 'antennaAbnormal',
            customRender: (text, record, index) => {
              //todo 字典值替换通用方法
              return filterDictText(this.abnormalDictOptions, text);
            }
          },
          {
            title:'转向锁定异常',
            align:"center",
            dataIndex: 'steeringLockAbnormal',
            customRender: (text, record, index) => {
              //todo 字典值替换通用方法
              return filterDictText(this.abnormalDictOptions, text);
            }
          },
          {
            title:'安全轮辋异常',
            align:"center",
            dataIndex: 'safetyrimAbnormal',
            customRender: (text, record, index) => {
              //todo 字典值替换通用方法
              return filterDictText(this.abnormalDictOptions, text);
            }
          },
          {
            title:'通讯异常',
            align:"center",
            dataIndex: 'reportAbnormal',
            customRender: (text, record, index) => {
              //todo 字典值替换通用方法
              return filterDictText(this.abnormalDictOptions, text);
            }
          },
          {
            title:'左驱动异常',
            align:"center",
            dataIndex: 'leftDriveAbnormal',
            customRender: (text, record, index) => {
              //todo 字典值替换通用方法
              return filterDictText(this.abnormalDictOptions, text);
            }
          },
          {
            title:'右驱动异常',
            align:"center",
            dataIndex: 'rightDriveAbnormal',
            customRender: (text, record, index) => {
              //todo 字典值替换通用方法
              return filterDictText(this.abnormalDictOptions, text);
            }
          }
        ],
        url: {
          list: "/carStatus/carStatus/list",
          delete: "/carStatus/carStatus/delete",
          deleteBatch: "/carStatus/carStatus/deleteBatch",
          exportXlsUrl: "/carStatus/carStatus/exportXls",
          importExcelUrl: "/carStatus/carStatus/importExcel",
          putUrl:"/carStatus/carStatus/operate",
          
        },
        dictOptions:{},
        superFieldList:[],
        // 定时器ID
        timer: null,
        // 定时器周期
        millisec: 1000,
        selectedRowKeys: [],

        nowStepDictOptions:[],
        taskStatusDictOptions:[],
        radarStatusDictOptions:[],
        avoidStatusDictOptions:[],
        chargeStatusDictOptions:[],
        isOnlineDictOptions:[],
        directionDictOptions:[],
        oprateStatusDictOptions:[],
        travelStatusDictOptions:[],
        overTimeDictOptions:[],
        abnormalDictOptions:[],
      }
    },
    created() {
    this.getSuperFieldList();
    },
    mounted() {
      this.openTimer()
      setTimeout(() => {
        this.loadData()
      }, this.millisec)
    },
    beforeDestroy() {
      if (this.timer) { //如果定时器还在运行 或者直接关闭,不用判断
        clearInterval(this.timer); //关闭
      }
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      handleClearSelection() {
        this.onSelectChange([], [])
      },
      onSelectChange(selectedRowKeys, selectionRows) {
        this.selectedRowKeys = selectedRowKeys
        this.selectionRows = selectionRows
      },
      operate(type){

        const numbers = this.selectedRowKeys.join(',');
        let operateString = "";
        let command = document.getElementById('command').value;
        let value = document.getElementById('value').value;
        debugger
        if(type === 1){
          operateString="上线";
        }else if(type === 2){
          operateString="下线";
        }else if(type === 3){
          operateString="远程启动";
        }else if(type === 4){
          operateString="远程停止";
        }else if(type === 5){
          operateString="强制跳步";
        }else if(type === 6){
          operateString="发送测试指令到";
        }
        this.$confirm({
          title: '远程控制',
          content: (<div>
            <p>您确定要{operateString}这 {this.selectedRowKeys.length} 台设备吗?</p>
            <p style="color:red;">注意:请谨慎操作!</p>
          </div>),
          centered: true,
          onOk: () => {
            var that = this;
            getAction(this.url.putUrl,{numbers:numbers, type:type ,command:command,value:value }).then((res) => {
              if (res.success) {
                this.$message.success(`操作成功!`)
              } else {
                that.$message.warning(res.message);
              }
            });
          },
        })
      },
      /** 开启定时器 */
      openTimer() {
        this.loadData()
        this.closeTimer()
        this.timer = setInterval(() => {
          this.loadData()
        }, this.millisec)
      },
      /** 关闭定时器 */
      closeTimer() {
        if (this.timer) clearInterval(this.timer)
      },

      initDictConfig(){
        initDictOptions('direction').then((res) => {
          if (res.success) {
            this.directionDictOptions = res.result;
          }
        });
        initDictOptions('oprate_status').then((res) => {
          if (res.success) {
            this.oprateStatusDictOptions = res.result;
          }
        });
        initDictOptions('travel_status').then((res) => {
          if (res.success) {
            this.travelStatusDictOptions = res.result;
          }
        });
        initDictOptions('error_status').then((res) => {
          if (res.success) {
            this.abnormalDictOptions = res.result;
          }
        });
        initDictOptions('over_time').then((res) => {
          if (res.success) {
            this.overTimeDictOptions = res.result;
          }
        });
        initDictOptions('radar_status').then((res) => {
          if (res.success) {
            this.radarStatusDictOptions = res.result;
          }
        });
        initDictOptions('avoid_status').then((res) => {
          if (res.success) {
            this.avoidStatusDictOptions = res.result;
          }
        });
        initDictOptions('charge_status').then((res) => {
          if (res.success) {
            this.chargeStatusDictOptions = res.result;
          }
        });
        initDictOptions('is_online').then((res) => {
          if (res.success) {
            this.isOnlineDictOptions = res.result;
          }
        });
        initDictOptions('task_status').then((res) => {
          if (res.success) {
            this.taskStatusDictOptions = res.result;
          }
        });
        initDictOptions('now_step').then((res) => {
          if (res.success) {
            this.nowStepDictOptions = res.result;
          }
        });
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'int',value:'type',text:'小车类型',dictCode:''})
        fieldList.push({type:'int',value:'number',text:'小车编号',dictCode:''})
        fieldList.push({type:'int',value:'speed',text:'速度',dictCode:''})
        fieldList.push({type:'int',value:'landmark',text:'地标位置',dictCode:''})
        fieldList.push({type:'double',value:'coordX',text:'X坐标',dictCode:''})
        fieldList.push({type:'double',value:'coordY',text:'Y坐标',dictCode:''})
        fieldList.push({type:'double',value:'angleW',text:'W角度',dictCode:''})
        fieldList.push({type:'int',value:'bolt',text:'插销',dictCode:''})
        fieldList.push({type:'int',value:'direction',text:'方向',dictCode:''})
        fieldList.push({type:'int',value:'charge',text:'充电',dictCode:''})
        fieldList.push({type:'int',value:'radarStatus',text:'雷达状态',dictCode:''})
        fieldList.push({type:'int',value:'avoidStatus',text:'避让状态',dictCode:''})
        fieldList.push({type:'int',value:'oprateStatus',text:'操作状态',dictCode:''})
        fieldList.push({type:'int',value:'battery',text:'电池电量',dictCode:''})
        fieldList.push({type:'int',value:'radarArea',text:'雷达区域',dictCode:''})
        fieldList.push({type:'int',value:'lineNum',text:'线路号',dictCode:''})
        fieldList.push({type:'datetime',value:'reciveTime',text:'接收时间'})
        fieldList.push({type:'int',value:'isScoket',text:'socket连接状态',dictCode:''})
        fieldList.push({type:'int',value:'isOnline',text:'在线状态',dictCode:''})
        fieldList.push({type:'int',value:'isOverTime',text:'超时状态',dictCode:''})
        fieldList.push({type:'int',value:'derailAbnormal',text:'脱线异常',dictCode:''})
        fieldList.push({type:'int',value:'batteryAbnormal',text:'低电量异常',dictCode:''})
        fieldList.push({type:'int',value:'emergencyStopAbnormal',text:'急停异常',dictCode:''})
        fieldList.push({type:'int',value:'lifterAbnormal',text:'升降销异常',dictCode:''})
        fieldList.push({type:'int',value:'bumperAbnormal',text:'保险杠异常',dictCode:''})
        fieldList.push({type:'int',value:'chargeAbnormal',text:'充电异常',dictCode:''})
        fieldList.push({type:'int',value:'antennaAbnormal',text:'触须异常',dictCode:''})
        fieldList.push({type:'int',value:'lifter',text:'升降销高度',dictCode:''})
        fieldList.push({type:'datetime',value:'handingTime',text:'处理时间'})
        fieldList.push({type:'datetime',value:'finishTime',text:'完成时间'})
        fieldList.push({type:'int',value:'expFlag',text:'异常处理标识',dictCode:''})
        fieldList.push({type:'int',value:'travelStatus',text:'运行状态',dictCode:''})
        fieldList.push({type:'int',value:'steeringLockAbnormal',text:'转向锁定异常',dictCode:''})
        fieldList.push({type:'int',value:'safetyrimAbnormal',text:'安全轮辋异常',dictCode:''})
        fieldList.push({type:'int',value:'reportAbnormal',text:'通讯异常',dictCode:''})
        fieldList.push({type:'int',value:'leftDriveAbnormal',text:'左驱动异常',dictCode:''})
        fieldList.push({type:'int',value:'rightDriveAbnormal',text:'右驱动异常',dictCode:''})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>