<template>
  <div>
    <a-form-model ref="addForm" :model="form" :rules="rules">
      <a-form-model-item
        v-show="form.parentCategoryName"
        :label="$t('SUP_CATEGORY')"
        prop="parentCategoryName"
      >
        <a-input v-model="form.parentCategoryName" disabled />
      </a-form-model-item>
      <a-form-model-item
        prop="categoryCode"
        allow-clear
        :label="$t('CATEGORY_CODE')"
      >
        <a-input v-model="form.categoryCode" :placeholder="$t('PLACEENTER')" />
      </a-form-model-item>
      <a-form-model-item
        prop="categoryName"
        allow-clear
        :label="$t('CATEGORY_NAME')"
        :placeholder="$t('PLACEENTER')"
      >
        <a-input v-model="form.categoryName" />
      </a-form-model-item>
      <a-form-model-item
        prop="seq"
        allow-clear
        :label="$t('ORDER')"
        :placeholder="$t('PLACEENTER')"
      >
        <a-input v-model="form.seq" />
      </a-form-model-item>
      <a-form-model-item :label="$t('REMARK')" prop="">
        <a-textarea
          v-model="form.remark"
          allow-clear
          :placeholder="$t('PLACEENTER')"
          :auto-size="{ minRows: 2, maxRows: 6 }"
        />
      </a-form-model-item>
    </a-form-model>
  </div>
</template>

<script>
import ApiConstant from "@/api/ApiConstant";

export default {
  props: {
    id: { type: String, default: "" },
    disabled: { type: Boolean, default: false },
  },
  data() {
    return {
      form: {
        id: undefined,
        superLevel: undefined,
        categoryCode: undefined,
        categoryName: "100",
        seq: "100",
        remark: undefined,
        parent: {
          id: undefined,
          categoryName: undefined,
        },
      },
      requestData: null,
    };
  },
  computed: {
    rules() {
      return {};
    },
  },
  created() {
    this.id &&
      this.$axios.get(`${ApiConstant.PREFIX_CORE}`).then((res) => {
        this.form = { ...res.data.data };
      });
  },
  methods: {
    confirm() {
      this.requestData = { ...this.form };
      return this.$axios.post(
        `${ApiConstant.PREFIX_CORE}/api/flowable/category`,
        this.requestData
      );
    },
  },
};
</script>
