<template>
  <!-- <equipment-search
        @search="reload"
        :networkCounts="networkCounts"
        ref="search"
      /> -->
  <!-- 数据表格 -->
  <el-dialog
    :close-on-click-modal="false"
    title="选择模板"
    :visible.sync="visibleSync"
    width="40vw"
    append-to-body
  >
    <ele-pro-table
      ref="table"
      :columns="columns"
      :datasource="datasource"
      height="calc(100vh - 400px)"
      highlight-current-row
      :current.sync="current"
      tool-class="ele-toolbar-form"
    >
      <template v-slot:disposalType="{ row }">
        {{ getDictValue('设备处置方式', row.type + '') }}
      </template>
      <!-- 操作列 -->
      <template v-slot:action="{ row }">
        <el-popconfirm
          class="ele-action"
          title="确定要删除吗？"
          @confirm="remove(row)"
        >
          <template v-slot:reference>
            <el-link type="danger" :underline="false" icon="el-icon-delete">
              删除
            </el-link>
          </template>
        </el-popconfirm>
      </template>
    </ele-pro-table>
    <footer slot="footer">
      <el-button @click="visibleSync = false">取消</el-button>
      <el-button @click="submit" type="primary">确认</el-button>
    </footer>
  </el-dialog>
</template>

<script>
import { templateList, removeTemplate } from '@/api/equipmentDisposal/index.js';

import dictMixins from '@/mixins/dictMixins';
// import equipmentSearch from './components/search.vue';

export default {
  mixins: [dictMixins],
  components: {
    // equipmentSearch,
  },

  data() {
    return {
      visibleSync: false,
      loading: false,
      current: null,
      // 表格列配置
      columns: [
        {
          columnKey: 'index',
          type: 'index',
          label: '序号',
          width: 55,
          align: 'center',
          showOverflowTooltip: true,
          fixed: 'left'
        },
        {
          prop: 'disposalType',
          slot: 'disposalType',
          align: 'center',
          label: '处置方式',
          showOverflowTooltip: true
        },

        {
          align: 'center',
          prop: 'name',
          label: '名称',
          showOverflowTooltip: true
        },

        {
          prop: 'createUserName',
          align: 'center',
          label: '创建人'
        },
        {
          prop: 'createTime',
          align: 'center',
          label: '创建时间'
        }
,
        {
          columnKey: 'action',
          slot: 'action',
          align: 'center',
          label: '操作',
          width: 150,
          fixed: 'right'
        }
      ]
    };
  },
  computed: {},
  created() {
    this.requestDict('设备处置方式');
  },
  methods: {
    /* 表格数据源 */
    datasource({ page, limit, where }) {
      // this.getNetWork(page, limit, where, order);
      return templateList({
        ...where,
        pageNum: page,
        size: limit
      });
    },

    /* 刷新表格 */
    reload(where) {
      this.$refs.table.reload({ pageNum: 1, where: where });
    },
    open() {
      this.visibleSync = true;
    },
    submit() {
      this.$emit('success', this.current);
      this.visibleSync = false;
    },
    remove(row) {
      removeTemplate([row.id]).then((res) => {
        this.$message.success('删除成功！');
        this.reload();
      });
    }
  }
};
</script>
<style lang="scss" scoped>
@media print {
  #printSection {
    font-size: 34px;
    span {
      font-size: 34px;
    }
  }
}
</style>
