Quellcode durchsuchen

新增shift功能
选定数据显示创建人

Qukatie vor 2 Tagen
Ursprung
Commit
e22a3f45cc

+ 62 - 2
src/views/iosBasicData/financialManagement/computationCenter/components/pickedData.vue

@@ -10,6 +10,7 @@
       :page.sync="page"
       @size-change="sizeChange"
       @current-change="currentChange"
+      @select="select"
       @selection-change="selectionChange"
       @row-dblclick="handleRowDBLClick"
       @row-click="handleRowClick"
@@ -308,6 +309,12 @@ export default {
             overHidden: true,
           },
           {
+            label: "创建人",
+            prop: "createUserName",
+            width: 100,
+            overHidden: true,
+          },
+          {
             label: "备注",
             prop: "remarkss",
             width: 100,
@@ -324,6 +331,8 @@ export default {
       },
       pageData: [],
       selectionList: [],
+      isShiftPressed: false, // 键盘状态
+      lastSelectedRowIndex: null,
     };
   },
   components: { feeInfo },
@@ -349,9 +358,60 @@ export default {
     this.roleName = localStorage.getItem("roleName").split(",");
     this.option = await this.getColumnData(this.getColumnName(491), this.optionBack);
   },
+  mounted() {
+    document.addEventListener("keydown", this.handleKeyDown);
+    document.addEventListener("keyup", this.handleKeyUp);
+  },
+  beforeDestroy() {
+    document.removeEventListener("keydown", this.handleKeyDown);
+    document.removeEventListener("keyup", this.handleKeyUp);
+  },
   methods: {
+    handleKeyDown(e) {
+      if (e.key === "Shift" || e.keyCode === 16) {
+        this.isShiftPressed = true;
+      }
+    },
+    handleKeyUp(e) {
+      if (e.key === "Shift" || e.keyCode === 16) {
+        this.isShiftPressed = false;
+      }
+    },
     handleRowClick(row, event, column) {
-      this.$refs.crud.toggleRowSelection(row, true);
+      const currentIndex = this.pageData.indexOf(row); // 获取当前行索引
+      if (this.isShiftPressed && this.lastSelectedRowIndex != null) {
+        const start = Math.min(this.lastSelectedRowIndex, currentIndex);
+        const end = Math.max(this.lastSelectedRowIndex, currentIndex);
+        this.$refs.crud.selectClear(); // 清空历史选中
+        setTimeout(() => {
+          for (let i = start; i <= end; i++) {
+            this.$refs.crud.toggleRowSelection(this.pageData[i], true);
+          }
+        }, 10);
+
+        this.lastSelectedRowIndex = currentIndex; // 更新起始行索引
+      } else {
+        // 普通点击:清空选中并设置起始行
+        // this.$refs.crud.selectClear(); // 清空历史选中
+        this.$refs.crud.toggleRowSelection(row, true); // 选中当前行
+        this.lastSelectedRowIndex = currentIndex; // 更新起始行索引
+      }
+    },
+    select(list, row) {
+      const currentIndex = this.pageData.indexOf(row); // 获取当前行索引
+      if (this.isShiftPressed && this.lastSelectedRowIndex != null) {
+        const start = Math.min(this.lastSelectedRowIndex, currentIndex);
+        const end = Math.max(this.lastSelectedRowIndex, currentIndex);
+        this.$refs.crud.selectClear(); // 清空历史选中
+        setTimeout(() => {
+          for (let i = start; i <= end; i++) {
+            this.$refs.crud.toggleRowSelection(this.pageData[i], true);
+          }
+        }, 10);
+        this.lastSelectedRowIndex = currentIndex; // 更新起始行索引
+      } else {
+        this.lastSelectedRowIndex = currentIndex; // 更新起始行索引
+      }
     },
     viewRLA(row, type) {
       this.rlaData = [];
@@ -785,7 +845,7 @@ export default {
     },
     rowClassName({ row, rowIndex }) {
       let rowName = "",
-      findRow = this.selectionList.find((c) => c.$index === rowIndex);
+        findRow = this.selectionList.find((c) => c.$index === rowIndex);
       if (findRow) {
         rowName = "current-row "; // elementUI 默认高亮行的class类 不用再样式了^-^,也可通过css覆盖改变背景颜色
       }

+ 61 - 1
src/views/iosBasicData/financialManagement/finstlbills/components/pickedData.vue

@@ -10,6 +10,7 @@
       :page.sync="page"
       @size-change="sizeChange"
       @current-change="currentChange"
+      @select="select"
       @selection-change="selectionChange"
       @row-dblclick="handleRowDBLClick"
       @row-click="handleRowClick"
@@ -447,6 +448,12 @@ export default {
             overHidden: true,
           },
           {
+            label: "创建人",
+            prop: "createUserName",
+            width: 100,
+            overHidden: true,
+          },
+          {
             label: "备注",
             prop: "remarkss",
             width: 100,
@@ -463,6 +470,8 @@ export default {
       },
       pageData: [],
       selectionList: [],
+      isShiftPressed: false, // 键盘状态
+      lastSelectedRowIndex: null,
     };
   },
   components: { feeInfo },
@@ -488,9 +497,60 @@ export default {
     this.roleName = localStorage.getItem("roleName").split(",");
     this.option = await this.getColumnData(this.getColumnName(488), this.optionBack);
   },
+  mounted() {
+    document.addEventListener("keydown", this.handleKeyDown);
+    document.addEventListener("keyup", this.handleKeyUp);
+  },
+  beforeDestroy() {
+    document.removeEventListener("keydown", this.handleKeyDown);
+    document.removeEventListener("keyup", this.handleKeyUp);
+  },
   methods: {
+    handleKeyDown(e) {
+      if (e.key === "Shift" || e.keyCode === 16) {
+        this.isShiftPressed = true;
+      }
+    },
+    handleKeyUp(e) {
+      if (e.key === "Shift" || e.keyCode === 16) {
+        this.isShiftPressed = false;
+      }
+    },
     handleRowClick(row, event, column) {
-      this.$refs.crud.toggleRowSelection(row, true);
+      const currentIndex = this.pageData.indexOf(row); // 获取当前行索引
+      if (this.isShiftPressed && this.lastSelectedRowIndex != null) {
+        const start = Math.min(this.lastSelectedRowIndex, currentIndex);
+        const end = Math.max(this.lastSelectedRowIndex, currentIndex);
+        this.$refs.crud.selectClear(); // 清空历史选中
+        setTimeout(() => {
+          for (let i = start; i <= end; i++) {
+            this.$refs.crud.toggleRowSelection(this.pageData[i], true);
+          }
+        }, 10);
+
+        this.lastSelectedRowIndex = currentIndex; // 更新起始行索引
+      } else {
+        // 普通点击:清空选中并设置起始行
+        // this.$refs.crud.selectClear(); // 清空历史选中
+        this.$refs.crud.toggleRowSelection(row, true); // 选中当前行
+        this.lastSelectedRowIndex = currentIndex; // 更新起始行索引
+      }
+    },
+    select(list, row) {
+      const currentIndex = this.pageData.indexOf(row); // 获取当前行索引
+      if (this.isShiftPressed && this.lastSelectedRowIndex != null) {
+        const start = Math.min(this.lastSelectedRowIndex, currentIndex);
+        const end = Math.max(this.lastSelectedRowIndex, currentIndex);
+        this.$refs.crud.selectClear(); // 清空历史选中
+        setTimeout(() => {
+          for (let i = start; i <= end; i++) {
+            this.$refs.crud.toggleRowSelection(this.pageData[i], true);
+          }
+        }, 10);
+        this.lastSelectedRowIndex = currentIndex; // 更新起始行索引
+      } else {
+        this.lastSelectedRowIndex = currentIndex; // 更新起始行索引
+      }
     },
     viewRLA(row, type) {
       this.rlaData = [];

+ 61 - 5
src/views/iosBasicData/financialManagement/finstlbills/components/queryData.vue

@@ -10,6 +10,7 @@
       :page.sync="page"
       @size-change="sizeChange"
       @current-change="currentChange"
+      @select="select"
       @selection-change="selectionChange"
       @row-click="handleRowClick"
       @resetColumn="resetColumn('crud', 'option', 'optionBack', 487)"
@@ -391,14 +392,12 @@ export default {
       },
       pageData: [],
       queryData: [],
-      // 键盘状态
-      isShiftPressed: false,
-      // 操作锁
-      isSelecting: false,
       // 选择相关
       lastSelectedRow: null,
       lastSelectionRange: null, // {startIndex, endIndex}
       selectionList: [],
+      isShiftPressed: false, // 键盘状态
+      lastSelectedRowIndex: null,
     };
   },
   props: {
@@ -423,9 +422,60 @@ export default {
     this.roleName = localStorage.getItem("roleName").split(",");
     this.option = await this.getColumnData(this.getColumnName(487), this.optionBack);
   },
+   mounted() {
+    document.addEventListener("keydown", this.handleKeyDown);
+    document.addEventListener("keyup", this.handleKeyUp);
+  },
+  beforeDestroy() {
+    document.removeEventListener("keydown", this.handleKeyDown);
+    document.removeEventListener("keyup", this.handleKeyUp);
+  },
   methods: {
+    handleKeyDown(e) {
+      if (e.key === "Shift" || e.keyCode === 16) {
+        this.isShiftPressed = true;
+      }
+    },
+    handleKeyUp(e) {
+      if (e.key === "Shift" || e.keyCode === 16) {
+        this.isShiftPressed = false;
+      }
+    },
     handleRowClick(row, event, column) {
-      this.$refs.crud.toggleRowSelection(row, true);
+      const currentIndex = this.pageData.indexOf(row); // 获取当前行索引
+      if (this.isShiftPressed && this.lastSelectedRowIndex != null) {
+        const start = Math.min(this.lastSelectedRowIndex, currentIndex);
+        const end = Math.max(this.lastSelectedRowIndex, currentIndex);
+        this.$refs.crud.selectClear(); // 清空历史选中
+        setTimeout(() => {
+          for (let i = start; i <= end; i++) {
+            this.$refs.crud.toggleRowSelection(this.pageData[i], true);
+          }
+        }, 10);
+
+        this.lastSelectedRowIndex = currentIndex; // 更新起始行索引
+      } else {
+        // 普通点击:清空选中并设置起始行
+        // this.$refs.crud.selectClear(); // 清空历史选中
+        this.$refs.crud.toggleRowSelection(row, true); // 选中当前行
+        this.lastSelectedRowIndex = currentIndex; // 更新起始行索引
+      }
+    },
+    select(list, row) {
+      const currentIndex = this.pageData.indexOf(row); // 获取当前行索引
+      if (this.isShiftPressed && this.lastSelectedRowIndex != null) {
+        const start = Math.min(this.lastSelectedRowIndex, currentIndex);
+        const end = Math.max(this.lastSelectedRowIndex, currentIndex);
+        this.$refs.crud.selectClear(); // 清空历史选中
+        setTimeout(() => {
+          for (let i = start; i <= end; i++) {
+            this.$refs.crud.toggleRowSelection(this.pageData[i], true);
+          }
+        }, 10);
+        this.lastSelectedRowIndex = currentIndex; // 更新起始行索引
+      } else {
+        this.lastSelectedRowIndex = currentIndex; // 更新起始行索引
+      }
     },
     viewRLA(row, type) {
       this.rlaData = [];
@@ -565,6 +615,12 @@ export default {
         res.data.data.forEach((item, index) => {
           item.accBillId = item.id;
           delete item.id;
+          delete item.createUser;
+          delete item.createUserName;
+          delete item.createTime;
+          delete item.updateUser;
+          delete item.updateUserName;
+          delete item.updateTime;
           item.lineNo = Number(index) + 1;
           this.$set(item, "currentStlCurCode", item.curCode);
           this.$set(item, "currentStlExrate", item.exrate);