uniapp heckbox-group实现多选

文章目录

  • html 代码
  • JS 代码

混了业务逻辑,谨慎观看

html 代码

<view><!--可滚动视图区域。用于区域滚动 --><scroll-view :style="{ height: clientHeight + 'px' }" :scroll-top="scrollTop" scroll-y="true"@scrolltoupper="upper" @scrolltolower="lower" @scroll="scroll"><!--多项选择器--><checkbox-group @change="checkboxChange"><!-- 多内容pendingList 卡片 --><view v-for="(item, index) in pendingList" :key="index"><uni-card :title="item.deliveryCode" :extra="item.dbilldate.substring(0,10)"><view class="checkbox_collapse"><!--多选项目 checkbox 和 view同级--><!-- value绑定的值;checked当前是否选中,可用来设置默认选中 --><checkbox :value="item.checkboxValue" :checked="item.checked" color="#1d99ff" /><view style="margin-left: 10px;width: 100%;"><view v-for="(array,index3) in item.detail" :key="index3"><u-row><u-col span="1" v-if="item.detail.length > 1">{{index3+1}}</u-col><u-col span="11"><view class="uni-body order_detail_product_name">{{array.materialName}}{{array.castUnit}}</view><view class="uni-body order_detail_product_name"><text style="color: #5d5d5d;">订单:</text>{{array.saleCode}}</view><view class="uni-body order_detail_product_name bottom-border"><text style="color: #5d5d5d;">单项金额:</text>¥{{array.norigtaxmny}}</view></u-col></u-row></view><view class="order_detail"><view style="color: black;">¥{{item.totalPrice}}</view></view></view></view></uni-card></view></checkbox-group></scroll-view><view class="foot_view"><u-row><u-col><u-row><u-col span="5" class="foot_view_checkbox"><!--全选选择器--><checkbox-group placement="column" @change="groupChange"><checkbox :value="allRadio.name" :checked="allRadio.checked" color="#1d99ff"style="margin-left: 25px;">全选</checkbox></checkbox-group></u-col><u-col span="9" justify="end"><view class="foot_view_but_box"><button type="primary" class="foot_view_but" @click="submitTicket">提交申请</button></view></u-col></u-row></u-col></u-row></view>
</view>

JS 代码

