当前位置: 首页 > news >正文

全返网站建设网站策划书范文模板

全返网站建设,网站策划书范文模板,番禺市桥网站建设公司,建设银行福建分行招聘网站RuoYi 框架本身对于图片上传功能#xff0c;在ElementUI的 el-upload 组件的基础装封装了 /components/ImageUpload/index.vue 组件。本组件就是在 RuoYi 自定义的 ImageUpload 组件的基础上进行改造#xff0c;将图片的信息在上传之前处理成 base64 格式在ElementUI的 el-upload 组件的基础装封装了 /components/ImageUpload/index.vue 组件。本组件就是在 RuoYi 自定义的 ImageUpload 组件的基础上进行改造将图片的信息在上传之前处理成 base64 格式用于提交到后端接口以及前端图片相应的预览展示。 自定义组件 ImageUploadBase64 组件目录 /components/ImageUploadBase64/index.vue templatediv classcomponent-upload-imageel-upload refimageUploadRefaction#list-typepicture-cardaccept.png, .jpeg, .jpg:limitlimit:on-changehandleChange:on-removehandleRemove:on-previewhandlePictureCardPreview:on-exceedhandleExceed:file-listfileList:class{hide: this.fileList.length this.limit}:show-file-listtrue:auto-uploadfalsei classel-icon-plus/i/el-uploadel-dialog :visible.syncpreviewDialogVisible title图片预览 width800 append-to-bodyel-image styledisplay: block; max-width: 100%; margin: 0 auto:srcpreviewDialogImageUrl alt/el-image/el-dialog/div /template scriptexport default {props: {// 对应父组件 v-model绑定对应本组件 this.$emit(input,参数)绑定value: [String, Object, Array],// 图片数量限制limit: {type: Number,default: 5,},// 大小限制(MB)fileSize: {type: Number,default: 5,},// 文件类型, 例如[png, jpg, jpeg]fileType: {type: Array,default: () [png, jpg, jpeg],},},data() {return {// 图片预览弹窗 显隐previewDialogVisible: false,// 图片预览 urlpreviewDialogImageUrl: ,// 待上传的图片集合 是转化完base64 后的结果fileList: [/*{name:,url:}*/]}},watch: {value: {handler(val) {if (val) {// 首先将值转为数组const list Array.isArray(val) ? val : this.value.split(,);// 然后将数组转为对象数组this.fileList list.map(item {if (typeof item string) {item {name: item, url: item};}return item;});} else {this.fileList [];return [];}},deep: true,immediate: true}},methods: {/*** 校验文件尺寸是否符合要求 和类型是否是图片* param file* returns {boolean}*/handleFileValidate(file) {// 上传文件的类型let type file.raw.type || file.type;let isImg type.indexOf(image) -1;if (isImg) {if (this.fileSize) {const isLt file.size / 1024 / 1024 this.fileSize;if (!isLt) {this.$message.error(上传头像图片大小不能超过 ${this.fileSize} MB!);return false;} else {return true;}}} else {this.$message.error(文件格式不正确, 请上传${this.fileType.join(/)}图片格式文件!);// 不是图片格式return false;}},/* 添加文件、上传成功和上传失败时都会被调用 */handleChange(file, fileList) {if (this.handleFileValidate(file)) {this.fileToBase64(file);} else {// 删除尺寸大的图片 或者非图片类型的文件let lastIndex fileList.length - 1;if (lastIndex -1) {fileList.splice(lastIndex, 1);}}},/*** 删除图片* param file 被删除的图片* param fileList 剩余的文件信息列表*/handleRemove(file, fileList) {const findex this.fileList.map(f f.url).indexOf(file.url);if (findex -1) {// 删除对应的 文件数据this.fileList.splice(findex, 1);this.$emit(input, this.listToArray(this.fileList));}},/*预览图片*/handlePictureCardPreview(file) {this.previewDialogImageUrl file.url;this.previewDialogVisible true;},/*** 文件个数超出* param files 超出的文件信息* param fileList 原来已经添加的文件信息*/handleExceed(files, fileList) {this.$message.error(上传文件数量不能超过 ${this.limit} 个!);},/*** 将el-upload组件上传的文件转为base64* param file*/fileToBase64(file) {var reader new FileReader();reader.readAsDataURL(file.raw); // 转换为Base64reader.onload e {// 当转换完成后e.target.result就是Base64字符串const base64 e.target.result;this.fileList.push({name: base64, url: base64});this.$emit(input, this.listToArray(this.fileList));};},// list中的元素{name:,url:} 转 url字符串listToArray(list) {let arr [];for (let i in list) {arr.push(list[i].url);}return arr;}} }/script style scoped langscss // .el-upload--picture-card 控制加号部分 ::v-deep.hide .el-upload--picture-card {display: none; }// 去掉动画效果 ::v-deep .el-list-enter-active, ::v-deep .el-list-leave-active {transition: all 0s; }::v-deep .el-list-enter, .el-list-leave-active {opacity: 0;transform: translateY(0); } /style 表单中引用如下 templatediv classapp-container!-- 添加或修改对话框 --el-dialog :titletitle :visible.syncopen width500px append-to-bodyel-form refform :modelform :rulesrules :show-messagefalse label-width80pxel-col :span24el-form-item label上传图片ImageUploadBase64 v-modelform.base64DataList :file-size10 inputhandleImageInput/ImageUploadBase64/el-form-item/el-col/el-row/el-formdiv slotfooter classdialog-footerel-button typeprimary clicksubmitForm()保 存/el-buttonel-button clickcancel取 消/el-button/div/el-dialog/div /templatescript import ImageUploadBase64 from /components/ImageUploadBase64/index.vue;import {listWorkInfo, getWorkInfo, delWorkInfo, addWorkInfo, updateWorkInfo} from /api/basic/work;export default {name: Work,components: {ImageUploadBase64},data() {return {// 弹出层标题title: ,// 是否显示弹出层open: false,// 表单参数form: {},};},created() {this.getList();},methods: {/*** 子组件 this.$emit(input, this.listToArray(this.fileList)); 返回的数据* param fileList*/handleImageInput(fileList){// 这里返回的就是base64字符串的数组可以直接提交后端接口也可以根据业务做其他处理console.log(handleImageInput-----:, fileList)},// 取消按钮cancel() {this.open false;this.reset();},// 表单重置reset() {this.form {id: nullbase64DataList:[]};this.resetForm(form);},/** 新增按钮操作 */handleAdd() {this.reset();this.title 添加工作信息;this.open true;},/** 修改按钮操作 */handleUpdate(row) {this.reset();const id row.id || this.idsgetWorkInfo(id).then(response {this.form response.data;this.open true;this.title 修改工作信息;});},/** 提交按钮 */submitForm: function () {this.$refs[form].validate(valid {if (valid) {if (this.form.id ! undefined) {updateWorkInfo(this.form).then(response {this.$modal.msgSuccess(修改成功);this.open false;this.getList();});} else {addWorkInfo(this.form).then(response {this.$modal.msgSuccess(新增成功);this.open false;this.getList();});}}});}} }; /script 这个组件将图片信息直接在前端转化成 base64格式的字符串数字后端可以直接使用ListString 接收图片的信息并进行后续的处理。
http://www.dnsts.com.cn/news/85095.html

