<template>
    <div>
        <div style="height: 800px; overflow: auto">
            <embed
                v-if="this.model.docXML"
                :src="pdf"
                type="application/pdf"
                height="100%"
                width="100%"
            />

            <c-row v-if="!this.model.docXML">
                <c-col v-for="(item, index) in model.docTXT" :key="index" >
                    <c-col :offset="4" :span="8">
                        {{ item[0] }}
                    </c-col>
                    <c-col :span="12">
                        {{ item[1] }}
                    </c-col>
                </c-col>
               
            </c-row>
        </div>
    </div>
</template>

<script>
import Api from "~/service/Api";

export default {
    data() {
        return {
            model: { docXML: "" },
            pdf: "data:application/pdf;base64,",
        };
    },
    created() {
        this.model.docXML = window.sessionStorage.docXML;
        this.model.docTXT = window.sessionStorage.docTXT
            .split("\r\n")
            .filter((item) => item)
            .map((item) => {
                let idx = item.indexOf(":");
                return [
                    item.substring(0, idx).trim(),
                    item.substring(idx + 1).trim(),
                ];
            });
        if (this.model.docXML != "")
            Api.post("pdf", { xml: this.model.docXML }).then((res) => {
                if (res.respCode == SUCCESS) {
                    this.pdf += res.data;
                }
            });
    },
};
</script>

<style scoped>
</style>