<template>
  <!-- 新增预托书 -->
  <a-card :bordered="false">
    <!-- 主表信息 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline">
        <a-row :gutter="24">
          <a-col :md="6" :sm="8">
            <a-form-item label="托书日期">
              <a-date-picker
                @change="bookDateChange"
                placeholder="请选择托书日期"
                style="width:100%;"
                v-model="preBook.bookDate"
              />
            </a-form-item>
          </a-col>

          <a-col :md="6" :sm="8">
            <a-form-item label="托书号">
              <a-input placeholder="请输入托书号" v-model="preBook.bookNum"></a-input>
            </a-form-item>
          </a-col>

          <a-col :md="12" :sm="12">
            <a-form-item label="外销发票号码">
              <a-input placeholder="请输入外销发票号码" v-model="preBook.exportInvoiceNo"></a-input>
            </a-form-item>
          </a-col>

          <a-col :md="6" :sm="8">
            <a-form-item label="经营单位">
              <a-input placeholder="请输入经营单位" v-model="preBook.businessUnit"></a-input>
            </a-form-item>
          </a-col>

          <a-col :md="6" :sm="8">
            <a-form-item label="经营单位地址">
              <a-select placeholder="请选择经营单位地址" v-model="preBook.businessUnitAdd">
                <a-select-option value="">请选择</a-select-option>
                <a-select-option :value="0">客户1</a-select-option>
                <a-select-option :value="1">客户2</a-select-option>
                <a-select-option :value="2">客户3</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>

          <a-col :md="6" :sm="8">
            <a-form-item label="进仓/装柜日期">
              <a-date-picker
                @change="enterInstallDateChange"
                placeholder="请选择进仓/装柜日期"
                style="width:100%;"
                v-model="preBook.inLoadDate"
              />
            </a-form-item>
          </a-col>

          <a-col :md="6" :sm="8">
            <a-form-item label="最终船期">
              <a-input placeholder="请输入最终船期" v-model="preBook.finalShipDate"></a-input>
            </a-form-item>
          </a-col>

          <a-col :md="6" :sm="8">
            <a-form-item label="收货人">
              <a-input placeholder="请输入收货人" v-model="preBook.consignee"></a-input>
            </a-form-item>
          </a-col>

          <a-col :md="6" :sm="8">
            <a-form-item label="收货人地址">
              <a-select placeholder="请选择收货人地址" v-model="preBook.consigneeAdd">
                <a-select-option value="">请选择</a-select-option>
                <a-select-option value="0">收货人1</a-select-option>
                <a-select-option value="1">收货人2</a-select-option>
                <a-select-option value="2">收货人3</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>

          <a-col :md="6" :sm="8">
            <a-form-item label="通知方">
              <a-input placeholder="请输入通知方" v-model="preBook.notifying"></a-input>
            </a-form-item>
          </a-col>

          <a-col :md="6" :sm="8">
            <a-form-item label="通知方地址">
              <a-input placeholder="请输入通知方地址" v-model="preBook.notifyingAdd"></a-input>
            </a-form-item>
          </a-col>

          <a-col :md="6" :sm="8">
            <a-form-item label="贸易国别">
              <a-input placeholder="请输入贸易国别" v-model="preBook.tradeCountry"></a-input>
            </a-form-item>
          </a-col>

          <a-col :md="6" :sm="8">
            <a-form-item label="运抵国别">
              <a-input placeholder="请输入运抵国别" v-model="preBook.arriveCountry"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <a-form-item label="出口口岸">
              <a-input placeholder="请输入出口口岸" v-model="preBook.exportPort"></a-input>
            </a-form-item>
          </a-col>

          <a-col :md="6" :sm="8">
            <a-form-item label="目的港">
              <a-input placeholder="请输入目的港" v-model="preBook.destinationport"></a-input>
            </a-form-item>
          </a-col>

          <a-col :md="6" :sm="8">
            <a-form-item label="收汇方式">
              <a-input placeholder="请输入收汇方式" v-model="preBook.collectionMethod"></a-input>
            </a-form-item>
          </a-col>

          <a-col :md="6" :sm="8">
            <a-form-item label="成交方式">
              <a-input placeholder="请输入成交方式" v-model="preBook.soldType"></a-input>
            </a-form-item>
          </a-col>

          <a-col :md="6" :sm="8">
            <a-form-item label="金额">
              <a-input placeholder="请输入金额" v-model="preBook.money"></a-input>
            </a-form-item>
          </a-col>

          <a-col :md="6" :sm="8">
            <a-form-item label="人民币">
              <a-input placeholder="请输入人民币" v-model="preBook.RMB"></a-input>
            </a-form-item>
          </a-col>

          <a-col :md="6" :sm="8">
            <a-form-item label="美元">
              <a-input placeholder="请输入美元" v-model="preBook.dollar"></a-input>
            </a-form-item>
          </a-col>
        </a-row>
      </a-form>
    </div>

    <!--操作按钮区域 参照预装箱单  増行-->
    <div class="table-operator">
      <a-button type="primary" @click="referadvancePackingList" icon="ordered-list">参照预装箱单</a-button>
      <a-button type="primary" @click="handleAddColumn" icon="plus" style="margin-left: 20px">増行</a-button>
    </div>

    <!-- table , y: 300-->
    <div>
      <a-table
        bordered
        rowKey="id"
        :columns="addPerBookColumns"
        :data-source="addPerBookData"
        :loading="loading"
        :pagination="ipagination"
        :scroll="{ x: 1500 }"
        @change="handleTableChange"
      >
        <!-- 操作 -->
        <span slot="operationSlot" slot-scope="text, record">
          <a-popconfirm title="确定删除吗?" ok-text="是" cancel-text="否" @confirm="handleDelete(record.id)">
            <a href="javascript:void(0);" style="color:red;">删除</a>
          </a-popconfirm>
        </span>
      </a-table>
    </div>

    <!-- 人民币、美金 -->
    <a-row>
      <a-col :md="12" :sm="12">
        <!-- <div style="background:#ECECEC; padding:10px"> -->
        <a-card title="人民币" :bordered="true" style="width:100%"> </a-card>
        <!-- </div> -->
      </a-col>
      <a-col :md="12" :sm="12">
        <!-- <div style="background:#ECECEC; padding:10px"> -->
        <a-card title="美金" :bordered="true" style="width: 100%"> </a-card>
        <!-- </div> -->
      </a-col>
    </a-row>

    <!-- 保存 取消 -->
    <a-row style="marginTop:20px;">
      <a-col :md="24" :sm="12">
        <span style="float: right;overflow: hidden;">
          <a-button type="primary" style="left: 10px" @click="save">保存</a-button>
          <a-button type="primary" @click="cancel" style="margin-left: 20px">取消</a-button>
        </span>
      </a-col>
    </a-row>

    <!-- 参照预装箱单 -->
    <advancePackingList-modal ref="advancePackingListModal" :father="aa" @ok="modalFormOk"></advancePackingList-modal>
  </a-card>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import JEllipsis from '@/components/jeecg/JEllipsis'
