提交 c5cb227a authored 作者: 龙菲's avatar 龙菲

修复pdf无法添加第二条笔记的问题;完善pdf笔记模块;我的笔记模块增加按原文和笔记搜索;

上级 168298f1
......@@ -1564,7 +1564,7 @@
}
rAddAnnotation(annotations) {
const ids = annotations.map((o) => o.id);
const ds = [...this._annotations].filter((o) => !ids.include(o.id));
const ds = [...this._annotations].filter((o) => !ids.includes(o.id));
this._annotations = [...ds, ...annotations];
}
removeAnnotation(id) {
......
......@@ -2154,10 +2154,14 @@
this._hasJSActionsPromise,
this._fieldObjectsPromise,
]);
this.show();
if (this.annotationLayer) {
this.annotationLayer?.addElement({
annotations: [data],
this.div.innerHTML = "";
// this.annotationLayer.addElement({
this.annotationLayer?.render({
annotations: [...data],
imageResourcesPath: this.imageResourcesPath,
renderForms: this.renderForms,
linkService: this.linkService,
......@@ -2202,6 +2206,7 @@
if (!this.div) {
div = this.div = document.createElement("div");
div.className = "annotationLayer";
this.pageDiv.append(div);
}
if (annotations.length === 0 && ss.length === 0) {
......
......@@ -21,6 +21,16 @@ export const getCollect = params => {
})
}
// 点击添加收藏
export const addFavorite = params => {
return request({
url: baseUrl + '/folder/file/addFavorite',
method: 'get',
params
})
}
// 取消收藏
export const cancelCollect = params => {
return request({
......
......@@ -51,6 +51,7 @@ import noteIcon from "./icon/note.svg";
import highlightIcon from "./icon/hign.svg";
import strikeOutIcon from "./icon/se.svg";
import { showMagBox } from "./message/index";
import { textCopy } from "@/utils/index";
pdfjsLib.GlobalWorkerOptions.workerSrc = "/pdf.worker.js";
......@@ -122,19 +123,21 @@ export default {
},
copy() {
const text = document.getSelection().toString();
navigator.clipboard
.writeText(text)
.then(() => {
showMagBox({
type: "info",
msg: "复制成功",
});
this.closeMenu();
this.$emit("copy", text);
})
.catch((err) => {
console.log("无法复制文本: ", err);
});
textCopy(text);
this.$message.success("已复制到剪贴板");
// navigator.clipboard
// .writeText(text)
// .then(() => {
// showMagBox({
// type: "info",
// msg: "复制成功",
// });
// this.closeMenu();
// this.$emit("copy", text);
// })
// .catch((err) => {
// console.log("无法复制文本: ", err);
// });
},
addNote() {
this.closeMenu();
......@@ -279,21 +282,21 @@ export default {
icon: noteIcon,
event: this.addNote,
},
{
name: "下划线",
icon: underlineIcon,
event: this.Underline,
},
{
name: "高亮",
icon: highlightIcon,
event: this.highlight,
},
{
name: "删除线",
icon: strikeOutIcon,
event: this.StrikeOut,
},
// {
// name: "下划线",
// icon: underlineIcon,
// event: this.Underline,
// },
// {
// name: "高亮",
// icon: highlightIcon,
// event: this.highlight,
// },
// {
// name: "删除线",
// icon: strikeOutIcon,
// event: this.StrikeOut,
// },
...this.contextmenuList,
];
},
......
......@@ -300,8 +300,6 @@ const fileFunction = {
* @param {array} fileList 文件列表
*/
handleFileNameClickNew(row, currentIndex = 0, fileList = []) {
// console.log('row', row);
// return
// 若是文件夹则进入该文件夹
if (row.isDir) {
router.push({
......@@ -315,8 +313,8 @@ const fileFunction = {
const WORD = ['doc', 'docx']
const PDF = ['pdf']
// 若当前点击项是word
let extendName = row.extendName || row.suffix || row.showType
const { fileId, userId, id } = row
let extendName = row.extendName || row.suffix || row.showType || row.docSType
const { fileId, userId, id, docId } = row
if (WORD.includes(extendName.toLowerCase())) {
let flag = false
// 根据当前文件的作者的userId进行判断,和本人一致则是可编辑
......
......@@ -154,6 +154,12 @@ import { getNoteAllFilesList, getNoteByFile } from "@/api/doc/index";
import noteOperationMixins from "./noteOperationMixins";
export default {
mixins: [noteOperationMixins],
props: {
content: {
type: String,
default: "",
},
},
data() {
return {
keyword: "", //文件名关键词,搜索文件时使用
......@@ -236,6 +242,7 @@ export default {
currentPage: current,
pageCount: size,
fileId: this.currentFileId,
content: this.content,
};
let res = await getNoteByFile(params);
this.loading = false;
......@@ -399,14 +406,9 @@ export default {
.tag {
float: left;
}
// display: flex;
// justify-content: space-between;
.oprations {
float: right;
margin-bottom: 8px;
// display: flex;
// justify-content: flex-end;
.el-link {
margin-right: 16px;
......@@ -433,7 +435,15 @@ export default {
}
}
.page {
// width: 100%;
display: flex;
justify-content: center;
height: 70px;
}
.el-pagination {
// width: 100%;
padding: 10px;
background-color: #fff;
position: absolute;
......@@ -442,9 +452,5 @@ export default {
justify-content: center;
}
.page {
display: flex;
justify-content: center;
height: 70px;
}
</style>
......@@ -127,7 +127,7 @@
@current-change="handleCurrentChangeNote"
:current-page.sync="noteList.current"
:page-size="noteList.size"
layout="prev, pager, next"
layout="prev, pager, next,total"
:total="tagList.total"
>
</el-pagination>
......@@ -150,6 +150,12 @@ import { getNoteAllTagList, getNoteByTag } from "@/api/doc/index";
import noteOperationMixins from "./noteOperationMixins";
export default {
mixins: [noteOperationMixins],
props: {
content: {
type: String,
default: "",
},
},
data() {
return {
keyword: "", //标签名关键词,搜索文件时使用
......@@ -231,6 +237,7 @@ export default {
currentPage: current,
pageCount: size,
id: this.currentTagId,
content: this.content,
};
let res = await getNoteByTag(params);
this.loading = false;
......@@ -364,7 +371,7 @@ export default {
padding: 12px 16px 4px;
margin-bottom: 8px;
background-color: #eef0f4;
// border-bottom: 1px solid #333;
// border-bottom: 1px solid #333;
border-radius: 4px;
.info-title {
color: #333;
......@@ -432,14 +439,16 @@ export default {
background-color: #fff;
position: absolute;
bottom: 0;
// width: 100%;
width: 100%;
display: flex;
justify-content: center;
}
.page {
width: 100%;
display: flex;
justify-content: center;
background-color: #fff;
}
::v-deep .el-tabs__header {
......
......@@ -63,8 +63,9 @@ export default {
let res = await deleteNote(params);
if (res.code == 200) {
this.$message.success("操作成功");
this.loadLeftList();
this.loadNoteList();
}
},
}
}
......@@ -3,13 +3,23 @@
<el-tabs v-model="activeName" type="card">
<el-tab-pane name="byFile">
<span slot="label"><i class="el-icon-document"></i> 按文件分类</span>
<NoteByFile ref="NoteByFile" />
<NoteByFile ref="NoteByFile" :content="content" />
</el-tab-pane>
<el-tab-pane name="byTag">
<span slot="label"><i class="el-icon-price-tag"></i> 按标签分类</span>
<NoteByTag ref="NoteByTag" />
<NoteByTag ref="NoteByTag" :content="content" />
</el-tab-pane>
</el-tabs>
<div class="input">
<el-input
v-model="content"
@keyup.native.enter="handleSearch"
clearable
placeholder="请输入关键词搜索原文或者笔记"
size="mini"
suffix-icon="el-icon-search"
></el-input>
</div>
</div>
</template>
<script>
......@@ -23,6 +33,7 @@ export default {
data() {
return {
activeName: "byFile",
content: "",
};
},
watch: {
......@@ -34,11 +45,29 @@ export default {
}
},
},
methods: {
handleSearch() {
if (this.activeName == "byFile") {
this.$refs.NoteByFile.loadLeftList();
} else {
this.$refs.NoteByTag.loadLeftList();
}
},
},
};
</script>
<style lang="scss" scoped>
.app-containter {
position: relative;
}
::v-deep .el-tab-pane {
height: calc(100vh - 180px);
}
.input {
width: 400px;
position: absolute;
right: 20px;
top: 20px;
}
</style>
......@@ -270,7 +270,6 @@ export default {
// 点击选择颜色
handleClickColor(color) {
this.currentColor = color;
console.log("this.currentColor", this.currentColor);
},
},
};
......
......@@ -11,7 +11,7 @@
@keyup.enter.native="handleSearch"
clearable
></el-input>
<el-select
<!-- <el-select
v-if="!currrentFileOnly"
size="mini"
v-model="searchParams.tagId"
......@@ -31,22 +31,23 @@
:value="item.id"
>
</el-option>
</el-select>
</el-select> -->
</div>
<div class="total">
<i class="el-icon-refresh"></i>
<i
class="el-icon-refresh"
style="cursor: pointer"
@click="hanleUpdate"
></i>
<span>{{ noteList.records.length }}条数据</span>
</div>
<div
class="note-list"
v-if="noteList.records.length > 0"
v-loading="loading"
>
<div class="note-list" v-if="noteList.records.length > 0">
<el-card
class="note-item"
:class="['note-item', currentNote == item ? 'active' : '']"
v-for="(item, index) in noteList.records"
:key="index"
shadow="hover"
@click.native="handleSwitchPage(item)"
>
<div class="card-header">
<div class="tag" v-if="item.tagName && item.tagName.length > 0">
......@@ -171,7 +172,13 @@ export default {
// }
},
// 子/孙组件中用inject接收父组件传来的值,全部返回的都是函数来确保响应式,需要调用才能获取值
inject: ["readOnly", "currrentFileOnly", "fileId"],
inject: [
"readOnly",
"currrentFileOnly",
"fileId",
"updateNoteList",
"pdfSwitchPage",
],
data() {
return {
searchParams: {
......@@ -183,10 +190,10 @@ export default {
oldContent: "", //用于记录上一次搜索的关键词,以至于不会被实时影响关键词着色效果
loading: false,
dropdownList: [
{
label: "查看原文",
value: "view",
},
// {
// label: "查看原文",
// value: "view",
// },
{
label: "编辑笔记",
value: "edit",
......@@ -197,7 +204,6 @@ export default {
},
],
noteList: {
// records: notes,
records: [],
current: 1,
size: 20,
......@@ -209,6 +215,7 @@ export default {
size: 20,
total: 0,
},
currentNote: {}, //当前笔记
};
},
mounted() {
......@@ -222,39 +229,26 @@ export default {
this.loading = true;
const { current, size } = this.noteList;
const { content } = this.searchParams;
const fileId = this.fileId();
const params = {
currentPage: current,
pageCount: size,
fileId,
content,
};
// 只有仅阅读当前文件的笔记时才带fileId查询
if (this.currentFileOnly) {
const fileId = this.fileId(); //fileId注入的是一个函数
params.fileId = fileId;
}
let res = await getNoteByFile(params);
this.oldContent = content;
this.loading = false;
if (res.code == 200) {
this.noteList = res.data;
if (this.updateNoteList) {
this.updateNoteList(this.noteList.records);
}
}
},
// 加载笔记列表
// async loadNoteList() {
// this.loading = true;
// const { current, size } = this.noteList;
// const { content, tagId } = this.searchParams;
// const params = {
// currentPage: current,
// pageCount: size,
// id: tagId,
// content,
// };
// let res = await getNoteByTag(params);
// this.oldContent = content;
// this.loading = false;
// if (res.code == 200) {
// this.noteList = res.data;
// this.loadTagList();
// }
// },
// 搜索
handleSearch() {
this.loadNoteList();
......@@ -328,7 +322,7 @@ export default {
}
return res; //此时的res里已经将需要标红的字体带上了格式(<span style="color:red"></span>
},
// 文件列表current
// 文件列表size
handleSizeChangeNote(value) {
this.tagList.pageCount = value;
this.loadNoteList();
......@@ -339,6 +333,30 @@ export default {
this.tagList.currentPage = value;
this.loadNoteList();
},
// 点击笔记跳转
handleSwitchPage(item) {
if (item == this.currentNote) {
this.currentNote = {};
} else {
this.currentNote = item;
}
if (!this.readOnly) {
// 如果不是只读,是可编辑的状态则不需要跳转
return;
}
const jsonStr = JSON.parse(item.jsonStr);
const { page } = jsonStr;
if (this.pdfSwitchPage) {
this.pdfSwitchPage(page + 1);
}
},
// 点击刷新
hanleUpdate() {
this.loadNoteList();
},
},
};
</script>
......@@ -373,6 +391,7 @@ export default {
.note-item {
margin-bottom: 16px;
font-size: 14px;
cursor: pointer;
.tag {
display: flex;
justify-content: space-between;
......@@ -390,6 +409,9 @@ export default {
}
}
}
.active {
border: 1px solid $theme-blue;
}
.card-header {
height: 30px;
.tag {
......
......@@ -39,7 +39,7 @@ import RightPanel from "../components/rightPanel.vue";
import AddOrUpdateNoteDialog from "../components/addOrUpdateNoteDialog.vue";
import { deepCopy } from "@/utils/index";
import { getNoteByFile } from "@/api/doc/index";
import { note } from "../components/mockData";
// import { note } from "../components/mockData";
export default {
components: {
PDFAnnot,
......@@ -49,15 +49,13 @@ export default {
// 向子/孙组件注入依赖,不论组件层次有多深,并在其上下游关系成立的时间里始终生效。
provide() {
return {
currrentFileOnly: () => {
return true; //使用方法返回保证响应式
},
readOnly: () => {
return true; //使用方法返回保证响应式
},
currrentFileOnly: true,
readOnly: true,
fileId: () => {
return this.form.docId; //使用方法返回保证响应式
},
pdfSwitchPage: this.pdfSwitchPage,
updateNoteList: this.updateNoteList,
};
},
data() {
......@@ -78,7 +76,7 @@ export default {
},
},
panelVisible: false, //笔记的窗口
noteList: note,
noteList: [],
pdfAnnotInstance: null,
};
},
......@@ -101,19 +99,30 @@ export default {
},
// 获取当前文件的所有笔记
// async getCurrentFileNotes() {
// const params = {
// currentPage: 1,
// pageCount: 100,
// fileId: this.form.docId,
// };
// let res = await getNoteByFile(params);
// if (res.data) {
// this.noteList = res.data.records;
// this.renderNote();
// }
// // this.noteList=this.$refs.RightPanel.$refs.NoteList.noteList
// // const params = {
// // currentPage: 1,
// // pageCount: 100,
// // fileId: this.form.docId,
// // };
// // let res = await getNoteByFile(params);
// // if (res.data) {
// // this.noteList = res.data.records;
// // this.renderNote();
// // }
// },
updateNoteList(noteList) {
this.noteList = noteList;
if (!this.pdfAnnotInstance) {
return
}
this.renderNote()
},
// 渲染笔记
renderNote() {
if (!this.noteList) {
return;
}
const annotsMap = this.noteList.map((item) => {
if (typeof item.jsonStr == "string") {
return JSON.parse(item.jsonStr);
......@@ -122,7 +131,10 @@ export default {
}
});
this.pdfAnnotInstance.renderAnnots(annotsMap);
// this.pdfAnnotInstance.switchPage(3);
},
// pdf跳转页面
pdfSwitchPage(page) {
this.pdfAnnotInstance.switchPage(page);
},
// 复制文本
copyText(value) {
......@@ -135,14 +147,11 @@ export default {
const { info } = value[0];
this.form.bookmarkContent = info;
this.form.jsonStr = deepCopy(value[0]);
console.log("this.form", this.form);
},
ready(value) {
this.pdfAnnotInstance = value;
this.renderNote();
// this.getCurrentFileNotes();
console.log("ready", value);
},
},
};
......
......@@ -41,6 +41,18 @@ export default {
RightPanel,
AddOrUpdateNoteDialog,
},
// 向子/孙组件注入依赖,不论组件层次有多深,并在其上下游关系成立的时间里始终生效。
provide() {
return {
currrentFileOnly: false,
readOnly: false,
fileId: () => {
return this.form.docId; //使用方法返回保证响应式
},
pdfSwitchPage: null, //不传值孙组件接收不到该方法会报错
updateNoteList: null, //不传值孙组件接收不到该方法会报错
};
},
data() {
return {
wpsInstance: {}, //wps实例
......@@ -85,24 +97,26 @@ export default {
});
this.wpsInstance.setToken({ token });
await this.wpsInstance.ready();
// 新增阅读记录
this.addViewRecord();
// 添加文档选区监听
this.addDocSelectionListen();
// this.addDocSelectionListen();
},
// 添加文档选区监听
async addDocSelectionListen() {
// debugger;
console.log("addDocSelectionListen");
// 等待加载完毕
const app = this.wpsInstance.Application;
this.wpsInstance.ApiEvent.AddApiEventListener(
"WindowSelectionChange",
(data) => {
console.log("WindowSelectionChange: ", data);
// this.handleDocSelectionChange(data);
}
);
},
// // 添加文档选区监听
// async addDocSelectionListen() {
// // debugger;
// console.log("addDocSelectionListen");
// // 等待加载完毕
// const app = this.wpsInstance.Application;
// this.wpsInstance.ApiEvent.AddApiEventListener(
// "WindowSelectionChange",
// (data) => {
// console.log("WindowSelectionChange: ", data);
// // this.handleDocSelectionChange(data);
// }
// );
// },
// 新增阅读记录
async addViewRecord() {
......@@ -112,29 +126,8 @@ export default {
};
await addNearRead(params);
},
//
// // 增加浏览记录
// this.addViewRecord();
// const { readOnly } = this.routeParams;
// // 只有只读的才能新建笔记和监听
// if (readOnly) {
// // this.initAddNoteButton();
// this.addDocSelectionListen();
// }
// // 高亮文本
// async highlightSelection() {
// const app = this.wpsInstance.Application;
// const font = await app.ActiveDocument.Range(118, 207).Font;
// // 设置选定文字的高亮颜色
// font.HighLight = "#228B22";
// },
// 监听DOC文字选取变化
async handleDocSelectionChange(data) {
console.log("handleDocSelectionChange", data);
const { begin, end } = data;
// console.log(data);
if (begin != undefined && (end != undefined) & (begin != end)) {
......@@ -173,36 +166,18 @@ export default {
console.log(currentPage);
},
// 初始化并监听新建笔记按钮
async initAddNoteButton() {
const app = this.wpsInstance.Application;
// 通过 CommandBar 的 Controls 对象,可获取到对应类型的内容集合,从而做新增操作或者获取到具体内容进行操作
// 定制元素对象:【开始 Tab】
const controls = await app.CommandBars("StartTab").Controls;
// 新增按钮型定制元素
this.controlButton = await controls.Add(1);
this.controlButton.Caption = "新建笔记";
this.controlButton.Enabled = false;
this.controlButton.OnAction = this.handleAddNote;
},
// //添加PDF选取监听
// addPdfSelectionListen() {
// this.wpsInstance.ApiEvent.AddApiEventListener(
// "TextSelectChange",
// async (data) => {
// console.log("TextSelectChange");
// // 复制选中的批注文案
// const app = this.wpsInstance.Application;
// console.log("app", app);
// // 初始化并监听新建笔记按钮
// async initAddNoteButton() {
// const app = this.wpsInstance.Application;
// // 通过 CommandBar 的 Controls 对象,可获取到对应类型的内容集合,从而做新增操作或者获取到具体内容进行操作
// // 定制元素对象:【开始 Tab】
// const controls = await app.CommandBars("StartTab").Controls;
// // 新增按钮型定制元素
// this.controlButton = await controls.Add(1);
// this.controlButton.Caption = "新建笔记";
// await app.ActivePDF.AnnoAPI.SetSelectionAnno({
// type: app.Enum.AnnoType.Highlight,
// color: "rgba(0,0,0,1)",
// });
// }
// );
// this.controlButton.Enabled = false;
// this.controlButton.OnAction = this.handleAddNote;
// },
//新建笔记
......
......@@ -42,8 +42,8 @@ export default {
const { keyword } = this;
const params = {
keyword,
pageNo: 1,
pageCount: 10,
// pageNo: 1,
// pageCount: 10,
};
this.$emit("search", params);
},
......
......@@ -116,7 +116,8 @@
</template>
<script>
import { list } from "../../mockData";
// import { list } from "../../mockData";
import { addFavorite, cancelCollect } from "@/api/user/collect";
export default {
props: {
list: {
......@@ -151,7 +152,7 @@ export default {
queryParams: {
pageNo: 1,
pageCount: 10,
totalElements:0,
totalElements: 0,
keyword: "", //文件名称
},
// 批量取消的弹窗可见性
......@@ -173,7 +174,7 @@ export default {
},
methods: {
getList() {
this.$emit("getList",this.queryParams);
this.$emit("getList", this.queryParams);
},
// 多选框选中数据
handleSelectionChange(selection) {
......@@ -185,11 +186,27 @@ export default {
handleOpenFile(file) {
this.$file.handleFileNameClickNew(file);
},
// 批量收藏
handleMultiCollect() {},
// 点击收藏
handleCollect(file) {},
async handleCollect(file) {
let request;
let params;
if (file.collected) {
request = cancelCollect;
params = {
fileIds: file.fileId,
};
} else {
request = addFavorite;
params = file;
}
// console.log(file);
let res = await request(params);
if (res.code == 200) {
let message = file.collected ? "取消收藏成功!" : "收藏成功!";
this.$message.success(message);
}
},
},
};
</script>
......
<template>
<div class="app-container container">
<SearchBar ref="SearchBar" @search="loadData" />
<Table :list="list" @getList="loadData" v-loading="loading" />
<Table ref="Table" :list="list" @getList="loadData" v-loading="loading" />
</div>
</template>
<script>
......@@ -31,20 +31,19 @@ export default {
},
methods: {
async loadData(queryParams) {
// console.log("queryParams", queryParams);
// return;
async loadData() {
this.loading = true;
const { pageNo, pageCount, keyword } = queryParams;
const activeTab = this.$refs.SearchBar.activeTab;
// const { current, size } = this.list;
const { activeTab, keyword } = this.$refs.SearchBar;
const { pageNo, pageCount } = this.$refs.Table.queryParams;
const params = {
keyword,
pageNo,
pageCount,
};
if (keyword) {
params.pageNo = 1;
}
console.log(params);
// return;
let request;
switch (activeTab) {
case "报纸":
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论