Commit 061f6de1 authored by whlviolin's avatar whlviolin

增加线性回归和lasso回归两种方式

parent ecd30789
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<!-- <template v-for="ch in item.child">--> <!-- <template v-for="ch in item.child">-->
<div class="algo-item" style="font-size:13px;height:26px; line-height:26px;" @click="getAnalysisResultDetail(item)" <div class="algo-item" style="font-size:13px;height:26px; line-height:26px;" @click="getAnalysisResultDetail(item)"
:class="item.id == selectAlgo.id?'active-item':''"> :class="item.id == selectAlgo.id?'active-item':''">
<div style="margin-left:38px;white-space: nowrap;text-overflow:ellipsis; overflow:hidden;" :title="item.name">{{item.name}}</div> <div style="margin-left:20px;white-space: nowrap;text-overflow:ellipsis; overflow:hidden;" :title="item.name">{{item.name}}</div>
</div> </div>
<!-- </template>--> <!-- </template>-->
...@@ -273,6 +273,74 @@ ...@@ -273,6 +273,74 @@
</div> </div>
</div> </div>
<div style="width:100%;display: flex; flex-direction: column;overflow:auto;overflow-scrolling: inherit" v-else-if="selectAlgo.key == 'LASSO'"> <!-- 这是回归模型定制的参数 -->
<div style="height:3%;line-height:41px; font-size:16px;font-weight:600">
<span style="margin-left:30px">{{selectAlgo.name}}</span>
</div>
<div style="height:7%;line-height:50px;margin-bottom:20px;">
<span style="margin-left:20px">{{selectAlgo.desc}}</span>
</div>
<div style="height: 87%; flex: 1;">
<div style="width: 100%; height:100%; display: flex;flex-direction: column;">
<div style="height:5%;line-height:40px;margin-left: 20px;">放入 [定量] 变量Y (变量数=1)</div>
<div style="width: 95%; height: 27%; overflow: scroll;border:1px dashed #cdcdcd;margin-top: 8px;margin-left: 20px;position: relative;">
<draggable class="mdc_right" :group="{name:'person'}" v-model="choose_args1" @start="dragItem"
@add="addItem">
<div v-for="(item,index) in choose_args1" v-bind:key="index" style="display: flex;position: relative;">
<div><span style="margin-left:20px">{{item.name}}</span></div>
<div class="del-entry" style="position: absolute;right: 10px;" @click="delEntry1(item)"><i class="el-icon-circle-close"></i></div>
</div>
</draggable>
</div>
<div style="height:5%;line-height:40px;margin-left: 20px;">放入 [定量] 或 [定类] 自变量X (变量数≥1)</div>
<div style="width: 95%;height: 27%; ;border:1px dashed #cdcdcd;overflow-y: auto;margin-top: 8px;margin-left: 20px;position: relative;">
<draggable class="mdc_right" :group="{name:'person'}" v-model="choose_args2" @start="dragItem"
@add="addItem">
<div v-for="(item,index) in choose_args2" v-bind:key="index" style="display: flex;position: relative;">
<div><span style="margin-left:20px">{{item.name}}</span></div>
<div class="del-entry" style="position: absolute;right: 10px;" @click="delEntry2(item)"><i class="el-icon-circle-close"></i></div>
</div>
</draggable>
</div>
</div>
</div>
</div>
<div style="width:100%;display: flex; flex-direction: column;overflow:auto;overflow-scrolling: inherit" v-else-if="selectAlgo.key == 'OLS'"> <!-- 这是回归模型定制的参数 -->
<div style="height:3%;line-height:41px; font-size:16px;font-weight:600">
<span style="margin-left:30px">{{selectAlgo.name}}</span>
</div>
<div style="height:7%;line-height:50px;margin-bottom:20px;">
<span style="margin-left:20px">{{selectAlgo.desc}}</span>
</div>
<div style="height: 87%; flex: 1;">
<div style="width: 100%; height:100%; display: flex;flex-direction: column;">
<div style="height:5%;line-height:40px;margin-left: 20px;">放入 [定量] 变量Y (变量数=1)</div>
<div style="width: 95%; height: 27%; overflow: scroll;border:1px dashed #cdcdcd;margin-top: 8px;margin-left: 20px;position: relative;">
<draggable class="mdc_right" :group="{name:'person'}" v-model="choose_args1" @start="dragItem"
@add="addItem">
<div v-for="(item,index) in choose_args1" v-bind:key="index" style="display: flex;position: relative;">
<div><span style="margin-left:20px">{{item.name}}</span></div>
<div class="del-entry" style="position: absolute;right: 10px;" @click="delEntry1(item)"><i class="el-icon-circle-close"></i></div>
</div>
</draggable>
</div>
<div style="height:5%;line-height:40px;margin-left: 20px;">放入 [定量] 或 [定类] 自变量X (变量数≥1)</div>
<div style="width: 95%;height: 27%; ;border:1px dashed #cdcdcd;overflow-y: auto;margin-top: 8px;margin-left: 20px;position: relative;">
<draggable class="mdc_right" :group="{name:'person'}" v-model="choose_args2" @start="dragItem"
@add="addItem">
<div v-for="(item,index) in choose_args2" v-bind:key="index" style="display: flex;position: relative;">
<div><span style="margin-left:20px">{{item.name}}</span></div>
<div class="del-entry" style="position: absolute;right: 10px;" @click="delEntry2(item)"><i class="el-icon-circle-close"></i></div>
</div>
</draggable>
</div>
</div>
</div>
</div>
<div style="width:100%;display: flex; flex-direction: column;" v-else> <!-- 这是相关性分析定制的参数 --> <div style="width:100%;display: flex; flex-direction: column;" v-else> <!-- 这是相关性分析定制的参数 -->
<div style="height:41px;line-height:41px; font-size:16px;font-weight:600"> <div style="height:41px;line-height:41px; font-size:16px;font-weight:600">
<span style="margin-left:30px">{{selectAlgo.name}}</span> <span style="margin-left:30px">{{selectAlgo.name}}</span>
...@@ -306,14 +374,14 @@ ...@@ -306,14 +374,14 @@
</div> </div>
<div style="flex: 1;" v-if="hasResult"> <div style="flex: 1;" v-if="hasResult">
<component :is="selectAlgo.component" :algoName="selectAlgo.name" :algoRes="algoRes" :algoAllHeader="algoAllHeader"/> <component :is="selectAlgo.component" :algoName="selectAlgo.name" :algoRes="algoRes" :algoAllHeader="algoAllHeader" :algoParams = "algoParams"/>
</div> </div>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import { import {
runAlgo, getDataHeader, runDEAAlgo, readFile, getTOPSISList, getRSRList, getDEAList, getAHPList, createAnalysisResult, getAnalysisResult runAlgo, getDataHeader, runDEAAlgo, readFile, getTOPSISList, getRSRList, getDEAList, getAHPList,getLassoRegression, getOLSList, createAnalysisResult, getAnalysisResult
} from '@/api/data' } from '@/api/data'
import VabChart from '@/plugins/echarts' import VabChart from '@/plugins/echarts'
import draggable from 'vuedraggable' import draggable from 'vuedraggable'
...@@ -323,6 +391,9 @@ import dea from "./res/dea.vue" ...@@ -323,6 +391,9 @@ import dea from "./res/dea.vue"
import ahpsimple from "./res/ahpsimple.vue" import ahpsimple from "./res/ahpsimple.vue"
import topsis from "./res/topsis.vue" import topsis from "./res/topsis.vue"
import rsr from "./res/rsr.vue" import rsr from "./res/rsr.vue"
import lasso from "./res/lasso.vue"
import ols from "./res/ols.vue"
//import dea from "./res/dea.vue"
import uploadForm from "mockjs"; import uploadForm from "mockjs";
export default { export default {
name: 'Index', name: 'Index',
...@@ -334,6 +405,8 @@ export default { ...@@ -334,6 +405,8 @@ export default {
ahpsimple, ahpsimple,
topsis, topsis,
rsr, rsr,
lasso,
ols
}, },
data() { data() {
...@@ -342,6 +415,7 @@ export default { ...@@ -342,6 +415,7 @@ export default {
algoRes: {}, algoRes: {},
selectAlgo: {}, selectAlgo: {},
algoAllHeader:[], algoAllHeader:[],
algoParams:[],
project: {}, project: {},
AHPSimpleHeader:[], AHPSimpleHeader:[],
AHPSimpletableData:[], AHPSimpletableData:[],
...@@ -531,12 +605,20 @@ export default { ...@@ -531,12 +605,20 @@ export default {
"expand": false, "expand": false,
"child": [{ "child": [{
"id": '51', "id": '51',
"name": "预测与对象关联的连续值属性", "name": "Lasso回归",
"desc": "预测与对象关联的连续值属性", "desc": "Lasso回归",
"key": "deal1", "key": "LASSO",
"algo": "pearson", "algo": "LASSO",
"component": "res1" "component": "lasso"
} },
{
"id": '52',
"name": "线性回归(最小二乘法)",
"desc": "线性回归(最小二乘法)",
"key": "OLS",
"algo": "pearson",
"component": "ols"
},
] ]
}, },
{ {
...@@ -739,6 +821,7 @@ export default { ...@@ -739,6 +821,7 @@ export default {
}, },
createAnalysisResult(selectAlgo,algoRes){ createAnalysisResult(selectAlgo,algoRes){
debugger;
let args = this.choose_args1.concat(this.choose_args2).concat(this.choose_args3) let args = this.choose_args1.concat(this.choose_args2).concat(this.choose_args3)
let names = selectAlgo.name let names = selectAlgo.name
args.forEach(function(item) { args.forEach(function(item) {
...@@ -770,6 +853,7 @@ export default { ...@@ -770,6 +853,7 @@ export default {
console.log("选择算法") console.log("选择算法")
console.log(algo) console.log(algo)
this.selectAlgo = algo; this.selectAlgo = algo;
this.algoRes =algo;
this.hasResult = false; this.hasResult = false;
}, },
getAnalysisResultDetail(item){ getAnalysisResultDetail(item){
...@@ -869,6 +953,52 @@ export default { ...@@ -869,6 +953,52 @@ export default {
}) })
}, },
runLASSO(){
let index = this.choose_args3
if(index.length>0)
index = index[0]['name'].replace("\ufeff", "");
else
index = ""
let params = {
"fileName": this.project.fileName,
"positive": this.getArrayObjectStrValue(this.choose_args1),
"negative": this.getArrayObjectStrValue(this.choose_args2),
}
getLassoRegression(params).then(res => {
this.hasResult = true
this.algoRes = res.data;
this.algoParams.push(this.choose_args1)
this.algoParams.push(this.choose_args2)
debugger;
this.createAnalysisResult(this.selectAlgo, this.algoRes,this.choose_args1,this.choose_args2,this.choose_args3)
})
},
runOLS(){
debugger;
let index = this.choose_args3
if(index.length>0)
index = index[0]['name'].replace("\ufeff", "");
else
index = ""
let params = {
"fileName": this.project.fileName,
"positive": this.getArrayObjectStrValue(this.choose_args1),
"negative": this.getArrayObjectStrValue(this.choose_args2),
}
getOLSList(params).then(res => {
this.hasResult = true
this.algoRes = res.data;
debugger;
this.algoParams.push(this.choose_args1)
this.algoParams.push(this.choose_args2)
this.createAnalysisResult(this.selectAlgo, this.algoRes,this.choose_args1,this.choose_args2,this.choose_args3)
})
},
run() { run() {
if(this.selectAlgo.key == "DEA") { if(this.selectAlgo.key == "DEA") {
this.runDEA(); this.runDEA();
...@@ -878,6 +1008,10 @@ export default { ...@@ -878,6 +1008,10 @@ export default {
this.runTOPSIS(); this.runTOPSIS();
}else if(this.selectAlgo.key == "RSR"){ }else if(this.selectAlgo.key == "RSR"){
this.runRSR(); this.runRSR();
}else if(this.selectAlgo.key == "LASSO"){
this.runLASSO();
}else if(this.selectAlgo.key == "OLS"){
this.runOLS();
} }
else { else {
this.runCommon(); this.runCommon();
......
<template>
<div style="height:100%;width:100%">
<div style="height: 100%;position:relative;" >
<div style="height:41px;line-height:41px; font-size:16px;font-weight:600;border-bottom:1px solid #e3e3e3">
<span style="margin-left:30px">{{algoName}}</span>
</div>
<div v-if="loading" style="position: absolute; top: 41px; right:0px; left:0px; bottom:0px;overflow: scroll;">
<div style="padding-bottom: 100px;">
<div style="width: 100%; height:80px;margin:10px 30px;">
<span style="font-weight:600;font-size:14px">算法结果描述</span>
</div>
<div class="dynamicComp">
<div v-for="(item,idx) in compDataList">
<!-- <component :is="item.type"></component>-->
<div style="margin:30px">
<span style="font-weight:600;font-size:14px">{{item.name}}</span>
</div>
<div v-if="item.name=='模型结果图'">
<div style="height:400px; display: flex;flex-direction: column; align-content: center;justify-content: center; align-items: center;">
<vab-chart autoresize :options="fwl" :style="{'width': '100%', 'height':'100%'}" />
</div>
</div>
<div v-else>
<el-table
border
height="100%"
:data=decimalNumberPrecision(item.header,item.value)
:style="{'width': '100%','margin':'30px'}">
<template v-for="item1 in item.header">
<el-table-column
:prop="item1"
align="center"
:label="item1"
:sortable="true"
min-width="200">
</el-table-column>
</template>
</el-table>
</div>
<div style="margin:15px">
<div style="font-weight:600;font-size: 14px;margin:10px 15px;">图表说明:</div>
<div style="white-space: pre-wrap;font-size: 14px;margin:10px 15px;line-height:1.8">{{item.chartText}}</div>
</div>
<div style="margin:15px" v-if="item.displayAnalysisText==true">
<div style="font-weight:600;font-size: 14px;margin:10px 15px;">智能分析:</div>
<div style="white-space: pre-wrap;font-size: 14px;margin:10px 15px;line-height:1.8">{{item.analysisText}}</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import {getOptionByLasso, getOptionByDEA} from "@/utils/echartsUtil"
import * as echarts from 'echarts';
import VabChart from '@/plugins/echarts'
import {forEach} from "lodash/fp/_util";
//引入echarts
export default {
name: 'lasso',
props: {
algoName: {
},
algoRes: {
},
algoParams:{
},
},
components: {
VabChart
},
data() {
return {
compDataList:[],
fwl: {},
quadrant:{},
displayAnalysisText: false,
loading: false,
}
},
mounted() {
debugger;
this.initData();
},
methods: {
initData() {
debugger;
let data=JSON.parse(this.algoRes)
console.log(this.algoRes)
let params = []
this.algoParams.forEach(function(algoParam) {
algoParam.forEach(function (param) {
params.push(param["name"])
})
});
params.unshift("截距");
this.loading = true;
let newHeader=[]
for(let i in data) {
let item = data[i]
let header = Object.keys(item.value)
if(item.name.indexOf('模型系数表') >= 0 || item.name.indexOf('模型结果预测') >= 0){
let data1 =this.resultToJsonObjectArray(header, item.value, params)
if(item.name.indexOf('模型系数表') >= 0){
item["displayAnalysisText"] =true;
}
item['header'] = header
item['value'] = data1
this.compDataList.push(item)
}
if(item.name.indexOf('模型结果图') >= 0){
this.fwl =getOptionByLasso(item)
this.compDataList.push(item)
}
if(item.text["图表说明"]!==undefined){
item["chartText"]=item.text["图表说明"].replaceAll('\n','\n● ')
item["analysisText"]=item.text["智能分析"].replaceAll('\n','\n● ')
}else{
item["chartText"]=item.text.replaceAll('\n','\n● ')
}
}
},
decimalNumberPrecision(headers, datas){
datas.forEach(function(data) {
headers.forEach(function (header) {
let value = data[header];
if (typeof value === 'number')
data[header] = value.toFixed(3)
});
});
return datas
},
resultToJsonObjectArray(keys, values, params) {
let rows = [];
let p = values[keys[0]];
let indexs = [];
for(let m = 0; m<p.length; m++){
if(params.indexOf(p[m])>-1){
indexs.push(m);
}
}
let item = values[keys[1]]
for (let j = 0; j < Object.keys(item).length; j++) {
if(indexs.indexOf(j)>-1){
let key = Object.keys(item)[j]
let row = {}
for (let i = 0; i < keys.length; i++) {
if(keys[i]== "R²"){
row[keys[i]] = values["R²"]
}else{
let key1 = keys[i];
let value = values[key1][key];
row[key1] =value
}
}
rows.push(row)
}
}
return rows;
},
}
}
</script>
<style scoped>
</style>
<template>
<div style="height:100%;width:100%">
<div style="height: 100%;position:relative;" >
<div style="height:41px;line-height:41px; font-size:16px;font-weight:600;border-bottom:1px solid #e3e3e3">
<span style="margin-left:30px">{{algoName}}</span>
</div>
<div v-if="loading" style="position: absolute; top: 41px; right:0px; left:0px; bottom:0px;overflow: scroll;">
<div style="padding-bottom: 100px;">
<div style="width: 100%; height:80px;margin:10px 30px;">
<span style="font-weight:600;font-size:14px">算法结果描述</span>
</div>
<div class="dynamicComp">
<div v-for="(item,idx) in compDataList">
<!-- <component :is="item.type"></component>-->
<div style="margin:30px">
<span style="font-weight:600;font-size:14px">{{item.name}}</span>
</div>
<div v-if="item.name=='拟合效果图'">
<div style="height:400px; display: flex;flex-direction: column; align-content: center;justify-content: center; align-items: center;">
<vab-chart autoresize :options="fwl" :style="{'width': '100%', 'height':'100%'}" />
</div>
</div>
<div v-else-if="item.name=='模型结果预测'">
<el-table
border
height="100%"
:data=decimalNumberPrecision(item.header,item.value)
:style="{'width': '100%','margin':'30px'}">
<template v-for="item1 in item.header">
<el-table-column
:prop="item1"
align="center"
:label="item1"
:sortable="true"
min-width="200">
</el-table-column>
</template>
</el-table>
</div>
<div v-else>
<el-table
ref="overTargetDetailsTable2222"
:data="rows"
border
:header-cell-style="spanHeader2"
:span-method="spanMethod2">
<el-table-column align="center" :label= "spanheaderfirst">
<el-table-column align="center" height ="10px" prop="intercept and coef name" label="" fixed width="100" />
<el-table-column align="center" :label= "unStandardizedCoefficient">
<el-table-column align="center" height ="10px" label="B" prop="B"></el-table-column>
<el-table-column align="center" height ="10px" label="标准差" prop="标准差"></el-table-column>
</el-table-column>
<el-table-column align="center" :label= "standardizedCoefficient">
<el-table-column align="center" height ="10px" label="Beta" prop="Beta"></el-table-column>
</el-table-column>
<el-table-column align="center" height ="10px" label="t" prop="t" fixed></el-table-column>
<el-table-column align="center" height ="10px" label="P" prop="P" fixed></el-table-column>
<el-table-column align="center" height ="10px" label="VIF" prop="VIF" fixed></el-table-column>
<el-table-column align="center" label="R²" prop="R**2" fixed />
<el-table-column align="center" label="调整R²" prop="调整R**2" fixed />
<el-table-column align="center" label="F" prop="F" fixed />
</el-table-column>
</el-table>
</div>
<div style="margin:15px">
<div style="font-weight:600;font-size: 14px;margin:10px 15px;">图表说明:</div>
<div style="white-space: pre-wrap;font-size: 14px;margin:10px 15px;line-height:1.8">{{item.chartText}}</div>
</div>
<div style="margin:15px" v-if="item.displayAnalysisText==true">
<div style="font-weight:600;font-size: 14px;margin:10px 15px;">智能分析:</div>
<div style="white-space: pre-wrap;font-size: 14px;margin:10px 15px;line-height:1.8">{{item.analysisText}}</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import {getOptionByLasso, getOptionByDEA} from "@/utils/echartsUtil"
import * as echarts from 'echarts';
import VabChart from '@/plugins/echarts'
import {forEach} from "lodash/fp/_util";
//引入echarts
export default {
name: 'lasso',
props: {
algoName: {
},
algoRes: {
},
algoParams: {
}
},
components: {
VabChart
},
data() {
return {
compDataList:[],
fwl: {},
quadrant:{},
displayAnalysisText: false,
loading: false,
spanheaderfirst:'线性回归分析结果 n=',
unStandardizedCoefficient:'非标准化系数',
standardizedCoefficient:'标准化系数',
spanbottom:'',
rows: [],
rowcount:0,
params:[],
}
},
mounted() {
debugger;
this.initData();
},
methods: {
initData() {
debugger;
let data=JSON.parse(this.algoRes)
console.log(this.algoRes)
let params = []
this.algoParams.forEach(function(algoParam) {
algoParam.forEach(function (param) {
params.push(param["name"])
})
});
params.unshift("常数");
this.params = params;
this.loading = true;
let newHeader=[]
for(let i in data) {
let item = data[i]
let header = Object.keys(item.value)
if(item.name.indexOf('线性回归分析结果表') >= 0 ){
let data1 =this.jsonResultToData(header, item.value, params)
if(item.name.indexOf('线性回归分析结果表') >= 0){
item["displayAnalysisText"] =true;
}
item['header'] = header
item['value'] = data1
this.compDataList.push(item)
}
if(item.name.indexOf('模型结果预测') >= 0){
let data1 =this.resultToJsonObjectArray(header, item.value, params)
item['header'] = header
item['value'] = data1
this.compDataList.push(item)
}
if(item.name.indexOf('拟合效果图') >= 0){
this.fwl =getOptionByLasso(item)
this.compDataList.push(item)
}
if(item.text["图表说明"]!==undefined){
item["chartText"]=item.text["图表说明"].replaceAll('\n','\n● ')
item["analysisText"]=item.text["智能分析"].replaceAll('\n','\n● ')
}else{
item["chartText"]=item.text.replaceAll('\n','\n● ')
}
}
},
decimalNumberPrecision(headers, datas){
datas.forEach(function(data) {
headers.forEach(function (header) {
let value = data[header];
if (typeof value === 'number')
data[header] = value.toFixed(3)
});
});
return datas
},
decimalNumberByValue(value){
let returnValue;
if (Array.isArray(value)){
returnValue = [];
value.forEach(function(v) {
if(typeof v === 'number')
returnValue.push(v.toFixed(3));
else
returnValue.push(v);
});
return returnValue;
}
if (typeof value === 'number')
return value.toFixed(3)
return value;
},
jsonResultToData(keys, values, params){
let rows = [];
let row = {};
let rowcount = 0;
let p = values["intercept and coef name"];
let indexs = [];
for (let m = 0; m < p.length; m++) {
if (params.indexOf(p[m]) > -1) {
indexs.push(m);
}
}
for (let i = 0; i < keys.length; i++) {
if(keys[i]== "n" || keys[i]=='因变量'){
this.spanheaderfirst = "线性回归分析结果 n= " + values["n"];
this.spanbottom = "因变量:"+ this.decimalNumberByValue(values["因变量"]);
}else if(keys[i]== "intercept and coef name"){
let key1 = keys[i];
let value = values[key1];
row[key1] =value;
rowcount = value.length;
}else if(keys[i]== this.standardizedCoefficient || keys[i]== this.unStandardizedCoefficient){
let aakeys = Object.keys(values[keys[i]]);
for (let j = 0; j < aakeys.length; j++) {
let aakey = aakeys[j];
let value = values[keys[i]][aakey];
row[aakey] = this.pushToArray(rowcount, value.length, value);
}
}else if(keys[i]== "F"){
let FKeys = Object.keys(values[keys[i]])
let fvalue = "";
for (let j = 0; j < FKeys.length; j++) {
let fkey = FKeys[j];
fvalue = fvalue + fkey + "=" + this.decimalNumberByValue(values[keys[i]][fkey]) +" ";
}
row[keys[i]] = this.pushToArray(rowcount, 0 ,fvalue);
}else if(keys[i]== "调整R**2" || keys[i]== "R**2"){
let key1 = keys[i];
let value = values[key1];
row[key1] =this.pushToArray(rowcount, 0 ,value);
}
else {
let key1 = keys[i];
let value = values[key1];
row[key1] = this.pushToArray(rowcount, value.length, value);
}
}
for(let n = 0; n < rowcount; n++) {
if(indexs.indexOf(n)>-1) {
let keys = Object.keys(row);
let rrow = {};
for (let m = 0; m < keys.length; m++) {
let key = keys[m]
rrow[key] = row[key][n]
}
rows.push(rrow);
}
}
rows.push({"intercept and coef name":this.spanbottom})
this.rows = rows;
this.rowcount = rowcount;
},
pushToArray(rowcount, selfcount, valueOrArray){
let updateArray = []
if(selfcount<rowcount && selfcount != 0){
valueOrArray.unshift("--");
return this.decimalNumberByValue(valueOrArray);
}else{
if(selfcount == 0){
for(let i = 0 ;i<rowcount ; i++)
updateArray.push(this.decimalNumberByValue(valueOrArray))
return updateArray;
}else{
return this.decimalNumberByValue(valueOrArray);
}
}
},
resultToJsonObjectArray(keys, values, params) {
let rows = [];
let p = values[keys[0]];
let indexs = [];
for(let m = 0; m<p.length; m++){
if(params.indexOf(p[m])>-1){
indexs.push(m);
}
}
let item = values[keys[1]]
for (let j = 0; j < Object.keys(item).length; j++) {
if(indexs.indexOf(j)>-1){
let key = Object.keys(item)[j]
let row = {}
for (let i = 0; i < keys.length; i++) {
if(keys[i]== "R²"){
row[keys[i]] = values["R²"]
}else{
let key1 = keys[i];
let value = values[key1][key];
row[key1] =value
}
}
rows.push(row)
}
}
return rows;
},
// resultToJsonObjectArray(keys, values) {
//
// let rows = [];
// let item = values[keys[1]];
// for (let j = 0; j < Object.keys(item).length; j++) {
// let key = Object.keys(item)[j];
// let row = {};
// for (let i = 0; i < keys.length; i++) {
// if(keys[i]== "R²"){
// row[keys[i]] = values["R²"];
// }else{
// let key1 = keys[i];
// let value = values[key1][key];
// row[key1] =value;
// }
// }
// rows.push(row);
// }
// return rows;
// },
/** 表头合并控制 */
spanHeader2({ row, column, rowIndex, columnIndex }) {
let comStyle = {};
// 1.1 让第0行的第0列跨2行
if (rowIndex === 1) {
// row[0].colSpan = 0; // 将表头第一列和第二列合并,内容展示为第二列的内容
// row[1].colSpan = 2;
// if (columnIndex === 0) { // 将表头第一列隐藏
// return {
// display: "none",
// };
// }
}
return comStyle;
},
/** 合并行、列 */
spanMethod2({ row, column, rowIndex, columnIndex }) {
if(rowIndex == this.params.length){
return {
rowspan: 1,
colspan: 10,
};
}
// if (columnIndex === 7 || columnIndex === 8 || columnIndex === 9) {
//
// const rowCell = this.rows.length;
// if (rowCell > 0) {
// const colCell = 1;
// return {
// rowspan: rowCell-1,
// colspan: colCell,
// };
// }
// }
},
}
}
</script>
<style scoped>
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment