优化代码handlerAddConfirm let rules = name fun required message 请输入油站名称 type fun required message 请选择站点类型 groupId fun required message 请选择所属集团 provinceId fun requ
优化代码handlerAddConfirm() { let rules = { name: [{ fun: 'required', message: '请输入油站名称' }], type: [{ fun: 'required', message: '请选择站点类型' }], groupId: [{ fun: 'required', message: '请选择所属集团' }], provinceId: [{ fun: 'required', message: '请选择省份' }], cityId: [{ fun: 'required', message: '请选择城市' }], regionId: [{ fun: 'required', message: '请选择区/县' }], address: [{ fun: 'required', message: '请输入详细地址' }], responsiblePerson: [{ fun: 'required', message: '请输入联系人' }], tel: [{ fun: 'required', message: '请输入联系电话' }, { fun: 'checkPhone', message: '联系电话不正确' }], businessLicenseName: [{ fun: 'required', message: '请输入营业执照名称' }], } let params = { name: this.addOilStationInfo.name, type: this.addOilStationInfo.type, groupId: this.addOilStationInfo.groupId, provinceId: this.addOilStationInfo.provinceId, cityId: this.addOilStationInfo.cityId, regionId: this.addOilStationInfo.regionId, responsiblePerson: this.addOilStationInfo.responsiblePerson, tel: this.addOilStationInfo.tel, address: this.addOilStationInfo.address, businessLicenseName: this.addOilStationInfo.businessLicenseName, }
const requiredDocs = ['businessLicenseId', 'accountOpeningPermit', 'productOilRetailCertificate', 'idCardFront', 'idCardOpposite']
requiredDocs.forEach(doc => {
if (this.addOilStationInfo[doc] && JSON.parse(this.addOilStationInfo[doc]).uuid) {
params[doc] = JSON.parse(this.addOilStationInfo[doc]).uuid
}
})
if (this.$validate.validateForm(rules, this.addOilStationInfo)) {
this.$http.post('/oilStation/Info/saveOrUpdateOilStationInfo', params).then((res) => {
this.addOilStationInfo = {}
this.$message.success('新增成功!')
this.showType = 'init'
this.getList()
})
}
}
原文地址: https://www.cveoy.top/t/topic/eb2o 著作权归作者所有。请勿转载和采集!