planrecord.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <view class="container">
  3. <view class="list-item">
  4. <view class="item" v-for="item in chargeList" :key="item.id">
  5. <view class="item-header">
  6. <view class="item-title">
  7. {{i18('设备编号')}}:{{ item.deviceId }}
  8. </view>
  9. <view class="item-status">
  10. <uni-tag type="success" :text="i18('激活中')" v-if="item.status === 1"></uni-tag>
  11. <uni-tag type="error" :text="i18('已停用')" v-if="item.status === 2"></uni-tag>
  12. <uni-tag type="success" :text="i18('已执行')" v-if="item.status === 3"></uni-tag>
  13. </view>
  14. </view>
  15. <view class="item-body">
  16. <view style="font-size: 12px">
  17. {{i18('预约类型')}}:
  18. <uni-tag type="primary" :text="i18('单次')" v-if="item.planType === 1"></uni-tag>
  19. <uni-tag type="warning" :text="i18('重复')" v-if="item.planType === 2"></uni-tag>
  20. </view>
  21. <view style="font-size: 12px; margin: 5px 0">
  22. {{i18('创建时间')}}:{{ item.createTime }}
  23. </view>
  24. <view v-if="item.planType === 2">
  25. <view class="item-time">{{i18('重复日期')}}:{{ formatRepeatDays(item.repeatDays) }}</view>
  26. <view class="item-time">{{i18('重复时间')}}:{{ item.repeatTime }}</view>
  27. </view>
  28. <view v-if="item.planType === 1">
  29. <view class="item-time">{{i18('执行时间')}}:{{ item.runTime }}</view>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. <uni-load-more @clickLoadMore="getMore" :content-text="contentText" :status="startText"></uni-load-more>
  35. </view>
  36. </template>
  37. <script>
  38. import { plan } from '@/api/device/plan.js';
  39. import i18 from '@/utils/i18.js'
  40. export default {
  41. data() {
  42. return {
  43. startText:"more",
  44. search:{
  45. pageNum:1,
  46. pageSize:6,
  47. reasonable:true,
  48. },
  49. contentText: {
  50. contentdown: i18('点击查看更多'),
  51. contentrefresh: i18('加载中'),
  52. contentnomore: i18('没有更多'),
  53. },
  54. chargeList: [],
  55. };
  56. },
  57. onShow(){
  58. uni.setNavigationBarTitle({
  59. title: this.$t('page.planrecord')
  60. })
  61. },
  62. methods: {
  63. i18(text){
  64. return i18(text)
  65. },
  66. getMore(){
  67. this.search.pageNum++;
  68. this.planRecord();
  69. },
  70. async planRecord() {
  71. plan(this.search).then(res=>{
  72. if(res.data.length == 0){
  73. this.$modal.showToast("没有更多数据了");
  74. this.startText = "no-more"
  75. }else{
  76. this.startText = "more"
  77. this.chargeList = this.chargeList.concat(res.data);
  78. }
  79. })
  80. },
  81. formatRepeatDays(daysStr) {
  82. const days = daysStr.split(',');
  83. const weekdays = ['周一', '周二', '周三', '周四', '周五', '周六', '周日'];
  84. const result = [];
  85. for (const day of days) {
  86. const weekday = weekdays[parseInt(day) - 1];
  87. result.push(i18(weekday));
  88. }
  89. return result.join(' ');
  90. },
  91. },
  92. created() {
  93. this.planRecord();
  94. },
  95. };
  96. </script>
  97. <style>
  98. .container {
  99. background: rgb(249, 252, 255);
  100. inset: 0;
  101. position: absolute;
  102. }
  103. .list-item {
  104. margin: 0vw;
  105. }
  106. .item {
  107. box-shadow: 0px 5px 27px 0px rgba(195, 195, 195, 0.4);
  108. border-radius: 4px;
  109. background: #FFFFFF;
  110. margin: 4vw;
  111. padding: 4vw;
  112. }
  113. .item-title {
  114. display: inline-block;
  115. float: left;
  116. }
  117. .item-status {
  118. display: inline-block;
  119. float: right;
  120. }
  121. .item-header {
  122. border-bottom: 1px solid lightgray;
  123. height: 4vh;
  124. font-size: 12px;
  125. }
  126. .item-body {
  127. padding-top: 4vw;
  128. line-height: 3vh;
  129. }
  130. .item-time {
  131. color: #545454;
  132. font-size: 12px;
  133. margin-bottom: 4px
  134. }
  135. </style>