operation.vue 6.9 KB

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