operation.vue 7.5 KB

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