| | |
| | | </template> |
| | | <template #buttons> |
| | | <CompReportDownloadDialog |
| | | name="é®é¢ä¸æ´æ¹æ±æ»åæä¸å¨æè·è¸ªæ¸
å" |
| | | :name="fileName" |
| | | :locations="formSearch.locations" |
| | | :scenetype="formSearch.scenetype" |
| | | :time="formSearch.time" |
| | | @submit="handleSearch" |
| | | @submit="(e) => handleSearch(e, true)" |
| | | ></CompReportDownloadDialog> |
| | | </template> |
| | | </FYSearchBar> |
| | |
| | | <el-table-column |
| | | v-for="(item, index) in activeExcelData.head" |
| | | :key="index" |
| | | :prop="item.name" |
| | | :prop="item.prop" |
| | | :label="item.name" |
| | | > |
| | | <template v-if="item.children" #default="{ row }"> |
| | | <span v-html="row[item.name]"></span> |
| | | <span v-html="row[item.prop]"></span> |
| | | <el-table-column |
| | | v-for="(item1, index1) in item.children" |
| | | :key="index1" |
| | | :prop="item1.name" |
| | | :prop="item1.prop" |
| | | :label="item1.name" |
| | | > |
| | | <template v-if="item1.children" #default="scope1"> |
| | | <span v-html="scope1.row[item1.name]"></span> |
| | | <span v-html="scope1.row[item1.prop]"></span> |
| | | <el-table-column |
| | | v-for="(item2, index2) in item1.children" |
| | | :key="index2" |
| | | :prop="item2.name" |
| | | :prop="item2.prop" |
| | | :label="item2.name" |
| | | > |
| | | <template v-if="item2.children" #default="scope2"> |
| | | <span v-html="scope2.row[item2.name]"></span> |
| | | <span v-html="scope2.row[item2.prop]"></span> |
| | | </template> |
| | | </el-table-column> |
| | | </template> |
| | |
| | | //å¼å
¥ç¸å
³æ ·å¼ |
| | | import '@vue-office/excel/lib/index.css'; |
| | | |
| | | import { ref, onMounted } from 'vue'; |
| | | import { ref, onMounted, computed } from 'vue'; |
| | | import dayjs from 'dayjs'; |
| | | import * as XLSX from 'xlsx'; |
| | | import * as ExcelJS from 'exceljs'; |
| | | import dataproductApi from '@/api/fysp/dataproductApi'; |
| | | import CompReportDownloadDialog from './CompReportDownloadDialog.vue'; |
| | | import { Base64 } from 'js-base64'; |
| | | import { useBgtaskStore } from '@/stores/bgtaskStore'; |
| | | |
| | | const bgtaskStore = useBgtaskStore(); |
| | | |
| | | const emit = defineEmits(['search']); |
| | | |
| | |
| | | headNum: { |
| | | type: Number, |
| | | default: 1 |
| | | } |
| | | }); |
| | | |
| | | const fileName = computed(() => { |
| | | switch (props.productType) { |
| | | case 1: |
| | | return 'é®é¢ä¸æ´æ¹æ±æ»åæä¸å¨æè·è¸ªæ¸
å'; |
| | | case 2: |
| | | return 'è§èæ§è¯ä¼°ä¸åææ¸
å'; |
| | | case 3: |
| | | return 'é®é¢ä¸æ´æ¹åå¸åææ¸
å'; |
| | | default: |
| | | return 'æ¥åæ¸
å'; |
| | | } |
| | | }); |
| | | |
| | |
| | | getTable(activeSheet.value); |
| | | } |
| | | |
| | | function handleSearch(forceUpdate) { |
| | | function handleSearch(forceUpdate, isDownload) { |
| | | const locations = formSearch.value.locations; |
| | | const time = formSearch.value.time; |
| | | const scenetype = formSearch.value.scenetype; |
| | |
| | | dataproductApi |
| | | .downloadProduct(area, props.productType, forceUpdate ? forceUpdate : false) |
| | | .then(async (res) => { |
| | | // const data = new Uint8Array(res); |
| | | res.arrayBuffer().then((data) => { |
| | | workbook = XLSX.read(data, { type: 'array' }); |
| | | sheetNames.value = workbook.SheetNames; |
| | | activeSheet.value = sheetNames.value[0]; |
| | | getTable(activeSheet.value); |
| | | }); |
| | | if (res == false) { |
| | | alert('æ¥åçæä¸ï¼å¯å¨åå°ä»»å¡æ¥ççæè¿åº¦'); |
| | | bgtaskStore.dialogShow = true; |
| | | bgtaskStore.fetchTask(); |
| | | } else { |
| | | if (isDownload) { |
| | | const name = Base64.decode(res.headers.get('filename')); |
| | | const url = window.URL.createObjectURL(res.data); |
| | | const link = document.createElement('a'); |
| | | link.href = url; |
| | | link.setAttribute('download', name); |
| | | document.body.appendChild(link); |
| | | link.click(); |
| | | document.body.removeChild(link); |
| | | window.URL.revokeObjectURL(url); |
| | | } else { |
| | | res.data.arrayBuffer().then((data) => { |
| | | workbook = XLSX.read(data, { type: 'array' }); |
| | | sheetNames.value = workbook.SheetNames; |
| | | activeSheet.value = sheetNames.value[0]; |
| | | getTable(activeSheet.value); |
| | | }); |
| | | } |
| | | |
| | | // const workbook = new ExcelJS.Workbook(); |
| | | // await workbook.xlsx.load(res); |
| | | // workbook.eachSheet(function (worksheet, sheetId) { |
| | | // console.log(worksheet.name); |
| | | // }); |
| | | // const sheet1 = workbook.worksheets[0] |
| | | // const row = sheet1.getRow(1) |
| | | // console.log(row); |
| | | // const workbook = new ExcelJS.Workbook(); |
| | | // await workbook.xlsx.load(res); |
| | | // workbook.eachSheet(function (worksheet, sheetId) { |
| | | // console.log(worksheet.name); |
| | | // }); |
| | | // const sheet1 = workbook.worksheets[0] |
| | | // const row = sheet1.getRow(1) |
| | | // console.log(row); |
| | | |
| | | // console.log(res); |
| | | // console.log(new ArrayBuffer(res)); |
| | | // res.arrayBuffer().then(r=>{ |
| | | // excel.value = r |
| | | // }) |
| | | // console.log(res); |
| | | // console.log(new ArrayBuffer(res)); |
| | | // res.arrayBuffer().then(r=>{ |
| | | // excel.value = r |
| | | // }) |
| | | |
| | | // excel.value = new ArrayBuffer(res) |
| | | // excel.value = new ArrayBuffer(res) |
| | | } |
| | | }) |
| | | .finally(() => (loading.value = false)); |
| | | } |
| | |
| | | // console.log(tableData); |
| | | |
| | | const t = strToTableObj(tableData); |
| | | console.log(t); |
| | | // console.log(t); |
| | | // console.log(head); |
| | | // console.log(data); |
| | | excelDatas.value.set(sheetName, t); |
| | |
| | | const row = rows[i]; |
| | | if (lastHead.length == 0) { |
| | | row.forEach((r, y) => { |
| | | lastHead.push({ name: r }); |
| | | dataKeys.push(r); |
| | | const prop = r == '' ? r : `id-${r}-${y}`; |
| | | lastHead.push({ name: r, prop }); |
| | | dataKeys.push(prop); |
| | | }); |
| | | } else { |
| | | const newHead = []; |
| | | row.forEach((r, y) => { |
| | | const prop = `id-${r}-${y}`; |
| | | if (dataKeys[y] == '') { |
| | | dataKeys[y] = r; |
| | | // lastHead[y] = { name: r, prop }; |
| | | dataKeys[y] = prop; |
| | | } |
| | | |
| | | const last = lastHead[y]; |
| | |
| | | console.log(last); |
| | | } |
| | | if (last.name == '') { |
| | | newHead.push({ name: r }); |
| | | newHead.push({ name: r, prop }); |
| | | offset++; |
| | | } else if (r != '') { |
| | | newHead.push({ |
| | |
| | | }); |
| | | offset = 1; |
| | | } else { |
| | | newHead.push({ name: '' }); |
| | | newHead.push({ name: '', prop }); |
| | | let _index = newHead.length - 1 - offset; |
| | | _index = _index >= 0 ? _index : 0; |
| | | newHead[_index].children.push(last); |