<!--
 * @Author: zwq
 * @Date: 2021-11-18 14:16:25
 * @LastEditors: zwq
 * @LastEditTime: 2023-04-10 15:43:27
 * @Description:
-->
<template>
  <el-dialog :visible.sync="hisVisible" append-to-body class="baseDialog">
    <template #title>
      <slot name="title">
        <div class="titleStyle">历史记录</div>
      </slot>
    </template>
    <el-table
      :data="dataList"
      :header-cell-style="{
        background: '#F2F4F9',
        color: '#606266',
      }"
      style="width: 100%;"
    >
      <el-table-column type="index" header-align="center" align="center" label="序号" width="50">
      </el-table-column>
      <el-table-column prop="code" align="center" label="编号"> </el-table-column>
      <el-table-column prop="name" align="center" label="名称"></el-table-column>
      <el-table-column prop="type" align="center" label="特性类型">
        <template slot-scope="scope">
          <span>{{ scope.row.type === 2 ? "计数" : "计量" }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="defectLevel" align="center" label="缺陷等级">
        <template slot-scope="scope">
          <span>{{
            scope.row.defectLevel === 1
              ? "致命缺陷"
              : scope.row.defectLevel === 2
              ? "严重缺陷"
              : "轻微缺陷"
          }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="measureToolName" align="center" label="量具"></el-table-column>
      <el-table-column prop="isSpc" align="center" label="SPC">
        <template slot-scope="scope">
          <span>{{ scope.row.isSpc === 1 ? "是" : "否" }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="controlGraphName" align="center" label="分析图形"></el-table-column>
      <el-table-column prop="sampleSize" align="center" label="样本大小"></el-table-column>
      <el-table-column prop="samplingFrequency" align="center" label="抽样频率"></el-table-column>
      <el-table-column prop="unitName" align="center" label="单位"></el-table-column>
      <el-table-column prop="decimalPlaces" align="center" label="小数位数"></el-table-column>
      <el-table-column prop="specifications" align="center" label="规格"></el-table-column>
      <el-table-column prop="lsl" align="center" label="LSL"></el-table-column>
      <el-table-column prop="sl" align="center" label="SL"></el-table-column>
      <el-table-column prop="usl" align="center" label="USL"></el-table-column>
      <el-table-column prop="targetCpk" align="center" label="目标CPK"></el-table-column>
      <el-table-column prop="targetPpk" align="center" label="目标PPK"></el-table-column>
      <el-table-column prop="remark" align="center" label="备注"></el-table-column>
    </el-table>
    <span slot="footer" class="dialog-footer">
      <el-button @click="hisVisible = false">关闭</el-button>
    </span>
  </el-dialog>
</template>

<script>
export default {
  data() {
    return {
      hisVisible: false,
      dataList: [],
    };
  },
  created() {},
  methods: {
    init(id) {
      this.hisVisible = true;
      this.$nextTick(() => {
        this.$http
          .get("/basic/productFeaturesHis/page", {
            params: {
              id: id,
              page: 1,
              limit: 100,
            },
          })
          .then(({ data: res }) => {
            if (res.code !== 0) {
              this.dataList = [];
              return this.$message.error(res.msg);
            }
            this.dataList = res.data.list;
          })
          .catch(() => {});
      });
    },
  },
};
</script>

<style>
.baseDialog .el-dialog__header {
  font-size: 16px;
  color: rgba(0, 0, 0, 0.85);
  font-weight: 500;
  padding: 13px 24px;
  border-bottom: 1px solid #e9e9e9;
}
.baseDialog .el-dialog__header .titleStyle::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 16px;
  background-color: #0b58ff;
  border-radius: 1px;
  margin-right: 8px;
  position: relative;
  top: 2px;
}
.baseDialog .el-dialog__body {
  padding-left: 24px;
  padding-right: 24px;
}
.baseDialog .el-table .el-table__cell {
  padding: 0;
  height: 35px;
}
</style>
