Gamma 导出excel功能开发
This commit is contained in:
parent
da3e09e847
commit
3b516367d3
|
@ -1,6 +1,7 @@
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import { axios } from '@/utils/request'
|
import { axios } from '@/utils/request'
|
||||||
import signMd5Utils from '@/utils/encryption/signMd5Utils'
|
import signMd5Utils from '@/utils/encryption/signMd5Utils'
|
||||||
|
import qs from "qs";
|
||||||
|
|
||||||
const api = {
|
const api = {
|
||||||
user: '/mock/api/user',
|
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
|
//deleteAction
|
||||||
export function deleteAction(url,parameter) {
|
export function deleteAction(url,parameter) {
|
||||||
return axios({
|
return axios({
|
||||||
|
|
|
@ -46,8 +46,10 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { getAction } from '@/api/manage'
|
import { getAction, getFileAction } from '@/api/manage'
|
||||||
import ModalMixin from '@/mixins/ModalMixin'
|
import ModalMixin from '@/mixins/ModalMixin'
|
||||||
|
import SampleDataMixin from '@/views/spectrumAnalysis/SampleDataMixin'
|
||||||
|
import { saveAs } from 'file-saver';
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
|
@ -113,7 +115,7 @@ const columns = [
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
export default {
|
export default {
|
||||||
mixins: [ModalMixin],
|
mixins: [ModalMixin, SampleDataMixin],
|
||||||
props: {
|
props: {
|
||||||
sampleId: {
|
sampleId: {
|
||||||
type: Number
|
type: Number
|
||||||
|
@ -130,7 +132,8 @@ export default {
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
|
|
||||||
list: [],
|
list: [],
|
||||||
compareList: []
|
compareList: [],
|
||||||
|
fileName: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -166,7 +169,43 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
// 导出到Excel
|
// 导出到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>
|
</script>
|
||||||
|
|
|
@ -3,13 +3,15 @@
|
||||||
<a-spin :spinning="isLoading">
|
<a-spin :spinning="isLoading">
|
||||||
<a-table :columns="columns" :dataSource="list" :pagination="false" />
|
<a-table :columns="columns" :dataSource="list" :pagination="false" />
|
||||||
</a-spin>
|
</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>
|
</custom-modal>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { getAction } from '@/api/manage'
|
import { getAction, getFileAction } from '@/api/manage'
|
||||||
import ModalMixin from '@/mixins/ModalMixin'
|
import ModalMixin from '@/mixins/ModalMixin'
|
||||||
|
import SampleDataMixin from '@/views/spectrumAnalysis/SampleDataMixin'
|
||||||
|
import { saveAs } from 'file-saver';
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
|
@ -58,7 +60,7 @@ const columns = [
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
export default {
|
export default {
|
||||||
mixins: [ModalMixin],
|
mixins: [ModalMixin, SampleDataMixin],
|
||||||
props: {
|
props: {
|
||||||
sampleId: {
|
sampleId: {
|
||||||
type: Number
|
type: Number
|
||||||
|
@ -68,7 +70,8 @@ export default {
|
||||||
this.columns = columns
|
this.columns = columns
|
||||||
return {
|
return {
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
list: []
|
list: [],
|
||||||
|
fileName: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -92,6 +95,44 @@ export default {
|
||||||
|
|
||||||
beforeModalOpen() {
|
beforeModalOpen() {
|
||||||
this.getData()
|
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")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
</a-spin>
|
</a-spin>
|
||||||
<div slot="custom-footer" style="text-align: center;">
|
<div slot="custom-footer" style="text-align: center;">
|
||||||
<a-space :size="20">
|
<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-button @click="visible = false">Close</a-button>
|
||||||
</a-space>
|
</a-space>
|
||||||
</div>
|
</div>
|
||||||
|
@ -23,8 +23,10 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { getAction } from '@/api/manage'
|
import { getAction, getFileAction } from '@/api/manage'
|
||||||
import ModalMixin from '@/mixins/ModalMixin'
|
import ModalMixin from '@/mixins/ModalMixin'
|
||||||
|
import SampleDataMixin from '@/views/spectrumAnalysis/SampleDataMixin'
|
||||||
|
import { saveAs } from 'file-saver';
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
|
@ -86,7 +88,7 @@ const columns = [
|
||||||
]
|
]
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mixins: [ModalMixin],
|
mixins: [ModalMixin, SampleDataMixin],
|
||||||
props: {
|
props: {
|
||||||
sampleId: {
|
sampleId: {
|
||||||
type: Number
|
type: Number
|
||||||
|
@ -96,7 +98,8 @@ export default {
|
||||||
this.columns = columns
|
this.columns = columns
|
||||||
return {
|
return {
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
data: {}
|
data: {},
|
||||||
|
fileName: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -121,6 +124,44 @@ export default {
|
||||||
beforeModalOpen() {
|
beforeModalOpen() {
|
||||||
this.data = {}
|
this.data = {}
|
||||||
this.getInfo()
|
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")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,9 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import ModalMixin from '@/mixins/ModalMixin'
|
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 = [
|
const columns = [
|
||||||
{
|
{
|
||||||
|
@ -80,7 +82,7 @@ const columns = [
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
export default {
|
export default {
|
||||||
mixins: [ModalMixin],
|
mixins: [ModalMixin, SampleDataMixin],
|
||||||
props: {
|
props: {
|
||||||
sampleId: {
|
sampleId: {
|
||||||
type: Number
|
type: Number
|
||||||
|
@ -92,7 +94,8 @@ export default {
|
||||||
list: [],
|
list: [],
|
||||||
compareList: [],
|
compareList: [],
|
||||||
compareVisible: false, // 是否显示比较
|
compareVisible: false, // 是否显示比较
|
||||||
isLoading: false
|
isLoading: false,
|
||||||
|
fileName: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -125,7 +128,43 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
// 导出到Excel
|
// 导出到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>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user