Vrfpp.vue 12.2 KB
<template>
	<div class="eibs-tab">
		<div :class="model.cfagit.recgrp.vrf.length > 1 ? 'vrf-wrap' : 'vrf-wrap1'" v-if="model.cfagit.recgrp.vrf && model.cfagit.recgrp.vrf.length">
			<div class="vrf-left div-tags" v-if="model.cfagit.recgrp.vrf.length > 1">
				<div class="vrf-item" v-for="(item, index) in model.cfagit.recgrp.vrf" :key="index" @click="handleActive(index)" :class="[curActive === index ? 'active-tag' : '']">
					履约信息{{ index + 1 }}
				</div>
			</div>
			<div :class="model.cfagit.recgrp.vrf.length > 1 ? 'vrf-right' : 'vrf-right1'" v-show="curActive == index" v-for="(item, index) in model.cfagit.recgrp.vrf" :key="index+'1'">
				<c-col :span="24">
					<!-- ==================================左边-外债编号================================ -->
					<c-col :span="12" style="padding-right: 20px">
						<c-col :span="24">
							<el-form-item label="对外担保编号" :prop="`cfagit.recgrp.vrf.${index}.exguarancode`">
								<c-input v-model="model.cfagit.recgrp.vrf[index].exguarancode" disabled maxlength="28" placeholder="请输入对外担保编号"></c-input>
							</el-form-item>
						</c-col>
						<c-col :span="24">
							<el-form-item label="履约编号" :prop="`cfagit.recgrp.vrf.${index}.complianceno`">
								<c-input v-model="model.cfagit.recgrp.vrf[index].complianceno" disabled maxlength="4" placeholder="请输入履约编号"></c-input>
							</el-form-item>
						</c-col>
						<c-col :span="24">
							<el-form-item label="操作类型" :prop="`cfagit.recgrp.vrf.${index}.actiontype`">
								<c-select v-model="model.cfagit.recgrp.vrf[index].actiontype" disabled style="width: 100%" placeholder="请选择操作类型" dbCode="action" @change="changeActiontype(curActive)">
								</c-select>
							</el-form-item>
						</c-col>
						<c-col :span="24">
							<el-form-item label="担保人代码" :prop="`cfagit.recgrp.vrf.${index}.guarantorcode`" :rules="[{validator:(rule,value,callback)=>validateGuarantorcode(rule,value,callback,index)}]">
								<c-input v-model="model.cfagit.recgrp.vrf[index].guarantorcode" disabled maxlength="12" placeholder="请输入担保人代码"></c-input>
							</el-form-item>
						</c-col>
						<c-col :span="24">
							<el-form-item label="银行业务参号" :prop="`cfagit.recgrp.vrf.${index}.buscode`" :rules="[{validator:(rule,value,callback)=>validateBuscode(rule,value,callback,index)}]">
								<c-input v-model="model.cfagit.recgrp.vrf[index].buscode" :disabled="index < model.oldvrf" maxlength="32" placeholder="请输入银行业务参号"></c-input>
							</el-form-item>
						</c-col>
						<c-col :span="24">
							<el-form-item label="受益人代码" :prop="`cfagit.recgrp.vrf.${index}.bencode`">
								<c-input v-model="model.cfagit.recgrp.vrf[index].bencode" :disabled="index < model.oldvrf" maxlength="32" placeholder="请输入受益人代码"></c-input>
							</el-form-item>
						</c-col>
						<c-col :span="24">
							<el-form-item label="受益人中文名称" :prop="`cfagit.recgrp.vrf.${index}.bename`" :rules="[{ validator:(rule,value,callback) =>validateBename(rule,value,callback,index)}]">
								<c-input v-model="model.cfagit.recgrp.vrf[index].bename" :disabled="index < model.oldvrf" maxlength="90" placeholder="请输入受益人中文名称"></c-input>
							</el-form-item>
						</c-col>
						<c-col :span="24">
							<el-form-item label="受益人英文名称" :prop="`cfagit.recgrp.vrf.${index}.benamen`">
								<c-input v-model="model.cfagit.recgrp.vrf[index].benamen" :disabled="index < model.oldvrf" maxlength="90" placeholder="请输入受益人英文名称"></c-input>
							</el-form-item>
						</c-col>
						<c-col :span="24">
							<el-form-item label="履约日期" :prop="`cfagit.recgrp.vrf.${index}.guperdate`" :rules="[{validator:(rule,value,callback) =>validateGuperdate(rule,value,callback,index)}]">
								<c-date-picker type="date" v-model="model.cfagit.recgrp.vrf[index].guperdate" :disabled="index < model.oldvrf" style="width: 100%" placeholder="请选择履约日期" value-format="yyyy-MM-dd"></c-date-picker>
							</el-form-item>
						</c-col>
						<c-col :span="24">
							<c-col :span="12">
								<el-form-item label="履约金额" :prop="`cfagit.recgrp.vrf.${index}.gupercurr`" :rules="[{ validator:(rule,value,callback) =>validateGupercurr(rule,value,callback,index)}]">
									<c-select v-model="model.cfagit.recgrp.vrf[index].gupercurr" :disabled="index < model.oldvrf" maxlength="3" placeholder="请输入履约币种" dbCode="curtxt"></c-select>
								</el-form-item>
							</c-col>
							<c-col :span="12">
								<el-form-item label="" :prop="`cfagit.recgrp.vrf.${index}.guperamount`" label-width="0" style="margin-left:5px;" :rules="[{ validator:(rule,value,callback) =>validateGuperamount(rule,value,callback,index)}]">
									<c-input-currency v-model="model.cfagit.recgrp.vrf[index].guperamount" :disabled="index < model.oldvrf" placeholder="请输入履约金额">
									</c-input-currency>
								</el-form-item>
							</c-col>
						</c-col>
						<c-col :span="24">
							<el-form-item label="购汇履约金额" :prop="`cfagit.recgrp.vrf.${index}.pguperamount`" :rules="[{ validator:(rule,value,callback) =>validatePguperamount(rule,value,callback,index) }]">
								<c-input-currency v-model="model.cfagit.recgrp.vrf[index].pguperamount" :disabled="index < model.oldvrf" placeholder="请输入购汇履约金额">
								</c-input-currency>
							</el-form-item>
						</c-col>
						<c-col :span="24">
							<el-form-item label="备注" :prop="`cfagit.recgrp.vrf.${index}.remark`">
								<c-input type="textarea" v-model="model.cfagit.recgrp.vrf[index].remark" :disabled="index < model.oldvrf" maxlength="248" show-word-limit placeholder="请输入备注" :rows="5"></c-input>
							</el-form-item>
						</c-col>
					</c-col>

					<!-- ==================================右边-删除原因================================ -->
					<c-col :span="12" style="padding-left: 20px">
						<c-col :span="24">
							<el-form-item label="删除原因" :prop="`cfagit.recgrp.vrf.${index}.actiondesc`">
								<c-input type="textarea" v-model="model.cfagit.recgrp.vrf[index].actiondesc" maxlength="128" show-word-limit placeholder="请输入删除原因" :rows="5" :disabled="disabledActiondesc" @change="changeActiondesc(curActive)"></c-input>
							</el-form-item>
						</c-col>
						<c-col :span="24">
							<el-form-item label="" :prop="`cfagit.recgrp.vrf.${index}.acp`" class="checkbox-left">
								<c-checkbox true-label="X" false-label="" v-model="model.cfagit.recgrp.vrf[index].acp" disabled @change="changeActiondesc(curActive)">确认</c-checkbox>
							</el-form-item>
						</c-col>
					</c-col>
				</c-col>
			</div>
		</div>
	</div>
