【前端】智能库房综合管理系统前端项目
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.

445 lines
15 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <div class="app-container">
  3. <!-- 门类列表 -->
  4. <el-row class="container-main">
  5. <el-col class="curd-in-out" :xs="10" :sm="8" :md="5" :lg="6" :xl="5">
  6. <div :class="['container-left', !isRecycle?'left-tree-item':'']">
  7. <span class="right-top-line" />
  8. <span class="left-bottom-line" />
  9. <div class="tree-title">档案门类</div>
  10. <!--档案门类树状结构-->
  11. <div class="tree-scroll">
  12. <el-tree ref="archivesTree" v-loading="crud.loading" :data="crud.data" :props="defaultProps" node-key="id" :expand-on-click-node="false" highlight-current @node-click="handleNodeClick" />
  13. </div>
  14. </div>
  15. <div v-if="!isRecycle" class="container-left left-tree-item">
  16. <span class="right-top-line" />
  17. <span class="left-bottom-line" />
  18. <div class="tree-title">智能分类</div>
  19. <!--智能分类树状结构-->
  20. <div class="tree-scroll">
  21. <el-tree ref="smartTree" v-loading="intellClassifyLoading" :data="intellClassifyTree" :props="intellDefaultProps" node-key="id" :expand-on-click-node="false" highlight-current @node-click="handleIntellNodeClick" />
  22. </div>
  23. </div>
  24. </el-col>
  25. <!-- 档案管理列表 -->
  26. <el-col class="archives-right-list" :xs="14" :sm="18" :md="19" :lg="18" :xl="19">
  27. <div v-if="selectedCategory.isType !== 1 && !isRecycle" :class="['archives-top', {'archives-fixed-top': selectedCategory.isType===2 || selectedCategory.isType===4 }]">
  28. <el-checkbox v-model="fixedStatusBar">隐藏固定状态栏</el-checkbox>
  29. </div>
  30. <!-- 项目 -->
  31. <archivesProject
  32. v-if="selectedCategory.isType === 2"
  33. ref="project"
  34. :selected-category="selectedCategory"
  35. :smart-query="smartQuery"
  36. @getAjInProjectBtnState="getAjInProjectBtnState"
  37. @getProjectSelections="getProjectSelections"
  38. />
  39. <!-- 案卷 -->
  40. <archivesAnjuan
  41. v-if="selectedCategory.isType === 2 || selectedCategory.isType === 3|| selectedCategory.isType === 5"
  42. ref="anjuan"
  43. :selected-category="selectedCategory"
  44. :is-project="isProject"
  45. :project-selection="projectSelection"
  46. :fixed-status-bar="fixedStatusBar"
  47. :archive-year="archiveYear"
  48. :smart-query="smartQuery"
  49. @getJnInAjBtnState="getJnInAjBtnState"
  50. @getSelections="getSelections"
  51. />
  52. <!-- 卷内 -->
  53. <archivesJuannei
  54. v-if="selectedCategory.isType === 2 || selectedCategory.isType === 3 || selectedCategory.isType === 4"
  55. ref="file"
  56. :is-anjuan="isAnjuan"
  57. :anjuan-selection="anjuanSelection"
  58. :selected-category="selectedCategory"
  59. :fixed-status-bar="fixedStatusBar"
  60. :smart-query="smartQuery"
  61. />
  62. </el-col>
  63. </el-row>
  64. </div>
  65. </template>
  66. <script>
  67. import { getDicts } from '@/api/archivesConfig/dict'
  68. import archivesProject from './module/archivesProject/index'
  69. import archivesAnjuan from './module/archivesAnjuan/index'
  70. import archivesJuannei from './module/archivesJuannei/index'
  71. import crudCategory from '@/api/category/category'
  72. import CRUD, { presenter } from '@crud/crud'
  73. export default {
  74. name: 'ArchivesList',
  75. components: { archivesProject, archivesAnjuan, archivesJuannei },
  76. cruds() {
  77. return [
  78. CRUD({
  79. title: '档案', url: 'api/archives-type/menu',
  80. crudMethod: { ...crudCategory }
  81. })
  82. ]
  83. },
  84. provide() {
  85. return {
  86. recycleMain: this
  87. }
  88. },
  89. mixins: [presenter()],
  90. props: {
  91. isdel: {
  92. type: Boolean,
  93. default: false
  94. },
  95. isRecycle: {
  96. type: Boolean,
  97. default: false
  98. }
  99. },
  100. data() {
  101. return {
  102. intellClassifyTree: [],
  103. defaultProps: {
  104. children: 'children',
  105. label: 'cnName'
  106. },
  107. intellDefaultProps: {
  108. children: 'childMenus',
  109. label: 'dicName'
  110. },
  111. selectedCategory: {},
  112. isAnjuan: true,
  113. isProject: true,
  114. anjuanSelection: {},
  115. projectSelection: {},
  116. intellClassifyLoading: false,
  117. fixedStatusBar: false,
  118. archiveYear: null,
  119. smartQuery: {
  120. 'archiveYear': null,
  121. 'department': null,
  122. 'retention': null,
  123. 'securityClass': null,
  124. 'organizationMatter': null
  125. },
  126. treeCurrentNode: null
  127. }
  128. },
  129. watch: {
  130. isdel: function(newValue, oldValue) {
  131. },
  132. isRecycle: function(newValue, oldValue) {
  133. }
  134. },
  135. methods: {
  136. // 逆归实现 获取指定元素
  137. findNode(tree, func) {
  138. for (const node of tree) {
  139. if (func(node)) return node
  140. if (node.children) {
  141. const res = this.findNode(node.children, func)
  142. if (res) return res
  143. }
  144. }
  145. return null
  146. },
  147. // 展开选中的父级
  148. expandParents(node) {
  149. node.expanded = true
  150. if (node.parent) {
  151. this.expandParents(node.parent)
  152. }
  153. },
  154. [CRUD.HOOK.afterRefresh]() {
  155. let currentKey
  156. if (localStorage.getItem('currentArchivesKey')) {
  157. currentKey = JSON.parse(localStorage.getItem('currentArchivesKey'))
  158. // 删除门类节点后
  159. if (this.$refs.archivesTree.getCurrentKey(currentKey.id) == null) {
  160. localStorage.removeItem('currentArchivesKey')
  161. }
  162. // 缓存的门类节点判断
  163. if (currentKey.isType === 1) {
  164. if (currentKey.children.length !== 0) {
  165. currentKey = this.findNode(currentKey.children, (node) => {
  166. return node.isType !== 1
  167. })
  168. }
  169. }
  170. } else {
  171. // 默认
  172. if (this.crud.data[0].isType === 1) {
  173. currentKey = this.findNode(this.crud.data[0].children, (node) => {
  174. return node.isType !== 1
  175. })
  176. } else {
  177. currentKey = this.crud.data[0]
  178. }
  179. }
  180. if (currentKey.id) {
  181. // 设置某个节点的当前选中状态
  182. this.$refs.archivesTree.setCurrentKey(currentKey.id)
  183. this.$nextTick(() => {
  184. // 设置某个节点的父级展开
  185. const selectedKey = this.$refs.archivesTree.getCurrentNode()
  186. if (this.$refs.archivesTree.getNode(selectedKey) && this.$refs.archivesTree.getNode(selectedKey).parent) {
  187. this.expandParents(this.$refs.archivesTree.getNode(selectedKey).parent)
  188. }
  189. // 选中节点的门类详情
  190. this.handleNodeClick(selectedKey)
  191. })
  192. }
  193. this.getIntellClassify()
  194. },
  195. getIntellClassify() {
  196. getDicts().then(data => {
  197. if (data) {
  198. this.intellClassifyTree = data.filter(item => {
  199. return item.dicCode === 'Search_MJ' || item.dicCode === 'Search_BGQX' || item.dicCode === 'Search_JGWT' || item.dicCode === 'Search_BM'
  200. })
  201. }
  202. })
  203. },
  204. // 选中字典后,设置字典详情数据
  205. handleNodeClick(val) {
  206. if (val) {
  207. // 初始化智能分类的操作
  208. if (this.$refs.smartTree) {
  209. this.treeCurrentNode = null
  210. const smartTreeList = this.intellClassifyTree
  211. this.smartQuery = {
  212. 'archiveYear': null,
  213. 'department': null,
  214. 'retention': null,
  215. 'securityClass': null,
  216. 'organizationMatter': null
  217. }
  218. this.$refs.smartTree.setCurrentKey(null)
  219. smartTreeList.forEach((item, index) => {
  220. this.$refs.smartTree.store.nodesMap[smartTreeList[index].id].expanded = false
  221. })
  222. }
  223. this.crud.selectionChangeHandler([val])
  224. this.selectedCategory = val
  225. this.handleTableList()
  226. // 缓存当前的选中的
  227. localStorage.setItem('currentArchivesKey', JSON.stringify(val))
  228. }
  229. },
  230. // 判断案卷内的卷内-新增btn-状态 中转站
  231. getJnInAjBtnState(data) {
  232. this.isAnjuan = data
  233. },
  234. getAjInProjectBtnState(data) {
  235. this.isProject = data
  236. },
  237. getProjectSelections(data, selectData) {
  238. this.smartQuery = {
  239. 'archiveYear': null,
  240. 'department': null,
  241. 'retention': null,
  242. 'securityClass': null,
  243. 'organizationMatter': null
  244. }
  245. if ((selectData && selectData.length > 1) || (selectData && selectData.length === 0)) {
  246. this.projectSelection = {}
  247. this.$nextTick(() => {
  248. if (this.$refs.anjuan) {
  249. this.$refs.anjuan.anjuanData = []
  250. }
  251. })
  252. } else if (selectData && selectData.length === 1) {
  253. this.projectSelection = selectData[0]
  254. this.$nextTick(() => {
  255. if (this.$refs.anjuan) {
  256. this.$refs.anjuan.getTableList()
  257. }
  258. })
  259. } else {
  260. this.projectSelection = data
  261. this.$nextTick(() => {
  262. if (this.$refs.anjuan) {
  263. this.$refs.anjuan.getTableList()
  264. }
  265. })
  266. }
  267. },
  268. getSelections(data, selectData) {
  269. this.smartQuery = {
  270. 'archiveYear': null,
  271. 'department': null,
  272. 'retention': null,
  273. 'securityClass': null,
  274. 'organizationMatter': null
  275. }
  276. if ((selectData && selectData.length > 1) || (selectData && selectData.length === 0)) {
  277. this.anjuanSelection = {}
  278. this.$nextTick(() => {
  279. if (this.$refs.file) {
  280. this.$refs.file.junneiData = []
  281. }
  282. })
  283. } else if (selectData && selectData.length === 1) {
  284. this.anjuanSelection = selectData[0]
  285. this.$nextTick(() => {
  286. if (this.$refs.file) {
  287. this.$refs.file.getTableList()
  288. }
  289. })
  290. } else {
  291. this.anjuanSelection = data
  292. this.$nextTick(() => {
  293. if (this.$refs.file) {
  294. this.$refs.file.getTableList()
  295. }
  296. })
  297. }
  298. },
  299. getYear(obj) {
  300. if (this.$refs.smartTree) {
  301. this.intellClassifyLoading = true
  302. setTimeout(() => {
  303. if (this.intellClassifyTree[0].dicName === '年度') {
  304. this.intellClassifyTree = this.intellClassifyTree.slice(1)
  305. }
  306. if (this.$refs[obj].yearGroup.length !== 0) {
  307. const newYearArr = this.$refs[obj].yearGroup.map((item, index) => {
  308. const json = {}
  309. json.id = index
  310. json.dicName = item
  311. json.childMenus = []
  312. json.ifChild = true
  313. return json
  314. })
  315. this.intellClassifyTree.unshift({ id: -1, dicName: '年度', dicCode: 'Search_year', childMenus: newYearArr })
  316. }
  317. this.intellClassifyLoading = false
  318. }, 500)
  319. }
  320. },
  321. // 智能分类
  322. handleIntellNodeClick(data, node, ele) {
  323. if (data) {
  324. if (node.childNodes.length === 0) {
  325. const selectedKey = this.$refs.smartTree.getCurrentNode()
  326. const selectedParentVal = this.$refs.smartTree.getNode(selectedKey).parent.data.dicCode
  327. this.treeCurrentNode = ele.$el
  328. // if (data.ifChild) {
  329. // this.treeCurrentNode = ele.$el
  330. // const eles = document.querySelectorAll('.el-tree-node__children .el-tree-node.is-focusable')
  331. // for (let i = 0; i < eles.length; i++) {
  332. // eles[i].classList.remove('is-current')
  333. // }
  334. // this.treeCurrentNode.classList.add('is-current')
  335. // } else {
  336. // ele.$el.classList.remove('is-current')
  337. // console.log(this.treeCurrentNode)
  338. // if (this.treeCurrentNode) {
  339. // this.treeCurrentNode.classList.add('is-current')
  340. // }
  341. // }
  342. if (ele.$el.classList.contains('is-current')) {
  343. this.treeCurrentNode.classList.remove('is-current')
  344. this.smartQuery = {
  345. 'archiveYear': null,
  346. 'department': null,
  347. 'retention': null,
  348. 'securityClass': null,
  349. 'organizationMatter': null
  350. }
  351. } else {
  352. this.treeCurrentNode.classList.add('is-current')
  353. switch (selectedParentVal) {
  354. case 'Search_year':
  355. if (selectedKey.dicCode !== 'Search_year') {
  356. this.smartQuery.archiveYear = selectedKey.dicName
  357. }
  358. break
  359. case 'Search_BM':
  360. if (selectedKey.dicCode !== 'Search_BM') {
  361. this.smartQuery.department = selectedKey.dicName
  362. }
  363. break
  364. case 'Search_BGQX':
  365. if (selectedKey.dicCode !== 'Search_BGQX') {
  366. this.smartQuery.retention = selectedKey.dicName
  367. }
  368. break
  369. case 'Search_MJ':
  370. if (selectedKey.dicCode !== 'Search_MJ') {
  371. this.smartQuery.securityClass = selectedKey.dicName
  372. }
  373. break
  374. default:
  375. if (selectedKey.dicCode !== 'Search_JGWT') {
  376. this.smartQuery.organizationMatter = selectedKey.dicName
  377. }
  378. }
  379. }
  380. this.handleTableList()
  381. }
  382. }
  383. },
  384. handleTableList() {
  385. if (this.selectedCategory.isType === 2) {
  386. this.$nextTick(() => {
  387. this.$refs.anjuan.anjuanData = []
  388. this.$refs.file.junneiData = []
  389. if (this.selectedCategory.children.length !== 0) {
  390. this.$refs.anjuan.getTableDisplayFields()
  391. this.$refs.file.getTableDisplayFields()
  392. }
  393. this.$refs.project.getTableList()
  394. if (!this.treeCurrentNode) {
  395. this.getYear('project')
  396. }
  397. })
  398. } else if (this.selectedCategory.isType === 3) {
  399. this.$nextTick(() => {
  400. this.$refs.anjuan.anjuanData = []
  401. this.$refs.file.junneiData = []
  402. this.$refs.anjuan.getTableDisplayFields()
  403. if (this.selectedCategory.children.length !== 0) {
  404. this.$refs.file.getTableDisplayFields()
  405. }
  406. this.$refs.anjuan.getTableList()
  407. if (!this.treeCurrentNode) {
  408. this.getYear('anjuan')
  409. }
  410. })
  411. } else if (this.selectedCategory.isType === 4) {
  412. this.$nextTick(() => {
  413. this.$refs.file.junneiData = []
  414. this.$refs.file.getTableDisplayFields()
  415. this.$refs.file.getTableList()
  416. if (!this.treeCurrentNode) {
  417. this.getYear('file')
  418. }
  419. })
  420. } else if (this.selectedCategory.isType === 5) {
  421. this.$nextTick(() => {
  422. this.$refs.anjuan.anjuanData = []
  423. this.$refs.anjuan.getTableDisplayFields()
  424. this.$refs.anjuan.getTableList()
  425. if (!this.treeCurrentNode) {
  426. this.getYear('anjuan')
  427. }
  428. })
  429. }
  430. }
  431. }
  432. }
  433. </script>
  434. <style lang="scss" scoped>
  435. @import "~@/assets/styles/archives-manage.scss";
  436. .tree-scroll{
  437. height: calc(100vh - 630px);
  438. overflow-y: scroll;
  439. overflow-x: hidden;
  440. }
  441. </style>