<template>
  <div class="bpmn-page">
    <Bpmn :xml="xml" @save="handleSave" @edit="handleEdit" />
  </div>
</template>

<script>
import ApiConstant from "@/api/ApiConstant";
import Bpmn from "@/components/bpmn";

export default {
  components: { Bpmn },
  data() {
    return {
      xml: undefined,
    };
  },
  methods: {
    handleSave(xml) {
      this.$axios
        .post(`${ApiConstant.PREFIX_CORE}/api/flowable/model`, {
          editor: xml,
          newVersion: 1,
        })
        .then(() => {
          this.$message.success(this.$t("ADD_SUCCESS"));
          this.$router.push({
            path: "/flowable/model",
          });
        });
    },
    handleEdit(xml) {
      this.xml = xml;
    },
  },
};
</script>

<style lang="less" scoped>
.bpmn-page {
  position: absolute;
  width: 100%;
  height: 100%;
}
</style>