</template>
<script>
export default {
  inject: ["root"],
  props: ["model", "codes"],
  mixins: [],
  data() {
    return {
      curActive: 0
    };
  },
  computed: {
    disabledActiondesc() {
      let sub = this.model.cfagit.transName;
      sub = sub.slice(3, 6);
      let actiontype = this.model.cfagit.recgrp.vrf[this.curActive].actiontype;
      if (this.model.cfagit.recgrp.vrf[this.curActive].acp) {
        this.model.cfagit.recgrp.vrf[this.curActive].actiondesc = "";
      }
      return true;
      this.changeActiondesc();
    }
  },
  methods: {
    handleActive(ind) {
      this.curActive = ind;
    },
    // default
    changeActiontype(curActive) {
      if (!this.model.cfagit.recgrp.vrf[curActive].actiontype) {
        this.model.cfagit.recgrp.vrf[curActive].actiontype = "A";
      }
    },
    validateBuscode(rule, value, callback, index) {
			console.log("1111",index)
      if (
        this.model.cfagit.recgrp.vrf[index].acp == "X" &&
        this.model.cfagit.recgrp.vrf[index].actiontype != "D"
      ) {
        if (!value) {
          return callback(new Error("必输项"));
        }
      }
      callback();
    },
    validateGuarantorcode(rule, value, callback, index) {
      if (
        this.model.cfagit.recgrp.vrf[index].acp == "X" &&
        this.model.cfagit.recgrp.vrf[index].actiontype != "D"
      ) {
        if (!value) {
          return callback(new Error("必输项"));
        }
      }
      callback();
    },
    changeActiondesc(curActive) {
      let actiontype = this.model.cfagit.recgrp.vrf[curActive].actiontype;
      if (this.model.cfagit.recgrp.vrf[curActive].acp) {
        this.model.cfagit.recgrp.vrf[curActive].actiondesc = "";
      }
    },
    validateBename(rule, value, callback, index) {
      if (
        this.model.cfagit.recgrp.vrf[index].acp == "X" &&
        this.model.cfagit.recgrp.vrf[index].actiontype != "D"
      ) {
        if (!value && !this.model.cfagit.recgrp.vrf[index].benamen) {
          return callback(new Error("受益人中文名称和英文名称至少填写一个!"));
        }
      }

      callback();
    },
    validateGuperdate(rule, value, callback, index) {
      let valuedate = this.model.cfagit.recgrp.bas.contractdate;
      if (
        this.model.cfagit.recgrp.vrf[index].acp == "X" &&
        this.model.cfagit.recgrp.vrf[index].actiontype != "D"
      ) {
        if (!value) {
          return callback(new Error("必输项"));
        } else {
          if (value < valuedate) {
            return callback(new Error("履约日期不能小于签约日期!"));
          }
        }
      }

      callback();
    },
    validatePguperamount(rule, value, callback, index) {
      if (
        this.model.cfagit.recgrp.vrf[index].acp == "X" &&
        this.model.cfagit.recgrp.vrf[index].actiontype != "D"
      ) {
        if (Number(value) < 0) {
          return callback(new Error("购汇履约金额必须大于等于0!"));
        } else {
          if (
            Number(value) >
            Number(this.model.cfagit.recgrp.vrf[index].guperamount)
          ) {
            return callback(new Error("购汇履约金额必须小于等于履约金额!"));
          }
        }
      }

      callback();
    },
    validateGuperamount(rule, value, callback, index) {
      if (
        this.model.cfagit.recgrp.vrf[index].acp == "X" &&
        this.model.cfagit.recgrp.vrf[index].actiontype != "D"
      ) {
        if (!value) {
          return callback(new Error("必输项"));
        } else {
          if (Number(value) < 0) {
            return callback(new Error("履约金额必须大于等于0!"));
          } else {
            if (
              Number(value) > Number(this.model.cfagit.recgrp.bas.guaranamount)
            ) {
              return callback(new Error("履约金额不能大于保函金额!"));
            }
          }
        }
      }

      callback();
    },
    validateGupercurr(rule, value, callback, index) {
      if (
        this.model.cfagit.recgrp.vrf[index].acp == "X" &&
        this.model.cfagit.recgrp.vrf[index].actiontype != "D"
      ) {
        if (!value) {
          return callback(new Error("必输项"));
        } else {
          if (value != this.model.cfagit.recgrp.bas.guarancurr) {
            return callback(new Error("履约币种应等于签约币种!"));
          }
        }
      }
      callback();
    }
  },
  created() {},
  watch: {}
};
</script>
<style scoped>
.vrf-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  border: 1px solid #f1f1f1;
  box-sizing: border-box;
  border-radius: 3px;
}

.vrf-wrap1 {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  box-sizing: border-box;
  border-radius: 3px;
}

.vrf-left {
  width: 120px;
  height: 100%;
  overflow: auto;
  padding: 10px 0 10px 10px;
  position: relative;
  background-color: rgba(102, 83, 242, 0.1);
}

.div-tags {
  padding: 0 !important;
}

.vrf-item {
  width: 100%;
  height: 60px;
  text-align: center;
  line-height: 25px;
  cursor: pointer;
  padding: 5px 5px;
  border: 1px solid #f1f1f1;
  box-shadow: 2px 2px 2px 1px rgba(0, 0, 0, 0.1);
  font-size: 14px;
}

.active-tag {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
  color: #ffffff;
  border: 1px solid #f1f1f1;
}

.vrf-right {
  width: calc(100% - 200px);
  height: 100%;
  border-left: 1px solid #f1f1f1;
  overflow-y: auto;
  box-sizing: border-box;
  padding: 10px 10px 10px 0;
}

.vrf-right1 {
  height: 100%;
  box-sizing: border-box;
}
</style>