<u-modal :show="showPicker" title='标题' @confirm="onPostsPickConfirm"> <view> <view style="width: 100%; margin-bottom: 40rpx"> <u-button type="primary" text="全选" @click="onPickAllPosts" size="small"></u-button> </view> <view style="width: 340rpx" > <u-checkbox-group size="20" borderBottom v-model="checkboxVlue" iconPlacement="right" placement="column"> <u-checkbox v-for="(item, index) in checkboxList" :key="index" :customStyle="{ marginBottom: '20rpx' }" :label="item.NAME" :name="item.NAME" @change="onPostsChange(index)" ></u-checkbox> </u-checkbox-group> </view> </view> </u-modal>
script:
data() { return {
showPicker: false,
checkboxVlue: '',
checkboxList: [],
ylmd: [{ID:1,NAME:'BB'}],
},
methods: {
onPostsPickConfirm() { this.showPicker = false this.zhKgYyName= this.checkboxVlue.join(',') this.data.zhKgYyId=Object.values(this.zhKgYyId).join(',') },
onPickAllPosts() { this.checkboxVlue = this.ylmd.map((x) => x.NAME) }, onPostsChange(index){ if(this.zhKgYyId[index]){ delete this.zhKgYyId[index]; }else{ this.zhKgYyId[index]=this.ylmd[index].ID; } }
}