style.vue 2.8 KB
<template>
  <div>
    <el-button @click="openDialog" class="bi-photo_btn">
      <img
        src="http://cdn.yxvzb.com/WEB/SaaS/images/bi/svg/delete.svg"
        alt=""
      />
      选择样式
    </el-button>
    <el-dialog
      title="选择样式"
      :visible.sync="selectStyleShow"
      width="400px"
      center
      :before-close="handleClose"
    >
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="布局样式:">
          <el-radio-group v-model="form.imageStyle">
            <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.imageSize">
            <el-radio :label="1">大图</el-radio>
            <el-radio :label="2">中图</el-radio>
            <el-radio :label="3">小图</el-radio>
          </el-radio-group>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleClose">取 消</el-button>
        <el-button type="primary" @click="handleSave">保 存</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { Dialog, Button, Radio, RadioGroup, Form, FormItem } from 'element-ui';

export default {
  name: 'select-style',
  props: {
    layout: {
      type: Object,
      default() {
        return {
          imageStyle: 2,
          imageSize: 2
        };
      }
    }
  },
  components: {
    [Form.name]: Form,
    [FormItem.name]: FormItem,
    [Dialog.name]: Dialog,
    [Button.name]: Button,
    [RadioGroup.name]: RadioGroup,
    [Radio.name]: Radio
  },
  data() {
    return {
      selectStyleShow: false,
      form: {
        imageStyle: 2,
        imageSize: 2
      }
    };
  },
  methods: {
    openDialog() {
      this.selectStyleShow = true;
      Object.assign(this.form, this.layout);
    },
    handleClose() {
      this.selectStyleShow = false;
    },
    handleSave() {
      this.$emit('handleSave', this.form);
      this.selectStyleShow = false;
    }
  }
};
</script>

<style scoped lang="scss">
.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;
        }
      }
    }
  }
}
</style>