<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="24">
            <div style="text-align: center;font-size: larger;margin-bottom: 10px">企业信息填报</div>
          </a-col>
          <a-col :span="24">
            <a-row>
              <a-col :span="4">
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="用地单位编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qybm">
                  <a-input   v-model="model.qybm" placeholder="用地单位编码" disabled ></a-input>
                </a-form-model-item>
              </a-col>
              <a-col :span="10">
                <a-form-model-item label="用地单位名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qymc">
                  <a-input   v-model="model.qymc" placeholder="请输入企业名称"  ></a-input>
                  <!--              <j-popup
                                  v-model="model.qymc"
                                  field="qymc"
                                  org-fields="depart_name,org_type,org_code"
                                  dest-fields="qymc,org_type,org_code"
                                  code="qymc"
                                  :multi="false"
                                  @input="popupCallback"
                                />-->
                </a-form-model-item>
              </a-col>
            </a-row>


          </a-col>
          <a-col :span="24">
            <a-form-model-item label="上级单位" :labelCol="labelCol" :wrapperCol="wrapperCol"  prop="sjdw">
              <j-popup disabled
                       v-model="model.sjdw"
                       field="sjdw"
                       org-fields="depart_name"
                       dest-fields="sjdw"
                       code="sjdw"
                       :multi="true"
                       @input="popupCallback"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="统一社会信用编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="tyshxybm">
              <a-input v-model="model.tyshxybm" placeholder="请输入统一社会信用编码"   ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="企业类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qylx">
              <j-dict-select-tag type="list" v-model="model.qylx" dictCode="qylx" placeholder="请选择企业类型" @change='change' />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="国有资产持股比例(%)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="gyzccgbl">
              <a-input-number  v-model="model.gyzccgbl" placeholder="请输入国有资产持股比例" style="width: 100%" :max='100' :min='0'/>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="是否涉及省内土地资产" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sfsjtdzc">
              <j-dict-select-tag type="list" v-model="model.sfsjtdzc" dictCode="sfsjtdzc" placeholder="请选择是否涉及省内土地资产" />
            </a-form-model-item>
            <!-- <a-icon class='info' type='question-circle-o' @click='info("sfsjtdzc")'></a-icon>-->
          </a-col>
          <a-col :span="24">
            <div style="text-align: center;font-size: larger;margin-bottom: 10px">企业联络人报名表</div>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="分管领导" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fgld">
              <a-input v-model="model.fgld" placeholder="请输入分管领导姓名"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="分管领导手机" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fgldsjh">
              <a-input v-model="model.fgldsjh" placeholder="请输入分管领导手机号码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item  label="联络人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="tbr">
              <a-input v-model="model.tbr" placeholder="请输入联络人" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="手机号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sjh">
              <a-input v-model="model.sjh" placeholder="请输入座机号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="座机号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="lxdh">
              <a-input v-model="model.lxdh" placeholder="请输入座机号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="统一社会信用代码证书" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="tyshxydmzs">
              <j-upload v-model='model.tyshxydmzs' :disabled="formDisabled"></j-upload>
            </a-form-model-item>
          </a-col>
<!--          <a-col :span="24">-->
<!--          <a-form-model-item label="审核是否通过" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="shzt">-->
<!--            <j-dict-select-tag type="list" v-model="model.shzt" dictCode="shzt" placeholder="请选择审核是否通过" />-->
<!--          </a-form-model-item>-->
<!--          </a-col>-->
<!--          <a-col :span="24">-->
<!--          <a-form-model-item label="审核意见" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="shyj">-->
<!--            <a-textarea v-model="model.shyj" rows="4" placeholder="请输入审核意见" />-->
<!--          </a-form-model-item>-->
<!--          </a-col>-->
<!--          <a-col :span="24">-->
<!--            <a-form-model-item label="审核人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="shren">-->
<!--              <a-input v-model="model.shren" placeholder="请输入审核人" ></a-input>-->
<!--            </a-form-model-item>-->
<!--          </a-col>-->
<!--          <a-col :span="24">-->
<!--            <a-form-model-item label="审核时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="shsj">-->
<!--              <j-date placeholder="请选择审核时间"  v-model="model.updateTime" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%" />-->
<!--            </a-form-model-item>-->
<!--          </a-col>-->
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'
  import store from '@/store'

  export default {
    name: 'QcQyxxForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        blDisable:false,
        model:{
          gyzccgbl:0,
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
           qymc: [
              { required: true, message: '请输入用地单位名称!'},
           ],
           tyshxybm: [
              { required: true, message: '请输入统一社会信用编码!'},
           ],
           gyzccgbl: [
              { required: true, message: '请输入国有资产持股比例!'},

           ],
            sfsjtdzc: [
                { required: true, message: '请输入是否涉及省内土地资产!'},
            ],
          tyshxydmzs: [
            { required: true, message: '请输入统一社会信用代码证书!'},
          ],
          shtg:[{
            required: true, message: '请选择是否通过!'
          }],
            fgld: [
                { required: true, message: '请输入分管领导姓名!'},
            ],
            fgldsjh: [
                { required: true, message: '请输入分管领导手机号码!'},
            ],
            tbr: [
                { required: true, message: '请输入联络人姓名!'},
            ],
            sjh: [
                { required: true, message: '请输入联系手机号码!'},
            ],
            lxdh: [
                { required: false, message: '请输入固定电话!'},
            ],
        },
        url: {
          add: "/qcsb.qyxx/qcQyxx/add",
          edit: "/qcsb.qyxx/qcQyxx/edit",
          queryById: "/qcsb.qyxx/qcQyxx/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      change(val){
        if(val==='国有全资公司'){
          this.model.gyzccgbl=100;
          this.blDisable=true;
        }else {
          this.model.gyzccgbl=0;
          this.blDisable=false;
        }
      },
      popupCallback(row){

      },
      submitForm () {
        const that = this;

        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            this.model.gyzccgbl=this.model.gyzccgbl;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }

        })
      },
    }
  }
</script>