export default {name: "pending",data() {return {pendingList: [],scrollTop: 0,allRadio: { name: '全选',checked: false},selectPending: [], //选中的经销商数据selectPendingCode: [],//选中的出库单编号和订单编号数据dealerRadio: false, //选择开票客户和发票类型对话框dealerRadioList: [], //开票客户selectDealerRadio: '', //对话框中选择的经销商totalAmount: 0,//总金额showDealerRadio: false, // 开票客户对话框}},methods: {checkboxChange(e) {this.totalAmount = 0 //总金额this.selectPending = [] //选中的经销商数据this.selectPendingCode = []//选中的出库单编号和订单编号数据let dealerList = new Set() //这步业务需要,过滤重复经销商//  e.detail.value是checkbox选中的值:"XC2022121000000002-SO302022121000000001"let selectData = e.detail.value//pendingList循环的数据for (var i = 0, lenI = this.pendingList.length; i < lenI; ++i) {const item = this.pendingList[i]//判断selectData和pendingList.checkboxValue是否相等,相等则把checked设为trueif (selectData.includes(item.checkboxValue)) {this.$set(this.pendingList[i], 'checked', true)} else {this.$set(this.pendingList[i], 'checked', false)}}//  商品是否全部勾选,判断全选与否状态var offCarArr = []//this.pendingList.whether 属性值是true,则把itempush到offCarArrthis.pendingList.forEach(item => item.whether == true ? offCarArr.push(item) : '')//offCarArr的checked都是true,则allChecks = true,否则反之//every 若有一个不满足条件,则返回false,后面的元素都不会再执行。不会对空数组进行检测,不会改变原始数组let allChecks = offCarArr.every(item => item.checked == true)//如果allChecks等于true就反allRadio改为选中状态allChecks ? this.$set(this.allRadio, 'checked', true) : this.$set(this.allRadio, 'checked', false)//往dealerList添加经销商数据for (let ii in selectData) {this.selectPendingCode.push(selectData[ii])const temp = selectData[ii].split('-')for (let i in this.pendingList) {if (temp[0] === this.pendingList[i].deliveryCode) {this.totalAmount += this.pendingList[i].totalPricefor (let j in this.pendingList[i].detail) {let item = this.pendingList[i].detail[j]const str = item.invoiceCustCode + '-' + item.invoiceCustNamedealerList.add(str)}}}}this.selectPending = [...dealerList]},groupChange(n) {//全选按钮是否选中if (n.detail.value.length == 0) { //未选中this.pendingList.map(item => this.$set(item, 'checked', false))this.$set(this.allRadio, 'checked', false)//清空业务数据this.totalAmount = 0this.selectPending = []this.selectPendingCode = []} else {// 选中for (var i in this.pendingList) {this.$set(this.pendingList[i], 'checked', true)}this.$set(this.allRadio, 'checked', true)//清空业务数据this.totalAmount = 0this.selectPending = []this.selectPendingCode = []let dealerList = new Set()//往dealerList添加经销商数据for (let i in this.pendingList) {if (this.pendingList[i].checked) {this.selectPendingCode.push(this.pendingList[i].checkboxValue)this.totalAmount += this.pendingList[i].totalPricefor (let j in this.pendingList[i].detail) {let item = this.pendingList[i].detail[j]const str = item.invoiceCustCode + '-' + item.invoiceCustNamedealerList.add(str)}}}this.selectPending = [...dealerList]}},}
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/146739.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

http的几种方法

http的几种方法在 rfc2616 中进行了定义&#xff1a; https://www.rfc-editor.org/rfc/rfc2616.html#page-51 HEAD方法&#xff1a;HEAD方法和GET方法相同&#xff0c;只不过服务端只返回头&#xff0c;不返回消息体。GET方法&#xff1a;用于获取资源POST方法&#xff1a;用于…

2013年11月10日 Go生态洞察:Go语言四周年回顾

&#x1f337;&#x1f341; 博主猫头虎&#xff08;&#x1f405;&#x1f43e;&#xff09;带您 Go to New World✨&#x1f341; &#x1f984; 博客首页——&#x1f405;&#x1f43e;猫头虎的博客&#x1f390; &#x1f433; 《面试题大全专栏》 &#x1f995; 文章图文…

招聘小程序源码 人才招聘网源码

招聘小程序源码 人才招聘网源码 求职招聘小程序源码系统是一种基于微信小程序的招聘平台&#xff0c;它可以帮助企业和求职者快速、方便地进行招聘和求职操作。 该系统通常包括以下功能模块&#xff1a; 用户注册和登录&#xff1a;用户可以通过微信小程序注册和登录&#…

javascript选择器的封装,只需要写元素名或css类及id都可以选择到元素

//模仿jquery选择器样式&#xff0c;只需要写元素名或css类及id都可以选择到元素 <html><head><meta http-equiv"Content-Type:text/html;charsetutf8"/><link rel"shortcut icon" href"#"/><title>封装选择器&l…

MySQL中json类型,你使用过吗

在最近的项目开发过程中&#xff0c;遇到了消息发送内容以Map形式存储的情况。最初的解决方案是将对象转换为字符串&#xff0c;并存储在MySQL的varchar(3000)字段中。然而&#xff0c;由于对存储空间的限制&#xff0c;不得不寻找其他解决方案。在调研中发现&#xff0c;从MyS…

如何利用ChatGPT撰写学术论文?

在阅读全文前请注意&#xff0c;本文是利用ChatGPT“辅助完成”而不是“帮写”学术论文&#xff0c;请一定要注意学术规范&#xff01; 本文我将介绍如何使用清晰准确的“指令”让ChatGPT帮助我们在论文写作上提高效率&#xff0c;希望通过本文的指导&#xff0c;读者能够充分…

uniapp app tabbar 页面默认隐藏

1.在page.json 中找到tabbar visible 默认为true,设为false则是不显示 uni.setTabBarItem({ index: 1, //列表索引 visible:true //显示或隐藏 })

Linux环境的Windows子系统

Linux环境的Windows 子系统 (WSL) 可让开发人员直接在 Windows 上按原样运行 GNU/Linux 环境&#xff08;包括大多数命令行工具、实用工具和应用程序&#xff09;&#xff0c;且不会产生传统虚拟机或双启动设置开销。 1、启用适用于 Linux 的 Windows 子系统 dism.exe /online …

PyTorch

正常界面 创建环境 conda create -n env_test python3.6进入环境 conda activate env_testpycharm中&#xff0c;创建项目&#xff0c;选择环境

Ubuntu18.04安装IgH主站

EtherCAT主站是EtherCAT网络中的中央控制单元,负责协调和管理连接到网络的所有从站设备。EtherCAT(Ethernet for Control Automation Technology)是一种高性能、实时的工业以太网通信协议,广泛应用于自动化和控制领域。 一、安装依赖包 sudo apt install autoconf automa…

LeetCode(26)判断子序列【双指针】【简单】

目录 1.题目2.答案3.提交结果截图 链接&#xff1a; 判断子序列 1.题目 给定字符串 s 和 t &#xff0c;判断 s 是否为 t 的子序列。 字符串的一个子序列是原始字符串删除一些&#xff08;也可以不删除&#xff09;字符而不改变剩余字符相对位置形成的新字符串。&#xff08;…

【Java】恺撒密码,stream流,方法引用

文章目录 一、题目二、题解2.1、写法12.2、写法2&#xff0c;stream流2.3、写法3&#xff0c;方法引用 一、题目 二、题解 2.1、写法1 普通写法, 遍历每个字符进行加密 public static void main1 (String[] args) {Scanner sc new Scanner(System.in);String strs sc.nextL…

Linux 进程管理 实时调度类及SMP和NUMA

文章目录 一、 实时调度类分析1.1 实时调度实体sched_rt_entity数据结构1.2 实时调度类rt_sched_class数据结构1.3 实时调度类功能函数 二、SMP和NUMA2.1 SMP&#xff08;多对称处理器结构&#xff0c;UMA&#xff09;2.2 NUMA&#xff08;非一致内存访问结构&#xff09;2.3 C…

JS 防抖封装方法

防抖封装方法&#xff1a; /*** param {Function} func* param {number} wait* param {boolean} immediate* return {*}*/ export function debounce(func, wait, immediate) {let timeout, args, context, timestamp, resultconst later function () {// 据上一次触发时间间隔…

【Linux系统化学习】进程的父子关系 | fork 进程

个人主页点击直达&#xff1a;小白不是程序媛 Linux专栏&#xff1a;Linux系统化学习 目录 前言&#xff1a; 父子进程 父子进程的引入 查看父子进程 查询进程的动态目录 更改进程的工作目录 fork创建进程 fork的引入 fork的使用 fork的原理 fork如何实现的&#…

PS学习笔记——图层

文章目录 图层面板图层类型新建图层新建方式图层颜色 操作图层修改图层名称选中图层隐藏图层调整图层顺序复制图层 图层面板 按F7可打开/关闭图层面板 该面板就是图层面板了 对所有图层进行筛选的按钮&#xff0c;第一个搜索框可以选择按什么方式进行筛选&#xff0c;支持&am…

html-网站菜单-点击显示导航栏

一、效果图 1.点击显示菜单栏&#xff0c;点击x号关闭&#xff1b; 2.点击一级菜单&#xff0c;展开显示二级&#xff0c;并且加号变为减号&#xff1b; 3.点击其他一级导航&#xff0c;自动收起展开的导航。 二、代码实现 <!DOCTYPE html> <html><head>&…

首尔市立大学经营学专业介绍,柯桥留学韩语培训

首尔市立大学成立于1918年&#xff0c;位于韩国首尔特别市&#xff0c;是韩国国内一所综合性公立大学&#xff0c;2022QS世界大学排名位列801-1000名区间。近年来因为实行“半价学费”策略&#xff0c;得到首尔市政府的大力支持&#xff0c;通过大幅提高高考分数&#xff0c;吸…

IDEA导入jar包

通过maven导入本地包 mvn install:install-file -DfileD:\WebProject\ERP\zhixing-heyue-erp-server\zxhy-service-api\src\main\java\com\zxhy\service\api\invoice\baiwang\lib\com_baiwang_bop_sdk_outer_3_4_393.jar -DgroupIdcom.baiwang -DartifactIdbaiwang.open -Dver…

力扣labuladong一刷day11拿下打家劫舍问题共3题

力扣labuladong一刷day11拿下打家劫舍问题共3题 文章目录 力扣labuladong一刷day11拿下打家劫舍问题共3题一、198. 打家劫舍二、213. 打家劫舍 II三、337. 打家劫舍 III 一、198. 打家劫舍 题目链接&#xff1a;https://leetcode.cn/problems/house-robber/ 思路&#xff1a;打…