feat:krosum弹窗完成分析以及右侧table数据渲染功能
This commit is contained in:
parent
8835f93580
commit
489fd642fb
|
@ -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: {
|
||||
|
|
Loading…
Reference in New Issue
Block a user