operation.vue 6.9 KB

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