diff --git a/src/components/patientRegister/PatientRegisterList.vue b/src/components/patientRegister/PatientRegisterList.vue index 251db3d..b7c9411 100644 --- a/src/components/patientRegister/PatientRegisterList.vue +++ b/src/components/patientRegister/PatientRegisterList.vue @@ -4,8 +4,8 @@ @contextmenu.prevent="onContextmenu"> + @row-click="rowClick" size="small" @selection-change="handleSelectionChange" @cell-contextmenu="onCellRightClick" + ref="info" :row-class-name="handleRowClassName" > @@ -328,7 +328,6 @@ export default { return { startPoint: -1,// 多选起点 -1 表示选择 endPoint: -1,// 多选终点 -1 表示选择 - pin: false,// 是否按住,默认不按住 multipleSelection: [], //选中的数据列表 @@ -367,32 +366,12 @@ export default { created() { - + }, //挂载完成 mounted() { - this.quickAsb = this.dict.asbItemAll; - - // 监听keydown:获取键盘按住事件,code返回按住的键信息 - window.addEventListener('keydown', code => { - // 判断是否按住了shift键(左右都包括)key: "Shift" - if (code.key == "Shift" && code.shiftKey) { - this.pin = true;// 标记按住了shift键 - } - console.log('this.pin', this.pin) - }); - // 监听keyup:获取键盘松开事件,code返回按住的键信息 - window.addEventListener('keyup', code => { - // 判断是否松开了shift键(左右都包括),以为之前已经按下了code.shiftKey已经是true - if (code.key == "Shift") { - this.pin = false;// 标记松开了shift键 - // this.startPoint = undefined;// 清空多选起点 - // this.endPoint = undefined;// 清空多选终点 - } - console.log('this.pin', this.pin) - }); - + this.quickAsb = this.dict.asbItemAll; }, computed: { ...mapState(["window", "dict", "patientRegister", "customerOrg"]), @@ -400,6 +379,7 @@ export default { methods: { ...mapActions(["getCustomerOrgGroup", "getPatientRegisterAbs"]), + handleRowClassName({ row, rowIndex }) { // highLightBg 为 'selected'的高亮 console.log(rowIndex, row) @@ -504,60 +484,9 @@ export default { }); } this.multipleSelection = JSON.parse(JSON.stringify(rows)); - - - }, - - // 按住shift多选 - shiftSelect(rows, row) { - console.log('rows, row', rows, row) - // 判断原来选择的数组长度selectDatas和现在的长度rows - if (this.multipleSelection.length > rows.length) { - // 原来的长,说明取消勾选了,把当前条取消高亮 - row.highLightBg = ''; - } else { - // 现在的长,说明多勾选了,把当前条高亮 - row.highLightBg = 'selected'; - } - // 判断是勾选的时候才会多选 - if (rows.length < this.multipleSelection.length) { - this.startPoint = undefined;// 清空多选起点 - this.endPoint = undefined;// 清空多选终点 - return; - } - // 判断此时有没有按住shift键 - // 按住了则表示开始多选,没有则停止多选,清空起点终点. - // 开始多选则判断之前是否有起点 - // 有则当前的index标记为终点且勾选这之间的数据,勾选结束清空起点终点 - // 没有则当前的index标记为起点 - // 记录当前的index为多选起点 - if (this.pin) { // 按住了shift键 - if (this.startPoint || this.startPoint == 0) { // 之前有多选起点(第一条单独) - this.endPoint = row.index;// 把当前项的index标记为多选终点 - if (this.startPoint > this.endPoint) { // 如果起点大于终点,则替换否则保留,确保起点始终小于终点 - let temp = this.startPoint; - this.startPoint = this.endPoint; - this.endPoint = temp; - } - // 避免和handleSelectionChange冲突导致返回的数据不准确 - setTimeout(() => { - // 勾选数据 - for (let i = this.startPoint + 1; i < this.endPoint; i++) { - this.$refs.info.toggleRowSelection(this.patientRegister.prList[i], true); - } - this.startPoint = undefined;// 清空多选起点 - this.endPoint = undefined;// 清空多选终点 - }, 100); - } else { // 之前没有多选起点 - this.startPoint = row.index;// 把当前项的index标记为多选起点 - } - } else { // 没按住shift键 - this.startPoint = undefined;// 清空多选起点 - this.endPoint = undefined;// 清空多选终点 - } }, - + //获取单位分组 /api/app/customer-org-group/in-customer-org-id/3a0c0444-d7a0-871f-4074-19faf1655caf getCustomerOrgGroup(customerOrgld) { getapi(`/api/app/customer-org-group/in-customer-org-id/${customerOrgld}`) @@ -570,7 +499,7 @@ export default { }, //点击体检次数行 - rowick(row) { + rowClick(row) { this.patientRegister.photo = ""; //清除照片缓存 this.patientRegister.patientRegisterId = row.id; @@ -583,21 +512,20 @@ export default { this.dict.asbItem = [...this.dict.asbItemAll] this.getPatientRegisterAbs(row.id); - //清除所有选择 - this.patientRegister.prList.forEach(e => { - e.choosed = false; - }); + + console.log('this.patientRegister.prList',this.window, this.patientRegister.prList) + + // 按住了shift键 + if (this.window.shift) { + //清除所有选择 + this.patientRegister.prList.forEach(e => { + e.choosed = false; + return e + }); - if (!this.pin) { // 按住了shift键 - this.patientRegister.prList[row.index].choosed = true; - this.startPoint = row.index; - console.log('this.patientRegister.prList',this.pin,this.startPoint, this.patientRegister.prList) - return - } else { if (this.startPoint == - 1) { this.patientRegister.prList[row.index].choosed = true; this.startPoint = row.index; - console.log('this.patientRegister.prList',this.pin, this.startPoint, this.patientRegister.prList) return } @@ -610,9 +538,25 @@ export default { this.patientRegister.prList[i].choosed = true } } + return } - console.log('this.patientRegister.prList',this.pin, this.startPoint, this.patientRegister.prList) + // 按住了ctrl 键 + if (this.window.ctrl) { + this.patientRegister.prList[row.index].choosed = true; + this.startPoint = row.index; + return + } + + // 未按住了ctrl 、shift 键 + //清除所有选择 + console.log('清除所有选择') + this.patientRegister.prList.forEach(e => { + e.choosed = false; + return e + }); + this.patientRegister.prList[row.index].choosed = true; + this.startPoint = row.index; }, //体检次数 相关操作 diff --git a/src/main.js b/src/main.js index eae3c06..49560d2 100644 --- a/src/main.js +++ b/src/main.js @@ -105,3 +105,25 @@ function onResize() { store.commit('setData', { key: 'window.pageWidth', value: window.innerWidth}) } onResize(); + +// 监听keydown:获取键盘按住事件,code返回按住的键信息 +window.addEventListener('keydown', code => { + if (code.key == "Shift" && code.shiftKey) { + store.commit('setData', { key: 'window.shift', value: true });// 标记按住了shift键 + } + if (code.key == "Control" && code.ctrlKey) { + store.commit('setData', { key: 'window.ctrl', value: true });// 标记按住了ctrl键 + } +}); + +// 监听keyup:获取键盘松开事件,code返回按住的键信息 +window.addEventListener('keyup', code => { + console.log('keyup',code) + if (code.key == "Shift") { + store.commit('setData', { key: 'window.shift', value: false });// 标记松开了shift键 + } + if (code.key == "Control") { + store.commit('setData', { key: 'window.ctrl', value: false });// 标记松开了ctrl键 + } + +}); diff --git a/src/store/index.js b/src/store/index.js index c99ea4a..acf36e6 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -18,6 +18,8 @@ export default new Vuex.Store({ window: { pageHeight: 960, //页面高度 pageWidth: 1920, //页面宽度 + shift:false, //是否按下 shift键 + ctrl:false, //是否按下 ctrl键 }, customerOrg: { //体检单位设置 diff --git a/src/views/Home.vue b/src/views/Home.vue index 1030e1a..8279f21 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -836,6 +836,10 @@ export default { }, //打开客户端调试工具 toggleDevTools() { + if(!this.$peisAPI) { + this.$message.info("此功能,需要在壳客户端才可运行!") + return + } this.$peisAPI.toggleDevTools(); }, },