layui的table 中 禁用某行勾选

文章描述了如何在前端代码中,通过API获取数据后,根据发票状态处理表格中checkbox的勾选和禁用功能,以实现对发票信息的筛选和管理。
摘要由CSDN通过智能技术生成
            done: function (res, curr, count) {
                var suborders_data_arr = res.data;
                for (let suborders_key in suborders_data_arr) {
                    if (suborders_data_arr[suborders_key]['checkStatus'] == 0) {
                        let index = suborders_data_arr[suborders_key]['LAY_TABLE_INDEX'];
                        $('tr[data-index=' + index + '] input[type="checkbox"]').prop('disabled', true).attr("name","layTableCheckboxDisabled"); // 禁止部分选择
                        $('tr[data-index=' + index + '] input[type="checkbox"]').prop('checked', false);   // 取消选中
                    }
                };
                form.render('checkbox');
            }

全部代码块

        //渲染发票tab表格
        table.render({
            elem: '#overdueTable',
            data: invoce,
            cols: [[
                {type: 'checkbox',width: 60},
                {field: 'number',type: 'numbers',title: '序号',width: 60},
                {field: 'checkedState',title: '勾选状态',width: 100,
                    templet: function (data) {
                        if (data.checkedState == '0') {
                            return '未勾选';
                        } else if (data.checkedState == '1') {
                            return '已勾选';
                        } else {
                            return ''
                        }
                    }
                },
                {field: 'invoiceFrom',title: '发票来源',width: 160,
                    templet: function (data) {
                        if (data.invoiceFrom == '0') {
                            return '增值税发票管理系统';
                        } else if (data.invoiceFrom == '1') {
                            return '电子发票服务平台';
                        } else {
                            return ''
                        }
                    }
                },
                {field: 'sdpNumber',title: '数电票号码',width: 160},
                {field: 'invoiceCode',title: '发票代码',width: 160},
                {field: 'invoiceNumber',title: '发票号码',width: 160},
                {field: 'invoiceDate',title: '开票日期',width: 120},
                {field: 'amountMoney',title: '金额',width: 100},
                {field: 'faceTaxAmount',title: '票面税额',width: 100},
                {field: 'deductionTaxAmount',title: '有效抵扣税额',width: 120},
                {field: 'taxpayerName',title: '销售方纳税人名称',width: 160},
                {field: 'taxpayerNumber',title: '销售方纳税人识别号',width: 160},
                {field: 'ticketType',title: '票种',width: 120,                     
                    templet: function (data) {
                        if (data.ticketType == '0') {
                            return '数电票(增值税专用发票)';
                        } else if (data.ticketType == '1') {
                            return '数电票(普通发票)';
                        } else if (data.ticketType == '2') {
                            return '数电票纸质发票(增值税专用发票)';
                        } else if (data.ticketType == '3') {
                            return '数电票纸质发票(普通发票)';
                        } else if (data.ticketType == '4') {
                            return '数电票(机动车销售统一发票)';
                        } else if (data.ticketType == '5') {
                            return '数电纸质发票(机动车销售统一发票)';
                        } else if (data.ticketType == '6') {
                            return '数电票(航空运输电子客行程单)';
                        } else if (data.ticketType == '7') {
                            return '数电票(铁路电子客票)';
                        } else if (data.ticketType == '8') {
                            return '机动车销售统一发票';
                        } else if (data.ticketType == '9') {
                            return '增值税专用发票';
                        } else if (data.ticketType == '10') {
                            return '增值税通发票';
                        } else if (data.ticketType == '11') {
                            return '增值税电子专用发票';
                        } else if (data.ticketType == '12') {
                            return '增值税电子普通发票';
                        } else {
                            return ''
                        }
                    }
                },
                {field: 'invoiceStatus',title: '发票状态',width: 120,
                    templet: function (data) {
                        if (data.invoiceStatus == '0') {
                            return '正常';
                        } else if (data.invoiceStatus == '1') {
                            return '作废';
                        } else if (data.invoiceStatus == '2') {
                            return '已红冲-部分';
                        } else if (data.invoiceStatus == '3') {
                            return '已红冲-全额';
                        } else {
                            return ''
                        }
                    }
                },
                {field: 'redFontLockFlag',title: '红字锁定标志',width: 120,
                    templet: function (data) {
                        if (data.redFontLockFlag == '0') {
                            return '未锁定';
                        } else if (data.redFontLockFlag == '1') {
                            return '已锁定';
                        } else {
                            return ''
                        }
                    }
                },
                {field: 'checkDate',title: '勾选时间',width: 120},
                {field: 'invoiceRiskLevel',title: '发票风险等级',width: 120,fixed: 'right',
                    templet: function (data) {
                        var str = ""
                        if (data.invoiceRiskLevel == '0') {
                            str  = '正常';
                        } else if (data.invoiceRiskLevel == '1') {
                            str  = '疑点发票';
                        } else if (data.invoiceRiskLevel == '2') {
                            str  = '异常凭证';
                        } else {
                            str  = '';
                        }
                        return '<div><span style="color:#00A870; background: #DCF5ED;padding: 6px 8px;">' + str + '</span></div>'
                    }
                },
                {field: 'redFontLockFlag',title: '红字锁定',width: 120,fixed: 'right',
                    templet: function (data) {
                        if (data.redFontLockFlag == '0') {
                            return '未锁定';
                        } else if (data.redFontLockFlag == '1') {
                            return '已锁定';
                        } else {
                            return ''
                        }
                    }
                }
            ]],
            page: true,
            id: 'invoiceTable',
            limit: 10,
            limits: [5, 10, 15],
            done: function (res, curr, count) {
                var suborders_data_arr = res.data;
                for (let suborders_key in suborders_data_arr) {
                    if (suborders_data_arr[suborders_key]['checkStatus'] == 0) {
                        let index = suborders_data_arr[suborders_key]['LAY_TABLE_INDEX'];
                        $('tr[data-index=' + index + '] input[type="checkbox"]').prop('disabled', true).attr("name","layTableCheckboxDisabled"); // 禁止部分选择
                        $('tr[data-index=' + index + '] input[type="checkbox"]').prop('checked', false);   // 取消选中
                    }
                };
                form.render('checkbox');
            }

        })

  • 9
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值