<!-- 基本的文本属性框 -->
<template>
  <div class="base-text">
    <div class="title">属性</div>
    <ul>
      <li>
        <div class="small-title">边框</div>
        <div class="property">
          <div class="color-box">
            <div class="cololorSelect">
              <el-color-picker show-alpha @change="changeColor" class="fix-box-1" v-model="color"></el-color-picker>
            </div>
            <span>颜色</span>
          </div>
          <div class="line-width">
            <el-input-number
              style="width:80px"
              v-model="fontSize"
              controls-position="right"
              @change="changeFontSize"
              size="mini"
              :min="1"
              :max="20"
              :maxlength="100"
            ></el-input-number>
            <span>字号</span>
          </div>
          <div class="color-box">
            <div class="cololorSelect">
              <el-color-picker
                @change="changeBackground"
                show-alpha
                class="fix-box-1"
                v-model="backgroundcolor"
              ></el-color-picker>
            </div>
            <span>背景颜色</span>
          </div>
        </div>
      </li>
      <li>
        <el-input
          type="textarea"
          @input="changeText"
          :autosize="{ minRows: 2, maxRows: 4}"
          v-model="text"
        ></el-input>
        <span>文本</span>
      </li>
    </ul>
  </div>
</template>
<script>
import bus from "@/bus/bus";
export default {
  props: ["strokeColor", "fontSize", "backgroundColor", "textMsg"],
  data() {
    return {
      size: 0, //font-size
      text: "", //文本
      color: "",
      backgroundcolor: "",
      borderLineOption: [
        {
          id: "solid",
          src: require("@/assets/images/solidLine.png"),
        },
        {
          id: "dashed",
          src: require("@/assets/images/dashedLine.png"),
        },
        {
          id: "dotted",
          src: require("@/assets/images/dotLine.png"),
        },
      ],
      borderStyle: "solid",
    };
  },
  methods: {
    // 改变文字
    changeText(val) {
      bus.$emit("updateStyle", "text", val);
    },
    // 改变颜色
    changeColor(val) {
      bus.$emit("updateStyle", "strokeColor", val);
    },
    // 改变背景颜色
    changeBackground(val) {
      bus.$emit("updateStyle", "backgroundColor", val);
    },
    // 改变字体大小
    changeFontSize(val) {
      bus.$emit("updateStyle", "font", val);
    },
  },
  mounted() {
    // console.log(Select)
  },
  watch: {
    strokeColor(val) {
      this.color = val;
    },
    fontSize(val) {
      this.size = val;
    },
    backgroundColor(val) {
      this.backgroundcolor = val;
    },

    textMsg(val) {
      this.text = val;
    },
  },
};
</script>
<style lang="less" scoped>
ul,
li {
  margin: 0;
  padding: 0;
  list-style-type: none;
}
.base-text {
  .title {
    height: 47px;
    border-bottom: 1px solid #979797;
    color: #646c73;
    font-size: 16px;
    padding-left: 12px;
    box-sizing: border-box;
  }
  ul {
    width: calc(~"100% - 24px");
    margin: -1px 12px 0 12px;
    li {
      border-top: 1px solid #979797;
      .small-title {
        font-size: 12px;
        color: #8d9399;
        margin: 12px 0;
      }
      .property {
        display: flex;
        align-items: center;
        justify-content: space-around;
        .color-box {
          display: flex;
          align-items: center;
          flex-direction: column;
          .cololorSelect {
            width: 32px;
            height: 20px;
            overflow: hidden;
            position: relative;
            margin: 4px 0;
            .fix-box-1 {
              margin-top: -8px;
              margin-left: -8px;
              /deep/ .el-color-picker__trigger {
                width: 200px;
                height: 200px;
              }
            }
          }
        }
        .line-width {
          display: flex;
          align-items: center;
          flex-direction: column;
          margin-left: 8px;
          position: relative;
        }
        span {
          font-size: 12px;
          color: #1f2429;
          margin-top: 4px;
        }
      }
    }
  }
}
</style>