Commit 0c2b9037 by web

feat: 开发照片墙

1 parent e1805ec1
<!--
* @Description:
* @Date: 2022-05-13 09:41:06
-->
<template>
<el-button @click="handleRemove" class="bi-photo_btn">
<img src="http://cdn.yxvzb.com/WEB/SaaS/images/bi/svg/delete.svg" alt="" />
......@@ -25,6 +29,7 @@ export default {
}
)
.then(() => {
this.$emit('del');
Message({
type: 'success',
message: '删除成功!'
......
<template>
<ul>
<li>
<img
src="http://yiyang.oss-cn-beijing.aliyuncs.com/WEB/SaaS/images/20201013_1147.png"
alt=""
/>
</li>
<li>
<img
src="http://yiyang.oss-cn-beijing.aliyuncs.com/WEB/SaaS/images/2103251844.png"
alt=""
/>
</li>
</ul>
<div :style="{ columnCount }">
<img v-for="(item, index) in list" :key="index" :src="setUrl(item)" />
</div>
</template>
<script>
const IMG_MAPPING = {
1: {
column: 2,
width: 548
},
2: {
column: 3,
width: 355
},
3: {
column: 4,
width: 262
}
};
export default {
name: 'bi-photo-wall-images',
mixins: [],
components: {},
data() {
return {};
props: {
list: {
type: Array,
default() {
return [];
}
},
imgStyle: {
type: Object,
default() {
return {
layout: 2, // 1流式 2平铺 流式不限制高度,但是有max-height,平铺为正方形
size: 2 // 1大548px 2中355px 3小262px
};
}
}
},
computed: {},
watch: {},
methods: {},
created() {},
beforeDestroy() {}
computed: {
columnCount() {
return IMG_MAPPING[this.imgStyle.size].column;
},
width() {
return IMG_MAPPING[this.imgStyle.size].width;
},
height() {
if (this.imgStyle.layout === 2) {
return this.width;
}
return 'auto';
}
},
methods: {
setUrl(url) {
// x-oss-process=image/resize,w_355 流式
// ?x-oss-process=image/resize,m_fill,w_355,h_355
if (this.imgStyle.layout === 1) {
return `${url}?x-oss-process=image/resize,w_${this.width}`;
}
return `${url}?x-oss-process=image/resize,m_fill,w_${this.width},h_${this.width}`;
}
}
};
</script>
<style scoped lang="scss">
ul {
// https://help.aliyun.com/document_detail/44688.html
// ul {
// padding: 0 30px;
// padding-top: 35px;
// position: relative;
// list-style: none;
// display: flex;
// flex-wrap: wrap;
// li {
// margin: 10px;
// img {
// // 大548px 中355px 小262px
// width: 358px;
// height: 358px;
// // object-fit: fill;
// }
// }
// }
div {
padding: 0 30px;
padding-top: 35px;
position: relative;
list-style: none;
// display: flex;
// flex-wrap: wrap;
column-count: 3;
column-gap: 0;
img {
max-width: 300px;
max-height: 300px;
margin: 10px;
// 大548px 中355px 小262px
// width: 358px;
// height: 358px;
// object-fit: fill;
}
}
</style>
......@@ -7,13 +7,13 @@
<BiTitle :index="index" :name="name">
<template #handler>
<div class="bi-title-photo-btn">
<SelectStyle @handleSave="selectStyleSave" />
<SelectImages @handleSave="selectImgSave" />
<Del />
<SelectStyle :imgStyle="imgStyle" @handleSave="selectStyleSave" />
<SelectImages :selected="list" @handleSave="selectImgSave" />
<Del @del="onDel" />
</div>
</template>
</BiTitle>
<BiImages />
<BiImages :list="list" :imgStyle="imgStyle" />
</div>
</template>
......@@ -24,7 +24,6 @@ import SelectImages from './select';
import SelectStyle from './style';
import Del from './del';
import { heightToPage } from '../../chart-type/common';
import { MessageBox, Message } from 'element-ui';
export default {
name: 'bi-photo-wall',
......@@ -47,39 +46,25 @@ export default {
}
},
data() {
return {};
return {
list: [],
imgStyle: {
layout: 2, // 1流式 2平铺
size: 2 // 1大 2中 3小
}
};
},
methods: {
// 选择图片的保存
selectImgSave(e) {
console.log(e);
this.list = e;
},
// 选择样式的保存
selectStyleSave(e) {
console.log(e);
this.imgStyle = e;
},
handleRemove() {
MessageBox.confirm(
'是否确认删除?删除后可在撤销删除里面回复该分析',
'提示',
{
confirmButtonText: '是',
cancelButtonText: '否',
type: 'warning'
}
)
.then(() => {
Message({
type: 'success',
message: '删除成功!'
});
})
.catch(() => {
Message({
type: 'info',
message: '已取消删除'
});
});
onDel() {
this.$refs['bi-photo'].style.display = 'none';
}
},
mounted() {},
......
......@@ -69,7 +69,14 @@ import {
export default {
name: 'select-img',
mixins: [],
props: {
selected: {
type: Array,
default() {
return [];
}
}
},
components: {
[Dialog.name]: Dialog,
[Button.name]: Button,
......@@ -134,8 +141,11 @@ export default {
handleSave() {
this.$emit(
'handleSave',
this.imgWallList.filter(item => item.isSelect === 1)
this.imgWallList
.filter(item => item.isSelect === 1)
.map(item => item.imgUrl)
);
this.selectImgShow = false;
}
},
computed: {
......
......@@ -16,13 +16,13 @@
>
<el-form ref="form" :model="form" label-width="80px">
<el-form-item label="布局样式:">
<el-radio-group v-model="form.layoutStyle">
<el-radio-group v-model="form.layout">
<el-radio :label="1">流式布局</el-radio>
<el-radio :label="2">平铺布局</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="图片大小:">
<el-radio-group v-model="form.imgSize">
<el-radio-group v-model="form.size">
<el-radio :label="1">大图</el-radio>
<el-radio :label="2">中图</el-radio>
<el-radio :label="3">小图</el-radio>
......@@ -42,7 +42,17 @@ import { Dialog, Button, Radio, RadioGroup, Form, FormItem } from 'element-ui';
export default {
name: 'select-style',
mixins: [],
props: {
imgStyle: {
type: Object,
default() {
return {
layout: 2,
size: 2
};
}
}
},
components: {
[Form.name]: Form,
[FormItem.name]: FormItem,
......@@ -55,29 +65,24 @@ export default {
return {
selectStyleShow: false,
form: {
layoutStyle: 1,
imgSize: 2
layout: 2,
size: 2
}
};
},
methods: {
openDialog() {
this.selectStyleShow = true;
const asyncData = {
layoutStyle: 1,
imgSize: 2
};
this.form = asyncData;
Object.assign(this.form, this.imgStyle);
},
handleClose() {
this.selectStyleShow = false;
},
handleSave() {
this.$emit('handleSave', this.form);
this.selectStyleShow = false;
}
}
},
computed: {},
created() {}
};
</script>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!