From b9369953170fbc6c28c8e4f5b50e369b390c90e3 Mon Sep 17 00:00:00 2001 From: Xu Zhimeng Date: Mon, 23 Oct 2023 15:13:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BF=9D=E5=AD=98Resu?= =?UTF-8?q?lts=E6=97=B6=E7=9A=84=E6=96=87=E4=BB=B6=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E4=B8=8D=E6=AD=A3=E7=A1=AE=E9=97=AE=E9=A2=98=EF=BC=8CCompare?= =?UTF-8?q?=E5=92=8CStrip=E5=A2=9E=E5=8A=A0=E6=9C=AC=E5=9C=B0=E7=9B=B4?= =?UTF-8?q?=E6=8E=A5=E9=80=89=E6=8B=A9=E6=96=87=E4=BB=B6=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + src/utils/file.js | 17 +++-- .../Modals/CompareFileListModal.vue | 2 +- src/views/spectrumAnalysis/gamma-analysis.vue | 62 ++++++++++++++----- src/views/spectrumAnalysis/index.vue | 9 +-- 5 files changed, 65 insertions(+), 26 deletions(-) diff --git a/package.json b/package.json index 493438c..4c33fa3 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,7 @@ "vxe-table": "2.9.13", "vxe-table-plugin-antd": "1.8.10", "xe-utils": "2.4.8", + "xlsx": "^0.18.5", "xss": "^1.0.13" }, "devDependencies": { diff --git a/src/utils/file.js b/src/utils/file.js index f5bcc69..6df6fdd 100644 --- a/src/utils/file.js +++ b/src/utils/file.js @@ -104,21 +104,28 @@ export function getFileNameByHeaderContentDisposition(contentDisposition) { return fileName } -export const fetchAndDownload = async (url, data) => { +export const fetchAndDownload = async (url, data, method='post') => { const apiBaseUrl = window._CONFIG['domianURL'] || '/jeecg-boot' const sign = signMd5Utils.getSign(url, data) - const response = await Axios({ + + const config = { baseURL: apiBaseUrl, - method: 'post', + method, url, - data: data, + data, + headers: { 'X-Sign': sign, 'X-TIMESTAMP': signMd5Utils.getTimestamp(), 'X-Access-Token': Vue.ls.get(ACCESS_TOKEN), 'tenant-id': Vue.ls.get(TENANT_ID) } - }) + } + if(method == 'get') { + config.params = data + } + + const response = await Axios(config) const { status, headers, data: responseData } = response if (status == 200) { if (typeof responseData == 'object') { diff --git a/src/views/spectrumAnalysis/components/Modals/CompareFileListModal.vue b/src/views/spectrumAnalysis/components/Modals/CompareFileListModal.vue index de8c912..dd873f1 100644 --- a/src/views/spectrumAnalysis/components/Modals/CompareFileListModal.vue +++ b/src/views/spectrumAnalysis/components/Modals/CompareFileListModal.vue @@ -80,7 +80,7 @@ export default { const params = this.getQueryParams() //查询条件 const searchName = this.queryParam.searchName - params.name = `${searchName ? `${searchName},` : ''}_S_` + params.name = searchName this.loading = true getAction('/spectrumFile/get', params) .then(res => { diff --git a/src/views/spectrumAnalysis/gamma-analysis.vue b/src/views/spectrumAnalysis/gamma-analysis.vue index c3ca71d..d2b833e 100644 --- a/src/views/spectrumAnalysis/gamma-analysis.vue +++ b/src/views/spectrumAnalysis/gamma-analysis.vue @@ -138,6 +138,8 @@ import store from '@/store/' import Vue from 'vue' import { ACCESS_TOKEN } from '@/store/mutation-types' import StripModal from './components/Modals/StripModal.vue' +import { FilePicker } from '@/utils/FilePicker' +import { zipFile } from '@/utils/file' export default { props: { @@ -470,21 +472,21 @@ export default { // 推入BaseLine series.push( buildLineSeries('BaseLine', this.transformPointListData(channelBaseLine.pointlist), channelBaseLine.color, { - zlevel: 2, + z: 2, }) ) // 推入LcLine线 series.push( buildLineSeries('LcLine', this.transformPointListData(channelLcLine.pointlist), channelLcLine.color, { - zlevel: 3, + z: 3, }) ) // 推入Scac线 series.push( buildLineSeries('ScacLine', this.transformPointListData(channelScacLine.pointlist), channelScacLine.color, { - zlevel: 4, + z: 4, }) ) @@ -506,7 +508,7 @@ export default { disabled: true, }, animation: false, - zlevel: 5, + z: 5, }) // 推入Peak Line @@ -514,7 +516,7 @@ export default { channelPeakGroup.forEach((item, index) => { peakLines.push( buildLineSeries(`Peak_${index}`, this.transformPointListData(item.pointlist), item.color, { - zlevel: 6, + z: 6, }) ) }) @@ -524,12 +526,13 @@ export default { series.push( buildLineSeries('Compare', [], '#fff', { symbolSize: 2, + z: 7, }) ) this.opts.notMerge = true this.option.series = series - + this.$nextTick(() => { this.resetChartOpts() }) @@ -576,6 +579,11 @@ export default { break case 'Channel': case 'Energy': + // 如果Energy没有值,则不进行切换 + if (!this.energyData.all.pointlist) { + return + } + this.graphAssistance.axisType = label this.option.xAxis.name = label @@ -713,7 +721,7 @@ export default { data.forEach((item, index) => { peakLines.push( buildLineSeries(`Peak_${index}`, this.transformPointListData(item.pointlist), item.color, { - zlevel: 6, + z: 6, }) ) }) @@ -1219,15 +1227,42 @@ export default { } this.handleResetChart() this.clearCompareLine() - this.compareFileListModalVisible = true - this.isStrip = isStrip + if (FilePicker.canUse()) { + this.chooseFileFromFS() + } else { + this.compareFileListModalVisible = true + } + }, + + // 从文件系统中选择文件 + async chooseFileFromFS() { + try { + const [fileHandle] = await FilePicker.chooseFile(false, [{ accept: { 'text/phd': ['.phd'] } }]) + const file = await fileHandle.getFile() + const zipedFiles = await zipFile([file], 'test.zip') + try { + const formData = new FormData() + formData.append('file', zipedFiles) + const { success, message } = await postAction('/spectrumFile/upload', formData) + if (success) { + this.handleFileSelect(file.name) + } else { + this.$message.error(message) + } + } catch (error) { + console.error(error) + } + } catch (error) { + console.error(error) + } }, // 文件之间对比 async handleFileSelect(selectedFileName) { const { inputFileName: fileName } = this.sample + const hide = this.$message.loading(this.isStrip ? 'Stripping...' : 'Comparing...', 0) try { let param = { fileName, @@ -1246,7 +1281,6 @@ export default { url = '/gamma/Strip' } - this.isLoading = true const { success, result, message } = await getAction(url, param) if (success) { const [channelData, energyData] = result @@ -1254,10 +1288,6 @@ export default { this.energyCompareLine = energyData this.redrawLineBySeriesName('Compare', energyData, channelData, true, channelData.color) - if (this.isScatter()) { - lineSeries.type = 'scatterGL' - } - this.$nextTick(() => { this.thumbnailOption.yAxis.max = getAxisMax(this.getChart(), 'yAxis') }) @@ -1267,7 +1297,7 @@ export default { } catch (error) { console.error(error) } finally { - this.isLoading = false + hide() } }, @@ -1305,7 +1335,7 @@ export default { this.dataProcess(result) } else { this.isLoading = false - if(showMessage) { + if (showMessage) { const arr = message.split('\n') this.$warning({ title: 'Warning', diff --git a/src/views/spectrumAnalysis/index.vue b/src/views/spectrumAnalysis/index.vue index 2f2a253..b57630d 100644 --- a/src/views/spectrumAnalysis/index.vue +++ b/src/views/spectrumAnalysis/index.vue @@ -198,7 +198,7 @@