123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- <template>
- <el-dialog
- title="修改个人签名"
- :visible.sync="visible"
- :append-to-body="true">
- <el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="80px">
- <upload-component :title="'个人签名'" :accept="'.png,.jpeg,.jpg'" :file-obj-list="fileList" @uploadSuccess="uploadSuccess"/>
- </el-form>
- <span slot="footer">
- <el-button @click="visible = false">取消</el-button>
- <el-button type="primary" @click="dataFormSubmit()" v-reClick>确定</el-button>
- </span>
- </el-dialog>
- </template>
- <script>
- import { getMyInfo } from '@/api/my'
- import UploadComponent from './modules/common/upload-component'
- export default {
- components: {
- UploadComponent
- },
- data () {
- return {
- visible: false,
- fileList: [],
- dataForm: {},
- dataRule: {
- }
- }
- },
- computed: {
- userName: {
- get () { return this.$store.state.user.name }
- },
- mainTabs: {
- get () { return this.$store.state.common.mainTabs },
- set (val) { this.$store.commit('common/updateMainTabs', val) }
- }
- },
- methods: {
- // 初始化
- init () {
- // 获取用户信息
- getMyInfo().then(({data}) => {
- if (data && data.code === '200' && data.data) {
- this.dataForm = data.data
- this.fileList = []
- data.data.attachList.forEach((item) => {
- this.fileList.push({
- name: item.fileName,
- url: item.url,
- id: item.url
- })
- })
- }
- })
- this.visible = true
- this.$nextTick(() => {
- this.$refs['dataForm'].resetFields()
- })
- },
- // 表单提交
- dataFormSubmit () {
- let fList = this.fileList
- if (!fList || fList.length === 0) {
- this.$message.error('请上传文件')
- return
- }
- if (fList.length > 1) {
- this.$message.error('只能上传一个附件')
- return
- } else {
- this.dataForm.attachList = []
- for (let i = 0; i < fList.length; i++) {
- this.dataForm.attachList.push({
- fileName: fList[i].name,
- url: fList[i].url
- })
- }
- }
- this.$refs['dataForm'].validate((valid) => {
- if (valid) {
- this.$http({
- url: this.$http.adornUrl('/biz-service/personal/setSignInfo'),
- method: 'post',
- data: this.dataForm
- }).then(({data}) => {
- if (data && data.code === '200') {
- this.$message({
- message: '操作成功',
- type: 'success',
- duration: 1500,
- onClose: () => {
- this.visible = false
- }
- })
- } else {
- this.$message.error(data.msg)
- }
- })
- }
- })
- },
- uploadSuccess (fileList) {
- this.fileList = fileList
- }
- }
- }
- </script>
|