<template>
  <div class="add-ticket">
    <div class="breadcrumb">
      <bg-breadcrumb />
    </div>
    <div class="content">
      <div class="add-form-main bg-scroll">
        <add-form ref="add_form"></add-form>
      </div>
      <div class="add-btns">
        <el-button size="default" @click="Cancle">取消</el-button>
        <el-button type="primary" size="default" @click="SaveSubmit">保存</el-button>
        <el-button type="primary" size="default" @click="Distribute">立即下发</el-button>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from "vue";
import { useRouter } from "vue-router";
import bgBreadcrumb from "@/components/bg-breadcrumb.vue";
import addForm from "../modules/add-form.vue";
import { Save } from "../modules/interface.js";
const router = useRouter();
const Cancle = () => {
  router.go(-1);
};
const add_form = ref(null);
const SaveSubmit = async () => {
  let res = await add_form.value.Submit();
  if (!res) return;
  Save({ res, is_push: 0 }, { url: "/v1/api/work_order/work_order_manage/add" }, () => {
    Cancle();
  });
};
const Distribute = async () => {
  let res = await add_form.value.Submit();
  if (!res) return;
  Save({ res, is_push: 1 }, {}, () => {
    Cancle();
  });
};
</script>

<style lang="scss" scoped>
.add-ticket {
  width: 100%;
  height: 100%;
  padding: 0 24px 16px;
  .breadcrumb {
    width: 100%;
    height: 46px;
  }
  .content {
    width: 100%;
    height: calc(100% - 46px);
    background-color: #ffffff;
    box-shadow: 0px 1px 4px 0px rgba(0, 7, 101, 0.15);
    border-radius: 6px;
    .add-form-main {
      padding: 24px;
      height: calc(100% - 68px);
    }
    .add-btns {
      height: 68px;
      display: flex;
      align-items: center;
      justify-content: flex-end;
      border-top: 1px solid #ddd;
      padding: 0 24px;
    }
  }
}
</style>
