checkPointList.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <view class="warp">
  3. <uni-section title="商家列表" type="line">
  4. <uni-data-select v-model="shopId" :localdata="shopList" placeholder="请选择商家" @change="handleShopChange"
  5. class="padding" />
  6. </uni-section>
  7. <uni-section v-if="controlInfoList.length > 0" title="检查点列表" type="line">
  8. <uni-list>
  9. <uni-list-item v-for="item in controlInfoList" :key="item.ciid" showArrow :title="item.cicode"
  10. :clickable="true" @click="handleCiClick(item.ciid)" />
  11. <!-- <uni-list-item showArrow title="列表文字" rightText="右侧文字" /> -->
  12. </uni-list>
  13. </uni-section>
  14. </view>
  15. </template>
  16. <script>
  17. import {
  18. DefaultRequest,
  19. IdRequest
  20. } from "@/grpc/app_api_pb.js"
  21. // import { mobileUtils } from "@/utils/util.js"
  22. export default {
  23. components: {},
  24. data() {
  25. return {
  26. shopId: 0,
  27. shopList: [],
  28. controlInfoList: []
  29. }
  30. },
  31. computed: {},
  32. mounted() {},
  33. onLoad() {
  34. this.getShopList()
  35. },
  36. methods: {
  37. getShopList() {
  38. // 创建请求参数并赋值
  39. var request = new DefaultRequest()
  40. // 调用客户端相应的grpc方法,发送grpc请求,并接受后台发送回来的返回值
  41. this.$client.assShopList(request, {}, (err, response) => {
  42. if (err) {
  43. console.log(`[assShopList] err: code = ${err.code}` +
  44. `, message = "${err.message}"`)
  45. } else {
  46. // console.log(response)
  47. // let res = response.getListList()
  48. // let res = response.assShopListReply()
  49. // let res = this.$client.assShopListReply(response)
  50. // console.log(res)
  51. // console.log(res[0].toObject())
  52. let res = response.toObject().listList
  53. // console.log(res)
  54. let len = res.length
  55. this.shopList.length = 0 // 清空整个数组
  56. for (let i = 0; i < len; i++) {
  57. this.shopList[i] = {
  58. value: res[i].shopid,
  59. text: res[i].name,
  60. }
  61. }
  62. }
  63. });
  64. },
  65. getControlInfoList(shopId) {
  66. // 创建请求参数并赋值
  67. var request = new IdRequest()
  68. request.setId(shopId)
  69. // 调用客户端相应的grpc方法,发送grpc请求,并接受后台发送回来的返回值
  70. this.$client.assControlInfoList(request, {}, (err, response) => {
  71. if (err) {
  72. console.log(`[assControlInfoList] err: code = ${err.code}` +
  73. `, message = "${err.message}"`)
  74. } else {
  75. let res = response.toObject().listList
  76. // console.log(res)
  77. this.controlInfoList.length = 0 // 清空整个数组
  78. this.controlInfoList = res
  79. }
  80. })
  81. },
  82. handleShopChange(shopId) {
  83. console.log("shopId:" + shopId)
  84. this.getControlInfoList(shopId)
  85. },
  86. handleCiClick(ciId) {
  87. console.log("ciId:" + ciId)
  88. uni.navigateTo({
  89. // url: '/pages/checkPoint/checkPointDetail',
  90. url: './checkPointDetail?ciId=' + ciId
  91. })
  92. }
  93. }
  94. }
  95. </script>
  96. <style lang="scss">
  97. .padding {
  98. padding: 0 20rpx;
  99. }
  100. </style>