tree-node.vue 7.0 KB

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