新增界面 左右侧指标数据移动功能实现

zqqdev
CherrysChang 5 years ago
parent 5995db5d95
commit f8b7ce3153
  1. 109
      src/views/train/case-detail.vue

@ -26,7 +26,7 @@
<el-col :span="7">
<el-table ref="leftTable" :data="getFilterDataBySearchName" :row-key="getRowKey" height="400" border highlight-current-row tooltip-effect="dark" @selection-change="leftSelectionChange">
<el-table-column type="selection" :reserve-selection="true" width="55"></el-table-column>
<el-table-column header-align="right" label="未选择 10/10">
<el-table-column header-align="right" :label="leftSumLabel">
<el-table-column prop="name" label="名称" show-overflow-tooltip>
<template slot="header" slot-scope="scope">
<el-input v-model="searchName" placeholder="输入指标名称模糊搜索" prefix-icon="el-icon-search"></el-input>
@ -36,17 +36,18 @@
</el-table>
</el-col>
<el-col :span="1" style="text-align:center;padding: 160px 0 0 0;width: 24px;">
<!--:disabled="leftSelectedRows.length==0"-->
<el-button @click="addToRight" size="mini" type="primary" icon="el-icon-arrow-right" circle :disabled="isDisable"></el-button>
<el-button @click="removeToLeft" size="mini" type="primary" icon="el-icon-arrow-left" circle style="margin:10px 0 0 0;"></el-button>
<el-button @click="addToRight" size="mini" type="primary" icon="el-icon-arrow-right" circle :disabled="isDisableToRight"></el-button>
<el-button @click="removeToLeft" size="mini" type="primary" icon="el-icon-arrow-left" circle :disabled="isDisableToLeft" style="margin:10px 0 0 0;"></el-button>
</el-col>
<el-col :span="14" class="rightTable">
<el-table ref="rightTable" :data="dataForm.taskList" height="400" border highlight-current-row tooltip-effect="dark" :summary-method="getScoreSummaries" show-summary @selection-change="rightSelectionChange">
<el-table ref="rightTable" :data="rightTargetList" height="400" border highlight-current-row tooltip-effect="dark" :summary-method="getScoreSummaries" show-summary @selection-change="rightSelectionChange">
<el-table-column type="selection" width="55"></el-table-column>
<el-table-column header-align="right" label="已选择 0/10,剩余可配置分数 90 分">
<el-table-column header-align="right" :label="rightSumLabel">
<el-table-column prop="name" label="名称"></el-table-column>
<el-table-column prop="target" label="任务目标" width="226">
<template slot-scope="scope">
<el-row>
<el-col :span="12">
<el-form-item :prop="'taskList.'+scope.$index+'.taskOperate'" :rules="dataRule.score" class="score-input" >
<el-select v-model="scope.row.taskOperate" size="small" style="width: 100px;">
<el-option label="大于" value="1"></el-option>
@ -54,11 +55,15 @@
<el-option label="小于" value="3"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item :prop="'taskList.'+scope.$index+'.taskRate'" :rules="dataRule.score" class="score-input" >
<el-input size="small" v-model.trim="scope.row.taskRate" :disabled="formAction == 2" style="width: 100px;">
<i slot="suffix">%</i>
</el-input>
</el-form-item>
</el-col>
</el-row>
</template>
</el-table-column>
<el-table-column prop="score" label="分数" width="120">
@ -70,7 +75,7 @@
</el-table-column>
<el-table-column fixed="right" label="操作" width="50">
<template slot-scope="scope">
<el-button @click.native.prevent="rightDeleteRow(scope.$index, tableData)" type="text" size="small">移除</el-button>
<el-button @click.native.prevent="removeToLeftByRow(scope.$index,scope.row)" type="text" size="small">移除</el-button>
</template>
</el-table-column>
</el-table-column>
@ -140,9 +145,11 @@
],
},
leftDictTargetList: [],//
leftDictTargetListCount: 0,//
searchName: '',
leftSelectedRows: [],//
leftSelectedRows: [],//
rightTargetList:[],//
rightSelectedRows:[],//
selectedItemRows: [],
selectedTradeItems: [],
}
@ -167,15 +174,42 @@
this.initTargetList();
},
computed: {
isDisable: function() { // truefalse
isDisableToRight: function() { // truefalse
if(this.leftSelectedRows && this.leftSelectedRows.length >0) {
return false;
}
return true;
},
isDisableToLeft: function() { // truefalse
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] = '--';

Loading…
Cancel
Save