|
@@ -80,7 +80,7 @@
|
|
|
</el-tooltip>
|
|
|
</label>
|
|
|
<el-select
|
|
|
- v-model="otherForm.nullValueWay"
|
|
|
+ v-model="nullValueForm.nullValueWay"
|
|
|
placeholder="请选择"
|
|
|
>
|
|
|
<el-option
|
|
@@ -101,11 +101,11 @@
|
|
|
</el-tooltip>
|
|
|
</label>
|
|
|
<el-select
|
|
|
- v-model="otherForm.maxNullWay"
|
|
|
+ v-model="nullValueForm.maxNullWay"
|
|
|
placeholder="请选择"
|
|
|
>
|
|
|
- <el-option label="等于0" value="等于0" />
|
|
|
- <el-option label="跳过空值" value="跳过空值" />
|
|
|
+ <el-option label="等于0" :value="1" />
|
|
|
+ <el-option label="跳过空值" :value="2" />
|
|
|
</el-select>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -124,7 +124,7 @@
|
|
|
|
|
|
<span v-if="formulaDateArr.length" class="date-section-text">{{formulaDateArr[formulaDateArr.length-1]}}(含)之后</span>
|
|
|
|
|
|
- <span class="example-txt">公式示例:A*0.5+B*C*1.2+120-MAX(A,B,C) 函数支持:MAX(),MIN(),ln(A),log(a,A)</span>
|
|
|
+ <span class="example-txt">公式示例:A*0.5+B*C*1.2+120-MAX(A,B,C) 函数支持:MAX(),MIN(),ln(A),log(a,A),abs(),exp(),pow(),round()</span>
|
|
|
</li>
|
|
|
|
|
|
<li class="formula-item" v-for="(item,index) in formulaList.slice(1)" :key="index+1">
|
|
@@ -268,7 +268,7 @@ export default {
|
|
|
showMaxNullDeal() {
|
|
|
let haveMaxOrMin = this.formulaList.some(_ => _.formula.toUpperCase().includes('MAX') || _.formula.toUpperCase().includes('MIN'))
|
|
|
|
|
|
- return haveMaxOrMin && this.otherForm.nullValueWay===5
|
|
|
+ return haveMaxOrMin && this.nullValueForm.nullValueWay===4
|
|
|
},
|
|
|
|
|
|
formulaDateArr() {
|
|
@@ -282,7 +282,10 @@ export default {
|
|
|
/* 回显 */
|
|
|
if (this.calulateList.length && newval) {
|
|
|
this.addList = _.cloneDeep(this.calulateList);
|
|
|
- this.formula = this.calulateForm.formula;
|
|
|
+ this.formulaList = JSON.parse(this.calulateForm.formula).map(_ => ({
|
|
|
+ formula: _.f,
|
|
|
+ date: _.d||''
|
|
|
+ }));
|
|
|
this.formData = {
|
|
|
targetName: this.calulateForm.targetName,
|
|
|
unit: this.calulateForm.unit,
|
|
@@ -290,6 +293,11 @@ export default {
|
|
|
frequency: this.calulateForm.frequency,
|
|
|
};
|
|
|
|
|
|
+ this.nullValueForm = {
|
|
|
+ nullValueWay: this.calulateForm.emptyType,
|
|
|
+ maxNullWay: this.calulateForm.maxEmptyType,
|
|
|
+ }
|
|
|
+
|
|
|
this.searchOptions = this.calulateList.map(item => ({
|
|
|
EdbInfoId: item.target,
|
|
|
EdbName: item.edb_name,
|
|
@@ -339,9 +347,8 @@ export default {
|
|
|
],
|
|
|
searchOptions: [],
|
|
|
formula: '', //计算公式
|
|
|
- formulaList: [
|
|
|
- { formula: '', },
|
|
|
- { formula: '',date: '' }
|
|
|
+ formulaList: [ //公式数组
|
|
|
+ { formula: '', }
|
|
|
],
|
|
|
dataloading: false,
|
|
|
formData: {
|
|
@@ -356,16 +363,16 @@ export default {
|
|
|
|
|
|
newestDate: '',
|
|
|
|
|
|
- otherForm: {
|
|
|
- nullValueWay: 1,
|
|
|
- maxNullWay: '等于0'
|
|
|
+ nullValueForm: {
|
|
|
+ nullValueWay: 0,
|
|
|
+ maxNullWay: 1
|
|
|
},//空值处理
|
|
|
nullWayOptions: [
|
|
|
- { label: '查找前后35天最近值',value: 1 },
|
|
|
- { label: '不计算',value: 2 },
|
|
|
- { label: '前值填充',value: 3 },
|
|
|
- { label: '后值填充',value: 4 },
|
|
|
- { label: '等于0',value: 5 },
|
|
|
+ { label: '查找前后35天最近值',value: 0 },
|
|
|
+ { label: '不计算',value: 1 },
|
|
|
+ { label: '前值填充',value: 2 },
|
|
|
+ { label: '后值填充',value: 3 },
|
|
|
+ { label: '等于0',value: 4 },
|
|
|
],
|
|
|
formTips: {
|
|
|
'null-val': `1、查找前后35天最近值:在参与计算的日期序列上某指标无值时,该指标往前/往后找距离最近的值作为当天的值进行计算,遍历允许跨年,往前最多35天,往后最多35天,<br>
|
|
@@ -497,25 +504,28 @@ export default {
|
|
|
this.getNewestDate();
|
|
|
},
|
|
|
async saveHandle() {
|
|
|
- if (!this.formula) return this.$message.warning('计算公式不能为空');
|
|
|
+ if (!this.formulaList[0].formula) return this.$message.warning('计算公式不能为空');
|
|
|
await this.$refs.diaForm.validate();
|
|
|
|
|
|
// 指标id数组
|
|
|
- let target_arr = this.addList
|
|
|
- .filter((item) => item.target)
|
|
|
- .map((item) => {
|
|
|
- return {
|
|
|
- EdbInfoId: item.target,
|
|
|
- FromTag: item.tag,
|
|
|
- };
|
|
|
- });
|
|
|
+ let EdbInfoIdArr = this.addList.filter((item) => item.target).map((item) => ({
|
|
|
+ EdbInfoId: item.target,
|
|
|
+ FromTag: item.tag,
|
|
|
+ }));
|
|
|
+
|
|
|
+ let formulaArr = this.formulaList.map(_ => ({f: _.formula,d: _.date}))
|
|
|
+
|
|
|
+ const { nullValueWay,maxNullWay } = this.nullValueForm;
|
|
|
+
|
|
|
let params = {
|
|
|
- CalculateFormula: this.formula,
|
|
|
+ CalculateFormula: JSON.stringify(formulaArr),
|
|
|
ClassifyId: this.formData.menu[this.formData.menu.length - 1] || 0,
|
|
|
EdbName: this.formData.targetName,
|
|
|
Frequency: this.formData.frequency,
|
|
|
Unit: this.formData.unit,
|
|
|
- EdbInfoIdArr: target_arr,
|
|
|
+ EdbInfoIdArr,
|
|
|
+ EmptyType: nullValueWay,
|
|
|
+ MaxEmptyType: maxNullWay
|
|
|
};
|
|
|
this.dataloading = true;
|
|
|
|
|
@@ -540,7 +550,7 @@ export default {
|
|
|
/* 新增公式分段 */
|
|
|
addFormulaHandle() {
|
|
|
let addItem = {
|
|
|
- formula: this.formulaList[0].formula,
|
|
|
+ formula: this.formulaList[this.formulaList.length-1].formula,
|
|
|
date: ''
|
|
|
}
|
|
|
this.formulaList.push(addItem)
|
|
@@ -611,9 +621,9 @@ export default {
|
|
|
this.formulaList = [
|
|
|
{ formula: '' }
|
|
|
]
|
|
|
- this.otherForm = {
|
|
|
- nullValueWay: 1,
|
|
|
- maxNullWay: '等于0'
|
|
|
+ this.nullValueForm = {
|
|
|
+ nullValueWay: 0,
|
|
|
+ maxNullWay: 1
|
|
|
}
|
|
|
|
|
|
},
|