<template>
  <el-dialog
    :visible.sync="equipmentdialog"
    :before-close="handleClose"
    :close-on-click-modal="true"
    :close-on-press-escape="false"
    append-to-body
    width="70%"
  >
    <div>
      <el-row>
        <el-col :span="12" class="table_col" v-if="equipmentdialog">
          <div class="title">工艺参数</div>

          <ele-pro-table
            ref="equiTable"
            :columns="columns"
            :datasource="datasource"
            :current.sync="current"
            highlight-current-row
            row-key="id"
            height="50vh"
          >
          <template v-slot:textType="{ row }">
          {{ row.textType == 1 ? '数值' : row.textType == 2 ? '选择' : row.textType == 3 ? '产品参数' : row.textType == 4 ? '规格' :
             row.textType == 5 ? '时间' : '' }}
        </template>

          </ele-pro-table>
        </el-col>
        <el-col :span="12" class="table_col" v-if="equipmentdialog">
          <div class="title">质检项</div>

          <ele-pro-table
            ref="equiTable"
            :columns="columns1"
            :datasource="datasource1"
            :current.sync="current1"
            highlight-current-row
            row-key="id"
            height="50vh"
          >
          </ele-pro-table>
        </el-col>
      </el-row>
    </div>
    <div class="btns">
      <el-button type="primary" size="small" @click="selected">选择</el-button>
      <el-button size="small" @click="handleClose">关闭</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { parameterList } from '@/api/inspectionStandard';
import { getList } from '@/api/inspectionProject';

export default {
  components: {},
  props: {
    selectList: Array,
    type: {
      default: 1 //1多选 2单选
    }
  },
  data() {
    return {
      equipmentdialog: false,
      current: null,
      current1: null,
      columns: [
        {
          prop: 'code',
          label: '参数编码',
          // sortable: 'custom',
          showOverflowTooltip: true,
          align: 'center',
          minWidth: 110
        },
        {
          prop: 'name',
          label: '参数名称',
          showOverflowTooltip: true,
          align: 'center',
          minWidth: 110
        },

        {
          prop: 'textType',
          label: '参数类型',
          showOverflowTooltip: true,
          align: 'center',
          slot: 'textType',
          minWidth: 110
        },
        {
          align: 'center',
          prop: 'description',
          label: '文本描述',
          showOverflowTooltip: true,
          minWidth: 110
        },
        {
          prop: 'maxValue',
          label: '参数上限',
          align: 'center',
          showOverflowTooltip: true
        },
        {
          prop: 'minValue',
          label: '参数下限',
          align: 'center',
          showOverflowTooltip: true
        },
        {
          prop: 'defaultValue',
          label: '默认值',
          align: 'center',
          showOverflowTooltip: true
        },
        {
          prop: 'categoryType',
          label: '参数分类',
          align: 'center',
          slot: 'status',
          showOverflowTooltip: true
        }
      ],
      columns1: [
        {
          prop: 'inspectionCode',
          label: '编码'
        },
        {
          label: '质检项名称',
          prop: 'inspectionName'
        },

        // {
        //   label: '是否生成过程',
        //   prop: 'isCreateCourse',
        //   formatter: (row, column, cellValue) => {
        //     return cellValue == 1 ? '是' : cellValue === 0 ? '否' : '';
        //   }
        // },
        {
          label: '质检标准',
          prop: 'inspectionStandard',
          formatter: (row, column, cellValue) => {
            return row.symbol+' '+cellValue+' '+row.unit
          }
        },

        // {
        //   label: '质检工具',
        //   prop: 'inspectionTool'
        // },
        {
          label: '状态',
          prop: 'status',
          formatter: (row, column, cellValue) => {
            return cellValue == 1 ? '启用' : cellValue === 0 ? '停用' : '';
          }
        },
        {
          label: '描述',
          prop: 'description'
        },

        {
          label: '备注',
          prop: 'inspectionRemark'
        }
      ],
      categoryLevelId: null,
      code: null,
      selection: [],
      ids: []
    };
  },

  watch: {},
  methods: {
    datasource({ page, where, limit }) {
      return parameterList({
        ...where,
        pageNum: page,
        size: limit
      });
    },
    datasource1({ page, where, limit }) {
      return getList({
        ...where,
        pageNum: page,
        size: limit
      });
    },
    open() {
      this.equipmentdialog = true;
    },

    handleClose() {
      this.equipmentdialog = false;
    },
    // 选择
    selected() {
      this.$emit('choose', {
        parameter: JSON.parse(JSON.stringify(this.current)),
        project: JSON.parse(JSON.stringify(this.current1))
      });
      this.handleClose();
    }
  }
};
</script>

<style lang="scss" scoped>
.title {
  font-size: 16px;
  margin-bottom: 20px;
}
.btns {
  text-align: center;
  padding: 10px 0;
}
</style>
