Commit 4390879ac3810d2494a82f69f042210b8f20e6cd

Authored by qianbao
1 parent a5b82dcb

1、添加多选赋值 多选删除

src/views/bigscreenDesigner/designer/index.vue
... ... @@ -523,6 +523,7 @@ export default {
523 523 // 判断是否松开shift键,是就把pin赋值为false
524 524 if (code.keyCode === 16) {
525 525 this.shiftEnt = false;
  526 + this.selectMore=[];
526 527 }
527 528 }, 500, true),
528 529 /**
... ... @@ -554,7 +555,9 @@ export default {
554 555 },
555 556 async initEchartData() {
556 557 const reportCode = this.$route.query.reportCode;
  558 + this.$showLoading();
557 559 const { code, data } = await detailDashboard(reportCode);
  560 + this.$hideLoading();
558 561 if (code != 200) return;
559 562 const processData = this.handleInitEchartsData(data);
560 563 const screenData = this.handleBigScreen(data.dashboard);
... ... @@ -968,13 +971,17 @@ export default {
968 971 for (let i = 0; i < draggableArr.length; i++) {
969 972 if (i == index) {
970 973 this.$refs.widgets[i].$refs.draggable.setActive(true);
  974 + this.selectMore.push(index);
971 975 }
972 976 }
973 977 }else{
974 978 //没有按住shift键标识编辑单个
  979 + let selectMore = [];
975 980 for (let i = 0; i < draggableArr.length; i++) {
976 981 if (i == index) {
977 982 this.$refs.widgets[i].$refs.draggable.setActive(true);
  983 + selectMore.push(index);
  984 + this.selectMore = selectMore;
978 985 } else {
979 986 this.$refs.widgets[i].$refs.draggable.setActive(false);
980 987 }
... ... @@ -993,6 +1000,7 @@ export default {
993 1000 for (let i = 0; i < draggableArr.length; i++) {
994 1001 this.$refs.widgets[i].$refs.draggable.setActive(false);
995 1002 }
  1003 + this.selectMore = [];
996 1004 }
997 1005 },
998 1006 setWidgetOptionsData(val){
... ... @@ -1101,14 +1109,30 @@ export default {
1101 1109 arr[oldIndex] = arr.splice(newIndex, 1, arr[oldIndex])[0];
1102 1110 return arr;
1103 1111 },
1104   - // 删除
1105   - deletelayer() {
1106   - this.widgets.splice(this.rightClickIndex, 1);
  1112 + //去重
  1113 + setUnique(arr) {
  1114 + let newArr = [];
  1115 + arr.forEach(item => {
  1116 + return newArr.includes(item) ? '' : newArr.push(item);
  1117 + });
  1118 + return newArr;
1107 1119 },
1108   - // 复制
  1120 + // 多选复制
1109 1121 copylayer() {
1110   - // console.log("copylayer");
1111   - const obj = this.deepClone(this.widgets[this.rightClickIndex]);
  1122 + //首先复制右选节点,再复制其他选择节点
  1123 + this.copylayerOne(this.rightClickIndex)
  1124 + // if(this.isNotBlankArray(this.selectMore)){
  1125 + // for(let i = 0; i< this.selectMore.length;i++){
  1126 + // const copyIndex = this.selectMore[i];
  1127 + // if(this.rightClickIndex != copyIndex){
  1128 + // this.copylayerOne(copyIndex);
  1129 + // }
  1130 + // }
  1131 + // }
  1132 + },
  1133 + // 复制
  1134 + copylayerOne(index) {
  1135 + const obj = this.deepClone(this.widgets[index]);
1112 1136 this.widgets.splice(this.widgets.length, 0, obj);
1113 1137 },
1114 1138 // 置顶
... ... @@ -1151,6 +1175,28 @@ export default {
1151 1175 //输入删除键删除
1152 1176 entryDelete(index){
1153 1177 this.widgets.splice(index, 1);
  1178 + //调用删除
  1179 + // this.selectMore.push(index);
  1180 + // this.deletelayerOne();
  1181 + },
  1182 + deletelayer() {
  1183 + this.widgets.splice(this.rightClickIndex, 1);
  1184 + // this.selectMore.push(this.rightClickIndex);
  1185 + // this.deletelayerOne();
  1186 + },
  1187 + // 删除
  1188 + deletelayerOne() {
  1189 + this.selectMore = this.setUnique(this.selectMore);
  1190 + //首先复制右选节点,再复制其他选择节点
  1191 + let widgetsCp = [];
  1192 + if(this.isNotBlankArray(this.selectMore)){
  1193 + for(let i = 0; i< this.widgets.length;i++){
  1194 + if(this.selectMore.indexOf(i)<0){
  1195 + widgetsCp.push(this.widgets[i]);
  1196 + }
  1197 + }
  1198 + }
  1199 + this.widgets = widgetsCp;
1154 1200 },
1155 1201 //根据上下左右键移动(因为子组件直接切换焦点事件问题,这里弥补不点大屏直接切组件移动)
1156 1202 dragWidgetMoveByKey(code,widgetIndex){
... ...