首页 > 其他分享 >AntDeisgn中checkbox group的使用

AntDeisgn中checkbox group的使用

时间:2023-05-16 15:00:35浏览次数:38  
标签:AntDeisgn checkbox group name checkboxAttr length state code checkedList

<template>
  <!-- 弹窗类型选择 -->
    <div>
        <a-modal :visible="state.modalAttr.visible" title="规选类型" width="680px" @ok="showModal" @cancel="hideModal">
            <a-checkbox
                    v-model:checked="state.checkboxAttr.checkAll"
                    :indeterminate="state.checkboxAttr.indeterminate"
                    @change="onCheckAllChange"
            >
                <span style="color: white">全选</span>
            </a-checkbox>
            <a-checkbox-group v-model:value="state.checkboxAttr.checkedList">
                <a-checkbox v-for="opt in state.categoryOpts" :value="opt.code" @change="onChange">
                    <span style="color: white">{{ opt.name }}</span>
                </a-checkbox>
            </a-checkbox-group>
        </a-modal>
    </div>
</template>

<script setup>
import {defineComponent, ref, reactive, watch, defineExpose, defineEmits, toRaw, onBeforeUnmount, onMounted} from 'vue';

const state = reactive({
    modalAttr: {
        visible: true,
    },
    checkboxAttr: {
        indeterminate: true,
        checkedList: [],
        checkAll: false,
    },
    categoryOpts: [{
        name: '实有单位',
        code: 'SYDW',
    }, {
        name: '标准地址',
        code: 'JZW',
    }, {
        name: '实有房屋',
        code: 'SYFW'
    }, {
        name: '实有人口',
        code: 'SYRK'
    }, {
        name: '层户信息',
        code: 'CHJGXXB',
    }]
})

const showModal = () => {
    console.log('state.checkboxAttr.checkedArr::: ', state.checkboxAttr.checkedList)
    return;
    state.modalAttr.visible = true;
}

const hideModal = () => {
    state.modalAttr.visible = false;
}

const onChange = (e, index) => {//单个选择
    state.checkboxAttr.indeterminate = !!state.checkboxAttr.checkedList.length && state.checkboxAttr.checkedList.length < state.categoryOpts.length;
    state.checkboxAttr.checkAll = state.checkboxAttr.checkedList.length === state.categoryOpts.length;
}

const onCheckAllChange = (e, index) => {//选择全部的事件
    if (e.target.checked) {
        state.checkboxAttr.indeterminate = false;
        state.checkboxAttr.checkedList = state.categoryOpts.map(item => {
            return item?.code;
        })
    } else {
        state.checkboxAttr.indeterminate = false;
        state.checkboxAttr.checkedList = []
    }
}

watch
(
    () => state.checkboxAttr.checkedList,
    val => {
        state.checkboxAttr.indeterminate = false;
        state.checkboxAttr.checkAll = state.checkboxAttr.checkedList.length === 5;
        console.log('state.checkboxAttr.checkedList:::: ', state.checkboxAttr.checkedList)
    },
);


</script>

<style scoped lang="scss">
:deep(ant-modal-title) {
  color: white;
}
</style>

标签:AntDeisgn,checkbox,group,name,checkboxAttr,length,state,code,checkedList
From: https://www.cnblogs.com/openmind-ink/p/17405674.html

相关文章

  • Bela Ban's JGroups Manual Translation Serial IV - 协议栈和高级概念
    本章讨论怎么样正确使用和配置JGroups的协议栈协议,以及一些 JGroups 的高级概念。1.jGroups协议栈   我们知道jGroups是一个可靠多播传输工具包,它能够为集群中成员提供点对点,点对组的通信,所有通信通过通道完成。通道基于协议栈之上,协议栈中协议各自有自己特别的功能,这些功能......
  • el-checkbox中设置不可编辑
    做项目遇到el-checkbox需要不可编辑,必须固定选择的需求,首先想到的肯定是disabled,但是disabled的样式不很好看,你接下来可能还会想到readonly,然后你就会发现checkbox上面没有readonly这个属性。那我们怎么办呢! 下面是我的两个方法: 1,既然disabled不好看,那当然我们可以通过dee......
  • 如何保证group by 留下的数据是想要的那一条
    比如我想要groupby结果为日期最大的一条使用子查询,先将数据使用orderby按日期字段排序,再在外层使用groupby分组。留下的数据是:如groupbya那留下的是orderbya后的第一条;所以如果想要留下一定的数据,请先嵌套一层查询,如select*from(select*fromtable_a......
  • Linq to SQL 多表Group By
    varpark=_context.ParkCountRecordsvararea=_context.AreaInfos;vardata=frompinparkjoinainareaonp.ProCodeequalsa.Codegroupp.ParkingNumb......
  • el-tree 根据多个结果筛选树状图(增加checkbox勾选)
    <template><divclass="wrapper-jjy"><el-dialogtitle="接警员查找"v-model="jjyDialogVisible":draggable="true"width="735px"height="300":close-on-click-modal="true&q......
  • c#设置checkbox选中状态
    this.checkBox1.Checked=true;//设置默认勾选......
  • AtCoder Beginner Contest 217 G Groups
    洛谷传送门AtCoder传送门不妨钦定组之间的顺序是最小值越小的组越靠前,这样可以给每个组按顺序编号。设\(f_{i,j}\)为考虑了模\(m\)后\(<i\)的数,目前有\(j\)个非空组的方案数。转移就是枚举模\(m=i-1\)的数新开了\(k\)个组,设\(\len\)的数中模\(m=i-1......
  • 关于docker的Cgroup Driver相关的配置说明以及其值为cgroupfs与systemd的区别
    在我们安装完docker-ce软件后(笔者这里安装的docker-ce-20.10.24-3.el8.x86_64)就可以直接启动docker服务 systemctlrestartdocker.service这时我们通过 dockerinfo命令,可以看到当前docker的一些配置信息,今天笔者主要是看CgroupDriver相关的,如下:[root@k8s-masterqq-5201......
  • 修改docker的cgroup driver为systemd
    简单来说修改docker的cgroupdriver为systemd的原因是因为在文档CRIinstallation中的相关说明:“使用systemd作为initsystem的Linux的发行版,使用systemd作为docker的cgroupdriver可以确保服务器节点在资源紧张的情况更加稳定”。但是在修改后发现自己的docker服务无法正常启动,以......
  • 从案例中详解go-errgroup-源码
    一、背景某次会议上发表了errorgroup包,一个g失败,其他的g会同时失败的错误言论(看了一下源码中的一句话Thefirstcalltoreturnanon-nilerrorcancelsthegroup,没进一步看其他源码,片面理解了)。//Thefirstcalltoreturnanon-nilerrorcancelsthegroup'scontext......