evaluateStore.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <template>
  2. <!-- @rightClick 只有存在右边部分的情况下才使用,
  3. 右边默认为空,可以使用slot="right" 自定义右边内容
  4. @ok 是单选或多选最终返回的结果
  5. types 类型 radio或checkbox
  6. titleKeys 标题对应的字段名称key,默认是name
  7. listData 是数据
  8. showArrow 是否显示右边箭头
  9. backValue 设置返回的数据是idArr [id,id,...] 或 objArr [obj,obj,...]
  10. defValue 设置已选择的数据,格式和backValue 一致
  11. checkIconPositon 选择图标显示左边还是右边 left or right
  12. -->
  13. <uni-check-list
  14. :listData="list"
  15. checkIconPositon="right"
  16. :showArrow="false"
  17. :defValue="value"
  18. :types="type"
  19. backValue="objArr"
  20. @ok="chooseOk">
  21. </uni-check-list>
  22. </template>
  23. <script>
  24. import {findStoreList} from '@/api/store'
  25. export default {
  26. data() {
  27. return {
  28. list: [],
  29. value: [],
  30. type: '' // 单选或多选
  31. }
  32. },
  33. onLoad(opts) {
  34. this.value = opts.item&&JSON.parse(opts.item)||[]
  35. this.value.map(item=>{
  36. item.id = item.storeId
  37. })
  38. this.type = opts.type && opts.type || 'checkbox'
  39. console.log(this.value)
  40. // 查询门店
  41. findStoreList({}).then(res=>{
  42. if(res.status == 200){
  43. this.list = res.data || []
  44. }
  45. })
  46. },
  47. methods: {
  48. // 选中门店,item 返回的是数组
  49. chooseOk(item) {
  50. console.log(item)
  51. //关闭当前页面,这里处理数据逻辑
  52. uni.$emit("selKpStores",item)
  53. uni.navigateBack()
  54. },
  55. }
  56. }
  57. </script>
  58. <style lang="scss">
  59. page{
  60. height: 100%;
  61. }
  62. </style>