personal.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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.getLayout()
  133. this.getUser()
  134. },
  135. methods: {
  136. getLayout(){
  137. this.list.forEach(value => {
  138. if (this.userType == 3) {
  139. if (value.field == 'imgUrls' || value.field == 'lines') {
  140. value.visible = true
  141. }
  142. } else if (this.userType == 4) {
  143. if (value.field == 'imgUrl' || value.field == 'line') {
  144. value.visible = true
  145. }
  146. } else {
  147. if (value.field == 'imgUrl' || value.field == 'imgUrls' ||
  148. value.field == 'line' || value.field == 'lines' || value
  149. .field == 'certificateNo' ||
  150. value.field == 'issueAuthority' || value.field ==
  151. 'issueAuthority' || value.field == 'remarks') {
  152. value.visible = true
  153. }
  154. }
  155. })
  156. },
  157. getUser() {
  158. this.$api.get('/api/user/profile').then(res => {
  159. if (res.code == 200) {
  160. const param = res.data.user
  161. this.userInfo = param
  162. this.$nextTick(() => {
  163. this.userType = param.provUser.userType
  164. this.getLayout()
  165. this.model.name = param.provUser.name
  166. this.model.idCard = param.provUser.idCard
  167. this.model.phone = param.provUser.phone
  168. this.model.description = param.provUser.description
  169. if (this.userType == 3) {
  170. this.model.certificateNo = param.provStoreUserBindCertificate.certificateNo
  171. this.model.issueAuthority = param.provStoreUserBindCertificate
  172. .issueAuthority
  173. this.model.imgUrl = param.provStoreUserBindCertificate.imgUrl
  174. if (param.provStoreUserBindCertificate.remarks) {
  175. this.model.remarks = param.provStoreUserBindCertificate.remarks
  176. } else {
  177. this.model.remarks = ''
  178. }
  179. } else if (this.userType == 4) {
  180. this.model.certificateNo = param.provTruckUserBindCertificate.certificateNo
  181. this.model.issueAuthority = param.provTruckUserBindCertificate
  182. .issueAuthority
  183. this.model.imgUrls = param.provTruckUserBindCertificate.imgUrl
  184. if (param.provTruckUserBindCertificate.remarks) {
  185. this.model.remarks = param.provTruckUserBindCertificate.remarks
  186. } else {
  187. this.model.remarks = ''
  188. }
  189. }
  190. let arrImg = []
  191. let arrImg1 = []
  192. if (param.provStoreUserBindCertificate.imgUrl && this.userType == 3) {
  193. arrImg = param.provStoreUserBindCertificate.imgUrl.split(',')
  194. } else if (param.provTruckUserBindCertificate.imgUrl && this.userType == 4) {
  195. arrImg = param.provTruckUserBindCertificate.imgUrl.split(',')
  196. }
  197. arrImg.forEach(item => {
  198. let arr = {
  199. thumb: this.$baseUrl + item,
  200. url: item,
  201. }
  202. arrImg1.push(arr)
  203. })
  204. this.$refs.personage.fileList1 = arrImg1
  205. })
  206. // console.log(this.model, 26)
  207. }
  208. })
  209. },
  210. // 修改个人信息
  211. clientele() {
  212. let param = {
  213. id: this.userInfo.id,
  214. roleId: this.userInfo.roleId,
  215. provUser: {
  216. name: this.model.name,
  217. cmpCode: this.model.cmpCode,
  218. phone: this.model.phone,
  219. description: this.model.description,
  220. },
  221. provStoreUserBindCertificate: {
  222. certificateNo: this.model.certificateNo,
  223. issueAuthority: this.model.issueAuthority,
  224. imgUrl: this.model.imgUrl,
  225. remarks: this.model.remarks,
  226. },
  227. provTruckUserBindCertificate: {
  228. certificateNo: this.model.certificateNo,
  229. issueAuthority: this.model.issueAuthority,
  230. imgUrl: this.model.imgUrls,
  231. remarks: this.model.remarks,
  232. }
  233. }
  234. if (this.userType == 3) {
  235. delete param.provTruckUserBindCertificate
  236. } else if (this.userType == 4) {
  237. delete param.provStoreUserBindCertificate
  238. }
  239. this.$api.put('/api/sys-user', param).then(res => {
  240. if (res.code == 200) {
  241. this.getUser()
  242. uni.$u.toast(res.msg)
  243. }
  244. })
  245. }
  246. }
  247. }
  248. </script>
  249. <style lang="scss">
  250. .card_form {
  251. margin: 10rpx 40rpx;
  252. }
  253. </style>