<template>
  <div>
    <el-dialog
      :visible.sync="dialogVisible"
      width="1000px">
      <div>
        <el-tabs v-model="activeName" type="card">
          <el-tab-pane label="成分标准" name="elementStd">
            <el-table border :data="elemntData" height="300" highlight-current-row class="xg-ytg-line-hei">
              <el-table-column label="化学元素" prop="chem_name" min-width="120px"></el-table-column>
              <el-table-column label="标准范围" min-width="120px">
                <el-table-column label="符号" prop="stdmin_sign" min-width="120px"></el-table-column>
                <el-table-column label="下限" prop="stdmin" min-width="120px"></el-table-column>
                <el-table-column label="符号" prop="stdmax_sign" min-width="120px"></el-table-column>
                <el-table-column label="上限" prop="stdmax" min-width="120px"></el-table-column>
              </el-table-column>
            </el-table>
          </el-tab-pane>
          <el-tab-pane label="材质标准" name="materialStd">
            <el-table border :data="materialData" height="300" highlight-current-row class="xg-ytg-line-hei">
              <el-table-column label="检验大项" prop="phy_name_l" min-width="120px"></el-table-column>
              <el-table-column label="试样组" prop="phy_name_m" min-width="120px"></el-table-column>
              <el-table-column label="检验项" prop="phy_name_s" min-width="120px"></el-table-column>
              <el-table-column label="试验方向" prop="item_name_d" min-width="120px"></el-table-column>
              <el-table-column label="试验温度" align="right" prop="item_name_t" min-width="80px"></el-table-column>
              <el-table-column label="试样尺寸" prop="item_name_s" min-width="120px"></el-table-column>
              <el-table-column label="标准范围" min-width="120px">
                <el-table-column label="符号" align="center" prop="stdmin_sign" min-width="60px"></el-table-column>
                <el-table-column label="下限" align="right" prop="stdmin" min-width="60px"></el-table-column>
                <el-table-column label="符号" align="center" prop="stdmax_sign" min-width="60px"></el-table-column>
                <el-table-column label="上限" align="right" prop="stdmax" min-width="60px"></el-table-column>
              </el-table-column>
            </el-table>
          </el-tab-pane>
          <el-tab-pane label="公差标准" name="toleranceStd">
            <el-table border :data="toleranceData" height="300" highlight-current-row class="xg-ytg-line-hei">
              <el-table-column label="公差项" prop="bias_name" min-width="120px"></el-table-column>
              <el-table-column align="right" label="标准负值(mm)" prop="std_min_val" min-width="120px"></el-table-column>
              <el-table-column align="right" label="标准正值(mm)" prop="std_max_val" min-width="120px"></el-table-column>
              <el-table-column align="right" label="标准负值(%)" prop="std_min_percent" min-width="120px"></el-table-column>
              <el-table-column align="right" label="标准正值(%)" prop="std_max_percent" min-width="120px"></el-table-column>
            </el-table>
          </el-tab-pane>
          <el-tab-pane label="探伤标准" name="flawStd">
            <el-table border :data="flawData" height="300" highlight-current-row class="xg-ytg-line-hei">
              <el-table-column label="检验项" prop="phy_name_s" min-width="120px"></el-table-column>
              <el-table-column label="探伤位置" prop="position_desc" min-width="120px"></el-table-column>
              <el-table-column label="探伤级别" prop="lv_desc" min-width="120px"></el-table-column>
              <el-table-column align="right" label="探伤覆盖率(%)" prop="coverage" min-width="120px"></el-table-column>
              <el-table-column align="right" label="探伤频率" prop="desc_rate" min-width="120px"></el-table-column>
              <el-table-column align="right" label="最大壁厚" prop="max_h" min-width="120px"></el-table-column>
              <el-table-column align="right" label="最小壁厚" prop="min_h" min-width="120px"></el-table-column>
            </el-table>
          </el-tab-pane>
        </el-tabs>
      </div>
    </el-dialog>
  </div>
</template>
<script>
export default {
  props: ['showFlag', 'Params'],
  data () {
    return {
      activeName: 'elementStd',
      dialogVisible: false,
      elemntData: [],
      materialData: [],
      toleranceData: [],
      flawData: []
    }
  },
  methods: {
    getTableData (params) {
      this.axios.post('/CommonApiForWorkShopService/getStandardSample', [params.design_key, params.psc]).then(res => {
        if (res) {
          for (let item of res.data) {
            if (item.msgInfo === '成分要求') {
              this.elemntData = item.data
            }
            if (item.msgInfo === '材质要求') {
              this.materialData = item.data
            }
            if (item.msgInfo === '公差要求') {
              this.toleranceData = item.data
            }
            if (item.msgInfo === '探伤要求') {
              this.flawData = item.data
            }
          }
        }
      })
    }
  },
  watch: {
    showFlag () {
      this.dialogVisible = true;
      this.getTableData(this.Params)
    }
  }
}
</script>
