<template>
  <div class="edit-lines">
    <el-form
      ref="modalFormComp"
      :key="modalForm.id"
      :model="modalForm"
      label-width="100px"
    >
      <el-form-item prop="lineCount" label="线条数量：">
        <el-input-number
          v-model.number="modalForm.lineCount"
          style="width: 125px"
          :min="2"
          :max="100"
          :step="1"
          step-strictly
          :controls="false"
        ></el-input-number>
      </el-form-item>
      <el-form-item prop="lineSpacing" label="线条间距：">
        <el-input-number
          v-model.number="modalForm.lineSpacing"
          style="width: 125px"
          :min="2"
          :max="100"
          :step="1"
          step-strictly
          :controls="false"
        ></el-input-number>
      </el-form-item>
      <el-form-item label="左右边距：">
        <el-input-number
          v-model.number="modalForm.margin"
          style="width: 125px"
          :min="0"
          :max="100"
          :step="1"
          step-strictly
          :controls="false"
        ></el-input-number>
      </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: "",
  lineCount: 2,
  lineSpacing: 10,
  margin: 0,
  bold: "1px",
  color: "#000000",
  style: "solid",
};

export default {
  name: "EditLines",
  components: { ColorSelect, LineStyleSelect, LineWidthSelect },
  props: {
    instance: {
      type: Object,
      default() {
        return {};
      },
    },
  },
  data() {
    return {
      modalForm: { ...initModalForm },
    };
  },
  mounted() {
    this.initData(this.instance);
  },
  methods: {
    initData(val) {
      this.modalForm = { ...val };
    },
    submit() {
      this.$emit("modified", this.modalForm);
    },
  },
};
</script>
