<template>
  <!-- 新增托书  -->
  <div id="addBookDrawer">
    <a-drawer
      title="详情"
      width="89%"
      placement="right"
      :closable="true"
      :visible="visible"
      @close="handleCancel">
      <!-- 主表信息 填写 为什么原先图部分回显？？-->
      <a-card :bordered="true">
        <div class="table-page-search-wrapper">
          <a-form-model layout="inline" ref="form" :model="addBook" :rules="validatorRules">
           <a-row :gutter="24">
              <a-col :md="6" :sm="8">
                <a-form-model-item label="托书日期" prop="shippingOrderDate">
                  {{addBook.shippingOrderDate}}
                </a-form-model-item>
              </a-col>

              <a-col :md="6" :sm="8">
                <a-form-model-item label="托书号" prop="shippingOrderNumber">
                  {{addBook.shippingOrderNumber}}
                  
                </a-form-model-item>
              </a-col>

              <a-col :md="6" :sm="8">
                <a-form-model-item label="经营单位" prop="unitInOperation">
                  {{addBook.unitInOperation}}
                </a-form-model-item>
              </a-col>

              <a-col :md="6" :sm="8">
                <a-form-model-item label="经营单位地址" prop="unitInOperationAddress">
                  {{addBook.unitInOperationAddress}}
                </a-form-model-item>
              </a-col>

              <a-col :md="6" :sm="8">
                <a-form-model-item label="装运期限" prop="latestDateOfShipment">
                  {{addBook.latestDateOfShipment}}
                </a-form-model-item>
              </a-col>


              <a-col :md="6" :sm="8">
                <a-form-model-item label="最终船期" prop="theFinalShippingDate">
                  {{addBook.theFinalShippingDate}}
                 
                </a-form-model-item>
              </a-col>

               <a-col :md="6" :sm="8">
                <a-form-model-item label="运抵国别" prop="arriveInCountry">
                  {{addBook.arriveInCountry}}
                  <!-- <a-input placeholder="请输入运抵国别" v-model="addBook.arriveInCountry"></a-input> -->
                </a-form-model-item>
              </a-col>

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

               <a-col :md="6" :sm="8">
                <a-form-model-item label="收货人" prop="consignee">
                  {{addBook.consignee}}
                
                </a-form-model-item>
              </a-col>

              <a-col :md="6" :sm="8">
                <a-form-model-item label="收货人地址" prop="consigneeAddress">
                  {{addBook.consigneeAddress}}
                </a-form-model-item>
              </a-col>

              <a-col :md="6" :sm="8">
                <a-form-model-item label="通知方" prop="notifyParty">
                  {{addBook.notifyParty}}
              
                </a-form-model-item>
              </a-col>

              <a-col :md="6" :sm="8">
                <a-form-model-item label="通知方地址" prop="notifyPartyAddress">
                  {{addBook.notifyPartyAddress}}
              
                </a-form-model-item>
              </a-col>


             
              <a-col :md="6" :sm="8">
                <a-form-model-item label="出口口岸" prop="exportPort">
                  {{addBook.exportPort}}
                    
                </a-form-model-item>
              </a-col>

              <a-col :md="6" :sm="8">
                <a-form-model-item label="目的港" prop="destinationPort">
                  {{addBook.destinationPort}}
                  
                  <!-- <a-input placeholder="请输入目的港" v-model="addBook.destinationPort"></a-input> -->
                </a-form-model-item>
              </a-col>

              <a-col :md="6" :sm="8">
                <a-form-model-item label="收汇方式" prop="exchangeEarningsValue">
                  {{addBook.exchangeEarningsValue}}
                   
                  <!-- <a-input placeholder="请输入收汇方式" v-model="addBook.exchangeEarningsValue"></a-input> -->
                </a-form-model-item>
              </a-col>

              <a-col :md="6" :sm="8">
                <a-form-model-item label="成交方式" prop="termsOfDeliveryvalue">
                  {{addBook.termsOfDeliveryvalue}}
               
                  <!-- <a-input placeholder="请输入成交方式" v-model="addBook.termsOfDeliveryvalue"></a-input> -->
                </a-form-model-item>
              </a-col>

              <a-col :md="6" :sm="8">
                <a-form-model-item label="金额" prop="money">
                  {{addBook.money}}
                 
                </a-form-model-item>
              </a-col>

              <!-- <a-col :md="6" :sm="8">
                <a-form-model-item label="人民币" prop="cny">
                  {{addBook.cny}}
                 
                </a-form-model-item>
              </a-col>

              <a-col :md="6" :sm="8">
                <a-form-model-item label="美元" prop="usd">
                    {{addBook.usd}}
                  
                </a-form-model-item>
              </a-col> -->
            </a-row>
          </a-form-model>
        </div>
      </a-card>

      <!--操作按钮区域 参照装箱单  増行-->
      <a-card :bordered="true" style="margin:10px 0  40px 0;">
        <!-- 子表-->
        <a-spin :spinning="confirmLoading">
          <a-form-model ref="formRef" :rules="validatorRules">
            <a-table
              bordered
              :row-key="record => record.id"
              :columns="addBookColumns"
              :data-source="addBookData"
              :loading="loading"
              :pagination="ipagination"
              :scroll="{ x: 1500,y: 350 }"
              @change="handleTableChange"
            >
            </a-table>
          </a-form-model>

          <!-- 人民币、美金 -->
          <a-row style="margin:60px 0;">
            <div class="purchase-order-table" style="width:48%;marginRight:4%;float:left;">
              <h6 class="table-title">人民币</h6>
              <a-table
                :row-key="record => record.id"
                :loading="loading"
                :columns="CNYColumns"
                :scroll="{ y: 200 }"
                :data-source="rmbList"
                bordered
                :pagination="false"
              >
              <template slot="CNYfreighForward" slot-scope="text, record, index">
                <a-form-model-item prop="CNYfreighForward" :rules="rules.CNYfreighForward" >
                  {{record.freightForwarder}}
                </a-form-model-item>
              </template>
              <template slot="CNYmoney" slot-scope="text, record, index">
                <a-form-model-item prop="CNYmoney" :rules="rules.CNYmoney" >
                  {{record.amount}}
                </a-form-model-item>
              </template>
                <!-- CNY项目列 -->
                <template slot="CNYProjectList" slot-scope="text, record, index">
                  <a-form-model-item prop="CNYProjectList" :rules="rules.CNYProjectList">
                    <a-select v-model="record.itemColumn" style="width:100%" placeholder="请输入项目列" :disabled="disabled">
                      <a-select-option value="1">项目列1</a-select-option>
                      <a-select-option value="2">项目列2</a-select-option>
                    </a-select>
                  </a-form-model-item>
                </template>
              </a-table>
            </div>

            <div class="purchase-order-table" style="width:48%;float:right;">
              <h6 class="table-title">美金</h6>
              <a-table
                :row-key="record => record.id"
                :loading="loading"
                :columns="USDColumns"
                :data-source="usdList"
                :scroll="{ y: 200 }"
                bordered
                :pagination="false"
              >
               <template slot="USDfreighForward" slot-scope="text, record, index">
                <a-form-model-item prop="USDfreighForward" :rules="rules.USDfreighForward" >
                  {{record.freightForwarder}}
                </a-form-model-item>
              </template>
              <template slot="USDmoney" slot-scope="text, record, index">
                <a-form-model-item prop="USDmoney" :rules="rules.USDmoney" >
                  {{record.amount}}
                </a-form-model-item>
              </template>
                <!-- USD项目列 -->
                <template slot="USDProjectList" slot-scope="text, record, index">
                  <a-form-model-item prop="USDProjectList" :rules="rules.USDProjectList">
                    <a-select v-model="record.itemColumn" style="width:100%" :disabled="disabled">
                      <a-select-option value="1">项目列1</a-select-option>
                      <a-select-option value="2">项目列2</a-select-option>
                    </a-select>
                  </a-form-model-item>
                </template>
              </a-table>
            </div>
          </a-row>
        </a-spin>
      </a-card>

      <!-- 页面底部保存取消 -->
      <div
        :style="{
          position: 'absolute',
          right: 0,
          bottom: 0,
          width: '100%',
          borderTop: '1px solid #e9e9e9',
          padding: '10px 16px',
          background: '#fff',
          textAlign: 'right',
          zIndex: 999
        }"
      >
        <a-popconfirm title="确定放弃新增？" @confirm="handleCancel" okText="确定" cancelText="取消">
          <a-button :style="{ marginRight: '8px' }">关闭</a-button>
        </a-popconfirm>
      </div>
    </a-drawer>
  </div>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import JEllipsis from '@/components/jeecg/JEllipsis'
