<template>
  <el-dialog
    title="检验详情"
    :visible.sync="visible"
    width="1200px"
    append-to-body
    @open="dialogOpen"
  >
    <!-- 列表 -->
    <el-table v-loading="loading" :data="list" border>
      <el-table-column
        label="检验单号"
        width="170"
        align="center"
        prop="inspectionNo"
      />
      <el-table-column label="检验项名称" align="center" prop="inspectionName" />
      <el-table-column label="标准值" align="center" prop="standValue" />
      <el-table-column label="单项检验结果" align="center" prop="singleResult">
        <template slot-scope="scope">
          <dict-tag :type="DICT_TYPE.MES_QUALITY_IPQC_SINGLE_RESULT" :value="scope.row.singleResult" />
        </template>
      </el-table-column>
      <el-table-column label="不良项(不良代码)" align="center" prop="badId" />
      <!-- <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
        width="180"
      >
        <template slot-scope="scope">
          <el-button
            v-hasPermi="['wms:material-item-actual:query']"
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleEditTestItem(scope.row)"
          >实测</el-button>
          <el-button

            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
          >编辑检验结果</el-button>
        </template>
      </el-table-column> -->
    </el-table>
    <span slot="footer">
      <el-button @click="visible = false">取消</el-button>
      <!-- <el-button type="primary" :loading="submitLoading" @click="handleTesting">检验完成</el-button> -->
    </span>
    <!-- 实测 -->
    <MeasuredDialog ref="measuredDialog" />
    <!-- 检验结果 -->
    <EditInspectItem ref="editInspectItem" @complete="getList" />

  </el-dialog>
</template>

<script>
// import { finishMaterialItem } from '@/api/wms/quality/inspectionCase'
import { getViewFqcPage } from '@/api/wms/quality/tempInspectionExecute'
import MeasuredDialog from '../../iqcInspection/components/MeasuredDialog.vue'
import EditInspectItem from '../../iqcInspection/components/EditInspectItem.vue'

export default {
  components: {
    MeasuredDialog,
    EditInspectItem
  },
  data() {
    return {
      visible: false,
      finishOpen: false,
      open: false,
      loading: false,
      submitLoading: false,
      // 总条数
      // total: 0,
      // 品质检验执行主列表
      list: [],
      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 10,
        inspectionRegisterId: null,
        inspectionNo: null,
        inspectionResult: null,
        badNo: null,
        createTime: [],
        warehousingOrderNo: null,
        materialLots: null
      },
      form: {
        manage: null
      },
      rules: {
      }
    }
  },
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true
      // 执行查询
      getViewFqcPage(this.queryParams).then(response => {
        this.list = response.data.list
      }).finally(() => {
        this.loading = false
      })
    },
    /** 取消按钮 */
    cancel() {
      this.open = false
    },
    reset() {
      this.form = {
        manage: undefined
      }
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNo = 1
      this.getList()
    },
    dialogOpen() {
      this.$nextTick(() => {
        this.handleQuery()
      })
    },
    // 填入实测值
    handleEditTestItem(row) {
      const { id } = row
      this.$refs.measuredDialog.form = row
      this.$refs.measuredDialog.queryParams.materialItemResultId = id
      this.$refs.measuredDialog.visible = true
    },
    handleUpdate(row) {
      const { id } = row
      this.$refs.editInspectItem.visible = true
      this.$refs.editInspectItem.form.id = id
    }
  }
}
</script>
