<template>
  <c-row>
    <c-blkTextarea :model="model" v-bind="blk"> </c-blkTextarea>
    <br />
    <c-col v-if="dtyp === 'dogp'" :span="12">
      <el-form-item label="Goods code" :prop="`${rec}grp.rec.stagod`">
        <c-select
          v-model="model[`${rec}grp`].rec.stagod"
          style="width: 100%"
          placeholder="请选择Goods code"
          :code="codes.godcod"
        >
        </c-select>
      </el-form-item>
    </c-col>
    <template v-else-if="dtyp === 'adcp'">
      <c-col :span="20" class="letopn_adcp_cheak">
        <c-checkbox v-model="model[`${rec}grp`].rec.spcbenflg"
          >Special payment conditions for beneficiary</c-checkbox
        >
      </c-col>

      <c-col :span="20" class="letopn_adcp_cheak">
        <c-checkbox v-model="model[`${rec}grp`].rec.spcrcbflg">
          Special payment conditions for receiving bank</c-checkbox
        >
      </c-col>

      <c-col :span="20" class="letopn_adcp_cheak">
        <c-checkbox v-model="model[`${rec}grp`].rec.redclsflg"
          >Red/Green Clause</c-checkbox
        >
      </c-col>
      <c-blkTextarea :model="model" v-bind="blk1"> </c-blkTextarea>
    </template>
  </c-row>
</template>
<script>
import Api from "~/service/Api";
import CommonProcess from "~/mixin/CommonProcess";
import BlkTextarea from "./BlkTextarea";

export default {
  inject: ["root"],
  // dtyp=>dogp:货物描述；dorp：单据要求；adcp：附加条款；spcbenp：受益人特殊付款条款；spcrcvp：收款银行特殊付款条款
  props: ["model", "codes", "dtyp", "rec"],
  components: { "c-blkTextarea": BlkTextarea },
  mixins: [CommonProcess],
  data() {
    return {
      blk: this.getBlk(this.dtyp, this.rec),
      blk1: {
        blkMsg: {
          title: "Instructions to Pay.,Accept.,Negot.bank",
          dataUrl: `${this.rec}grp.blk.insbnk`, //字段所在model路劲
          rows: 6,
          maxlength: 2000,
        },
        rulePath: `${this.rec.slice(0, 2)}tp.insbnk.buttxmsel`,
      },
    };
  },
  methods: {
    getBlk(dtyp, rec) {
      let blk = { blkMsg: {}, rulePath: "" };
      let tp = rec.slice(0, 2);
      console.log('tp is :',tp);
      switch (dtyp) {
        case "dogp":
          blk.blkMsg = {
            title: "Description of Goods",
            dataUrl: `${rec}grp.blk.lcrgod`, //字段所在model路劲
            rows: 20,
          };
          blk.rulePath = `${tp}tp.lcrgod.buttxmsel`;
          break;
        case "dorp":
          blk.blkMsg = {
            title: "Documents Required",
            dataUrl: `${rec}grp.blk.lcrdoc`, //字段所在model路劲
            rows: 20,
          };
          blk.rulePath = `${tp}tp.lcrdoc.buttxmsel`;
          break;
        case "adcp":
          blk.blkMsg = {
            title: "Additional Conditions",
            dataUrl: `${rec}grp.blk.adlcnd`, //字段所在model路劲
            rows: 14,
          };
          blk.rulePath = `${tp}tp.adlcnd.buttxmsel`;
          break;
        case "spcbenp":
          blk.blkMsg = {
            title: "Special payment conditions for beneficiary",
            dataUrl: `${rec}grp.blk.spcben`, //字段所在model路劲
            rows: 20,
          };
          blk.rulePath = `${tp}tp.spcben.buttxmsel`;
          break;
        case "spcrcvp":
          blk.blkMsg = {
            title: "Special payment conditions for receiving bank",
            dataUrl: `${rec}grp.blk.spcrcb`, //字段所在model路劲
            rows: 20,
          };
          blk.rulePath = `${tp}tp.spcrcb.buttxmsel`;
          break;
      }
      return blk;
    },
  },
  computed: {},
  created: function () {},
};
</script>
<style>
.letopn_adcp_cheak {
  margin: 0px 0 10px 150px;
}
</style>
