history.vue 7.9 KB

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