1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <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"
- backValue="objArr"
- @ok="chooseOk">
- </uni-check-list>
- </template>
- <script>
- import {findStoreList} from '@/api/store'
- export default {
- data() {
- return {
- list: [],
- value: [],
- type: '' // 单选或多选
- }
- },
- onLoad(opts) {
- this.value = opts.item&&JSON.parse(opts.item)||[]
- console.log(this.value)
- this.value.map(item=>{
- item.id = item.storeId
- })
- this.type = opts.type && opts.type || 'checkbox'
- // 查询门店
- findStoreList({}).then(res=>{
- onsole.log(res.data)
- if(res.status == 200){
- this.list = res.data || []
- }
- })
- },
- methods: {
- // 选中门店,item 返回的是数组
- chooseOk(item) {
- console.log(item)
- //关闭当前页面,这里处理数据逻辑
- uni.$emit("selKpStores",item)
- uni.navigateBack()
- },
- }
- }
- </script>
- <style lang="scss">
- page{
- height: 100%;
- }
- </style>
|