<template>
  <div class="app-container">
    <div v-show="viewState == 1">
      <div class="tab-header webtop">
        <div>{{ viewTitle }}</div>
        <div>
          <el-button type="primary" size="small" :disabled="submitdisabled" @click="saveOrUpdate()">保存</el-button>
          <el-button type="info" size="small" @click="handleReturn()">关闭</el-button>
        </div>
      </div>
      <div class="listconadd">
        <el-form ref="form_obj" :model="formobj" :rules="rules" class="formaddcopy02">
          <el-row style="border-top: 1px solid #e0e3eb">
            <el-col :span="12">
              <div class="span-sty"><span class="icon">*</span>客户名称</div>
              <el-form-item prop="name"><el-input class="addinputInfo addinputw" :disabled="formobj.sid !== ''" v-model="formobj.name" clearable placeholder="" /></el-form-item>
            </el-col>
            <el-col :span="12">
              <div class="span-sty">客户类型</div>
              <el-form-item><span class="addinputInfo">{{ formobj.customerType }}</span></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <div class="span-sty"><span class="icon">*</span>联系电话</div>
              <el-form-item prop="mobile"><el-input class="addinputInfo" :disabled="formobj.sid !== ''" style="width: 30%" v-model="formobj.mobile" clearable placeholder="" /></el-form-item>
            </el-col>
            <el-col :span="12">
              <div class="span-sty">微信号</div>
              <el-form-item><el-input class="addinputInfo" style="width: 30%" v-model="formobj.weixin" clearable placeholder="" /></el-form-item>
            </el-col>
          </el-row>
          <el-row v-if="formobj.customerType == '个人'">
            <el-col :span="24">
              <div class="span-sty">公司名称</div>
              <el-form-item>
                <el-select class="addinputInfo" style="width: 40%" v-model="formobj.customerOrgSid" filterable clearable placeholder="" @change="customerOrgChange">
                  <el-option v-for="item in customerOrg_list" :key="item.sid" :label="item.orgName" :value="item.sid"/>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <div class="span-sty">客户地址</div>
              <el-form-item>
                <div class="addinputInfo" style="display: flex;flex-direction: row;justify-content: flex-start;align-items: center">
                  <el-select v-model="formobj.province" filterable clearable placeholder="请选择省" style="width:160px" @change="provinceChange">
                    <el-option v-for="item in province_list" :key="item.sid" :label="item.name" :value="item.name"/>
                  </el-select>
                  <el-select v-model="formobj.city" filterable placeholder="请选择市" style="width:160px" @change="cityChange">
                    <el-option v-for="item in city_list" :key="item.sid" :label="item.name" :value="item.name"/>
                  </el-select>
                  <el-select v-model="formobj.county" filterable placeholder="请选择县" style="width:160px" @change="countyChange">
                    <el-option v-for="item in county_list" :key="item.sid" :label="item.name" :value="item.name"/>
                  </el-select>
                  <el-input style="width: 30%" v-model="formobj.address" clearable placeholder=""/>
                </div>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <div class="span-sty">客户级别</div>
              <el-form-item>
                <el-select v-model="formobj.levelKey" class="addinputInfo" clearable filterable placeholder="" @change="levelChange">
                  <el-option v-for="item in level_list" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey"/>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <div class="span-sty">是否开启提醒</div>
              <el-form-item>
                <el-radio-group class="addinputInfo" :disabled="formobj.sid !== ''" v-model="formobj.isOnRemind" @change="isOnRemindChange">
                  <el-radio label="是">是</el-radio>
                  <el-radio label="否">否</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row v-show="formobj.isOnRemind == '是'">
            <el-col :span="12">
              <div class="span-sty">提醒日期</div>
              <el-form-item><el-date-picker class="addinputInfo" v-model="formobj.remind_day" type="date" value-format="yyyy-MM-dd" format="yyyy-MM-dd" placeholder="选择日期" /></el-form-item>
            </el-col>
            <el-col :span="12">
              <div class="span-sty">提醒备注</div>
              <el-form-item><el-input class="addinputInfo addinputw" v-model="formobj.remind_remark" clearable placeholder="" /></el-form-item>
            </el-col>
          </el-row>
          <div class="title">更多信息</div>
          <el-row v-if="formobj.customerType == '个人'">
            <el-col :span="12">
              <div class="span-sty">客户生日</div>
              <el-form-item><el-date-picker class="addinputInfo" v-model="formobj.birthday" type="date" value-format="yyyy-MM-dd" format="yyyy-MM-dd" placeholder="选择日期" /></el-form-item>
            </el-col>
            <el-col :span="12">
              <div class="span-sty">性别</div>
              <el-form-item>
                <el-radio-group class="addinputInfo" v-model="formobj.sex" @change="sexChange">
                  <el-radio v-for="item in sex_list" :key="item.dictKey" :label="item.dictValue">{{ item.dictValue }}</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <div class="span-sty">证件类型</div>
              <el-form-item><span class="addinputInfo">{{ formobj.certificateType }}</span></el-form-item>
            </el-col>
            <el-col :span="12">
              <div class="span-sty">证件号码</div>
              <el-form-item><el-input class="addinputInfo addinputw" v-model="formobj.idnumber" clearable placeholder="" /></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <div class="span-sty">证件有效期</div>
              <el-form-item><el-date-picker class="addinputInfo" v-model="formobj.endDate" type="date" value-format="yyyy-MM-dd" format="yyyy-MM-dd" placeholder="选择日期" /></el-form-item>
            </el-col>
            <el-col :span="12">
              <div class="span-sty">电子邮箱</div>
              <el-form-item><el-input class="addinputInfo addinputw" style="width: 30%" v-model="formobj.e_mail" clearable placeholder="" /></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <div class="span-sty">紧急联系人</div>
              <el-form-item><el-input class="addinputInfo addinputw" style="width: 30%" v-model="formobj.emergencyContact" clearable placeholder="" /></el-form-item>
            </el-col>
            <el-col :span="12">
              <div class="span-sty">紧急联系电话</div>
              <el-form-item><el-input class="addinputInfo addinputw" style="width: 30%" v-model="formobj.emergencyMobile" clearable placeholder="" /></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <div class="span-sty">客户来源</div>
              <el-form-item>
                <el-select v-model="formobj.sourceKey" class="addinputInfo" clearable filterable placeholder="" @change="sourceChange">
                  <el-option v-for="item in source_list" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey"/>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <div class="span-sty">客户分类</div>
              <el-form-item>
                <el-select v-model="formobj.customerClassKey" class="addinputInfo" clearable filterable placeholder="" @change="customerClassChange">
                  <el-option v-for="item in customerClass_list" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey"/>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <div class="span-sty">备注</div>
              <el-form-item><el-input class="addinputInfo addinputw" v-model="formobj.remarks" clearable placeholder="" /></el-form-item>
            </el-col>
          </el-row>
          <div class="title">车辆信息</div>
          <el-row>
            <el-col :span="12">
              <div class="span-sty"><span class="icon">*</span>车牌号</div>
              <el-form-item prop="vehMark"><el-input class="addinputInfo" style="width: 40%" v-model="formobj.vehMark" clearable placeholder="" /></el-form-item>
            </el-col>
            <el-col :span="12">
              <div class="span-sty"><span class="icon">*</span>车架号</div>
              <el-form-item prop="vinNo"><el-input class="addinputInfo" style="width: 40%" v-model="formobj.vinNo" clearable placeholder="" /></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <div class="span-sty">发动机号</div>
              <el-form-item><el-input class="addinputInfo" style="width: 40%" v-model="formobj.engineNo" clearable placeholder="" /></el-form-item>
            </el-col>
            <el-col :span="12">
              <div class="span-sty">车型</div>
              <el-form-item><el-input class="addinputInfo" style="width: 40%" v-model="formobj.vehModel" clearable placeholder="" /></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <div class="span-sty">购车日期</div>
              <el-form-item> <el-date-picker class="addinputInfo" value-format="yyyy-MM-dd" v-model="formobj.buyDate" clearable type="date" placeholder="" /></el-form-item>
            </el-col>
            <el-col :span="12">
              <div class="span-sty">行驶里程(Km)</div>
              <el-form-item><el-input class="addinputInfo" style="width: 40%" @keyup.native="formobj.mileage = getNumber(formobj.mileage, 2)" v-model="formobj.mileage" clearable placeholder="" /></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <div class="span-sty">上次保养里程(Km)</div>
              <el-form-item><el-input class="addinputInfo" style="width: 40%" @keyup.native="formobj.lastMileage = getNumber(formobj.lastMileage, 2)" v-model="formobj.lastMileage" clearable placeholder="" /></el-form-item>
            </el-col>
            <el-col :span="12">
              <div class="span-sty">下次保养日期</div>
              <el-form-item> <el-date-picker class="addinputInfo" value-format="yyyy-MM-dd" v-model="formobj.nextMaintainDate" clearable type="date" placeholder="" /></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <div class="span-sty">商业险到期日期</div>
              <el-form-item> <el-date-picker class="addinputInfo" value-format="yyyy-MM-dd" v-model="formobj.commercialInsuranceEndDate" clearable type="date" placeholder="" /></el-form-item>
            </el-col>
            <el-col :span="12">
              <div class="span-sty">交强险到期日期</div>
              <el-form-item> <el-date-picker class="addinputInfo" value-format="yyyy-MM-dd" v-model="formobj.compulsoryInsuranceEndDate" clearable type="date" placeholder="" /></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <div class="span-sty">备注</div>
              <el-form-item><el-input class="addinputInfo addinputw" v-model="formobj.carRemarks" clearable placeholder="" /></el-form-item>
            </el-col>
          </el-row>
          <div class="title">保养到期明细</div>
          <el-row>
            <el-col :span="12">
              <div class="span-sty">行驶里程(Km)</div>
              <el-form-item><el-input class="addinputInfo" style="width: 40%" @keyup.native="formobj.currentMileage = getNumber(formobj.currentMileage, 2)" v-model="formobj.currentMileage" clearable placeholder="" /></el-form-item>
            </el-col>
            <el-col :span="12">
              <div class="span-sty">每月公里</div>
              <el-form-item><el-input class="addinputInfo" style="width: 40%" @keyup.native="formobj.monthKm = getNumber(formobj.monthKm, 2)" v-model="formobj.monthKm" clearable placeholder="" /></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <div class="span-sty">滤芯到期公里</div>
              <el-form-item><el-input class="addinputInfo" style="width: 40%" @keyup.native="formobj.filter_km = getNumber(formobj.filter_km, 2)" v-model="formobj.filter_km" clearable placeholder="" /></el-form-item>
            </el-col>
            <el-col :span="12">
              <div class="span-sty">滤芯到期日期</div>
              <el-form-item> <el-date-picker class="addinputInfo" value-format="yyyy-MM-dd" v-model="formobj.filter_date" clearable type="date" placeholder="" /></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <div class="span-sty">机油到期公里</div>
              <el-form-item><el-input class="addinputInfo" style="width: 40%" @keyup.native="formobj.engineoil_km = getNumber(formobj.engineoil_km, 2)" v-model="formobj.engineoil_km" clearable placeholder="" /></el-form-item>
            </el-col>
            <el-col :span="12">
              <div class="span-sty">机油到期日期</div>
              <el-form-item> <el-date-picker class="addinputInfo" value-format="yyyy-MM-dd" v-model="formobj.engineoil_date" clearable type="date" placeholder="" /></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <div class="span-sty">齿轮油到期公里</div>
              <el-form-item><el-input class="addinputInfo" style="width: 40%" @keyup.native="formobj.gearoil_km = getNumber(formobj.gearoil_km, 2)" v-model="formobj.gearoil_km" clearable placeholder="" /></el-form-item>
            </el-col>
            <el-col :span="12">
              <div class="span-sty">齿轮油到期日期</div>
              <el-form-item> <el-date-picker class="addinputInfo" value-format="yyyy-MM-dd" v-model="formobj.gearoil_date" clearable type="date" placeholder="" /></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <div class="span-sty">宝轮到期公里</div>
              <el-form-item><el-input class="addinputInfo" style="width: 40%" @keyup.native="formobj.treasurewheel_km = getNumber(formobj.treasurewheel_km, 2)" v-model="formobj.treasurewheel_km" clearable placeholder="" /></el-form-item>
            </el-col>
            <el-col :span="12">
              <div class="span-sty">宝轮到期日期</div>
              <el-form-item> <el-date-picker class="addinputInfo" value-format="yyyy-MM-dd" v-model="formobj.treasurewheel_date" clearable type="date" placeholder="" /></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <div class="span-sty">风扇皮带到期公里</div>
              <el-form-item><el-input class="addinputInfo" style="width: 40%" @keyup.native="formobj.fanbelt_km = getNumber(formobj.fanbelt_km, 2)" v-model="formobj.fanbelt_km" clearable placeholder="" /></el-form-item>
            </el-col>
            <el-col :span="12">
              <div class="span-sty">风扇皮带到期日期</div>
              <el-form-item> <el-date-picker class="addinputInfo" value-format="yyyy-MM-dd" v-model="formobj.fanbelt_date" clearable type="date" placeholder="" /></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <div class="span-sty">刹车片到期公里</div>
              <el-form-item><el-input class="addinputInfo" style="width: 40%" @keyup.native="formobj.brakepads_km = getNumber(formobj.brakepads_km, 2)" v-model="formobj.brakepads_km" clearable placeholder="" /></el-form-item>
            </el-col>
            <el-col :span="12">
              <div class="span-sty">刹车片到期日期</div>
              <el-form-item> <el-date-picker class="addinputInfo" value-format="yyyy-MM-dd" v-model="formobj.brakepads_date" clearable type="date" placeholder="" /></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <div class="span-sty">备注</div>
              <el-form-item><el-input class="addinputInfo addinputw" v-model="formobj.byRemarks" clearable placeholder="" /></el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
    </div>
  </div>
