chooseReceiveUser.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. :status="status"
  20. :noDataText="noDataText"
  21. backValue="objArr"
  22. @ok="chooseOk">
  23. </uni-check-list>
  24. </template>
  25. <script>
  26. import {findUserList} from '@/api/user.js'
  27. export default {
  28. data() {
  29. return {
  30. list: [],
  31. value: [],
  32. noDataText: '暂无抄送人数据',
  33. type: '', // 单选或多选
  34. status: 'loading'
  35. }
  36. },
  37. onLoad(opts) {
  38. this.value = opts.item&&JSON.parse(opts.item)||[]
  39. this.type = opts.type && opts.type || 'checkbox'
  40. console.log(this.value)
  41. // 查询用户列表
  42. this.status = 'loading'
  43. uni.showLoading({
  44. title: '加载中...'
  45. })
  46. // 登录用户id
  47. const loginUserId = this.$store.state.vuex_userData.userid
  48. // console.log(loginUserId,'loginUserId')
  49. findUserList({loginFlag:'1'}).then(res=>{
  50. if(res.status == 200){
  51. this.list = res.data || []
  52. this.list.map(item=>{
  53. if (item.id==loginUserId) {
  54. item.disabled = true
  55. }
  56. })
  57. console.log(this.list,'this.list')
  58. } else {
  59. this.noDataText = res.message
  60. }
  61. this.status = 'nomore'
  62. uni.hideLoading()
  63. })
  64. },
  65. methods: {
  66. // 选中门店,item 返回的是数组
  67. chooseOk(item) {
  68. console.log(item)
  69. //关闭当前页面,这里处理数据逻辑
  70. uni.$emit("selKpUsers",item)
  71. uni.navigateBack()
  72. },
  73. }
  74. }
  75. </script>
  76. <style lang="scss">
  77. page{
  78. height: 100%;
  79. }
  80. </style>