<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">
            <a-form-model-item label="昵称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="nickName">
              <a-input v-model="model.nickName" placeholder="请输入昵称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="用户头像" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="headImage">
              <j-image-upload isMultiple  v-model="model.headImage" ></j-image-upload>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="真实姓名" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="name">
              <a-input v-model="model.name" placeholder="请输入真实姓名"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="手机号码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="phone">
              <a-input v-model="model.phone" placeholder="请输入手机号码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="登录账号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="account">
              <a-input v-model="model.account" placeholder="请输入登录账号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="登录密码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="password">
              <a-input v-model="model.password" placeholder="请输入登录密码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="登录盐" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="passwordSalt">
              <a-input v-model="model.passwordSalt" placeholder="请输入登录盐"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="店铺名称备注" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="shopName">
              <a-input v-model="model.shopName" placeholder="请输入店铺名称备注"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="角色" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="role">
              <a-input v-model="model.role" placeholder="请输入角色"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="ID标识号码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cardId">
              <a-input v-model="model.cardId" placeholder="请输入ID标识号码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="是否冻结" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="frozenFlag">
              <a-input v-model="model.frozenFlag" placeholder="请输入是否冻结"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="是否删除" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="deleteFlag">
              <a-input v-model="model.deleteFlag" placeholder="请输入是否删除"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="登录TOEKN" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="token">
              <a-input v-model="model.token" placeholder="请输入登录TOEKN"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="公众号openid" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="officialOpenid">
              <a-input v-model="model.officialOpenid" placeholder="请输入公众号openid"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="小程序标识" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="appletOpenid">
              <a-input v-model="model.appletOpenid" placeholder="请输入小程序标识"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="APP标识" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="appOpenid">
              <a-input v-model="model.appOpenid" placeholder="请输入APP标识"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="微信UNIONID" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="wxUnionid">
              <a-input v-model="model.wxUnionid" placeholder="请输入微信UNIONID"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="公众号appid" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="officialAppid">
              <a-input v-model="model.officialAppid" placeholder="请输入公众号appid"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="身份证号码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="idCard">
              <a-input v-model="model.idCard" placeholder="请输入身份证号码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="发薪平台密码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="idCardPassword">
              <a-input v-model="model.idCardPassword" placeholder="请输入发薪平台密码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="发薪平台加密盐" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="idCardSalt">
              <a-input v-model="model.idCardSalt" placeholder="请输入发薪平台加密盐"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="是否实名认证" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="idCardOpen">
              <a-input v-model="model.idCardOpen" placeholder="请输入是否实名认证"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="intentionNum" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="intentionNum">
              <a-input-number v-model="model.intentionNum" placeholder="请输入intentionNum" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="successNum" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="successNum">
              <a-input-number v-model="model.successNum" placeholder="请输入successNum" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="addNum" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="addNum">
              <a-input-number v-model="model.addNum" placeholder="请输入addNum" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="shareId" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="shareId">
              <a-input v-model="model.shareId" placeholder="请输入shareId"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="邀请人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="vid">
              <a-input v-model="model.vid" placeholder="请输入邀请人"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="邀请时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="vtime">
              <j-date placeholder="请选择邀请时间" v-model="model.vtime"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="兼兼街会员" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="isPay">
              <a-input-number v-model="model.isPay" placeholder="请输入兼兼街会员" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="是否关注公众号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="follow">
              <a-input-number v-model="model.follow" placeholder="请输入是否关注公众号" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="payRole" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="payRole">
              <a-input-number v-model="model.payRole" placeholder="请输入payRole" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="余额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="balance">
              <a-input-number v-model="model.balance" placeholder="请输入余额" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="积分" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="integerPrice">
              <a-input-number v-model="model.integerPrice" placeholder="请输入积分" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="小程序appid" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="appletAppid">
              <a-input v-model="model.appletAppid" placeholder="请输入小程序appid"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="性别" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sex">
              <a-input v-model="model.sex" placeholder="请输入性别"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="是否分销商" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="isDai">
              <a-input v-model="model.isDai" placeholder="请输入是否分销商"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="团长等级" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="leaderLevelId">
              <j-dict-select-tag type="list" v-model="model.leaderLevelId" dictCode="teambuy_level,title,id" placeholder="请选择团长等级" />
            </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'

  export default {
    name: 'HanHaiMemberForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/hanHaiMember/hanHaiMember/add",
          edit: "/hanHaiMember/hanHaiMember/edit",
          queryById: "/hanHaiMember/hanHaiMember/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;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            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>