<template>
  <div class="eibs-tab">
    <c-col :span="12" class="col-left">
      <c-col :span="24">
        <c-col :span="12">
          <el-form-item label="发生日期" prop="eblmod.ebl.reldat">
            <c-date-picker :disabled="this.disflg == 'X'" type="date"  v-model="model.eblmod.ebl.reldat" style="width:100%"  placeholder="请选择授权日期"></c-date-picker>
          </el-form-item>
        </c-col>
        <c-col :span="12">
          <el-form-item  prop="cfabut.basflg">
	         <c-checkbox v-model="model.cfabut.basflg" true-label="X" false-label="" :disabled="this.calflg == 'X'||(model.recgrp.bas.actiontype =='D' && model.recgrp.bas.sta =='S')" @change="basflgChange">签约信息</c-checkbox>
          </el-form-item>
        </c-col>
      </c-col>
      <c-col :span="24">
        <el-form-item label="业务所属机构" prop="cfabut.ownextkey">
          <c-select :disabled="this.disflg == 'X'" v-model="model.cfabut.ownextkey" style="width:100%" placeholder="请输入业务所属机构" @change="getDecnum(model.cfabut.ownextkey)" >
            <el-option :key="item.inr" :label="item.branch + ' ' + item.bchname" :value="item.branch" v-for="item in ownExtkeyList">
            </el-option>
            </c-select>
        </el-form-item>
      </c-col>
      <c-col :span="24">
        <el-form-item v-if="transName == 'ecaall'">
					<c-checkbox v-model="model.cfabut.addnew" true-label="X" false-label="" disabled>新增接口数据</c-checkbox>
				</el-form-item>
      </c-col>
      <c-col :span="24" >
        <el-form-item label="变动信息数目" prop="cfabut.newdcl" v-if="transName == 'ecaall'">
          <c-input v-model="model.cfabut.newdcl" placeholder="请输入"></c-input>
        </el-form-item>
      </c-col>
    </c-col>
    <c-col :span="12" class="col-right">
      <c-col :span="12">
	      <c-checkbox v-model="model.cfabut.dclflg" true-label="X" false-label="" :disabled="this.calflg == 'X'">变动信息</c-checkbox>
      </c-col>
    </c-col>
  </div>
</template>
<script>
import CommonEvent from '../../common/event/CommonEvent'
import event from "~/page/Business/Cfa/Ecaadd/event";

export default {
    inject: ['root'],
    props:["model","codes","transName"],
    mixins: [event,CommonEvent],
    data(){
        return {
          ownExtkeyList: [],
          disflg: '',
          calflg: '',
        }
    },
    computed: {
    },
    methods:{
      calDisabled() {
        if(this.transName == 'ecadel' || this.transName == 'ecainf' || this.transName == 'ecaame' || this.transName == 'ecaall') {
          this.disflg = 'X';
        } else if(this.transName == 'ecaadd') {
          this.disflg = '';
        } else {
          this.disflg = 'X';
        }
      },

      calFlgDisabled() {
        if(this.transName == 'ecainf' || this.transName == 'ecaadd' || this.transName == 'ecaall') {
          this.calflg = 'X';
        } else if(this.transName == 'ecaame'||this.transName == 'ecadel') {
          this.calflg = '';
        } else {
          this.calflg = 'X';
        }
      },

      //勾选签约信息后 更新操作类型
     basflgChange(){
        if(this.model.cfabut.basflg == 'X'){
          //进行判断
          if(this.model.recgrp.bas == 'E'){
            this.$message.error('此签约信息存在报送错误,未修改前不能删除!');
					  this.model.cfabut.basflg = ''
					  return
          }else if(this.model.notdelflg != '' && this.model.notdelflg != null){
            this.$message.error('此签约信息存在已报送或待修改的变动信息或履约信息,不能删除!');
					  this.model.cfabut.basflg = ''
					  return
          }else {
            this.$confirm('删除签约信息,会同时删除未报送的变动信息,确定要删除吗?', '提示', {
						confirmButtonText: '是',
						cancelButtonText: '否',
						type: 'warning'
					}).then(() => {
            this.model.recgrp.bas.acp = 'X';
            let dclArr =this.model.recgrp.dcl || [] ;
						let oldsta = this.model.recgrp.bas.sta;
            let transname = this.transName;
            let oldacttyp = this.model.oldbasacttyp;
            let newdclacttyp = this.setCfaActiontype(transname,oldacttyp,oldsta,"X");
            this.model.recgrp.bas.actiontype = newdclacttyp;
						if (dclArr.length > 0) {
							this.model.cfabut.dclflg = 'X'
							for (let z = 0; z < dclArr.length; z++) {
								if (dclArr[z].sta == 'W') {
                    dclArr[z].acp = 'X'
                    let dcloldsta = dclArr[z].sta;
                    let dcloldacttyp = this.model.olddclacttyp[z];
                    let dclnewdclacttyp = this.setCfaActiontype(this.transName,dcloldacttyp,dcloldsta,"X");
                    dclArr[z].actiontype = dclnewdclacttyp;
								}
							}
						}
					 }).catch(() => {
            this.model.cfabut.basflg = ''
            this.model.recgrp.bas.acp = '';
            this.model.recgrp.bas.actiontype = this.model.oldbasacttyp;
					 });
          }
         }else{
            this.model.recgrp.bas.acp = '';
            this.model.recgrp.bas.actiontype = this.model.oldbasacttyp;
          }
      }

    },
    created:function(){
      //初始化机构列表 
     this.getOwnExtkeyCondition();
     //界面可编辑初始化
     this.calDisabled();
     this.calFlgDisabled();
    },
    mounted() {
    
  },
}
</script>
<style>

</style>