Gamma 导出excel功能开发

This commit is contained in:
renpy 2023-09-07 17:30:07 +08:00
parent da3e09e847
commit 3b516367d3
5 changed files with 195 additions and 16 deletions

View File

@ -1,6 +1,7 @@
import Vue from 'vue'
import { axios } from '@/utils/request'
import signMd5Utils from '@/utils/encryption/signMd5Utils'
import qs from "qs";
const api = {
user: '/mock/api/user',
@ -69,6 +70,24 @@ export function getAction(url,parameter) {
})
}
export function getFileAction(url,parameter) {
let sign = signMd5Utils.getSign(url, parameter);
//将签名和时间戳,添加在请求接口 Header
// update-begin--author:taoyan---date:20220421--for: VUEN-410【签名改造】 X-TIMESTAMP牵扯
let signHeader = {"X-Sign": sign,"X-TIMESTAMP": signMd5Utils.getTimestamp()};
// update-end--author:taoyan---date:20220421--for: VUEN-410【签名改造】 X-TIMESTAMP牵扯
return axios({
url: url,
method: 'get',
params: parameter,
responseType:"blob",
paramsSerializer: function (params) {
return qs.stringify(params, { arrayFormat: "repeat" });
},
headers: signHeader
})
}
//deleteAction
export function deleteAction(url,parameter) {
return axios({

View File

@ -46,8 +46,10 @@
</template>
<script>
import { getAction } from '@/api/manage'
import { getAction, getFileAction } from '@/api/manage'
import ModalMixin from '@/mixins/ModalMixin'
import SampleDataMixin from '@/views/spectrumAnalysis/SampleDataMixin'
import { saveAs } from 'file-saver';
const columns = [
{
@ -113,7 +115,7 @@ const columns = [
}
]
export default {
mixins: [ModalMixin],
mixins: [ModalMixin, SampleDataMixin],
props: {
sampleId: {
type: Number
@ -130,7 +132,8 @@ export default {
isLoading: false,
list: [],
compareList: []
compareList: [],
fileName: ''
}
},
methods: {
@ -166,7 +169,43 @@ export default {
},
// Excel
handleExportToExcel() {}
handleExportToExcel() {
if (this.list.length > 0) {
let _this = this
this.$confirm({
title: 'Please enter file name',
content: h => <a-input v-model={_this.fileName} />,
okText: 'Cancle',
cancelText: 'Save',
okButtonProps: {style: {backgroundColor: "#b98326", color: "#fff", borderColor: "transparent"}},
cancelButtonProps: {style: {color: "#fff", backgroundColor: "#31aab0", borderColor: "transparent"}},
onOk() {
console.log('Cancel');
},
onCancel() {
if (_this.fileName) {
_this.visible = false
let params = {
// sampleId: "426530",
// fileName: "CAX05_001-20230731_1528_S_FULL_37563.6.PHD"
sampleId: this.sampleId,
fileName: this.sampleData.fileName
}
getFileAction('/gamma/exportRadionuclideActivity', params).then(res => {
if (res.code && res.code == 500) {
this.$message.warning("This operation fails. Contact your system administrator")
} else {
const blob = new Blob([res], { type: "application/vnd.ms-excel" })
saveAs(blob, `${_this.fileName}`)
}
})
}
},
});
} else {
this.$message.warning("No downloadable data")
}
}
}
}
</script>

View File

@ -3,13 +3,15 @@
<a-spin :spinning="isLoading">
<a-table :columns="columns" :dataSource="list" :pagination="false" />
</a-spin>
<a-button slot="custom-footer" type="primary">Export to Excel</a-button>
<a-button slot="custom-footer" type="primary" @click="handleExportToExcel">Export to Excel</a-button>
</custom-modal>
</template>
<script>
import { getAction } from '@/api/manage'
import { getAction, getFileAction } from '@/api/manage'
import ModalMixin from '@/mixins/ModalMixin'
import SampleDataMixin from '@/views/spectrumAnalysis/SampleDataMixin'
import { saveAs } from 'file-saver';
const columns = [
{
@ -58,7 +60,7 @@ const columns = [
}
]
export default {
mixins: [ModalMixin],
mixins: [ModalMixin, SampleDataMixin],
props: {
sampleId: {
type: Number
@ -68,7 +70,8 @@ export default {
this.columns = columns
return {
isLoading: false,
list: []
list: [],
fileName: ''
}
},
methods: {
@ -92,6 +95,44 @@ export default {
beforeModalOpen() {
this.getData()
},
// Excel
handleExportToExcel() {
if (this.list.length > 0) {
let _this = this
this.$confirm({
title: 'Please enter file name',
content: h => <a-input v-model={_this.fileName} />,
okText: 'Cancle',
cancelText: 'Save',
okButtonProps: {style: {backgroundColor: "#b98326", color: "#fff", borderColor: "transparent"}},
cancelButtonProps: {style: {color: "#fff", backgroundColor: "#31aab0", borderColor: "transparent"}},
onOk() {
console.log('Cancel');
},
onCancel() {
if (_this.fileName) {
_this.visible = false
let params = {
// sampleId: "426530",
// fileName: "CAX05_001-20230731_1528_S_FULL_37563.6.PHD"
sampleId: this.sampleId,
fileName: this.sampleData.fileName
}
getFileAction('/gamma/exportQCResult', params).then(res => {
if (res.code && res.code == 500) {
this.$message.warning("This operation fails. Contact your system administrator")
} else {
const blob = new Blob([res], { type: "application/vnd.ms-excel" })
saveAs(blob, `${_this.fileName}`)
}
})
}
},
});
} else {
this.$message.warning("No downloadable data")
}
}
}
}

View File

@ -15,7 +15,7 @@
</a-spin>
<div slot="custom-footer" style="text-align: center;">
<a-space :size="20">
<a-button type="primary">Export to Excel</a-button>
<a-button type="primary" @click="handleExportToExcel">Export to Excel</a-button>
<a-button @click="visible = false">Close</a-button>
</a-space>
</div>
@ -23,8 +23,10 @@
</template>
<script>
import { getAction } from '@/api/manage'
import { getAction, getFileAction } from '@/api/manage'
import ModalMixin from '@/mixins/ModalMixin'
import SampleDataMixin from '@/views/spectrumAnalysis/SampleDataMixin'
import { saveAs } from 'file-saver';
const columns = [
{
@ -86,7 +88,7 @@ const columns = [
]
export default {
mixins: [ModalMixin],
mixins: [ModalMixin, SampleDataMixin],
props: {
sampleId: {
type: Number
@ -96,7 +98,8 @@ export default {
this.columns = columns
return {
isLoading: false,
data: {}
data: {},
fileName: ''
}
},
methods: {
@ -121,6 +124,44 @@ export default {
beforeModalOpen() {
this.data = {}
this.getInfo()
},
// Excel
handleExportToExcel() {
if (Object.keys(this.data).length > 0) {
let _this = this
this.$confirm({
title: 'Please enter file name',
content: h => <a-input v-model={_this.fileName} />,
okText: 'Cancle',
cancelText: 'Save',
okButtonProps: {style: {backgroundColor: "#b98326", color: "#fff", borderColor: "transparent"}},
cancelButtonProps: {style: {color: "#fff", backgroundColor: "#31aab0", borderColor: "transparent"}},
onOk() {
console.log('Cancel');
},
onCancel() {
if (_this.fileName) {
_this.visible = false
let params = {
// sampleId: "426530",
// fileName: "CAX05_001-20230731_1528_S_FULL_37563.6.PHD"
sampleId: this.sampleId,
fileName: this.sampleData.fileName
}
getFileAction('/gamma/exportSampleInformation', params).then(res => {
if (res.code && res.code == 500) {
this.$message.warning("This operation fails. Contact your system administrator")
} else {
const blob = new Blob([res], { type: "application/vnd.ms-excel" })
saveAs(blob, `${_this.fileName}`)
}
})
}
},
});
} else {
this.$message.warning("No downloadable data")
}
}
}
}

View File

@ -31,7 +31,9 @@
<script>
import ModalMixin from '@/mixins/ModalMixin'
import { getAction } from '@/api/manage'
import SampleDataMixin from '@/views/spectrumAnalysis/SampleDataMixin'
import { getAction, getFileAction } from '@/api/manage'
import { saveAs } from 'file-saver';
const columns = [
{
@ -80,7 +82,7 @@ const columns = [
}
]
export default {
mixins: [ModalMixin],
mixins: [ModalMixin, SampleDataMixin],
props: {
sampleId: {
type: Number
@ -92,7 +94,8 @@ export default {
list: [],
compareList: [],
compareVisible: false, //
isLoading: false
isLoading: false,
fileName: ''
}
},
methods: {
@ -125,7 +128,43 @@ export default {
},
// Excel
handleExportToExcel() {}
handleExportToExcel() {
if (this.list.length > 0) {
let _this = this
this.$confirm({
title: 'Please enter file name',
content: h => <a-input v-model={_this.fileName} />,
okText: 'Cancle',
cancelText: 'Save',
okButtonProps: {style: {backgroundColor: "#b98326", color: "#fff", borderColor: "transparent"}},
cancelButtonProps: {style: {color: "#fff", backgroundColor: "#31aab0", borderColor: "transparent"}},
onOk() {
console.log('Cancel');
},
onCancel() {
if (_this.fileName) {
_this.visible = false
let params = {
// sampleId: "426530",
// fileName: "CAX05_001-20230731_1528_S_FULL_37563.6.PHD"
sampleId: this.sampleId,
fileName: this.sampleData.fileName
}
getFileAction('/gamma/exportPeakInformation', params).then(res => {
if (res.code && res.code == 500) {
this.$message.warning("This operation fails. Contact your system administrator")
} else {
const blob = new Blob([res], { type: "application/vnd.ms-excel" })
saveAs(blob, `${_this.fileName}`)
}
})
}
},
});
} else {
this.$message.warning("No downloadable data")
}
}
}
}
</script>