operationModel.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <template>
  2. <view class="container">
  3. <!-- 建议放在外层 -->
  4. <u-navbar
  5. title="操作历史"
  6. @leftClick="devicemenuShow"
  7. :safeAreaInsetTop="true"
  8. >
  9. <view class="u-nav-slot" slot="left">
  10. <u-icon name="list" size="20"> </u-icon>
  11. </view>
  12. </u-navbar>
  13. <view v-show="menushow" class="menupage">
  14. <DeviceMenu @menuClick="menuClick"></DeviceMenu>
  15. </view>
  16. <view v-show="!menushow" class="main">
  17. <view class="u-page">
  18. <div class="flcard">
  19. <div class="btns">
  20. <u-button
  21. type="primary"
  22. shape="circle"
  23. :text="StartTime ? StartTime : '起始时间'"
  24. @click="dataShow = true"
  25. ></u-button>
  26. <u-button
  27. type="primary"
  28. shape="circle"
  29. :text="EndTime ? EndTime : '结束时间'"
  30. @click="dataShow1 = true"
  31. ></u-button>
  32. <u-icon
  33. size="30"
  34. color="#3c9cff"
  35. name="search"
  36. @click="checkHistoryData"
  37. ></u-icon>
  38. </div>
  39. <u-datetime-picker
  40. :show="dataShow"
  41. mode="datetime"
  42. @cancel="dataShow = false"
  43. @confirm="selectStartTime"
  44. v-model="dataTime"
  45. ></u-datetime-picker>
  46. <u-datetime-picker
  47. :show="dataShow1"
  48. mode="datetime"
  49. @cancel="dataShow1 = false"
  50. @confirm="selectEndTime"
  51. v-model="dataTime"
  52. ></u-datetime-picker>
  53. </div>
  54. <u-list>
  55. <u-list-item
  56. class="itemback"
  57. v-for="(item, index) in historyData"
  58. :key="index"
  59. >
  60. <view>
  61. <view class="content flcard">
  62. <view class="datacard user">
  63. <view style="margin: 20rpx 20rpx">
  64. <text class="text-style">{{ item.realname }}</text>
  65. </view>
  66. <view style="margin: 20rpx 20rpx; font-size: small"
  67. >用户</view
  68. >
  69. </view>
  70. <view class="datacard device">
  71. <view style="margin: 20rpx 20rpx">
  72. <text class="text-style">{{ item.devicename }}</text>
  73. </view>
  74. <view style="margin: 20rpx 20rpx; font-size: small"
  75. >操作设备</view
  76. >
  77. </view>
  78. <view class="datacard record">
  79. <view style="margin: 20rpx 20rpx">
  80. <text class="text-style">{{ item.strremark }}</text>
  81. </view>
  82. <view style="margin: 20rpx 20rpx; font-size: small"
  83. >操作记录</view
  84. >
  85. </view>
  86. <view class="datacard time">
  87. <view style="margin: 20rpx 20rpx">
  88. <text class="text-style">{{ item.createTime }}</text>
  89. </view>
  90. <view style="margin: 20rpx 20rpx; font-size: small"
  91. >操作时间</view
  92. >
  93. </view>
  94. </view>
  95. </view>
  96. </u-list-item>
  97. </u-list>
  98. </view>
  99. </view>
  100. </view>
  101. </template>
  102. <script>
  103. import DeviceMenu from "./devicemenu/devicemenu.vue";
  104. import api from "@/api/api";
  105. import dayjs from "dayjs";
  106. export default {
  107. data() {
  108. return {
  109. menushow: false,
  110. TabCur: "gate",
  111. dataShow: false,
  112. dataShow1: false,
  113. dataTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
  114. deviceType: "gate", //设备类型
  115. StartTime: "",
  116. EndTime: "",
  117. historyData: [],
  118. };
  119. },
  120. components: {
  121. DeviceMenu,
  122. },
  123. props: ["showColum"],
  124. watch: {
  125. showColum(data) {
  126. this.colums = data;
  127. console.log(this.colums);
  128. },
  129. },
  130. created() {
  131. this.colums = this.showColum;
  132. const startTime =new Date().getTime() - 3600 * 1000 * 24 * 30;
  133. const endTime = new Date();
  134. this.StartTime = dayjs(startTime).format("YYYY-MM-DD HH:mm:ss");
  135. this.EndTime = dayjs(endTime).format("YYYY-MM-DD HH:mm:ss");
  136. this.checkHistoryData();
  137. },
  138. mounted() {},
  139. methods: {
  140. //选择起始时间
  141. selectStartTime(e) {
  142. const startTime = e.value;
  143. const formattedTime = dayjs(startTime).format("YYYY-MM-DD HH:mm:ss");
  144. this.StartTime = formattedTime;
  145. this.dataShow = false;
  146. },
  147. //选择起始时间
  148. selectEndTime(e) {
  149. const endTime = e.value;
  150. const formattedTime = dayjs(endTime).format("YYYY-MM-DD HH:mm:ss");
  151. this.EndTime = formattedTime;
  152. this.dataShow1 = false;
  153. },
  154. devicemenuShow(e) {
  155. this.menushow = !this.menushow;
  156. },
  157. menuClick(id) {
  158. this.TabCur = id;
  159. this.deviceType = this.TabCur;
  160. this.menushow = false;
  161. },
  162. //查询历史数据
  163. checkHistoryData() {
  164. const params = {
  165. createTime_begin: this.StartTime,
  166. createTime_end: this.EndTime,
  167. pageNo: 1,
  168. pageSize: 10000,
  169. devicetype: this.deviceType + "*",
  170. };
  171. new Promise((resolve, reject) => {
  172. api
  173. .getOpreateHistory(params)
  174. .then((response) => {
  175. if (response.data.code == 200) {
  176. this.historyData = response.data.result.records;
  177. } else {
  178. resolve(response);
  179. }
  180. })
  181. .catch((error) => {
  182. reject(error);
  183. });
  184. });
  185. },
  186. },
  187. destroyed() {},
  188. };
  189. </script>
  190. <style>
  191. .main {
  192. display: flex;
  193. flex-direction: column;
  194. }
  195. .menupage {
  196. position: absolute;
  197. z-index: 2;
  198. /* top: 40rpx; */
  199. height: calc(100% - 40rpx);
  200. width: 100%;
  201. }
  202. .btns {
  203. display: flex;
  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>