当前位置: 首页 > news >正文

113 链接集10--ctrl+左键单击多选

1.ctrl+左键单击多选,单击单选

精简代码

  <div class="model-list"><div@mousedown.prevent="handleClick(item, $event)"class="model-list-item"v-for="item in modelList":key="item.id":class="{ 'model-active': item.active }">{{ item.name }}</div></div>//scriptpublic modelList = [{id: 0,name: '马栏山方案-HR-0001',active: false,},{id: 1,name: '马栏山方案-HR-0002',active: false,},{id: 2,name: '马栏山方案-HR-0003',active: false,},];//单选 状态切换modelSelect(info: any) {this.modelList.forEach(item => {if (item.id === info.id) {item.active = !item.active;} else {item.active = false;}});}//多选状态为truemultiSelect(info: any) {this.modelList.forEach(item => {if (item.id === info.id) {item.active = !item.active;}});}//判断是否多选操作handleClick(item: any, event: any) {// 检查是否按下了Ctrl键并是左键点击if (event.ctrlKey && event.button === 0) {this.multiSelect(item);} else {this.modelSelect(item);}}
<template><!-- 数据编辑--合并 --><CsDialog:width="580"@close="visibleDialog = false"@reduce="visibleDialog = false"@expend="visibleDialog = false"title="合并":visible="visibleDialog"><div class="row-item common-wrapper">提示:选择一个模型继承其属性</div><div class="model-list"><div@mousedown.prevent="handleClick(item, $event)"class="model-list-item"v-for="item in modelList":key="item.id":class="{ 'model-active': item.active }">{{ item.name }}</div></div><template slot="footer"><div class="end__operation"><CsButton @click="visibleDialog = false">确定</CsButton><CsButton @click="visibleDialog = false">取消</CsButton></div></template></CsDialog>
</template><script lang="ts">
import { Component, Vue, Prop } from 'vue-property-decorator';@Component({components: {},
})
export default class CombineDialog extends Vue {@Prop() visible!: any;get visibleDialog() {return this.visible;}set visibleDialog(val: any) {this.$emit('update:visible', val);}mounted() {}public modelList = [{id: 0,name: '马栏山方案-HR-0001',active: false,},{id: 1,name: '马栏山方案-HR-0002',active: false,},{id: 2,name: '马栏山方案-HR-0003',active: false,},{id: 3,name: '马栏山方案-HR-0004',active: false,},{id: 4,name: '马栏山方案-HR-0005',active: false,},{id: 5,name: '马栏山方案-HR-0006',active: false,},{id: 6,name: '马栏山方案-HR-0006',active: false,},{id: 7,name: '马栏山方案-HR-0006',active: false,},{id: 8,name: '马栏山方案-HR-0006',active: false,},];modelSelect(info: any) {this.modelList.forEach(item => {if (item.id === info.id) {item.active = !item.active;} else {item.active = false;}});}multiSelect(info: any) {this.modelList.forEach(item => {if (item.id === info.id) {item.active = !item.active;}});}handleClick(item: any, event: any) {// 检查是否按下了Ctrl键并是左键点击if (event.ctrlKey && event.button === 0) {this.multiSelect(item);} else {this.modelSelect(item);}}
}
</script><style lang="scss" scoped>
.excavation-analysis {position: absolute;top: 0;left: 50%;
}
.end__operation {float: right;display: flex;
}.el-radio-group {padding: 5px 8px;border-radius: 2px;border: 1px solid rgba(204, 212, 228, 1);background-color: #f9fafc;display: flex;align-items: center;
}
.row-item {display: flex;justify-content: space-between;margin-bottom: 8px;
}
.common-wrapper {display: flex;align-items: center;font-size: 14px;font-weight: 400;line-height: 22px;color: rgba(115, 123, 141, 1);padding: 5px 8px;border-radius: 2px;border: 1px solid rgba(204, 212, 228, 1);background-color: #f9fafc;font-family: PingFang SC;
}
.file-select {display: flex;justify-content: space-between;width: 100%;
}.model-list {font-family: PingFang SC;font-size: 14px;color: rgba(115, 123, 141, 1);max-height: 300px;overflow-y: auto;.model-list-item {height: 32px;line-height: 32px;padding-left: 8px;&:nth-child(2n + 1) {background-color: rgba(245, 248, 253, 1);}}.model-active {background: rgba(203, 218, 255, 1) !important;}
}
</style>

http://www.lryc.cn/news/324614.html

相关文章:

  • 详解JavaScript中this指向
  • c语言之在函数中传递指针
  • vue2 插槽(默认插槽 slot 、具名插槽 v-slot 、作用域插槽 slot-scope -- 插槽传值 )
  • (第79天)单机转 RAC:19C 单机 到 19C RAC
  • Spring Cloud微服务Actuator和Vue
  • Iterator对象功能学习
  • Linux的一些基本指令
  • 【tips】Git使用指南
  • 【字节序】
  • 数据结构(五)——树森林
  • vscode配置c/c++调试环境
  • 食品输送带的材质
  • 普通用户权限运行Docker
  • 7.Java并发编程—掌握线程池的标准创建方式和优雅关闭技巧,提升任务调度效率
  • 从边缘设备丰富你的 Elasticsearch 文档
  • day29|leetcode|C++|491. 非递减子序列|46. 全排列|47. 全排列 II
  • [Java、Android面试]_12_java访问修饰符、抽象类和接口
  • Linux:Prometheus的源码包安装及操作(2)
  • MongoDB聚合运算符:$integral
  • 手撕算法-买卖股票的最佳时机 II(买卖多次)
  • 技术创新与产业升级
  • 透视未来工厂:山海鲸可视化打造数字孪生新篇章
  • 三.寄存器(内存访问)
  • Day31 贪心算法
  • 【WEEK4】 【DAY5】AJAX - Part Two【English Version】
  • 力扣100热题[哈希]:最长连续序列
  • python笔记基础--文件和存储数据(7)
  • Vue黑马笔记(最新)
  • 安全工具介绍 SCNR/Arachni
  • 赋能数据收集:从机票网站提取特价优惠的JavaScript技巧