operationLog.vue 7.0 KB

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