evaluateStore.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. :noDataText="noDataText"
  20. backValue="objArr"
  21. @ok="chooseOk">
  22. </uni-check-list>
  23. </template>
  24. <script>
  25. import {findStoreList,findAllStore} from '@/api/store'
  26. export default {
  27. data() {
  28. return {
  29. list: [],
  30. value: [],
  31. noDataText: '暂无考评门店',
  32. type: '' // 单选或多选
  33. }
  34. },
  35. onUnload() {
  36. this.value = []
  37. this.list = []
  38. },
  39. onLoad(opts) {
  40. this.value = opts.item&&JSON.parse(opts.item)||[]
  41. this.value.map(item=>{
  42. item.id = item.storeId || item.id
  43. })
  44. this.type = opts.type || 'checkbox'
  45. if(opts.isAll == '1'){
  46. // 所有门店
  47. this.findAllStore()
  48. }else{
  49. // 查询门店
  50. this.findStoreList()
  51. }
  52. },
  53. methods: {
  54. // 查询门店
  55. findStoreList(){
  56. findStoreList({}).then(res=>{
  57. if(res.status == 200){
  58. this.list = res.data || []
  59. } else {
  60. this.noDataText = res.message
  61. }
  62. })
  63. },
  64. // 查询所有门店
  65. findAllStore(){
  66. findAllStore({}).then(res=>{
  67. if(res.status == 200){
  68. this.list = res.data || []
  69. } else {
  70. this.noDataText = res.message
  71. }
  72. })
  73. },
  74. // 选中门店,item 返回的是数组
  75. chooseOk(item) {
  76. console.log(item)
  77. if(item.length){
  78. //关闭当前页面,这里处理数据逻辑
  79. uni.$emit("selKpStores",item)
  80. uni.navigateBack()
  81. }else{
  82. uni.showToast({
  83. title:"请选择考评门店"
  84. })
  85. }
  86. },
  87. }
  88. }
  89. </script>
  90. <style lang="scss">
  91. page{
  92. height: 100%;
  93. }
  94. </style>