<template>
  <uv-popup ref="popupRef" mode="bottom" round="30rpx" closeable>
    <view class="contract-template">
      <view class="popup-title">预览</view>
      <scroll-view class="scroll-view" scroll-y>
        <uv-parse :content="content"></uv-parse>
      </scroll-view>
    </view>
  </uv-popup>
</template>

<script setup name="contractTemplate">
import { ref } from "vue";
import { agentGetContractPreview_Api } from "@/api/agencyCenter";

const popupRef = ref(null);
const content = ref("");
const getContractPreview = async (form) => {
  uni.showLoading({ title: "加载中", mask: true });
  await agentGetContractPreview_Api(form)
    .then((res) => {
      uni.hideLoading();
      if (res.code == 200) {
        content.value = res.data || {};
      }
    })
    .catch((err) => {
      console.log(err);
      // uni.hideLoading();
    });
};

const open = async (form) => {
  await getContractPreview(form);
  popupRef.value.open();
};

defineExpose({
  open,
});
</script>

<style scoped lang="scss">
.contract-template {
  padding-top: 30rpx;
  .popup-title {
    padding-bottom: 20rpx;
  }
  .scroll-view {
    height: 70vh;
    padding: 0 30rpx;
    box-sizing: border-box;
  }
}
</style>
