operationLog.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. <template>
  2. <view>
  3. <u-navbar title="操作日志" title-color="#101010">
  4. </u-navbar>
  5. <!-- 标签 -->
  6. <view class="tabs">
  7. <u-picker v-model="tabsFrom.show1" mode="selector"
  8. :default-selector="[tabsFrom.show1Index]"
  9. :range="tabsFrom.selector1" range-key="label"
  10. @confirm="selector1confirm"></u-picker>
  11. <u-picker-select title="日期选择" :noselect="false"
  12. v-model="tabsFrom.show2" :defaultTime="tabsFrom.show2Index" :endYear="endYear"
  13. mode="time" :params="params" @confirm="selector2confirm" @reset="selector2reset"></u-picker-select>
  14. <view class="tabsItem" @click="tabsFrom.show2=!tabsFrom.show2">{{tabsFrom.show2Text}} <u-icon
  15. name="arrow-up" v-if="tabsFrom.show2"></u-icon><u-icon v-else name="arrow-down"></u-icon></view>
  16. <view class="tabsItem" @click="tabsFrom.show1=!tabsFrom.show1">{{tabsFrom.show1Text}} <u-icon
  17. name="arrow-up" v-if="tabsFrom.show1"></u-icon><u-icon v-else name="arrow-down"></u-icon></view>
  18. </view>
  19. <!-- 日志 -->
  20. <view class="log">
  21. <view class="log-item" v-for="(item,i) in list">
  22. <view class="item-infos">
  23. <view class="place">
  24. {{item.meterName}} <text v-if="item.installationAddress">({{item.installationAddress}})</text>
  25. </view>
  26. <view class="date">
  27. {{item.switchStatusN}}
  28. </view>
  29. </view>
  30. <view class="else">
  31. <view class="operation">
  32. {{item.createTime}}
  33. </view>
  34. <view class="from">
  35. 来自 {{item.typeN}}
  36. </view>
  37. </view>
  38. <view class="else" style="margin-top: 4rpx;">
  39. <view class="from">
  40. 备注:{{item.remark}}
  41. </view>
  42. </view>
  43. </view>
  44. <u-divider :isnone="list.length==0" v-if="recordsTotal==list.length" nonetext="无记录"
  45. border-color="#CFD2D5">已经到底了</u-divider>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. import * as API from '@/apis/pagejs/meterTimer.js'
  51. import {
  52. nextDay,
  53. nextMonth,
  54. } from '@/apis/utils'
  55. export default {
  56. data() {
  57. return {
  58. meterList:[],
  59. endYear:'',
  60. pageIndex: 1,
  61. queryMonth:"",
  62. recordsTotal:0,
  63. list:[],
  64. meterId:"",
  65. formData:{
  66. startDate:""
  67. },
  68. params: {
  69. year: true,
  70. month: true,
  71. day: false,
  72. hour: false,
  73. minute: false,
  74. second: false
  75. },
  76. tabsFrom: {
  77. show1: false,
  78. show1Index: 0,
  79. show2Index: '',
  80. show2: false,
  81. show1Text: "全部开关",
  82. show2Text: "全部时间",
  83. selector1: [{
  84. label: '全部开关',
  85. value: '',
  86. },
  87. {
  88. label: '大厅空调',
  89. value: '1',
  90. },
  91. {
  92. label: '大厅灯控',
  93. value: '2',
  94. },
  95. {
  96. label: '道闸',
  97. value: '3',
  98. },
  99. {
  100. label: '地下车库灯控',
  101. value: '4',
  102. },
  103. ]
  104. },
  105. }
  106. },
  107. onLoad(op) {
  108. this.endYear=new Date().getFullYear()
  109. //var date=new Date()
  110. //this.formData.startDate=date.getFullYear()+"-"+(date.getMonth() + 1) +"-1"
  111. //this.queryMonth=date.getFullYear()+"年"+(date.getMonth() + 1) +"月"
  112. if(op.id){
  113. this.meterId=op.id;
  114. }
  115. this.getHaveMeterList()
  116. this.rechargeRecord()
  117. },
  118. onReachBottom() {
  119. if (this.list.length < this.recordsTotal) {
  120. this.myLoadmore();
  121. }
  122. },
  123. methods: {
  124. myLoadmore() {
  125. this.pageIndex += 1;
  126. this.rechargeRecord();
  127. },
  128. getHaveMeterList(){
  129. var data = {
  130. queryForm:"tenant",
  131. };
  132. API.haveMeterList(data).then((response) => {
  133. //var MeterList=response.data.switchRecordList.data
  134. this.meterList = response.data.remoteReadingMeterList;
  135. //this.recordsTotal = response.data.switchRecordList.recordsTotal;
  136. this.tabsFrom.selector1=[]
  137. this.tabsFrom.selector1=[{
  138. label: "全部开关",
  139. value: '',
  140. }]
  141. var i =0;
  142. this.meterList.forEach(item=>{
  143. this.tabsFrom.selector1.push({
  144. label: item.name,
  145. value: item.id,
  146. })
  147. i++
  148. if(item.id==this.meterId){
  149. this.selector1confirmTest([i])
  150. }
  151. })
  152. }).catch(error => {
  153. uni.showToast({
  154. title: error,
  155. icon: "none"
  156. })
  157. })
  158. },
  159. rechargeRecord(bl){
  160. uni.showLoading({
  161. title: "加载中",
  162. mask: true,
  163. })
  164. if (bl) {
  165. this.list = [];
  166. this.pageIndex = 1;
  167. }
  168. var data = {
  169. pageIndex: this.pageIndex,
  170. pageSize: 20,
  171. meterId:this.meterId,
  172. queryForm:"tenant",
  173. yearMonth:this.formData.startDate
  174. // companyId: this.companyId,
  175. // status: this.status
  176. };
  177. API.meterTimerRecord(data).then((response) => {
  178. uni.hideLoading();
  179. var list=response.data.switchRecordList.data
  180. this.list = [
  181. ...this.list,
  182. ...list
  183. ];
  184. this.recordsTotal = response.data.switchRecordList.recordsTotal;
  185. }).catch(error => {
  186. uni.showToast({
  187. title: error,
  188. icon: "none"
  189. })
  190. })
  191. },
  192. selector2confirm(e) {
  193. this.tabsFrom.show2Text = e.year + "年" + e.month + "月"
  194. this.tabsFrom.show2Index = e.year + "-" + e.month
  195. if (e.day) {
  196. this.tabsFrom.show2Text += e.day + "日"
  197. this.tabsFrom.show2Index += '-' + e.day
  198. }
  199. if (e.day) {
  200. this.formData.startDate = e.year + "-" + e.month + "-" + e.day
  201. this.queryMonth = e.year + "年" + e.month + "月" + e.day + "日"
  202. this.formData.endDate = this.formData.startDate
  203. } else {
  204. this.queryMonth = e.year + "年" + e.month + "月"
  205. this.formData.startDate = e.year + "-" + e.month
  206. this.formData.endDate = nextMonth(e.year, e.month, 1, 1)
  207. }
  208. this.rechargeRecord(true)
  209. },
  210. selector2reset(e) {
  211. this.tabsFrom.show2Text = '全部时间'
  212. this.tabsFrom.show2Index = '';
  213. this.formData.startDate = date.getFullYear() + "-" + (date.getMonth() + 1) + "-1"
  214. this.queryMonth = date.getFullYear() + "年" + (date.getMonth() + 1) + "月"
  215. this.rechargeRecord(true)
  216. },
  217. selector1confirm(e) {
  218. var index = e[0]
  219. this.tabsFrom.show1Index = index
  220. this.tabsFrom.show1Text = this.tabsFrom.selector1[index].label
  221. this.meterId = this.tabsFrom.selector1[index].value
  222. this.rechargeRecord(true)
  223. },
  224. selector1confirmTest(e) {
  225. var index = e[0]
  226. this.tabsFrom.show1Index = index
  227. this.tabsFrom.show1Text = this.tabsFrom.selector1[index].label
  228. //this.meterId = this.tabsFrom.selector1[index].value
  229. //this.rechargeRecord(true)
  230. },
  231. }
  232. }
  233. </script>
  234. <style lang="scss" scoped>
  235. // 标签
  236. .tabs {
  237. height: 96rpx;
  238. line-height: 96rpx;
  239. background-color: #fff;
  240. border-top: 1px solid rgba(241, 241, 241, 1);
  241. display: flex;
  242. justify-content: space-around;
  243. }
  244. // 日志
  245. .log{
  246. .log-item{
  247. background-color: #fff;
  248. padding: 24rpx 32rpx;
  249. border-bottom: 1px solid rgba(245,245,245,1);
  250. .item-infos{
  251. display: flex;
  252. align-items: center;
  253. justify-content: space-between;
  254. .place{
  255. color: rgba(51,51,51,1);
  256. font-weight: bold;
  257. text{
  258. color: #777777;
  259. font-weight: normal;
  260. }
  261. overflow: hidden;
  262. white-space: nowrap;
  263. text-overflow: ellipsis;
  264. }
  265. .date{
  266. color: rgba(51,51,51,1);
  267. white-space: pre;
  268. font-weight: bold;
  269. font-size: 24rpx;
  270. }
  271. }
  272. .else{
  273. display: flex;
  274. align-items: center;
  275. justify-content: space-between;
  276. text-align: right;
  277. .operation{
  278. color: rgba(119,119,119,1);
  279. }
  280. .from{
  281. color: rgba(119,119,119,1);
  282. font-size: 24rpx;
  283. }
  284. }
  285. }
  286. }
  287. </style>