|
@@ -5,16 +5,20 @@
|
|
|
class="add_ico"
|
|
|
@click="addPage(chooseModalId)"
|
|
|
/>
|
|
|
+ <el-button type="text" icon="el-icon-arrow-left" :disabled="clickLeftTime===0" @click="scrollPrev"></el-button>
|
|
|
<div class="format-wrap">
|
|
|
- <div class="format-item" :class="{'last-choose':chooseModalId===item.modelId}"
|
|
|
- v-for="item in formatArr" :key="item.modelId">
|
|
|
- <component
|
|
|
- :is="previewComponentName(item.modelId)"
|
|
|
- @click.native="addPage(item.modelId)"
|
|
|
- />
|
|
|
- <!-- <p>{{ item.text }}</p> -->
|
|
|
- </div>
|
|
|
+ <div class="format-trans-wrap" :style="`transform:translateX(${scrollOffset}px);`">
|
|
|
+ <div class="format-item" :class="{'last-choose':chooseModalId===item.modelId}"
|
|
|
+ :style="`margin:0 ${itemOccupyMargin}px;`"
|
|
|
+ v-for="item in formatArr" :key="item.modelId">
|
|
|
+ <component
|
|
|
+ :is="previewComponentName(item.modelId)"
|
|
|
+ @click.native="addPage(item.modelId)"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
+ <el-button type="text" icon="el-icon-arrow-right" :disabled="clickRightTime===0" @click="scrollNext"></el-button>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -32,6 +36,7 @@ import FormatPreNine from "@/views/ppt_manage/newVersion/components/formatPrevie
|
|
|
import FormatPreTen from "@/views/ppt_manage/newVersion/components/formatPreview/FormatPreTen";
|
|
|
import FormatPreEle from "@/views/ppt_manage/newVersion/components/formatPreview/FormatPreEle";
|
|
|
import FormatPreTwelve from "@/views/ppt_manage/newVersion/components/formatPreview/FormatPreTwelve";
|
|
|
+import FormatPreThirteen from "@/views/ppt_manage/newVersion/components/formatPreview/FormatPreThirteen";
|
|
|
import {countComponentName} from '@/views/ppt_manage/newVersion/utils/untils';
|
|
|
export default {
|
|
|
name: "AddFormat",
|
|
@@ -53,15 +58,44 @@ export default {
|
|
|
FormatPreNine,
|
|
|
FormatPreTen,
|
|
|
FormatPreEle,
|
|
|
- FormatPreTwelve
|
|
|
+ FormatPreTwelve,
|
|
|
+ FormatPreThirteen
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
formatArr: formatPre,
|
|
|
-
|
|
|
+ lineShowNum:9,//一行最多能展示几个
|
|
|
+ clickLeftTime:0,//可以按下左按钮的次数,为0时该按钮禁用
|
|
|
+ clickRightTime:0,//可以按下右按钮的次数,为0时该按钮禁用
|
|
|
+ scrollOffset:0,//当前滚动偏移量
|
|
|
+ itemOccupyMargin:0,//当前一个format占用间距
|
|
|
+ itemWidth:92,//当前一个format所占宽度(固定)
|
|
|
};
|
|
|
},
|
|
|
methods: {
|
|
|
+ init(){
|
|
|
+ //初始化按钮次数
|
|
|
+ this.clickLeftTime = 0
|
|
|
+ this.clickRightTime = this.formatArr.length - this.lineShowNum
|
|
|
+ //获取容器宽度,以确定一个format应占宽度
|
|
|
+ const parentWidth = $('.format-wrap').width()
|
|
|
+ this.itemOccupyMargin = ((parentWidth/this.lineShowNum - this.itemWidth - 0.5)/2).toFixed(2)
|
|
|
+ },
|
|
|
+ scrollPrev(){
|
|
|
+ if(this.clickLeftTime<=0) return
|
|
|
+ this.clickLeftTime--
|
|
|
+ this.clickRightTime++
|
|
|
+ this.scrollFormat(this.clickLeftTime)
|
|
|
+ },
|
|
|
+ scrollNext(){
|
|
|
+ if(this.clickRightTime===0) return
|
|
|
+ this.clickRightTime--
|
|
|
+ this.clickLeftTime++
|
|
|
+ this.scrollFormat(this.clickLeftTime)
|
|
|
+ },
|
|
|
+ scrollFormat(multiple){
|
|
|
+ this.scrollOffset = -(multiple*this.itemWidth+Number(this.itemOccupyMargin))
|
|
|
+ },
|
|
|
previewComponentName(modelId) {
|
|
|
return countComponentName(modelId,'pre')
|
|
|
//return `formatPre${modelMap[modelId]}`;
|
|
@@ -70,10 +104,20 @@ export default {
|
|
|
this.$emit("addPage", modelId);
|
|
|
},
|
|
|
},
|
|
|
+ mounted(){
|
|
|
+ this.init()
|
|
|
+ },
|
|
|
};
|
|
|
</script>
|
|
|
<style lang="scss">
|
|
|
@import "~@/views/ppt_manage/newVersion/css/formatPre.scss";
|
|
|
+.add-icon-wrap{
|
|
|
+ .el-button{
|
|
|
+ i{
|
|
|
+ font-weight: bold;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
</style>
|
|
|
<style scoped lang="scss">
|
|
|
.add-icon-wrap {
|
|
@@ -81,6 +125,8 @@ export default {
|
|
|
min-height: 64px;
|
|
|
position: relative;
|
|
|
padding: 10px 20px;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
.add_ico {
|
|
|
cursor: pointer;
|
|
|
position: absolute;
|
|
@@ -91,15 +137,25 @@ export default {
|
|
|
height: 28px;
|
|
|
display: inline-block;
|
|
|
}
|
|
|
+ .el-button{
|
|
|
+ font-size: 22px;
|
|
|
+ padding:0;
|
|
|
+ &:first-of-type{
|
|
|
+ margin-left: 40px;
|
|
|
+ }
|
|
|
+ }
|
|
|
.format-wrap {
|
|
|
- margin-left: 40px;
|
|
|
- /* background-color: #eef0f3; */
|
|
|
- width: calc(100% - 40px);
|
|
|
- /* height: 120px; */
|
|
|
- display: flex;
|
|
|
- /* flex-wrap: wrap; */
|
|
|
- justify-content: space-between;
|
|
|
+ width: calc(100% - 80px);
|
|
|
+ height:68px;
|
|
|
+ overflow-x: hidden;
|
|
|
+ .format-trans-wrap{
|
|
|
+ width:100%;
|
|
|
+ height: 100%;
|
|
|
+ display: flex;
|
|
|
+ flex-wrap: nowrap;
|
|
|
+ }
|
|
|
.format-item {
|
|
|
+ flex:0 0 auto;
|
|
|
width: 80px;
|
|
|
height: 56px;
|
|
|
padding: 5px;
|