阅行客电子档案
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.

420 lines
17 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
10 months ago
2 years ago
2 years ago
2 years ago
10 months ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
10 months ago
2 years ago
2 years ago
10 months ago
2 years ago
2 years ago
2 years ago
10 months ago
2 years ago
10 months ago
2 years ago
2 years ago
10 months ago
2 years ago
2 years ago
10 months ago
10 months ago
10 months ago
2 years ago
2 years ago
10 months ago
2 years ago
2 years ago
2 years ago
10 months ago
2 years ago
2 years ago
2 years ago
10 months ago
2 years ago
2 years ago
2 years ago
10 months ago
2 years ago
2 years ago
2 years ago
10 months ago
2 years ago
10 months ago
2 years ago
2 years ago
2 years ago
10 months ago
2 years ago
10 months ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. import { FetchInitCategoryViewTable, FetchInitCategoryView } from '@/api/collect/collect'
  2. import { FetchDictionaryTree } from '@/api/system/dict'
  3. import { crud } from '@crud/crud'
  4. export const collectionLibraryCrud = {
  5. mixins: [crud()],
  6. // 组件共用属性
  7. data() {
  8. return {
  9. getTableDisplayFieldsLoading: false,
  10. tableDisplayFields: [],
  11. projectData: [],
  12. anjuanData: [],
  13. junneiData: [],
  14. fileData: [],
  15. arrySort: [],
  16. page: {
  17. page: localStorage.getItem('currentPage') ? parseInt(localStorage.getItem('currentPage')) : 0,
  18. size: 10,
  19. total: 0
  20. },
  21. timer: null,
  22. query: {
  23. search: null,
  24. project_class: null,
  25. archive_ctg_no: null
  26. },
  27. classifyTree: [],
  28. classifyLoading: false,
  29. parentsId: null
  30. }
  31. },
  32. // 组件挂载时的共用方法
  33. mounted() {
  34. },
  35. // 组件共用方法
  36. methods: {
  37. // 缓存用户对于固定栏操作习惯
  38. statusBarChecked(val) {
  39. this.fixedStatusBar = val
  40. localStorage.setItem('statusBarFixedType', val)
  41. },
  42. hasValue(obj) {
  43. for (const key in obj) {
  44. if (obj.hasOwnProperty(key) && obj[key] !== null && obj[key] !== '') {
  45. return true
  46. }
  47. }
  48. return false
  49. },
  50. handleSearch(categoryLevel) {
  51. const queryResult = this.hasValue(this.query)
  52. if (localStorage.getItem('currentPage') && !queryResult) {
  53. this.page.page = parseInt(localStorage.getItem('currentPage'))
  54. } else {
  55. this.page.page = 0
  56. }
  57. this.parentsData.$refs.classifyTree.setCurrentKey(null)
  58. // this.smartQuery = {
  59. // 'retention': null,
  60. // 'security_class': null,
  61. // 'doc_type': null,
  62. // 'medium_type': null,
  63. // 'archive_year': null,
  64. // 'fonds_no': null
  65. // }
  66. this.smartQuery = this.parentsData.smartQuery
  67. // 2 项目 3 案卷 /文件 4 卷内 6 文件
  68. if (this.isTitleType === 2) {
  69. this.parentsId = null
  70. this.$parent.getTableDisplayFieldsLoading = true
  71. } else if (this.isTitleType === 3) {
  72. if (this.selectedCategory.arrangeType === 1) {
  73. this.parentsId = null
  74. } else {
  75. if (this.activeIndex === 1) {
  76. this.parentsId = null
  77. } else {
  78. this.parentsId = this.parentsData.parentsProjectId
  79. }
  80. }
  81. this.$parent.getTableDisplayFieldsLoading = true
  82. } else if (this.isTitleType === 4) {
  83. // 卷内
  84. this.$parent.$parent.getTableDisplayFieldsLoading = true
  85. this.parentsId = this.parentsData.parentsAnjuanId
  86. } else if (this.isTitleType === 6) {
  87. // 原文
  88. if (this.selectedCategory.arrangeType === 1) {
  89. this.parentsId = this.parentsData.parentsAnjuanId
  90. this.$parent.getTableDisplayFieldsLoading = true
  91. } else {
  92. this.$parent.$parent.getTableDisplayFieldsLoading = true
  93. if (this.parentsData.isTabFile) {
  94. this.parentsId = this.parentsData.parentsAnjuanId
  95. } else {
  96. this.parentsId = this.parentsData.parentsJuanneiId
  97. }
  98. }
  99. }
  100. setTimeout(() => {
  101. this.getViewTable(categoryLevel, this.parentsId, 'search')
  102. }, 200)
  103. },
  104. getViewTable(categoryLevel, parentsId, type) {
  105. this.getTableDisplayFieldsLoading = true
  106. this.tableDisplayFields = []
  107. FetchInitCategoryViewTable({ categoryId: this.selectedCategory.id, categoryLevel: categoryLevel }).then((res) => {
  108. if (res) {
  109. this.arrySort = []
  110. this.tableDisplayFields = res
  111. const orderSortArry = this.tableDisplayFields.filter(item => item.queue).sort((a, b) => a.queue - b.queue)
  112. orderSortArry.forEach(item => {
  113. if (item.displayOrderBy) {
  114. this.arrySort.push(item.fieldName + ',' + item.displayOrderBy)
  115. }
  116. })
  117. this.$nextTick(() => {
  118. this.getViewTableList(categoryLevel, parentsId, type)
  119. })
  120. }
  121. })
  122. },
  123. getViewTableList(categoryLevel, parentsId, type) {
  124. const currentPageSize = localStorage.getItem('currentPageSize')
  125. if (currentPageSize) {
  126. this.page.size = parseInt(currentPageSize)
  127. } else {
  128. this.page.size = 10
  129. }
  130. const params = {
  131. 'parentId': parentsId,
  132. 'categoryId': this.selectedCategory.id,
  133. 'categoryLevel': categoryLevel,
  134. 'ignore': false,
  135. // 'isdel': (this.parentsData.isdel && this.selectedCategory.arrangeType === 2 && categoryLevel === 3) ? false : this.parentsData.isdel,
  136. 'isdel': this.parentsData.isdel === true ? this.parentsData.isdel : false,
  137. 'search': this.query.search,
  138. 'retention': this.smartQuery.retention,
  139. 'security_class': this.smartQuery.security_class,
  140. 'medium_type': this.smartQuery.medium_type,
  141. 'doc_type': this.smartQuery.doc_type,
  142. 'archive_year': this.smartQuery.archive_year,
  143. 'organ_or_function': this.smartQuery.organ_or_function,
  144. 'fonds_no': this.smartQuery.fonds_no,
  145. 'project_class': this.query.project_class,
  146. 'archive_ctg_no': this.query.archive_ctg_no,
  147. 'page': this.page.page,
  148. 'size': this.page.size,
  149. 'sort': this.arrySort
  150. }
  151. FetchInitCategoryView(params).then((res) => {
  152. if (res.code !== 500) {
  153. this.parentsData.listCategory = res.category
  154. const baseCategory = res.category.id
  155. if (categoryLevel === 1) {
  156. // 项目
  157. const projectObj = this.parentsData.$refs.projectEle
  158. // this.projectData = res.list.content
  159. this.projectData = res.list.content.map(item => {
  160. return {
  161. ...item,
  162. baseCategory: baseCategory
  163. }
  164. })
  165. this.page.total = res.list.totalElements
  166. this.yearData = res.yearGroup
  167. if (this.yearData && type !== 'quickFilter') {
  168. this.$emit('myYearEvent', this.yearData)
  169. }
  170. if (type === 'search') {
  171. // projectObj.projectData = res.list.content
  172. projectObj.projectData = res.list.content.map(item => {
  173. return {
  174. ...item,
  175. baseCategory: baseCategory
  176. }
  177. })
  178. projectObj.currentPage = this.page.page + 1
  179. // projectObj.page.page = 1
  180. // projectObj.page.size = 10
  181. projectObj.page.total = res.list.totalElements
  182. projectObj.getTableDisplayFieldsLoading = false
  183. }
  184. } else if (categoryLevel === 2) {
  185. // 案卷
  186. const anjuanObj = this.parentsData.$refs.anjuanEle.$refs.ajContent.$refs.tableList
  187. // this.anjuanData = res.list.content
  188. this.anjuanData = res.list.content.map(item => {
  189. return {
  190. ...item,
  191. baseCategory: baseCategory
  192. }
  193. })
  194. this.page.total = res.list.totalElements
  195. this.yearData = res.yearGroup
  196. if (this.yearData && type !== 'quickFilter') {
  197. this.$parent.$parent.$emit('myYearEvent', this.yearData)
  198. }
  199. // 搜索/新增/编辑 非 案卷是主页的时候
  200. if (type === 'search') {
  201. // anjuanObj.anjuanData = res.list.content
  202. anjuanObj.anjuanData = res.list.content.map(item => {
  203. return {
  204. ...item,
  205. baseCategory: baseCategory
  206. }
  207. })
  208. anjuanObj.currentPage = this.page.page + 1
  209. // anjuanObj.page.page = 1
  210. // anjuanObj.page.size = 10
  211. anjuanObj.page.total = res.list.totalElements
  212. anjuanObj.getTableDisplayFieldsLoading = false
  213. }
  214. } else if (categoryLevel === 3) {
  215. if (this.isTitleType === 3) {
  216. // 案卷下的未整理 / 文件为主页时
  217. const wjObj = this.parentsData.$refs.anjuanEle.$refs.ajContent.$refs.tableList
  218. // this.anjuanData = res.list.content
  219. this.anjuanData = res.list.content.map(item => {
  220. return {
  221. ...item,
  222. baseCategory: baseCategory
  223. }
  224. })
  225. this.page.total = res.list.totalElements
  226. this.yearData = res.yearGroup
  227. if (this.yearData && type !== 'quickFilter') {
  228. this.$parent.$parent.$emit('myYearEvent', this.yearData)
  229. }
  230. if (type === 'search') {
  231. // wjObj.anjuanData = res.list.content
  232. wjObj.anjuanData = res.list.content.map(item => {
  233. return {
  234. ...item,
  235. baseCategory: baseCategory
  236. }
  237. })
  238. wjObj.currentPage = this.page.page + 1
  239. // wjObj.page.page = 0
  240. // wjObj.page.size = 10
  241. wjObj.page.total = res.list.totalElements
  242. wjObj.getTableDisplayFieldsLoading = false
  243. }
  244. } else {
  245. // 卷内
  246. // this.junneiData = res.list.content
  247. this.junneiData = res.list.content.map(item => {
  248. return {
  249. ...item,
  250. baseCategory: baseCategory
  251. }
  252. })
  253. this.page.total = res.list.totalElements
  254. if (type === 'search') {
  255. // this.parentsData.$refs.juanneiEle.junneiData = res.list.content
  256. this.parentsData.$refs.juanneiEle.junneiData = res.list.content.map(item => {
  257. return {
  258. ...item,
  259. baseCategory: baseCategory
  260. }
  261. })
  262. this.parentsData.$refs.juanneiEle.currentPage = this.page.page + 1
  263. // this.parentsData.$refs.juanneiEle.page.page = 1
  264. // this.parentsData.$refs.juanneiEle.page.size = 10
  265. this.parentsData.$refs.juanneiEle.page.total = res.list.totalElements
  266. this.parentsData.$refs.juanneiEle.getTableDisplayFieldsLoading = false
  267. }
  268. }
  269. } else {
  270. // 原文
  271. // this.fileData = res.list.content
  272. this.fileData = res.list.content.map(item => {
  273. return {
  274. ...item,
  275. baseCategory: baseCategory
  276. }
  277. })
  278. this.page.total = res.list.totalElements
  279. if (type === 'search') {
  280. // this.parentsData.$refs.fileEle.fileData = res.list.content
  281. this.parentsData.$refs.fileEle.fileData = res.list.content.map(item => {
  282. return {
  283. ...item,
  284. baseCategory: baseCategory
  285. }
  286. })
  287. this.parentsData.$refs.fileEle.currentPage = this.page.page + 1
  288. // this.parentsData.$refs.fileEle.page.page = 1
  289. // this.parentsData.$refs.fileEle.page.size = 10
  290. this.parentsData.$refs.fileEle.page.total = res.list.totalElements
  291. this.parentsData.$refs.fileEle.getTableDisplayFieldsLoading = false
  292. }
  293. }
  294. }
  295. this.getTableDisplayFieldsLoading = false
  296. this.crud.selections = []
  297. if (categoryLevel === 3) {
  298. // 按件
  299. if (this.isTitleType === 3) {
  300. const wjObj = this.parentsData.$refs.anjuanEle.$refs.ajContent.$refs.tableList
  301. wjObj.selections = []
  302. wjObj.$refs.table.clearSelection() // 清空选中
  303. wjObj.$refs.table.setCurrentRow(-1) // 清除高亮
  304. } else {
  305. const juanneiObj = this.parentsData.$refs.juanneiEle
  306. juanneiObj.selections = []
  307. juanneiObj.$refs.table.clearSelection()
  308. juanneiObj.$refs.table.setCurrentRow(-1)
  309. }
  310. } else if (categoryLevel === 2) {
  311. // 按卷
  312. const anjuanObj = this.parentsData.$refs.anjuanEle.$refs.ajContent.$refs.tableList
  313. anjuanObj.selections = []
  314. anjuanObj.$refs.table.clearSelection()
  315. anjuanObj.$refs.table.setCurrentRow(-1)
  316. } else if (categoryLevel === 1) {
  317. // 项目
  318. const projectObj = this.parentsData.$refs.projectEle
  319. projectObj.selections = []
  320. projectObj.$refs.table.clearSelection()
  321. projectObj.$refs.table.setCurrentRow(-1)
  322. } else {
  323. const fileObj = this.parentsData.$refs.fileEle
  324. fileObj.selections = []
  325. fileObj.$refs.table.clearSelection()
  326. fileObj.$refs.table.setCurrentRow(-1)
  327. }
  328. })
  329. },
  330. // 项目级别 - 阶段分类
  331. getDictsList(type) {
  332. FetchDictionaryTree().then((res) => {
  333. const filterCodes = ['project_class']
  334. let filteredItems = JSON.parse(JSON.stringify(res)).filter(item => filterCodes.includes(item.dictionaryCode))
  335. filteredItems = this.addLevelToDictionaryList(filteredItems, 1)
  336. if (type === 1) {
  337. let fiterData = []
  338. fiterData = filteredItems.flatMap(item => {
  339. const level2Childs = item.childDictionarys.filter(child => {
  340. return child.dictionaryParents === item.id && child.level === 2
  341. })
  342. return level2Childs
  343. })
  344. if (this.parentsData.parentsProjectRow) {
  345. console.log(this.parentsData.parentsProjectRow.project_class)
  346. const anjuanObj = this.parentsData.$refs.anjuanEle.$refs.ajContent.$refs.tableList
  347. anjuanObj.$refs.collectHeaderRef.projectOptions = []
  348. if (this.parentsData.parentsProjectRow.project_class !== '') {
  349. const findDic = fiterData.find(item => item.dictionaryName === this.parentsData.parentsProjectRow.project_class)
  350. anjuanObj.$refs.collectHeaderRef.projectOptions.push(findDic)
  351. } else {
  352. console.log(fiterData)
  353. anjuanObj.$refs.collectHeaderRef.projectOptions = fiterData
  354. }
  355. }
  356. } else {
  357. if (this.selectedCategory.arrangeType === 3) {
  358. const projectObj = this.$refs.projectEle
  359. // this.projectOptions = this.filterData(filteredItems, filteredItems[0].id)
  360. projectObj.$refs.collectHeaderRef.projectOptions = filteredItems.flatMap(item => {
  361. const level2Childs = item.childDictionarys.filter(child => {
  362. return child.dictionaryParents === item.id && child.level === 2
  363. })
  364. // 将满足条件的子项目的childDictionarys设置为空数组,因为项目页不需要
  365. level2Childs.forEach(child => {
  366. child.childDictionarys = []
  367. })
  368. return level2Childs
  369. })
  370. }
  371. }
  372. }).catch(err => {
  373. console.log(err)
  374. })
  375. },
  376. // 显示第一级和第二级
  377. // filterData(data, targetId) {
  378. // return data.filter(item => {
  379. // if (item.id === targetId || item.dictionaryParents === targetId) {
  380. // if (item.childDictionarys && item.childDictionarys.length > 0) {
  381. // item.childDictionarys = this.filterData(item.childDictionarys, targetId)
  382. // }
  383. // return true
  384. // }
  385. // return false
  386. // })
  387. // },
  388. // 给筛选出来的数据加level 方便后面是否可点击
  389. addLevelToDictionaryList(dictionaryList, level) {
  390. dictionaryList.forEach(dictionary => {
  391. dictionary.level = level
  392. if (dictionary.childDictionarys) {
  393. dictionary.childDictionarys = this.addLevelToDictionaryList(dictionary.childDictionarys, level + 1)
  394. }
  395. })
  396. return dictionaryList
  397. },
  398. normalizerProject(node) {
  399. if ((node.childDictionarys && !node.childDictionarys.length) || node.childDictionarys === null) {
  400. delete node.childDictionarys
  401. }
  402. return {
  403. id: node.dictionaryName,
  404. label: `${node.dictionaryName} - ${node.dictionaryCode}`,
  405. children: node.childDictionarys,
  406. isDisabled: this.isTitleType === 3 ? node.level !== 3 : node.level === 1
  407. }
  408. },
  409. /* 重新渲染table组件 防止table-fixed 错位 配合watch-table数据 */
  410. doLayout() {
  411. this.$nextTick(() => {
  412. this.$refs.table.doLayout()
  413. })
  414. }
  415. }
  416. }