<template>
  <a-spin :spinning="confirmLoading">
    <a-button v-print="'#printContent'" ghost type="primary">打印</a-button>
    <section ref="print" id="printContent" class="ant-card-body">
    <j-form-container :disabled="formDisabled">
      <!-- 主表单区域 -->
      <a-form :form="form" slot="detail">
            <a-row>
              &nbsp;
            </a-row>
            <a-row style="font-size:24px;font-weight:bold;text-align:center;">
              保险单
            </a-row>
            <a-row>
              &nbsp;
            </a-row>
            <a-row>
              &nbsp;
            </a-row>
        <a-row>
          <a-col :span="12" >
              <span class="ant-inputlabel">保险单号:</span>
              <a-input v-model="model.insurancePolicyId" class="ant-input"></a-input>
          </a-col>
          <a-col :span="12" >
              <span class="ant-inputlabel">保险日期:</span>
              <a-input v-model="model.date" class="ant-input"></a-input>
          </a-col>
          <a-col :span="12" >
              <span class="ant-inputlabel">客户编码:</span>
              <a-input v-model="model.customerCode" class="ant-input"></a-input>
          </a-col>
          <a-col :span="12" >
              <span class="ant-inputlabel">客户姓名:</span>
              <a-input v-model="model.customerName" class="ant-input"></a-input>
          </a-col>
          <a-col :span="12" >
              <span class="ant-inputlabel">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;手机:</span>
              <a-input v-model="model.telephone" class="ant-input"></a-input>
          </a-col>
          <a-col :span="12" >
              <span class="ant-inputlabel">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;邮箱:</span>
              <a-input v-model="model.email" class="ant-input"></a-input>
          </a-col>
          <a-col :span="24">
              <span class="ant-inputlabel">公司地址:</span>
              <a-input v-model="model.address" class="ant-input"></a-input>
          </a-col>
        </a-row>
      </a-form>
            <a-row>
              &nbsp;
            </a-row>
    </j-form-container>
      <!-- 子表单区域 -->
      <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>
        <a-row>
          <span style="font-weight:bold;">特别约定：</span>本保险单涂改无效。
        </a-row>
        <a-row>
          <span style="font-weight:bold;">重要提示：</span>1.请详细阅读保险条款，特别是责任免除和投保人。
        </a-row>
      <hr />
        <a-row>
          <a-col :span="12" >
            <a-row>
              <span style="font-weight:bold;">投保人声明：</span>保险人已将投保险种对应的保险条款（包括责任免除部分）向本人作了明确说明，本人已充分理解。上述所填写的内容均属事实，同意签订本保险合同。
            </a-row>
            <a-row>
              &nbsp;
            </a-row>
            <a-row>
              <a-col :span="12" >
                  投保人签字（签章）：
              </a-col>
              <a-col :span="12" style="text-align:right;" >
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;年&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;月&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;日&nbsp;&nbsp;&nbsp;&nbsp;
              </a-col>
            </a-row>
          </a-col>
          <a-col :span="12" >
            <a-row>
              公司名称：
            </a-row>
            <a-row>
              公司地址：
            </a-row>
            <a-row>
              <a-col :span="13" >
                  邮政编码：
              </a-col>
              <a-col :span="11" >
                  &nbsp;&nbsp;&nbsp;联系电话：
              </a-col>
            </a-row>
            <a-row>
              &nbsp;
            </a-row>
            <a-row>
              <a-col :span="13" >
                  签单日期：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;年&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;月&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;日
              </a-col>
              <a-col :span="11" >
                  保险人签章：
              </a-col>
            </a-row>
          </a-col>
        </a-row>

    </section>
  </a-spin>
</template>

<script>

  import pick from 'lodash.pick'
  import { getAction } from '@/api/manage'
  import { FormTypes,getRefPromise } from '@/utils/JEditableTableUtil'
  import { JeecgListMixin4Entry } from '@/mixins/JeecgListMixin4Entry'
  import { validateDuplicateValue } from '@/utils/util'
  import JFormContainer from '@/components/jeecg/JFormContainer'
  import JDate from '@/components/jeecg/JDate'  

  export default {
    name: 'IostInsurancePolicyPForm',
    mixins: [JeecgListMixin4Entry],
    components: {
      JFormContainer,
      JDate,
    },
    data() {
      return {
        columns: [
          {
            title:'商品名称',
            align:"center",
            dataIndex: 'name',
          },
          {
            title:'体积',
            align:"center",
            dataIndex: 'volume',
          },
          {
            title:'重量(kg)',
            align:"center",
            dataIndex: 'weight',
          },
          {
            title:'箱数',
            align:"center",
            dataIndex: 'packages',
          },
          {
            title:'价格',
            align:"center",
            dataIndex: 'price',
          },
          {
            title:'金额',
            align:"center",
            dataIndex: 'money',
          },
          {
            title:'入仓号',
            align:"center",
            dataIndex: 'receivingNo',
          },
        ],
        form: this.$form.createForm(this),
        model: {},
        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 },
        },
        confirmLoading: false,
        url: {
          add: "/basedata/iostInsurancePolicy/add",
          edit: "/basedata/iostInsurancePolicy/edit",
          queryById: "/basedata/iostInsurancePolicy/queryById",
          list: '/basedata/iostInsurancePolicy/queryIostInsurancePolicyListByMainIdWithSum',
        }
      }
    },
    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,'insurancePolicyId','date','customerCode','customerName','telephone','email','address'))
        })
        
      },
     popupCallback(row){
       this.form.setFieldsValue(pick(row,'insurancePolicyId','date','customerCode','customerName','telephone','email','address'))
     },

    }
  }
</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>