From 2348002b7b9be5b60875bd73865862a344ded144 Mon Sep 17 00:00:00 2001
From: mk <2403457699@qq.com>
Date: Thu, 27 Feb 2025 14:22:28 +0800
Subject: [PATCH] =?UTF-8?q?=E6=99=BA=E8=83=BD=E6=8A=A5=E8=A1=A8=E6=96=B0?=
=?UTF-8?q?=E5=A2=9E=E6=8E=A5=E5=8F=A3=E8=81=94=E8=B0=83=EF=BC=8C=E5=88=A0?=
=?UTF-8?q?=E9=99=A4=E6=8E=A5=E5=8F=A3=E8=81=94=E8=B0=83=EF=BC=8C=E6=9F=A5?=
=?UTF-8?q?=E7=9C=8B=E8=BF=98=E9=9C=80=E8=A6=81=E5=86=8D=E6=94=B9=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../cpts/excel-template-confirmation.vue | 1 -
.../smartExcel/cpts/excel-upload-data.vue | 137 ++---
.../base/smartExcel/cpts/export-view.vue | 106 ++--
src/views/modules/base/smartExcel/report.vue | 486 +++++++++---------
4 files changed, 393 insertions(+), 337 deletions(-)
diff --git a/src/views/modules/base/smartExcel/cpts/excel-template-confirmation.vue b/src/views/modules/base/smartExcel/cpts/excel-template-confirmation.vue
index 1111777c1..3ea4b8593 100644
--- a/src/views/modules/base/smartExcel/cpts/excel-template-confirmation.vue
+++ b/src/views/modules/base/smartExcel/cpts/excel-template-confirmation.vue
@@ -77,7 +77,6 @@ export default {
},
handleConfirm(){
let boolean = this.exportJson.sheets[0].data[1].every(item => !item || !item.v);
- console.log(boolean);
if(boolean){
this.$emit('saveLuckysheetJson',this.exportJson)
}else{
diff --git a/src/views/modules/base/smartExcel/cpts/excel-upload-data.vue b/src/views/modules/base/smartExcel/cpts/excel-upload-data.vue
index a852d109c..819357759 100644
--- a/src/views/modules/base/smartExcel/cpts/excel-upload-data.vue
+++ b/src/views/modules/base/smartExcel/cpts/excel-upload-data.vue
@@ -11,13 +11,12 @@
-
+
-
-
-
+
@@ -65,22 +65,23 @@
-
+
-
温馨提示:智能填表将使用平台内已有的基础数据,如果您所在的组织下尚无基础数据,请先通过[智能导入]导入基础数据后再进行填表操作
+
温馨提示:智能填表将使用平台内已有的基础数据,如果您所在的组织下尚无基础数据,请先通过[智能导入]导入基础数据后再进行填表操作
- 上一步
- 下一步
-
+ 上一步
+ 下一步
+
@@ -138,20 +139,20 @@ export default {
// status:0
// },
],
- rules:{
- reportName:[{ required: true, message: this.$t('validate.required'), trigger: 'blur' }]
+ rules: {
+ reportName: [{ required: true, message: this.$t('validate.required'), trigger: 'blur' }]
},
formData: {
columnMateJson: '',
searchForm: {},
- formCode:'',
- reportName:''
+ formCode: '',
+ reportName: ''
},
resident_category_import_list: [],
groupList: [],
fileCode: null,
dataList: [],
- dataListLoading:false,
+ dataListLoading: false,
};
},
props: {
@@ -171,9 +172,13 @@ export default {
type: Array,
default: () => []
},
- pageType:{
+ pageType: {
+ type: String,
+ default: "excel"//excel:一张表数据填报 report:智能报表数据导出
+ },
+ workBookId:{
type:String,
- default:"excel"//excel:一张表数据填报 report:智能报表数据导出
+ default:()=>{}
}
},
created() {
@@ -181,9 +186,9 @@ export default {
},
methods: {
- toSmartImport(){
- this.$router.push({path:'/main/base-smartImport'})
- this.$emit('handleUploadDataHide',null)
+ toSmartImport() {
+ this.$router.push({ path: '/main/base-smartImport' })
+ this.$emit('handleUploadDataHide', null)
},
onClickTab(value) {
this.formData1 = {}
@@ -199,36 +204,21 @@ export default {
},
onClickNext() {
if (this.progress === 1) {
- if(this.pageType == 'report'){
- this.$refs['ref_form'].validate((valid)=>{
+ if (this.pageType == 'report') {
+ this.$refs['ref_form'].validate((valid) => {
if (!valid) {
return false
- }else{
+ } else {
this.progress = 2;
}
})
- }else{
+ } else {
this.progress = 2;
this.dataListLoading = true;
this.checkExtractExcelHead()
}
} else if (this.progress === 2) {
- let obj = this.dataList.reduce((acc, item) => {
- if (item.userTableHeader) {
- acc[item.userTableHeader] = item.itemId;
- }
- return acc;
- }, {});
- this.formData.columnMateJson = JSON.stringify(obj)
- this.progress = 3;
- } else {
- this.dataListLoading = true;
- if(this.formData1.importCategory === 'BASEINFO'){
- this.formData.searchForm= this.$refs['resi_form'].form;
- }else{
- this.formData.searchForm= this.$refs['house_form'].form;
- }
- if(this.pageType === 'report'){
+ if (this.pageType === 'report') {
this.formData.columnsJson = this.$refs['report_form'].rightList.map(item => {
return {
itemId: item.id,
@@ -238,10 +228,32 @@ export default {
supportAdd: item.supportAdd
}
})
+ this.$emit('saveLuckysheetHead',this.formData.columnsJson)
+ }else{
+ let obj = this.dataList.reduce((acc, item) => {
+ if (item.userTableHeader) {
+ acc[item.userTableHeader] = item.itemId;
+ }
+ return acc;
+ }, {});
+ this.formData.columnMateJson = JSON.stringify(obj)
+ }
+
+ this.progress = 3;
+ } else {
+ this.dataListLoading = true;
+ if (this.formData1.importCategory === 'BASEINFO') {
+ this.formData.searchForm = this.$refs['resi_form'].form;
+ } else {
+ this.formData.searchForm = this.$refs['house_form'].form;
+ }
+ if (this.pageType === 'report') {
+
this.formData.reportType = 0;
- this.formData.formCode = this.formData1.importCategory === 'BASEINFO'?'resident_base_info':'community_info'
+ this.formData.workbookId = this.workBookId;
+ this.formData.formCode = this.formData1.importCategory === 'BASEINFO' ? 'resident_base_info' : 'community_info'
delete this.formData.columnMateJson
- }else{
+ } else {
this.formData.formCode = this.formData1.importCategory
delete this.formData.reportName
}
@@ -249,11 +261,14 @@ export default {
}
},
async saveUploadForm() {
- const url = this.pageType === 'report'?'/actual/base/intellgentizeReport/create':'/actual/base/residentBaseInfo/exportOneSheet'
- const { data, code, msg } = await requestPost(url, this.formData)
+ const url = this.pageType === 'report' ? '/actual/base/intellgentizeReport/create' : '/actual/base/residentBaseInfo/exportOneSheet'
+ let { data, code, msg } = await requestPost(url, this.formData)
if (code === 0) {
this.dataListLoading = false;
- this.$emit('handleUploadDataHide',data)
+ if (this.pageType === 'report') {
+ data = { columnsJson: this.formData.columnsJson, id: data }
+ }
+ this.$emit('handleUploadDataHide', data)
} else {
console.log(msg);
}
@@ -291,22 +306,22 @@ export default {
let columnMateStr = '';
let foundFirstValue = false; // 标记是否找到第一个有效值
for (let item of this.currentTable[0].data[0]) {
- if (!foundFirstValue) {
- // 还没有遇到有效值,继续拼接空值
- if (!item || item.v === '') {
- columnMateStr += '空;'; // 空值拼接"空"
- } else {
- columnMateStr += item.v + ';'; // 第一个有效值拼接
- foundFirstValue = true; // 标记已经找到第一个有效值
- }
+ if (!foundFirstValue) {
+ // 还没有遇到有效值,继续拼接空值
+ if (!item || item.v === '') {
+ columnMateStr += '空;'; // 空值拼接"空"
} else {
- // 遇到第一个空值时停止拼接
- if (!item || item.v === '') {
- break; // 停止后续处理
- } else {
- columnMateStr += item.v + ';'; // 继续拼接有效值
- }
+ columnMateStr += item.v + ';'; // 第一个有效值拼接
+ foundFirstValue = true; // 标记已经找到第一个有效值
}
+ } else {
+ // 遇到第一个空值时停止拼接
+ if (!item || item.v === '') {
+ break; // 停止后续处理
+ } else {
+ columnMateStr += item.v + ';'; // 继续拼接有效值
+ }
+ }
}
// 去掉最后一个多余的分号
columnMateStr = columnMateStr.slice(0, -1);
@@ -353,7 +368,7 @@ export default {
this.createdTime = createdTime;
},
},
- components: {resiSearch,HoseSearch,exportProcessTwo},
+ components: { resiSearch, HoseSearch, exportProcessTwo },
computed: {},
watch: {},
};
diff --git a/src/views/modules/base/smartExcel/cpts/export-view.vue b/src/views/modules/base/smartExcel/cpts/export-view.vue
index 2aae9f6bd..8aeabe160 100644
--- a/src/views/modules/base/smartExcel/cpts/export-view.vue
+++ b/src/views/modules/base/smartExcel/cpts/export-view.vue
@@ -3,15 +3,13 @@
- 返回
- 上传统计模板
-
+ 返回
+ 上传统计模板
+
数据列表导出
- 导出
+ 导出
@@ -19,7 +17,7 @@
+ :btnLoading="btnLoading" :pageType='`report`' :workBookId="workBookId" @saveLuckysheetHead="saveLuckysheet">
@@ -31,7 +29,7 @@ import options from "@/utils/luckysheetConfig.js";
import { mapGetters } from 'vuex'
import { requestPost, requestGet } from "@/js/dai/request";
import nextTick from "dai-js/tools/nextTick";
-
+import { exportSheetExcel } from "@/utils/export";
export default {
data() {
@@ -43,11 +41,18 @@ export default {
currentTable: null,
currentId: '',
btnLoading: false,
- sheetR:0
+ workBookId: ''
};
},
props: {
-
+ pageType: {
+ type: String,
+ default: ''
+ },
+ infoIds: {
+ type: Object,
+ default: () => { }
+ }
},
computed: {
tableHeight() {
@@ -55,53 +60,75 @@ export default {
},
...mapGetters(['clientHeight', 'resolution']),
},
- created() {
+ created() {
},
watch: {},
async mounted() {
- this.loadWorkBook()
+ await this.loadWorkBook()
+ if (this.pageType === 'info') {
+ await this.getSheetList()
+ }
},
methods: {
- handleClickCurrencyEvent(){
- exportSheetExcel(luckysheet.getAllSheets(),'导出文件')
+ async getSheetList() {
+ const { data, code } = await requestGet('/actual/base/intellgentizeReport/detail', { id: this.infoIds.id })
+ if (code === 0) {
+ console.log(data);
+ }
},
- async handleClickInspect() {
-
+ handleClickCurrencyEvent() {
+ exportSheetExcel(luckysheet.getAllSheets(), '导出文件')
},
+ // 上传模板
+ async handleClickInspect() {
+ },
+
onClickUplond() {
this.showUploadData = true;
let list = luckysheet.getAllSheets()
this.currentTable = list.filter(item => item.status == '1')
+
},
async handleUploadDataHide(val) {
- this.showUploadData = false;
+ let listData = await this.getListData(val.id)
luckysheet.insertRow(this.currentTable[0].data.length, 1)
- const findLastNonNullIndex = (arr) => {
- for (let i = arr.length - 1; i >= 0; i--) {
- const subArray = arr[i];
- // 判断:是数组,且至少有一个不为 null 的元素
- if (Array.isArray(subArray) && subArray.some(item => item !== null && item.v && item.v !== null && item.v !== '')) {
- return i; // 返回下标
- }
- }
- return -1; // 如果没有符合条件的,返回 -1
- };
- this.sheetR = findLastNonNullIndex(this.currentTable[0].data)
- console.log(this.currentTable[0].data.length, val.length);
- luckysheet.insertRow(this.currentTable[0].data.length, { number: val.length });
- await nextTick(2000)
- let newArray = val.map(obj => {
+ luckysheet.insertRow(this.currentTable[0].data.length, { number: listData.length });
+ this.showUploadData = false;
+ await nextTick(500)
+ let newArray = listData.map(obj => {
return Object.keys(obj).map(key => {
return { m: obj[key], "ct": { "fa": "General", "t": "g" }, v: obj[key] };
});
});
- console.log(newArray, '处理后数据');
- let bottomRightCorner = this.numberToLetter(Object.keys(val[0]).length)//选区右下角数字
+ let bottomRightCorner = this.numberToLetter(Object.keys(listData[0]).length)//选区右下角数字
luckysheet.setRangeValue(newArray, {
- range: `A${this.sheetR + 2}:${bottomRightCorner}${this.sheetR + val.length}`,
+ range: `A2:${bottomRightCorner}${2 + listData.length}`,
})
+
+ },
+ async saveLuckysheet(head) {
+ if (this.currentTable[0].data[0].every(item => !item) && head) {
+ 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)
+ if (code === 0) {
+ this.workBookId = data.workbookId;
+ } else {
+ console.log(msg);
+ }
+ },
+ async getListData(id) {
+ const { data, code } = await requestGet('/actual/base/intellgentizeReport/listDatasById', { id })
+ if (code === 0) {
+ console.log(data);
+ return data
+ }
},
// 数字转换对应顺序英文
numberToLetter(num) {
@@ -115,11 +142,14 @@ export default {
},
loadWorkBook() {
window.luckysheet.destroy();
- const { id } = this.$store.state.user;
- options.gridKey = this.currentId;
options.allowUpdate = true;
options.container = 'luckysheet'
- // options.loadUrl = `${process.env.VUE_APP_API_SERVER}/actual/base/luckySheet/workbook/load?workbookId=${this.currentId}`
+ options.gridKey = this.pageType === 'info' ? this.infoIds.workbookId : null;
+ if (this.pageType === 'info') {
+ options.loadUrl = `${process.env.VUE_APP_API_SERVER}/actual/base/luckySheet/workbook/load?workbookId=${this.infoIds.workbookId}`
+ }else{
+ options.loadUrl = null
+ }
// options.updateUrl = `${process.env.VUE_APP_SOCKET_SERVER}/actual/base/ws/luckysheet/${this.currentId}/${id}`
window.luckysheet.create({
...options,
diff --git a/src/views/modules/base/smartExcel/report.vue b/src/views/modules/base/smartExcel/report.vue
index 634f84444..5ef5546a5 100644
--- a/src/views/modules/base/smartExcel/report.vue
+++ b/src/views/modules/base/smartExcel/report.vue
@@ -4,23 +4,11 @@
-
-
-
-
-
-
-
-
-
-
+
- {{scope.row.exportCount}}
+ {{ scope.row.exportCount }}
@@ -65,6 +55,7 @@
查看
+ 删除
@@ -77,8 +68,8 @@
-