removeAlarm.vue 4.69 KB
<template>
  <div class="system-container">
    <div class="container">
      <search-form
        class="searchTop border-shadow removeAlarm"
        :formModel="searchForm"
        :formList="todoFormList"
      >
        <span
          class="inline-b"
          slot="form-slot"
        >
          <el-button
            type="primary"
            :size="btn_size"
            icon="el-icon-search"
            :id="removeAlarmTableParams.btnId"
          >搜索</el-button>
          <el-button
            type="primary"
            :size="btn_size"
            icon="el-icon-refresh"
            @click="refresh"
          >重置</el-button>
        </span>
      </search-form>
      <h3>拆除预警信息
        <div class="pull-right">
          <template>
            <el-button
              v-for="item in authList"
              :key="item.id"
              :type="item.type"
              :size="btn_size"
              @click="btnClick(item.pType)"
            >{{item.name}}</el-button>
          </template>
        </div>
      </h3>
      <basic-table
        class="basic-table"
        ref="removeAlarmForm"
        :tableParams="removeAlarmTableParams"
        :getListApi="getListApi"
        :beforeSearchFn="beforeSearchFn"
        :searchForm="searchDataForm"
        :hasNum="false"
      >
      </basic-table>
    </div>
  </div>
</template>

<script>
import { TEARDOWN_API } from '@/config/config'
import store from '@/store'
import { getList } from 'services/alarmCenter'
export default {
  data() {
    return {
      searchForm: {},
      searchDataForm: {},
      todoFormList: [
        {
          type: 'input',
          inputType: 'text',
          prop: 'keywords',
          placeholder: '特约店编码|店名称 | 设备号 | 车型',
        },
        {
          type: 'daterange',
          prop: 'daterange',
          startPlaceholder: '报警开始时间',
          endPlaceholder: '报警结束时间'
          // pickerOptions: {
          //   disabledDate(time) {
          //     return time.getTime() > Date.now() || time.getTime() < new Date('2017-12-31').getTime()
          //   }
          // }
        }
      ],
      removeAlarmTableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: 'list',
        tableColumns: [
          {
            label: '所属大区',
            prop: 'area'
          }, {
            label: '所属省',
            prop: 'province'
          }, {
            label: '所属市',
            prop: 'city'
          }, {
            label: '特约店名称',
            prop: 'shopName'
          }, {
            label: '特约店编码',
            prop: 'shopCode'
          }, {
            label: '店级别',
            prop: 'shopLevel'
          }, {
            label: '车型',
            prop: 'modelName'
          }, {
            label: '配置',
            prop: 'configDesc'
          }, {
            label: '车架号',
            prop: 'vin',
            width: 150
          }, {
            label: '设备号',
            prop: 'sn',
            width: 100
          }, {
            label: '报警时间',
            prop: 'alarmTime',
            width: 160
          }, {
            label: '拆除报警类型',
            prop: 'alarmType',
            width: 100,
            formatter: (cellValue) => {
              return {
                1: '断电报警',
                99: '光感报警'
              }[cellValue.alarmType]
            }
          }, {
            label: '报警次数',
            prop: 'alarmCount'
          },
        ]
      },
      getListApi: getList,
      authList: [
        {
          id: 1,
          name: '导出Excel',
          type: 'primary',
          pType: 'export'
        }
      ],
    }
  },
  methods: {
    refresh() {
      this.searchForm = {}
      this.searchDataForm = {}
      this.$refs.removeAlarmForm.refreshTable()
    },
    beforeSearchFn() {
      return new Promise((resolve, reject) => {
        if (this.searchForm.daterange) {
          this.searchDataForm.startTime = this.searchForm.daterange[0]
          this.searchDataForm.endTime = this.searchForm.daterange[1]
        } else {
          this.searchDataForm.startTime = ''
          this.searchDataForm.endTime = ''
        }/*  */
        this.searchDataForm.keywords = this.searchForm.keywords
        resolve()
      })
    },
    btnClick(pType, scope) {
      switch (pType) {
        case 'export':
          this.$Common.exportExcel({
            url: `${store.state.baseURL}${TEARDOWN_API.TEAR_EXPORT}`,
            method: 'GET',
            data: this.searchDataForm,
            fileName: '导出拆除预警Excel'
          })
          break
      }
    },
  },
}
</script>