operationModel.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <view class="container">
  3. <!-- 建议放在外层 -->
  4. <u-navbar
  5. title="操作记录"
  6. @leftClick="devicemenuShow"
  7. :safeAreaInsetTop="false"
  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="起始时间"
  24. @click="dataShow = true"
  25. ></u-button>
  26. <u-button
  27. type="primary"
  28. shape="circle"
  29. text="结束时间"
  30. @click="dataShow1 = true"
  31. ></u-button>
  32. <u-button
  33. type="primary"
  34. shape="circle"
  35. text="查询"
  36. @click="checkHistoryData"
  37. ></u-button>
  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 class="datacard">
  61. <view class="content flcard">
  62. <view
  63. class="demo-layout bg-purple-light"
  64. style="margin-top: 10rpx; color: #3787fe"
  65. >用户:{{ item.realname }}</view
  66. >
  67. <view
  68. class="demo-layout bg-purple-light"
  69. style="margin-top: 10rpx; color: #3787fe"
  70. >操作设备:{{ item.devicename }}</view
  71. >
  72. <view
  73. class="demo-layout bg-purple-light"
  74. style="margin-top: 10rpx; color: #3787fe"
  75. >操作记录:{{ item.strremark }}</view
  76. >
  77. </view>
  78. </view>
  79. </u-list-item>
  80. </u-list>
  81. </view>
  82. </view>
  83. </view>
  84. </template>
  85. <script>
  86. import DeviceMenu from "./devicemenu/devicemenu.vue";
  87. import api from "@/api/api";
  88. import dayjs from "dayjs";
  89. export default {
  90. data() {
  91. return {
  92. menushow: false,
  93. TabCur: "gate",
  94. dataShow: false,
  95. dataShow1: false,
  96. dataTime: dayjs().toDate(),
  97. deviceType: "", //设备类型
  98. StartTime: "",
  99. EndTime: "",
  100. historyData: [],
  101. };
  102. },
  103. components: {
  104. DeviceMenu,
  105. },
  106. props: ["showColum"],
  107. watch: {
  108. showColum(data) {
  109. this.colums = data;
  110. console.log(this.colums);
  111. },
  112. },
  113. created() {
  114. this.colums = this.showColum;
  115. },
  116. mounted() {},
  117. methods: {
  118. //选择起始时间
  119. selectStartTime(e) {
  120. const startTime = e.value;
  121. const formattedTime = dayjs(startTime).format("YYYY-MM-DD HH:mm:ss");
  122. this.StartTime = formattedTime;
  123. this.dataShow = false;
  124. },
  125. //选择起始时间
  126. selectEndTime(e) {
  127. const endTime = e.value;
  128. const formattedTime = dayjs(endTime).format("YYYY-MM-DD HH:mm:ss");
  129. this.EndTime = formattedTime;
  130. this.dataShow1 = false;
  131. },
  132. devicemenuShow(e) {
  133. this.menushow = true;
  134. },
  135. menuClick(id) {
  136. this.TabCur = id;
  137. this.deviceType = this.TabCur;
  138. this.menushow = false;
  139. },
  140. //查询历史数据
  141. checkHistoryData() {
  142. const params = {
  143. createTime_begin: this.StartTime,
  144. createTime_end: this.EndTime,
  145. pageNo: 1,
  146. pageSize: 10000,
  147. devicetype: this.deviceType + "*",
  148. };
  149. new Promise((resolve, reject) => {
  150. api
  151. .getOpreateHistory(params)
  152. .then((response) => {
  153. if (response.data.code == 200) {
  154. this.historyData = response.data.result.records;
  155. } else {
  156. resolve(response);
  157. }
  158. })
  159. .catch((error) => {
  160. reject(error);
  161. });
  162. });
  163. },
  164. },
  165. destroyed() {},
  166. };
  167. </script>
  168. <style>
  169. .main {
  170. margin-top: 100rpx;
  171. display: flex;
  172. flex-direction: column;
  173. }
  174. .menupage {
  175. position: absolute;
  176. z-index: 2;
  177. top: 40rpx;
  178. height: calc(100% - 40rpx);
  179. width: 100%;
  180. }
  181. .btns {
  182. display: flex;
  183. }
  184. .flcard {
  185. padding: 20rpx;
  186. background-color: #ffffff;
  187. margin-bottom: 5rpx;
  188. }
  189. </style>