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

238 lines
7.6 KiB

  1. import qs from 'qs'
  2. import { exportFile } from '@/utils/index'
  3. import { FetchTableDisplayFields, FetchInitArchivesView, FetchFormDisplayFields } from '@/api/archivesManage/archivesList'
  4. export const common = {
  5. // 组件共用属性
  6. data() {
  7. return {
  8. permission: {
  9. add: ['admin', 'archivesList:add'],
  10. edit: ['admin', 'archivesList:edit'],
  11. del: ['admin', 'archivesList:del'],
  12. download: ['admin', 'archivesList:download']
  13. },
  14. page: {
  15. page: 0,
  16. size: 10,
  17. total: 0
  18. },
  19. query: {
  20. 'queryType': null,
  21. 'queryTitle': null,
  22. 'recordNo': null,
  23. 'archiveCtgNo': null,
  24. 'archiveNo': null,
  25. 'responsibleby': null
  26. },
  27. stateOptions: [ // 搜索 - 状态选择
  28. { key: '1', label: '全部' },
  29. { key: '2', label: '未装' },
  30. { key: '3', label: '未入' },
  31. { key: '4', label: '在库' },
  32. { key: '5', label: '待借' },
  33. { key: '6', label: '已借' }
  34. ],
  35. tableDisplayFields: [], // table-list-title字段
  36. getTableDisplayFieldsLoading: false, // table-loading
  37. formVisible: false,
  38. formTitle: '新建档案',
  39. formPreviewData: [], // 预览界面data
  40. totalSumAll: 0, // 删除时,内部文件数据求和
  41. arrySort: [], // 多项sort-query
  42. selections: [], // table已选择的
  43. categoryId: null, // 上传附件使用
  44. parentsId: null, // 父id
  45. arcId: null, // 档案ID
  46. yearGroup: [], // 智能分类 - 年度
  47. uploadFileVisible: false // 上传附件
  48. }
  49. },
  50. // 组件共用方法
  51. methods: {
  52. // 搜索-select
  53. querySelect(name, val) {
  54. this[name] = val
  55. },
  56. // 案卷 / 卷内 / 文件 导出
  57. doExport(type) {
  58. this.crud.downloadLoading = true
  59. if (type === 0 && this.selectedCategory.isType === 2) {
  60. this.parentsId = this.projectSelection.id
  61. } else if (type === 1 && this.selectedCategory.isType === 2) {
  62. this.parentsId = this.anjuanSelection.id
  63. } else {
  64. this.parentsId = null
  65. }
  66. const params = {
  67. 'categoryId': this.categoryId,
  68. 'parentsId': this.parentsId
  69. }
  70. exportFile(this.baseApi + '/api/archives/exportArchives?' + qs.stringify(params))
  71. this.crud.downloadLoading = false
  72. },
  73. // table - 表头项
  74. getTableItemCommon(type) {
  75. if (type === 0) {
  76. this.categoryId = this.selectedCategory.id
  77. } else if (type === 1) {
  78. if (this.selectedCategory.isType === 2) {
  79. if (this.selectedCategory.children.length !== 0) {
  80. this.categoryId = this.selectedCategory.children[0].id
  81. }
  82. } else {
  83. this.categoryId = this.selectedCategory.id
  84. }
  85. } else if (type === 2) {
  86. if (this.selectedCategory.isType === 2) {
  87. if (this.selectedCategory.children.length !== 0) {
  88. this.categoryId = this.selectedCategory.children[0].children[0].id
  89. }
  90. } else if (this.selectedCategory.isType === 3) {
  91. if (this.selectedCategory.children.length !== 0) {
  92. this.categoryId = this.selectedCategory.children[0].id
  93. }
  94. } else {
  95. this.categoryId = this.selectedCategory.id
  96. }
  97. }
  98. this.getTableDisplayFieldsLoading = true
  99. this.selections = []
  100. FetchTableDisplayFields({ categoryId: this.categoryId }).then(data => {
  101. if (data) {
  102. this.arrySort = []
  103. this.tableDisplayFields = data
  104. this.getTableDisplayFieldsLoading = false
  105. const orderSortArry = this.tableDisplayFields.filter(item => item.queue).sort((a, b) => a.queue - b.queue)
  106. orderSortArry.forEach(item => {
  107. this.arrySort.push(item.fieldName + ',' + item.displayOrderBy)
  108. })
  109. }
  110. })
  111. },
  112. // table - list
  113. getListCommon(name, page, type) {
  114. if (type === 0) {
  115. this.parentsId = null
  116. } else if (type === 1) {
  117. if (this.selectedCategory.isType === 3 || this.selectedCategory.isType === 5) {
  118. this.parentsId = null
  119. } else {
  120. this.parentsId = this.projectSelection.id
  121. }
  122. } else if (type === 2) {
  123. if (this.selectedCategory.isType !== 4) {
  124. this.parentsId = this.anjuanSelection.id
  125. } else {
  126. this.parentsId = null
  127. }
  128. }
  129. this.selections = []
  130. this.page.page = isNaN(page - 1) ? 0 : page - 1
  131. this.formVisible = false
  132. this.getTableDisplayFieldsLoading = true
  133. const params = {
  134. 'categoryId': this.categoryId,
  135. 'parentsId': this.parentsId,
  136. 'isdel': this.recycleMain.isdel,
  137. 'page': this.page.page,
  138. 'size': this.page.size,
  139. 'sort': this.arrySort,
  140. 'queryType': this.query.queryType,
  141. 'queryTitle': this.query.queryTitle,
  142. 'recordNo': this.query.recordNo,
  143. 'archiveCtgNo': this.query.archiveCtgNo,
  144. 'responsibleby': this.query.responsibleby,
  145. 'archiveNo': this.query.archiveNo,
  146. 'archiveYear': this.smartQuery.archiveYear,
  147. 'department': this.smartQuery.department,
  148. 'retention': this.smartQuery.retention,
  149. 'securityClass': this.smartQuery.securityClass,
  150. 'organizationMatter': this.smartQuery.organizationMatter
  151. }
  152. FetchInitArchivesView(params).then(data => {
  153. this.getTableDisplayFieldsLoading = false
  154. if (data) {
  155. this[name] = data.list.content
  156. this.yearGroup = data.yearGroup
  157. this.page.total = data.list.totalElements
  158. }
  159. })
  160. },
  161. // 著录界面-form/详情-api
  162. handleForm(type, title) {
  163. if (type === 'add') {
  164. this.formTitle = '新增' + title
  165. this.arcId = null
  166. // this.parentsId = this[name].id //案卷和卷内有 不确定
  167. } else if (type === 'edit') {
  168. this.arcId = this.selections[0].id
  169. this.formTitle = '编辑' + title
  170. }
  171. this.formVisible = true
  172. this.form.dictionaryConfigId = {}
  173. this.formPreviewData = []
  174. // 档案预编辑获取字段
  175. const params = {
  176. categoryId: this.categoryId,
  177. archivesId: this.arcId
  178. }
  179. this.getFormInfo(params, type)
  180. },
  181. getFormInfo(params, type) {
  182. FetchFormDisplayFields(params).then(data => {
  183. this.formPreviewData = data.showFiled
  184. this.$nextTick(() => {
  185. if (type === 'edit') {
  186. this.$refs.previewForm.addOrUpdateForm = data.echo
  187. }
  188. })
  189. })
  190. },
  191. // form - submit
  192. handlerArchivesSubmit() {
  193. this.$refs.previewForm.submitForm('addOrUpdateForm', this.categoryId)
  194. this.selections = []
  195. },
  196. // 选择删除
  197. toDelete(data) {
  198. this.$refs.deltArchives.deleteVisible = true
  199. this.getTotalSumAll()
  200. },
  201. getTotalSumAll() {
  202. this.totalSumAll = 0
  203. this.selections.map((item) => { if (!isNaN(item.children_num)) this.totalSumAll += item.children_num })
  204. if (isNaN(this.totalSumAll)) {
  205. return 0
  206. }
  207. return this.totalSumAll
  208. },
  209. // 删除 - 关闭
  210. handleClose(done) {
  211. this.formVisible = false
  212. done()
  213. },
  214. /* 重新渲染table组件 防止table-fixed 错位 配合watch-table数据 */
  215. doLayout() {
  216. this.$nextTick(() => {
  217. this.$refs.table.doLayout()
  218. })
  219. },
  220. // 上传附件
  221. uploadFile() {
  222. this.uploadFileVisible = true
  223. this.arcId = this.selections[0].id
  224. this.$nextTick(() => {
  225. this.$refs.uploadFile.tableData = []
  226. this.$refs.uploadFile.getFileList()
  227. })
  228. },
  229. // 还原
  230. handleRestore() {
  231. this.$refs.restore.restoreVisible = true
  232. }
  233. },
  234. // 组件挂载时的共用方法
  235. mounted() {
  236. }
  237. }