</template>

<script>
import req from '@/api/client/customermanagement'
import { getProvince, getCity, getCounty, typeValues } from '@/api/Common/dictcommons'

export default {
  name: 'CustomerManagementAdd',
  data() {
    return {
      viewTitle: '',
      viewState: 1,
      submitdisabled: false,
      customerOrg_list: [],
      province_list: [],
      city_list: [],
      county_list: [],
      level_list: [],
      sex_list: [],
      source_list: [],
      customerClass_list: [],
      formobj: {
        name: '',
        customerType: '',
        customerTypeKey: '',
        visitWay: '',
        visitWayKey: '',
        mobile: '',
        weixin: '',
        province: '',
        city: '',
        county: '',
        address: '',
        level: '',
        levelKey: '',
        isOnRemind: '',
        isOnRemindKey: '',
        remind_day: '',
        remind_remark: '',
        birthday: '',
        sex: '',
        sexKey: '',
        certificateType: '',
        certificateTypeKey: '',
        idnumber: '',
        endDate: '',
        e_mail: '',
        emergencyContact: '',
        emergencyMobile: '',
        source: '',
        sourceKey: '',
        customerClass: '',
        customerClassKey: '',
        remarks: '',
        userSid: '',
        orgPath: '',
        useOrgSid: '',
        sid: '',
        customerOrgName: '',
        customerOrgSid: '',
        customerVehSid: '',
        customerSid: '',
        vehMark: '',
        vinNo: '',
        engineNo: '',
        vehModelSid: '',
        vehModel: '',
        mileage: '',
        lastMileage: '',
        nextMaintainDate: '',
        buyDate: '',
        commercialInsuranceEndDate: '',
        compulsoryInsuranceEndDate: '',
        currentMileage: '',
        monthKm: '',
        filter_km: '',
        filter_date: '',
        engineoil_km: '',
        engineoil_date: '',
        gearoil_km: '',
        gearoil_date: '',
        treasurewheel_km: '',
        treasurewheel_date: '',
        fanbelt_km: '',
        fanbelt_date: '',
        brakepads_km: '',
        brakepads_date: '',
        carRemarks: '',
        byRemarks: ''
      },
      rules: {
        name: [{ required: true, message: '客户名称不能为空', trigger: 'blur' }],
        mobile: [{ required: true, message: '联系电话不能为空', trigger: 'blur' }],
        vehMark: [{ required: true, message: '车牌号不能为空', trigger: 'blur' }],
        vinNo: [{ required: true, message: '车架号不能为空', trigger: 'blur' }]
      }
    }
  },
  methods: {
    init() {
      getProvince().then((res) => {
        if (res.success) {
          this.province_list = res.data
        }
      })
      typeValues({ type: 'customerLevel' }).then((res) => {
        if (res.success) {
          this.level_list = res.data
        }
      })
      typeValues({ type: 'sex' }).then((res) => {
        if (res.success) {
          this.sex_list = res.data
        }
      })
      typeValues({ type: 'customerSource' }).then((res) => {
        if (res.success) {
          this.source_list = res.data
        }
      })
      req.selCustomerOrgList({ useOrgSid: window.sessionStorage.getItem('defaultOrgPath').substring(window.sessionStorage.getItem('defaultOrgPath').lastIndexOf('/') + 1) }).then((res) => {
        if (res.success) {
          this.customerOrg_list = res.data
        }
      })
    },
    customerOrgChange(value) {
      const choose = this.customerOrg_list.filter((item) => item.sid === value)
      if (choose.length > 0 && choose !== null) {
        this.formobj.customerOrgName = choose[0].orgName
      } else {
        this.formobj.customerOrgName = ''
      }
    },
    provinceChange(value) {
      const choose = this.province_list.filter((item) => item.name === value)
      if (choose !== null && choose.length > 0) {
        this.formobj.provinceSid = choose[0].sid
        this.getCity(this.formobj.provinceSid)
      } else {
        this.formobj.provinceSid = ''
        this.formobj.citySid = ''
        this.formobj.city = ''
        this.city_list = []
        this.formobj.county = ''
        this.formobj.countySid = ''
        this.county_list = []
      }
    },
    getCity(val) {
      getCity({ sid: val }).then((res) => {
        if (res.success) {
          this.city_list = res.data
        }
      })
    },
    cityChange(value) {
      const choose = this.city_list.filter((item) => item.name === value)
      if (choose !== null && choose.length > 0) {
        this.formobj.citySid = choose[0].sid
        this.getCounty(this.formobj.citySid)
      }
    },
    getCounty(val) {
      getCounty({ sid: val }).then((res) => {
        if (res.success) {
          this.county_list = res.data
        }
      })
    },
    countyChange(value) {
      const choose = this.county_list.filter((item) => item.name === value)
      if (choose !== null && choose.length > 0) {
        this.formobj.countySid = choose[0].sid
      }
    },
    getNumber(val, limit) {
      val = val.replace(/[^0-9.]/g, '') // 保留数字
      val = val.replace(/^00/, '0.') // 开头不能有两个0
      val = val.replace(/^\./g, '0.') // 开头为小数点转换为0.
      val = val.replace(/\.{2,}/g, '.') // 两个以上的小数点转换成一个
      val = val.replace('.', '$#$').replace(/\./g, '').replace('$#$', '.'); // 只保留一个小数点
      /^0\d+/.test(val) ? val = val.slice(1) : '' // 两位以上数字开头不能为0
      const str = '^(\\d+)\\.(\\d{' + limit + '}).*$'
      const reg = new RegExp(str)
      if (limit === 0) {
        // 不需要小数点
        val = val.replace(reg, '$1')
      } else {
        // 通过正则保留小数点后指定的位数
        val = val.replace(reg, '$1.$2')
      }
      return val
    },
    showAdd(value, sid) {
      this.viewTitle = '【快捷新增】客户信息'
      this.$nextTick(() => {
        this.$refs['form_obj'].clearValidate()
      })
      this.init()
      req.quickAddInit({ sid: sid }).then((resp) => {
        if (resp.success) {
          this.formobj = resp.data
          this.formobj.isOnRemind = '否'
          this.formobj.isOnRemindKey = '0'
          this.formobj.customerType = value.customerType
          this.formobj.customerTypeKey = value.customerTypeKey
          this.formobj.visitWay = value.visitWay
          this.formobj.visitWayKey = value.visitWayKey
          this.formobj.userSid = window.sessionStorage.getItem('userSid')
          this.formobj.orgPath = window.sessionStorage.getItem('defaultOrgPath')
          this.formobj.useOrgSid = window.sessionStorage.getItem('defaultOrgPath').substring(window.sessionStorage.getItem('defaultOrgPath').lastIndexOf('/') + 1)
          if (this.formobj.customerType === '个人') {
            this.formobj.certificateType = '身份证'
            this.formobj.certificateTypeKey = '01'
          } else {
            this.formobj.certificateType = '营业执照'
            this.formobj.certificateTypeKey = '02'
          }
          typeValues({ psid: value.psid, type: 'customerClass' }).then((res) => {
            if (res.success) {
              this.customerClass_list = res.data
            }
          })
        }
      })
    },
    levelChange(value) {
      const choose = this.level_list.filter((item) => item.dictKey === value)
      if (choose.length > 0 && choose !== null) {
        this.formobj.level = choose[0].dictValue
      } else {
        this.formobj.level = ''
      }
    },
    isOnRemindChange(val) {
      if (val === '是') {
        this.formobj.isOnRemindKey = '1'
      } else if (val === '否') {
        this.formobj.isOnRemindKey = '0'
      }
    },
    sexChange(value) {
      const choose = this.sex_list.filter((item) => item.dictValue === value)
      if (choose.length > 0 && choose !== null) {
        this.formobj.sexKey = choose[0].dictKey
      }
    },
    sourceChange(value) {
      const choose = this.source_list.filter((item) => item.dictKey === value)
      if (choose.length > 0 && choose !== null) {
        this.formobj.source = choose[0].dictValue
      } else {
        this.formobj.source = ''
      }
    },
    customerClassChange(value) {
      const choose = this.customerClass_list.filter((item) => item.dictKey === value)
      if (choose.length > 0 && choose !== null) {
        this.formobj.customerClass = choose[0].dictValue
      } else {
        this.formobj.customerClass = ''
      }
    },
    saveOrUpdate() {
      this.$refs['form_obj'].validate((valid) => {
        if (valid) {
          if (this.formobj.customerType === '企业' && this.formobj.name.length < 5) {
            this.$message({ showClose: true, type: 'error', message: '因客户类型为企业,客户名称的长度应不少于5个汉字' })
            return
          }
          this.submitdisabled = true
          req.saveCustomerVeh(this.formobj).then((res) => {
            if (res.success) {
              this.$message({ showClose: true, type: 'success', message: '保存成功' })
              this.handleReturn('true')
            } else {
              this.submitdisabled = false
            }
          }).catch(() => {
            this.submitdisabled = false
          })
        }
      })
    },
    handleReturn(isreload) {
      if (isreload === 'true') this.$emit('reloadlist')
      this.formobj = {
        name: '',
        customerType: '',
        customerTypeKey: '',
        visitWay: '',
        visitWayKey: '',
        mobile: '',
        weixin: '',
        province: '',
        city: '',
        county: '',
        address: '',
        level: '',
        levelKey: '',
        isOnRemind: '',
        isOnRemindKey: '',
        remind_day: '',
        remind_remark: '',
        birthday: '',
        sex: '',
        sexKey: '',
        certificateType: '',
        certificateTypeKey: '',
        idnumber: '',
        endDate: '',
        e_mail: '',
        emergencyContact: '',
        emergencyMobile: '',
        source: '',
        sourceKey: '',
        customerClass: '',
        customerClassKey: '',
        remarks: '',
        userSid: '',
        orgPath: '',
        useOrgSid: '',
        sid: '',
        customerOrgName: '',
        customerOrgSid: ''
      }
      this.submitdisabled = false
      this.$emit('doback')
    }
  }
}
</script>

<style scoped>
.span-sty {
  width: 130px !important;
}
.addinputInfo {
  margin-left: 120px !important;
}
.formaddcopy02 .el-row .el-col /deep/ .el-form-item .addinputw {
  margin-left: 120px !important;
  width: calc(100% - 115px);
}
/deep/ .el-form-item__error {
  margin-left: 120px !important;
}
.formaddcopy02 .el-row .el-col /deep/ .el-form-item .el-radio-group {
  display: inline;
  line-height: 1px;
  vertical-align: middle;
}
</style>
