123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289 |
- <template>
- <!-- 个人资料 -->
- <view>
- <u-navbar title="个人资料" autoBack placeholder></u-navbar>
- <view class="card_form">
- <x-form ref="personage" :userType="userType" :list="list" :model="model" :rules="rules"
- @clientele="clientele"></x-form>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- list: [{
- field: 'name',
- label: '姓名',
- placeholder: '请输入姓名',
- type: 'input',
- disabled: true,
- required: true,
- }, {
- field: 'idCard',
- label: '身份证号',
- placeholder: '请输入身份证号',
- type: 'input',
- disabled: true,
- required: true,
- }, {
- field: 'phone',
- label: '电话',
- placeholder: '请输入电话',
- type: 'input',
- required: true,
- }, {
- field: 'description',
- label: '备注',
- placeholder: '请输入备注',
- type: 'textarea',
- }, {
- field: 'line',
- label: '《燃气从业资格证》信息',
- type: 'line',
- }, {
- field: 'lines',
- label: '《道路运输从业人员从业资格证》信息',
- type: 'line',
- }, {
- field: 'certificateNo',
- label: '证书编号',
- placeholder: '请输入证书编号',
- type: 'input',
- required: true,
- }, {
- field: 'issueAuthority',
- label: '发证机关',
- placeholder: '请输入发证机关',
- type: 'input',
- required: true,
- }, {
- field: 'remarks',
- label: '备注',
- placeholder: '请输入备注',
- type: 'textarea',
- }, {
- field: 'imgUrl',
- label: '燃气从业资格证',
- placeholder: '请上传燃气从业资格证',
- type: 'upload',
- required: true,
- }, {
- field: 'imgUrls',
- label: '道路运输从业人员从业资格证',
- placeholder: '请上传道路运输从业人员从业资格证',
- type: 'upload',
- required: true,
- }],
- model: {
- name: '',
- idCard: '',
- phone: '',
- description: '',
- certificateNo: '',
- issueAuthority: '',
- remarks: '',
- imgUrl: '',
- imgUrls: '',
- },
- rules: {
- 'name': {
- type: 'string',
- required: true,
- message: '请输入姓名',
- trigger: ['blur', 'change']
- },
- 'idCard': {
- type: 'string',
- required: true,
- message: '请输入身份证号码',
- trigger: ['blur', 'change']
- },
- 'phone': {
- type: 'string',
- required: true,
- message: '请输入电话号码',
- trigger: ['blur', 'change']
- },
- 'certificateNo': {
- type: 'string',
- required: true,
- message: '请输入证书编号',
- trigger: ['blur', 'change']
- },
- 'issueAuthority': {
- type: 'string',
- required: true,
- message: '请输入发证机关',
- trigger: ['blur', 'change']
- },
- 'imgUrl': {
- type: 'string',
- required: true,
- message: '请上传燃气从业资格证',
- trigger: ['blur', 'change']
- },
- 'imgUrls': {
- type: 'string',
- required: true,
- message: '请上传燃气从业资格证',
- trigger: ['blur', 'change']
- },
- },
- userInfo: {},
- userType: 5,
- }
- },
- onLoad() {
- this.getLayout()
- },
- mounted() {
- this.getUser()
- },
- methods: {
- getLayout() {
- this.list.forEach(value => {
- if (this.userType == 3) {
- if (value.field == 'imgUrls' || value.field == 'lines') {
- value.visible = true
- } else {
- value.visible = false
- }
- } else if (this.userType == 4) {
- if (value.field == 'imgUrl' || value.field == 'line') {
- value.visible = true
- } else {
- value.visible = false
- }
- } else {
- if (['imgUrl', 'imgUrls', 'line', 'lines', 'certificateNo', 'issueAuthority',
- 'issueAuthority', 'remarks',
- ].includes(value.field)) {
- value.visible = true
- } else {
- value.visible = false
- }
- }
- })
- },
- getUser() {
- this.$api.get('/api/user/profile').then(res => {
- if (res.code == 200) {
- const param = res.data.user
- this.userInfo = param
- this.$nextTick(() => {
- this.userType = param.provUser.userType
- this.getLayout()
- this.model.name = param.provUser.name
- this.model.idCard = param.provUser.idCard
- this.model.phone = param.provUser.phone
- this.model.description = param.provUser.description
- if (this.userType == 3) {
- this.model.certificateNo = param.provStoreUserBindCertificate.certificateNo
- this.model.issueAuthority = param.provStoreUserBindCertificate
- .issueAuthority
- this.model.imgUrl = param.provStoreUserBindCertificate.imgUrl
- if (param.provStoreUserBindCertificate.remarks) {
- this.model.remarks = param.provStoreUserBindCertificate.remarks
- } else {
- this.model.remarks = ''
- }
- } else if (this.userType == 4) {
- this.model.certificateNo = param.provTruckUserBindCertificate.certificateNo
- this.model.issueAuthority = param.provTruckUserBindCertificate
- .issueAuthority
- this.model.imgUrls = param.provTruckUserBindCertificate.imgUrl
- if (param.provTruckUserBindCertificate.remarks) {
- this.model.remarks = param.provTruckUserBindCertificate.remarks
- } else {
- this.model.remarks = ''
- }
- }
- let arrImg = []
- let arrImg1 = []
- if (param.provStoreUserBindCertificate.imgUrl && this.userType == 3) {
- arrImg = param.provStoreUserBindCertificate.imgUrl.split(',')
- } else if (param.provTruckUserBindCertificate.imgUrl && this.userType == 4) {
- arrImg = param.provTruckUserBindCertificate.imgUrl.split(',')
- }
- arrImg.forEach(item => {
- let arr = {
- thumb: this.$baseUrl + item,
- url: this.$baseUrl + item,
- }
- arrImg1.push(arr)
- })
- this.$refs.personage.fileList1 = arrImg1
- })
- // console.log(this.model, 26)
- }
- })
- },
- // 修改个人信息
- clientele() {
- let param = {
- id: this.userInfo.id,
- roleId: this.userInfo.roleId,
- provUser: {
- name: this.model.name,
- cmpCode: this.model.cmpCode,
- phone: this.model.phone,
- description: this.model.description,
- },
- provStoreUserBindCertificate: {
- certificateNo: this.model.certificateNo,
- issueAuthority: this.model.issueAuthority,
- imgUrl: this.model.imgUrl,
- remarks: this.model.remarks,
- },
- provTruckUserBindCertificate: {
- certificateNo: this.model.certificateNo,
- issueAuthority: this.model.issueAuthority,
- imgUrl: this.model.imgUrls,
- remarks: this.model.remarks,
- }
- }
- if (this.model.addressImg != undefined) {
- param.provTruckUserBindCertificate.imgUrl = this.model.addressImg
- }
- if (this.userType == 3) {
- delete param.provTruckUserBindCertificate
- } else if (this.userType == 4) {
- delete param.provStoreUserBindCertificate
- }
- uni.showLoading({
- mask: true,
- });
- uni.hideLoading();
- this.$api.put('/api/sys-user', param).then(res => {
- if (res.code == 200) {
- this.getUser()
- uni.$u.toast(res.msg)
- }
- uni.hideLoading();
- }).catch(() => {
- uni.hideLoading();
- })
- },
- eliminateImge(img) {
- let arr = img.split(',')
- console.log(img,arr,1)
- let imgArr = []
- arr.forEach(item => {
- let img = item.split(this.$baseUrl)
- imgArr.push(img[1])
- })
- let imgList = imgArr.join()
- console.log(imgList,26)
- return imgList
- }
- }
- }
- </script>
- <style lang="scss">
- .card_form {
- margin: 10rpx 40rpx;
- }
- </style>
|