km-knowledage-view.vue 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293
  1. <template>
  2. <a-layout :class="$style.layout">
  3. <sd-header>
  4. <template>
  5. <span :class="[$style.handleBtn, $style.printNone]">
  6. <span @click="close"><a-icon type="close-circle"></a-icon> 退出 </span>
  7. </span>
  8. </template>
  9. </sd-header>
  10. <a-layout-content :class="$style.layoutContent">
  11. <a-card :class="$style.bgcolor">
  12. <div :class="$style.newsMain">
  13. <div :class="$style.knowLedage">
  14. <div :class="$style.klArticle">
  15. <a-row type="flex">
  16. <a-col flex="1 1 200px">
  17. <div :class="$style.leftContent">
  18. <a-skeleton v-if="!isAlertShow" active />
  19. <div v-else :class="$style.articeText">
  20. <h3>{{ news.title }}</h3>
  21. <div :class="$style.infos">
  22. <span>作者:{{ news.creatorName }}</span>
  23. <span>创建时间:{{ news.creationTime | sdDateFormat('YYYY-MM-DD') }}</span>
  24. <span>所属单位:{{ news.belongUnit }}</span>
  25. </div>
  26. <div :class="$style.infos">
  27. <span
  28. >标签:
  29. <a-tag v-for="(item, index) in labelArr" :key="index" color="blue">
  30. {{ item }}
  31. </a-tag>
  32. </span>
  33. <span
  34. >点评:<i>({{ (news.commentNumber = allCommentNum) }})</i></span
  35. >
  36. <span
  37. >阅读次数:<i>({{ news.readNumber }})</i></span
  38. >
  39. </div>
  40. <div v-if="news.type === 1" :class="$style.content">
  41. <!-- eslint-disable-next-line vue/no-v-html -->
  42. <div v-html="news.content"></div>
  43. </div>
  44. <div v-else-if="news.onlinePreview === '0'" :class="$style.content">
  45. <p v-html="news.abstractMessage"></p>
  46. </div>
  47. <div v-else :class="$style.files">
  48. <sd-wps-reader
  49. v-if="attachments.length > 0"
  50. :key="clickChange ? changeCode : attachments[0].code"
  51. :class="$style.wpsread"
  52. :code="clickChange ? changeCode : attachments[0].code"
  53. />
  54. </div>
  55. <div v-if="news.onlinePreview === '0'">
  56. <div
  57. v-for="(item, index) in attachments"
  58. :key="index"
  59. :class="$style.files"
  60. >
  61. <div :class="$style.filesName">附件:{{ item.name }}</div>
  62. <div :class="$style.filesBtn">
  63. <a
  64. :download="item.name"
  65. :href="
  66. `api/flow-mobile/v1/task-form-process/download-attachments/${item.code}`
  67. | sdResource
  68. "
  69. @click="attachmentRecord(item.name, item.code)"
  70. >下载</a
  71. >
  72. </div>
  73. </div>
  74. </div>
  75. <a-divider />
  76. <div :class="$style.klOperation">
  77. <span
  78. :class="isClick === 'dz' ? $style.isActive : ''"
  79. @click="handleLike('dz')"
  80. >
  81. <a-badge :class="$style.drage" :count="badgeCount">
  82. <a-icon type="like" :theme="flag ? 'filled' : 'outlined'" /> </a-badge
  83. >点赞
  84. </span>
  85. </div>
  86. </div>
  87. <div id="divId" :class="$style.comment">
  88. <a-skeleton v-if="!isAlertShow" active />
  89. <a-tabs v-else default-active-key="1" @change="callback">
  90. <a-tab-pane key="1" tab="点评">
  91. <div :class="$style.plContent">
  92. <a-comment>
  93. <a-avatar
  94. slot="avatar"
  95. icon="user"
  96. :src="
  97. `api/mobile/v1/user-manager/userAvatar/${currentUser}`
  98. | sdResource
  99. "
  100. />
  101. <div slot="content">
  102. <a-form>
  103. <a-form-item :class="$style.commentText">
  104. <a-textarea
  105. ref="textarea"
  106. v-model="commentValue"
  107. placeholder="发表您的评价或意见建议!"
  108. :max-length="1000"
  109. :rows="4"
  110. @input="handleChange"
  111. />
  112. </a-form-item>
  113. <a-form-item :class="$style.commentScore">
  114. <div :class="$style.publish">
  115. <span :class="$style.textNum"
  116. >还可以输入<em>{{ still }}</em
  117. >字</span
  118. >
  119. <a-button
  120. html-type="submit"
  121. :loading="submitting"
  122. type="primary"
  123. @click="handleSubmit"
  124. >
  125. 发表
  126. </a-button>
  127. </div>
  128. </a-form-item>
  129. </a-form>
  130. </div>
  131. </a-comment>
  132. <div v-if="comments.length === 0" :class="$style.noComment"
  133. >暂无评论</div
  134. >
  135. <a-list
  136. v-if="comments.length"
  137. :class="$style.commentList"
  138. :data-source="comments"
  139. item-layout="horizontal"
  140. >
  141. <div v-if="showLoadingMore" slot="loadMore" :class="$style.moredata">
  142. <a-spin v-if="loadingMore" />
  143. <div @click="clickMore">
  144. 查看更多
  145. <a-icon type="right" />
  146. </div>
  147. </div>
  148. <div v-else :class="$style.moredata">到底了,没有更多数据了</div>
  149. <a-list-item slot="renderItem" slot-scope="item">
  150. <a-comment>
  151. <a slot="author">{{ item.creatorName }}</a>
  152. <a-avatar
  153. slot="avatar"
  154. icon="user"
  155. :src="
  156. `api/mobile/v1/user-manager/userAvatar/${item.creatorAccount}`
  157. | sdResource
  158. "
  159. />
  160. <p slot="content">
  161. {{ item.commentContent }}
  162. </p>
  163. <span slot="datetime">{{
  164. moment(item.creationTime).format('YYYY-MM-DD HH:mm:ss')
  165. }}</span>
  166. </a-comment>
  167. </a-list-item>
  168. </a-list>
  169. </div>
  170. </a-tab-pane>
  171. <a-tab-pane key="3" tab="访问">
  172. <div v-if="spin" :class="$style.example">
  173. <a-spin />
  174. </div>
  175. <div v-else>
  176. <a-empty v-if="visitRecordData.length === 0" />
  177. <a-table
  178. v-else
  179. bordered
  180. :columns="columnsVisit"
  181. :data-source="visitRecordData"
  182. :pagination="pagination1"
  183. >
  184. <template slot="firstSeen" slot-scope="firstSeen">
  185. {{ moment(firstSeen).format('YYYY-MM-DD HH:mm:ss') }}
  186. </template>
  187. <template slot="lastSeen" slot-scope="lastSeen">
  188. {{ moment(lastSeen).format('YYYY-MM-DD HH:mm:ss') }}
  189. </template>
  190. </a-table>
  191. </div>
  192. </a-tab-pane>
  193. </a-tabs>
  194. </div>
  195. </div>
  196. </a-col>
  197. <!-- <a-col flex="0 1 350px">
  198. <div :class="$style.rightContent">
  199. <a-skeleton v-if="!isAlertShow" active />
  200. <div v-else :class="$style.articleInfo">
  201. <p :class="$style.title">文档信息</p>
  202. <a-divider />
  203. <div :class="$style.userInfo">
  204. <div :class="$style.user">
  205. <p>上传者</p>
  206. <a-row :class="$style.userImg" type="flex">
  207. <a-col flex="80px">
  208. <a-avatar
  209. :class="$style.userinfo"
  210. icon="user"
  211. :size="65"
  212. :src="
  213. `api/mobile/v1/user-manager/userAvatar/${news.creatorAccount}`
  214. | sdResource
  215. "
  216. alt="avatar"
  217. />
  218. </a-col>
  219. <a-col flex="auto">
  220. <p :class="$style.username">{{ news.creatorName }}</p>
  221. <p>{{ news.createDeptName }}</p>
  222. </a-col>
  223. </a-row>
  224. <a-divider />
  225. </div>
  226. <div :class="$style.userNum">
  227. <span><a-icon type="sd-message" />{{ news.commentNumber }}</span>
  228. <span><a-icon type="share-alt" />{{ news.recommendNumber }}</span>
  229. <span><a-icon type="sd-eye" />{{ news.readNumber }}</span>
  230. </div>
  231. </div>
  232. <div :class="$style.infos">
  233. <p v-if="news.type === 0" :class="$style.edition"
  234. ><i>版本</i>:<span>{{ news.versionNum }}</span></p
  235. >
  236. <p :class="$style.type"
  237. ><i>分类</i>:<span>{{
  238. categoryrArr.map((item) => item.categoryName).join(' 、')
  239. }}</span></p
  240. >
  241. <p :class="$style.labels"
  242. ><i>标签</i>:<span>{{
  243. labelArr.map((item) => item.name).join(' 、')
  244. }}</span></p
  245. >
  246. <p v-if="news.type === 0" :class="$style.field"
  247. >业务领域:<span>{{
  248. businessAreaArr.map((item) => item.name).join(' 、')
  249. }}</span></p
  250. >
  251. <p
  252. v-if="news.onlinePreview === '1' && news.type === 0"
  253. :class="$style.abstract"
  254. ><i>摘要</i>:<span>{{ news.abstractMessage }}</span></p
  255. >
  256. </div>
  257. </div>
  258. <a-skeleton v-if="!isAlertShow" active />
  259. <div
  260. v-else-if="news.onlinePreview === '1' && news.type === 0"
  261. :class="$style.articleInfo"
  262. >
  263. <p :class="$style.title">链接文档</p>
  264. <a-divider />
  265. <div v-if="attachments.length > 0" :class="$style.wordlist">
  266. <p
  267. v-for="(item, index) in attachments"
  268. :key="index"
  269. :class="[
  270. $style.downloda,
  271. currentIndex === index ? $style.actived : '',
  272. index === 0 && !clickChange ? $style.defalutColor : '',
  273. ]"
  274. @click="chooseAttach(item, index)"
  275. >{{ item.name }}
  276. <a
  277. v-if="news.authDownload === '1'"
  278. :download="item.name"
  279. :href="
  280. `api/flow-mobile/v1/task-form-process/download-attachments/${item.code}`
  281. | sdResource
  282. "
  283. @click="attachmentRecord(item.name, item.code)"
  284. ><a-icon type="vertical-align-bottom"/></a
  285. ></p>
  286. </div>
  287. <a-empty v-else />
  288. </div>
  289. </div>
  290. </a-col> -->
  291. </a-row>
  292. </div>
  293. </div>
  294. </div>
  295. </a-card>
  296. </a-layout-content>
  297. </a-layout>
  298. </template>
  299. <script>
  300. import moment from 'moment'
  301. import { Modal, Message } from 'ant-design-vue'
  302. import errorUtil from '@/common/services/error-util'
  303. import axios from '@/common/services/axios-instance'
  304. import { getUserInfo } from '@/common/store-mixin'
  305. import crossWindowWatcher from '@/common/services/cross-window-watcher'
  306. import FlowService from '@/webflow/flow-service'
  307. import KmKnowledageService from '../km-knowledage-service'
  308. import KmCollectModal from '../components/km-knowledage-collectmodal'
  309. import KmCommentModal from '../components/km-knowledage-commentmodal'
  310. import KmEditFormModal from '../components/km-knowledage-editmodal'
  311. import components from './_import-components/km-knowledage-view-import'
  312. const columnsVisit = [
  313. {
  314. title: '首次访问时间',
  315. dataIndex: 'firstSeen',
  316. scopedSlots: { customRender: 'firstSeen' },
  317. },
  318. {
  319. title: '最近访问时间',
  320. dataIndex: 'lastSeen',
  321. scopedSlots: { customRender: 'lastSeen' },
  322. },
  323. {
  324. title: '访问人',
  325. dataIndex: 'creatorName',
  326. },
  327. {
  328. title: '访问次数',
  329. dataIndex: 'visitCount',
  330. },
  331. ]
  332. export default {
  333. name: 'KmKnowledageView',
  334. metaInfo: {
  335. title: '知识查看',
  336. },
  337. components: {
  338. ...components,
  339. },
  340. data() {
  341. return {
  342. columnsVisit,
  343. pagination1: {
  344. onChange: (page) => {},
  345. pageSize: 10,
  346. },
  347. pagination2: {
  348. onChange: (page) => {},
  349. pageSize: 10,
  350. },
  351. show: false, // 控制显示收藏弹框
  352. isEdit: false, // 控制显示勘误弹框
  353. fwId: Number(this.$route.query.id),
  354. creatorName: '', // 作者
  355. creationTime: null, // 创建时间
  356. recommendNum: null, // 推荐次数
  357. versionNum: null, // 版本号
  358. categoryName: '', // 分类
  359. label: '', // 标签
  360. businessArea: '', // 业务领域
  361. abstractMessage: '', // 摘要
  362. badgeCount: 0,
  363. favoritiesShow: false,
  364. isRecommend: false,
  365. labelCol: { span: 4 },
  366. wrapperCol: { span: 14 },
  367. // 推荐
  368. recommendForm: {
  369. resource: '',
  370. desc: '',
  371. },
  372. rules: {
  373. resource: [
  374. { required: true, message: 'Please select activity resource', trigger: 'change' },
  375. ],
  376. desc: [{ required: true, message: 'Please input activity form', trigger: 'blur' }],
  377. },
  378. isClick: '',
  379. loading: false,
  380. columns: [
  381. {
  382. title: '姓名',
  383. dataIndex: 'name',
  384. },
  385. {
  386. sorter: true,
  387. dataIndex: 'account',
  388. title: 'ID',
  389. },
  390. {
  391. title: '状态',
  392. dataIndex: 'status',
  393. },
  394. ],
  395. attachments: [],
  396. coverAttachments: [],
  397. comments: [],
  398. submitting: false,
  399. commentValue: '',
  400. moment,
  401. still: 1000,
  402. confirmLoading: false,
  403. // 版本
  404. editionModal: false,
  405. editionForm: {
  406. edition: '',
  407. },
  408. editionrules: {
  409. edition: [{ required: true, message: '版本号不能为空!', trigger: 'change' }],
  410. },
  411. // 获取所有点评入参
  412. commentParams: {
  413. columns:
  414. 'commentContent,businessId,creatorName,creationTime,creatorId,praiseNumber,creatorAccount',
  415. expressions: [
  416. {
  417. dataType: 'str',
  418. name: 'commentContent',
  419. op: 'like',
  420. stringValue: '%%',
  421. },
  422. {
  423. dataType: 'str',
  424. name: 'businessId',
  425. op: 'eq',
  426. stringValue: this.$route.query.id,
  427. },
  428. ],
  429. formId: 'kmComment',
  430. maxResults: 3,
  431. orderBy: 'creationTime asc',
  432. startPosition: 0,
  433. },
  434. // 发表点评 入参
  435. publishData: {
  436. eventId: 'save',
  437. inputs: [
  438. {
  439. name: 'commentContent',
  440. value: '',
  441. },
  442. {
  443. name: 'businessId',
  444. value: this.$route.query.id,
  445. },
  446. ],
  447. pageFlowId: 'string',
  448. pagePath: '/audit/km/comp/comment/kmComment',
  449. },
  450. showLoadingMore: true,
  451. pagination: {
  452. onChange: (page, pageSize) => this.changePage(page, pageSize),
  453. hideOnSinglePage: true,
  454. current: 1,
  455. pageSize: 3,
  456. total: 0,
  457. showTotal: (total) => {
  458. return `总共${total}条`
  459. },
  460. },
  461. loadingMore: false,
  462. lastPage: '',
  463. moreData: false,
  464. allCommentNum: null,
  465. news: {},
  466. isAlertShow: false,
  467. currentUser: '',
  468. // 推荐记录入参
  469. recommendrecord: {
  470. maxResults: -1,
  471. startPosition: 0,
  472. orderBy: 'id asc',
  473. expressions: [
  474. {
  475. dataType: 'str',
  476. name: 'knowledgeId',
  477. op: 'eq',
  478. stringValue: this.$route.query.id,
  479. },
  480. ],
  481. },
  482. // 访问记录入参
  483. visitedrecord: {
  484. maxResults: -1,
  485. startPosition: 0,
  486. orderBy: 'id asc',
  487. expressions: [
  488. {
  489. dataType: 'str',
  490. name: 'beanId',
  491. op: 'eq',
  492. stringValue: this.$route.query.id,
  493. },
  494. ],
  495. },
  496. recommendRecordData: [],
  497. visitRecordData: [],
  498. flag: null,
  499. clickChange: false,
  500. currentIndex: '',
  501. changeCode: '',
  502. changeName: '',
  503. active: false,
  504. choosedViewCategory: [],
  505. clickNum: 0,
  506. categoryrArr: [],
  507. businessAreaArr: [],
  508. labelArr: [],
  509. spin: true,
  510. }
  511. },
  512. created() {
  513. this.currentUser = getUserInfo().account
  514. // 获取所有评论
  515. this.queryComment(this.commentParams)
  516. // 获取知识点赞数
  517. this.queryKnowledgeComment()
  518. const obj = {}
  519. obj.categoryId = this.$route.query.typeId
  520. obj.categoryName = this.$route.query.typeName
  521. this.choosedViewCategory.push(obj)
  522. this.callback('2')
  523. },
  524. mounted() {
  525. // 判断是否有权限借阅
  526. this.queryKnowledgeCheck()
  527. },
  528. methods: {
  529. refreshData() {
  530. // 获取推荐,访问记录
  531. this.queryRecommendOrVisitRecord(this.recommendrecord, '2')
  532. // 获取详情
  533. this.queryKnowledgeDetails()
  534. },
  535. // 下载记录
  536. attachmentRecord(attachmentName, attachmentCode) {
  537. const params = {
  538. knowledgeId: this.$route.query.id,
  539. knowledgeName: this.$route.query.title,
  540. categoryId: JSON.parse(this.news.category)[0].categoryId,
  541. categoryName: JSON.parse(this.news.category)[0].categoryName,
  542. attachmentGroupId: this.news.applyAttachment,
  543. attachmentName: attachmentName,
  544. attachmentCode: attachmentCode,
  545. }
  546. KmKnowledageService.getAttachmentRecord(params).then((res) => {})
  547. },
  548. showModal() {
  549. this.isRecommend = false
  550. },
  551. chooseAttach(item, index) {
  552. this.clickChange = true
  553. this.changeCode = item.code
  554. this.changeName = item.name
  555. this.currentIndex = index
  556. },
  557. queryRecommendOrVisitRecord(record, key) {
  558. if (key === '3') {
  559. // 访问记录
  560. record.columns = 'creationTime,creatorName,createDeptName,firstSeen,lastSeen,visitCount'
  561. record.formId = 'kmPreview'
  562. KmKnowledageService.getKnowledgeComment(record).then((res) => {
  563. this.spin = false
  564. if (res.data.data.length > 0) {
  565. this.visitRecordData = res.data.data
  566. record.columns = ''
  567. record.formId = ''
  568. } else {
  569. this.visitRecordData = []
  570. }
  571. })
  572. }
  573. },
  574. // 是否有借阅权限
  575. queryKnowledgeCheck() {
  576. const params = {
  577. id: this.$route.query.id,
  578. }
  579. KmKnowledageService.getKnowledgeCheck(params)
  580. .then((res) => {
  581. if (res.data.success) {
  582. // 获取详情
  583. this.queryKnowledgeDetails()
  584. }
  585. })
  586. .catch((err) => {
  587. const msg = errorUtil.getMessage(err)
  588. if (
  589. msg === '该知识未发布无法预览,待发布后进行详情查看!' ||
  590. msg === '查无数据,请核实入参!'
  591. ) {
  592. Message.error(msg)
  593. setTimeout(() => {
  594. window.close()
  595. }, 1000)
  596. } else {
  597. // 借阅提醒
  598. this.showRemind()
  599. }
  600. })
  601. },
  602. // 获取知识详情
  603. queryKnowledgeDetails() {
  604. KmKnowledageService.getKnowledgeDetails({ id: this.$route.query.id })
  605. .then((res) => {
  606. if (res.status === 200) {
  607. this.isAlertShow = true
  608. this.news = res.data
  609. this.flag = this.news.praiseed
  610. this.labelArr = this.news.label?.split('、')
  611. // 获取文档附件
  612. this.getAttachmentCode(res.data.applyAttachment)
  613. }
  614. })
  615. .catch((err) => {
  616. debugger
  617. Modal.error({
  618. title: '数据异常!',
  619. content: err.response?.data?.message?.split(':')[1] || '获取详情失败!',
  620. onOk() {
  621. window.close()
  622. },
  623. })
  624. })
  625. },
  626. // 获取附件code
  627. getAttachmentCode(groupId) {
  628. axios
  629. .get(`api/xcoa-mobile/v1/attachment-extend/attachments-info-perm/${groupId}`)
  630. .then((res) => {
  631. if (res.data.length > 0) {
  632. this.attachments = res.data
  633. } else {
  634. this.attachments = []
  635. }
  636. })
  637. },
  638. // 获取所有评论
  639. queryComment(params) {
  640. KmKnowledageService.getKnowledgeComment(params).then((res) => {
  641. if (res.data.totalSize < 4) {
  642. this.showLoadingMore = false
  643. }
  644. this.pagination.total = res.data.totalSize
  645. this.lastPage = Math.ceil(res.data.totalSize / this.pagination.pageSize)
  646. if (
  647. this.comments.length !== 0 &&
  648. this.moreData === true &&
  649. this.showLoadingMore !== false
  650. ) {
  651. this.comments = this.comments.concat(res.data.data)
  652. this.loadingMore = false
  653. this.$nextTick(() => {
  654. window.dispatchEvent(new Event('resize'))
  655. })
  656. } else {
  657. this.comments = res.data.data
  658. this.allCommentNum = res.data.totalSize
  659. }
  660. if (parseInt(this.pagination.total / 3) === this.clickNum) {
  661. this.showLoadingMore = false
  662. }
  663. })
  664. },
  665. // 获取更多评论
  666. clickMore() {
  667. this.clickNum++
  668. if (this.comments.length === this.allCommentNum) {
  669. this.showLoadingMore = false
  670. }
  671. if (this.allCommentNum < 4) {
  672. this.showLoadingMore = false
  673. }
  674. this.loadingMore = true
  675. this.moreData = true
  676. this.pagination.current += 1
  677. this.commentParams.startPosition =
  678. this.commentParams.maxResults * (this.pagination.current - 1)
  679. this.$nextTick(function() {
  680. this.queryComment(this.commentParams)
  681. })
  682. },
  683. // 获取知识点赞数
  684. queryKnowledgeComment() {
  685. const params = {
  686. id: this.$route.query.id,
  687. }
  688. KmKnowledageService.getKnowledgePraiseNum(params).then((res) => {
  689. this.badgeCount = res.data
  690. })
  691. },
  692. // 借阅提醒弹框
  693. showRemind() {
  694. const _this = this
  695. Modal.confirm({
  696. title: '借阅提醒',
  697. content: (h) => <div>您没有该文档的阅读权限,是否申请借阅?</div>,
  698. onOk() {
  699. _this.$router.replace(
  700. `/km-flow-guide?code=PROJECT_ZSGL_ZSJY&knowledgeId=${_this.$route.query.id}&title=${_this.$route.query.title}`
  701. )
  702. },
  703. onCancel() {
  704. window.close()
  705. },
  706. class: 'test',
  707. })
  708. },
  709. // 知识点赞
  710. handleLike(v) {
  711. const params = {
  712. id: this.$route.query.id,
  713. }
  714. KmKnowledageService.getKnowledgePraise(params).then((res) => {
  715. if (res.status === 200) {
  716. if (this.news.praiseed) {
  717. this.badgeCount = this.badgeCount - 1
  718. Message.success({ content: '取消点赞' })
  719. this.flag = false
  720. this.news.praiseed = false
  721. } else {
  722. this.badgeCount = this.badgeCount + 1
  723. Message.success({ content: '点赞成功' })
  724. this.flag = true
  725. this.news.praiseed = true
  726. }
  727. this.queryKnowledgeComment()
  728. // // 获取详情
  729. // this.queryKnowledgeDetails()
  730. }
  731. })
  732. },
  733. // 收藏
  734. handleCollect(v) {
  735. this.favoritiesShow = true
  736. },
  737. // 选择收藏夹save
  738. handleOkInFavorities(e) {
  739. this.onFavorities()
  740. },
  741. // 新建收藏夹
  742. createFavorites(e) {
  743. this.show = !this.show
  744. },
  745. getselectKey(key) {
  746. this.modelSelectedKey = key
  747. },
  748. // 收藏按钮点击处理, 目前通用接口没返回,手写的
  749. onFavorities() {
  750. const key = Symbol.for()
  751. Message.loading({ content: '处理中...', key })
  752. const url = window.location.hash
  753. const params = {
  754. eventId: 'save',
  755. inputs: [
  756. {
  757. name: 'title',
  758. value: this.news.title,
  759. },
  760. {
  761. name: 'topping',
  762. value: 1, // 0置顶, 1不置顶,默认不置顶
  763. },
  764. {
  765. name: 'url',
  766. value: url.split('#')[1],
  767. },
  768. {
  769. name: 'formId',
  770. value: this.news.formId,
  771. },
  772. {
  773. name: 'beanType',
  774. value: String(this.news.beanId),
  775. },
  776. {
  777. name: 'folderId',
  778. value: this.modelSelectedKey,
  779. },
  780. {
  781. name: 'businessTypeName',
  782. value: this.news.businessTypeName,
  783. },
  784. {
  785. name: 'businessTypeId',
  786. value: this.news.businessTypeId,
  787. },
  788. ],
  789. pageFlowId: 'string',
  790. pagePath: 'comp/bookmark/kmBookmarkContent',
  791. }
  792. FlowService.saveFavorities(params).then(
  793. () => {
  794. Message.success({ content: '收藏成功', key })
  795. this.news.collectioned = true
  796. },
  797. (_) => {
  798. Message.error({ content: '收藏失败', key })
  799. }
  800. )
  801. this.favoritiesShow = false
  802. },
  803. // 取消收藏
  804. onCancelFavorities() {
  805. const key = Symbol.for()
  806. Message.loading({ content: '处理中...', key })
  807. const params = {
  808. formId: this.news.formId,
  809. beanType: this.news.beanId,
  810. }
  811. FlowService.cancelFavorities(params).then(
  812. () => {
  813. Message.success({ content: '取消收藏成功', key })
  814. this.news.collectioned = false
  815. },
  816. (_) => {
  817. Message.error({ content: '取消收藏失败', key })
  818. }
  819. )
  820. },
  821. // 推荐
  822. handleRecommend(v) {
  823. this.isClick = v
  824. this.isRecommend = true
  825. },
  826. recomentChange(values) {},
  827. // 点评
  828. goAnchor(v) {
  829. this.isClick = v
  830. this.$refs.textarea.focus()
  831. document.getElementById('divId').scrollIntoView()
  832. },
  833. // 生成链接
  834. goLink(v) {
  835. this.isClick = v
  836. this.copyToClip(window.location.href)
  837. },
  838. copyToClip(content, message) {
  839. var aux = document.createElement('input')
  840. aux.setAttribute('value', content)
  841. document.body.appendChild(aux)
  842. aux.select()
  843. document.execCommand('copy')
  844. document.body.removeChild(aux)
  845. if (message == null) {
  846. Message.success('链接已生成!')
  847. } else {
  848. Message.warning('链接生成出错!')
  849. }
  850. },
  851. // 勘误
  852. goEdit(v) {
  853. this.isEdit = !this.isEdit
  854. },
  855. // 新版本
  856. goEdition(v) {
  857. this.isClick = v
  858. this.editionModal = true
  859. },
  860. handleEditionModalOk() {
  861. this.$refs.editionRuleForm.validate((valid) => {
  862. if (valid) {
  863. const advancedFields = this.news.applyPerson.map((item) => item.name).join(',')
  864. const attFields = []
  865. attFields.push(this.news.applyAttachment)
  866. attFields.push(this.news.coverAttachment)
  867. const inputs = [
  868. {
  869. name: 'flowId',
  870. value: this.news.flowId,
  871. },
  872. {
  873. name: 'formId',
  874. value: this.news.formId,
  875. },
  876. {
  877. name: 'beanId',
  878. value: String(this.news.beanId),
  879. },
  880. {
  881. name: 'advancedFields',
  882. value: advancedFields,
  883. },
  884. {
  885. name: 'attFields',
  886. value: 'applyAttachment,coverAttachment',
  887. },
  888. {
  889. name: 'pagePath',
  890. value: '/knowledge/contribution/kmKnowledge',
  891. },
  892. ]
  893. // 复制附件
  894. KmKnowledageService.copyAttachment({ inputs: inputs }).then((res) => {
  895. window.open(
  896. `#/sd-webflow/pages/draft/${res.data.instId}?versionNum=${this.editionForm.edition}&relationId=${this.news.relationId}`,
  897. '_blank'
  898. )
  899. this.editionForm.edition = ''
  900. })
  901. this.editionModal = false
  902. } else {
  903. return false
  904. }
  905. })
  906. },
  907. handleEditionModalCancel() {
  908. this.editionModal = false
  909. },
  910. change(values) {},
  911. // tab切换
  912. callback(key) {
  913. if (key === '2') {
  914. // 获取推荐,访问记录
  915. this.queryRecommendOrVisitRecord(this.recommendrecord, key)
  916. } else if (key === '3') {
  917. // 获取推荐,访问记录
  918. this.queryRecommendOrVisitRecord(this.visitedrecord, key)
  919. }
  920. },
  921. // 发表评论
  922. handleSubmit() {
  923. if (!this.commentValue) {
  924. return
  925. }
  926. this.submitting = true
  927. this.publishData.inputs[0].value = this.commentValue
  928. KmKnowledageService.getComment(this.publishData).then((res) => {
  929. if (res.status === 200) {
  930. this.submitting = false
  931. this.still = 1000
  932. Message.success({ content: '评论成功!', duration: 1 })
  933. if (!this.showLoadingMore) {
  934. // 初始化为0
  935. this.commentParams.startPosition = this.startNum
  936. // 结束位置+1
  937. this.commentParams.maxResults = this.pagination.total + 1
  938. this.$nextTick(function() {
  939. this.queryComment(this.commentParams)
  940. })
  941. } else {
  942. this.$nextTick(function() {
  943. this.queryComment(this.commentParams)
  944. })
  945. }
  946. this.commentValue = ''
  947. }
  948. })
  949. },
  950. handleChange() {
  951. const txtVal = this.commentValue.length
  952. this.still = 1000 - txtVal
  953. },
  954. // 评论点赞
  955. like(item) {
  956. KmKnowledageService.getPraise({ id: item.id })
  957. .then((res) => {
  958. this.moreData = false
  959. if (res.data.accountOperation === 0) {
  960. Message.success('取消点赞成功', 2)
  961. } else {
  962. Message.success('点赞成功', 2)
  963. }
  964. if (!this.showLoadingMore) {
  965. // 初始化为0
  966. this.commentParams.startPosition = this.startNum
  967. // 结束位置为
  968. this.commentParams.maxResults = this.pagination.total + 1
  969. this.$nextTick(function() {
  970. this.queryComment(this.commentParams)
  971. })
  972. } else {
  973. this.$nextTick(function() {
  974. this.queryComment(this.commentParams)
  975. })
  976. }
  977. })
  978. .catch(() => {
  979. this.submitting = false
  980. })
  981. },
  982. treeSelected() {},
  983. close(flag) {
  984. crossWindowWatcher.notifyChange(this.$route.path, flag)
  985. window.close()
  986. },
  987. },
  988. }
  989. </script>
  990. <style module lang="scss">
  991. @use '@/common/design' as *;
  992. $header-lh: 50px;
  993. $comment-bg: #e4e4e4;
  994. $font-size-middle: 14px;
  995. $link-icon-size: 22px;
  996. $bgcolor: #f7f7f7;
  997. .layout {
  998. height: 100%;
  999. .layout-content {
  1000. min-height: calc(100% - 64px);
  1001. }
  1002. .bgcolor {
  1003. height: 100%;
  1004. background: $bgcolor;
  1005. :global(.ant-card-body) {
  1006. background-color: $bgcolor;
  1007. }
  1008. }
  1009. .header {
  1010. width: 100%;
  1011. height: 50px;
  1012. padding: 0 20px;
  1013. line-height: $header-lh;
  1014. color: $heading-color-dark;
  1015. background-color: $primary-color;
  1016. }
  1017. .news-main {
  1018. max-width: 1300px;
  1019. margin: 0 auto;
  1020. }
  1021. .recoment-radio {
  1022. margin-left: 140px;
  1023. }
  1024. .know-ledage {
  1025. padding: 20px 0;
  1026. overflow: hidden;
  1027. .kl-operation {
  1028. width: 100%;
  1029. padding-top: 20px;
  1030. margin-bottom: 20px;
  1031. text-align: left;
  1032. .drage {
  1033. sup {
  1034. top: -8px;
  1035. span {
  1036. p {
  1037. color: $heading-color-dark;
  1038. }
  1039. }
  1040. }
  1041. }
  1042. .is-active {
  1043. color: $primary-color;
  1044. i {
  1045. color: $primary-color;
  1046. }
  1047. }
  1048. > span {
  1049. margin-right: 20px;
  1050. }
  1051. span {
  1052. color: $text-color;
  1053. i {
  1054. padding-right: 5px;
  1055. }
  1056. &:hover {
  1057. color: $primary-color;
  1058. cursor: pointer;
  1059. }
  1060. }
  1061. .down-btn {
  1062. float: right;
  1063. padding: 6px 20px;
  1064. color: $white;
  1065. background: $primary-color;
  1066. border-radius: $border-radius-base;
  1067. }
  1068. }
  1069. .kl-article {
  1070. margin-top: 10px;
  1071. .left-content {
  1072. h3 {
  1073. font-size: $heading-3-size;
  1074. text-align: center;
  1075. }
  1076. .infos {
  1077. padding-bottom: 10px;
  1078. text-align: center;
  1079. :global(.ant-tag) {
  1080. background: white;
  1081. }
  1082. span {
  1083. padding-right: 15px;
  1084. font-size: $font-size-middle;
  1085. i {
  1086. font-style: normal;
  1087. color: $highlight-color;
  1088. }
  1089. }
  1090. }
  1091. .content {
  1092. min-height: 250px;
  1093. padding-top: 40px;
  1094. margin-bottom: 40px;
  1095. p {
  1096. font-size: $font-size-base;
  1097. line-height: $line-height-base;
  1098. text-indent: 60px;
  1099. }
  1100. }
  1101. .files {
  1102. margin: 0 0 10px;
  1103. overflow: hidden;
  1104. .files-name {
  1105. float: left;
  1106. }
  1107. .files-btn {
  1108. float: right;
  1109. button {
  1110. margin-right: 20px;
  1111. }
  1112. }
  1113. }
  1114. .artice-text {
  1115. padding: 40px 40px 10px;
  1116. background: #fff;
  1117. }
  1118. .comment {
  1119. padding: 20px;
  1120. margin-top: 20px;
  1121. background: #fff;
  1122. .pl-content {
  1123. .comment-text {
  1124. margin-bottom: 10px;
  1125. }
  1126. .comment-score {
  1127. .score {
  1128. float: left;
  1129. }
  1130. .publish {
  1131. float: right;
  1132. .text-num {
  1133. padding-right: 40px;
  1134. font-size: $font-size-middle;
  1135. color: $modal-mask-bg;
  1136. em {
  1137. padding: 0 2px;
  1138. font-style: normal;
  1139. }
  1140. }
  1141. }
  1142. }
  1143. }
  1144. .comment-list {
  1145. margin-top: -20px;
  1146. }
  1147. }
  1148. }
  1149. .right-content {
  1150. margin: 0 0 0 40px;
  1151. .article-info {
  1152. padding: 20px;
  1153. margin-bottom: 20px;
  1154. background: #fff;
  1155. p.title {
  1156. font-size: $font-size-lg;
  1157. font-weight: bold;
  1158. }
  1159. .user-info {
  1160. padding-top: 10px;
  1161. p {
  1162. margin-bottom: 10px;
  1163. }
  1164. .user-img {
  1165. padding-bottom: 10px;
  1166. .username {
  1167. margin-top: 8px;
  1168. margin-bottom: 0;
  1169. font-size: $btn-font-size-lg;
  1170. font-weight: bold;
  1171. }
  1172. .userinfo {
  1173. width: 65px;
  1174. height: 65px;
  1175. border-radius: 50%;
  1176. }
  1177. }
  1178. .user-num {
  1179. padding: 10px 0;
  1180. span {
  1181. padding-right: 40px;
  1182. font-weight: bold;
  1183. color: $black;
  1184. i {
  1185. padding-right: 10px;
  1186. }
  1187. }
  1188. }
  1189. }
  1190. .infos {
  1191. p {
  1192. margin-bottom: 5px;
  1193. font-size: $btn-font-size-sm;
  1194. i {
  1195. width: 4em; /* 这个值是看最长能显示几个文字,如x,则为x em */
  1196. margin-right: -2em; /* 同上 */
  1197. font-style: normal;
  1198. text-align: center;
  1199. letter-spacing: 2em; /* 如果需要y个字两端对齐,则为(x-y)/(y-1),这里是(4-2)/(2-1)=2em */
  1200. }
  1201. }
  1202. }
  1203. .wordlist {
  1204. .downloda {
  1205. display: inline-block;
  1206. width: 100%;
  1207. padding: 0 10px;
  1208. line-height: $btn-height-lg;
  1209. color: $btn-default-color;
  1210. cursor: pointer;
  1211. i {
  1212. padding-left: 10px;
  1213. }
  1214. }
  1215. .actived {
  1216. background: rgba(173, 212, 247, 0.78);
  1217. }
  1218. .defalut-color {
  1219. background: rgba(173, 212, 247, 0.78);
  1220. }
  1221. }
  1222. }
  1223. }
  1224. .moredata {
  1225. margin-top: 20px;
  1226. text-align: center;
  1227. cursor: pointer;
  1228. }
  1229. .no-comment {
  1230. text-align: center;
  1231. }
  1232. }
  1233. .wpsread {
  1234. height: 800px;
  1235. }
  1236. .example {
  1237. text-align: center;
  1238. }
  1239. }
  1240. .handle-btn {
  1241. padding: 0 $link-icon-size / 2;
  1242. span {
  1243. padding: 0 $link-icon-size / 2;
  1244. margin-right: 0;
  1245. margin-left: 10px;
  1246. cursor: pointer;
  1247. a {
  1248. cursor: pointer;
  1249. }
  1250. }
  1251. }
  1252. .list-item {
  1253. display: flex;
  1254. div {
  1255. &:first-child {
  1256. min-width: 150px;
  1257. }
  1258. &:nth-child(2) {
  1259. margin-left: 50px;
  1260. }
  1261. &:nth-child(3) {
  1262. margin-left: 50px;
  1263. }
  1264. }
  1265. }
  1266. .ulheight {
  1267. :global(.ant-list-items) {
  1268. max-height: 500px;
  1269. overflow-y: scroll;
  1270. }
  1271. }
  1272. :global(.ant-divider) {
  1273. margin: 0;
  1274. }
  1275. }
  1276. </style>