toDaySugarList.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <!-- 今日做糖列表 -->
  3. <div class="sugarPage 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 class="o-pt-20" v-model:loading="loading" :finished="finished" :finished-text="$t('public.noMore')"
  11. @load="selectSugarListFun">
  12. <van-cell v-for="(item, index) in list" :key="index" :title="item" />
  13. </van-list>
  14. </div>
  15. </div>
  16. </template>
  17. <script>
  18. import {
  19. onMounted,
  20. ref
  21. } from "vue";
  22. import sHeader from "@/components/SimpleHeader";
  23. import {
  24. getDeviceDetal,
  25. selectSugarList
  26. } from "@/service/device";
  27. import {
  28. showFailToast
  29. } from "vant";
  30. import {
  31. getLoginUser,
  32. styleUrl
  33. } from "@/common/js/utils";
  34. import {
  35. useRoute
  36. } from 'vue-router';
  37. export default {
  38. setup() {
  39. const route = useRoute();
  40. const deviceId = route.query.deviceId;
  41. const deviceDetal = ref(null);
  42. const loading = ref(false);
  43. const finished = ref(false);
  44. const user = getLoginUser();
  45. const list = ref([]);
  46. // 初始化页面获取列表
  47. onMounted(async () => {
  48. // 加载样式
  49. styleUrl('doSugar');
  50. getDeviceDetalFun();
  51. selectSugarListFun();
  52. // console.log(deviceDetal);
  53. });
  54. // 获取设备数据
  55. const getDeviceDetalFun = async () => {
  56. const {
  57. data
  58. } = await getDeviceDetal({
  59. id: deviceId
  60. });
  61. if (data.code === '00000') {
  62. deviceDetal.value = data.data;
  63. } else {
  64. showFailToast(data.message);
  65. }
  66. }
  67. // 获取做糖列表数据
  68. const selectSugarListFun = async () => {
  69. // console.log(user);
  70. const {
  71. data
  72. } = await selectSugarList({
  73. adminId: user.id
  74. });
  75. if (data.code) {
  76. list.value = data.data.map((item) => {
  77. return item.productName;
  78. });
  79. finished.value = true;
  80. } else {
  81. showFailToast(data.message);
  82. }
  83. };
  84. return {
  85. list,
  86. deviceDetal,
  87. loading,
  88. finished,
  89. selectSugarListFun,
  90. };
  91. },
  92. components: {
  93. sHeader
  94. },
  95. };
  96. </script>
  97. <style lang="less" scoped>
  98. @import "../../common/style/common";
  99. </style>