tree-node.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <template>
  2. <view class="tree-node ">
  3. <view class=" sum " :class="{
  4. node0:level==0
  5. }" >
  6. <view class=" meter-statistic-main" >
  7. <view class="icon" @click="toggle" v-if="node.childMeterList&&node.childMeterList.length" >
  8. <u-icon name="arrow-up" color="rgb(164 156 156)" v-show="isOpen" size="24"></u-icon>
  9. <u-icon name="arrow-down" color="rgb(164 156 156)" v-show="!isOpen" size="24"></u-icon>
  10. </view>
  11. <view class="icon" v-else >
  12. <u-icon name="arrow-rightward" color="#fcfafa" size="24"></u-icon>
  13. </view>
  14. <view class="meter-name" :style="level==0||level==1?'font-weight: bold;':''"
  15. @click="toggle" >{{ node.name }}</view>
  16. <template v-if="level==0">
  17. <view class="meter-state" v-if="node.online">
  18. 在线
  19. </view>
  20. <view class="meter-state meter-state2" v-else>
  21. 离线
  22. </view>
  23. </template>
  24. <view class="meter-number" @click="toElectronicMonitoring(node)">
  25. {{node.kwh}}度
  26. <u-icon name="arrow-right" color="#fcfafa" v-if="node.type==6" size="24"></u-icon>
  27. <u-icon name="arrow-right" v-else
  28. color="#d4d4d4" size="24"></u-icon>
  29. </view>
  30. </view>
  31. <view class="sum2" v-if="node.level==0&& node.childMeterList && node.childMeterList.length > 0" >
  32. <view class="title">
  33. 一级表合计用电(未扣除)
  34. </view>
  35. <view class="value">
  36. {{node.childKwh}}度
  37. </view>
  38. </view>
  39. <view class="tags" v-if="level!=0">
  40. <view class="tagsList">
  41. <view class="meter-state" v-if="node.online">
  42. 在线
  43. </view>
  44. <view class="meter-state meter-state2" v-else>
  45. 离线
  46. </view>
  47. <view class="meter-state"
  48. :style="{
  49. color:colorList[node.type%6],
  50. borderColor:colorList[node.type%6],
  51. }"
  52. >
  53. {{node.typeN}}
  54. </view>
  55. <view class="icon icon2" :class="{
  56. icon6:node.type==6,
  57. iconSwitch1:node.switchStatus,
  58. iconSwitch0:!node.switchStatus,
  59. }" v-if="level!=0&&role&&node.type!=6" >
  60. <img src="@/assets/img/switchIcon.png"
  61. @click="switchBtn(node,0)"
  62. v-if="node.switchStatus" alt="" />
  63. <img src="@/assets/img/switchClose.png"
  64. @click="switchBtn(node,1)"
  65. v-else alt="" />
  66. </view>
  67. <view v-if="node.type==6" class="meter-state"
  68. :style="{
  69. color:colorList[node.manyType%6],
  70. borderColor:colorList[node.manyType%6],
  71. }">
  72. {{node.manyTypeN}}
  73. </view>
  74. </view>
  75. <view class="operationList">
  76. <!-- <u-switch size="32" @change="switchBtn(node,$event)" v-model="node.switchStatus" inactive-color="#ff9900" ></u-switch >-->
  77. </view>
  78. </view>
  79. </view>
  80. <view class="sum first-level" :class="{
  81. 'first-level-node0':level==0
  82. }"
  83. v-if="isOpen && node.childMeterList && node.childMeterList.length > 0">
  84. <tree-node @query="query" :role="role"
  85. v-for="(child, index) in node.childMeterList"
  86. :key="index" @switchBtn="switchBtn" :level="level+1"
  87. :node="child"
  88. ></tree-node>
  89. </view>
  90. </view>
  91. </template>
  92. <script>
  93. export default {
  94. name: 'TreeNode',
  95. props: {
  96. node: Object,
  97. role:false,
  98. level:0,
  99. },
  100. data() {
  101. return {
  102. isOpen: false,
  103. isInit: false,
  104. colorList:["#52b8aa","#307af6","#ef8132",
  105. "#4d65ed","#5cb657","#777777"],
  106. };
  107. },
  108. mounted() {
  109. console.log("mountedmountedmounted")
  110. if(this.level==0){
  111. this.toggle()
  112. }
  113. },
  114. methods: {
  115. switchBtn(node,key){
  116. this.$emit('switchBtn',node,key)
  117. },
  118. toElectronicMonitoring(item) {
  119. if(item.type!=6){
  120. uni.navigateTo({
  121. url: '/pages/equipmentDataMonitoring/electronicMonitoring?id=' + item.id + '&name=' + item
  122. .name +
  123. '&companyId=' + item.companyId
  124. })
  125. }
  126. },
  127. query(item){
  128. this.$emit('query',item)
  129. },
  130. toggle() {
  131. this.isOpen = !this.isOpen;
  132. if(!this.isInit){
  133. this.isInit=true;
  134. this.$emit('query',this.node)
  135. }
  136. }
  137. }
  138. };
  139. </script>
  140. <style lang="scss" scoped>
  141. .tree-node {
  142. margin-top: 24rpx;
  143. ;
  144. }
  145. .meter-statistic-node {
  146. margin-top: 32rpx;
  147. padding-bottom: 20px;
  148. background-color: #fcfafa;
  149. .meter-statistic-main{
  150. display: flex;
  151. align-items: center;
  152. }
  153. .sum {
  154. .meter-name {
  155. color: rgba(51, 51, 51, 1);
  156. font-size: 32rpx;
  157. }
  158. .icon {
  159. margin-right: 16rpx;
  160. img {
  161. width: 32rpx;
  162. height: 32rpx;
  163. vertical-align: middle;
  164. }
  165. }
  166. .icon2 {
  167. padding: 2rpx 20rpx;
  168. margin-right: 8rpx;
  169. border-radius: 8rpx;
  170. display: flex;
  171. align-items: center;
  172. }
  173. .iconSwitch1{
  174. background: #307af7;
  175. border: 1px solid #307af7;
  176. }
  177. .iconSwitch0{
  178. background: #e1e6ee;
  179. border: 1px solid #bfc4cd;
  180. }
  181. .icon6{
  182. //width: 40rpx;
  183. }
  184. .meter-state {
  185. margin:0 8rpx;
  186. //width: 64rpx;
  187. min-height: 40rpx;
  188. //line-height: 36rpx;
  189. //border-radius: 8rpx;
  190. border-radius: 4px;
  191. background-color: #fcfafa;;
  192. color: rgba(0, 185, 98, 1);
  193. font-size: 22rpx;
  194. text-align: center;
  195. padding: 0 8rpx;
  196. border: 1px solid rgba(0, 185, 98, 1);
  197. white-space: pre;
  198. display: flex;
  199. align-items: center;
  200. }
  201. .meter-state2 {
  202. border: 1px solid rgba(255, 123, 0, 1);
  203. color: rgba(255, 123, 0, 1);
  204. }
  205. .meter-number {
  206. margin-left: auto;
  207. color: rgba(51, 51, 51, 1);
  208. font-size: 32rpx;
  209. white-space: pre;
  210. /deep/.u-icon--right {
  211. margin:0 8rpx;
  212. }
  213. }
  214. .tags{
  215. display: flex;
  216. padding: 0rpx 32rpx;
  217. margin-top: 8rpx;
  218. justify-content: space-between;
  219. .tagsList{
  220. display: flex;
  221. flex-wrap: wrap;
  222. .meter-state{
  223. margin-bottom: 4rpx;
  224. }
  225. }
  226. .operationList{
  227. display: flex;
  228. }
  229. }
  230. }
  231. .sum2 {
  232. padding: 0 40rpx;
  233. margin-top: 8rpx;
  234. display: flex;
  235. align-items: center;
  236. justify-content: space-between;
  237. .title {
  238. color: rgba(119, 119, 119, 1);
  239. }
  240. .value {
  241. color: rgba(119, 119, 119, 1);
  242. }
  243. }
  244. .first-level-list{
  245. width: 100%;
  246. display: flex;
  247. align-items: center;
  248. }
  249. // 一级表
  250. .first-level {
  251. padding-left: 32rpx;
  252. margin-top: 20rpx;
  253. .meter-name {
  254. font-size: 32rpx;
  255. overflow: hidden;
  256. white-space: nowrap;
  257. text-overflow: ellipsis;
  258. }
  259. }
  260. // 二级表
  261. .second-level {
  262. padding-left: 64rpx;
  263. margin-top: 20rpx;
  264. .meter-name {
  265. font-size: 24rpx;
  266. }
  267. }
  268. .else-switch {
  269. padding-left: 144rpx;
  270. .meter-name {
  271. font-size: 24rpx
  272. }
  273. .item {
  274. margin-top: 24rpx;
  275. }
  276. }
  277. .node0{
  278. padding:24rpx;
  279. background: linear-gradient(180deg, rgba(22,119,255,1) 0%,rgba(93,160,255,1) 100%);
  280. .meter-name,.meter-number,/deep/.u-iconfont,.title,.value{
  281. color:#fff !important;
  282. }
  283. }
  284. .first-level-node0{
  285. padding-left: 16rpx;
  286. }
  287. }
  288. </style>