personal.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <!-- 个人资料 -->
  3. <view>
  4. <u-navbar title="个人资料" autoBack placeholder></u-navbar>
  5. <view class="card_form">
  6. <x-form ref="personage" :userType="userType" :list="list" :model="model" :rules="rules" @confirm="confirm"
  7. @clientele="clientele"></x-form>
  8. </view>
  9. </view>
  10. </template>
  11. <script>
  12. export default {
  13. data() {
  14. return {
  15. list: [{
  16. field: 'name',
  17. label: '姓名',
  18. placeholder: '请输入姓名',
  19. type: 'input',
  20. disabled: true,
  21. required: true,
  22. }, {
  23. field: 'idCard',
  24. label: '身份证号',
  25. placeholder: '请输入身份证号',
  26. type: 'input',
  27. disabled: true,
  28. required: true,
  29. }, {
  30. field: 'phone',
  31. label: '电话',
  32. placeholder: '请输入电话',
  33. type: 'input',
  34. required: true,
  35. }, {
  36. field: 'description',
  37. label: '备注',
  38. placeholder: '请输入备注',
  39. type: 'textarea',
  40. }, {
  41. field: 'line',
  42. label: '《燃气从业资格证》信息',
  43. type: 'line',
  44. }, {
  45. field: 'lines',
  46. label: '《道路运输从业人员从业资格证》信息',
  47. type: 'line',
  48. }, {
  49. field: 'certificateNo',
  50. label: '证书编号',
  51. placeholder: '请输入证书编号',
  52. type: 'input',
  53. required: true,
  54. }, {
  55. field: 'issueAuthority',
  56. label: '发证机关',
  57. placeholder: '请输入发证机关',
  58. type: 'input',
  59. required: true,
  60. }, {
  61. field: 'remarks',
  62. label: '备注',
  63. placeholder: '请输入备注',
  64. type: 'textarea',
  65. }, {
  66. field: 'imgUrl',
  67. label: '燃气从业资格证',
  68. placeholder: '请上传燃气从业资格证',
  69. type: 'upload',
  70. required: true,
  71. }, {
  72. field: 'imgUrls',
  73. label: '道路运输从业人员从业资格证',
  74. placeholder: '请上传道路运输从业人员从业资格证',
  75. type: 'upload',
  76. required: true,
  77. }],
  78. model: {
  79. name: '',
  80. idCard: '',
  81. phone: '',
  82. description: '',
  83. certificateNo: '',
  84. issueAuthority: '',
  85. remarks: '',
  86. imgUrl: '',
  87. imgUrls: '',
  88. },
  89. rules: {
  90. 'name': {
  91. type: 'string',
  92. required: true,
  93. message: '请输入姓名',
  94. trigger: ['blur', 'change']
  95. },
  96. 'idCard': {
  97. type: 'string',
  98. required: true,
  99. message: '请输入身份证号码',
  100. trigger: ['blur', 'change']
  101. },
  102. 'phone': {
  103. type: 'string',
  104. required: true,
  105. message: '请输入电话号码',
  106. trigger: ['blur', 'change']
  107. },
  108. 'certificateNo': {
  109. type: 'string',
  110. required: true,
  111. message: '请输入证书编号',
  112. trigger: ['blur', 'change']
  113. },
  114. 'issueAuthority': {
  115. type: 'string',
  116. required: true,
  117. message: '请输入发证机关',
  118. trigger: ['blur', 'change']
  119. },
  120. 'imgUrl': {
  121. type: 'string',
  122. required: true,
  123. message: '请上传燃气从业资格证',
  124. trigger: ['blur', 'change']
  125. },
  126. },
  127. userInfo: {},
  128. userType: 5,
  129. }
  130. },
  131. mounted() {
  132. this.getUser()
  133. },
  134. methods: {
  135. getUser() {
  136. this.$api.get('/api/user/profile').then(res => {
  137. if (res.code == 200) {
  138. const param = res.data.user
  139. this.userInfo = param
  140. this.$nextTick(() => {
  141. this.userType = param.provUser.userType
  142. this.list.forEach(value => {
  143. if (this.userType == 3) {
  144. if (value.field == 'imgUrls' || value.field == 'lines') {
  145. value.visible = true
  146. }
  147. } else if (this.userType == 4) {
  148. if (value.field == 'imgUrl' || value.field == 'line') {
  149. value.visible = true
  150. }
  151. } else {
  152. if (value.field == 'imgUrl' || value.field == 'imgUrls' ||
  153. value.field == 'line' || value.field == 'lines' || value
  154. .field == 'certificateNo' ||
  155. value.field == 'issueAuthority' || value.field ==
  156. 'issueAuthority' || value.field == 'remarks') {
  157. value.visible = true
  158. }
  159. }
  160. })
  161. this.model.name = param.provUser.name
  162. this.model.idCard = param.provUser.idCard
  163. this.model.phone = param.provUser.phone
  164. this.model.description = param.provUser.description
  165. if (this.userType == 3) {
  166. this.model.certificateNo = param.provStoreUserBindCertificate.certificateNo
  167. this.model.issueAuthority = param.provStoreUserBindCertificate
  168. .issueAuthority
  169. this.model.imgUrl = param.provStoreUserBindCertificate.imgUrl
  170. if (param.provStoreUserBindCertificate.remarks) {
  171. this.model.remarks = param.provStoreUserBindCertificate.remarks
  172. } else {
  173. this.model.remarks = ''
  174. }
  175. } else if (this.userType == 4) {
  176. this.model.certificateNo = param.provTruckUserBindCertificate.certificateNo
  177. this.model.issueAuthority = param.provTruckUserBindCertificate
  178. .issueAuthority
  179. this.model.imgUrls = param.provTruckUserBindCertificate.imgUrl
  180. if (param.provTruckUserBindCertificate.remarks) {
  181. this.model.remarks = param.provTruckUserBindCertificate.remarks
  182. } else {
  183. this.model.remarks = ''
  184. }
  185. }
  186. let arrImg = []
  187. let arrImg1 = []
  188. if (param.provStoreUserBindCertificate.imgUrl && this.userType == 3) {
  189. arrImg = param.provStoreUserBindCertificate.imgUrl.split(',')
  190. } else if (param.provTruckUserBindCertificate.imgUrl && this.userType == 4) {
  191. arrImg = param.provTruckUserBindCertificate.imgUrl.split(',')
  192. }
  193. arrImg.forEach(item => {
  194. let arr = {
  195. thumb: this.$baseUrl + item,
  196. url: item,
  197. }
  198. arrImg1.push(arr)
  199. })
  200. this.$refs.personage.fileList1 = arrImg1
  201. })
  202. // console.log(this.model, 26)
  203. }
  204. })
  205. },
  206. // 修改个人信息
  207. clientele() {
  208. let param = {
  209. id: this.userInfo.id,
  210. roleId: this.userInfo.roleId,
  211. provUser: {
  212. name: this.model.name,
  213. cmpCode: this.model.cmpCode,
  214. phone: this.model.phone,
  215. description: this.model.description,
  216. },
  217. provStoreUserBindCertificate: {
  218. certificateNo: this.model.certificateNo,
  219. issueAuthority: this.model.issueAuthority,
  220. imgUrl: this.model.imgUrl,
  221. remarks: this.model.remarks,
  222. },
  223. provTruckUserBindCertificate: {
  224. certificateNo: this.model.certificateNo,
  225. issueAuthority: this.model.issueAuthority,
  226. imgUrl: this.model.imgUrls,
  227. remarks: this.model.remarks,
  228. }
  229. }
  230. if (this.userType == 3) {
  231. delete param.provTruckUserBindCertificate
  232. } else if (this.userType == 4) {
  233. delete param.provStoreUserBindCertificate
  234. }
  235. this.$api.put('/api/sys-user', param).then(res => {
  236. if (res.code == 200) {
  237. this.getUser()
  238. uni.$u.toast(res.msg)
  239. }
  240. })
  241. }
  242. }
  243. }
  244. </script>
  245. <style lang="scss">
  246. .card_form {
  247. margin: 10rpx 40rpx;
  248. }
  249. </style>