<template>
  <a-spin :spinning="confirmLoading">
    <a-button v-print="'#printContent1'" ghost type="primary">打印</a-button>
    <section ref="print" id="printContent1" class="ant-card-body">
    <j-form-container :disabled="formDisabled">
      <!-- 主表单区域 -->
      <a-form :form="form" slot="detail">
        <a-row>
          <a-col :span="8" >
              <span class="ant-inputlabel">&nbsp;&nbsp;&nbsp;&nbsp;入仓号:</span>
              <a-input v-model="model.receivingNo" class="ant-input"></a-input>
          </a-col>
          <a-col :span="8" >
              <span class="ant-inputlabel">送货厂家:</span>
              <a-input v-model="model.deliveryFactory" class="ant-input"></a-input>
          </a-col>
          <a-col :span="8" >
              <span class="ant-inputlabel">仓库名称:</span>
              <a-input v-model="model.storgeName" class="ant-input"></a-input>
          </a-col>
          <a-col :span="8" >
              <span class="ant-inputlabel">客户姓名:</span>
              <a-input v-model="model.customerName" class="ant-input"></a-input>
          </a-col>
          <a-col :span="8" >
              <span class="ant-inputlabel">&nbsp;&nbsp;&nbsp;&nbsp;送货人:</span>
              <a-input v-model="model.deliveryMan" class="ant-input"></a-input>
          </a-col>
          <a-col :span="8" >
              <span class="ant-inputlabel">&nbsp;&nbsp;&nbsp;&nbsp;总件数:</span>
              <a-input v-model="model.casesTotal" class="ant-input"></a-input>
          </a-col>
          <a-col :span="8" >
              <span class="ant-inputlabel">客户编码:</span>
              <a-input v-model="model.customerCode" class="ant-input"></a-input>
          </a-col>
          <a-col :span="8" >
              <span class="ant-inputlabel">联系电话:</span>
              <a-input v-model="model.telephone" class="ant-input"></a-input>
          </a-col>
          <a-col :span="8" >
              <span class="ant-inputlabel">入库日期:</span>
              <a-input v-model="model.date" class="ant-input"></a-input>
          </a-col>
        </a-row>
      </a-form>
    </j-form-container>
        <a-row>
          &nbsp;
        </a-row>
      <!-- 子表单区域 -->
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        class="j-table-force-nowrap"
        :scroll="{x:true}"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="false"
        :loading="loading">
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
      </a-table>
    </section>
  </a-spin>
</template>

<script>

  import pick from 'lodash.pick'
  import { getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'
  import JFormContainer from '@/components/jeecg/JFormContainer'
  import JDate from '@/components/jeecg/JDate'  
  import { JeecgListMixin4Entry } from '@/mixins/JeecgListMixin4Entry'
  import '@/assets/less/TableExpand.less'

  export default {
    name: 'IostReceivingCopyForm',
    mixins: [JeecgListMixin4Entry],
    components: {
      JFormContainer,
      JDate,
    },
    data() {
      return {
        labelCol: {
          xs: { span: 24 },
          sm: { span: 6 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        labelCol2: {
          xs: { span: 24 },
          sm: { span: 3 },
        },
        wrapperCol2: {
          xs: { span: 24 },
          sm: { span: 20 },
        },
        form: this.$form.createForm(this),
        model: {},
        columns: [
          {
            title: '商品中文名称',
            align:"center",
            dataIndex: 'nameChs'
          },
          {
            title: '商品英文名称',
            align:"center",
            dataIndex: 'nameEng'
          },
          {
            title: '单位',
            align:"center",
            dataIndex: 'unit'
          },
          {
            title: '件数',
            align:"center",
            dataIndex: 'cases',
          },
          {
            title: '单件装箱数',
            align:"center",
            dataIndex: 'packages'
          },
          {
            title: '总装箱数',
            align:"center",
            dataIndex: 'packagesTotal',
          },
          {
            title: '长(cm)',
            align:"center",
            dataIndex: 'length',
          },
          {
            title: '宽(cm)',
            align:"center",
            dataIndex: 'width',
          },
          {
            title: '高(cm)',
            align:"center",
            dataIndex: 'height',
          },
          {
            title: '总体积',
            align:"center",
            dataIndex: 'volumeTotal',
          },
          {
            title: '总重量(kg)',
            align:"center",
            dataIndex: 'weightTotal',
          },
          {
            title: '材质',
            align:"center",
            dataIndex: 'material'
          },
          {
            title: '单价',
            align:"center",
            dataIndex: 'price'
          },
          {
            title: '金额',
            align:"center",
            dataIndex: 'money',
          },
        ],
        confirmLoading: false,
        url: {
          add: "/basedata/iostReceiving/add",
          edit: "/basedata/iostReceiving/edit",
          queryById: "/basedata/iostReceiving/queryByIdPrint",
          list: '/basedata/iostReceiving/queryIostReceivingIostReceivingListByMainId'
        }
      }
    },
    props: {
      //流程表单data
      formData: {
        type: Object,
        default: ()=>{},
        required: false
      },
      //表单模式：false流程表单 true普通表单
      formBpm: {
        type: Boolean,
        default: false,
        required: false
      },
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    computed: {
      formDisabled(){
        if(this.formBpm===true){
          if(this.formData.disabled===false){
            return false
          }
          return true
        }
        return this.disabled
      },
      showFlowSubmitButton(){
        if(this.formBpm===true){
          if(this.formData.disabled===false){
            return true
          }
        }
        return false
      }
    },
    created () {
    },
    methods: {
      edit (record) {
        let params = { id: record.id }
        this.queryParam = params;
        this.willLoadData = true;
        this.loadData(1);



        this.form.resetFields();
        this.model = Object.assign({}, record);
        this.visible = true;
        this.$nextTick(() => {
          this.form.setFieldsValue(pick(this.model,'receivingNo','deliveryFactory','warehouseName','customerName','deliveryMan','casesTotal','customerCode','telephone','date'))
        })
        
      },
     popupCallback(row){
       this.form.setFieldsValue(pick(row,'receivingNo','deliveryFactory','warehouseName','customerName','deliveryMan','casesTotal','customerCode','telephone','date'))
     },

    }
  }
</script>

<style scoped>
  /*update_begin author:scott date:20191203 for:打印机打印的字体模糊问题 */
  * {
    color: #000000!important;
    -webkit-tap-highlight-color: #000000!important;
  }
  /*update_end author:scott date:20191203 for:打印机打印的字体模糊问题 */

  .ant-card-body{
    margin-left: 0%;
    margin-right: 0%;
    margin-bottom: 1%;
    border:0px solid black;
    min-width: 800px;
    color:#000000!important;
  }
  .ant-input{
    border-left-width:0px!important;
    border-top-width:0px!important;
    border-right-width:0px!important;
    text-align: left;
    margin-left: 10px;
    width: 70%;
  }
  .ant-inputlabel{
    text-align: right;
  }
</style>