personal.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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"
  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. inputType: 'idcard',
  28. disabled: true,
  29. required: true,
  30. }, {
  31. field: 'phone',
  32. label: '电话',
  33. placeholder: '请输入电话',
  34. type: 'input',
  35. inputType: 'number',
  36. required: true,
  37. }, {
  38. field: 'description',
  39. label: '备注',
  40. placeholder: '请输入备注',
  41. type: 'textarea',
  42. }, {
  43. field: 'line',
  44. label: '《燃气从业资格证》信息',
  45. type: 'line',
  46. }, {
  47. field: 'lines',
  48. label: '《道路运输从业人员从业资格证》信息',
  49. type: 'line',
  50. }, {
  51. field: 'certificateNo',
  52. label: '证书编号',
  53. placeholder: '请输入证书编号',
  54. type: 'input',
  55. required: true,
  56. }, {
  57. field: 'issueAuthority',
  58. label: '发证机关',
  59. placeholder: '请输入发证机关',
  60. type: 'input',
  61. required: true,
  62. }, {
  63. field: 'remarks',
  64. label: '备注',
  65. placeholder: '请输入备注',
  66. type: 'textarea',
  67. }, {
  68. field: 'imgUrl',
  69. label: '燃气从业资格证',
  70. placeholder: '请上传燃气从业资格证',
  71. type: 'upload',
  72. required: true,
  73. }, {
  74. field: 'imgUrls',
  75. label: '道路运输从业人员从业资格证',
  76. placeholder: '请上传道路运输从业人员从业资格证',
  77. type: 'upload',
  78. required: true,
  79. }],
  80. model: {
  81. name: '',
  82. idCard: '',
  83. phone: '',
  84. description: '',
  85. certificateNo: '',
  86. issueAuthority: '',
  87. remarks: '',
  88. imgUrl: '',
  89. imgUrls: '',
  90. },
  91. rules: {
  92. 'name': {
  93. type: 'string',
  94. required: true,
  95. message: '请输入姓名',
  96. trigger: ['blur', 'change']
  97. },
  98. 'idCard': {
  99. type: 'string',
  100. required: true,
  101. message: '请输入身份证号码',
  102. trigger: ['blur', 'change']
  103. },
  104. 'phone': [{
  105. required: true,
  106. message: '请输入电话号码',
  107. trigger: ['blur', "change"]
  108. }, {
  109. // 自定义验证函数,见上说明
  110. pattern: /^1(3|4|5|6|7|8|9)\d{9}$/,
  111. message: '手机号码不正确',
  112. // 触发器可以同时用blur和change
  113. trigger: ['blur'],
  114. }],
  115. 'certificateNo': {
  116. type: 'string',
  117. required: true,
  118. message: '请输入证书编号',
  119. trigger: ['blur', 'change']
  120. },
  121. 'issueAuthority': {
  122. type: 'string',
  123. required: true,
  124. message: '请输入发证机关',
  125. trigger: ['blur', 'change']
  126. },
  127. 'imgUrl': {
  128. type: 'string',
  129. required: true,
  130. message: '请上传燃气从业资格证',
  131. trigger: ['blur', 'change']
  132. },
  133. 'imgUrls': {
  134. type: 'string',
  135. required: true,
  136. message: '请上传燃气从业资格证',
  137. trigger: ['blur', 'change']
  138. },
  139. },
  140. userInfo: {},
  141. userType: 5,
  142. }
  143. },
  144. onLoad() {
  145. this.getLayout()
  146. },
  147. mounted() {
  148. this.getUser()
  149. },
  150. methods: {
  151. getLayout() {
  152. this.list.forEach(value => {
  153. if (this.userType == 3) {
  154. if (value.field == 'imgUrls' || value.field == 'lines') {
  155. value.visible = true
  156. } else {
  157. value.visible = false
  158. }
  159. } else if (this.userType == 4) {
  160. if (value.field == 'imgUrl' || value.field == 'line') {
  161. value.visible = true
  162. } else {
  163. value.visible = false
  164. }
  165. } else {
  166. if (['imgUrl', 'imgUrls', 'line', 'lines', 'certificateNo', 'issueAuthority',
  167. 'issueAuthority', 'remarks',
  168. ].includes(value.field)) {
  169. value.visible = true
  170. } else {
  171. value.visible = false
  172. }
  173. }
  174. })
  175. },
  176. getUser() {
  177. this.$api.get('/api/user/profile').then(res => {
  178. if (res.code == 200) {
  179. const param = res.data.user
  180. this.userInfo = param
  181. this.$nextTick(() => {
  182. this.userType = param.provUser.userType
  183. this.getLayout()
  184. this.model.name = param.provUser.name
  185. this.model.idCard = param.provUser.idCard
  186. this.model.phone = param.provUser.phone
  187. this.model.description = param.provUser.description
  188. if (this.userType == 3) {
  189. this.model.certificateNo = param.provStoreUserBindCertificate.certificateNo
  190. this.model.issueAuthority = param.provStoreUserBindCertificate
  191. .issueAuthority
  192. this.model.imgUrl = param.provStoreUserBindCertificate.imgUrl
  193. if (param.provStoreUserBindCertificate.remarks) {
  194. this.model.remarks = param.provStoreUserBindCertificate.remarks
  195. } else {
  196. this.model.remarks = ''
  197. }
  198. } else if (this.userType == 4) {
  199. this.model.certificateNo = param.provTruckUserBindCertificate.certificateNo
  200. this.model.issueAuthority = param.provTruckUserBindCertificate
  201. .issueAuthority
  202. this.model.imgUrls = param.provTruckUserBindCertificate.imgUrl
  203. if (param.provTruckUserBindCertificate.remarks) {
  204. this.model.remarks = param.provTruckUserBindCertificate.remarks
  205. } else {
  206. this.model.remarks = ''
  207. }
  208. }
  209. let arrImg = []
  210. let arrImg1 = []
  211. if (param.provStoreUserBindCertificate.imgUrl && this.userType == 3) {
  212. arrImg = param.provStoreUserBindCertificate.imgUrl.split(',')
  213. } else if (param.provTruckUserBindCertificate.imgUrl && this.userType == 4) {
  214. arrImg = param.provTruckUserBindCertificate.imgUrl.split(',')
  215. }
  216. arrImg.forEach(item => {
  217. let arr = {
  218. thumb: this.$baseUrl + item,
  219. url: this.$baseUrl + item,
  220. }
  221. arrImg1.push(arr)
  222. })
  223. this.$refs.personage.fileList1 = arrImg1
  224. })
  225. // console.log(this.model, 26)
  226. }
  227. })
  228. },
  229. // 修改个人信息
  230. clientele() {
  231. let param = {
  232. id: this.userInfo.id,
  233. roleId: this.userInfo.roleId,
  234. provUser: {
  235. name: this.model.name,
  236. cmpCode: this.model.cmpCode,
  237. phone: this.model.phone,
  238. description: this.model.description,
  239. },
  240. provStoreUserBindCertificate: {
  241. certificateNo: this.model.certificateNo,
  242. issueAuthority: this.model.issueAuthority,
  243. imgUrl: this.model.imgUrl,
  244. remarks: this.model.remarks,
  245. },
  246. provTruckUserBindCertificate: {
  247. certificateNo: this.model.certificateNo,
  248. issueAuthority: this.model.issueAuthority,
  249. imgUrl: this.model.imgUrls,
  250. remarks: this.model.remarks,
  251. }
  252. }
  253. if (this.model.addressImg != undefined) {
  254. param.provTruckUserBindCertificate.imgUrl = this.model.addressImg
  255. }
  256. if (this.userType == 3) {
  257. delete param.provTruckUserBindCertificate
  258. } else if (this.userType == 4) {
  259. delete param.provStoreUserBindCertificate
  260. }
  261. uni.showLoading({
  262. mask: true,
  263. });
  264. uni.hideLoading();
  265. this.$api.put('/api/sys-user', param).then(res => {
  266. if (res.code == 200) {
  267. this.getUser()
  268. uni.$u.toast(res.msg)
  269. }
  270. uni.hideLoading();
  271. }).catch(() => {
  272. uni.hideLoading();
  273. })
  274. },
  275. eliminateImge(img) {
  276. let arr = img.split(',')
  277. console.log(img,arr,1)
  278. let imgArr = []
  279. arr.forEach(item => {
  280. let img = item.split(this.$baseUrl)
  281. imgArr.push(img[1])
  282. })
  283. let imgList = imgArr.join()
  284. console.log(imgList,26)
  285. return imgList
  286. }
  287. }
  288. }
  289. </script>
  290. <style lang="scss">
  291. .card_form {
  292. margin: 10rpx 40rpx;
  293. }
  294. </style>