|
@@ -38,6 +38,7 @@
|
|
<el-upload
|
|
<el-upload
|
|
class="avatar-uploader"
|
|
class="avatar-uploader"
|
|
:http-request="test"
|
|
:http-request="test"
|
|
|
|
+ accept=".pdf, .PDF"
|
|
:show-file-list="false"
|
|
:show-file-list="false"
|
|
:before-upload="beforeUp"
|
|
:before-upload="beforeUp"
|
|
>
|
|
>
|
|
@@ -117,174 +118,190 @@
|
|
:fileUserTreeData="treeData"
|
|
:fileUserTreeData="treeData"
|
|
@fileChangeMsg="fileChangeMsg"
|
|
@fileChangeMsg="fileChangeMsg"
|
|
></PicTree>
|
|
></PicTree>
|
|
- <div v-loading.fullscreen="loadingPreview" v-if="loadingPreview" class="lodingBox"></div>
|
|
|
|
|
|
+ <div
|
|
|
|
+ v-loading.fullscreen="loadingPreview"
|
|
|
|
+ v-if="loadingPreview"
|
|
|
|
+ class="lodingBox"
|
|
|
|
+ ></div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
-import { onMounted, ref, toRaw, watch, inject } from 'vue'
|
|
|
|
-import { ElMessage } from 'element-plus'
|
|
|
|
-import Clipboard from 'clipboard'
|
|
|
|
-import Loading from '@/components/Loading/Loading.vue'
|
|
|
|
-import PicTree from '@/components/PicTree/PicTree.vue' //选择文件发送的列表
|
|
|
|
-import { picTree, pdfTree } from '@/api/search/search.js'
|
|
|
|
-import { ocrRemark, preview } from '@/api/common/common.js'
|
|
|
|
-import { getInfo } from '@/api/biz/info.js'
|
|
|
|
-import Cookies from 'js-cookie'
|
|
|
|
-import axios from 'axios'
|
|
|
|
-const textData = ref('') //解析出来的文字
|
|
|
|
-const showImg = ref() //上传的图片
|
|
|
|
-const isOpen = ref(props.openFile)
|
|
|
|
-const thisStep = ref('start') //解析进度 start,loading,end,
|
|
|
|
-const openFile = ref(false) //控制tree显示
|
|
|
|
-const treeData = ref() //树节点数据
|
|
|
|
-const actionUrl = ref(`${window.location.origin}${import.meta.env.VITE_APP_BASE_API}/biz/info/pdf2word`)
|
|
|
|
|
|
+import { onMounted, ref, toRaw, watch, inject } from "vue";
|
|
|
|
+import { ElMessage } from "element-plus";
|
|
|
|
+import Clipboard from "clipboard";
|
|
|
|
+import Loading from "@/components/Loading/Loading.vue";
|
|
|
|
+import PicTree from "@/components/PicTree/PicTree.vue"; //选择文件发送的列表
|
|
|
|
+import { picTree, pdfTree } from "@/api/search/search.js";
|
|
|
|
+import { ocrRemark, preview } from "@/api/common/common.js";
|
|
|
|
+import { getInfo } from "@/api/biz/info.js";
|
|
|
|
+import Cookies from "js-cookie";
|
|
|
|
+import axios from "axios";
|
|
|
|
+const textData = ref(""); //解析出来的文字
|
|
|
|
+const showImg = ref(); //上传的图片
|
|
|
|
+const isOpen = ref(props.openFile);
|
|
|
|
+const thisStep = ref("start"); //解析进度 start,loading,end,
|
|
|
|
+const openFile = ref(false); //控制tree显示
|
|
|
|
+const treeData = ref(); //树节点数据
|
|
|
|
+const actionUrl = ref(
|
|
|
|
+ `${window.location.origin}${
|
|
|
|
+ import.meta.env.VITE_APP_BASE_API
|
|
|
|
+ }/biz/info/pdf2word`
|
|
|
|
+);
|
|
const headersObj = ref({
|
|
const headersObj = ref({
|
|
- Authorization: Cookies.get('Admin-Token')
|
|
|
|
-})
|
|
|
|
|
|
+ Authorization: Cookies.get("Admin-Token"),
|
|
|
|
+});
|
|
// const actionUrl = ref(`${window.location.origin}/upload`);
|
|
// const actionUrl = ref(`${window.location.origin}/upload`);
|
|
-const loadingPreview = ref(false)
|
|
|
|
-const addFolderAdd = inject('addFolderAdd')
|
|
|
|
|
|
+const loadingPreview = ref(false);
|
|
|
|
+const addFolderAdd = inject("addFolderAdd");
|
|
|
|
|
|
const props = defineProps({
|
|
const props = defineProps({
|
|
openFile: {
|
|
openFile: {
|
|
type: Boolean,
|
|
type: Boolean,
|
|
- default: false
|
|
|
|
- }
|
|
|
|
-})
|
|
|
|
|
|
+ default: false,
|
|
|
|
+ },
|
|
|
|
+});
|
|
watch(
|
|
watch(
|
|
() => props.openFile,
|
|
() => props.openFile,
|
|
(newValue) => {
|
|
(newValue) => {
|
|
// console.log(111);
|
|
// console.log(111);
|
|
- isOpen.value = newValue
|
|
|
|
|
|
+ isOpen.value = newValue;
|
|
}
|
|
}
|
|
-)
|
|
|
|
|
|
+);
|
|
|
|
|
|
-const test=function(file){
|
|
|
|
- console.log('file',file);
|
|
|
|
- const url=`${window.location.origin}${import.meta.env.VITE_APP_BASE_API}/biz/info/pdf2word`;
|
|
|
|
- return axios({
|
|
|
|
- method:'post',
|
|
|
|
- url:url,
|
|
|
|
- responseType:'blob',
|
|
|
|
- data:file,
|
|
|
|
- headers:{
|
|
|
|
- "Authorization":Cookies.get('Admin-Token'),
|
|
|
|
- 'Content-Type': 'multipart/form-data'
|
|
|
|
- }
|
|
|
|
- }).then(function(res){
|
|
|
|
- console.log('testres',res);
|
|
|
|
- // if(res.headers['content-disposition'] !== undefined){
|
|
|
|
- let blob = new Blob([res.data], { type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' })
|
|
|
|
- let fileName = decodeURI(res.headers['content-disposition'])
|
|
|
|
- if (fileName) {
|
|
|
|
- // fileName = fileName.substring(fileName.indexOf('=') + 1)
|
|
|
|
- // fileName = fileName.substring(0,fileName.lastIndexOf('.'))
|
|
|
|
- // alert(fileName)
|
|
|
|
- }
|
|
|
|
- const elink = document.createElement('a')
|
|
|
|
- console.log('fileName',fileName);
|
|
|
|
- elink.download = fileName.replace(new RegExp('"', 'g'), '')+'.docx'
|
|
|
|
- elink.style.display = 'none'
|
|
|
|
- elink.href = URL.createObjectURL(blob)
|
|
|
|
- document.body.appendChild(elink)
|
|
|
|
- elink.click()
|
|
|
|
- URL.revokeObjectURL(elink.href)
|
|
|
|
- document.body.removeChild(elink)
|
|
|
|
- loadingPreview.value = false
|
|
|
|
- // }
|
|
|
|
- })
|
|
|
|
-}
|
|
|
|
-const fileId2Word=function(fileId){
|
|
|
|
- console.log('fileId',fileId);
|
|
|
|
- const url=`${window.location.origin}${import.meta.env.VITE_APP_BASE_API}/biz/info/pdf2word/${fileId}`;
|
|
|
|
- return axios({
|
|
|
|
- method:'get',
|
|
|
|
- url:url,
|
|
|
|
- responseType:'blob',
|
|
|
|
- headers:{
|
|
|
|
- "Authorization":Cookies.get('Admin-Token'),
|
|
|
|
- 'Content-Type': 'multipart/form-data'
|
|
|
|
- }
|
|
|
|
- }).then(function(res){
|
|
|
|
- console.log('testres',res);
|
|
|
|
- // if(res.headers['content-disposition'] !== undefined){
|
|
|
|
- let blob = new Blob([res.data], { type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' })
|
|
|
|
- let fileName = decodeURI(res.headers['content-disposition'])
|
|
|
|
- if (fileName) {
|
|
|
|
- // fileName = fileName.substring(fileName.indexOf('=') + 1)
|
|
|
|
- // fileName = fileName.substring(0,fileName.lastIndexOf('.'))
|
|
|
|
- // alert(fileName)
|
|
|
|
- }
|
|
|
|
- const elink = document.createElement('a')
|
|
|
|
- console.log('fileName',fileName);
|
|
|
|
- elink.download = fileName.replace(new RegExp('"', 'g'), '')+'.docx'
|
|
|
|
- elink.style.display = 'none'
|
|
|
|
- elink.href = URL.createObjectURL(blob)
|
|
|
|
- document.body.appendChild(elink)
|
|
|
|
- elink.click()
|
|
|
|
- URL.revokeObjectURL(elink.href)
|
|
|
|
- document.body.removeChild(elink)
|
|
|
|
- loadingPreview.value = false
|
|
|
|
- // }
|
|
|
|
- })
|
|
|
|
-}
|
|
|
|
|
|
+const test = function (file) {
|
|
|
|
+ console.log("file", file);
|
|
|
|
+ const url = `${window.location.origin}${
|
|
|
|
+ import.meta.env.VITE_APP_BASE_API
|
|
|
|
+ }/biz/info/pdf2word`;
|
|
|
|
+ return axios({
|
|
|
|
+ method: "post",
|
|
|
|
+ url: url,
|
|
|
|
+ responseType: "blob",
|
|
|
|
+ data: file,
|
|
|
|
+ headers: {
|
|
|
|
+ Authorization: Cookies.get("Admin-Token"),
|
|
|
|
+ "Content-Type": "multipart/form-data",
|
|
|
|
+ },
|
|
|
|
+ }).then(function (res) {
|
|
|
|
+ console.log("testres", res);
|
|
|
|
+ if (res.headers["content-disposition"] !== undefined) {
|
|
|
|
+ let blob = new Blob([res.data], {
|
|
|
|
+ type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
|
|
+ });
|
|
|
|
+ let fileName = decodeURI(res.headers["content-disposition"]);
|
|
|
|
+ if (fileName) {
|
|
|
|
+ fileName = fileName.substring(fileName.indexOf("=") + 1);
|
|
|
|
+ fileName = fileName.substring(0, fileName.lastIndexOf("."));
|
|
|
|
+ // alert(fileName)
|
|
|
|
+ }
|
|
|
|
+ const elink = document.createElement("a");
|
|
|
|
+ console.log("fileName", fileName);
|
|
|
|
+ elink.download = fileName.replace(new RegExp('"', "g"), "") + ".docx";
|
|
|
|
+ elink.style.display = "none";
|
|
|
|
+ elink.href = URL.createObjectURL(blob);
|
|
|
|
+ document.body.appendChild(elink);
|
|
|
|
+ elink.click();
|
|
|
|
+ URL.revokeObjectURL(elink.href);
|
|
|
|
+ document.body.removeChild(elink);
|
|
|
|
+ loadingPreview.value = false;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+};
|
|
|
|
+const fileId2Word = function (fileId) {
|
|
|
|
+ console.log("fileId", fileId);
|
|
|
|
+ const url = `${window.location.origin}${
|
|
|
|
+ import.meta.env.VITE_APP_BASE_API
|
|
|
|
+ }/biz/info/pdf2word/${fileId}`;
|
|
|
|
+ return axios({
|
|
|
|
+ method: "get",
|
|
|
|
+ url: url,
|
|
|
|
+ responseType: "blob",
|
|
|
|
+ headers: {
|
|
|
|
+ Authorization: Cookies.get("Admin-Token"),
|
|
|
|
+ "Content-Type": "multipart/form-data",
|
|
|
|
+ },
|
|
|
|
+ }).then(function (res) {
|
|
|
|
+ console.log("testres", res);
|
|
|
|
+ if (res.headers["content-disposition"] !== undefined) {
|
|
|
|
+ let blob = new Blob([res.data], {
|
|
|
|
+ type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
|
|
+ });
|
|
|
|
+ let fileName = decodeURI(res.headers["content-disposition"]);
|
|
|
|
+ if (fileName) {
|
|
|
|
+ fileName = fileName.substring(fileName.indexOf("=") + 1);
|
|
|
|
+ fileName = fileName.substring(0, fileName.lastIndexOf("."));
|
|
|
|
+ // alert(fileName)
|
|
|
|
+ }
|
|
|
|
+ const elink = document.createElement("a");
|
|
|
|
+ console.log("fileName", fileName);
|
|
|
|
+ elink.download = fileName.replace(new RegExp('"', "g"), "") + ".docx";
|
|
|
|
+ elink.style.display = "none";
|
|
|
|
+ elink.href = URL.createObjectURL(blob);
|
|
|
|
+ document.body.appendChild(elink);
|
|
|
|
+ elink.click();
|
|
|
|
+ URL.revokeObjectURL(elink.href);
|
|
|
|
+ document.body.removeChild(elink);
|
|
|
|
+ loadingPreview.value = false;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+};
|
|
|
|
|
|
-onMounted(async () => {})
|
|
|
|
|
|
+onMounted(async () => {});
|
|
|
|
|
|
const handleAvatarSuccess = (msg, file) => {
|
|
const handleAvatarSuccess = (msg, file) => {
|
|
// console.log('re', msg)
|
|
// console.log('re', msg)
|
|
- const flieData = toRaw(file)
|
|
|
|
|
|
+ const flieData = toRaw(file);
|
|
// console.log('file', flieData)
|
|
// console.log('file', flieData)
|
|
// setTimeout(() => {
|
|
// setTimeout(() => {
|
|
// downLoadfile(flieData.raw,file);
|
|
// downLoadfile(flieData.raw,file);
|
|
// }, 500);
|
|
// }, 500);
|
|
- const blob = new Blob([msg]) //excel,pdf等
|
|
|
|
- const href = URL.createObjectURL(blob) //创建新的URL表示指定的blob对象
|
|
|
|
- const a = document.createElement('a') //创建a标签
|
|
|
|
- a.style.display = 'none'
|
|
|
|
- a.href = href // 指定下载链接
|
|
|
|
- a.download = file.name + '.docx' //指定下载文件名
|
|
|
|
- a.click() //触发下载
|
|
|
|
- URL.revokeObjectURL(a.href) //释放URL对象
|
|
|
|
- ElMessage({ message: '转换成功,已下载到本地', type: 'success' })
|
|
|
|
- loadingPreview.value = false
|
|
|
|
-}
|
|
|
|
|
|
+ const blob = new Blob([msg]); //excel,pdf等
|
|
|
|
+ const href = URL.createObjectURL(blob); //创建新的URL表示指定的blob对象
|
|
|
|
+ const a = document.createElement("a"); //创建a标签
|
|
|
|
+ a.style.display = "none";
|
|
|
|
+ a.href = href; // 指定下载链接
|
|
|
|
+ a.download = file.name + ".docx"; //指定下载文件名
|
|
|
|
+ a.click(); //触发下载
|
|
|
|
+ URL.revokeObjectURL(a.href); //释放URL对象
|
|
|
|
+ ElMessage({ message: "转换成功,已下载到本地", type: "success" });
|
|
|
|
+ loadingPreview.value = false;
|
|
|
|
+};
|
|
//文件上传前的钩子
|
|
//文件上传前的钩子
|
|
const beforeUp = (raw) => {
|
|
const beforeUp = (raw) => {
|
|
// console.log('raw',raw);
|
|
// console.log('raw',raw);
|
|
// showImg.value = URL.createObjectURL(raw);
|
|
// showImg.value = URL.createObjectURL(raw);
|
|
- loadingPreview.value = true
|
|
|
|
|
|
+ loadingPreview.value = true;
|
|
// thisStep.value = "loading";
|
|
// thisStep.value = "loading";
|
|
-}
|
|
|
|
|
|
+};
|
|
// 复制功能调用的方法
|
|
// 复制功能调用的方法
|
|
const copyQbUrl = () => {
|
|
const copyQbUrl = () => {
|
|
- let clipboard = new Clipboard('.copy-qb', {
|
|
|
|
|
|
+ let clipboard = new Clipboard(".copy-qb", {
|
|
text: () => {
|
|
text: () => {
|
|
- return textData.value
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- clipboard.on('success', () => {
|
|
|
|
|
|
+ return textData.value;
|
|
|
|
+ },
|
|
|
|
+ });
|
|
|
|
+ clipboard.on("success", () => {
|
|
// console.log('success');
|
|
// console.log('success');
|
|
- ElMessage({ message: '复制成功', type: 'success' })
|
|
|
|
- clipboard.destroy()
|
|
|
|
- })
|
|
|
|
- clipboard.on('error', () => {
|
|
|
|
|
|
+ ElMessage({ message: "复制成功", type: "success" });
|
|
|
|
+ clipboard.destroy();
|
|
|
|
+ });
|
|
|
|
+ clipboard.on("error", () => {
|
|
// console.log('err');
|
|
// console.log('err');
|
|
- clipboard.destroy()
|
|
|
|
- })
|
|
|
|
-}
|
|
|
|
|
|
+ clipboard.destroy();
|
|
|
|
+ });
|
|
|
|
+};
|
|
// 选取文库图片
|
|
// 选取文库图片
|
|
const addlibraryImg = async () => {
|
|
const addlibraryImg = async () => {
|
|
- const res = await pdfTree()
|
|
|
|
- console.log('res', res)
|
|
|
|
- treeData.value = res
|
|
|
|
- openFile.value = true
|
|
|
|
-}
|
|
|
|
|
|
+ const res = await pdfTree();
|
|
|
|
+ console.log("res", res);
|
|
|
|
+ treeData.value = res;
|
|
|
|
+ openFile.value = true;
|
|
|
|
+};
|
|
//确定选中图片
|
|
//确定选中图片
|
|
const fileChangeMsg = async (val) => {
|
|
const fileChangeMsg = async (val) => {
|
|
- console.log('val', toRaw(val))
|
|
|
|
- loadingPreview.value = true
|
|
|
|
- fileId2Word(val.remark)
|
|
|
|
|
|
+ console.log("val", toRaw(val));
|
|
|
|
+ loadingPreview.value = true;
|
|
|
|
+ fileId2Word(val.remark);
|
|
// const res = await getInfo(val.id)
|
|
// const res = await getInfo(val.id)
|
|
// const data = toRaw(val)
|
|
// const data = toRaw(val)
|
|
// const imgRes = await preview(data.id)
|
|
// const imgRes = await preview(data.id)
|
|
@@ -295,40 +312,40 @@ const fileChangeMsg = async (val) => {
|
|
// textData.value = res.msg
|
|
// textData.value = res.msg
|
|
// console.log("res", res);
|
|
// console.log("res", res);
|
|
// console.log("imgRes", imgRes);
|
|
// console.log("imgRes", imgRes);
|
|
-}
|
|
|
|
|
|
+};
|
|
const reClick = () => {
|
|
const reClick = () => {
|
|
- thisStep.value = 'start'
|
|
|
|
- textData.value = null
|
|
|
|
- showImg.value = null
|
|
|
|
-}
|
|
|
|
|
|
+ thisStep.value = "start";
|
|
|
|
+ textData.value = null;
|
|
|
|
+ showImg.value = null;
|
|
|
|
+};
|
|
// 文件下载
|
|
// 文件下载
|
|
const downLoadfile = (res, file) => {
|
|
const downLoadfile = (res, file) => {
|
|
// console.log('downLoadfileres',res);
|
|
// console.log('downLoadfileres',res);
|
|
- var reader = new FileReader()
|
|
|
|
|
|
+ var reader = new FileReader();
|
|
reader.onloadend = function (event) {
|
|
reader.onloadend = function (event) {
|
|
//event 就是你要的返回内容
|
|
//event 就是你要的返回内容
|
|
//因为返回的报错格式是字符串,手动转换成对象,转换成功表示请求失败
|
|
//因为返回的报错格式是字符串,手动转换成对象,转换成功表示请求失败
|
|
//转换失败就意味着你拿到的result是文件流,那么直接手动下载就好
|
|
//转换失败就意味着你拿到的result是文件流,那么直接手动下载就好
|
|
try {
|
|
try {
|
|
- let data = JSON.parse(event.target.result)
|
|
|
|
|
|
+ let data = JSON.parse(event.target.result);
|
|
} catch (err) {
|
|
} catch (err) {
|
|
- const time = Date.now()
|
|
|
|
|
|
+ const time = Date.now();
|
|
// console.log('time',time);
|
|
// console.log('time',time);
|
|
- const link = document.createElement('a') // 创建a标签
|
|
|
|
- let blob = new Blob([res])
|
|
|
|
- link.style.display = 'none'
|
|
|
|
- link.href = URL.createObjectURL(blob) // 创建下载的链接
|
|
|
|
|
|
+ const link = document.createElement("a"); // 创建a标签
|
|
|
|
+ let blob = new Blob([res]);
|
|
|
|
+ link.style.display = "none";
|
|
|
|
+ link.href = URL.createObjectURL(blob); // 创建下载的链接
|
|
// link.setAttribute("download", clickRow.value.fileName); // 给下载后的文件命名
|
|
// link.setAttribute("download", clickRow.value.fileName); // 给下载后的文件命名
|
|
- link.setAttribute('download', file.name + '.docx') // 给下载后的文件命名
|
|
|
|
- document.body.appendChild(link)
|
|
|
|
- link.click() // 点击下载
|
|
|
|
- document.body.removeChild(link) // 完成移除元素
|
|
|
|
- window.URL.revokeObjectURL(link.href) // 释放blob对象
|
|
|
|
|
|
+ link.setAttribute("download", file.name + ".docx"); // 给下载后的文件命名
|
|
|
|
+ document.body.appendChild(link);
|
|
|
|
+ link.click(); // 点击下载
|
|
|
|
+ document.body.removeChild(link); // 完成移除元素
|
|
|
|
+ window.URL.revokeObjectURL(link.href); // 释放blob对象
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ };
|
|
// console.log('downLoadfileres',res);
|
|
// console.log('downLoadfileres',res);
|
|
- reader.readAsText(res)
|
|
|
|
-}
|
|
|
|
|
|
+ reader.readAsText(res);
|
|
|
|
+};
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|
|
@@ -472,7 +489,7 @@ const downLoadfile = (res, file) => {
|
|
.light_box {
|
|
.light_box {
|
|
width: 500px;
|
|
width: 500px;
|
|
height: 500px;
|
|
height: 500px;
|
|
- background-image: url('@/assets/images/light_boder.png');
|
|
|
|
|
|
+ background-image: url("@/assets/images/light_boder.png");
|
|
background-repeat: no-repeat;
|
|
background-repeat: no-repeat;
|
|
background-size: contain;
|
|
background-size: contain;
|
|
position: relative;
|
|
position: relative;
|