import moment from 'moment'

export default {
  name: 'AddBookDrawer', // 新增 托书
  mixins: [JeecgListMixin],
  components: {  JEllipsis, moment }, // 参照装箱单 弹框
  data() {
    let ellipsis = (v, l = 20) => <j-ellipsis value={v} length={l} />
    return {
      disabled:true,
      // 表头
      addBookColumns: [
        {
          title: '款号',
          dataIndex: 'styleNumber',
          width: 120,
          ellipsis: true,
          className: 'replacecolor'
        },
         {
          title: '小po',
          dataIndex: 'smailPo',
          width: 120,
          ellipsis: true,
          className: 'replacecolor'
        },
        {
          title: '数量',
          dataIndex: 'number',
          width: 120,
          ellipsis: true,
          className: 'replacecolor'
        },
         {
          title: '箱数',
          dataIndex: 'boxNumber',
          width: 160,
          ellipsis: true,
          className: 'replacecolor'
        },
         {
          title: '毛重',
          dataIndex: 'grossWeight',
          width: 120,
          ellipsis: true,
          className: 'replacecolor'
        },
        {
          title: '净重',
          dataIndex: 'netWeight',
          width: 120,
          ellipsis: true,
          // scopedSlots: { customRender: 'containerCode' },
          className: 'replacecolor'
        },
        {
          title: '体积',
          dataIndex: 'volume',
          width: 120,
          ellipsis: true,
          // scopedSlots: { customRender: 'containerNo' },
          // className: 'replacecolor'
        },
        {
          title: '分销点',
          dataIndex: 'distributionPoint',
          width: 120,
          ellipsis: true,
          className: 'replacecolor'
        },
        {
          title: '集装箱号',
          dataIndex: 'containerNumber',
          ellipsis: true,
          scopedSlots: { customRender: 'containerNumber' },
          width: 120,
          // fixed: 'left',
          className: 'replacecolor'
        },
          {
          title: '集装箱代号',
          dataIndex: 'containerCode',
          scopedSlots: { customRender: 'containerCode' },
          width: 120,
          ellipsis: true,
          className: 'replacecolor'
        },
          {
          title: '单价',
          dataIndex: 'unitPrice',
          width: 120,
          ellipsis: true,
          className: 'replacecolor'
        },
        {
          title: '金额',
          dataIndex: 'totalPrice',
          width: 120,
          ellipsis: true,
          className: 'replacecolor'
        },

         {
          title: '制单人',
          dataIndex: 'createBy',
          width: 120,
          ellipsis: true,
          // fixed: 'left',
          className: 'replacecolor'
        },
           {
          title: '采购/委外订单号',
          dataIndex: 'purOrSubOrder',
          width: 160,
          ellipsis: true,
          className: 'replacecolor'
        },
        {
          title: '英文名称',
          dataIndex: 'englishProductName',
          width: 160,
          ellipsis: true,
          className: 'replacecolor'
        },
      ],
      addBookData: [],
      CNYColumns: [
        {
          title: '货代',
          dataIndex: 'freightForwarder',
          width: 60,
          className: 'replacecolor'
        },
        {
          title: '金额',
          dataIndex: 'amount',
          width: 60,
          className: 'replacecolor'
        },
        {
          title: '项目列',
          dataIndex: 'itemColumn',
          scopedSlots: { customRender: 'CNYProjectList' },
          width: 60,
          className: 'replacecolor'
        }
      ],
      rmbList: [{}],
      USDColumns: [
        {
          title: '货代',
          dataIndex: 'freightForwarder',
          scopedSlots: { customRender: 'USDfreighForward' },
          width: 20,
          className: 'replacecolor'
        },
        {
          title: '金额',
          dataIndex: 'amount',
          scopedSlots: { customRender: 'USDmoney' },
          width: 20,
          className: 'replacecolor'
        },
        {
          title: '项目列',
          dataIndex: 'itemColumn',
          width: 90,
          scopedSlots: { customRender: 'USDProjectList' },
          className: 'replacecolor'
        }
      ],
      usdList: [{}],
      loading: false, // 表格加载
      addBook: {},
      confirmLoading: false,
      visible: false,
      dateFormat: 'YYYY-MM-DD',
      validatorRules: {
          shippingOrderDate:[{required: true, message: '托书日期不能为空!'}],
          consignee:[{required: true, message: '收货人不能为空!'}],
          shippingOrderNumber:[{required: true, message: '预托书号不能为空!'}],
      }
    }
  },
  created() {},
  methods: {

    //  // 新增托书 子表合计
    // addBookFooterShow(data) {
    //   console.log('新增托书 子表 ----合计行')
    //   console.log('data', data)
    //   return (
    //     <a-table
    //       rowKey={Math.random}
    //       bordered={false}
    //       pagination={false}
    //       columns={this.addBookColumns}
    //       dataSource={this.addBookFooterDataSource || []}
    //       showHeader={false}
    //     ></a-table>
    //   )
    // },
    
    // 抽屉 取消
    handleCancel() {
      console.log('点击抽屉取消')
      this.close()
    },

    close() {
      this.$emit('close')
      this.addBook ={}
      this.addBookData =[]
      this.rmbList = []
      this.usdList = []
      this.visible = false
    },

  
  },
  mounted() {}
}
</script>
<style lang="less" scoped>
@import '~@assets/less/common.less';
@import '~@assets/less/overwriter.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;
// }

// 抽屉里的card样式
/deep/ .ant-drawer-content {
  background-color: #f0f2f5;
}
/deep/ .ant-drawer-body {
  padding: 10px;
}
/deep/ .ant-table-footer .ant-table.body {
  // overflow: hidden !important;
}
/deep/ .ant-table.ant-table-bordered .ant-table-footer {
  border: none;
  padding: 0;
}
</style>
