operation.vue 7.1 KB

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