EnterpriseAuthenticationCreate.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <template>
  2. <div class="create-container" v-loading="loading">
  3. <div class="create-body">
  4. <div class="title">企业信息认证</div>
  5. <el-form :model="authentication" :rules="rules" ref="authentication" label-width="15%" class="demo-report">
  6. <el-form-item label="公司名" prop="enterpriseName">
  7. <el-input size="small" v-if="isModifyMode" v-model="authentication.enterpriseName"></el-input>
  8. <!--<span v-if="!isModifyMode">{{authentication.name}}</span>-->
  9. </el-form-item>
  10. <el-form-item label="公司营业执照" prop="businessLicensePhoto">
  11. <el-upload
  12. class="avatar-uploader"
  13. action="https://jsonplaceholder.typicode.com/posts/"
  14. :show-file-list="false"
  15. :http-request="uploadFile"
  16. :before-upload="beforeFileUpload">
  17. <img v-if="authentication.businessLicensePhoto" :src="authentication.businessLicensePhoto" class="avatar">
  18. <i v-else class="el-icon-plus avatar-uploader-icon"></i>
  19. </el-upload>
  20. <!--<div v-if="!isModifyMode">-->
  21. <!--<span v-if="authentication.photo==null">暂无文件</span>-->
  22. <!--<a :href="authentication.photo" v-if="authentication.photo!=null"><i class="fa fa-file-text-o"></i>-->
  23. <!--{{authentication.photo}}</a>-->
  24. <!--</div>-->
  25. </el-form-item>
  26. <el-form-item label="公司法人姓名" prop="legalPersonName">
  27. <el-input size="small" v-if="isModifyMode" v-model="authentication.legalPersonName"></el-input>
  28. <!--<span v-if="!isModifyMode">{{authentication.name}}</span>-->
  29. </el-form-item>
  30. <el-form-item label="对公账户" prop="bankAccount">
  31. <el-input size="small" v-if="isModifyMode" v-model="authentication.bankAccount"></el-input>
  32. <!--<span v-if="!isModifyMode">{{authentication.name}}</span>-->
  33. </el-form-item>
  34. <el-form-item label="统一社会信用代码" prop="unifiedSocialCreditCode">
  35. <el-input size="small" v-if="isModifyMode" v-model="authentication.unifiedSocialCreditCode"></el-input>
  36. <!--<span v-if="!isModifyMode">{{authentication.bankAccount}}</span>-->
  37. </el-form-item>
  38. <el-form-item label="公司地址" prop="address">
  39. <el-input size="small" v-if="isModifyMode" v-model="authentication.address"></el-input>
  40. <!--<span v-if="!isModifyMode">{{authentication.address}}</span>-->
  41. </el-form-item>
  42. <!--<el-form-item v-if="!isModifyMode">-->
  43. <!--<div class="btn btn-medium btn-info" @click="modifyInfo()">修改</div>-->
  44. <!--<div class="btn btn-medium" @click="cancelModify()">返回</div>-->
  45. <!--</el-form-item>-->
  46. <el-form-item v-if="isModifyMode">
  47. <div class="btn btn-primary btn-info" @click="submitInfo()">提交</div>
  48. <!--<div class="btn btn-primary" @click="cancelModify()">取消</div>-->
  49. </el-form-item>
  50. </el-form>
  51. </div>
  52. </div>
  53. </template>
  54. <script>
  55. import Http from '@/js/http'
  56. import Apis from '@/js/api'
  57. import {notify} from '@/constants/index'
  58. import {
  59. getCurrentUser,
  60. getRolesPermissions,
  61. storageGet,
  62. storageSave,
  63. uploadEnterpriseAuthenticationInfo
  64. } from '@/js/index'
  65. export default {
  66. name: 'EnterpriseAuthenticationCreate',
  67. data () {
  68. return {
  69. userId: 0,
  70. user: {},
  71. isModifyMode: true,
  72. loading: false,
  73. authentication: {
  74. enterpriseName: '',
  75. legalPersonName: '',
  76. bankAccount: '',
  77. businessLicensePhoto: '',
  78. unifiedSocialCreditCode: '',
  79. address: ''
  80. },
  81. rules: {
  82. enterpriseName: [
  83. {required: true, message: '请输入公司名称', trigger: 'blur'},
  84. {min: 3, max: 50, message: '机构名称长度在 3 到 50 个字符', trigger: 'blur'}
  85. ],
  86. businessLicensePhoto: [
  87. {
  88. validator: (rule, value, callback) => {
  89. console.log(value)
  90. if (value == null || value == '') {
  91. callback(new Error('公司营业执照不能为空'))
  92. } else {
  93. callback()
  94. }
  95. },
  96. trigger: 'blue'
  97. },
  98. ],
  99. legalPersonName: [
  100. {required: true, message: '请输入公司法人姓名', trigger: 'blur'}
  101. ],
  102. bankAccount: [
  103. {required: true, message: '请输入对公账户', trigger: 'blur'},
  104. {
  105. validator: (rule, value, callback) => {
  106. if (!this.checkNumber(value)) {
  107. callback(new Error('对公账户输入有误'))
  108. } else {
  109. callback()
  110. }
  111. },
  112. trigger: 'blur'
  113. },
  114. ],
  115. unifiedSocialCreditCode: [
  116. {required: true, message: '请输入统一社会信用代码', trigger: 'blur'},
  117. {
  118. validator: (rule, value, callback) => {
  119. if (!this.checkNumberAndWord(value)) {
  120. callback(new Error('统一社会信用代码输入有误'))
  121. } else {
  122. callback()
  123. }
  124. }, trigger: 'blur'
  125. },
  126. ],
  127. address: [
  128. {required: true, message: '请输入公司地址', trigger: 'blur'}
  129. ]
  130. }
  131. }
  132. },
  133. mounted () {
  134. this.$nextTick(() => {
  135. this.init()
  136. })
  137. },
  138. methods: {
  139. //初始化数据
  140. init () {
  141. this.setUserInfo()
  142. },
  143. //加载数据
  144. loadData: function () {
  145. },
  146. //表单进入可编辑状态,可修改表单,不再使用
  147. modifyInfo () {
  148. this.isModifyMode = true
  149. },
  150. //提交认证信息
  151. submitInfo () {
  152. //this.isModifyMode = false
  153. this.$refs['authentication'].validate(valid => {
  154. if (valid) {
  155. this.showLoading()
  156. const newAuthentication = {
  157. userId: this.user.userVO.id,
  158. enterpriseName: this.authentication.enterpriseName,
  159. legalPersonName: this.authentication.legalPersonName,
  160. businessLicensePhoto: this.authentication.businessLicensePhoto,
  161. unifiedSocialCreditCode: this.authentication.unifiedSocialCreditCode,
  162. bankAccount: this.authentication.bankAccount,
  163. address: this.authentication.address,
  164. }
  165. uploadEnterpriseAuthenticationInfo(this.user.userVO.id, newAuthentication, this.submitInfoSuccess, this.submitInfoFail)
  166. } else {
  167. notify('error', '表单填写错误!')
  168. return false
  169. }
  170. })
  171. },
  172. submitInfoSuccess (res) {
  173. // this.hideLoading()
  174. console.log(res)
  175. getCurrentUser().then(res => {
  176. storageSave('user', res)
  177. this.user = res
  178. this.sendBusMessage()
  179. //this.rolesPermissions = getRolesPermissions(res.roleList)
  180. storageSave('rolesPermissions', getRolesPermissions(res.roleList))
  181. this.hideLoading()
  182. //notify('success', '用户信息刷新成功')
  183. this.$alert('认证信息提交成功,将于3个工作日内审核完成', '提交成功', {
  184. confirmButtonText: '确定',
  185. callback: action => {
  186. this.$router.push({
  187. name: 'EnterpriseAuthentication',
  188. params: {userId: this.user.userVO.id}
  189. })
  190. }
  191. });
  192. // .catch(_ => {
  193. // this.$router.push({
  194. // name: 'EnterpriseAuthentication',
  195. // params: {userId: this.user.userVO.id}
  196. // })
  197. // })
  198. }).catch((error) => {
  199. this.hideLoading()
  200. notify('error', '重新获取用户信息失败:' + error.data)
  201. })
  202. },
  203. submitInfoFail (error) {
  204. this.hideLoading()
  205. notify('error', error.data)
  206. },
  207. //取消修改表单,表单进入不可编辑状态,不再使用
  208. cancelModify () {
  209. this.isModifyMode = false
  210. },
  211. //上传文件时移除文件的响应函数
  212. handleRemove (file, fileList) {
  213. console.log(file, fileList)
  214. },
  215. //添加文件时的响应函数
  216. handleExceed (files, fileList) {
  217. this.$message.warning(
  218. `当前限制选择 1 个文件,本次选择了 ${
  219. files.length
  220. } 个文件,共选择了 ${files.length + fileList.length} 个文件`
  221. )
  222. },
  223. //移除文件前的响应函数
  224. beforeRemove (file, fileList) {
  225. //return this.$confirm(`确定移除 ${file.name}?`)
  226. },
  227. //文件上传前的响应函数
  228. beforeFileUpload () {
  229. },
  230. //上传文件,此处为上传图片
  231. uploadFile (param) {
  232. this.showLoading()
  233. const formData = new FormData()
  234. let config = {
  235. //添加请求头
  236. headers: {'Content-Type': 'multipart/form-data'},
  237. }
  238. formData.append('file', param.file)
  239. Http.upload(Apis.FILE.UPLOAD_IMAGE.replace('{userId}', this.user.userVO.id), formData, config).then((res) => {
  240. this.hideLoading()
  241. console.log('上传成功')
  242. this.authentication.businessLicensePhoto = res.data
  243. console.log(res.data)
  244. notify('success', '上传成功')
  245. this.$refs['authentication'].validateField('businessLicensePhoto')
  246. }).catch(error => {
  247. this.hideLoading()
  248. notify('error', error.data)
  249. })
  250. },
  251. //
  252. setUserInfo () {
  253. this.user = storageGet('user')
  254. },
  255. //测试用函数
  256. test () {
  257. },
  258. showLoading () {
  259. this.loading = true
  260. },
  261. hideLoading () {
  262. this.loading = false
  263. },
  264. sendBusMessage () {
  265. this.$root.$emit('user', this.user)
  266. },
  267. checkNumber (value) {
  268. return /^\d+$/.test(value)
  269. },
  270. checkNumberAndWord (value) {
  271. return /^[^_IOZSVa-z\W]{2}\d{6}[^_IOZSVa-z\W]{10}$/g.test(value) || /^[A-Za-z0-9]\w{14}$/g.test(value)
  272. }
  273. },
  274. }
  275. </script>
  276. <style scoped>
  277. .el-radio {
  278. margin: 10px 20px 10px 0;
  279. }
  280. .el-form-item /deep/ .el-tabs__content {
  281. max-height: 120px !important;
  282. overflow: auto;
  283. }
  284. .el-row {
  285. margin-bottom: 10px;
  286. }
  287. .el-input {
  288. width: 400px;
  289. }
  290. .avatar-uploader .el-upload {
  291. border: 1px dashed #d9d9d9;
  292. border-radius: 6px;
  293. cursor: pointer;
  294. position: relative;
  295. overflow: hidden;
  296. }
  297. .avatar-uploader .el-upload:hover {
  298. border-color: #409EFF;
  299. }
  300. .avatar-uploader-icon {
  301. border: 1px dashed #d9d9d9;
  302. border-radius: 6px;
  303. font-size: 28px;
  304. color: #8c939d;
  305. width: 176px;
  306. height: 178px;
  307. line-height: 178px;
  308. text-align: center;
  309. }
  310. .avatar-uploader-icon:hover {
  311. border-color: #409EFF;
  312. }
  313. .avatar {
  314. width: 178px;
  315. height: 178px;
  316. display: block;
  317. }
  318. </style>