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

411 lines
14 KiB

2 months ago
2 months ago
1 month ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
  1. import qs from 'qs'
  2. import { exportFile } from '@/utils/index'
  3. import JsBarcode from 'jsbarcode'
  4. import { FetchTableDisplayFields, FetchInitArchivesView, FetchFormDisplayFields, FetchPrintArchivesBarcode } from '@/api/archivesManage/archivesList'
  5. export const archivesCrud = {
  6. filters: {
  7. creatBarCode(barCodeData, codePrintData, barCodeText) {
  8. // console.log('触发条码生成事件')
  9. console.log('codePrintData', codePrintData)
  10. console.log('barCodeText', barCodeText)
  11. const canvas = document.createElement('canvas')
  12. // 'fantasy', // 设置文本的字体
  13. JsBarcode(canvas, barCodeData, {
  14. format: 'CODE128',
  15. displayValue: true,
  16. text: barCodeText,
  17. fontOptions: 'bold', // 使文字加粗体或变斜体
  18. font: 'arial',
  19. margin: 15,
  20. height: 120,
  21. width: 5,
  22. fontSize: 36,
  23. textMargin: 6,
  24. textPosition: 'top'
  25. })
  26. return canvas.toDataURL('image/png')
  27. }
  28. },
  29. // 组件共用属性
  30. data() {
  31. return {
  32. permission: {
  33. add: [],
  34. edit: [],
  35. del: [],
  36. download: []
  37. },
  38. page: {
  39. page: 1,
  40. size: 10,
  41. total: 0
  42. },
  43. codeLoading: false,
  44. selectedRows: [],
  45. codePrintData: [],
  46. storageTxt: [],
  47. borrowTxt: [],
  48. tableDisplayFields: [], // table-list-title字段
  49. getTableDisplayFieldsLoading: false, // table-loading
  50. projectTableHeight: null,
  51. anjuanTableHeight: null,
  52. juanneiTableHeight: null,
  53. formVisible: false,
  54. formTitle: '新建档案',
  55. formPreviewData: [], // 预览界面data
  56. totalSumAll: 0, // 删除时,内部文件数据求和
  57. arrySort: [], // 多项sort-query
  58. selections: [], // table已选择的
  59. categoryId: null, // 上传附件使用
  60. parentsId: null, // 父id
  61. arcId: null, // 档案ID
  62. yearGroup: [], // 智能分类 - 年度
  63. uploadFileVisible: false, // 上传附件
  64. isDesFormType: null // 区分是门类得还是档案得
  65. }
  66. },
  67. // 组件共用方法
  68. methods: {
  69. // 搜索-select
  70. querySelect(name, val) {
  71. this[name] = val
  72. },
  73. rowKey(row) {
  74. return row.id
  75. },
  76. // table选中加上选中状态
  77. tableRowClassName({ row, rowIndex }) {
  78. // console.log('添加类名', row, rowIndex)
  79. let color = ''
  80. this.selections.forEach(item => {
  81. if (item.id === row.id) {
  82. color = 'rowStyle'
  83. }
  84. })
  85. return color
  86. },
  87. // 案卷 / 卷内 / 文件 导出
  88. doExport(type) {
  89. this.crud.downloadLoading = true
  90. if (type === 0 && this.selectedCategory.isType === 2) {
  91. this.parentsId = this.projectSelection.id
  92. } else if (type === 1 && this.selectedCategory.isType === 2) {
  93. this.parentsId = this.anjuanSelection.id
  94. } else {
  95. this.parentsId = null
  96. }
  97. const params = {
  98. 'categoryId': this.categoryId,
  99. 'parentsId': this.parentsId
  100. }
  101. exportFile(this.baseApi + '/api/archives/exportArchives?' + qs.stringify(params))
  102. this.crud.downloadLoading = false
  103. },
  104. // table - 表头项
  105. getTableItemCommon(type) {
  106. if (type === 0) {
  107. this.categoryId = this.selectedCategory.id
  108. } else if (type === 1) {
  109. if (this.selectedCategory.isType === 2) {
  110. if (this.selectedCategory.children.length !== 0) {
  111. this.categoryId = this.selectedCategory.children[0].id
  112. }
  113. } else {
  114. this.categoryId = this.selectedCategory.id
  115. }
  116. } else if (type === 2) {
  117. if (this.selectedCategory.isType === 2) {
  118. if (this.selectedCategory.children.length !== 0) {
  119. if (this.selectedCategory.children[0].children.length !== 0) {
  120. this.categoryId = this.selectedCategory.children[0].children[0].id
  121. }
  122. }
  123. } else if (this.selectedCategory.isType === 3) {
  124. if (this.selectedCategory.children.length !== 0) {
  125. this.categoryId = this.selectedCategory.children[0].id
  126. }
  127. } else {
  128. this.categoryId = this.selectedCategory.id
  129. }
  130. }
  131. this.getTableDisplayFieldsLoading = true
  132. this.selections = []
  133. FetchTableDisplayFields({ categoryId: this.categoryId }).then(data => {
  134. if (data) {
  135. this.arrySort = []
  136. this.tableDisplayFields = data
  137. this.getTableDisplayFieldsLoading = false
  138. const orderSortArry = this.tableDisplayFields.filter(item => item.queue).sort((a, b) => a.queue - b.queue)
  139. orderSortArry.forEach(item => {
  140. this.arrySort.push(item.fieldName + ',' + item.displayOrderBy)
  141. })
  142. }
  143. })
  144. },
  145. handleCurrentPage(val) {
  146. this.page.page = val
  147. // console.log(this.$refs.table.selection)
  148. this.getTableList()
  149. this.$nextTick(() => {
  150. this.selections = this.$refs.table.selection
  151. })
  152. },
  153. // table - list
  154. getListCommon(name, heightName, type) {
  155. if (type === 0) {
  156. this.parentsId = null
  157. } else if (type === 1) {
  158. if (this.selectedCategory.isType === 3 || this.selectedCategory.isType === 5) {
  159. this.parentsId = null
  160. } else {
  161. this.parentsId = this.projectSelection.id
  162. }
  163. } else if (type === 2) {
  164. if (this.selectedCategory.isType !== 4) {
  165. this.parentsId = this.anjuanSelection.id
  166. } else {
  167. this.parentsId = null
  168. }
  169. }
  170. if (this.categoryId !== null) { // 防止项目下无案卷门类情况
  171. this.selections = []
  172. // this.page.page = isNaN(this.page.page - 1) ? 0 : this.page.page - 1
  173. this.formVisible = false
  174. this.getTableDisplayFieldsLoading = true
  175. const params = {
  176. 'categoryId': this.categoryId,
  177. 'parentsId': this.parentsId,
  178. 'isdel': this.recycleMain.isdel,
  179. 'page': this.page.page - 1,
  180. 'size': this.page.size,
  181. 'sort': this.arrySort,
  182. 'queryType': this.query.queryType,
  183. 'queryTitle': this.query.queryTitle,
  184. 'nativePlace': this.query.nativePlace,
  185. 'idType': this.query.idType,
  186. 'idNumber': this.query.idNumber,
  187. 'itemNo': this.query.itemNo,
  188. 'archiveCtgNo': this.query.archiveCtgNo,
  189. 'responsibleby': this.query.responsibleby,
  190. 'archiveNo': this.query.archiveNo,
  191. 'archiveYear': this.smartQuery.archiveYear,
  192. 'department': this.smartQuery.department,
  193. 'retention': this.smartQuery.retention,
  194. 'securityClass': this.smartQuery.securityClass,
  195. 'organizationMatter': this.smartQuery.organizationMatter,
  196. 'fondsNo': this.smartQuery.fondsNo,
  197. 'recordType': this.smartQuery.recordType,
  198. 'mediumType': this.smartQuery.mediumType,
  199. 'documentNo': this.query.documentNo,
  200. 'docNo': this.query.docNo,
  201. 'barcode': this.query.barcode,
  202. 'folderLocation': this.query.folderLocation,
  203. 'tempNo': this.query.tempNo
  204. }
  205. FetchInitArchivesView(params).then(data => {
  206. this.getTableDisplayFieldsLoading = false
  207. if (data) {
  208. this[name] = data.list.content
  209. this.yearGroup = data.yearGroup
  210. this.page.total = data.list.totalElements
  211. // 自适应高度
  212. if (this[name].length === 0 || this[name].length < 10) {
  213. this[heightName] = `calc(100vh - 344px)`
  214. } else {
  215. const h = '100vh'
  216. // this[heightName] = `calc(${h} - 434px)`
  217. this[heightName] = `calc(${h} - 344px)`
  218. }
  219. if (name === 'anjuanData' || name === 'junneiData') {
  220. this[name].forEach((item, index) => {
  221. // 入库状态
  222. if (item.is_storage === 0) {
  223. this.storageTxt[index] = '未入'
  224. if (item.is_borrow === '') {
  225. this.borrowTxt[index] = '-'
  226. }
  227. } else if (item.is_storage === 1) {
  228. this.storageTxt[index] = '待入'
  229. if (item.is_borrow === '') {
  230. this.borrowTxt[index] = '-'
  231. }
  232. } else if (item.is_storage === 2) {
  233. this.storageTxt[index] = '已入'
  234. if (item.is_borrow === '') {
  235. this.borrowTxt[index] = '在库'
  236. }
  237. } else if (item.is_storage === 3) {
  238. this.storageTxt[index] = '待出'
  239. if (item.is_borrow === '') {
  240. this.borrowTxt[index] = '-'
  241. }
  242. } else if (item.is_storage === '') {
  243. this.storageTxt[index] = '未入'
  244. if (item.is_borrow === '') {
  245. this.borrowTxt[index] = '-'
  246. }
  247. }
  248. // 借阅状态
  249. if (item.is_borrow === 1) {
  250. this.borrowTxt[index] = '待借'
  251. } else if (item.is_borrow === 2) {
  252. this.borrowTxt[index] = '待借'
  253. } else if (item.is_borrow === 3) {
  254. this.borrowTxt[index] = '已借'
  255. } else if (item.is_borrow === -1) {
  256. this.borrowTxt[index] = '在库'
  257. }
  258. })
  259. }
  260. }
  261. })
  262. }
  263. },
  264. // 著录界面-form/详情-api
  265. handleForm(type, title, isAnOrJuan) {
  266. if (type === 'add') {
  267. this.formTitle = '新增' + title
  268. this.arcId = null
  269. // this.parentsId = this[name].id //案卷和卷内有 不确定
  270. } else if (type === 'edit') {
  271. this.arcId = this.selections[0].id
  272. this.formTitle = '编辑' + title
  273. }
  274. this.formVisible = true
  275. this.form.dictionaryConfigId = {}
  276. this.formPreviewData = []
  277. // 档案预编辑获取字段
  278. const params = {
  279. categoryId: this.categoryId,
  280. archivesId: this.arcId
  281. }
  282. this.getFormInfo(params, type, isAnOrJuan)
  283. },
  284. getFormInfo(params, type, isAnOrJuan) {
  285. FetchFormDisplayFields(params).then(data => {
  286. this.formPreviewData = data.showFiled
  287. this.$nextTick(() => {
  288. if (type === 'edit') {
  289. this.$refs.previewForm.addOrUpdateForm = data.echo
  290. this.$refs.previewForm.isEdit = true
  291. } else {
  292. this.$refs.previewForm.isEdit = false
  293. if (this.recycleMain.selectedCategory.isType !== 5) {
  294. // 新增时拿到项目和案卷的相同的字段的值
  295. this.formPreviewData.forEach(item => {
  296. if (isAnOrJuan === 1) {
  297. if (this.recycleMain.selectedCategory.isType !== 3) {
  298. if (this.recycleMain.projectSelection[item.fieldName]) {
  299. this.$refs.previewForm.addOrUpdateForm = JSON.parse(JSON.stringify(this.recycleMain.projectSelection))
  300. }
  301. }
  302. } else if (isAnOrJuan === 2) {
  303. if (this.recycleMain.anjuanSelection[item.fieldName]) {
  304. this.$refs.previewForm.addOrUpdateForm = JSON.parse(JSON.stringify(this.recycleMain.anjuanSelection))
  305. }
  306. }
  307. })
  308. }
  309. }
  310. this.isDesFormType = 'arcives'
  311. this.$refs.previewForm.FetchNoFormatField(this.categoryId)
  312. })
  313. })
  314. },
  315. // form - submit
  316. handlerArchivesSubmit() {
  317. this.$refs.previewForm.submitForm('addOrUpdateForm', this.categoryId)
  318. this.selections = []
  319. },
  320. // 选择删除
  321. toDelete(data) {
  322. // 已装盒的档案不可删除
  323. // const indexCaseBool = data.findIndex(item => item.case_no !== '')
  324. // if (indexCaseBool !== -1) {
  325. // this.$message.error('已装盒的档案不可删除!')
  326. // } else {
  327. // this.$refs.deltArchives.deleteVisible = true
  328. // this.getTotalSumAll()
  329. // }
  330. this.$refs.deltArchives.deleteVisible = true
  331. this.getTotalSumAll()
  332. },
  333. getTotalSumAll(data) {
  334. this.totalSumAll = 0
  335. this.selections.map((item) => { if (!isNaN(item.children_num)) this.totalSumAll += item.children_num })
  336. if (isNaN(this.totalSumAll)) {
  337. return 0
  338. }
  339. return this.totalSumAll
  340. },
  341. // 打印条码
  342. printArchivesCode(data) {
  343. this.codeLoading = true
  344. const params = data.map(item => {
  345. return item.id
  346. })
  347. FetchPrintArchivesBarcode(params).then(res => {
  348. if (res && res.length !== 0) {
  349. this.selectedRows = res
  350. } else {
  351. this.selectedRows = []
  352. this.$message({
  353. message: '无相关可打印条码数据!',
  354. type: 'warning'
  355. })
  356. return false
  357. }
  358. this.$nextTick(() => {
  359. this.codePrintData.count = this.selectedRows.length
  360. var printIframe = this.$refs.printIframe
  361. var html = this.$refs.printDiv.innerHTML
  362. printIframe.setAttribute('srcdoc', html)
  363. printIframe.onload = function() {
  364. console.log(printIframe.contentWindow)
  365. // 去掉iframe里面的dom的body的padding margin的默认数值
  366. printIframe.contentWindow.document.body.style.padding = '0px'
  367. printIframe.contentWindow.document.body.style.margin = '0px'
  368. // 开始打印
  369. printIframe.contentWindow.focus()
  370. printIframe.contentWindow.print()
  371. }
  372. })
  373. // this.crud.refresh()
  374. this.codeLoading = false
  375. })
  376. },
  377. // 删除 - 关闭
  378. handleClose(done) {
  379. this.formVisible = false
  380. done()
  381. },
  382. /* 重新渲染table组件 防止table-fixed 错位 配合watch-table数据 */
  383. doLayout() {
  384. this.$nextTick(() => {
  385. this.$refs.table.doLayout()
  386. })
  387. },
  388. // 上传附件
  389. uploadFile() {
  390. this.uploadFileVisible = true
  391. this.arcId = this.selections[0].id
  392. this.$nextTick(() => {
  393. this.$refs.uploadFile.tableData = []
  394. this.$refs.uploadFile.getFileList()
  395. })
  396. },
  397. // 还原
  398. handleRestore() {
  399. this.$refs.restore.restoreVisible = true
  400. }
  401. },
  402. // 组件挂载时的共用方法
  403. mounted() {
  404. }
  405. }