operationModel.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  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().toDate().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(
  133. new Date(
  134. new Date().getTime() - 3600 * 1000 * 24 * 30
  135. ).toLocaleDateString()
  136. );
  137. const endTime = new Date();
  138. this.StartTime = dayjs(startTime).format("YYYY-MM-DD HH:mm:ss");
  139. this.EndTime = dayjs(endTime).format("YYYY-MM-DD HH:mm:ss");
  140. this.checkHistoryData();
  141. },
  142. mounted() {},
  143. methods: {
  144. //选择起始时间
  145. selectStartTime(e) {
  146. const startTime = e.value;
  147. const formattedTime = dayjs(startTime).format("YYYY-MM-DD HH:mm:ss");
  148. this.StartTime = formattedTime;
  149. this.dataShow = false;
  150. },
  151. //选择起始时间
  152. selectEndTime(e) {
  153. const endTime = e.value;
  154. const formattedTime = dayjs(endTime).format("YYYY-MM-DD HH:mm:ss");
  155. this.EndTime = formattedTime;
  156. this.dataShow1 = false;
  157. },
  158. devicemenuShow(e) {
  159. this.menushow = !this.menushow;
  160. },
  161. menuClick(id) {
  162. this.TabCur = id;
  163. this.deviceType = this.TabCur;
  164. this.menushow = false;
  165. },
  166. //查询历史数据
  167. checkHistoryData() {
  168. const params = {
  169. createTime_begin: this.StartTime,
  170. createTime_end: this.EndTime,
  171. pageNo: 1,
  172. pageSize: 10000,
  173. devicetype: this.deviceType + "*",
  174. };
  175. new Promise((resolve, reject) => {
  176. api
  177. .getOpreateHistory(params)
  178. .then((response) => {
  179. if (response.data.code == 200) {
  180. this.historyData = response.data.result.records;
  181. } else {
  182. resolve(response);
  183. }
  184. })
  185. .catch((error) => {
  186. reject(error);
  187. });
  188. });
  189. },
  190. },
  191. destroyed() {},
  192. };
  193. </script>
  194. <style>
  195. .main {
  196. display: flex;
  197. flex-direction: column;
  198. }
  199. .menupage {
  200. position: absolute;
  201. z-index: 2;
  202. /* top: 40rpx; */
  203. height: calc(100% - 40rpx);
  204. width: 100%;
  205. }
  206. .btns {
  207. display: flex;
  208. }
  209. .flcard {
  210. padding: 20rpx;
  211. background-color: #ffffff;
  212. margin-bottom: 5rpx;
  213. }
  214. .text-style {
  215. color: #3787fe;
  216. font-weight: bold;
  217. }
  218. .itemback {
  219. padding: 20rpx;
  220. background-color: #ffffff;
  221. margin-bottom: 5rpx;
  222. }
  223. .datacard {
  224. width: 48%;
  225. margin: 1%;
  226. float: left;
  227. height: 120rpx;
  228. border-radius: 10px;
  229. }
  230. .time {
  231. background: url(/static/operation/operationTime.png),
  232. linear-gradient(
  233. to right,
  234. rgba(55, 135, 254, 0.08),
  235. rgba(4, 184, 255, 0.08),
  236. rgba(60, 161, 237, 0.08)
  237. );
  238. background-size: auto 100%;
  239. background-position: right;
  240. background-repeat: no-repeat;
  241. }
  242. .record {
  243. background: url(/static/operation/operationRecord.png),
  244. linear-gradient(
  245. to right,
  246. rgba(55, 135, 254, 0.08),
  247. rgba(4, 184, 255, 0.08),
  248. rgba(60, 161, 237, 0.08)
  249. );
  250. background-size: auto 100%;
  251. background-position: right;
  252. background-repeat: no-repeat;
  253. }
  254. .user {
  255. background: url(/static/operation/user.png),
  256. linear-gradient(
  257. to right,
  258. rgba(55, 135, 254, 0.08),
  259. rgba(4, 184, 255, 0.08),
  260. rgba(60, 161, 237, 0.08)
  261. );
  262. background-size: auto 100%;
  263. background-position: right;
  264. background-repeat: no-repeat;
  265. }
  266. .device {
  267. background: url(/static/operation/operationDevice.png),
  268. linear-gradient(
  269. to right,
  270. rgba(55, 135, 254, 0.08),
  271. rgba(4, 184, 255, 0.08),
  272. rgba(60, 161, 237, 0.08)
  273. );
  274. background-size: auto 100%;
  275. background-position: right;
  276. background-repeat: no-repeat;
  277. }
  278. </style>