<template>
  <div id="print">
    <el-form ref="elForm" :model="formData" size="medium" label-width="70px">
      <el-row :gutter="12">
     
        <el-col>
            <el-table id="evl"
                      ref="multipleTable"
                      :data="eltList"
                      style="width: 100%;margin-top:10px;"
                      border
                      fit
                      highlight-current-row
                      max-height="600">
              <el-table-column align="center" label="项目内容" width="750">
                <template slot-scope="scope">
                  <span v-if="scope.row.item">{{ scope.row.item.content }}</span>
                  <span v-else>{{ scope.row.content }}</span>
                </template>
              </el-table-column>

              <el-table-column label="符合">
                <template slot-scope="scope">
                  <!-- @change="changeHandler(scope.$index,radio[scope.$index])" -->
                  <el-radio-group v-model="radio[scope.$index]" @change="changeHandler(scope.$index,radio[scope.$index])">
    <el-radio :label="item" :key="item" v-for="item in review_options ">{{item}}</el-radio>
  </el-radio-group>
                </template>

              </el-table-column>

            </el-table>
        </el-col>

      </el-row>
    </el-form>
    <div slot="footer" align="center" style="margin-top:6px">
      <el-button type="primary" @click="handelConfirm">保存</el-button>
    </div>
   
  </div>
</template>
<script type="text/javascript">
  import { createEvaluationDetail, updateEvaluationDetail, getEvaluationDetailList } from "@/api/evaluationdetail";
  import { getEvaluationsList } from "@/api/evaluationitem";
  import { reviewCertapp } from "@/api/certapp"
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import { options } from "runjs";
export default {
 
  inheritAttrs: false,
  components: {  Treeselect },
  props: ["action", "certapp"],
  data() {
      return {
        
        formData: {
        field_code: 'QMS',
        result:null,
        is_approve: true,
        remark:null,
       cert_app:this.certapp
       
        
        },
        radio: [],
       review_options:[
'符合', '不符合', '不适用', '需说明'
 ],

        eltList: [],
        
         dgType: 0,
        dgVisiable: false,
       
      };
    },
   computed: {},
  watch: {

  },
    created() {
    
   this.getList()
  },
  mounted() {},
    methods: {
      getList() {
      
      getEvaluationsList().then(response => {
       
        this.eltList = response.data.results
        for (var i = 0; i < this.eltList.length; i++) {
          // this.eltList[i].options = this.review_options;
          // this.eltList[i].result = '符合'
        }
        
      });
      },
      // 获取表格选中时的数据
      selectRow (val) {
        this.selectlistRow = val
      },
      changeHandler(val1, val2) {
        console.log(val1,val2)
        this.eltList[val1].result = val2
        console.log(this.eltList)
    },
      handelConfirm() {
        console.log(this.eltList)
        let rlist = []
        for (var i = 0; i < this.eltList.length; i++) {
          rlist.push({id:this.eltList[i].id,result:this.eltList[i].result}) 
        }
        reviewCertapp({certapps:[this.certapp], rlist:rlist}).then(res=>{
          this.$message.success('成功')
        })
  // let val = this.selectlistRow
  // console.log(this.selectlistRow);
    },
    
    


    }
};
</script>
<style>
</style>
