阅行客电子档案
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

359 lines
12 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <div class="app-container archives-container">
  3. <div class="container-main" style="justify-content: flex-start;">
  4. <div class="elect-cont-left">
  5. <div class="container-left">
  6. <span class="right-top-line" />
  7. <span class="left-bottom-line" />
  8. <div class="arc-left-tree">
  9. <h3 class="arc-title arc-title-top">档案门类</h3>
  10. <div class="tree-scroll">
  11. <el-tree ref="categroyTree" v-loading="crud.loading" class="arc-tree arc-tree-01" :data="crud.data" :props="defaultProps" node-key="id" :expand-on-click-node="false" highlight-current @node-click="handleNodeClick">
  12. <span slot-scope="{ node, data }" class="custom-tree-node">
  13. <span v-if="data.isType === 1 " class="iconFolder">
  14. {{ data.cnName }}
  15. </span>
  16. <span v-if="data.isType === 2" class="iconArch">
  17. {{ data.cnName }}
  18. </span>
  19. <span v-if="data.isType === 3" class="iconFile">
  20. {{ data.cnName }}
  21. </span>
  22. </span>
  23. </el-tree>
  24. </div>
  25. <h3 class="arc-title arc-title-bottom">快速筛选</h3>
  26. <el-tree
  27. ref="classifyTree"
  28. v-loading="classifyLoading"
  29. class="arc-tree arc-tree-02"
  30. :data="classifyTree"
  31. :props="defaultClassifyProps"
  32. node-key="id"
  33. :expand-on-click-node="false"
  34. highlight-current
  35. @node-click="handleNodeFilter"
  36. >
  37. <span slot-scope="{ node, data }" class="custom-tree-node">
  38. <span v-if="data.childDictionarys || data.fondsName" class="iconClassify">
  39. {{ data.dictionaryName || data.fondsName }}
  40. </span>
  41. <span v-else class="iconClassify-child">
  42. {{ data.dictionaryName }}
  43. </span>
  44. </span>
  45. </el-tree>
  46. </div>
  47. </div>
  48. </div>
  49. <!--用户数据-->
  50. <div v-if="selectedCategory.isType !== 1" class="elect-cont-right">
  51. <div class="container-right tab-content">
  52. <span class="right-top-line" />
  53. <span class="left-bottom-line" />
  54. <Project v-if="selectedCategory.arrangeType === 3" ref="projectEle" :selected-category="selectedCategory" :data="sharedData" :is-recycle="isRecycle" @openAnjuan="handleOpenAnjuan" />
  55. <Anjuan v-if="selectedCategory.arrangeType === 1 || selectedCategory.arrangeType === 2 || selectedCategory.arrangeType === 3" ref="anjuanEle" :selected-category="selectedCategory" :data="sharedData" :is-recycle="isRecycle" @openJuannei="handleOpenJuannei" />
  56. <Juannei v-if="selectedCategory.arrangeType === 2 || selectedCategory.arrangeType === 3" ref="juanneiEle" :data="sharedData" :selected-category="selectedCategory" :is-recycle="isRecycle" @openFile="handleOpenFile" />
  57. <File v-if="selectedCategory.arrangeType === 1 || selectedCategory.arrangeType === 2 || selectedCategory.arrangeType === 3" ref="fileEle" :is-recycle="isRecycle" :selected-category="selectedCategory" />
  58. </div>
  59. </div>
  60. </div>
  61. </div>
  62. </template>
  63. <script>
  64. import crudCategory from '@/api/category/category'
  65. import { manageLibraryCrud } from './mixins/index'
  66. import { FetchDictionaryTreeByCategoryId } from '@/api/system/dict'
  67. import CRUD, { presenter, header } from '@crud/crud'
  68. import Project from './project/index'
  69. import Anjuan from './anjuan/index'
  70. import Juannei from './juannei/index'
  71. import File from './file/index'
  72. export default {
  73. name: 'CollectionLibrary',
  74. components: { Project, Anjuan, Juannei, File },
  75. cruds() {
  76. return [
  77. CRUD({
  78. title: '收集库', url: 'api/category/menu',
  79. crudMethod: { ...crudCategory },
  80. optShow: {
  81. add: false,
  82. edit: false,
  83. del: false,
  84. download: false,
  85. group: false
  86. }
  87. })
  88. ]
  89. },
  90. mixins: [presenter(), header(), manageLibraryCrud],
  91. props: {
  92. isRecycle: {
  93. type: Boolean,
  94. default: false
  95. }
  96. },
  97. data() {
  98. return {
  99. defaultProps: {
  100. children: 'children',
  101. label: 'cnName'
  102. },
  103. defaultClassifyProps: {
  104. children: 'childDictionarys',
  105. label: 'dictionaryName'
  106. },
  107. sharedData: '',
  108. selectedCategory: {},
  109. classifyTree: [],
  110. classifyLoading: false
  111. }
  112. },
  113. watch: {
  114. isRecycle: function(newValue, oldValue) {
  115. }
  116. },
  117. created() {
  118. },
  119. mounted() {
  120. },
  121. methods: {
  122. filterData(data) {
  123. return data.filter(node => {
  124. if (node.children && node.children.length > 0) {
  125. node.children = this.filterData(node.children) // 递归处理子节点
  126. }
  127. return node.isType !== 3 // 过滤掉isType为3的节点
  128. })
  129. },
  130. // 逆归实现 获取指定元素
  131. findNode(tree, func) {
  132. for (const node of tree) {
  133. if (func(node)) return node
  134. if (node.children) {
  135. const res = this.findNode(node.children, func)
  136. if (res) return res
  137. }
  138. }
  139. return null
  140. },
  141. // 展开选中的父级
  142. expandParents(node) {
  143. node.expanded = true
  144. if (node.parent) {
  145. this.expandParents(node.parent)
  146. }
  147. },
  148. [CRUD.HOOK.afterRefresh]() {
  149. this.crud.data = this.filterData(this.crud.data)
  150. this.$nextTick(() => {
  151. let currentKey
  152. if (localStorage.getItem('currentArchivesKey')) {
  153. currentKey = JSON.parse(localStorage.getItem('currentArchivesKey'))
  154. // 删除门类节点后
  155. if (this.$refs.categroyTree.getCurrentKey(currentKey.id) == null) {
  156. localStorage.removeItem('currentArchivesKey')
  157. }
  158. // 缓存的门类节点判断
  159. if (currentKey.isType === 1) {
  160. if (currentKey.children.length !== 0) {
  161. currentKey = this.findNode(currentKey.children, (node) => {
  162. return node.isType !== 1
  163. })
  164. }
  165. }
  166. } else {
  167. // 默认
  168. if (this.crud.data[0].isType === 1) {
  169. currentKey = this.findNode(this.crud.data[0].children, (node) => {
  170. return node.isType !== 1
  171. })
  172. } else {
  173. currentKey = this.crud.data[0]
  174. }
  175. }
  176. if (currentKey.id) {
  177. // 设置某个节点的当前选中状态
  178. this.$refs.categroyTree.setCurrentKey(currentKey.id)
  179. this.$nextTick(() => {
  180. // 设置某个节点的父级展开
  181. const selectedKey = this.$refs.categroyTree.getCurrentNode()
  182. if (this.$refs.categroyTree.getNode(selectedKey) && this.$refs.categroyTree.getNode(selectedKey).parent) {
  183. this.expandParents(this.$refs.categroyTree.getNode(selectedKey).parent)
  184. }
  185. // 选中节点的门类详情
  186. this.handleNodeClick(selectedKey)
  187. })
  188. }
  189. })
  190. },
  191. handleNodeClick(val) {
  192. // 缓存当前的选中的
  193. localStorage.setItem('currentArchivesKey', JSON.stringify(val))
  194. this.selectedCategory = val
  195. if (this.selectedCategory.isType !== 1) {
  196. this.getDictionaryTreeByCategoryId(val.id)
  197. } else {
  198. this.classifyTree = []
  199. }
  200. this.$nextTick(() => {
  201. if (this.selectedCategory.arrangeType === 3) {
  202. // this.$refs.projectEle.getCommonData(1)
  203. } else if (this.selectedCategory.arrangeType === 2) {
  204. // this.$refs.anjuanEle.$refs.ajContent.$refs.tableList.getCommonData(2)
  205. } else if (this.selectedCategory.arrangeType === 1) {
  206. // this.$refs.anjuanEle.$refs.ajContent.$refs.tableList.getCommonData(3)
  207. }
  208. if (this.$refs.anjuanEle) {
  209. this.$refs.anjuanEle.anjuanDrawer = false
  210. // if (this.$refs.anjuanEle.$refs.ajContent) {
  211. // this.$refs.anjuanEle.$refs.ajContent.activeIndex = 0
  212. // }
  213. }
  214. if (this.$refs.juanneiEle) {
  215. this.$refs.juanneiEle.juanneiDrawer = false
  216. }
  217. if (this.$refs.fileEle) {
  218. this.$refs.fileEle.fileDrawer = false
  219. }
  220. })
  221. },
  222. getDictionaryTreeByCategoryId(categoryId) {
  223. this.classifyLoading = true
  224. const params = {
  225. 'categoryId': categoryId
  226. }
  227. FetchDictionaryTreeByCategoryId(params).then((res) => {
  228. let fonds
  229. if (res.fonds.length <= 1) {
  230. fonds = []
  231. } else {
  232. fonds = res.fonds
  233. }
  234. this.classifyTree = res.dictionarys.concat(fonds)
  235. this.classifyLoading = false
  236. }).catch(err => {
  237. console.log(err)
  238. })
  239. },
  240. handleNodeFilter(val) {
  241. console.log('val', val)
  242. },
  243. handleOpenAnjuan(data) {
  244. this.$refs.anjuanEle.anjuanDrawer = true
  245. // this.$refs.anjuanEle.$refs.ajContent.activeIndex = 0
  246. this.$nextTick(() => {
  247. this.$refs.anjuanEle.$refs.ajContent.test = data
  248. })
  249. },
  250. handleOpenJuannei(data) {
  251. if (this.selectedCategory.arrangeType === 1) {
  252. // && this.$refs.anjuanEle.$refs.ajContent.activeIndex === 1
  253. this.$refs.fileEle.fileDrawer = true
  254. this.$nextTick(() => {
  255. this.$refs.fileEle.test = data
  256. this.$refs.fileEle.isAjNo = 1
  257. })
  258. } else {
  259. this.$refs.juanneiEle.juanneiDrawer = true
  260. this.$nextTick(() => {
  261. this.$refs.juanneiEle.test = data
  262. this.$refs.fileEle.isAjNo = 0
  263. })
  264. }
  265. },
  266. handleOpenFile(data) {
  267. this.$refs.fileEle.fileDrawer = true
  268. this.$nextTick(() => {
  269. this.$refs.fileEle.test = data
  270. })
  271. }
  272. }
  273. }
  274. </script>
  275. <style lang="scss" scoped>
  276. .elect-cont-left{
  277. width: 276px;
  278. padding: 0 !important;
  279. }
  280. .hideSidebar .elect-cont-left {
  281. width: 265px !important;
  282. }
  283. [data-theme=light] .elect-cont-left .container-left {
  284. min-height: calc(100vh - 140px);
  285. }
  286. [data-theme=dark] .elect-cont-left .container-left {
  287. min-height: calc(100vh - 160px);
  288. }
  289. .openSidebar .elect-cont-right {
  290. width: calc(100vw - 592px);
  291. }
  292. [data-theme=light] .elect-cont-right .container-right.tab-content {
  293. min-height: calc(100vh - 180px) !important;
  294. }
  295. .arc-title{
  296. position: relative;
  297. height: 48px;
  298. line-height: 48px;
  299. text-align: center;
  300. font-size: 16px;
  301. color: #0C0E1E;
  302. background-color: #F3F5F8;
  303. &::after{
  304. content: "";
  305. position: absolute;
  306. right: 12px;
  307. bottom: 0;
  308. }
  309. }
  310. .arc-title-top{
  311. &::after{
  312. width: 44px;
  313. height: 35px;
  314. background: url("~@/assets/images/collect/daml.png") no-repeat;
  315. background-size: 100% 100%;
  316. }
  317. }
  318. .arc-title-bottom{
  319. &::after{
  320. width: 41px;
  321. height: 40px;
  322. background: url("~@/assets/images/collect/kssx.png") no-repeat;
  323. background-size: 100% 100%;
  324. }
  325. }
  326. .arc-tree{
  327. padding: 0 20px;
  328. background-color: red;
  329. }
  330. .arc-tree-01{
  331. height: 400px;
  332. overflow: hidden;
  333. overflow-y: scroll;
  334. }
  335. [data-theme=dark] .arc-tree-01{
  336. height: 370px;
  337. }
  338. .arc-tree-02{
  339. height: calc(100vh - 720px);
  340. overflow: hidden;
  341. overflow-y: scroll;
  342. }
  343. ::v-deep .el-tree-node__children .custom-tree-node{
  344. font-size: 14px;
  345. }
  346. [data-theme=light] .elect-cont-right {
  347. padding: 0 20px !important;
  348. }
  349. [data-theme=dark] .elect-cont-right {
  350. margin-top: 0 !important;
  351. }
  352. </style>