history.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  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 form-content__item--text">{{
  39. item.oprecdName
  40. }}</view>
  41. <view class="form-content__item">
  42. <view class="item-open" v-if="item.oprecdContent == '打开'"
  43. >打开</view
  44. >
  45. <view class="item-close" v-else>{{ item.oprecdContent }}</view>
  46. </view>
  47. <view class="form-content__item">{{ item.oprcdCreatorName }}</view>
  48. <view class="form-content__item">
  49. <view class="item-time">{{
  50. getTopTime(item.oprcdCreateddate)
  51. }}</view>
  52. <view class="item-date">{{
  53. getYearTime(item.oprcdCreateddate)
  54. }}</view>
  55. </view>
  56. </view>
  57. </scroll-view>
  58. <u-empty v-else style="height: 80%"
  59. /></view>
  60. </view>
  61. <u-calendar
  62. v-model="show"
  63. mode="range"
  64. @change="handleConfirm"
  65. ></u-calendar>
  66. <!-- <wu-calendar
  67. ref="calendar"
  68. mode="range"
  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. header: {
  112. 'Content-Type': 'application/x-www-form-urlencoded',
  113. },
  114. data: {
  115. pageSize: this.pageSize,
  116. pageNum: this.pageNum,
  117. startTime: this.startTime + ' 00:00:00',
  118. endTime: this.endTime + ' 23:59:59',
  119. devBid: this.devBid,
  120. },
  121. sfType: true,
  122. });
  123. this.historyList = this.historyList.concat(res.data);
  124. this.total = res.total;
  125. },
  126. formartDate(month = 0) {
  127. const time = month * 30 * 24 * 60 * 60 * 1000;
  128. const timeStamp = new Date(new Date().getTime() - time);
  129. const year = timeStamp.getFullYear();
  130. const monthDate = timeStamp.getMonth() + 1;
  131. const monthStr = monthDate < 10 ? `0${monthDate}` : monthDate;
  132. const day = new Date().getDate();
  133. const dayStr = day < 10 ? `0${day}` : day;
  134. return `${year}-${monthStr}-${dayStr}`;
  135. },
  136. handleCalendarClick() {
  137. this.show = true;
  138. // this.$refs.calendar.open();
  139. },
  140. handleClose() {
  141. this.show = false;
  142. },
  143. scrolltolower() {
  144. if (this.hasMore) {
  145. this.pageNum++;
  146. this.getHistory();
  147. }
  148. },
  149. handleConfirm(e) {
  150. const startDate = e.startDate;
  151. const endDate = e.endDate;
  152. this.pageNum = 1;
  153. this.historyList = [];
  154. this.startTime = startDate;
  155. this.endTime = endDate;
  156. this.getHistory();
  157. },
  158. },
  159. onLoad(options) {
  160. const { devBid } = options;
  161. this.devBid = devBid;
  162. this.getHistory();
  163. },
  164. };
  165. </script>
  166. <style scoped lang="scss">
  167. uni-page-body {
  168. position: relative;
  169. height: 100%;
  170. }
  171. ::v-deep .u-calendar__action {
  172. display: flex;
  173. justify-content: center;
  174. align-items: center;
  175. }
  176. ::v-deep .u-hover-class {
  177. opacity: 0.6;
  178. }
  179. .scroll-container {
  180. height: calc(100vh - 420rpx);
  181. }
  182. .history-container {
  183. background: linear-gradient(180deg, #ffffff00 0%, #fff 23.64%, #fff 100%),
  184. linear-gradient(102deg, #bfeadd 6.77%, #b8f1e7 40.15%, #b9eef5 84.02%);
  185. height: 100%;
  186. width: 100%;
  187. overflow-x: hidden;
  188. overflow-y: hidden;
  189. .calendar {
  190. position: relative;
  191. display: flex;
  192. align-items: center;
  193. padding: 0 32rpx;
  194. line-height: 64rpx;
  195. border-radius: 16rpx;
  196. background-color: #fff;
  197. margin: 0 32rpx;
  198. &__icon {
  199. margin-right: 12rpx;
  200. }
  201. &__label {
  202. font-size: 28rpx;
  203. color: #666;
  204. margin-right: 10rpx;
  205. }
  206. &__content {
  207. font-size: 28rpx;
  208. color: #666;
  209. margin-left: 64rpx;
  210. .separate {
  211. margin: 0 6rpx;
  212. }
  213. }
  214. &__link {
  215. position: absolute;
  216. right: 20rpx;
  217. top: 50%;
  218. transform: translateY(-50%);
  219. }
  220. }
  221. .history-form-container {
  222. width: calc(100% - 64rpx);
  223. height: calc(100vh - 300rpx);
  224. margin: 32rpx;
  225. border-radius: 16rpx;
  226. background: #fff;
  227. overflow: hidden;
  228. .form-header {
  229. display: flex;
  230. justify-content: space-between;
  231. align-items: center;
  232. height: 80rpx;
  233. width: 100%;
  234. border-bottom: 2rpx solid #e4e7ed;
  235. &__title {
  236. width: 25%;
  237. text-align: center;
  238. font-size: 28rpx;
  239. color: #042118;
  240. font-family: 'Source Han Sans CN VF';
  241. font-style: normal;
  242. font-weight: 400;
  243. line-height: normal;
  244. }
  245. }
  246. .form-content {
  247. display: flex;
  248. justify-content: space-between;
  249. align-items: center;
  250. height: 96rpx;
  251. width: 100%;
  252. border-bottom: 2rpx solid #e4e7ed;
  253. &__item {
  254. width: 25%;
  255. text-align: center;
  256. font-size: 28rpx;
  257. font-family: 'Source Han Sans CN VF';
  258. font-style: normal;
  259. color: #042118;
  260. .item-open {
  261. display: inline-flex;
  262. height: 40rpx;
  263. padding: 4rpx 16rpx;
  264. justify-content: center;
  265. align-items: center;
  266. border-radius: 20rpx;
  267. background: #14a47824;
  268. color: #14a478;
  269. font-family: 'Source Han Sans CN VF';
  270. font-size: 24rpx;
  271. font-weight: 400;
  272. }
  273. .item-close {
  274. display: inline-flex;
  275. height: 40rpx;
  276. padding: 4rpx 16rpx;
  277. justify-content: center;
  278. align-items: center;
  279. border-radius: 20rpx;
  280. background: #7a82911a;
  281. color: #7a8291;
  282. font-family: 'Source Han Sans CN VF';
  283. font-size: 24rpx;
  284. font-weight: 400;
  285. }
  286. .item-time {
  287. color: #042118;
  288. font-family: 'Source Han Sans CN VF';
  289. font-size: 28rpx;
  290. font-weight: 400;
  291. }
  292. .item-date {
  293. color: #042118;
  294. font-family: 'Source Han Sans CN VF';
  295. font-size: 24rpx;
  296. font-weight: 400;
  297. }
  298. }
  299. &__item--text {
  300. width: 20%;
  301. margin-left: 5%;
  302. // 超出隐藏
  303. overflow: hidden;
  304. text-overflow: ellipsis;
  305. white-space: nowrap;
  306. text-align: left;
  307. }
  308. }
  309. }
  310. }
  311. </style>