<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <date-range-picker
          type="datetimerange"
          v-model="query.datatimevalue"
          class="date-item"
          style="width: 400px !important"
        />
        <rrOperation />
      </div>
      <crudOperation :permission="permission"> </crudOperation>
    </div>
    <el-dialog
      append-to-body
      :close-on-click-modal="false"
      :visible.sync="showMap"
      title="查看火灾报警现场"
      width="1000px"
    >
    </el-dialog>
    <!--表格渲染-->
    <el-table
      ref="table"
      v-loading="crud.loading"
      :data="crud.data"
      style="width: 100%"
      @selection-change="crud.selectionChangeHandler"
    >
      <el-table-column type="selection" width="55" />
      <el-table-column
        v-for="item in doorTableOptions"
        :key="item.prop"
        :label="item.label"
        :prop="item.prop"
        :width="item.width"
        :align="item.align"
        :fixed="item.fixed"
        :sortable="item.sortable"
      ></el-table-column>
      <!--   编辑与删除   -->
      <el-table-column
        v-if="checkPer(['admin', 'door:edit', 'door:del'])"
        label="操作"
        width="130px"
        align="center"
        fixed="right"
      >
        <template slot-scope="scope">
          <el-button size="mini" icon="el-icon-view" @click="showDetail(scope.row.id)"></el-button>
        </template>
      </el-table-column>
    </el-table>
    <!--分页组件-->
    <pagination />
  </div>
</template>

<script>
import permission from '@/directive/permission'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
// import { crudOperation, rrOperation, udOperation, pagination } from '@crud'
import crudComps from '@crud'
import DateRangePicker from '@/components/DateRangePicker'
import { doorTableOptions } from '../tableConfig'
import Dayjs from 'dayjs'

const defaultForm = {
  id: '',
  positionName: '',
  positionSort: 999,
  enabled: true,
}

export default {
  name: 'Door',
  directives: { permission },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  components: { ...crudComps, DateRangePicker },
  cruds() {
    return CRUD({
      title: '火灾报警',
      url: 'alarm/door/getList',
      listOrder: [],
      //crudMethod: { ...crudBeacon },
      optShow: {},
      query: {
        datatimevalue: [
          Dayjs().subtract(1, 'month').format('YYYY-MM-DD HH:mm:ss'),
          Dayjs().format('YYYY-MM-DD HH:mm:ss'),
        ],
      },
    })
  },
  data() {
    return {
      doorTableOptions,
      permission: {
        add: ['admin', 'door:add'],
        edit: ['admin', 'door:edit'],
        del: ['admin', 'door:del'],
      },
      showMap: false,
    }
  },
  methods: {
    showDetail() {
      this.showMap = true
    },
  },
}
</script>

<style></style>
