operationModel.vue 7.3 KB

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