<template>
  <div class="eibs-tab">
    <c-row>
      <c-col :span="12" :offset="2">
      <el-form-item label="单据类型" prop="bedgrp.srm.djutyp">
        <c-select
          v-model="model.bedgrp.srm.djutyp"
          style="width: 100%"
          placeholder="请选择单据类型"
          :code="codes.djutyp"
          @change="djutypkeyEvent"
        >
        </c-select>
      </el-form-item>
    </c-col>
    </c-row>

    <c-row>
          <c-col :span="12" :offset="2">
      <el-form-item label="单据出具人" prop="bedgrp.srm.djuusr">
        <c-input
          v-model="model.bedgrp.srm.djuusr"
          maxlength="80"
          placeholder="请输入单据出具人"
          :disabled="djutypFlag"
        ></c-input>
      </el-form-item>
    </c-col>
    </c-row>

    <c-row>
          <c-col :span="12" :offset="2">
      <el-form-item label="单据出具日期" prop="bedgrp.srm.djudat">
        <c-date-picker
          type="date"
          v-model="model.bedgrp.srm.djudat"
          value-format="yyyy-MM-dd"
          style="width: 100%"
          placeholder="请选择单据出具日期"
          :disabled="djutypFlag"
        ></c-date-picker>
      </el-form-item>
    </c-col>
    </c-row>

    <c-row>
      <c-col :span="12" :offset="2">
      <el-form-item label="货权单据编号" prop="bedgrp.srm.djuref">
        <c-input
          v-model="model.bedgrp.srm.djuref"
          maxlength="40"
          placeholder="请输入货权单据编号"
          :disabled="djutypFlag"
        ></c-input>
      </el-form-item>
    </c-col>
    </c-row>

  </div>
</template>
<script>
import Api from '~/service/Api'
import commonProcess from '~/mixin/commonProcess'
import CodeTable from '~/config/CodeTable'
import Event from '~/model/Letdrw/Event'

export default {
  inject: ['root'],
  props: ['model', 'codes'],
  mixins: [commonProcess],
  data() {
    return {}
  },
  methods: { 
    ...Event,
    djutypkeyEvent() {
      if (this.model.bedgrp.srm.djutyp=='D'||this.model.bedgrp.srm.djutyp=='') {
        this.model.bedgrp.srm.djuusr = ''  //单据出具人置空
        this.model.bedgrp.srm.djudat = '' //日期置空
        this.model.bedgrp.srm.djuref='' //货权单据编号置空
      }
      this.executeCheck('ledgrp.rec.avbby').then((res) => {
        if (res.respCode == SUCCESS) {
          Utils.copyValueFromVO(this.model, res.data)
        }
      })
    },
  },
  computed: {
    djutypFlag: {
      get() {
        return (
          this.model.bedgrp.srm.djutyp=='D' ||
          this.model.bedgrp.srm.djutyp== '' 
        )
      },
    },
  },
  created: function () {},
}
</script>
<style></style>
