tree.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <template>
  2. <view>
  3. <!-- 头部 -->
  4. <cu-custom bgColor="bg-blue" :isBack="true">
  5. <block slot="backText"></block>
  6. <block slot="content">选择关联工程部位</block>
  7. <block slot="right">
  8. <text style="margin-right: 10rpx" @click="navTo">确定</text>
  9. </block>
  10. </cu-custom>
  11. <scroll-view scroll-y class="margin-bottom" style="padding-bottom: 300rpx;">
  12. <view v-for="(item,index) in treeData" :key="item.id" class="treeData_b">
  13. <view class="treeData_1" @click="treeTap(index+1,item)">
  14. <view style="font-weight: bold;font-size: 34rpx;" :class="item.selected&&!allSelect?'indexColor':''">{{item.name}}</view>
  15. <view v-if="item.children.length>0">
  16. <image src="/static/information/shang.png" style="width: 40rpx;height: 40rpx;vertical-align: middle;" v-if="show == index + 1"></image>
  17. <image src="/static/information/xia.png" style="width: 40rpx;height: 40rpx;vertical-align: middle;" v-if="show != index + 1 || show == 0"></image>
  18. </view>
  19. </view>
  20. <view v-for="(second,seconds) in item.children" :key="second.id" v-if="show == index + 1">
  21. <view class="treeData_1s treeData_2" @click="secondTap(seconds + 1,second)">
  22. <view :class="second.selected&&!allSelect?'indexColor':''">{{second.name}}</view>
  23. <view v-if="second.children.length>0">
  24. <image src="/static/information/shang.png" style="width: 40rpx;height: 40rpx;vertical-align: middle;" v-if="showsecond == seconds + 1"></image>
  25. <image src="/static/information/xia.png" style="width: 40rpx;height: 40rpx;vertical-align: middle;" v-if="showsecond != seconds + 1 || showsecond == 0"></image>
  26. </view>
  27. </view>
  28. <view v-if="showsecond == seconds + 1" :style="{'padding-bottom': second.children.length>0 ? '22rpx':''}">
  29. <view v-for="(three,threes) in second.children" :key="three.id" class="treeData_three">
  30. <view class="treeData_1s treeData_3" @click="threeTap(threes + 1,three)">
  31. <view :class="three.selected&&!allSelect?'indexColor':''">{{three.name}}</view>
  32. <view v-if="three.children.length>0">
  33. <image src="/static/information/shang.png" style="width: 40rpx;height: 40rpx;vertical-align: middle;" v-if="showthree == threes + 1"></image>
  34. <image src="/static/information/xia.png" style="width: 40rpx;height: 40rpx;vertical-align: middle;" v-if="showthree != threes + 1 || showthree == 0"></image>
  35. </view>
  36. </view>
  37. <view v-if="showthree == threes + 1" v-for="(four,fours) in three.children" :key="four.id">
  38. <view class="treeData_1s treeData_3" @click="fourTap(fours + 1,four)">
  39. <view style="padding-left: 22rpx;" :class="four.selected&&!allSelect?'indexColor':''"><text style="margin-right: 10rpx;">◈</text>{{four.name}}</view>
  40. <view v-if="four.children.length>0">
  41. <image src="/static/information/shang.png" style="width: 40rpx;height: 40rpx;vertical-align: middle;" v-if="showfour == fours + 1"></image>
  42. <image src="/static/information/xia.png" style="width: 40rpx;height: 40rpx;vertical-align: middle;" v-if="showfour != fours + 1 || showfour == 0"></image>
  43. </view>
  44. </view>
  45. <view v-if="showfour == fours + 1" v-for="(five,fives) in four.children" :key="five.id">
  46. <view class="treeData_1s treeData_3" @click="fiveTap(fives + 1,five)">
  47. <view style="padding-left: 44rpx;" :class="five.selected&&!allSelect?'indexColor':''"><text style="margin-right: 10rpx;">➣</text>{{five.name}}</view>
  48. <view v-if="five.children.length>0">
  49. <image src="/static/information/shang.png" style="width: 40rpx;height: 40rpx;vertical-align: middle;" v-if="showfive == fives + 1"></image>
  50. <image src="/static/information/xia.png" style="width: 40rpx;height: 40rpx;vertical-align: middle;" v-if="showfive != fives + 1 || showfive == 0"></image>
  51. </view>
  52. </view>
  53. <view v-if="showfive == fives + 1" v-for="(six,sixs) in five.children" :key="six.id">
  54. <view class="treeData_1s treeData_3" @click="sixTap(sixs + 1,six)">
  55. <view style="padding-left: 66rpx;" :class="six.selected&&!allSelect?'indexColor':''"><text style="margin-right: 10rpx;">•</text>{{six.name}}</view>
  56. <view v-if="six.children.length>0">
  57. <image src="/static/information/shang.png" style="width: 40rpx;height: 40rpx;vertical-align: middle;" v-if="showsix == sixs + 1"></image>
  58. <image src="/static/information/xia.png" style="width: 40rpx;height: 40rpx;vertical-align: middle;" v-if="showsix != sixs + 1 || showsix == 0"></image>
  59. </view>
  60. </view>
  61. <view v-if="showsix == sixs + 1" v-for="(seven,sevens) in six.children" :key="seven.id">
  62. <view class="treeData_1s treeData_3" @click="sevenTap(sevens + 1,seven)">
  63. <view style="padding-left: 88rpx;" :class="seven.selected&&!allSelect?'indexColor':''">{{seven.name}}</view>
  64. </view>
  65. </view>
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. </scroll-view>
  74. </view>
  75. </template>
  76. <script>
  77. export default {
  78. data() {
  79. return {
  80. treeData: [],
  81. show: 0, //一级状态
  82. showsecond: 0, //二级状态
  83. showthree: 0, //三级状态
  84. showfour: 0, //四级状态
  85. showfive: 0, //五级状态
  86. showsix: 0, //六级状态
  87. showseven: 0, //七级状态
  88. modalShow: false,
  89. path: "",
  90. percentage:"",
  91. width:"",
  92. processNum:"",
  93. allSelect:false,//是否选中全部
  94. }
  95. },
  96. onLoad() {
  97. this.findDataProgress();
  98. },
  99. methods: {
  100. findDataProgress() {
  101. var that = this;
  102. that.http.request('/app/qualityModifyInfo/getDataByparantId', {
  103. type: 0,
  104. id: ''
  105. }).then((result) => {
  106. if (result.datas != null) {
  107. that.treeData = result.datas[0].children;
  108. that.text(that.treeData);
  109. }
  110. })
  111. },
  112. search() {
  113. uni.setStorageSync("pageType", 1); //区分搜索页面跳转
  114. uni.navigateTo({
  115. url: "/pages/search/search"
  116. })
  117. },
  118. filterNode(value, data) {
  119. if (!value) return true;
  120. return data.label.indexOf(value) !== -1;
  121. },
  122. /* 获取节点的资料进度 */
  123. handleNodeClick(data) {
  124. var that =this;
  125. that.http.request("/app/divideClient/countInstance",{ids:data.id,contractId:""}).then((res)=>{
  126. var num = res.data*100
  127. that.percentage = Math.round(num);
  128. that.width ="width:"+Math.round(num)+"%;";
  129. that.processNum = res.size;
  130. that.findPath(data.id);
  131. });
  132. },
  133. /* 全程工程的施工进度 */
  134. allData(){
  135. this.allSelect = true;
  136. var that =this;
  137. var project = uni.getStorageSync("porject"+"_"+uni.getStorageSync("userInfo").id);
  138. that.http.request("/app/divideClient/countInstance",{ids:project.contractId,contractId:project.contractId}).then((res)=>{
  139. var num = res.data*100
  140. that.percentage = Math.round(num);
  141. that.width ="width:"+Math.round(num)+"%;";
  142. that.processNum = res.size;
  143. that.path=" / 全部工程"
  144. that.modalShow = true
  145. });
  146. },
  147. findPath(id){
  148. /* 获取父节点信息 */
  149. var that=this;
  150. that.http.request("/app/divideClient/selectNodeTreeById",{id:id}).then((res)=>{
  151. that.path="";
  152. res.datas.forEach((item)=>{
  153. if(item.parentId!=0){
  154. that.path += " / "+item.name;
  155. }
  156. });
  157. that.modalShow = true
  158. });
  159. },
  160. treeTap(e,r) {
  161. this.text(this.treeData)
  162. r.selected = true;
  163. this.allSelect = false;
  164. if (this.show == e) {
  165. this.show = 0
  166. } else {
  167. this.show = e
  168. }
  169. this.handleNodeClick(r);
  170. },
  171. secondTap(e,r) {
  172. this.text(this.treeData)
  173. r.selected = true;
  174. this.allSelect = false;
  175. if (this.showsecond == e) {
  176. this.showsecond = 0
  177. } else {
  178. this.showsecond = e
  179. }
  180. this.handleNodeClick(r);
  181. },
  182. threeTap(e,r) {
  183. this.text(this.treeData)
  184. r.selected = true;
  185. this.allSelect = false;
  186. if (this.showthree == e) {
  187. this.showthree = 0
  188. } else {
  189. this.showthree = e
  190. }
  191. this.handleNodeClick(r);
  192. },
  193. fourTap(e,r) {
  194. this.text(this.treeData);
  195. this.$set(r,"selected",true);
  196. this.allSelect = false;
  197. if (this.showfour == e) {
  198. this.showfour = 0
  199. } else {
  200. this.showfour = e
  201. }
  202. this.handleNodeClick(r);
  203. },
  204. fiveTap(e,r) {
  205. this.text(this.treeData);
  206. this.$set(r,"selected",true);
  207. this.allSelect = false;
  208. if (this.showfive == e) {
  209. this.showfive = 0
  210. } else {
  211. this.showfive = e
  212. }
  213. this.handleNodeClick(r);
  214. },
  215. sixTap(e,r) {
  216. this.text(this.treeData)
  217. r.selected = true;
  218. this.allSelect = false;
  219. if (this.showsix == e) {
  220. this.showsix = 0
  221. } else {
  222. this.showsix = e
  223. }
  224. this.handleNodeClick(r);
  225. },
  226. sevenTap(e,r) {
  227. this.text(this.treeData)
  228. r.selected = true;
  229. this.allSelect = false;
  230. if (this.showseven == e) {
  231. this.showseven = 0
  232. } else {
  233. this.showseven = e
  234. }
  235. this.handleNodeClick(r);
  236. },
  237. text(data) {
  238. var that = this;
  239. data.forEach((item) => {
  240. item.selected = false;
  241. if (item.children.length > 0) {
  242. that.text(item.children);
  243. }
  244. })
  245. that.treeData = data;
  246. },
  247. navTo(){
  248. }
  249. }
  250. }
  251. </script>
  252. <style>
  253. page{background-color: #F7F7F7;}
  254. .toTop {
  255. position: fixed;
  256. bottom: 0;
  257. width: 100%;
  258. background-color: #F7F7F7;
  259. height: calc(var(--window-bottom) + 15px)
  260. }
  261. .solid-bottom-type {
  262. border-bottom: 1upx solid white;
  263. }
  264. .treeData_b {
  265. margin: 12rpx 22rpx 0;
  266. background-color: #fff;
  267. border-radius: 10rpx;
  268. padding: 0 22rpx;
  269. }
  270. .treeData_1 {
  271. font-size: 30rpx;
  272. color: #101010;
  273. height: 88rpx;
  274. display: flex;
  275. justify-content: space-between;
  276. align-items: center;
  277. }
  278. .treeData_1s {
  279. font-size: 30rpx;
  280. color: #101010;
  281. display: flex;
  282. justify-content: space-between;
  283. align-items: center;
  284. padding: 22upx 0;
  285. min-height: 88rpx;
  286. }
  287. .treeData_2 {
  288. border-top: 1upx dashed #E3E1E1;
  289. }
  290. .treeData_3 {
  291. border-top: 1upx dashed #E3E1E1;
  292. }
  293. .treeData_three {
  294. background-color: #F7F7F7;
  295. padding: 0 22rpx;
  296. border-radius: 10rpx;
  297. margin-bottom: 22;
  298. }
  299. .treeData_three:first-child {
  300. border-radius: 10rpx 10rpx 0 0;
  301. }
  302. .treeData_three:last-child {
  303. border-radius: 0 0 10rpx 10rpx;
  304. }
  305. .indexColor {
  306. color: #0A8CD5;
  307. font-weight: bold;
  308. }
  309. .padding-sm{padding:20rpx 22rpx;}
  310. </style>