operation.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <template>
  2. <view class="container">
  3. <view v-if="!menushow" class="main">
  4. <view class="u-page">
  5. <div class="flcard">
  6. <div class="btns">
  7. <u-button
  8. type="primary"
  9. shape="circle"
  10. :text="StartTime ? StartTime : '起始时间'"
  11. @click="dataShow = true"
  12. ></u-button>
  13. <u-button
  14. type="primary"
  15. shape="circle"
  16. :text="EndTime ? EndTime : '结束时间'"
  17. @click="dataShow1 = true"
  18. ></u-button>
  19. <u-icon
  20. size="30"
  21. color="#3c9cff"
  22. name="search"
  23. @click="checkHistoryData"
  24. ></u-icon>
  25. </div>
  26. <u-datetime-picker
  27. :show="dataShow"
  28. mode="datetime"
  29. @cancel="dataShow = false"
  30. @confirm="selectStartTime"
  31. v-model="dataTime"
  32. ></u-datetime-picker>
  33. <u-datetime-picker
  34. :show="dataShow1"
  35. mode="datetime"
  36. @cancel="dataShow1 = false"
  37. @confirm="selectEndTime"
  38. v-model="dataTime"
  39. ></u-datetime-picker>
  40. </div>
  41. <u-list>
  42. <u-list-item
  43. class="itemback"
  44. v-for="(item, index) in historyData"
  45. :key="index"
  46. >
  47. <view>
  48. <view class="content flcard">
  49. <view class="datacard user">
  50. <view style="margin: 20rpx 20rpx">
  51. <text class="text-style">{{ item.realname }}</text>
  52. </view>
  53. <view style="margin: 20rpx 20rpx; font-size: small"
  54. >用户</view
  55. >
  56. </view>
  57. <view class="datacard device">
  58. <view style="margin: 20rpx 20rpx">
  59. <text class="text-style">{{ item.devicename }}</text>
  60. </view>
  61. <view style="margin: 20rpx 20rpx; font-size: small"
  62. >操作设备</view
  63. >
  64. </view>
  65. <view class="datacard record">
  66. <view style="margin: 20rpx 20rpx">
  67. <text class="text-style">{{ item.strremark }}</text>
  68. </view>
  69. <view style="margin: 20rpx 20rpx; font-size: small"
  70. >操作记录</view
  71. >
  72. </view>
  73. <view class="datacard time">
  74. <view style="margin: 20rpx 20rpx">
  75. <text class="text-style">{{ item.createTime }}</text>
  76. </view>
  77. <view style="margin: 20rpx 20rpx; font-size: small"
  78. >操作时间</view
  79. >
  80. </view>
  81. </view>
  82. </view>
  83. </u-list-item>
  84. </u-list>
  85. </view>
  86. </view>
  87. </view>
  88. </template>
  89. <script>
  90. import api from "@/api/api";
  91. import dayjs from "dayjs";
  92. export default {
  93. data() {
  94. return {
  95. menushow: false,
  96. TabCur: "gate",
  97. dataShow: false,
  98. dataShow1: false,
  99. dataTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
  100. // deviceType: "gate", //设备类型
  101. StartTime: "",
  102. EndTime: "",
  103. historyData: [],
  104. };
  105. },
  106. props: ["showColum", 'deviceType'],
  107. watch: {
  108. showColum(data) {
  109. this.colums = data;
  110. },
  111. deviceType: {
  112. handler (data) {
  113. if(data){
  114. this.TabCur = data;
  115. // 选择设备分类,重新获取数据
  116. this.$emit('setMenushow', {
  117. menushow: false
  118. });
  119. }
  120. },
  121. immediate: true
  122. }
  123. },
  124. created() {
  125. this.colums = this.showColum;
  126. const startTime =new Date().getTime() - 3600 * 1000 * 24 * 30;
  127. const endTime = new Date();
  128. this.StartTime = dayjs(startTime).format("YYYY-MM-DD HH:mm:ss");
  129. this.EndTime = dayjs(endTime).format("YYYY-MM-DD HH:mm:ss");
  130. this.checkHistoryData();
  131. },
  132. mounted() {
  133. this.TabCur = this.deviceType;
  134. },
  135. methods: {
  136. //选择起始时间
  137. selectStartTime(e) {
  138. const startTime = e.value;
  139. const formattedTime = dayjs(startTime).format("YYYY-MM-DD HH:mm:ss");
  140. this.StartTime = formattedTime;
  141. this.dataShow = false;
  142. },
  143. //选择起始时间
  144. selectEndTime(e) {
  145. const endTime = e.value;
  146. const formattedTime = dayjs(endTime).format("YYYY-MM-DD HH:mm:ss");
  147. this.EndTime = formattedTime;
  148. this.dataShow1 = false;
  149. },
  150. devicemenuShow(e) {
  151. this.menushow = !this.menushow;
  152. },
  153. menuClick(id) {
  154. this.TabCur = id;
  155. this.menushow = false;
  156. },
  157. //查询历史数据
  158. checkHistoryData() {
  159. const params = {
  160. createTime_begin: this.StartTime,
  161. createTime_end: this.EndTime,
  162. pageNo: 1,
  163. pageSize: 10000,
  164. devicetype: this.TabCur + "*",
  165. };
  166. new Promise((resolve, reject) => {
  167. api
  168. .getOpreateHistory(params)
  169. .then((response) => {
  170. if (response.data.code == 200) {
  171. this.historyData = response.data.result.records;
  172. } else {
  173. resolve(response);
  174. }
  175. })
  176. .catch((error) => {
  177. reject(error);
  178. });
  179. });
  180. },
  181. },
  182. destroyed() {},
  183. };
  184. </script>
  185. <style>
  186. .main {
  187. display: flex;
  188. flex-direction: column;
  189. }
  190. .menupage {
  191. position: absolute;
  192. z-index: 2;
  193. /* top: 40rpx; */
  194. height: calc(100% - 40rpx);
  195. width: 100%;
  196. }
  197. .btns {
  198. display: flex;
  199. }
  200. .flcard {
  201. padding: 20rpx;
  202. background-color: #ffffff;
  203. margin-bottom: 5rpx;
  204. }
  205. .text-style {
  206. color: #3787fe;
  207. font-weight: bold;
  208. }
  209. .itemback {
  210. padding: 20rpx;
  211. background-color: #ffffff;
  212. margin-bottom: 5rpx;
  213. }
  214. .datacard {
  215. width: 48%;
  216. margin: 1%;
  217. float: left;
  218. height: 120rpx;
  219. border-radius: 10px;
  220. }
  221. .time {
  222. background: url(/static/operation/operationTime.png),
  223. linear-gradient(
  224. to right,
  225. rgba(55, 135, 254, 0.08),
  226. rgba(4, 184, 255, 0.08),
  227. rgba(60, 161, 237, 0.08)
  228. );
  229. background-size: auto 100%;
  230. background-position: right;
  231. background-repeat: no-repeat;
  232. }
  233. .record {
  234. background: url(/static/operation/operationRecord.png),
  235. linear-gradient(
  236. to right,
  237. rgba(55, 135, 254, 0.08),
  238. rgba(4, 184, 255, 0.08),
  239. rgba(60, 161, 237, 0.08)
  240. );
  241. background-size: auto 100%;
  242. background-position: right;
  243. background-repeat: no-repeat;
  244. }
  245. .user {
  246. background: url(/static/operation/user.png),
  247. linear-gradient(
  248. to right,
  249. rgba(55, 135, 254, 0.08),
  250. rgba(4, 184, 255, 0.08),
  251. rgba(60, 161, 237, 0.08)
  252. );
  253. background-size: auto 100%;
  254. background-position: right;
  255. background-repeat: no-repeat;
  256. }
  257. .device {
  258. background: url(/static/operation/operationDevice.png),
  259. linear-gradient(
  260. to right,
  261. rgba(55, 135, 254, 0.08),
  262. rgba(4, 184, 255, 0.08),
  263. rgba(60, 161, 237, 0.08)
  264. );
  265. background-size: auto 100%;
  266. background-position: right;
  267. background-repeat: no-repeat;
  268. }
  269. </style>