From f8b7ce3153857d84e07d08e5c81e1d4d050c0b76 Mon Sep 17 00:00:00 2001
From: CherrysChang <1935003650@qq.com>
Date: Sun, 26 Apr 2020 15:01:26 +0800
Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=95=8C=E9=9D=A2=20?=
=?UTF-8?q?=E5=B7=A6=E5=8F=B3=E4=BE=A7=E6=8C=87=E6=A0=87=E6=95=B0=E6=8D=AE?=
=?UTF-8?q?=E7=A7=BB=E5=8A=A8=E5=8A=9F=E8=83=BD=E5=AE=9E=E7=8E=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/views/train/case-detail.vue | 133 +++++++++++++++++++++++++-------
1 file changed, 104 insertions(+), 29 deletions(-)
diff --git a/src/views/train/case-detail.vue b/src/views/train/case-detail.vue
index 689c9ba..6539da7 100644
--- a/src/views/train/case-detail.vue
+++ b/src/views/train/case-detail.vue
@@ -26,7 +26,7 @@
-
+
@@ -36,29 +36,34 @@
-
-
-
+
+
-
+
-
+
-
-
-
-
-
-
-
-
-
- %
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+ %
+
+
+
+
@@ -70,7 +75,7 @@
- 移除
+ 移除
@@ -140,9 +145,11 @@
],
},
leftDictTargetList: [],//左侧指标数据:从数据库获取量化指标字典数据
+ leftDictTargetListCount: 0,//左侧指标初始数据总数
searchName: '',
- leftSelectedRows: [],//左侧指标选中数据
+ leftSelectedRows: [],//左侧选中的指标数据
rightTargetList:[],//右侧设置的指标数据
+ rightSelectedRows:[],//右侧选中的指标数据
selectedItemRows: [],
selectedTradeItems: [],
}
@@ -167,15 +174,42 @@
this.initTargetList();
},
computed: {
- isDisable: function() { //是否禁用 true为禁用,false为可用
+ isDisableToRight: function() { //是否禁用 true为禁用,false为可用
if(this.leftSelectedRows && this.leftSelectedRows.length >0) {
return false;
}
return true;
},
+ isDisableToLeft: function() { //是否禁用 true为禁用,false为可用
+ if(this.rightSelectedRows && this.rightSelectedRows.length >0) {
+ return false;
+ }
+ return true;
+ },
getFilterDataBySearchName: function () {//根据指标名称筛选列表数据
let searchName = this.searchName;
return this.leftDictTargetList.filter(data => !searchName || data.name.toLowerCase().includes(searchName.toLowerCase()))
+ },
+ leftSelectedCount: function(){//左侧已选择的指标数
+ return this.leftSelectedRows.length;
+ },
+ rightTargetListCount: function () {//右侧指标数据总数
+ return this.rightTargetList.length;
+ },
+ rightRemainScore: function (){//右侧剩余可配置分数
+ if(Number(this.totalScore)>100){
+ return 0;
+ }else{
+ return 100-Number(this.totalScore);
+ }
+ },
+ leftSumLabel: function () {//左侧剩余指标和指标总数的显示
+ // let remainCount = this.leftDictTargetListCount - this.leftSelectedCount -this.rightTargetListCount;
+ let remainCount = this.leftDictTargetListCount - this.rightTargetListCount;
+ return remainCount+"/"+this.leftDictTargetListCount;
+ },
+ rightSumLabel: function () {//右侧选择的指标和指标总数的显示
+ return this.rightTargetListCount+"/"+this.leftDictTargetListCount+",剩余可配置分数 "+this.rightRemainScore+" 分";
}
},
methods: {
@@ -187,6 +221,7 @@
Train.getTargetList(searchObj).then(res => {
if (res.code == 200) {
this.leftDictTargetList = res.data;
+ this.leftDictTargetListCount = this.leftDictTargetList.length;
}
}).catch(error => {
console.info(error)
@@ -199,16 +234,56 @@
this.leftSelectedRows = selection;
},
addToRight() {
- console.info("addToRight")
+ //移除左侧选中的指标数据,右侧添加对应的数据
+ this.leftSelectedRows.forEach(item => {
+ if (this.leftDictTargetList.indexOf(item) > -1) {
+ // 从量化指标字典数据列表中移出选中的数据
+ this.leftDictTargetList.splice(this.leftDictTargetList.indexOf(item), 1);
+ }
+ if(this.rightTargetList.indexOf(item) == -1){
+ //右侧添加选中的数据
+ this.rightTargetList.push(item);
+ }
+ });
+ //清除选中的数据
+ this.leftSelectedRows = [];
+ //清空量化指标字典数据列表的选择
+ this.$refs.leftTable.clearSelection();
+
},
- removeToLeft() {
- console.info("removeToLeft")
+ removeToLeft() {//批量移除右侧选中的指标数据,左侧添加对应的数据(位置为初始位置)
+ this.rightSelectedRows.forEach(item => {
+ let rightItemIndex = this.rightTargetList.indexOf(item);
+ if (rightItemIndex > -1) {
+ // 从右侧指标设置列表中移出选中的数据
+ this.rightTargetList.splice(rightItemIndex, 1);
+ }
+ //左侧还原右侧选中的数据
+ this.removeToLeftByRow(rightItemIndex,item);
+ });
+ //清除选中的数据
+ this.rightSelectedRows = [];
+ //清空量化指标字典数据列表的选择
+ this.$refs.rightTable.clearSelection();
+
},
- rightDeleteRow() {
- console.info("rightDeleteRow")
+ removeToLeftByRow(rowIndex,row) {//单个移除右侧选中的指标数据,左侧添加对应的数据(位置为初始位置)
+ //获取当前移除项的信息
+ // let selItem = this.rightTargetList[rowIndex];
+ //移除到左侧,显示到原来的位置 //ZqqTODO seq 字段命名问题(左侧字典和右侧设置项的seq)
+ let index = this.leftDictTargetList.findIndex(item => {
+ return row.seq < item.seq;
+ });
+ if (index > -1) {
+ this.leftDictTargetList.splice(index,0,row);
+ }else{
+ this.leftDictTargetList.splice(this.leftDictTargetList.length,0,row);
+ }
+ //右侧移除当前项
+ this.rightTargetList.splice(rowIndex,1);
},
rightSelectionChange(val) {
- // this.leftSelectedRows = val;
+ this.rightSelectedRows = val;
},
getScoreSummaries(param) { // 计算总分
const { columns, data } = param;
@@ -219,7 +294,6 @@
sums[index] = '总分';
return;
}
-
if (index === 3) { // 分数栏
values = data.map(item => Number(item['score']));
sums[index] = values.reduce((prev, curr) => {
@@ -231,7 +305,8 @@
}
}, 0);
// 给右上角总分赋值
- this.$set(this.dataForm,'totalScore',sums[index]);
+ // this.$set(this.dataForm,'totalScore',sums[index]);
+ this.totalScore = sums[index];
sums[index] += ' 分';
} else {
sums[index] = '--';