<template>
  <div class="edit-grids">
    <el-form
      ref="modalFormComp"
      :model="modalForm"
      :key="modalForm.id"
      label-width="100px"
    >
      <el-form-item prop="columnCount" label="单行网格数：">
        <el-input-number
          style="width: 125px"
          v-model.number="modalForm.columnCount"
          :min="2"
          :max="100"
          :step="1"
          step-strictly
          :controls="false"
        ></el-input-number>
      </el-form-item>
      <el-form-item prop="rowCount" label="网格行数：">
        <el-input-number
          style="width: 125px"
          v-model.number="modalForm.rowCount"
          :min="1"
          :max="100"
          :step="1"
          step-strictly
          :controls="false"
        ></el-input-number>
      </el-form-item>
      <el-form-item prop="rowSpace" label="网格行间距：">
        <el-input-number
          style="width: 125px"
          v-model.number="modalForm.rowSpace"
          :min="0"
          :max="100"
          :step="1"
          step-strictly
          :controls="false"
        ></el-input-number>
      </el-form-item>
      <el-form-item label="网格宽度：">
        <el-input-number
          style="width: 125px"
          v-model.number="modalForm.columnSize"
          :min="0"
          :max="100"
          :step="1"
          step-strictly
          :controls="false"
          :disabled="modalForm.halving"
        ></el-input-number>
      </el-form-item>
      <el-form-item>
        <el-checkbox v-model="modalForm.halving">是否自动网格宽度</el-checkbox>
      </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 LineStyleSelect from "../../components/common/LineStyleSelect";

const initModalForm = {
  id: "",
  columnSize: 43,
  columnCount: 16,
  rowCount: 3,
  rowSpace: 0,
  halving: true,
  style: "solid",
};

export default {
  name: "edit-grids",
  components: { LineStyleSelect },
  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>
