IndividualAuthenticationCreate.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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="file" 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="name">
  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="name">
  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="name">
  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. getProvinceCodeByProvinceName,
  58. getProvinceNameByProvinceCode,
  59. storageGet,
  60. } from '@/js/index'
  61. export default {
  62. name: 'IndividualAuthenticationCreate',
  63. data () {
  64. return {
  65. userId: 0,
  66. user: {},
  67. isModifyMode: true,
  68. loading: false,
  69. authentication: {
  70. IDCardPhoto: '',
  71. realName: '',
  72. IDCard: '',
  73. bankAccount: '',
  74. address: '',
  75. },
  76. rules: {
  77. // name: [
  78. // {required: true, message: '请输入报告名称', trigger: 'blur'}
  79. // // { min: 3, max: 5, message: "长度在 3 到 5 个字符", trigger: "blur" }
  80. // ],
  81. // abstract: [
  82. // {
  83. // required: true,
  84. // message: '请输入摘要信息',
  85. // trigger: 'change'
  86. // }
  87. // ],
  88. // type: [
  89. // {required: true, message: '请选择报告类型', trigger: 'change'}
  90. // ],
  91. // conclusion: [
  92. // {required: true, message: '请输入报告结论', trigger: 'blur'}
  93. // ]
  94. }
  95. }
  96. },
  97. mounted () {
  98. this.$nextTick(() => {
  99. this.init()
  100. })
  101. },
  102. methods: {
  103. //初始化数据
  104. init () {
  105. this.setUserInfo()
  106. },
  107. //加载数据
  108. loadData: function () {
  109. },
  110. //表单进入可编辑状态,可修改表单,不再使用
  111. modifyInfo () {
  112. this.isModifyMode = true
  113. },
  114. //提交认证信息
  115. submitInfo () {
  116. //this.isModifyMode = false
  117. this.showLoading()
  118. const newAuthentication = {
  119. userId: this.user.userVO.id,
  120. realName: this.authentication.realName,
  121. IDCard: this.authentication.IDCard,
  122. IDCardPhoto: this.authentication.IDCardPhoto,
  123. bankAccount: this.authentication.bankAccount,
  124. address: this.authentication.address
  125. }
  126. Http.post(Apis.USER.SUBMIT_INDIVIDUAL_AUTHENTICATION_INFO.replace('{userId}', this.user.userVO.id), newAuthentication).then((res) => {
  127. this.hideLoading()
  128. console.log(res)
  129. notify('success', '认证信息上传成功')
  130. }).catch(error => {
  131. this.hideLoading()
  132. notify('error', error.data)
  133. })
  134. },
  135. //取消修改表单,表单进入不可编辑状态,不再使用
  136. cancelModify () {
  137. this.isModifyMode = false
  138. },
  139. //上传文件时移除文件的响应函数
  140. handleRemove (file, fileList) {
  141. console.log(file, fileList)
  142. },
  143. //添加文件时的响应函数
  144. handleExceed (files, fileList) {
  145. this.$message.warning(
  146. `当前限制选择 1 个文件,本次选择了 ${
  147. files.length
  148. } 个文件,共选择了 ${files.length + fileList.length} 个文件`
  149. )
  150. },
  151. //移除文件前的响应函数
  152. beforeRemove (file, fileList) {
  153. //return this.$confirm(`确定移除 ${file.name}?`)
  154. },
  155. //文件上传前的响应函数
  156. beforeFileUpload () {
  157. },
  158. //上传文件,此处为上传图片
  159. uploadFile (param) {
  160. this.showLoading()
  161. const formData = new FormData()
  162. let config = {
  163. //添加请求头
  164. headers: {'Content-Type': 'multipart/form-data'},
  165. }
  166. formData.append('file', param.file)
  167. Http.upload(Apis.FILE.UPLOAD_IMAGE.replace('{userId}', this.user.userVO.id), formData, config).then((res) => {
  168. this.hideLoading()
  169. console.log('上传成功')
  170. this.authentication.IDCardPhoto = res.data
  171. console.log(res.data)
  172. notify('success', '上传成功')
  173. }).catch(error => {
  174. this.hideLoading()
  175. notify('error', error.data.msg)
  176. })
  177. },
  178. //
  179. setUserInfo () {
  180. this.user = storageGet('user')
  181. },
  182. showLoading () {
  183. this.loading = true
  184. },
  185. hideLoading () {
  186. this.loading = false
  187. }
  188. },
  189. created: function () {
  190. }
  191. }
  192. </script>
  193. <style scoped>
  194. .el-radio {
  195. margin: 10px 20px 10px 0;
  196. }
  197. .el-form-item /deep/ .el-tabs__content {
  198. max-height: 120px !important;
  199. overflow: auto;
  200. }
  201. .el-row {
  202. margin-bottom: 10px;
  203. }
  204. .el-input {
  205. width: 400px;
  206. }
  207. .avatar-uploader .el-upload {
  208. border: 1px dashed #d9d9d9;
  209. border-radius: 6px;
  210. cursor: pointer;
  211. position: relative;
  212. overflow: hidden;
  213. }
  214. .avatar-uploader .el-upload:hover {
  215. border-color: #409EFF;
  216. }
  217. .avatar-uploader-icon {
  218. border: 1px dashed #d9d9d9;
  219. border-radius: 6px;
  220. font-size: 28px;
  221. color: #8c939d;
  222. width: 176px;
  223. height: 178px;
  224. line-height: 178px;
  225. text-align: center;
  226. }
  227. .avatar-uploader-icon:hover {
  228. border-color: #409EFF;
  229. }
  230. .avatar {
  231. width: 178px;
  232. height: 178px;
  233. display: block;
  234. }
  235. </style>