Browse Source

优化图片库

master
陈裕财 3 years ago
parent
commit
deb5e90800
  1. 10
      config/index.js
  2. 3
      src/api/mdp/arc/image.js
  3. 10
      src/components/Image/ImageCategoryTree.vue
  4. 51
      src/components/Image/UploadImage.vue
  5. 18
      src/components/Tinymce/index.vue

10
config/index.js

@ -18,7 +18,15 @@ module.exports = {
'^/api/m1/xm': '/xm'
}
},
/**
/**
'/api/m1/arc': {
target: 'http://localhost:7012',
changeOrigin: true,
pathRewrite: {
'^/api/m1/arc': '/arc'
}
},
'/api/m1/sys': {
target: 'http://localhost:7015',
changeOrigin: true,

3
src/api/mdp/arc/image.js

@ -32,3 +32,6 @@ export const addImage = params => { return axios.post(`${base}/mdp/arc/image/add
export const listTags = params => { return axios.get(`${base}/mdp/arc/image/listTags`, params); };
export const uploadBase64 = params => { return axios.post(`${base}/mdp/arc/image/upload/base64`, params); };
export const upload = params => { return axios.post(`${base}/mdp/arc/image/upload`, params,{
'Content-type' : 'multipart/form-data'}); };

10
src/components/Image/ImageCategoryTree.vue

@ -1,5 +1,8 @@
<template>
<section>
<el-row class="padding">
<el-button type="primary" style="float:left;" icon="el-icon-plus" @click.prevent.stop="addTopNode()">添加顶级分类</el-button>
</el-row>
<el-row>
<el-tree
:data="categoryTreeData"
@ -21,8 +24,7 @@
<div class="custom-tree-node" slot-scope="{ node, data}">
<span>{{data.categoryName=='根'?'移动鼠标到此添加分类':data.categoryName}}</span>
<span class="el-ic">
<i class="el-icon-circle-plus" @click.prevent.stop="addTopNode()" title="添加顶级分类"></i>
<i class="el-icon-plus" v-if=" !(!data.id || data.id=='C0'||data.id=='0')" @click.prevent.stop="addNode(data,node)" title="添加子分类"></i>
<i class="el-icon-plus" v-if=" !(!data.id || data.id=='C0'||data.id=='0')" @click.prevent.stop="addNode(data,node)" title="添加子分类"></i>
<i class="el-icon-edit" v-if=" !(!data.id || data.id=='C0'||data.id=='0')" @click.prevent.stop="editNode(data,node)" title="修改名字"></i>
<i class="el-icon-delete" v-if=" !(!data.id || data.id=='C0'||data.id=='0')" @click.prevent.stop="deleteNode(data,node)" title="删除该分类"> </i>
</span>
@ -31,7 +33,7 @@
<el-dialog
title="提示"
:visible.sync="addVisible"
width="60%" append-to-body>
width="60%" append-to-body modal-append-to-body>
<el-form ref="addImageCategory" :model="addImageCategory" label-width="200" >
<el-form-item label="分类编号">
<el-input v-model="addImageCategory.id" placeholder="如果为空,则系统自动生成"></el-input>
@ -52,7 +54,7 @@
<el-dialog
title="提示"
:visible.sync="editVisible"
width="60%" append-to-body>
width="60%" append-to-body modal-append-to-body>
<el-form ref="editImageCategory" :model="editImageCategory" label-width="200" >
<el-form-item label="分类编号" prop="id">
{{editImageCategory.id}}

51
src/components/Image/UploadImage.vue

@ -1,40 +1,31 @@
<template>
<section>
<el-row class="uploadImgWindow" v-loading="listLoading">
<el-col :span=6 class="leftBox">
<el-col :span="6" class="leftBox">
<category-tree ref="categoryTree" :show-count="false" show-checkbox :default-expand-all="true" :expand-on-click-node="false" v-on:check-change="handleLeftCategoryNodeClick"></category-tree>
</el-col>
<el-col :span=18 class="rightBox">
<el-col :span=24 class="windowTitle">
<el-col :span=12 class="windowTitlefistchild">
<el-col :span="18" class="rightBox">
<el-row class="windowTitle">
<el-col :span="12" class="windowTitlefistchild">
<el-input v-model="filters.key" style="width:60%;" placeholder="按文件名模糊查询"></el-input>
<el-button type="primary" @click="searchImages" icon="el-icon-search"></el-button>
</el-col>
<el-col :span=4>
<el-upload :disabled="uploadOptions.categoryId==''||uploadOptions.categoryId==null" class="upload-demo" :show-file-list="false" :action="uploadAction" :on-change="fileChange" :on-success="handleSuccess" :before-upload="beforeupload" :data="uploadOptions" multiple>
<el-tooltip class="item" effect="dark" :content="uploadOptions.categoryId==''?'请先选择左边分类':'支持jpg和png,建议大小不超过200KB,超过1M将自动裁剪压缩'" placement="top-start">
<el-button type="primary">点击上传</el-button>
</el-tooltip>
<el-col :span="6" >
<el-upload :disabled="uploadOptions.categoryId==''||uploadOptions.categoryId==null" class="upload-demo" :show-file-list="false" :action="uploadAction" :on-change="fileChange" :on-success="handleSuccess" :before-upload="beforeupload" :data="uploadOptions" multiple>
<el-tooltip class="item" effect="dark" :content="uploadOptions.categoryId==''?'请先选择左边分类':'支持jpg和png,建议大小不超过200KB,超过1M将自动裁剪压缩'" placement="top-start">
<el-button type="primary">点击上传</el-button>
</el-tooltip>
</el-upload>
</el-upload>
</el-col>
<el-col :span=4>
<el-upload :disabled="uploadOptions.categoryId==''||uploadOptions.categoryId==null" class="upload-demo" :show-file-list="false" :action="uploadAction" :on-change="fileChangeForShear" :on-success="handleSuccess" :before-upload="beforeupload" :data="uploadOptions" multiple>
<el-tooltip class="item" effect="dark" :content="uploadOptions.categoryId==''?'请先选择分类':'支持jpg和png,建议大小不超过200KB,超过1M将自动裁剪压缩'" placement="top-start">
<el-button type="warning">裁剪上传</el-button>
</el-tooltip>
</el-upload>
</el-col>
<el-col :span=4>
<el-button type="danger" @click="handelDel" >删除</el-button>
<el-col :span="4" >
<el-button type="danger" @click="handelDel" >删除</el-button>
</el-col>
</el-col>
</el-row>
<el-col :span=24>
<el-col :span=24 type="flex" class="allImg">
<el-col :span=4 v-for="o in images" style="height:200px;width:200px;" :key="o.id" class="imgBox">
<el-row>
<el-col :span="24" type="flex" class="allImg">
<el-col :span="4" v-for="o in images" style="height:200px;width:200px;" :key="o.id" class="imgBox">
<el-card :body-style="{ padding: '0px' }">
<div style="width:100%;position:relative;" :index="o.url" v-on:click="selectImg(o)">
@ -50,11 +41,9 @@
</el-card>
</el-col>
</el-col>
</el-col>
<el-col :span="24">
<el-pagination layout="total, sizes, prev,pager, next" @current-change="handleCurrentChange" @size-change="handleSizeChange" :page-sizes="[10,20, 50, 100, 500]" :current-page="pageInfo.pageNum" :page-size="pageInfo.pageSize" :total="pageInfo.total" style="float:right;">
</el-pagination>
</el-col>
</el-row>
<el-pagination layout="total, sizes, prev,pager, next" @current-change="handleCurrentChange" @size-change="handleSizeChange" :page-sizes="[10,20, 50, 100, 500]" :current-page="pageInfo.pageNum" :page-size="pageInfo.pageSize" :total="pageInfo.total" style="float:right;">
</el-pagination>
</el-col>
</el-row>
<el-dialog title="裁剪图片" :visible.sync="shearMngVisible" width="1100px" top="0px" :close-on-click-modal="false" append-to-body>
@ -105,7 +94,7 @@
},
selectImages: [],
listLoading: false,//...
uploadOptions:{branchId:this.branchId,categoryId:'',fileName:'',remark:'',deptid:this.deptid},//
uploadOptions:{branchId:this.branchId,categoryId:'',fileName:'',remark:'',deptid:this.deptid,storedb:true},//
shearMngVisible:false,
showAddCategoryForm: false,
categoryName: '',//

18
src/components/Tinymce/index.vue

@ -5,13 +5,13 @@
>
<textarea :id="tinymceId" class="tinymce-textarea" />
<el-dialog
id="editor-dialog"
class="image-dialog"
title="选择图片"
:visible.sync="dialogVisible"
width="70%"
top="20px"
width="80%"
:close-on-click-modal="false"
append-to-body
modal-append-to-body
>
<upload-image
:multiple="true"
@ -125,9 +125,9 @@ export default {
selector: `#${_this.tinymceId}`,
height: _this.height,
body_class: "panel-body ",
object_resizing: false,
object_resizing: true,
toolbar: _this.toolbar.length > 0 ? _this.toolbar : toolbar,
menubar: _this.menubar,
menubar: false,
plugins: plugins,
end_container_on_empty_block: true,
powerpaste_word_import: "clean",
@ -193,11 +193,19 @@ export default {
// return img
// },
images_upload_handler(blobInfo, success, failure, progress) {
const formData = new FormData();
formData.append('storedb',false)
formData.append('file', blobInfo.blob());
formData.append("categoryId",_this.uploadOptions.categoryId)
upload(formData).then((res) => {
var tips = res.data.tips;
if(tips.isOk){
success(res.data.data.url)
}else{
failure(tips.msg)
}
})
},

Loading…
Cancel
Save