feat:krosum弹窗完成分析以及右侧table数据渲染功能

This commit is contained in:
xiaoguangbin 2023-10-20 18:09:51 +08:00
parent 8835f93580
commit 489fd642fb

View File

@ -148,6 +148,7 @@
import ModalMixin from '@/mixins/ModalMixin'
import TitleOverBorder from '../TitleOverBorder.vue'
import { getAction, postAction } from '@/api/manage'
import * as XLSX from 'xlsx';
const columns = [
{
@ -183,15 +184,18 @@ const columns = [
const outputColumns = [
{
title: 'Energy',
dataIndex: 'energy'
dataIndex: 'energy',
customRender: (text) => parseFloat(Number(text).toPrecision(6))
},
{
title: 'Correct Factor',
dataIndex: 'correctFactor'
dataIndex: 'correctFactor',
customRender: (text) => parseFloat(Number(text).toPrecision(6))
},
{
title: 'Uncertainty(%)',
dataIndex: 'uncertainty'
dataIndex: 'uncertainty',
customRender: (text) => parseFloat(Number(text).toPrecision(6))
}
]
export default {
@ -210,7 +214,10 @@ export default {
selectedItem: {}, // output
outputTableList: [], // output
filterWord: '' //
filterWord: '', //
fileName: '', // save excel name
analyseData: {} //
}
},
methods: {
@ -264,6 +271,7 @@ export default {
...this.efficiency,
energys: this.list.map(item => item.energy)
})
console.log(success);
if (success) {
this.list = result
} else {
@ -275,8 +283,22 @@ export default {
},
//
handleAnalyze() {
async handleAnalyze() {
console.log('%c [ 分析 ]-178', 'font-size:13px; background:pink; color:#bf2c9f;')
try {
this.isLoading = true
const { success, result, message } = await postAction('/gamma/KorSumAnalyse', this.list)
this.isLoading = false
if (success) {
this.analyseData = result
console.log(result);
} else {
this.$message.error(message)
}
} catch (error) {
this.isLoading = false;
console.error(error)
}
},
// 退
@ -286,12 +308,66 @@ export default {
// output
handleOutputItemClick(item) {
if(!this.analyseData) {
this.$message.error("Analyse Fail!")
return false;
}
this.selectedItem = item
this.outputTableList = [];
//
let data = this.analyseData[this.selectedItem]
if(!data || data.energy.length < 1) {
this.$message.error("Analyse Fail!")
return false;
}
let result = [];
for(let i = 0; i < data.energy.length; i++ ) {
//
let obj = {
"energy": data.energy[i],
"correctFactor" : data.factor[i],
"uncertainty" : (data.factor[i] - 1) / 10 * 100
}
result.push(obj);
}
this.outputTableList = result;
},
// excel
handleExport() {
console.log('%c [ 导出到excel ]-246', 'font-size:13px; background:pink; color:#bf2c9f;')
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() {
console.log(_this.fileName);
if (_this.fileName) {
// saveAs(blob, `${_this.fileName}`)
// 簿
const workbook = XLSX.utils.book_new();
//
const worksheet = XLSX.utils.json_to_sheet(_this.outputTableList);
// 簿
XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1');
// Excel
XLSX.writeFile(workbook, _this.fileName + ".xlsx");
}
},
})
}
},
computed: {