IndividualAuthenticationCreate.vue 9.4 KB

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