history.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. <template>
  2. <view class="history-container">
  3. <custom-card>
  4. <block slot="backText">{{ title }}</block>
  5. </custom-card>
  6. <view class="calendar" @tap="handleCalendarClick">
  7. <view class="calendar__label">选择日期</view>
  8. <view class="calendar__content">
  9. <text>{{ startTime }}</text>
  10. <text class="separate">-</text>
  11. <text>{{ endTime }} </text>
  12. </view>
  13. <view class="calendar__link">
  14. <u-icon name="arrow-right" color="#4e5969"></u-icon>
  15. </view>
  16. </view>
  17. <view class="history-form-container">
  18. <view class="form-header">
  19. <view class="form-header__title">设备名称</view>
  20. <view class="form-header__title">操作内容</view>
  21. <view class="form-header__title">操作人</view>
  22. <view class="form-header__title">操作时间</view>
  23. </view>
  24. <view class="scroll-container">
  25. <scroll-view
  26. class="main__right"
  27. v-if="historyList.length !== 0"
  28. scroll-y="true"
  29. style="height: 100%"
  30. @scrolltolower="scrolltolower"
  31. :show-scrollbar="true"
  32. >
  33. <view class="form-content" v-for="item in historyList" :key="item">
  34. <view class="form-content__item">{{ item.oprecdName }}</view>
  35. <view class="form-content__item">
  36. <view class="item-open" v-if="item.oprecdContent == '打开'"
  37. >打开</view
  38. >
  39. <view class="item-close" v-else>{{ item.oprecdContent }}</view>
  40. </view>
  41. <view class="form-content__item">{{ item.oprcdCreatorName }}</view>
  42. <view class="form-content__item">
  43. <view class="item-time">{{
  44. getTopTime(item.oprcdCreateddate)
  45. }}</view>
  46. <view class="item-date">{{
  47. getYearTime(item.oprcdCreateddate)
  48. }}</view>
  49. </view>
  50. </view>
  51. </scroll-view>
  52. <u-empty v-else style="height: 80%"
  53. /></view>
  54. </view>
  55. <u-calendar
  56. v-model="show"
  57. mode="range"
  58. @change="handleConfirm"
  59. ></u-calendar>
  60. </view>
  61. </template>
  62. <script>
  63. import solenoidValve from './assets/solenoidValve.png';
  64. export default {
  65. name: 'actionHistory',
  66. data() {
  67. return {
  68. title: '操作记录',
  69. devBid: '',
  70. pageSize: 20,
  71. pageNum: 1,
  72. show: false,
  73. // 获取当前日期向前3个月
  74. startTime: this.formartDate(3),
  75. endTime: this.formartDate(),
  76. historyList: [],
  77. total: 0,
  78. };
  79. },
  80. computed: {
  81. hasMore() {
  82. return this.total > 0 && this.total > this.pageNum * this.pageSize;
  83. },
  84. },
  85. methods: {
  86. getTopTime(date) {
  87. return date.split(' ')[1];
  88. },
  89. getYearTime(date) {
  90. return date.split(' ')[0];
  91. },
  92. async getHistory() {
  93. const res = await this.$myRequest({
  94. url: '/api/v2/iot/mobile/device/sf/op/record/list/',
  95. method: 'post',
  96. data: {
  97. pageSize: this.pageSize,
  98. pageNum: this.pageNum,
  99. startTime: this.startTime + ' 00:00:00',
  100. endTime: this.endTime + ' 23:59:59',
  101. devBid: this.devBid,
  102. },
  103. sfType: true,
  104. });
  105. this.historyList = this.historyList.concat(res?.data);
  106. this.total = res.total;
  107. },
  108. formartDate(month = 0) {
  109. const time = month * 30 * 24 * 60 * 60 * 1000;
  110. const timeStamp = new Date(new Date().getTime() - time);
  111. const year = timeStamp.getFullYear();
  112. const monthDate = timeStamp.getMonth() + 1;
  113. const monthStr = monthDate < 10 ? `0${monthDate}` : monthDate;
  114. const day = new Date().getDate();
  115. const dayStr = day < 10 ? `0${day}` : day;
  116. return `${year}-${monthStr}-${dayStr}`;
  117. },
  118. handleCalendarClick() {
  119. this.show = true;
  120. },
  121. handleClose() {
  122. this.show = false;
  123. },
  124. scrolltolower() {
  125. console.log('scroll');
  126. if (this.hasMore) {
  127. this.pageNum++;
  128. this.getHistory();
  129. }
  130. },
  131. handleConfirm(e) {
  132. this.pageNum = 1;
  133. const { startDate, endDate } = e;
  134. this.startTime = startDate;
  135. this.endTime = endDate;
  136. this.getHistory();
  137. },
  138. },
  139. onLoad(options) {
  140. const { devBid } = options;
  141. this.devBid = devBid;
  142. this.getHistory();
  143. },
  144. };
  145. </script>
  146. <style scoped lang="scss">
  147. uni-page-body {
  148. position: relative;
  149. height: 100%;
  150. }
  151. ::v-deep .u-calendar__action {
  152. display: flex;
  153. justify-content: center;
  154. align-items: center;
  155. }
  156. ::v-deep .u-hover-class {
  157. opacity: 0.6;
  158. }
  159. .scroll-container {
  160. height: calc(100% - 160rpx);
  161. }
  162. .history-container {
  163. background: linear-gradient(180deg, #ffffff00 0%, #fff 23.64%, #fff 100%),
  164. linear-gradient(102deg, #bfeadd 6.77%, #b8f1e7 40.15%, #b9eef5 84.02%);
  165. height: 100%;
  166. width: 100%;
  167. overflow-x: hidden;
  168. overflow-y: hidden;
  169. .calendar {
  170. position: relative;
  171. display: flex;
  172. align-items: center;
  173. padding: 0 32rpx;
  174. line-height: 64rpx;
  175. border-radius: 16rpx;
  176. background-color: #fff;
  177. margin: 0 32rpx;
  178. &__icon {
  179. margin-right: 12rpx;
  180. }
  181. &__label {
  182. font-size: 28rpx;
  183. color: #666;
  184. margin-right: 10rpx;
  185. }
  186. &__content {
  187. font-size: 28rpx;
  188. color: #666;
  189. margin-left: 64rpx;
  190. .separate {
  191. margin: 0 6rpx;
  192. }
  193. }
  194. &__link {
  195. position: absolute;
  196. right: 20rpx;
  197. top: 50%;
  198. transform: translateY(-50%);
  199. }
  200. }
  201. .history-form-container {
  202. width: calc(100% - 64rpx);
  203. height: calc(100% - 128rpx);
  204. margin: 32rpx;
  205. border-radius: 16rpx;
  206. background: #fff;
  207. overflow-x: hidden;
  208. overflow-y: scroll;
  209. .form-header {
  210. display: flex;
  211. justify-content: space-between;
  212. align-items: center;
  213. height: 80rpx;
  214. width: 100%;
  215. border-bottom: 2rpx solid #e4e7ed;
  216. &__title {
  217. width: 25%;
  218. text-align: center;
  219. font-size: 28rpx;
  220. color: #042118;
  221. font-family: 'Source Han Sans CN VF';
  222. font-style: normal;
  223. font-weight: 400;
  224. line-height: normal;
  225. }
  226. }
  227. .form-content {
  228. display: flex;
  229. justify-content: space-between;
  230. align-items: center;
  231. height: 96rpx;
  232. width: 100%;
  233. border-bottom: 2rpx solid #e4e7ed;
  234. &__item {
  235. width: 25%;
  236. text-align: center;
  237. font-size: 28rpx;
  238. font-family: 'Source Han Sans CN VF';
  239. font-style: normal;
  240. color: #042118;
  241. .item-open {
  242. display: inline-flex;
  243. height: 40rpx;
  244. padding: 4rpx 16rpx;
  245. justify-content: center;
  246. align-items: center;
  247. border-radius: 20rpx;
  248. background: #14a47824;
  249. color: #14a478;
  250. font-family: 'Source Han Sans CN VF';
  251. font-size: 24rpx;
  252. font-weight: 400;
  253. }
  254. .item-close {
  255. display: inline-flex;
  256. height: 40rpx;
  257. padding: 4rpx 16rpx;
  258. justify-content: center;
  259. align-items: center;
  260. border-radius: 20rpx;
  261. background: #7a82911a;
  262. color: #7a8291;
  263. font-family: 'Source Han Sans CN VF';
  264. font-size: 24rpx;
  265. font-weight: 400;
  266. }
  267. .item-time {
  268. color: #042118;
  269. font-family: 'Source Han Sans CN VF';
  270. font-size: 28rpx;
  271. font-weight: 400;
  272. }
  273. .item-date {
  274. color: #042118;
  275. font-family: 'Source Han Sans CN VF';
  276. font-size: 24rpx;
  277. font-weight: 400;
  278. }
  279. }
  280. }
  281. }
  282. }
  283. </style>