<template>
  <div class="ele-body">
    <el-card shadow="never">
      <!-- 搜索表单 -->
      <user-search @search="reload" />
      <!-- 数据表格 -->
      <ele-pro-table
        ref="table"
        :columns="columns"
        :datasource="datasource"
        :selection.sync="selection"
        row-key="code"
      >
        <!-- 表头工具栏 -->
       <template v-slot:toolbar>
          <el-button
            size="small"
            type="primary"
            icon="el-icon-refresh-left"
            class="ele-btn-icon"
            @click="toRefresh()"
          >
            刷新
          </el-button>
        </template>

        <!-- 状态列 -->
<!--        <template v-slot:status="{ row }">
          {{ checkStatus(row) }}
        </template> -->

        <!-- 操作列 -->
        <template v-slot:action="{ row }">
          <el-link
            type="primary"
            :underline="false"
            icon="el-icon-edit"
            @click="openEdit(row)"
          >
            查看
          </el-link>
        </template>
      </ele-pro-table>
    </el-card>

  </div>
</template>

<script>
  import UserSearch from './components/user-search.vue';
  import { pageList } from '@/api/technology/version/version.js';
  export default {
    name: 'technologyVersion',
    components: {
      UserSearch,
    },
    data() {
      return {
        // 表格列配置
        columns: [
          {
            prop: 'categoryCode',
            label: '产品编码',
            showOverflowTooltip: true,
            align: 'center',
            minWidth: 110
          },
          {
            prop: 'categoryName',
            label: '产品名称',
            showOverflowTooltip: true,
            align: 'center',
            minWidth: 110
          },
          {
            align: 'center',
            prop: 'code',
            label: '版本号',
            showOverflowTooltip: true,
            minWidth: 110
          },
          {
            prop: 'name',
            label: '版本名称',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 110
          },
          {
            prop: 'routingCode',
            label: '工艺路线编码',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 110
          },
          {
            prop: 'routingVersion',
            label: '工艺版本号',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 110
          },

          {
            columnKey: 'action',
            label: '操作',
            width: 220,
            align: 'center',
            resizable: false,
            slot: 'action',
            showOverflowTooltip: true
          }
        ],
        // 表格选中数据
        selection: [],
        // 当前编辑数据
        current: null,
        // 是否显示编辑弹窗
        showEdit: false,
        // 是否显示导入弹窗
        showImport: false,
        statusList: [
          { label: '草稿', value: -1 },
          { label: '失效', value: 0 },
          { label: '生效', value: 1 }
        ]
      };
    },
    methods: {
      /* 表格数据源 */
      datasource({ page, limit, where, order }) {
        return pageList({ pageNum: page, size: limit, ...where });
      },
      // async datasource({ page, limit, where, order }) {
      //   const res = await pageList({
      //     ...where,
      //     ...order,
      //     pageNum: page,
      //     size: limit
      //   });
      //   return res;
      // },
      /* 点击刷新 */
      toRefresh(){

      },
      /* 刷新表格 */
      reload(where) {
        this.$refs.table.reload({ page: 1, where: where });
      },
      /* 查看详情 */
      openEdit({id}) {
        this.$router.push({
          path: '/technology/version/details',
          query: {id}
        })
      }
    }
  };
</script>
