tree-node.vue 8.4 KB

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