<template>
  <div>
    <el-dialog  :title="title" :visible.sync="showDialog" width="1000px" :close-on-click-modal="false"  :before-close="handleClose" append-to-body>
        <div style="margin-bottom:10px" v-if="radio != 3">
            <el-radio-group v-model="radio" @input="change">
                <el-radio label="4">第一次法院意见</el-radio>
                <el-radio label="6">第二次法院意见</el-radio>
            </el-radio-group>
        </div>
        <div style="height:calc(100vh - 350px)" v-DivHeight="getDivHeight">
            <el-table v-loading="loading" :data="tableData" :maxHeight="tableHeight - 50" border :header-cell-style="{'text-align':'center'}" style="width: 100%">
                <el-table-column prop="sysOrder"  label="序号" width="100" align="center">
                    <template slot-scope="scope">
                        <div>
                            权要{{ scope.row.sysOrder+1 }}
                        </div>
                    </template>
                </el-table-column>
                <el-table-column prop="content" label="原权要内容" > 
                    <template slot-scope="scope">
                        <div>
                            <span>{{ scope.row.content }}</span> 
                        </div>
                    </template>
                </el-table-column>
                <el-table-column prop="content" label="第一次修改说明" > 
                    <template slot-scope="scope">
                        <div>
                            <span>{{ scope.row.content }}</span> 
                        </div>
                    </template>
                </el-table-column>
                <el-table-column prop="content" label="第二次修改说明" > 
                    <template slot-scope="scope">
                        <div>
                            <span>{{ scope.row.content }}</span> 
                        </div>
                    </template>
                </el-table-column>
                <el-table-column prop="content" :label="column.label" > 
                    <template slot-scope="scope">
                        <div>
                            <span>
                                <el-select v-model="scope.row[column.value]"  placeholder="请选择">
                                    <el-option label="维持有效"  value="维持有效"></el-option>
                                    <el-option label="部分有效"  value="部分有效"></el-option>
                                    <el-option label="无效"  value="无效"></el-option>
                                </el-select>
                            </span> 
                        </div>
                    </template>
                </el-table-column>
            </el-table>
        </div>
        <span slot="footer" class="dialog-footer">
          <el-button @click="handleClose">取 消</el-button>
          <el-button type="primary" :loading="btnLoading" @click="submit" >确 定</el-button>
        </span>
    </el-dialog>
  </div>
</template>

<script>
import { getTableHeight } from '@/views/components/mixins'
export default {
  components: {},
  mixins:[getTableHeight],
  props: {
    projectId:{
        default:0
    }
  },
  data() {
    return {
        title:'添加复审委决定',
        showDialog:false,
        loading:false,
        btnLoading:false,
        tableData:[],
        column:{},
        radio:'4'
    };
  },
  watch: {},
  computed: {},
  created() {},
  mounted() {
    // this.getClaims()
  },
  methods: {
    // getClaims(){
    //     var params = {
    //         projectId:this.projectId
    //     }
    //     this.loading = true
    //     this.$api.queryClaim(params).then(response=>{
    //         if(response.code == 200){
    //             this.tableData = response.data.data
    //             this.loading = false
    //         }
    //     }).catch(error=>{
    //         this.tableData = []
    //         this.loading = false
    //     })
    // },
    change(val){
        if(val == '4'){
            this.column.label='一审法院决定'
            this.column.value = 'courtDecision1'
        }else{
            this.column.label='二审法院决定'
            this.column.value = 'courtDecision2'
        }
    },
    open(type,claims){
        this.radio = type
        this.tableData = claims
        var types = {
            3:{
                value:'rbDecision',
                label:'复审委决定'
            },
            4:{
                value:'courtDecision1',
                label:'一审法院决定'
            }
        }
        this.column = types[type]
        this.showDialog = true
    },
    handleClose(){
        this.showDialog = false
    },
    submit(){
        var params = this.tableData.map(item=>{
            return {
                claimId:item.id,
                domainFieldDTOs:[
                    {
                        field:this.column.value ,
                        value:item[this.column.value]
                    }
                ]
            }
        })
        this.btnLoading = true
        this.$api.updatePatentClaimMessage(params).then(response=>{
            if(response.code == 200){
                this.$emit('save',true)
                this.handleClose()
                this.btnLoading = false
            }
        }).catch(error=>{
            this.btnLoading = false
        })
    }
  },
};
</script>
<style lang="scss" scoped>
</style>