完成beta 中excel 的导出功能
This commit is contained in:
parent
3b516367d3
commit
1c27c14564
|
@ -80,6 +80,7 @@ export default {
|
|||
}
|
||||
},
|
||||
handleOk() {
|
||||
this.fileName=""
|
||||
if (this.content) {
|
||||
let strData = new Blob([this.content], { type: 'text/plain;charset=utf-8' });
|
||||
// if (this.type == 1 || this.type == 3) {
|
||||
|
|
|
@ -54,6 +54,7 @@ export default {
|
|||
},
|
||||
|
||||
handleOk() {
|
||||
this.fileName=""
|
||||
if (this.content) {
|
||||
let _this = this
|
||||
let strData = new Blob([this.content], { type: 'text/plain;charset=utf-8' });
|
||||
|
|
|
@ -3,15 +3,17 @@
|
|||
<a-table :loading="isLoading" :columns="columns" :dataSource="list" :pagination="false"> </a-table>
|
||||
<a-space slot="custom-footer" :size="20">
|
||||
<a-button type="primary" @click="SaveText">Save Text</a-button>
|
||||
<a-button type="primary">Save Excel</a-button>
|
||||
<a-button type="primary" @click="handleExportToExcel">Save Excel</a-button>
|
||||
<a-button type="primary" @click="visible = false">Cancel</a-button>
|
||||
</a-space>
|
||||
</custom-modal>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getAction } from '@/api/manage'
|
||||
import { getAction, getFileAction } from '@/api/manage'
|
||||
import ModalMixin from '@/mixins/ModalMixin'
|
||||
import { saveAs } from 'file-saver';
|
||||
import SampleDataMixin from '@/views/spectrumAnalysis/SampleDataMixin'
|
||||
|
||||
const columns = [
|
||||
{
|
||||
|
@ -47,7 +49,7 @@ const columns = [
|
|||
]
|
||||
|
||||
export default {
|
||||
mixins: [ModalMixin],
|
||||
mixins: [ModalMixin, SampleDataMixin],
|
||||
props: {
|
||||
sampleId: {
|
||||
type: Number
|
||||
|
@ -59,7 +61,8 @@ export default {
|
|||
list: [],
|
||||
isLoading: false,
|
||||
text: '',
|
||||
fileName: ''
|
||||
fileName: '',
|
||||
fileName_excel: ''
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
@ -128,6 +131,7 @@ export default {
|
|||
this.getData()
|
||||
},
|
||||
SaveText() {
|
||||
this.fileName=""
|
||||
this.text = `#QC RESULT\n${this.columns[0].title} ${this.columns[1].title} ${this.columns[2].title} ${this.columns[3].title}\n`
|
||||
this.list.forEach(item => {
|
||||
let str = ""
|
||||
|
@ -156,6 +160,43 @@ export default {
|
|||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
// 导出到Excel
|
||||
handleExportToExcel() {
|
||||
this.fileName_excel=""
|
||||
if (this.list.length>0) {
|
||||
let _this = this
|
||||
this.$confirm({
|
||||
title: 'Please enter file name',
|
||||
content: h => <a-input v-model={_this.fileName_excel} />,
|
||||
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_excel) {
|
||||
_this.visible = false
|
||||
let params = {
|
||||
sampleId: _this.sampleData.sampleId||"",
|
||||
fileName: _this.sampleData.fileName
|
||||
}
|
||||
getFileAction('/spectrumAnalysis/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_excel}`)
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
});
|
||||
} else {
|
||||
this.$message.warning("No downloadable data")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<div slot="custom-footer">
|
||||
<a-space :size="20">
|
||||
<a-button type="primary" @click="saveText">Save Text</a-button>
|
||||
<a-button type="primary">Save Excel</a-button>
|
||||
<a-button type="primary" @click="handleExportToExcel">Save Excel</a-button>
|
||||
<a-button @click="visible = false">Cancel</a-button>
|
||||
</a-space>
|
||||
</div>
|
||||
|
@ -15,11 +15,12 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import { getAction } from '@/api/manage'
|
||||
import { getAction, getFileAction } from '@/api/manage'
|
||||
import ModalMixin from '@/mixins/ModalMixin'
|
||||
import { saveAs } from 'file-saver';
|
||||
import SampleDataMixin from '@/views/spectrumAnalysis/SampleDataMixin'
|
||||
export default {
|
||||
mixins: [ModalMixin],
|
||||
mixins: [ModalMixin, SampleDataMixin],
|
||||
props: {
|
||||
sampleId: {
|
||||
type: Number
|
||||
|
@ -29,7 +30,8 @@ export default {
|
|||
return {
|
||||
content: '',
|
||||
isLoading: true,
|
||||
fileName: ''
|
||||
fileName: '',
|
||||
fileName_excel: ''
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
@ -60,6 +62,7 @@ export default {
|
|||
}
|
||||
},
|
||||
saveText() {
|
||||
this.fileName=""
|
||||
if (this.content) {
|
||||
let strData = new Blob([this.content], { type: 'text/plain;charset=utf-8' });
|
||||
// saveAs(strData, `Beta-View Sample Infomation.txt`)
|
||||
|
@ -84,6 +87,43 @@ export default {
|
|||
} else {
|
||||
this.$message.warning("No data can be saved!")
|
||||
}
|
||||
},
|
||||
// 导出到Excel
|
||||
handleExportToExcel() {
|
||||
this.fileName_excel=""
|
||||
if (this.content) {
|
||||
let _this = this
|
||||
this.$confirm({
|
||||
title: 'Please enter file name',
|
||||
content: h => <a-input v-model={_this.fileName_excel} />,
|
||||
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_excel) {
|
||||
_this.visible = false
|
||||
let params = {
|
||||
sampleId: _this.sampleData.sampleId||"",
|
||||
fileName: _this.sampleData.fileName
|
||||
}
|
||||
getFileAction('/spectrumAnalysis/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_excel}`)
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
});
|
||||
} else {
|
||||
this.$message.warning("No downloadable data")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,6 +76,7 @@ export default {
|
|||
this.currTab = key
|
||||
},
|
||||
handleOk() {
|
||||
this.fileName=""
|
||||
let text = ""
|
||||
if (this.currTab == 1) {
|
||||
text=this.content.sample.join('\n')
|
||||
|
|
|
@ -52,6 +52,7 @@ export default {
|
|||
})
|
||||
},
|
||||
handleOk() {
|
||||
this.fileName=""
|
||||
if (this.text) {
|
||||
let strData = new Blob([this.text], { type: 'text/plain;charset=utf-8' });
|
||||
// saveAs(strData, `GammaViewer Log.txt`)
|
||||
|
|
|
@ -170,6 +170,7 @@ export default {
|
|||
|
||||
// 导出到Excel
|
||||
handleExportToExcel() {
|
||||
this.fileName=""
|
||||
if (this.list.length > 0) {
|
||||
let _this = this
|
||||
this.$confirm({
|
||||
|
@ -188,8 +189,8 @@ export default {
|
|||
let params = {
|
||||
// sampleId: "426530",
|
||||
// fileName: "CAX05_001-20230731_1528_S_FULL_37563.6.PHD"
|
||||
sampleId: this.sampleId,
|
||||
fileName: this.sampleData.fileName
|
||||
sampleId: _this.sampleId,
|
||||
fileName: _this.sampleData.fileName
|
||||
}
|
||||
getFileAction('/gamma/exportRadionuclideActivity', params).then(res => {
|
||||
if (res.code && res.code == 500) {
|
||||
|
|
|
@ -98,6 +98,7 @@ export default {
|
|||
},
|
||||
// 导出到Excel
|
||||
handleExportToExcel() {
|
||||
this.fileName=""
|
||||
if (this.list.length > 0) {
|
||||
let _this = this
|
||||
this.$confirm({
|
||||
|
@ -116,8 +117,8 @@ export default {
|
|||
let params = {
|
||||
// sampleId: "426530",
|
||||
// fileName: "CAX05_001-20230731_1528_S_FULL_37563.6.PHD"
|
||||
sampleId: this.sampleId,
|
||||
fileName: this.sampleData.fileName
|
||||
sampleId: _this.sampleId,
|
||||
fileName: _this.sampleData.fileName
|
||||
}
|
||||
getFileAction('/gamma/exportQCResult', params).then(res => {
|
||||
if (res.code && res.code == 500) {
|
||||
|
|
|
@ -127,6 +127,7 @@ export default {
|
|||
},
|
||||
// 导出到Excel
|
||||
handleExportToExcel() {
|
||||
this.fileName=""
|
||||
if (Object.keys(this.data).length > 0) {
|
||||
let _this = this
|
||||
this.$confirm({
|
||||
|
|
|
@ -129,6 +129,7 @@ export default {
|
|||
|
||||
// 导出到Excel
|
||||
handleExportToExcel() {
|
||||
this.fileName=""
|
||||
if (this.list.length > 0) {
|
||||
let _this = this
|
||||
this.$confirm({
|
||||
|
@ -147,8 +148,8 @@ export default {
|
|||
let params = {
|
||||
// sampleId: "426530",
|
||||
// fileName: "CAX05_001-20230731_1528_S_FULL_37563.6.PHD"
|
||||
sampleId: this.sampleId,
|
||||
fileName: this.sampleData.fileName
|
||||
sampleId: _this.sampleId,
|
||||
fileName: _this.sampleData.fileName
|
||||
}
|
||||
getFileAction('/gamma/exportPeakInformation', params).then(res => {
|
||||
if (res.code && res.code == 500) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user