相关文章:

  • 50强网站建设公司想要做个公司网站
  • 多个微信管理系统台州网站排名优化价格
  • 深圳网站设计公司哪家工艺好个人建个网站需要多少钱
  • 建筑网站图片网站制作专业
  • 北京网站建设价家具设计师要学哪些软件
  • 网站团队的建设wordpress展览会
  • 湖北企业响应式网站建设价位wordpress写文章页面无法显示
  • 宝塔做网站可以用什么端口网站域名费用交给谁
  • 西青网站文化建设wordpress写文章更新失败
  • 静态网站可以申请域名吗重庆推广网站排名公司
  • 为什么招聘网站不能用自己做的简历godday网站建设
  • 网站页面布局设计思路基于.net的个人网站开发实录
  • wordpress线上聊天插件seo是如何做优化的
  • 网站开发保密合同wordpress 自动 采集
  • 建设网站困难的解决办法广东东莞大益队
  • 网站功能模块表格wordpress 二手市场
  • 企业手机端网站源码下载全新装修效果图大全
  • 专业电商网站设计网站大全下载
  • 毕设做网站怎么命题红安建设局官方网站
  • 网站建设岗位工作职责临沂市建设安全管理网站
  • 电商网站首页图片能去百度上班意味着什么
  • 网站建设金网科技沈阳专业做网站方案
  • 网站上的图是怎么做的网站开发属于知识产权吗
  • 仙桃有哪些做网站的公司用手机可以做网站
  • 怎么做示爱的网站项目式学习
  • 苏州市住房和城乡建设局网站首页有哪些网站是可以接单做任务的
  • 百度网站推广怎么做寻找网站优化公司
  • dedecms企业网站模板免费下载wordpress媒体库现实不全
  • 廉政建设网站线上课程
  • 网站模块报价网站建设swot分析