<template>
  <a-spin :spinning="confirmLoading">
      <a-button v-print="'#printContent'" ghost type="primary" style="font-size:12px">打印</a-button>
    <j-form-container :disabled="formDisabled">
    <section ref="print" id="printContent" class="ant-card-body" style="width:800px">
      <!-- 主表单区域 -->
      <a-form :form="form" slot="detail">
        
        <a-row style="height:160px">
          <a-col>
              <a-input v-model="model.customerCode" class="ant-input"></a-input>
          </a-col>
        </a-row>
        <a-row style="height:160px">
          <a-col>
              <a-input v-model="model.casesTotal" class="ant-input"></a-input>
          </a-col>
        </a-row>
        <a-row style="height:160px">
          <a-col>
              <a-input v-model="model.receivingNo" class="ant-input"></a-input>
          </a-col>
        </a-row>
      </a-form>
    </section>
    </j-form-container>
  </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'  

  export default {
    name: 'IostReceivingLableForm',
    components: {
      JFormContainer,
      JDate,
    },
    data() {
      return {
        form: this.$form.createForm(this),
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/basedata/iostReceiving/add",
          edit: "/basedata/iostReceiving/edit",
          queryById: "/basedata/iostReceiving/queryById",
        }
      }
    },
    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 () {
      //如果是流程中表单，则需要加载流程表单data
      this.showFlowData();
    },
    methods: {
      edit (record) {
        this.form.resetFields();
        this.model = Object.assign({}, record);
        this.model.casesTotal = `共${this.model.casesTotal}件`
        this.visible = true;
        this.$nextTick(() => {
          this.form.setFieldsValue(pick(this.model,'receivingNo','casesTotal','customerCode'))
        })
      },
      //渲染流程表单数据
      showFlowData(){
        if(this.formBpm === true){
          let params = {id:this.formData.dataId};
          getAction(this.url.queryById,params).then((res)=>{
            if(res.success){
              this.edit (res.result);
            }
          })
        }
      },
     popupCallback(row){
       this.form.setFieldsValue(pick(row,'receivingNo','casesTotal','customerCode'))
     },

    }
  }
</script>

<style scoped>
  /*update_begin author:scott date:20191203 for:打印机打印的字体模糊问题 */
  * {
    color: #000000!important;
    font-size: 120px;
    -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: center;
    margin-left: 5px;
    width: 100%;
    height: 120px;
    font-weight: 900;
  }
</style>