|
|
|
@ -18,7 +18,7 @@ |
|
|
|
<el-dialog title="数据列表导出" v-if="showUploadData" :visible.sync="showUploadData" width="60%" |
|
|
|
:close-on-click-modal="false"> |
|
|
|
<excelUploadData @handleUploadDataHide="handleUploadDataHide" :currentTable="currentTable" |
|
|
|
:btnLoading="btnLoading" :pageType='`report`' :workBookId="workBookId" @saveLuckysheetHead="saveLuckysheet"> |
|
|
|
:btnLoading="btnLoading" :pageType='`report`' :workBookId="workBookId" @saveLuckysheetHead="saveLuckysheetHead"> |
|
|
|
</excelUploadData> |
|
|
|
</el-dialog> |
|
|
|
<el-dialog title="数据统计条件" v-if="showCondition" :visible.sync="showCondition" width="60%" |
|
|
|
@ -27,8 +27,7 @@ |
|
|
|
</el-dialog> |
|
|
|
<el-dialog title="上传统计模板" v-if="showTemplate" :visible.sync="showTemplate" width="60%" |
|
|
|
:close-on-click-modal="false"> |
|
|
|
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" |
|
|
|
:label-width="'120px'"> |
|
|
|
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" :label-width="'120px'"> |
|
|
|
<el-form-item label="报表名称" prop="reportName"> |
|
|
|
<el-input v-model.trim="dataForm.reportName" placeholder="报表名称"></el-input> |
|
|
|
</el-form-item> |
|
|
|
@ -73,7 +72,6 @@ export default { |
|
|
|
currentTable: null, |
|
|
|
currentId: '', |
|
|
|
btnLoading: false, |
|
|
|
workBookId: '', |
|
|
|
infoObj: {}, |
|
|
|
showCondition: false, |
|
|
|
showTemplate: false, |
|
|
|
@ -81,11 +79,15 @@ export default { |
|
|
|
reportType: 1,//报表类型。0:数据列表,1:统计数据 |
|
|
|
reportName: '',//报表名称 |
|
|
|
workbookId: '', |
|
|
|
formCode: "", |
|
|
|
columnsJson: [], |
|
|
|
searchForm: {} |
|
|
|
}, |
|
|
|
dataRule: { |
|
|
|
reportName: [{ required: true, message: this.$t('validate.required'), trigger: 'blur' }] |
|
|
|
}, |
|
|
|
exportJson:null, |
|
|
|
exportJson: null, |
|
|
|
importType: ''//template 上传统计模板 list 列表导出 |
|
|
|
}; |
|
|
|
}, |
|
|
|
props: { |
|
|
|
@ -108,29 +110,36 @@ export default { |
|
|
|
}, |
|
|
|
watch: {}, |
|
|
|
async mounted() { |
|
|
|
await this.loadWorkBook() |
|
|
|
this.$nextTick(async () => { |
|
|
|
if (this.pageType === 'info') { |
|
|
|
await this.loadWorkBook() |
|
|
|
await this.getSheetList() |
|
|
|
let heading = this.infoObj.columnsJson[0].children.map(item => ({ label: item.label })) |
|
|
|
for (let i in heading) { |
|
|
|
luckysheet.setCellValue(0, i, heading[i].label) |
|
|
|
} |
|
|
|
let list = await this.getListData(this.infoIds.id); |
|
|
|
let newArrar = luckysheet.getAllSheets(); |
|
|
|
this.currentTable = newArrar.filter(item => item.status == '1'); |
|
|
|
luckysheet.insertRow(this.currentTable[0].data.length, 1) |
|
|
|
luckysheet.insertRow(this.currentTable[0].data.length, { number: list.length }); |
|
|
|
await nextTick(500) |
|
|
|
let newArray = list.map(obj => { |
|
|
|
return Object.keys(obj).map(key => { |
|
|
|
return { m: obj[key], "ct": { "fa": "General", "t": "g" }, v: obj[key] }; |
|
|
|
if (this.infoObj.reportType === 0) { |
|
|
|
let heading = this.infoObj.columnsJson[0].children.map(item => ({ label: item.label })) |
|
|
|
for (let i in heading) { |
|
|
|
luckysheet.setCellValue(0, i, heading[i].label) |
|
|
|
} |
|
|
|
let list = await this.getListData(this.infoIds.id); |
|
|
|
let newArrar = luckysheet.getAllSheets(); |
|
|
|
this.currentTable = newArrar.filter(item => item.status == '1'); |
|
|
|
luckysheet.insertRow(this.currentTable[0].data.length, 1) |
|
|
|
luckysheet.insertRow(this.currentTable[0].data.length, { number: list.length }); |
|
|
|
await nextTick(500) |
|
|
|
let newArray = list.map(obj => { |
|
|
|
return Object.keys(obj).map(key => { |
|
|
|
return { m: obj[key], "ct": { "fa": "General", "t": "g" }, v: obj[key] }; |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
let bottomRightCorner = this.numberToLetter(Object.keys(list[0]).length)//选区右下角数字 |
|
|
|
luckysheet.setRangeValue(newArray, { |
|
|
|
range: `A2:${bottomRightCorner}${2 + list.length}`, |
|
|
|
}) |
|
|
|
let bottomRightCorner = this.numberToLetter(Object.keys(list[0]).length)//选区右下角数字 |
|
|
|
luckysheet.setRangeValue(newArray, { |
|
|
|
range: `A2:${bottomRightCorner}${list.length}`, |
|
|
|
}) |
|
|
|
}else{ |
|
|
|
await this.loadWorkBook(this.infoObj.workbookId) |
|
|
|
|
|
|
|
} |
|
|
|
}else{ |
|
|
|
await this.loadWorkBook() |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
@ -163,12 +172,10 @@ export default { |
|
|
|
throw error; |
|
|
|
} |
|
|
|
}, |
|
|
|
uploadExcel(files) { |
|
|
|
async uploadExcel(files) { |
|
|
|
if (!files) return alert('没有文件等待导入'); |
|
|
|
let that = this |
|
|
|
LuckyExcel.transformExcelToLucky(files, function (exportJson, luckysheetfile) { |
|
|
|
console.log(exportJson, '获取到导入的JSON'); |
|
|
|
that.exportJson = exportJson |
|
|
|
if (exportJson.sheets == null || exportJson.sheets.length == 0) return alert('读取excel文件内容失败, 目前不支持XLS文件!'); |
|
|
|
window.luckysheet.destroy(); |
|
|
|
options.container = 'luckysheet-export' |
|
|
|
@ -179,8 +186,10 @@ export default { |
|
|
|
title: exportJson.info.name, |
|
|
|
hook: {}, |
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
this.saveLuckysheet() |
|
|
|
await nextTick(1000) |
|
|
|
await this.saveLuckysheetHead() |
|
|
|
}, |
|
|
|
beforeExcelUpload(file) { |
|
|
|
this.fullscreenLoading = true; |
|
|
|
@ -200,7 +209,7 @@ export default { |
|
|
|
return fileType && isLt1M; |
|
|
|
}, |
|
|
|
onClickShowCondition() { |
|
|
|
this.showCondition = true |
|
|
|
this.showCondition = true; |
|
|
|
}, |
|
|
|
async getSheetList() { |
|
|
|
const { data, code } = await requestGet('/actual/base/intellgentizeReport/detail', { id: this.infoIds.id }) |
|
|
|
@ -214,16 +223,17 @@ export default { |
|
|
|
// 上传模板 |
|
|
|
async handleClickInspect() { |
|
|
|
this.showTemplate = true; |
|
|
|
this.importType = 'template' |
|
|
|
}, |
|
|
|
|
|
|
|
onClickUplond() { |
|
|
|
this.showUploadData = true; |
|
|
|
let list = luckysheet.getAllSheets() |
|
|
|
this.currentTable = list.filter(item => item.status == '1') |
|
|
|
|
|
|
|
this.importType = 'list' |
|
|
|
}, |
|
|
|
async handleUploadDataHide(val) { |
|
|
|
let listData = await this.getListData(val.id) |
|
|
|
const listData = await this.getListData(val.id) |
|
|
|
luckysheet.insertRow(this.currentTable[0].data.length, 1) |
|
|
|
luckysheet.insertRow(this.currentTable[0].data.length, { number: listData.length }); |
|
|
|
this.showUploadData = false; |
|
|
|
@ -235,21 +245,34 @@ export default { |
|
|
|
}); |
|
|
|
let bottomRightCorner = this.numberToLetter(Object.keys(listData[0]).length)//选区右下角数字 |
|
|
|
luckysheet.setRangeValue(newArray, { |
|
|
|
range: `A2:${bottomRightCorner}${2 + listData.length}`, |
|
|
|
range: `A2:${bottomRightCorner}${listData.length}`, |
|
|
|
}) |
|
|
|
|
|
|
|
}, |
|
|
|
async saveLuckysheet(head) { |
|
|
|
if (this.currentTable[0].data[0].every(item => !item) && head) { |
|
|
|
async saveLuckysheetHead(head) { |
|
|
|
// this.currentTable[0].data[0].every(item => !item) && |
|
|
|
if (head && this.importType === 'list') { |
|
|
|
let temp = head.map(item => item.children).flat(); |
|
|
|
for (let i in temp) { |
|
|
|
luckysheet.setCellValue(0, i, temp[i].label) |
|
|
|
} |
|
|
|
} |
|
|
|
let luckysheetJson = luckysheet.getAllSheets() |
|
|
|
const { data, code, msg } = await requestPost(`/actual/base/luckySheet/workbook/createByJson?fileName=`, luckysheetJson) |
|
|
|
const { data, code, msg } = await requestPost(`/actual/base/luckySheet/workbook/createByJson?fileName=${this.dataForm.reportName}`, luckysheetJson) |
|
|
|
if (code === 0) { |
|
|
|
this.workBookId = data.workbookId; |
|
|
|
this.dataForm.workbookId = data.workbookId; |
|
|
|
if (this.importType === 'template') { |
|
|
|
this.createdReport() |
|
|
|
} |
|
|
|
} else { |
|
|
|
console.log(msg); |
|
|
|
} |
|
|
|
}, |
|
|
|
// |
|
|
|
async createdReport() { |
|
|
|
const url = '/actual/base/intellgentizeReport/create' |
|
|
|
let { data, code, msg } = await requestPost(url, this.dataForm) |
|
|
|
if (code === 0) { |
|
|
|
console.log(data); |
|
|
|
} else { |
|
|
|
console.log(msg); |
|
|
|
} |
|
|
|
@ -271,10 +294,10 @@ export default { |
|
|
|
} |
|
|
|
return letter; |
|
|
|
}, |
|
|
|
loadWorkBook() { |
|
|
|
loadWorkBook(workbookId) { |
|
|
|
options.container = 'luckysheet-export' |
|
|
|
options.gridKey = this.pageType === 'info' ? this.infoIds.workbookId : null; |
|
|
|
options.loadUrl = null |
|
|
|
options.loadUrl = workbookId?`${process.env.VUE_APP_API_SERVER}/actual/base/luckySheet/workbook/load?workbookId=${workbookId}`:null |
|
|
|
window.luckysheet.create({ |
|
|
|
...options, |
|
|
|
}); |
|
|
|
@ -321,7 +344,7 @@ export default { |
|
|
|
height: calc(100vh - 250px); |
|
|
|
} |
|
|
|
|
|
|
|
#luckysheet-export{ |
|
|
|
#luckysheet-export { |
|
|
|
width: 100%; |
|
|
|
padding: 0px; |
|
|
|
z-index: 2; |
|
|
|
|