<template>
  <div class="detail_container">
    <bg-breadcrumb></bg-breadcrumb>
    <div class="main_container">
      <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>
      </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";
// const infoData = ref({
//   id: 1,
//   name: "11",
//   type_key: "static",
//   duration: 1,
//   time: 10,
//   inspection_cycle: 1,
//   push_num: 1,
//   push_frequency: 60,
//   enabled: true,
//   type_com_ref: {
//     warn_type: "colony",
//     warn_indicator: "1",
//     warn_target: "1",
//     warn_type_com: {
//       value1: "22",
//       value1_select: "3",
//       value2: "33",
//       value2_select: "2",
//       risk_level: 1,
//     },
//   },
//   manual_distribution_form: {
//     method: ["1", "2"],
//     lists: [
//       {
//         user_id: 2,
//         user_name: 22,
//         phone: 13000000002,
//       },
//       {
//         user_id: 3,
//         user_name: 33,
//         phone: 13000000003,
//       },
//     ],
//   },
// });
const infoData = ref({
  name: "11",
  type_key: "static",
  duration: 1,
  time: 10,
  inspection_cycle: 1,
  push_num: 1,
  push_frequency: 60,
  enabled: true,
  type_com_ref: {
    warn_type: "gateway",
    warn_indicator: "1",
    warn_target: "1",
    warn_type_com: {
      ruleRows: [
        {
          from: "22",
          to: "33",
          risk_level: 1,
        },
        {
          from: "44",
          to: "55",
          risk_level: 2,
        },
      ],
    },
  },
  manual_distribution_form: {
    method: ["1"],
    lists: [
      {
        user_id: 1,
        user_name: 11,
        phone: 13000000001,
      },
    ],
  },
});
// const infoData = ref({
//   id: 1,
//   name: "11",
//   type_key: "static",
//   duration: 1,
//   time: 10,
//   inspection_cycle: 1,
//   push_num: 1,
//   push_frequency: 60,
//   enabled: true,
//   type_com_ref: {
//     warn_type: "colony",
//     warn_indicator: "1",
//     warn_target: "1",
//     warn_type_com: {
//       value1: "22",
//       value1_select: "3",
//       value2: "33",
//       value2_select: "2",
//       risk_level: 1,
//     },
//   },
//   manual_distribution_form: {
//     method: ["1", "2"],
//     lists: [
//       {
//         user_id: 2,
//         user_name: 22,
//         phone: 13000000002,
//       },
//       {
//         user_id: 3,
//         user_name: 33,
//         phone: 13000000003,
//       },
//     ],
//   },
// });
// const infoData = ref({
//   name: "11",
//   type_key: "custom",
//   duration: 1,
//   time: 10,
//   inspection_cycle: 1,
//   push_num: 1,
//   push_frequency: 60,
//   enabled: true,
//   type_com_ref: {
//     warn_target: "22",
//     warn_type: "33",
//     warn_indicator: "44",
//     indicator_expression: "55\n66\n77",
//     rule_type: "1",
//     ruleRows: [
//       {
//         from: "88",
//         to: "99",
//         risk_level: 1,
//       },
//     ],
//   },
//   manual_distribution_form: {
//     method: ["1", "2"],
//     lists: [
//       {
//         user_id: 1,
//         user_name: 11,
//         phone: 13000000001,
//       },
//       {
//         user_id: 2,
//         user_name: 22,
//         phone: 13000000002,
//       },
//     ],
//   },
// });
const router = useRouter();
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);
};
</script>

<style lang="scss" scoped>
.detail_container {
  width: 100%;
  height: calc(100vh - 56px);
  padding: 0 24px 16px;
  min-height: 100%;
  .main_container {
    height: calc(100% - 46px);
    padding: 0;
    .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>
