<template>
  <div class="edit-pane">
    <el-form
      ref="modalFormComp"
      :model="modalForm"
      :key="modalForm.id"
      label-width="100px"
    >
      <el-form-item label="背景颜色：">
        <color-select
          v-model="modalForm.bgColor"
          show-empty
          :predefine="predefineColors"
        ></color-select>
      </el-form-item>
      <el-form-item label="边框颜色：">
        <color-select v-model="modalForm.color"></color-select>
      </el-form-item>
      <el-form-item label="边框粗细：">
        <line-width-select v-model="modalForm.bold"></line-width-select>
      </el-form-item>
      <el-form-item label="边框形状：">
        <line-style-select v-model="modalForm.style"></line-style-select>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import ColorSelect from "../../components/common/ColorSelect";
import LineStyleSelect from "../../components/common/LineStyleSelect";
import LineWidthSelect from "../../components/common/LineWidthSelect";

const initModalForm = {
  id: "",
  bold: "1px",
  color: "#000000",
  bgColor: "#ffffff",
  style: "solid"
};

export default {
  name: "edit-pane",
  components: { ColorSelect, LineStyleSelect, LineWidthSelect },
  props: {
    instance: {
      type: Object,
      default() {
        return {};
      }
    }
  },
  data() {
    return {
      modalForm: { ...initModalForm },
      predefineColors: ["#000000", "#666666", "#999999", "#ffffff"]
    };
  },
  mounted() {
    this.initData(this.instance);
  },
  methods: {
    initData(val) {
      this.modalForm = { ...val };
    },
    submit() {
      this.$emit("modified", this.modalForm);
    }
  }
};
</script>
