tree-node.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  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. <view class="meter-number" v-if="(node.level==0&&showPark)||node.level!=0"
  17. @click="toElectronicMonitoring(node)">
  18. {{node.kwh}}度
  19. <u-icon name="arrow-right"
  20. color="#d4d4d4" size="24"></u-icon>
  21. </view>
  22. </view>
  23. <view class="sum3" v-if="level==0">
  24. <template v-if="rootnode.type!='6'&&rootnode.type!='7'" >
  25. <view class="meter-state" v-if="node.online">
  26. 在线
  27. </view>
  28. <view class="meter-state meter-state2" v-else>
  29. 离线
  30. </view>
  31. </template>
  32. <view class="meter-state supplyType1" v-if="rootnode.supplyType=='1'">
  33. 转供电
  34. </view>
  35. <view class="meter-state supplyType2" v-if="rootnode.supplyType=='2'">
  36. 直供电
  37. </view>
  38. </view>
  39. <view class="sum2" v-if="childInfo.styleTemplate=='1'&&node.level==0&& node.childMeterList && node.childMeterList.length > 0" >
  40. <view class="title">
  41. 一级表计电量
  42. </view>
  43. <view class="value" :style="node.childKwh<node.kwh*0.999?'color:red!important':''">
  44. {{node.childKwh}}度
  45. </view>
  46. </view>
  47. <view class="sum2" v-if="childInfo.styleTemplate=='2'&&node.level==0&& node.childMeterList && node.childMeterList.length > 0" >
  48. <view class="title">
  49. 代缴费用户合计电量
  50. </view>
  51. <view class="value" >
  52. {{node.replaceKwh}}度
  53. </view>
  54. </view>
  55. <view class="tags" v-if="level!=0">
  56. <view class="tagsList">
  57. <template v-if="node.type!='7'&&node.type!='6'" >
  58. <view class="meter-state" v-if="node.online">
  59. 在线
  60. </view>
  61. <view class="meter-state meter-state2" v-else>
  62. 离线
  63. </view>
  64. </template>
  65. <view class="meter-state " v-if="childInfo.styleTemplate=='2'&&node.type!=7"
  66. :class="'paymentMode'+node.paymentMode" >{{node.paymentMode==1?'代缴费':''}}{{node.paymentMode==2?'自缴费':''}}</view>
  67. <view class="meter-state"
  68. :style="{
  69. borderColor:colorList[node.type%colorList.length],
  70. background:colorList[node.type%colorList.length],
  71. color:'#fff',
  72. }"
  73. >
  74. {{node.typeN}}
  75. </view>
  76. <view class="icon icon2" :class="{
  77. icon6:node.type==6,
  78. iconSwitch1:node.switchStatus,
  79. iconSwitch0:!node.switchStatus,
  80. }" v-if="level!=0&&role&&node.type!=6&&node.allowSwitch" >
  81. <img src="@/assets/img/switchIcon.png"
  82. @click="switchBtn(node,0)"
  83. v-if="node.switchStatus" alt="" />
  84. <img src="@/assets/img/switchClose.png"
  85. @click="switchBtn(node,1)"
  86. v-else alt="" />
  87. </view>
  88. <view v-if="node.tag" class="meter-state" v-for="(item ,i) in getTags(node.tag)"
  89. :key="i"
  90. :style="{
  91. borderColor:item.color,
  92. background:item.color,
  93. color:'#fff',
  94. }">
  95. {{item.name}}
  96. </view>
  97. </view>
  98. <view class="operationList">
  99. <!-- <u-switch size="32" @change="switchBtn(node,$event)" v-model="node.switchStatus" inactive-color="#ff9900" ></u-switch >-->
  100. </view>
  101. </view>
  102. </view>
  103. <view class="sum first-level" :class="{
  104. 'first-level-node0':level==0
  105. }"
  106. v-if="isOpen && node.childMeterList && node.childMeterList.length > 0">
  107. <tree-node @query="query" :role="role"
  108. v-for="(child, index) in node.childMeterList"
  109. :key="index" @switchBtn="switchBtn" :level="level+1"
  110. :node="child" :rootnode="rootnode" :childInfo="childInfo"
  111. ></tree-node>
  112. </view>
  113. </view>
  114. </template>
  115. <script>
  116. export default {
  117. name: 'TreeNode',
  118. props: {
  119. node: Object,
  120. role:false,
  121. level:0,
  122. showPark:false,
  123. rootnode: Object, //根节点
  124. childInfo: Object, //公司属性
  125. },
  126. data() {
  127. return {
  128. isOpen: false,
  129. isInit: false,
  130. colorList:['#9C27B0',"#52b8aa","#53b56b","#ef8132",
  131. "#307af6","#52b8aa","#777777",'#f44336','#e91e63','#009688','#607d8b','#795548'],
  132. };
  133. },
  134. mounted() {
  135. //console.log("mountedmountedmounted")
  136. if(this.level==0){
  137. this.toggle()
  138. }
  139. },
  140. methods: {
  141. getTags(tag){
  142. if(!tag){
  143. return []
  144. }
  145. var sz=[]
  146. var str1=tag.split(',')
  147. for(var i in str1){
  148. if(str1[i].indexOf('#')>-1){
  149. var str2=str1[i].split('#');
  150. console.log(str2[1],typeof(str2[1]))
  151. var num =parseInt(str2[1])
  152. if(!isNaN(num)){
  153. sz.push({
  154. name:str2[0],
  155. color:this.colorList[num%this.colorList.length]
  156. })
  157. }else{
  158. sz.push({
  159. name:str2[0],
  160. color:'#'+str2[1]
  161. })
  162. }
  163. }
  164. }
  165. return sz
  166. },
  167. switchBtn(node,key){
  168. this.$emit('switchBtn',node,key)
  169. },
  170. toElectronicMonitoring(item) {
  171. if(item.type!=6){
  172. }
  173. uni.navigateTo({
  174. url: '/pages/equipmentDataMonitoring/electronicMonitoring?id=' + item.id + '&name=' + item
  175. .name +
  176. '&companyId=' + item.companyId
  177. })
  178. },
  179. query(item){
  180. this.$emit('query',item)
  181. },
  182. toggle() {
  183. this.isOpen = !this.isOpen;
  184. if(!this.isInit){
  185. this.isInit=true;
  186. this.$emit('query',this.node)
  187. }
  188. }
  189. }
  190. };
  191. </script>
  192. <style lang="scss" scoped>
  193. .tree-node {
  194. margin-top: 24rpx;
  195. ;
  196. }
  197. .meter-statistic-node {
  198. //margin-top: 32rpx;
  199. //padding-top: 12rpx;
  200. padding-bottom: 20px;
  201. background-color: #fcfafa;
  202. .meter-statistic-main{
  203. display: flex;
  204. align-items: center;
  205. }
  206. .sum {
  207. .meter-name {
  208. color: rgba(51, 51, 51, 1);
  209. font-size: 32rpx;
  210. }
  211. .icon {
  212. margin-right: 16rpx;
  213. img {
  214. width: 32rpx;
  215. height: 32rpx;
  216. vertical-align: middle;
  217. }
  218. }
  219. .icon2 {
  220. padding: 2rpx 20rpx;
  221. margin-right: 8rpx;
  222. border-radius: 8rpx;
  223. display: flex;
  224. align-items: center;
  225. }
  226. .iconSwitch1{
  227. background: #307af7;
  228. border: 1px solid #307af7;
  229. }
  230. .iconSwitch0{
  231. background: #e1e6ee;
  232. border: 1px solid #bfc4cd;
  233. }
  234. .icon6{
  235. //width: 40rpx;
  236. }
  237. .meter-state {
  238. margin:0 8rpx;
  239. //width: 64rpx;
  240. min-height: 40rpx;
  241. //line-height: 36rpx;
  242. //border-radius: 8rpx;
  243. border-radius: 4px;
  244. background-color: #fcfafa;;
  245. color: rgba(0, 185, 98, 1);
  246. font-size: 22rpx;
  247. text-align: center;
  248. padding: 0 8rpx;
  249. border: 1px solid rgba(0, 185, 98, 1);
  250. white-space: pre;
  251. display: flex;
  252. align-items: center;
  253. }
  254. .meter-state2 {
  255. border: 1px solid rgba(255, 123, 0, 1);
  256. color: rgba(255, 123, 0, 1);
  257. }
  258. .paymentMode1{
  259. color: rgba(255,255,255,1);
  260. background-color: rgba(22,119,255,1);
  261. border: 1px solid rgba(22,119,255,1);
  262. }
  263. .paymentMode2{
  264. color: rgba(255,255,255,1);
  265. background-color: rgba(129,97,255,1);
  266. border: 1px solid rgba(129,97,255,1);
  267. }
  268. .supplyType1{
  269. border: 1px solid rgba(255, 123, 0, 1);
  270. color: rgba(255, 123, 0, 1);
  271. }
  272. .supplyType2{
  273. }
  274. .meter-number {
  275. margin-left: auto;
  276. color: rgba(51, 51, 51, 1);
  277. font-size: 32rpx;
  278. white-space: pre;
  279. /deep/.u-icon--right {
  280. margin:0 8rpx;
  281. }
  282. }
  283. .tags{
  284. display: flex;
  285. padding: 0rpx 32rpx;
  286. margin-top: 8rpx;
  287. justify-content: space-between;
  288. .tagsList{
  289. display: flex;
  290. flex-wrap: wrap;
  291. .meter-state{
  292. margin-bottom: 4rpx;
  293. }
  294. }
  295. .operationList{
  296. display: flex;
  297. }
  298. }
  299. }
  300. .sum3 {
  301. padding: 0 40rpx;
  302. margin-top: 8rpx;
  303. display: flex;
  304. align-items: center;
  305. .title {
  306. color: rgba(119, 119, 119, 1);
  307. }
  308. .value {
  309. color: rgba(119, 119, 119, 1);
  310. }
  311. }
  312. .sum2 {
  313. padding: 0 40rpx;
  314. margin-top: 8rpx;
  315. display: flex;
  316. align-items: center;
  317. justify-content: space-between;
  318. .title {
  319. color: rgba(119, 119, 119, 1);
  320. }
  321. .value {
  322. color: rgba(119, 119, 119, 1);
  323. }
  324. }
  325. .first-level-list{
  326. width: 100%;
  327. display: flex;
  328. align-items: center;
  329. }
  330. // 一级表
  331. .first-level {
  332. padding-left: 32rpx;
  333. margin-top: 20rpx;
  334. .meter-name {
  335. font-size: 32rpx;
  336. overflow: hidden;
  337. white-space: nowrap;
  338. text-overflow: ellipsis;
  339. }
  340. }
  341. // 二级表
  342. .second-level {
  343. padding-left: 64rpx;
  344. margin-top: 20rpx;
  345. .meter-name {
  346. font-size: 24rpx;
  347. }
  348. }
  349. .else-switch {
  350. padding-left: 144rpx;
  351. .meter-name {
  352. font-size: 24rpx
  353. }
  354. .item {
  355. margin-top: 24rpx;
  356. }
  357. }
  358. .node0{
  359. padding:24rpx;
  360. background: linear-gradient(180deg, rgba(22,119,255,1) 0%,rgba(93,160,255,1) 100%);
  361. .meter-name,.meter-number,/deep/.u-iconfont,.title,.value{
  362. color:#fff !important;
  363. }
  364. }
  365. .first-level-node0{
  366. padding-left: 16rpx;
  367. }
  368. }
  369. </style>