黄陂项目
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.

288 lines
8.0 KiB

2 weeks ago
6 days ago
2 weeks ago
6 days ago
2 weeks ago
6 days ago
2 weeks ago
6 days ago
2 weeks ago
6 days ago
2 weeks ago
6 days ago
2 weeks ago
6 days ago
6 days ago
2 weeks ago
  1. import { FetchInitBorrowerNumStatistics, FetchInitArchivesTypeNum, FetchInitArchivesTypeStatistics, FetchStorageStatistics, FetchInitArchivesSearchRanking, FetchInitAddArchivesStatistics } from '@/api/archivesManage/statistics'
  2. // import qs from 'qs'
  3. export const statisticsCrud = {
  4. // 组件共用属性
  5. data() {
  6. return {
  7. cateDate: '',
  8. typeDate: '',
  9. inOutStorageDate: '',
  10. arcSearchDate: '',
  11. arcAddDate: '',
  12. pickerOptions: {
  13. disabledDate(time) {
  14. return time.getTime() > Date.now() - 8.64e6
  15. }
  16. },
  17. lendData: [],
  18. cateData: [],
  19. typeData: [],
  20. storageData: {
  21. storageMonths: [],
  22. inStorageData: [],
  23. outStorageData: []
  24. },
  25. searchAcrivesData: {
  26. searchName: [],
  27. searchValue: []
  28. },
  29. addArcivesData: {
  30. addArcivesMonth: [],
  31. addArcivesNum: []
  32. },
  33. numTop: '10',
  34. options: [{
  35. value: '10',
  36. label: '10'
  37. }, {
  38. value: '20',
  39. label: '20'
  40. }, {
  41. value: '30',
  42. label: '30'
  43. }, {
  44. value: '40',
  45. label: '40'
  46. }, {
  47. value: '50',
  48. label: '50'
  49. }]
  50. }
  51. },
  52. // 组件挂载时的共用方法
  53. mounted() {
  54. this.getBorrowerNumSta()
  55. this.getArchivesTypeNum()
  56. this.getArchivesTypeStatistics()
  57. this.getStorageStatistics()
  58. this.getArchivesSearchRanking()
  59. this.getAddArchivesStatistics()
  60. },
  61. // 组件共用方法
  62. methods: {
  63. // 档案借阅统计
  64. // getBorrowerNumSta() {
  65. // FetchInitBorrowerNumStatistics().then(res => {
  66. // if (res) {
  67. // delete res.total
  68. // // 固定排序 '在库档案', '已借档案', '待借档案', '逾期档案', '异常档案'
  69. // const borrowerArr = []
  70. // for (const i in res) {
  71. // const obj = {}
  72. // obj.name = i
  73. // obj.value = res[i]
  74. // if (i === 'inStorage') {
  75. // obj.sequence = 1
  76. // } else if (i === 'borrow') {
  77. // obj.sequence = 2
  78. // } else if (i === 'waitBorrow') {
  79. // obj.sequence = 3
  80. // } else if (i === 'overdue') {
  81. // obj.sequence = 4
  82. // } else if (i === 'abnormal') {
  83. // obj.sequence = 5
  84. // }
  85. // borrowerArr.push(obj)
  86. // }
  87. // this.arrSortByKey(borrowerArr, 'sequence', false)
  88. // borrowerArr.forEach(item => {
  89. // this.lendData.push(item.value)
  90. // console.log(this.lendData)
  91. // })
  92. // }
  93. // })
  94. // },
  95. getBorrowerNumSta() {
  96. FetchInitBorrowerNumStatistics().then(res => {
  97. if (res) {
  98. delete res.total
  99. // 新的固定排序: '逾期档案', '已借档案', '在库档案'
  100. const borrowerArr = []
  101. for (const i in res) {
  102. const obj = {}
  103. obj.name = i
  104. obj.value = res[i]
  105. // 重新定义排序序号
  106. if (i === 'overdue') { // 逾期档案 - 第1位
  107. obj.sequence = 1
  108. } else if (i === 'borrow') { // 已借档案 - 第2位
  109. obj.sequence = 2
  110. } else if (i === 'inStorage') { // 在库档案 - 第3位
  111. obj.sequence = 3
  112. }
  113. // 只添加需要的三类数据,过滤掉待借、异常档案
  114. if (obj.sequence) {
  115. borrowerArr.push(obj)
  116. }
  117. }
  118. // 按sequence排序
  119. this.arrSortByKey(borrowerArr, 'sequence', true)
  120. // 清空原有数据(避免多次调用累加)
  121. this.lendData = []
  122. borrowerArr.forEach(item => {
  123. this.lendData.push(item.value)
  124. })
  125. }
  126. })
  127. },
  128. // 档案类别 - 年选择
  129. handleCateDate() {
  130. this.cateData = []
  131. this.getArchivesTypeNum()
  132. },
  133. // 档案类别
  134. getArchivesTypeNum() {
  135. let params
  136. if (this.cateDate) {
  137. params = {
  138. 'year': this.cateDate
  139. }
  140. } else {
  141. params = {
  142. 'year': null
  143. }
  144. }
  145. FetchInitArchivesTypeNum(params).then(res => {
  146. if (res) {
  147. for (const i in res) {
  148. this.cateData.push(res[i])
  149. }
  150. }
  151. })
  152. },
  153. // 档案类型 - 月选择
  154. handleTypeDate() {
  155. this.typeData = []
  156. this.getArchivesTypeStatistics()
  157. },
  158. // 档案类型
  159. getArchivesTypeStatistics() {
  160. let params
  161. if (this.typeDate) {
  162. params = {
  163. 'yearMonth': this.typeDate
  164. }
  165. } else {
  166. params = {
  167. 'yearMonth': null
  168. }
  169. }
  170. FetchInitArchivesTypeStatistics(params).then(res => {
  171. if (res) {
  172. res.map(item => {
  173. const obj = {}
  174. obj.name = item.archivesType
  175. obj.value = item.archivesNum
  176. this.typeData.push(obj)
  177. })
  178. }
  179. })
  180. },
  181. // 档案类别 - 年选择
  182. handleStorageDate() {
  183. this.getStorageStatistics()
  184. },
  185. // 出入库管理情况
  186. getStorageStatistics() {
  187. let params
  188. let getYear
  189. if (this.inOutStorageDate) {
  190. params = {
  191. 'year': this.inOutStorageDate
  192. }
  193. getYear = this.inOutStorageDate
  194. } else {
  195. params = {
  196. 'year': null
  197. }
  198. getYear = new Date().getFullYear()
  199. }
  200. FetchStorageStatistics(params).then(res => {
  201. if (res) {
  202. this.storageData.storageMonths = []
  203. res.months.forEach(item => {
  204. this.storageData.storageMonths.push(getYear + '/' + item)
  205. })
  206. this.storageData.inStorageData = res.inStorage
  207. this.storageData.outStorageData = res.outStorage
  208. }
  209. })
  210. },
  211. handleSearchDate() {
  212. this.getArchivesSearchRanking()
  213. },
  214. selectNumTop(val) {
  215. this.numTop = val
  216. this.searchAcrivesData = {
  217. searchName: [],
  218. searchValue: []
  219. }
  220. this.getArchivesSearchRanking()
  221. },
  222. // 档案检索排名
  223. getArchivesSearchRanking() {
  224. let params
  225. if (this.arcSearchDate) {
  226. params = {
  227. 'yearMonth': this.arcSearchDate,
  228. 'top': this.numTop
  229. }
  230. } else {
  231. params = {
  232. 'yearMonth': null,
  233. 'top': this.numTop
  234. }
  235. }
  236. FetchInitArchivesSearchRanking(params).then(res => {
  237. if (res) {
  238. this.arrSortByKey(res, 'num', true)
  239. this.searchAcrivesData.searchName = res.map(item => item.cnName)
  240. this.searchAcrivesData.searchValue = res.map(item => item.num)
  241. }
  242. })
  243. },
  244. handleArcAddSta() {
  245. this.getAddArchivesStatistics()
  246. },
  247. // 档案实际情况
  248. getAddArchivesStatistics() {
  249. let params
  250. let getYear
  251. if (this.arcAddDate) {
  252. params = {
  253. 'year': this.arcAddDate
  254. }
  255. getYear = this.arcAddDate
  256. } else {
  257. params = {
  258. 'year': null
  259. }
  260. getYear = new Date().getFullYear()
  261. }
  262. FetchInitAddArchivesStatistics(params).then(res => {
  263. if (res) {
  264. this.addArcivesData.addArcivesMonth = []
  265. res.months.forEach(item => {
  266. this.addArcivesData.addArcivesMonth.push(getYear + '/' + item)
  267. })
  268. this.addArcivesData.addArcivesNum = res.nums
  269. }
  270. })
  271. },
  272. // array: 需要进行排序的数组
  273. // key: 根据某个属性进行排序
  274. // order: 升序/降序 true:升序 false:降序
  275. arrSortByKey(array, property, order) {
  276. return array.sort(function(a, b) {
  277. const value1 = a[property]
  278. const value2 = b[property]
  279. if (order) { // 升序
  280. return value1 - value2
  281. } else { // 降序
  282. return value2 - value1
  283. }
  284. })
  285. }
  286. }
  287. }