<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" :row="infoData"></add-form>
      </div>
      <div class="add-btns">
        <el-button size="default" @click="Cancle">取消</el-button>
        <el-button type="primary" size="default" @click="Save">保存</el-button>
        <el-button type="success" size="default" @click="Distribute">立即下发</el-button>
      </div>
    </div>
  </div>
</template>

<script setup>
import { onMounted, ref } from "vue";
import { useRouter } from "vue-router";
import bgBreadcrumb from "@/components/bg-breadcrumb.vue";
import addForm from "../modules/add-form.vue";
const router = useRouter();
const infoData = ref({});
const Cancle = () => {
  router.go(-1);
};
const add_form = ref(null);
const Save = async () => {
  let res = await add_form.value.Submit();
  if (!res) return;
  console.log("res: ", res);
};
const Distribute = async () => {
  let res = await add_form.value.Submit();
  if (!res) return;
  console.log("res: ", res);
};
onMounted(() => {
  setTimeout(() => {
    infoData.value = {
      ticket_name: 11,
      id: 111,
      status: 1,
      finish: 10,
      all: 10,
      history: {
        method: ["1", "2"],
        lists: [
          {
            user_id: "1111",
            user_name: "11111111",
            phone: "13011111111",
          },
        ],
      },
      ticket_name: "1",
      ticket_level: 1,
      ticket_desc: "1111",
      timing_rules: 2,
      rules: {
        lists: [
          {
            date: ["2023-01-01", "2023-12-31"],
            time: "00:00:00",
          },
          {
            date: ["2023-01-01", "2023-12-31"],
            time: "00:00:01",
          },
        ],
        week_days: [1, 2, 3, 4, 6],
        time: "00:00:03",
      },
    };
  }, 1000);
});
</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>
