toDaySugarList.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <!-- 今日做糖列表 -->
  3. <div class="page flex-col">
  4. <s-header :name="$t('device.todaysSugarList')" :noback="false"></s-header>
  5. <div class="box1 flex-col">
  6. <div class="block2 flex-row justify-between">
  7. <div class="block3 flex-col"></div>
  8. <span class="info2">{{ $t('device.equipmentName') }}:{{ deviceDetal ? deviceDetal.name : '' }}</span>
  9. </div>
  10. <van-list
  11. class="o-pt-20"
  12. v-model:loading="loading"
  13. :finished="finished"
  14. :finished-text="$t('public.noMore')"
  15. @load="selectSugarListFun"
  16. >
  17. <van-cell v-for="(item, index) in list" :key="index" :title="item" />
  18. </van-list>
  19. </div>
  20. </div>
  21. </template>
  22. <script>
  23. import {
  24. onMounted,
  25. ref
  26. } from "vue";
  27. import sHeader from "@/components/SimpleHeader";
  28. import {
  29. getDeviceDetal,
  30. selectSugarList
  31. } from "@/service/device";
  32. import {
  33. Toast
  34. } from "vant";
  35. import {
  36. getLoginUser
  37. } from "@/common/js/utils";
  38. import {
  39. useRoute
  40. } from 'vue-router';
  41. export default {
  42. setup() {
  43. const route = useRoute();
  44. const deviceId = route.query.deviceId;
  45. const deviceDetal = ref(null);
  46. const loading = ref(false);
  47. const finished = ref(false);
  48. const user = getLoginUser();
  49. const list = ref([]);
  50. // 初始化页面获取列表
  51. onMounted(async () => {
  52. getDeviceDetalFun();
  53. selectSugarListFun();
  54. // console.log(deviceDetal);
  55. });
  56. // 获取设备数据
  57. const getDeviceDetalFun = async () => {
  58. const {
  59. data
  60. } = await getDeviceDetal({
  61. id: deviceId
  62. });
  63. if (data.code === '00000') {
  64. deviceDetal.value = data.data;
  65. } else {
  66. Toast.fail(data.message);
  67. }
  68. }
  69. // 获取做糖列表数据
  70. const selectSugarListFun = async () => {
  71. // console.log(user);
  72. const {
  73. data
  74. } = await selectSugarList({
  75. adminId: user.id
  76. });
  77. if (data.code) {
  78. list.value = data.data.map((item) => {
  79. return item.productName;
  80. });
  81. finished.value = true;
  82. } else {
  83. Toast.fail(data.message);
  84. }
  85. };
  86. return {
  87. list,
  88. deviceDetal,
  89. loading,
  90. finished,
  91. selectSugarListFun,
  92. };
  93. },
  94. components: {
  95. sHeader
  96. },
  97. };
  98. </script>
  99. <style lang="less" scoped>
  100. @import "../../common/style/common";
  101. .page {
  102. position: relative;
  103. width: 375px;
  104. height: calc(100vh - 44px);
  105. .box1 {
  106. width: 100%;
  107. height: 237px;
  108. .block2 {
  109. width: 162px;
  110. height: 20px;
  111. margin: 18px 0 0 15px;
  112. .block3 {
  113. background-color: rgba(128, 150, 236, 1);
  114. border-radius: 2px;
  115. width: 4px;
  116. height: 12px;
  117. margin-top: 4px;
  118. }
  119. .info2 {
  120. width: 150px;
  121. height: 20px;
  122. overflow-wrap: break-word;
  123. color: rgba(64, 77, 116, 1);
  124. font-size: 14px;
  125. font-family: PingFangSC-Medium;
  126. text-align: left;
  127. white-space: nowrap;
  128. line-height: 20px;
  129. display: block;
  130. }
  131. }
  132. }
  133. }
  134. </style>