|
@@ -26,7 +26,7 @@
|
|
</el-date-picker>
|
|
</el-date-picker>
|
|
<!-- 上传图片 -->
|
|
<!-- 上传图片 -->
|
|
<el-upload v-if="formConfig.htmlType == 'imageUpload'" :headers="{Authorization: 'Bearer ' + getToken()}" :action="process + '/boman-file/upload'" :file-list="config" list-type="picture-card"
|
|
<el-upload v-if="formConfig.htmlType == 'imageUpload'" :headers="{Authorization: 'Bearer ' + getToken()}" :action="process + '/boman-file/upload'" :file-list="config" list-type="picture-card"
|
|
- :on-preview="handlePictureCardPreview" :on-remove="handleRemove">
|
|
|
|
|
|
+ :on-preview="handlePictureCardPreview" :on-success="upImageFn" :on-remove="reseImage" >
|
|
<i class="el-icon-plus"></i>
|
|
<i class="el-icon-plus"></i>
|
|
</el-upload>
|
|
</el-upload>
|
|
<el-dialog :visible.sync="dialogVisible" v-if="formConfig.htmlType == 'imageUpload'">
|
|
<el-dialog :visible.sync="dialogVisible" v-if="formConfig.htmlType == 'imageUpload'">
|
|
@@ -39,6 +39,8 @@
|
|
v-if="formConfig.htmlType == 'fileUpload'"
|
|
v-if="formConfig.htmlType == 'fileUpload'"
|
|
:action="process + '/boman-file/upload'"
|
|
:action="process + '/boman-file/upload'"
|
|
:on-change="handleChange"
|
|
:on-change="handleChange"
|
|
|
|
+ :on-success="upImageFn"
|
|
|
|
+ :on-remove="reseImage"
|
|
:file-list="config">
|
|
:file-list="config">
|
|
<el-button size="small" type="primary">点击上传</el-button>
|
|
<el-button size="small" type="primary">点击上传</el-button>
|
|
<div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div>
|
|
<div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div>
|
|
@@ -82,6 +84,12 @@
|
|
mounted() {
|
|
mounted() {
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
|
|
+ upImageFn(res, file){
|
|
|
|
+ this.config.push({
|
|
|
|
+ name: res.data.name,
|
|
|
|
+ url: res.data.url,
|
|
|
|
+ });
|
|
|
|
+ },
|
|
init() {
|
|
init() {
|
|
if(this.formConfig.htmlType == 'checkbox' || this.formConfig.htmlType == 'imageUpload' || this.formConfig.htmlType == 'fileUpload'){
|
|
if(this.formConfig.htmlType == 'checkbox' || this.formConfig.htmlType == 'imageUpload' || this.formConfig.htmlType == 'fileUpload'){
|
|
this.config = []
|
|
this.config = []
|
|
@@ -93,9 +101,32 @@
|
|
},
|
|
},
|
|
getToken() {
|
|
getToken() {
|
|
return getToken()
|
|
return getToken()
|
|
- },
|
|
|
|
- handleRemove(file, fileList) {
|
|
|
|
- console.log(file, fileList);
|
|
|
|
|
|
+ },
|
|
|
|
+ reseImage(file, fileList) {
|
|
|
|
+ let urls = ""
|
|
|
|
+ if(file.response){
|
|
|
|
+ urls = file.response.url
|
|
|
|
+ }else{
|
|
|
|
+ urls = file.url
|
|
|
|
+ }
|
|
|
|
+ for (let i = this.config.length - 1; i >= 0; i--) {
|
|
|
|
+ if (this.config[i].url == urls) {
|
|
|
|
+ this.config.splice(i, 1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ reseImage1(file, fileList) {
|
|
|
|
+ let urls = ""
|
|
|
|
+ if(file.response){
|
|
|
|
+ urls = file.response.url
|
|
|
|
+ }else{
|
|
|
|
+ urls = file.url
|
|
|
|
+ }
|
|
|
|
+ for (let i = this.config.length - 1; i >= 0; i--) {
|
|
|
|
+ if (this.config[i].url == urls) {
|
|
|
|
+ this.config.splice(i, 1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
},
|
|
},
|
|
handlePictureCardPreview(file) {
|
|
handlePictureCardPreview(file) {
|
|
this.dialogImageUrl = file.url;
|
|
this.dialogImageUrl = file.url;
|