<template>
  <div class="eibs-tab">
    <c-col :span="20">
      <el-form-item label="单据内部不符点" prop="bfdgrp.blk.intdis">
        <c-input
          type="textarea"
          v-model="model.bfdgrp.blk.intdis"
          maxlength="65"
          show-word-limit
          placeholder="请输入单据不符点"
          
        ></c-input>
      </el-form-item>
    </c-col>

    <c-col :span="2">
      <c-button
        size="small"
        type="primary"
        icon="el-icon-search"
        @click="onIntdisButtxmsel"
      >
        ...
      </c-button>
    </c-col>

    <c-col :span="20">
      <el-form-item label="不符点" prop="bfdgrp.blk.docdis">
        <c-input
          type="textarea"
          style="float: left"
          v-model="model.bfdgrp.blk.docdis"
          maxlength="65"
          show-word-limit
          placeholder="请输入不符点"
          :disabled="!docdisflg"
        ></c-input>
      </el-form-item>
    </c-col>

    <c-col :span="2">
      <c-button
        size="small"
        type="primary"
        icon="el-icon-search"
        @click="onDocdisButtxmsel"
        :disabled="!docdisflg"
      >
        ...
      </c-button>
    </c-col>

    <c-col :span="2">
      <c-checkbox v-model="model.rejpenins">保留单据，等候指示</c-checkbox>
    </c-col>

    <c-col :span="2">
      <c-checkbox v-model="docdisflg">不符点修改</c-checkbox>
    </c-col>

    <!-- <c-col :span="24" style="height: 24px; margin-top: 20px">
      <el-form-item :label="model.bftp.docgrdm.docdsclab" class="messageLabel">
      </el-form-item>
    </c-col>
    <c-col :span="24" style="height: 0px; margin-top: 5px">
      <el-divider></el-divider>
    </c-col>
    <c-col :span="24">
      <c-table :data="model.bftp.docgrdm.docgrd" style="width: 100%">
        <el-table-column prop="cmail1" label="1st"> </el-table-column>
        <el-table-column prop="cmail2" label="2st"> </el-table-column>
        <el-table-column label="Document" prop="docnam">
                    <template slot-scope="scope">
                        <c-select v-model="scope.row.ptydbt">
                            <el-option
                                        v-for="item in codes.ptydbt"
                                        :key="item.value"
                                        :label="item.value"
                                        :value="item.value"
                                    >
                                        <span style="float: left">{{ item.label }}</span>
                                    </el-option>
                        </c-select>
                    </template>
                </el-table-column>
        <el-table-column label="" prop="det" width="80px" fixed="right">
          <template slot-scope="scope" slot="header">
            <el-button
              circle
              style="padding: 4px"
              class="el-icon-plus"
              size="mini"
              @click="addRow(scope)"
            >
            </el-button>
            <el-button
              style="padding: 4px"
              circle
              class="el-icon-minus"
              size="mini"
              @click="removeRow(scope)"
            >
            </el-button>
          </template>
        </el-table-column>
      </c-table>
    </c-col> -->
    <c-col :span="24" style="height: 24px; margin-top: -10px">
      <el-form-item :label="model.bftp.docgrdm.docdsclab" class="messageLabel">
        <c-button style="float: right" @click="addTableValue" type="primary"
          >新增单据</c-button
        >
      </el-form-item>
    </c-col>
    <c-col :span="24" style="height: 0px">
      <el-divider></el-divider>
    </c-col>
    <c-col :span="24" style="margin-bottom: 30px;">
      <c-table
        height="200px"
        style="text-align: center"
        :list="this.model.bftp.docgrdm.docgrd || []"
        :paginationShow="false"
        :border="true"
      >
        <el-table-column
          label="1st"
          width="auto"
        >
        <template slot-scope="scope"> 
          <c-input
            v-model="scope.row.cmail1"
          ></c-input>
        </template>
        
        </el-table-column>
        <el-table-column
          label="2nd"
          width="auto"
        >
        <template slot-scope="scope">
          <c-input
            v-model="scope.row.cmail2"
          ></c-input>
        </template>
        </el-table-column>
        <el-table-column label="Document" prop="docnam" width="auto">
          <template slot-scope="scope">
            <!-- {{scope.row.docnam}} -->
            <c-select
              style="width: 100%"
              placeholder="请选择"
              v-model="scope.row.docnam"
            >
              <el-option
                v-for="item in codeTable"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </c-select>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="170px" fixed="right">
          <template slot-scope="scope">
            <c-button @click="deleteTable(scope.$index)" type="primary"
              >删除</c-button
            >
          </template>
        </el-table-column>
      </c-table>
    </c-col>
  </div>
</template>
<script>
import Api from "~/service/Api";
import commonProcess from "~/mixin/commonProcess";
import CodeTable from "~/config/CodeTable";
import Event from "~/model/Bftdcr/Event";
import Utils from "~/utils";

export default {
  inject: ["root"],
  props: ["model", "codes"],
  mixins: [commonProcess],
  data() {
    return {
      TableValue: [
        {
          id: 0,
          cmail1: "",
          cmail2: "",
          docnam: "",
          serialNum: "",
          tableName: "",
          tcddoc: "",
        },
      ],
      newValue: {
        id: 0,
        cmail1: "",
        cmail2: "",
        docnam: "",
        serialNum: "",
        tableName: "",
        tcddoc: "",
      },
      codeTable: [
        { label: "增值税发票", value: "1" },
        { label: "发票", value: "2" },
        { label: "装箱单", value: "3" },
        { label: "空运单", value: "4" },
        { label: "海运提单", value: "5" },
        { label: "铁路运单", value: "6" },
        { label: "货物收据", value: "7" },
        { label: "邮政收据", value: "8" },
      ],
    };
  },
  computed:{
    docdisflg: {
      get() {
        return this.model.bfdgrp.blk.docdisflg != "";
      },
      set(val) {
        this.model.bfdgrp.blk.docdisflg = val ? "X" : "";
        this.model.bfdgrp.blk.docdis = "";
      },
    },

  },
  methods: { ...Event,
    addTableValue(index) {
      var newTableValue = Object.assign({}, this.newValue);
      const serial=Utils.generateUUID();
      newTableValue.serialNum=serial;
      // this.model.bftp.docgrdm.docgrd.push(newTableValue);
      this.model.bftp.docgrdm.docgrd.splice(index-1,0,newTableValue);
    },
    deleteTable(index) {
      this.model.bftp.docgrdm.docgrd.splice(index, 1);
    },
  },
  created: function () {},
};
</script>
<style>
.messageLabel >>> .el-form-item__label {
  text-align: left;
  font-weight: bold;
  font-size: 12px;
}
</style>
