<template>
  <view class="leave-page">
    <JsQjEdit :data="qjData" v-if="qjData.id" />
  </view>
</template>

<script setup lang="ts">
import { findQjById } from "@/api/base/jsQjApi";
import { useDataStore } from "@/store/modules/data";
import { onLoad } from "@dcloudio/uni-app";
import JsQjEdit from "./components/jsQjEdit.vue";
const { setData, getData, getDb } = useDataStore();

const dbFlag = ref(false);

const qjData = computed(() => getData);

onLoad(async (data: any) => {
  // 从待办过来的，需要从后端获取数据
  if (data && data.from && data.from == "db") {
    dbFlag.value = true;
    if (getDb.dbZt === "B") {
      setData({ id: data.id });
      let url = "/pages/view/hr/jsQj/detail"; // 使用新路径
      uni.navigateTo({ url });
      return;
    }
    const res = await findQjById({ id: data.id });
    nextTick(() => {
      setData(res.result);
    });
  } else {
    dbFlag.value = false;
  }
});
</script>

<style lang="scss" scoped>
.leave-page {
  height: 100vh;
}
</style>
