<!-- 基本线的属性框 -->
<template>
  <div class="base-line">
    <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="linewidth"
              controls-position="right"
              @change="changeWidth"
              size="mini"
              :min="1"
              :max="20"
              :maxlength="100"
            ></el-input-number>
            <span>线宽</span>
          </div>
          <div class="line-width">
            <a-select
              style="width: 80px"
              v-model="linestyle"
              :default-value="borderLineOption[0].id"
              @change="changeLineStyle"
            >
              <a-select-option
                v-for="item in borderLineOption"
                :key="item.id"
                :label="item.src"
                :value="item.id"
              >
                <img :src="item.src" alt width="60" />
              </a-select-option>
            </a-select>
            <span>线型</span>
          </div>
        </div>
      </li>
    </ul>
  </div>
</template>
<script>
import bus from "@/bus/bus";
export default {
  props: ["strokeColor", "lineStyle", "lineWidth"],
  data() {
    return {
      color: "",
      linewidth: "",
      linestyle: "",
      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"),
        },
      ],
    };
  },
  methods: {
    // 改变线宽
    changeWidth(val) {
      bus.$emit("updateStyle", "lineWidth", val);
    },
    // 改变颜色
    changeColor(val) {
      bus.$emit("updateStyle", "strokeColor", val);
    },
    // 改变线样式
    changeLineStyle(val) {
      bus.$emit("updateStyle", "lineStyle", val);
    },
  },
  mounted() {
    // console.log(Select)
  },
  watch: {
    strokeColor(val) {
      this.color = val;
    },
    lineWidth(val) {
      this.linewidth = val;
    },
    lineStyle(val) {
      this.linestyle = val;
    },
  },
};
</script>
<style lang="less" scoped>
ul,
li {
  margin: 0;
  padding: 0;
  list-style-type: none;
}
.base-line {
  .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>