km-kmap-pages.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <template>
  2. <a-layout :class="$style.pages">
  3. <sd-header>
  4. <template>
  5. <span :class="$style.handleBtn">
  6. <span @click="close"><a-icon type="close-circle"></a-icon> 退出 </span>
  7. </span>
  8. </template>
  9. </sd-header>
  10. <a-layout-content v-if="inited" :class="$style.main">
  11. <div :class="$style.content">
  12. <sd-form
  13. v-if="formData.pageFormData"
  14. ref="form"
  15. :init-values="formData.pageFormData.pageFieldInfos"
  16. :read-only="docReadonly"
  17. >
  18. <template v-slot="{ model, fields }">
  19. <a-row type="flex">
  20. <a-col flex="1 1 ">
  21. <div :class="$style.leftDivContent">
  22. <a-card>
  23. <table :class="$style.table">
  24. <h3 :class="$style.title">{{ fields.kmapName.value }}</h3>
  25. <a-divider />
  26. <tr v-if="model.type === '0'">
  27. <td>
  28. <a-table
  29. :pagination="false"
  30. :columns="childColumns"
  31. :data-source="model.kmKmapKnowledgeList"
  32. >
  33. <a
  34. slot="fldSubject"
  35. slot-scope="text, record"
  36. @click="fnOpenDoc(record)"
  37. >
  38. {{ text }}
  39. </a>
  40. </a-table>
  41. </td>
  42. </tr>
  43. <tr v-else>
  44. <td>
  45. <div>
  46. <km-js-mind
  47. ref="jsmind"
  48. v-model="model.kmapTemplate"
  49. :read-only="docReadonly"
  50. />
  51. </div>
  52. </td>
  53. </tr>
  54. </table>
  55. </a-card>
  56. </div>
  57. </a-col>
  58. <a-col flex="0 1 300px">
  59. <div :class="$style.rightDivContent">
  60. <div :class="$style.articleInfo">
  61. <p :class="$style.title">文档信息</p>
  62. <a-divider />
  63. <div :class="$style.userInfo">
  64. <div :class="$style.user">
  65. <p>创建者</p>
  66. <a-row :class="$style.userImg" type="flex">
  67. <a-col flex="80px">
  68. <a-avatar
  69. :class="$style.userinfo"
  70. icon="user"
  71. :size="65"
  72. :src="
  73. `api/mobile/v1/user-manager/userAvatar/${fields.creatorAccount.value}`
  74. | sdResource
  75. "
  76. alt="avatar"
  77. />
  78. </a-col>
  79. <a-col flex="auto">
  80. <p :class="$style.username">{{ fields.creatorName.value }}</p>
  81. <p>{{ fields.createDeptName.value }}</p>
  82. </a-col>
  83. </a-row>
  84. </div>
  85. </div>
  86. <a-divider />
  87. <div :class="$style.infos">
  88. <p>
  89. <i>分类</i>:<span>{{ fnGetCate(fields.kmapCategory.value) }}</span>
  90. </p>
  91. <p>
  92. 创建时间:<span>{{ fields.creationTime.value | sdDateFormat }}</span>
  93. </p>
  94. <p>
  95. <i>标签</i>:<span>{{ fnGetLable(fields.label.value) }}</span>
  96. </p>
  97. <p>
  98. <i>摘要</i>:<span :title="fields.abstractMessage.value">{{
  99. fnGetMessage(fields.abstractMessage.value)
  100. }}</span>
  101. </p>
  102. </div>
  103. </div>
  104. </div>
  105. </a-col>
  106. </a-row>
  107. </template>
  108. </sd-form>
  109. </div>
  110. </a-layout-content>
  111. </a-layout>
  112. </template>
  113. <script>
  114. import crossWindowWatcher from '@/common/services/cross-window-watcher'
  115. import PageService from '@/common/services/page-service'
  116. import KmKnowledageService from '../km-knowledage-service'
  117. import components from './_import-components/km-kmap-pages-import'
  118. export default {
  119. name: 'KmKmapPages',
  120. metaInfo: {
  121. title: '知识地图',
  122. },
  123. components,
  124. data() {
  125. return {
  126. inited: false,
  127. formData: {},
  128. docReadonly: true,
  129. childColumns: [
  130. { dataIndex: 'title', title: '知识标题', scopedSlots: { customRender: 'fldSubject' } },
  131. { dataIndex: 'categoryName', title: '所属分类' },
  132. ],
  133. }
  134. },
  135. created() {
  136. this.getData()
  137. this.fnSetKmapReadNum()
  138. },
  139. methods: {
  140. // 获取表单数据
  141. getData() {
  142. const pageId = 'kmap/kmKmap/kmKmapData'
  143. const docId = parseInt(this.$route.params.docId)
  144. this.inited = true
  145. const params = {
  146. id: docId,
  147. }
  148. PageService.get(params, pageId).then((res) => {
  149. if (res.status === 200) {
  150. this.inited = true
  151. this.formData = res.data
  152. }
  153. })
  154. },
  155. // 知识地图阅读次数
  156. fnSetKmapReadNum() {
  157. const params = {
  158. id: this.$route.params.docId,
  159. }
  160. KmKnowledageService.setKmapReadNum(params).then((res) => {})
  161. },
  162. fnGetCate(val) {
  163. if (val) {
  164. if (Array.isArray(val)) {
  165. return val[0].name
  166. } else {
  167. return JSON.parse(val)[0].name
  168. }
  169. } else {
  170. return ''
  171. }
  172. },
  173. fnGetMessage(val) {
  174. if (!val) return ''
  175. if (val.length > 100) {
  176. return val.slice(0, 100) + '...'
  177. }
  178. return val
  179. },
  180. fnGetLable(val) {
  181. if (val) {
  182. let array = []
  183. if (Array.isArray(val)) {
  184. array = val
  185. } else {
  186. array = JSON.parse(val)
  187. }
  188. if (array.length > 1) {
  189. return array.join(',')
  190. } else {
  191. return array[0]
  192. }
  193. } else {
  194. return ''
  195. }
  196. },
  197. fnOpenDoc(record) {
  198. if (record.type === '1') {
  199. // 说明是外部知识
  200. window.open(record.link, '_blank')
  201. } else {
  202. window.open(`#/km-knowledage-view?id=${record.knowledgeId}&title=${record.title}`, '_blank')
  203. }
  204. },
  205. close(flag) {
  206. crossWindowWatcher.notifyChange(this.$route.path, flag)
  207. window.close()
  208. },
  209. },
  210. }
  211. </script>
  212. <style module lang="scss">
  213. @use '@/common/design' as *;
  214. $link-icon-size: 22px;
  215. .pages {
  216. min-height: 100%;
  217. :global(.ant-tabs-nav-wrap) {
  218. text-align: center;
  219. }
  220. .handle-btn {
  221. padding: 0 $link-icon-size / 2;
  222. span {
  223. padding: 0 $link-icon-size / 2;
  224. margin-right: 0;
  225. margin-left: 10px;
  226. cursor: pointer;
  227. }
  228. }
  229. .main {
  230. display: flex;
  231. justify-content: space-between;
  232. padding: 20px;
  233. .content {
  234. flex: 1;
  235. max-width: 1200px;
  236. margin: 0 auto;
  237. .left-div-content {
  238. min-height: 850px;
  239. margin: 0 10px;
  240. background-color: $white;
  241. .table {
  242. width: 100%;
  243. .title {
  244. font-size: $heading-3-size;
  245. text-align: center;
  246. }
  247. }
  248. }
  249. .right-div-content {
  250. background-color: $white;
  251. .article-info {
  252. padding: 20px;
  253. p.title {
  254. font-size: $font-size-lg;
  255. font-weight: bold;
  256. }
  257. .user-info {
  258. .user-img {
  259. .username {
  260. margin-top: 8px;
  261. margin-bottom: 0;
  262. font-size: $btn-font-size-lg;
  263. font-weight: bold;
  264. }
  265. .userinfo {
  266. width: 65px;
  267. height: 65px;
  268. border-radius: 50%;
  269. }
  270. }
  271. }
  272. .infos {
  273. p {
  274. margin-bottom: 5px;
  275. font-size: $btn-font-size-sm;
  276. i {
  277. width: 4em; /* 这个值是看最长能显示几个文字,如x,则为x em */
  278. margin-right: -2em; /* 同上 */
  279. font-style: normal;
  280. text-align: center;
  281. letter-spacing: 2em; /* 如果需要y个字两端对齐,则为(x-y)/(y-1),这里是(4-2)/(2-1)=2em */
  282. }
  283. }
  284. }
  285. }
  286. }
  287. }
  288. }
  289. }
  290. </style>