Commit 468e98bd by web

Merge branch 'feature/照片墙' into 'develop'

Feature/照片墙

See merge request !19
2 parents 3d37b3a6 9bd54476
/dist /dist
\ No newline at end of file /src/packages/bi/src/components/photo-wall/waterfall.vue
\ No newline at end of file
{ {
"name": "xrk-bi", "name": "xrk-bi",
"version": "0.3.0-beta.21", "version": "0.4.1",
"description": "xrk-bi", "description": "xrk-bi",
"author": "xrk", "author": "xrk",
"main": "dist/bundler.js", "main": "dist/bundler.js",
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
:mobile="isMobile" :mobile="isMobile"
:print="isPrint" :print="isPrint"
:projectType="projectType" :projectType="projectType"
:selectType="selectType"
></component> ></component>
<!-- <XrkTaskRecordPdf :projectType="20" :taskId="1209388" :from="1" /> -->
</div> </div>
<!-- <ul class="pervie"> <!-- <ul class="pervie">
<li name="任务记录"> <li name="任务记录">
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
<script> <script>
import { getQueryVariable } from './packages/bi/src/chart-type/common'; import { getQueryVariable } from './packages/bi/src/chart-type/common';
// import { XrkTaskRecordPdf } from './packages/task-recored/index';
export default { export default {
name: 'App', name: 'App',
data() { data() {
...@@ -44,7 +44,8 @@ export default { ...@@ -44,7 +44,8 @@ export default {
isMobile: +getQueryVariable('mobile') === 1, isMobile: +getQueryVariable('mobile') === 1,
isPrint: +getQueryVariable('print') === 1, isPrint: +getQueryVariable('print') === 1,
projectType: +getQueryVariable('projectType') || 6, projectType: +getQueryVariable('projectType') || 6,
componentName: getQueryVariable('componentName') || 'XrkBi' componentName: getQueryVariable('componentName') || 'XrkBi',
selectType: +getQueryVariable('selectType') || 45 // 44自定义-BI报告 45当期-BI报告 46累计-BI报告
}; };
} }
}; };
......
...@@ -2,11 +2,10 @@ ...@@ -2,11 +2,10 @@
* @Description: * @Description:
* @Date: 2021-01-28 23:29:19 * @Date: 2021-01-28 23:29:19
*/ */
import 'babel-polyfill'; // import 'babel-polyfill';
import Vue from 'vue'; import Vue from 'vue';
import App from './App'; import App from './App';
import Xrk from './lib/index.js'; import Xrk from './lib/index.js';
Vue.config.productionTip = false; Vue.config.productionTip = false;
Vue.use(Xrk); Vue.use(Xrk);
......
...@@ -3,10 +3,15 @@ ...@@ -3,10 +3,15 @@
* @Date: 2022-05-13 09:41:06 * @Date: 2022-05-13 09:41:06
--> -->
<template> <template>
<el-button @click="handleRemove" class="bi-photo_btn"> <div>
<img src="http://cdn.yxvzb.com/WEB/SaaS/images/bi/svg/delete.svg" alt="" /> <el-button @click="handleRemove" class="bi-photo_btn">
删除 <img
</el-button> src="http://cdn.yxvzb.com/WEB/SaaS/images/bi/svg/delete.svg"
alt=""
/>
删除
</el-button>
</div>
</template> </template>
<script> <script>
......
<template> <template>
<ul :style="{ columnCount }"> <!-- <ul :style="{ columnCount }">
<li v-for="(item, index) in taskImageInfo.imageUrls" :key="index"> <li v-for="(item, index) in taskImageInfo.imageUrls" :key="index">
<img :src="setUrl(item.imageUrl)" /> <img :src="setUrl(item.imageUrl)" />
</li> </li>
</ul> </ul> -->
<div>
<div
v-for="(imageUrls, imageUrlsIndex) in waterfalls"
:key="imageUrlsIndex"
>
<waterfall
ref="waterfall"
:col="columnCount"
:data="imageUrls"
@finish="finish"
>
<template>
<div
v-for="(item, index) in imageUrls"
:key="index"
:style="{
padding: '10px 0',
'text-align': 'center'
}"
>
<img
:style="{ width: widthPx, height: heightPx }"
:src="setUrl(item.imageUrl)"
/>
</div>
</template>
</waterfall>
</div>
</div>
</template> </template>
<script> <script>
import waterfall from './waterfall.vue';
const IMG_MAPPING = { const IMG_MAPPING = {
1: { 1: {
column: 2, column: 2, // 2列数据
width: 548 width: 548,
height: 305
}, },
2: { 2: {
column: 3, column: 3,
width: 355 width: 355,
height: 198
}, },
3: { 3: {
column: 4, column: 4,
width: 262 width: 262,
height: 144
} }
}; };
const baseHeight = 1697;
export default { export default {
name: 'bi-photo-wall-images', name: 'bi-photo-wall-images',
components: {
waterfall
},
props: { props: {
taskImageInfo: { taskImageInfo: {
type: Object, type: Object,
...@@ -42,6 +80,49 @@ export default { ...@@ -42,6 +80,49 @@ export default {
} }
} }
}, },
watch: {
taskImageInfo: {
deep: true,
immediate: true,
handler(v) {
const { imageUrls, imageStyle } = v;
let waterfalls = [];
const titleHeight = 88;
const margin = 20;
// 第一页图片总列数
const firstColumnNum = Math.floor(
(baseHeight - titleHeight) / (this.height + margin)
);
// 其他页图片总列数
const otherColumnNum = Math.floor(baseHeight / (this.height + margin));
const firstCount = firstColumnNum * this.columnCount; // 第一页数据总数
const otherCount = otherColumnNum * this.columnCount; // 其他页数据总数
if (imageUrls) {
if (imageStyle === 2) {
imageUrls.forEach((item, index) => {
// 第一个 || 第一组最后一个(只会出现一次) || 其他组最后一个(多次出现)
if (
index === 0 ||
index === firstCount ||
!(index % otherCount)
) {
waterfalls[waterfalls.length] = [];
}
waterfalls[waterfalls.length - 1].push(item);
});
} else {
waterfalls = [imageUrls];
}
this.waterfalls = waterfalls;
}
}
}
},
data() {
return {
waterfalls: [] // 二维数组,第一个为第一页算上title单独计算,其他为统一计算分组
};
},
computed: { computed: {
columnCount() { columnCount() {
return IMG_MAPPING[this.taskImageInfo.imageSize].column; return IMG_MAPPING[this.taskImageInfo.imageSize].column;
...@@ -50,20 +131,30 @@ export default { ...@@ -50,20 +131,30 @@ export default {
return IMG_MAPPING[this.taskImageInfo.imageSize].width; return IMG_MAPPING[this.taskImageInfo.imageSize].width;
}, },
height() { height() {
return IMG_MAPPING[this.taskImageInfo.imageSize].height;
},
widthPx() {
return this.width + 'px';
},
heightPx() {
if (this.taskImageInfo.imageStyle === 2) { if (this.taskImageInfo.imageStyle === 2) {
return this.width; return this.height + 'px';
} }
return 'auto'; return 'auto';
} }
}, },
methods: { methods: {
finish() {
this.$emit('finish');
},
setUrl(url) { setUrl(url) {
// x-oss-process=image/resize,w_355 流式 // x-oss-process=image/resize,w_355 流式
// ?x-oss-process=image/resize,m_fill,w_355,h_355 // ?x-oss-process=image/resize,m_fill,w_355,h_355
const _url = url.split('?')[0];
if (this.taskImageInfo.imageStyle === 1) { if (this.taskImageInfo.imageStyle === 1) {
return `${url}?x-oss-process=image/resize,w_${this.width}`; 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}`; return `${_url}?x-oss-process=image/resize,m_fill,w_${this.width},h_${this.height}`;
} }
} }
}; };
...@@ -97,12 +188,17 @@ ul { ...@@ -97,12 +188,17 @@ ul {
// flex-wrap: wrap; // flex-wrap: wrap;
column-count: 3; column-count: 3;
column-gap: 0; column-gap: 0;
img {
margin: 10px; li {
// 大548px 中355px 小262px break-inside: avoid;
// width: 358px; img {
// height: 358px; max-height: 588px;
// object-fit: fill; margin: 10px;
// 大548px 中355px 小262px
// width: 358px;
// height: 358px;
// object-fit: fill;
}
} }
} }
</style> </style>
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
<template #handler> <template #handler>
<div class="bi-title-photo-btn" v-if="!isPrint"> <div class="bi-title-photo-btn" v-if="!isPrint">
<SelectStyle <SelectStyle
style="margin: 0 5px"
v-if="showEdit"
:layout="{ :layout="{
imageStyle: value.imageStyle, imageStyle: value.imageStyle,
imageSize: value.imageSize imageSize: value.imageSize
...@@ -15,14 +17,16 @@ ...@@ -15,14 +17,16 @@
@handleSave="selectStyleSave" @handleSave="selectStyleSave"
/> />
<SelectImages <SelectImages
style="margin: 0 5px"
v-if="showEdit"
:imageUrls="value.imageUrls" :imageUrls="value.imageUrls"
@handleSave="selectImgSave" @handleSave="selectImgSave"
/> />
<Del @del="onDel" /> <Del style="margin: 0 5px" @del="onDel" />
</div> </div>
</template> </template>
</BiTitle> </BiTitle>
<BiImages :taskImageInfo="value" /> <BiImages :taskImageInfo="value" @finish="finish" />
</div> </div>
</template> </template>
...@@ -70,8 +74,15 @@ export default { ...@@ -70,8 +74,15 @@ export default {
default: 4 default: 4
} }
}, },
computed: {
showEdit() {
return +this.Bi.selectType === 45; // 44自定义-BI报告 45当期-BI报告(显示样式、选择) 46累计-BI报告
}
},
methods: { methods: {
finish() {
this.$emit('finish');
},
// 选择图片的保存 // 选择图片的保存
selectImgSave(e) { selectImgSave(e) {
this.$emit('input', { this.$emit('input', {
...@@ -108,7 +119,7 @@ export default { ...@@ -108,7 +119,7 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.bi-photo { .bi-photo {
// page-break-before: always; page-break-before: always;
// page-break-after: always; // page-break-after: always;
padding-bottom: 50px; padding-bottom: 50px;
...@@ -144,6 +155,6 @@ export default { ...@@ -144,6 +155,6 @@ export default {
.bi-title-photo-btn { .bi-title-photo-btn {
display: flex; display: flex;
width: 320px; width: 320px;
justify-content: space-between; justify-content: flex-end;
} }
</style> </style>
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
:key="item.imageUrl + index" :key="item.imageUrl + index"
> >
<el-checkbox <el-checkbox
:disabled="selectSum >= 50 && item.isSelect === 0" :disabled="selectSum >= 50 && !imageUrlsMap.includes(item.imageUrl)"
class="select-box" class="select-box"
:value="imageUrlsMap.includes(item.imageUrl)" :value="imageUrlsMap.includes(item.imageUrl)"
@change=" @change="
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Description: * @Description:
* @Author: jml * @Author: jml
* @Date: 2021-02-26 15:38:10 * @Date: 2021-02-26 15:38:10
* @LastEditTime: 2022-05-19 15:25:49 * @LastEditTime: 2022-06-07 11:25:17
--> -->
<template> <template>
<div class="xrk-components-bi bi" :class="{ 'bi-print': print }"> <div class="xrk-components-bi bi" :class="{ 'bi-print': print }">
...@@ -58,6 +58,7 @@ export default { ...@@ -58,6 +58,7 @@ export default {
cantEdit: [Number, String], cantEdit: [Number, String],
projectType: [Number, String], projectType: [Number, String],
from: [Number, String], from: [Number, String],
selectType: Number, // 44自定义-BI报告 45当期-BI报告 46累计-BI报告
getBaseInfo: { getBaseInfo: {
type: Function, type: Function,
default: () => {} default: () => {}
......
...@@ -51,6 +51,12 @@ export default { ...@@ -51,6 +51,12 @@ export default {
resolve('load fail'); resolve('load fail');
}; };
}); });
},
preloadImgs(urls) {
if (!urls.length) {
return Promise.resolve();
}
return Promise.all(urls.map(url => this.preloadImg(url)));
} }
} }
}; };
...@@ -61,15 +61,16 @@ ...@@ -61,15 +61,16 @@
@sort="sort(arguments, 'singleChoice', hideSingleChoice)" @sort="sort(arguments, 'singleChoice', hideSingleChoice)"
@page="setPage(arguments, 'page4')" @page="setPage(arguments, 'page4')"
> >
<BiSingleChoiceInfo index="4" name="照片集合"></BiSingleChoiceInfo> <BiSingleChoiceInfo index="4" name="照片合集"></BiSingleChoiceInfo>
</BiSingleChoice> --> </BiSingleChoice> -->
<BiPhoto <BiPhoto
v-if="!hideTaskImage" v-if="!hideTaskImage"
class="bi-block" class="bi-block"
ref="bi-photo" ref="bi-photo"
name="照片集合" name="照片合集"
v-model="taskImageInfo" v-model="taskImageInfo"
@page="setPage(arguments, 'page4')" @page="setPage(arguments, 'page4')"
@finish="taskImageInfo.finish = true"
/> />
<BiCoverEnd title="奇正藏药医学沙龙推广项目数据报告"></BiCoverEnd> <BiCoverEnd title="奇正藏药医学沙龙推广项目数据报告"></BiCoverEnd>
<BiOperate <BiOperate
...@@ -142,6 +143,7 @@ export default { ...@@ -142,6 +143,7 @@ export default {
title: { title: {
name: '照片墙' name: '照片墙'
}, },
finish: false, // 图片是否渲染完成
has: false, // true有图片题,false无 has: false, // true有图片题,false无
isDelete: 0, isDelete: 0,
imageStyle: 2, //展示样式 1 流式 2平铺 imageStyle: 2, //展示样式 1 流式 2平铺
...@@ -218,10 +220,10 @@ export default { ...@@ -218,10 +220,10 @@ export default {
}, },
...(!this.hideTaskImage && [ ...(!this.hideTaskImage && [
{ {
name: '照片集合', name: '照片合集',
child: [ child: [
{ {
name: '照片集合', name: '照片合集',
page: 4 page: 4
} }
] ]
...@@ -246,6 +248,15 @@ export default { ...@@ -246,6 +248,15 @@ export default {
} }
}, },
methods: { methods: {
taskImageFinish(resolve) {
if (this.taskImageInfo.finish) {
resolve();
} else {
setTimeout(() => {
this.taskImageFinish(resolve);
}, 1000);
}
},
dealPos(dis) { dealPos(dis) {
return dis * (this.isPrint ? printWidth : this.baseFontSize); return dis * (this.isPrint ? printWidth : this.baseFontSize);
}, },
...@@ -506,11 +517,7 @@ export default { ...@@ -506,11 +517,7 @@ export default {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const { biInfoId, styleConfigureId } = this.biInfo; const { biInfoId, styleConfigureId } = this.biInfo;
const { content } = this.$refs['cover']; const { content } = this.$refs['cover'];
if ( if (!this.hideTaskImage && !this.taskImageInfo.imageUrls.length) {
this.taskImageInfo.has &&
!this.taskImageInfo.isDelete &&
!this.taskImageInfo.imageUrls.length
) {
reject('照片墙:请删除或至少选择一张图片'); reject('照片墙:请删除或至少选择一张图片');
} }
Promise.all([ Promise.all([
...@@ -585,14 +592,23 @@ export default { ...@@ -585,14 +592,23 @@ export default {
this.dealChoice(topicInfo.data.data || []); this.dealChoice(topicInfo.data.data || []);
this.dealChoiceMixin(topicMixinInfo.data.data || []); this.dealChoiceMixin(topicMixinInfo.data.data || []);
this.coverList = tempaletList.data.data || []; this.coverList = tempaletList.data.data || [];
if (hasImageQuestion) { // taskImageInfo.data.data.imageUrls.forEach(item => {
Object.assign(this.taskImageInfo, taskImageInfo.data.data, { // item.imageUrl = item.imageUrl.replace('https', 'http');
has: hasImageQuestion // });
}); Object.assign(this.taskImageInfo, taskImageInfo.data.data, {
} has: hasImageQuestion,
finish: !hasImageQuestion || !!taskImageInfo.data.data.isDelete
});
this.$nextTick(async () => { this.$nextTick(async () => {
await this.preloadImg(this.coverUrl); await this.preloadImg(this.coverUrl);
window.status = '1'; await new Promise(resolve => {
this.taskImageFinish(resolve); // 提供给wkwebivewtopdf使用,页面处理完成,node不用
});
setTimeout(() => {
window.status = '1'; // 提供给wkwebivewtopdf使用,页面处理完成,node不用
console.log('done7');
}, 1000 * 5);
}); });
} }
) )
...@@ -604,8 +620,4 @@ export default { ...@@ -604,8 +620,4 @@ export default {
} }
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped></style>
.bi-block {
// margin-top: 8px;
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!