|
|
import qs from 'qs'import { exportFile } from '@/utils/index'import JsBarcode from 'jsbarcode'import { FetchTableDisplayFields, FetchInitArchivesView, FetchFormDisplayFields, FetchPrintArchivesBarcode } from '@/api/archivesManage/archivesList'export const archivesCrud = { filters: { creatBarCode(barCodeData, codePrintData, barCodeText) { // console.log('触发条码生成事件')
console.log('codePrintData', codePrintData) console.log('barCodeText', barCodeText) const canvas = document.createElement('canvas') // 'fantasy', // 设置文本的字体
JsBarcode(canvas, barCodeData, { format: 'CODE128', displayValue: true, text: barCodeText, fontOptions: 'bold', // 使文字加粗体或变斜体
font: 'arial', margin: 15, height: 120, width: 5, fontSize: 36, textMargin: 6, textPosition: 'top' }) return canvas.toDataURL('image/png') } }, // 组件共用属性
data() { return { permission: { add: [], edit: [], del: [], download: [] }, page: { page: 1, size: 10, total: 0 }, codeLoading: false, selectedRows: [], codePrintData: [], storageTxt: [], borrowTxt: [], tableDisplayFields: [], // table-list-title字段
getTableDisplayFieldsLoading: false, // table-loading
projectTableHeight: null, anjuanTableHeight: null, juanneiTableHeight: null, formVisible: false, formTitle: '新建档案', formPreviewData: [], // 预览界面data
totalSumAll: 0, // 删除时,内部文件数据求和
arrySort: [], // 多项sort-query
selections: [], // table已选择的
categoryId: null, // 上传附件使用
parentsId: null, // 父id
arcId: null, // 档案ID
yearGroup: [], // 智能分类 - 年度
uploadFileVisible: false, // 上传附件
isDesFormType: null // 区分是门类得还是档案得
} }, // 组件共用方法
methods: { // 搜索-select
querySelect(name, val) { this[name] = val }, rowKey(row) { return row.id }, // table选中加上选中状态
tableRowClassName({ row, rowIndex }) { // console.log('添加类名', row, rowIndex)
let color = '' this.selections.forEach(item => { if (item.id === row.id) { color = 'rowStyle' } }) return color }, // 案卷 / 卷内 / 文件 导出
doExport(type) { this.crud.downloadLoading = true if (type === 0 && this.selectedCategory.isType === 2) { this.parentsId = this.projectSelection.id } else if (type === 1 && this.selectedCategory.isType === 2) { this.parentsId = this.anjuanSelection.id } else { this.parentsId = null } const params = { 'categoryId': this.categoryId, 'parentsId': this.parentsId } exportFile(this.baseApi + '/api/archives/exportArchives?' + qs.stringify(params)) this.crud.downloadLoading = false }, // table - 表头项
getTableItemCommon(type) { if (type === 0) { this.categoryId = this.selectedCategory.id } else if (type === 1) { if (this.selectedCategory.isType === 2) { if (this.selectedCategory.children.length !== 0) { this.categoryId = this.selectedCategory.children[0].id } } else { this.categoryId = this.selectedCategory.id } } else if (type === 2) { if (this.selectedCategory.isType === 2) { if (this.selectedCategory.children.length !== 0) { if (this.selectedCategory.children[0].children.length !== 0) { this.categoryId = this.selectedCategory.children[0].children[0].id } } } else if (this.selectedCategory.isType === 3) { if (this.selectedCategory.children.length !== 0) { this.categoryId = this.selectedCategory.children[0].id } } else { this.categoryId = this.selectedCategory.id } }
this.getTableDisplayFieldsLoading = true this.selections = [] FetchTableDisplayFields({ categoryId: this.categoryId }).then(data => { if (data) { this.arrySort = [] this.tableDisplayFields = data this.getTableDisplayFieldsLoading = false const orderSortArry = this.tableDisplayFields.filter(item => item.queue).sort((a, b) => a.queue - b.queue) orderSortArry.forEach(item => { this.arrySort.push(item.fieldName + ',' + item.displayOrderBy) }) } }) }, handleCurrentPage(val) { this.page.page = val // console.log(this.$refs.table.selection)
this.getTableList() this.$nextTick(() => { this.selections = this.$refs.table.selection }) }, // table - list
getListCommon(name, heightName, type) { if (type === 0) { this.parentsId = null } else if (type === 1) { if (this.selectedCategory.isType === 3 || this.selectedCategory.isType === 5) { this.parentsId = null } else { this.parentsId = this.projectSelection.id } } else if (type === 2) { if (this.selectedCategory.isType !== 4) { this.parentsId = this.anjuanSelection.id } else { this.parentsId = null } } if (this.categoryId !== null) { // 防止项目下无案卷门类情况
this.selections = [] // this.page.page = isNaN(this.page.page - 1) ? 0 : this.page.page - 1
this.formVisible = false this.getTableDisplayFieldsLoading = true const params = { 'categoryId': this.categoryId, 'parentsId': this.parentsId, 'isdel': this.recycleMain.isdel, 'page': this.page.page - 1, 'size': this.page.size, 'sort': this.arrySort, 'queryType': this.query.queryType, 'queryTitle': this.query.queryTitle, 'nativePlace': this.query.nativePlace, 'idType': this.query.idType, 'idNumber': this.query.idNumber, 'itemNo': this.query.itemNo, 'archiveCtgNo': this.query.archiveCtgNo, 'responsibleby': this.query.responsibleby, 'archiveNo': this.query.archiveNo, 'archiveYear': this.smartQuery.archiveYear, 'department': this.smartQuery.department, 'retention': this.smartQuery.retention, 'securityClass': this.smartQuery.securityClass, 'organizationMatter': this.smartQuery.organizationMatter, 'fondsNo': this.smartQuery.fondsNo, 'recordType': this.smartQuery.recordType, 'mediumType': this.smartQuery.mediumType, 'documentNo': this.query.documentNo, 'docNo': this.query.docNo, 'barcode': this.query.barcode, 'folderLocation': this.query.folderLocation, 'tempNo': this.query.tempNo } FetchInitArchivesView(params).then(data => { this.getTableDisplayFieldsLoading = false if (data) { this[name] = data.list.content this.yearGroup = data.yearGroup this.page.total = data.list.totalElements
// 自适应高度
if (this[name].length === 0 || this[name].length < 10) { this[heightName] = `calc(100vh - 344px)` } else { const h = '100vh' // this[heightName] = `calc(${h} - 434px)`
this[heightName] = `calc(${h} - 344px)` }
if (name === 'anjuanData' || name === 'junneiData') { this[name].forEach((item, index) => { // 入库状态
if (item.is_storage === 0) { this.storageTxt[index] = '未入' if (item.is_borrow === '') { this.borrowTxt[index] = '-' } } else if (item.is_storage === 1) { this.storageTxt[index] = '待入' if (item.is_borrow === '') { this.borrowTxt[index] = '-' } } else if (item.is_storage === 2) { this.storageTxt[index] = '已入' if (item.is_borrow === '') { this.borrowTxt[index] = '在库' } } else if (item.is_storage === 3) { this.storageTxt[index] = '待出' if (item.is_borrow === '') { this.borrowTxt[index] = '-' } } else if (item.is_storage === '') { this.storageTxt[index] = '未入' if (item.is_borrow === '') { this.borrowTxt[index] = '-' } }
// 借阅状态
if (item.is_borrow === 1) { this.borrowTxt[index] = '待借' } else if (item.is_borrow === 2) { this.borrowTxt[index] = '待借' } else if (item.is_borrow === 3) { this.borrowTxt[index] = '已借' } else if (item.is_borrow === -1) { this.borrowTxt[index] = '在库' } }) } } }) } }, // 著录界面-form/详情-api
handleForm(type, title, isAnOrJuan) { if (type === 'add') { this.formTitle = '新增' + title this.arcId = null // this.parentsId = this[name].id //案卷和卷内有 不确定
} else if (type === 'edit') { this.arcId = this.selections[0].id this.formTitle = '编辑' + title } this.formVisible = true this.form.dictionaryConfigId = {} this.formPreviewData = [] // 档案预编辑获取字段
const params = { categoryId: this.categoryId, archivesId: this.arcId } this.getFormInfo(params, type, isAnOrJuan) }, getFormInfo(params, type, isAnOrJuan) { FetchFormDisplayFields(params).then(data => { this.formPreviewData = data.showFiled this.$nextTick(() => { if (type === 'edit') { this.$refs.previewForm.addOrUpdateForm = data.echo this.$refs.previewForm.isEdit = true } else { this.$refs.previewForm.isEdit = false if (this.recycleMain.selectedCategory.isType !== 5) { // 新增时拿到项目和案卷的相同的字段的值
this.formPreviewData.forEach(item => { if (isAnOrJuan === 1) { if (this.recycleMain.selectedCategory.isType !== 3) { if (this.recycleMain.projectSelection[item.fieldName]) { this.$refs.previewForm.addOrUpdateForm = JSON.parse(JSON.stringify(this.recycleMain.projectSelection)) } } } else if (isAnOrJuan === 2) { if (this.recycleMain.anjuanSelection[item.fieldName]) { this.$refs.previewForm.addOrUpdateForm = JSON.parse(JSON.stringify(this.recycleMain.anjuanSelection)) } } }) } } this.isDesFormType = 'arcives' this.$refs.previewForm.FetchNoFormatField(this.categoryId) }) }) }, // form - submit
handlerArchivesSubmit() { this.$refs.previewForm.submitForm('addOrUpdateForm', this.categoryId) this.selections = [] }, // 选择删除
toDelete(data) { // 已装盒的档案不可删除
// const indexCaseBool = data.findIndex(item => item.case_no !== '')
// if (indexCaseBool !== -1) {
// this.$message.error('已装盒的档案不可删除!')
// } else {
// this.$refs.deltArchives.deleteVisible = true
// this.getTotalSumAll()
// }
this.$refs.deltArchives.deleteVisible = true this.getTotalSumAll() }, getTotalSumAll(data) { this.totalSumAll = 0 this.selections.map((item) => { if (!isNaN(item.children_num)) this.totalSumAll += item.children_num }) if (isNaN(this.totalSumAll)) { return 0 } return this.totalSumAll }, // 打印条码
printArchivesCode(data) { this.codeLoading = true const params = data.map(item => { return item.id }) FetchPrintArchivesBarcode(params).then(res => { if (res && res.length !== 0) { this.selectedRows = res } else { this.selectedRows = [] this.$message({ message: '无相关可打印条码数据!', type: 'warning' }) return false } this.$nextTick(() => { this.codePrintData.count = this.selectedRows.length var printIframe = this.$refs.printIframe var html = this.$refs.printDiv.innerHTML printIframe.setAttribute('srcdoc', html) printIframe.onload = function() { console.log(printIframe.contentWindow) // 去掉iframe里面的dom的body的padding margin的默认数值
printIframe.contentWindow.document.body.style.padding = '0px' printIframe.contentWindow.document.body.style.margin = '0px' // 开始打印
printIframe.contentWindow.focus() printIframe.contentWindow.print() } }) // this.crud.refresh()
this.codeLoading = false }) }, // 删除 - 关闭
handleClose(done) { this.formVisible = false done() }, /* 重新渲染table组件 防止table-fixed 错位 配合watch-table数据 */ doLayout() { this.$nextTick(() => { this.$refs.table.doLayout() }) }, // 上传附件
uploadFile() { this.uploadFileVisible = true this.arcId = this.selections[0].id this.$nextTick(() => { this.$refs.uploadFile.tableData = [] this.$refs.uploadFile.getFileList() }) }, // 还原
handleRestore() { this.$refs.restore.restoreVisible = true } }, // 组件挂载时的共用方法
mounted() {
}}
|