index.vue 3.45 KB
<!--
 * @Description: 
 * @Date: 2021-06-09 19:05:20
-->
<template>
  <div class="bi-photo" ref="bi-photo">
    <BiTitle :index="index" :name="name">
      <template #handler>
        <div class="bi-title-photo-btn" v-if="!isPrint">
          <SelectStyle
            style="margin: 0 5px"
            v-if="showEdit"
            :layout="{
              imageStyle: value.imageStyle,
              imageSize: value.imageSize
            }"
            @handleSave="selectStyleSave"
          />
          <SelectImages
            style="margin: 0 5px"
            v-if="showEdit"
            :imageUrls="value.imageUrls"
            @handleSave="selectImgSave"
          />
          <Del style="margin: 0 5px" @del="onDel" />
        </div>
      </template>
    </BiTitle>
    <BiImages :taskImageInfo="value" @finish="finish" />
  </div>
</template>

<script>
import BiTitle from '../../commonComponents/title.vue';
import BiImages from './images';
import SelectImages from './select';
import SelectStyle from './style';
import Del from './del';
import { heightToPage } from '../../chart-type/common';
import mixin from '../../mixin/index';

export default {
  name: 'bi-photo-wall',
  mixins: [mixin],
  components: {
    BiTitle,
    BiImages,
    SelectImages,
    SelectStyle,
    Del
  },
  props: {
    name: String,
    value: {
      default() {
        return {
          isDelete: 0, // 1删除
          imageStyle: 2, // 1流式 2平铺 流式不限制高度,但是有max-height,平铺为正方形
          imageSize: 2, //图片大小 1 大  2中  3小
          imageUrls: [
            // {
            // id: 1,
            // biInfoId: 123, //BI主键
            // taskId: 123, //任务记录ID
            // imageUrl: '图片地址'
            // }
          ]
        };
      },
      type: Object
    },
    index: {
      type: Number,
      default: 4
    }
  },
  computed: {
    showEdit() {
      return +this.Bi.selectType === 45; // 44自定义-BI报告 45当期-BI报告(显示样式、选择) 46累计-BI报告
    }
  },
  methods: {
    finish() {
      this.$emit('finish');
    },
    // 选择图片的保存
    selectImgSave(e) {
      this.$emit('input', {
        ...this.value,
        imageUrls: e
      });
    },
    // 选择样式的保存
    selectStyleSave(e) {
      this.$emit('input', {
        ...this.value,
        ...e
      });
    },
    onDel() {
      this.$emit('input', {
        ...this.value,
        isDelete: 1
      });
    }
  },
  watch: {
    value: {
      handler() {
        this.$nextTick(() => {
          this.$emit('page', heightToPage(this.$refs['bi-photo'].offsetHeight));
        });
      },
      deep: true,
      immediate: true
    }
  }
};
</script>
<style lang="scss" scoped>
.bi-photo {
  page-break-before: always;
  // page-break-after: always;
  padding-bottom: 50px;

  &_btn {
    display: inline-block;
    min-width: 42px;
    height: 42px;
    border: 1px solid #bac1ce;
    border-radius: 4px;
    vertical-align: top;
    text-align: center;
    line-height: 42px;
    padding: 0 15px;
    font-size: 16px;
    font-weight: 500;
    color: #6f7a91;
    cursor: pointer;
    position: relative;
    &_group {
      position: absolute;
      right: 16px;
      top: 50%;
      margin-top: -21px;
      z-index: 3;
      &_item {
        & + .bi-chart-title_btn_group_item {
          margin-left: 8px;
        }
      }
    }
  }
}
.bi-title-photo-btn {
  display: flex;
  width: 320px;
  justify-content: flex-end;
}
</style>