operationLog.vue 7.7 KB

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