单图上传组件添加移除
This commit is contained in:
parent
56fa3912ae
commit
a118738d0f
|
@ -153,9 +153,9 @@
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
<el-input v-model="form.${field}" placeholder="请输入${comment}" />
|
<el-input v-model="form.${field}" placeholder="请输入${comment}" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "uploadImage")
|
#elseif($column.htmlType == "imageUpload")
|
||||||
<el-form-item label="${comment}">
|
<el-form-item label="${comment}">
|
||||||
<uploadImage v-model="form.${field}"/>
|
<imageUpload v-model="form.${field}"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "editor")
|
#elseif($column.htmlType == "editor")
|
||||||
<el-form-item label="${comment}">
|
<el-form-item label="${comment}">
|
||||||
|
@ -244,8 +244,8 @@ import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${Busin
|
||||||
import Treeselect from "@riophae/vue-treeselect";
|
import Treeselect from "@riophae/vue-treeselect";
|
||||||
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
||||||
#foreach($column in $columns)
|
#foreach($column in $columns)
|
||||||
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "uploadImage")
|
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "imageUpload")
|
||||||
import UploadImage from '@/components/UploadImage';
|
import ImageUpload from '@/components/ImageUpload';
|
||||||
#break
|
#break
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
|
@ -260,8 +260,8 @@ export default {
|
||||||
name: "${BusinessName}",
|
name: "${BusinessName}",
|
||||||
components: {
|
components: {
|
||||||
#foreach($column in $columns)
|
#foreach($column in $columns)
|
||||||
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "uploadImage")
|
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "imageUpload")
|
||||||
UploadImage,
|
ImageUpload,
|
||||||
#break
|
#break
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
|
|
|
@ -185,9 +185,9 @@
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
<el-input v-model="form.${field}" placeholder="请输入${comment}" />
|
<el-input v-model="form.${field}" placeholder="请输入${comment}" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "uploadImage")
|
#elseif($column.htmlType == "imageUpload")
|
||||||
<el-form-item label="${comment}">
|
<el-form-item label="${comment}">
|
||||||
<uploadImage v-model="form.${field}"/>
|
<imageUpload v-model="form.${field}"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "editor")
|
#elseif($column.htmlType == "editor")
|
||||||
<el-form-item label="${comment}">
|
<el-form-item label="${comment}">
|
||||||
|
@ -274,8 +274,8 @@
|
||||||
<script>
|
<script>
|
||||||
import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName}, export${BusinessName} } from "@/api/${moduleName}/${businessName}";
|
import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName}, export${BusinessName} } from "@/api/${moduleName}/${businessName}";
|
||||||
#foreach($column in $columns)
|
#foreach($column in $columns)
|
||||||
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "uploadImage")
|
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "imageUpload")
|
||||||
import UploadImage from '@/components/UploadImage';
|
import ImageUpload from '@/components/ImageUpload';
|
||||||
#break
|
#break
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
|
@ -290,8 +290,8 @@ export default {
|
||||||
name: "${BusinessName}",
|
name: "${BusinessName}",
|
||||||
components: {
|
components: {
|
||||||
#foreach($column in $columns)
|
#foreach($column in $columns)
|
||||||
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "uploadImage")
|
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "imageUpload")
|
||||||
UploadImage,
|
ImageUpload,
|
||||||
#break
|
#break
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
|
|
|
@ -11,8 +11,21 @@
|
||||||
:headers="headers"
|
:headers="headers"
|
||||||
style="display: inline-block; vertical-align: top"
|
style="display: inline-block; vertical-align: top"
|
||||||
>
|
>
|
||||||
<img v-if="value" :src="value" class="avatar" />
|
<el-image v-if="!value" :src="value">
|
||||||
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
|
<div slot="error" class="image-slot">
|
||||||
|
<i class="el-icon-plus" />
|
||||||
|
</div>
|
||||||
|
</el-image>
|
||||||
|
<div v-else class="image">
|
||||||
|
<el-image :src="value" />
|
||||||
|
<div class="mask">
|
||||||
|
<div class="actions">
|
||||||
|
<span title="移除" @click.stop="removeImage">
|
||||||
|
<i class="el-icon-delete" />
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</el-upload>
|
</el-upload>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -37,6 +50,9 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
removeImage() {
|
||||||
|
this.$emit("input", "");
|
||||||
|
},
|
||||||
handleUploadSuccess(res) {
|
handleUploadSuccess(res) {
|
||||||
this.$emit("input", res.url);
|
this.$emit("input", res.url);
|
||||||
this.loading.close();
|
this.loading.close();
|
||||||
|
@ -65,4 +81,18 @@ export default {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
.image {
|
||||||
|
position: relative;
|
||||||
|
.mask {
|
||||||
|
opacity: 0;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
width: 100%;
|
||||||
|
background-color: rgba(0, 0, 0, 0.5);
|
||||||
|
transition: all 0.3s;
|
||||||
|
}
|
||||||
|
&:hover .mask {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
|
@ -90,7 +90,7 @@
|
||||||
<el-option label="单选框" value="radio" />
|
<el-option label="单选框" value="radio" />
|
||||||
<el-option label="复选框" value="checkbox" />
|
<el-option label="复选框" value="checkbox" />
|
||||||
<el-option label="日期控件" value="datetime" />
|
<el-option label="日期控件" value="datetime" />
|
||||||
<el-option label="上传控件" value="uploadImage" />
|
<el-option label="单图上传" value="imageUpload" />
|
||||||
<el-option label="富文本控件" value="editor" />
|
<el-option label="富文本控件" value="editor" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</template>
|
</template>
|
||||||
|
|
Loading…
Reference in New Issue