| | |
| | | <el-dialog title="基本信息" :visible.sync="dialogshowArr[0].show" width="50%" class="baseinfo"> |
| | | <el-container> |
| | | <el-aside width="200px"> |
| | | <el-input v-if="false" v-model="empBaseInfoForm.file" /> |
| | | <el-upload |
| | | class="avatar-uploader" |
| | | action="#" |
| | |
| | | import Treeselect from '@riophae/vue-treeselect' |
| | | import '@riophae/vue-treeselect/dist/vue-treeselect.css' |
| | | import Pagination from '@/components/Pagination' |
| | | import { pages } from '@/settings' |
| | | |
| | | export default { |
| | | components: { Treeselect, Pagination }, |
| | |
| | | version: '' |
| | | }, |
| | | empBaseInfoForm: { |
| | | file: null, |
| | | imagePath: '', |
| | | empId: '', |
| | | customerId: '', |
| | | archivesNumb: '', |
| | |
| | | this.isShow(false, 0) |
| | | }, |
| | | methods: { |
| | | // 获取图片的Blob值 |
| | | getImageBlob(url, cb) { |
| | | var xhr = new XMLHttpRequest() |
| | | xhr.open('get', url, true) |
| | | xhr.responseType = 'blob' |
| | | xhr.onload = function() { |
| | | if (this.status === 200) { |
| | | if (cb) cb(this.response) |
| | | } |
| | | } |
| | | xhr.send() |
| | | }, |
| | | preView(url) { |
| | | var this_ = this |
| | | const reader = new FileReader() |
| | | this.getImageBlob(url, function(blob) { |
| | | reader.readAsDataURL(blob) |
| | | }) |
| | | reader.onload = function(e) { |
| | | // 获取bolb里面数据时,生成预览 |
| | | var img = document.createElement('img') |
| | | img.src = e.target.result |
| | | this_.empBaseInfoForm.imagePath = e.target.result |
| | | } |
| | | }, |
| | | // 图片预览 |
| | | handlePictureCardPreview(file) { |
| | | const fileName = file.name |
| | | const regex = /(.jpg|.jpeg|.gif|.png|.bmp)$/ |
| | | if (regex.test(fileName.toLowerCase())) { |
| | | var reader = new FileReader() |
| | | reader.readAsDataURL(file) |
| | | this.empBaseInfoImageUrl = URL.createObjectURL(file.raw) // 获取URL |
| | | // 判断图片大小 |
| | | if (file.size < 4400000) { |
| | | // 判断图片格式是否为jpg,png,jepg,gif |
| | | var fileName = file.name |
| | | // var suffixIndex=fileName.lastIndexOf(".") |
| | | // var suffix=fileName.substring(suffixIndex+1).toUpperCase() |
| | | var suffix = fileName.substring(fileName.lastIndexOf('.') + 1).toUpperCase() |
| | | if (suffix === 'JPG' || suffix === 'JPEG' || suffix === 'PNG') { |
| | | this.preView(this.empBaseInfoImageUrl) |
| | | } else { |
| | | this.$message.error('请选择图片文件') |
| | | this.$message.error('文件类型不正确,请重新上传!') |
| | | } |
| | | } else { |
| | | this.$message.error('图片大小超过4M,请重新上传') |
| | | } |
| | | }, |
| | | // 翻页插件翻页方法 |
| | |
| | | this.empBaseInfoForm.modifier = '' |
| | | this.empBaseInfoForm.delFlag = '' |
| | | this.empBaseInfoForm.version = '' |
| | | this.empBaseInfoForm.imagePath = '' |
| | | this.empBaseInfoImageUrl = '' |
| | | }, |
| | | editEmpBase(row) { |
| | | this.isAdd = false |
| | |
| | | this.empBaseInfoForm.delFlag = row.delFlag |
| | | this.empBaseInfoForm.version = row.version |
| | | this.dialogshowArr[0].show = true |
| | | this.empBaseInfoImageUrl = pages.getEmpBaseInfoImage + row.empId |
| | | }, |
| | | putEmpBase(formName) { |
| | | this.$refs[formName].validate((valid) => { |