import moment from 'moment'
import AdvancePackingListModal from '@views/pre-book/advancePackingListModal.vue'

export default {
  name: 'AddPreBook', //
  computed: {},
  mixins: [JeecgListMixin],
  components: { AdvancePackingListModal, JEllipsis, moment }, // 参照预装箱单 弹框
  data() {
    return {
      // 表头
      addPerBookColumns: [
        {
          title: '英文名称',
          dataIndex: 'englishName',
          width: 120,
          key: '',
          fixed: 'left',
          className: 'replacecolor'
        },
        {
          title: '款号',
          dataIndex: 'styleNum',
          width: 120,
          key: '',
          fixed: 'left',
          className: 'replacecolor'
        },
        {
          title: '小po号',
          dataIndex: 'smallPoNum',
          width: 120,
          key: '',
          className: 'replacecolor'
        },
        {
          title: '数量',
          dataIndex: 'quantity',
          width: 120,
          key: '',
          className: 'replacecolor'
        },
        {
          title: '箱数',
          dataIndex: 'boxedNum',
          width: 90,
          key: '',
          className: 'replacecolor'
        },

        {
          title: '毛重',
          dataIndex: 'roughWeigh',
          width: 120,
          key: '',
          className: 'replacecolor'
        },
        {
          title: '净重',
          dataIndex: 'suttle',
          width: 120,
          key: '',
          className: 'replacecolor'
        },
        {
          title: '体积',
          dataIndex: 'volume',
          width: 160,
          key: '',
          className: 'replacecolor'
        },
        {
          title: '分销点',
          dataIndex: 'distributionPoint',
          width: 120,
          key: '',
          className: 'replacecolor'
        },
        {
          title: '集装箱代号',
          dataIndex: 'containerCode',
          width: 120,
          key: '',
          className: 'replacecolor'
        },

        {
          title: '集装箱号',
          dataIndex: 'containerNo',
          width: 120,
          key: '',
          className: 'replacecolor'
        },
        {
          title: '单价',
          dataIndex: 'price',
          width: 120,
          key: '',
          className: 'replacecolor'
        },
        //         {
        //   title: '创建时间',
        //   dataIndex: 'createTime',
        //   align: 'center',
        //   sorter: true,
        //   customRender: text => {
        //     return moment(text).format('YYYY-MM-DD')
        //   }
        // },
        {
          title: '预发货日期',
          dataIndex: 'scheduledShipDate',
          width: 120,
          key: '',
          className: 'replacecolor'
        },
        {
          title: '业务员',
          dataIndex: 'salesman',
          width: 120,
          key: '',
          className: 'replacecolor'
        },

        {
          title: '业务部门',
          dataIndex: 'operatingDepartment',
          width: 120,
          key: '',
          className: 'replacecolor'
        },
        {
          title: '采购/委外订单号',
          dataIndex: 'purchaseAboardOrderNum',
          width: 160,
          key: '',
          className: 'replacecolor'
        },

        {
          title: '采购/委外工厂',
          dataIndex: 'purchaseAboardFactory',
          width: 160,
          key: '',
          className: 'replacecolor'
        },

        {
          title: '操作',
          dataIndex: 'operation',
          scopedSlots: { customRender: 'operationSlot' },
          width: 160,
          key: '',
          fixed: 'right',
          className: 'replacecolor'
        }
      ],
      addPerBookData: [{}, {}, {}, {}, {}],
      //  RMBColumns ： [
      //     {
      //         title: '货代',
      //         dataIndex: '',
      //         width: 20,
      //         key: '',
      //         className: 'replacecolor'
      //     },
      //     {
      //         title: '金额',
      //         dataIndex: '',
      //         width: 20,
      //         key: '',
      //         className: 'replacecolor'
      //     },
      //     {
      //         title: '项目列',
      //         dataIndex: '',
      //         width: 20,
      //         key: '',
      //         className: 'replacecolor'
      //     }]，
      //  RMBData ； [{}]，

      //  USDColumns ； [
      //     {
      //         title: '货代',
      //         dataIndex: '',
      //         width: 20,
      //         key: '',
      //         className: 'replacecolor'
      //     },
      //     {
      //         title: '金额',
      //         dataIndex: '',
      //         width: 20,
      //         key: '',
      //         className: 'replacecolor'
      //     },
      //     {
      //         title: '项目列',
      //         dataIndex: '',
      //         width: 20,
      //         key: '',
      //         className: 'replacecolor'
      //     }],
      //  USDData : [{}]
      loading: false, // 表格加载
      preBook: []
    }
  },
  created() {},
  methods: {
    aa() {}, // father
    // 保存按钮
    save() {},
    // 返回
    cancel() {
      this.$router.push('preBookList')
    },
    //  操作按钮 删除
    handleDelete() {},
    // 操作按钮 复制
    copy() {},

    // 参照预装箱单
    referadvancePackingList() {
      console.log('打开参照订单数据')
      // 打开订单数据弹框
      this.$refs.advancePackingListModal.advancePackingListModVis = true
    },
    // 増行
    // 増行
    handleAddColumn() {
      console.log('増行')

      const addrow = {
        englishName: '',
        styleNum: '',
        smallPoNum: '',
        quantity: '',
        boxedNum: '',
        roughWeigh: '',
        suttle: '',
        volume: '',
        distributionPoint: '',
        containerCode: '',
        containerNo: '',
        price: '',
        scheduledShipDate: '',
        salesman: '',
        operatingDepartment: '',
        purchaseAboardOrderNum: '',
        purchaseAboardFactory: '',
        operation: ''
      }

      this.addPerBookData.push(addrow)
    },
    // 托书 日期
    bookDateChange() {},
    // 进仓/装柜子 日期
    enterInstallDateChange() {},
    // ==============================================================

    // ??
    modalFormOk() {}
    // // 分页、排序、筛选变化时触发
    // handleTableChange(pagination, filters, sorter) {
    //   // console.log('当前页信息>>>>',pagination)
    //   this.queryParam.pageNo = pagination.current
    //   this.getAnnList()
    // }
  },

  mounted() {}
}
</script>
<style lang="less" scoped>
@import '~@assets/less/common.less';
/deep/ .ant-table-thead > tr > th {
  text-align: center;
  // font-weight: 700;
}
/deep/ .ant-table-tbody {
  text-align: center;
}
// /deep/ th.replacecolor {
//   background-color: #ccc;
// }
</style>
