<template> <!-- @rightClick 只有存在右边部分的情况下才使用, 右边默认为空,可以使用slot="right" 自定义右边内容 @ok 是单选或多选最终返回的结果 types 类型 radio或checkbox titleKeys 标题对应的字段名称key,默认是name listData 是数据 showArrow 是否显示右边箭头 backValue 设置返回的数据是idArr [id,id,...] 或 objArr [obj,obj,...] defValue 设置已选择的数据,格式和backValue 一致 checkIconPositon 选择图标显示左边还是右边 left or right --> <uni-check-list :listData="list" checkIconPositon="right" :showArrow="false" :defValue="value" :types="type" :noDataText="noDataText" backValue="objArr" @ok="chooseOk"> </uni-check-list> </template> <script> import {findStoreList} from '@/api/store' export default { data() { return { list: [], value: [], noDataText: '暂无考评门店', type: '' // 单选或多选 } }, onUnload() { this.value = [] this.list = [] }, onLoad(opts) { this.value = opts.item&&JSON.parse(opts.item)||[] this.value.map(item=>{ item.id = item.storeId || item.id }) this.type = opts.type || 'checkbox' // 查询门店 findStoreList({}).then(res=>{ if(res.status == 200){ this.list = res.data || [] } else { this.noDataText = res.message } }) }, methods: { // 选中门店,item 返回的是数组 chooseOk(item) { console.log(item) //关闭当前页面,这里处理数据逻辑 uni.$emit("selKpStores",item) uni.navigateBack() }, } } </script> <style lang="scss"> page{ height: 100%; } </style>