people.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <template>
  2. <view class="talbbox">
  3. <!-- 左侧 -->
  4. <view>
  5. <scroll-view :scroll-top="scrollTop" class="cate-left" scroll-y="true" show-scrollbar="false">
  6. <view class="cate-item" :class="{act:current==index}" v-for="(item,index) in cateList"
  7. @click="menuTab(index)" :key="item.userId">
  8. {{item.name}}
  9. </view>
  10. </scroll-view>
  11. </view>
  12. <!-- 右侧 -->
  13. <view class="cate-right">
  14. <scroll-view :scroll-top="riscrollTop" :scroll-into-view="'cate'+tempCurrent" class="cate-right-scroll" scroll-y="true"
  15. show-scrollbar="false" @scroll="getCurrentHeight">
  16. <view :id="'cate'+index" v-for="(item,index) in cateList" :key="item.userId" class="cate-right-item">
  17. <view class="flexcj">
  18. <view class="cate-title">{{item.name}}</view>
  19. <view class="allbtns" @click="getAll(item)">全选</view>
  20. </view>
  21. <view class="cate-right-txt">
  22. <!-- :class="checkList.findIndex((it) => it.userId === el.userId)!=-1?'act':''" -->
  23. <text v-for="(el,idx) in item.children" @click="getTabFn(el,item)" :class="checkList.findIndex((it) => it.userId === el.userId)!=-1?'act':''" :key="el.userId">{{el.name}}</text>
  24. </view>
  25. </view>
  26. <view style="height: 30rpx;"></view>
  27. </scroll-view>
  28. </view>
  29. <!-- 弹窗 -->
  30. <view class="lmtac">
  31. <view class="flex1 table">
  32. <view class="upimg">
  33. <image :src="upimg"></image>
  34. </view>
  35. <view class="flex1" style="overflow-y: auto;">
  36. <view class="lmtit mb14">已添加人员</view>
  37. <block v-for="(item,index) in cateList" :key="item.userId">
  38. <block v-if="checkList.findIndex((it) => it.grade.indexOf(item.userId)!=-1)!=-1">
  39. <view class="lmtxt mb14" >
  40. <view class="laber">{{item.name}}:</view>
  41. <view class="lmame">
  42. <block v-for="(ite,idx) in checkList" ::key="ite.userId">
  43. <view class="tit" v-if="ite.grade.indexOf(item.userId)!=-1">{{ite.userName}}
  44. <view class="delimg" @click="getDel(idx)"><image :src="delimg"></image></view>
  45. </view>
  46. </block>
  47. </view>
  48. </view>
  49. </block>
  50. </block>
  51. </view>
  52. </view>
  53. <view class="btns" @click="getSure">确定</view>
  54. </view>
  55. <!-- <view class="fwbtns" @click="getSure">确定</view> -->
  56. </view>
  57. </template>
  58. <script>
  59. import {getInfotreeSelectFn} from "@/api/mine/meeting.js"
  60. export default {
  61. data() {
  62. return {
  63. upimg:require("@/work/static/images/meeting/up.png"),
  64. delimg:require("@/work/static/images/meeting/del.png"),
  65. cateList: [{name: "驻潜全国政协委员",userId:'a'},
  66. {name: "驻潜省政协委员",userId:'b',
  67. children:[
  68. {boundary: "1",card: "342224199110121234",createBy: "",createTime: "2024-03-15 14:13:38",delFlag: "0",
  69. grade: "c,b",memberId: 4,name: "测试委员",partyAffiliation: "zggcd",phonenumber: "15333434321",unit: "潜山市政府",userId: 1},
  70. {boundary: "1",card: "342224199110121234",createBy: "",createTime: "2024-03-15 14:13:38",delFlag: "0",
  71. grade: "b",memberId: 5,name: "测试委员2",partyAffiliation: "zggcd",phonenumber: "15333434321",unit: "潜山市政府",userId: 2},
  72. ]
  73. },
  74. {name: "驻潜安庆市政协委员",userId:'c',
  75. children:[
  76. {boundary: "1",card: "342224199110121234",createBy: "",createTime: "2024-03-15 14:13:38",delFlag: "0",
  77. grade: "c,b",memberId: 4,name: "测试委员",partyAffiliation: "zggcd",phonenumber: "15333434321",unit: "潜山市政府",userId: 1},
  78. ]
  79. }
  80. ],
  81. current: 0, //当前点击项
  82. rectInfoList: [],
  83. tempCurrent: 0,
  84. ricurrent:'',
  85. scrollTop: 0, //左侧导航栏距离顶部的位置
  86. riscrollTop:0,//右侧导航栏距离顶部的位置
  87. checkList:[],//选择的人员
  88. }
  89. },
  90. onLoad(e) {
  91. if(e.data){
  92. var newobj=JSON.parse(decodeURIComponent(e.data));
  93. this.checkList=newobj.list;
  94. }
  95. // this.getCasetalbFn()
  96. },
  97. mounted() {
  98. setTimeout(() => {
  99. this.getRectInfo();
  100. }, 200)
  101. },
  102. methods: {
  103. getCasetalbFn(){
  104. getInfotreeSelectFn().then(res=>{
  105. if(res.code==200){
  106. this.cateList=res.data;
  107. }
  108. })
  109. },
  110. menuTab(index){
  111. var top=this.rectInfoList[index].top;
  112. this.current = index;
  113. this.riscrollTop = top;
  114. },
  115. getTabFn(ite,item){
  116. var obj={
  117. userId:ite.userId,
  118. userName:ite.name,
  119. postName:ite.unit,
  120. userLevel:item.name,
  121. grade:ite.grade,
  122. }
  123. var indexNum = (this.checkList || []).findIndex((item) => item.userId === ite.userId);
  124. if(indexNum!=-1){
  125. this.checkList.splice(indexNum,1)
  126. }else{
  127. this.checkList.push(obj)
  128. }
  129. },
  130. getDel(idx){
  131. this.checkList.splice(idx,1)
  132. },
  133. getAll(item){
  134. var newArr=this.checkList;
  135. if(item.children&&item.children.length){
  136. item.children.forEach(ite=>{
  137. const matchingData = newArr.find(d => d.userId == ite.userId);
  138. if(matchingData){
  139. }else{
  140. var obj={
  141. userId:ite.userId,
  142. userName:ite.name,
  143. postName:ite.unit,
  144. userLevel:item.name,
  145. grade:ite.grade,
  146. }
  147. this.checkList.push(obj)
  148. }
  149. })
  150. }
  151. },
  152. getSure(){
  153. // 带数据返回
  154. var obj={
  155. zxConferenceUserList:this.checkList,
  156. }
  157. uni.$emit("refreshtalb",obj)
  158. uni.navigateBack({
  159. delta: 1 //返回层数,2则上上页
  160. });
  161. },
  162. // 获取与顶部之间的距离
  163. getRectInfo() {
  164. var top = 0;
  165. var bottom = 0;
  166. var temp = 0;
  167. for (var i = 0; i < this.cateList.length; i++) {
  168. let view = uni.createSelectorQuery().in(this).select("#cate" + i);
  169. view.fields({
  170. size: true,
  171. rect: true
  172. }, data => {
  173. top = temp;
  174. bottom = top + data.height;
  175. temp = bottom;
  176. this.rectInfoList[i] = {
  177. 'top': top,
  178. 'bottom': bottom
  179. }
  180. // console.log(top, bottom);
  181. }).exec();
  182. }
  183. },
  184. getCurrentHeight(e) {
  185. var currentHeight = e.detail.scrollTop;
  186. this.rectInfoList.forEach((item, index) => {
  187. if (currentHeight >= item.top && currentHeight <= item.bottom) {
  188. // 当前获取的盒子高度大于top小于bottom,判定将索引传至左侧菜单导航
  189. this.current = index;
  190. this.scrollTop = index * uni.upx2px(100);
  191. }
  192. })
  193. }
  194. }
  195. }
  196. </script>
  197. <style scoped lang="scss">
  198. /deep/::-webkit-scrollbar {
  199. display: none;
  200. width: 0;
  201. height: 0;
  202. }
  203. .talbbox{
  204. display: flex;height: 100vh;padding-bottom: 412rpx;
  205. .cate-left{width: 252rpx;flex: 0 0 auto;height: 100%;background-color: #f5f5f5;
  206. .cate-item{height: 110rpx;line-height: 110rpx;text-align: center;font-weight: 500;
  207. font-size: 28rpx;color: #666666;
  208. &.act{background-color: #ffffff;font-weight: bold;color: #1D64E2;}
  209. }
  210. }
  211. .cate-right{flex: 1;height: 100%;background: #ffffff;
  212. .cate-right-scroll{height: 100%;padding-left:34rpx;
  213. .cate-right-item{
  214. .cate-title{font-weight: bold;font-size: 30rpx;color: #222327;height: 110rpx;line-height: 110rpx;}
  215. .cate-right-txt{display: flex;flex-wrap: wrap;
  216. text{font-weight: 500;font-size: 26rpx;color: #666666;min-width: 130rpx;margin-right:24rpx ;margin-bottom: 16rpx;padding: 8rpx 0;
  217. &.act{color: #1D64E2;}
  218. }
  219. }
  220. }
  221. }
  222. }
  223. .allbtns{font-weight: bold;font-size: 26rpx;color: #28C529;padding: 0 26rpx;}
  224. }
  225. // 弹窗
  226. .lmtac{padding: 0 22rpx 40rpx;box-sizing: border-box;display: flex;flex-direction: column;
  227. position: fixed;left: 0;right: 0;bottom: 0;background: #FFFFFF;height:612rpx;
  228. box-shadow: 0px 12rpx 6rpx 0px #EDEDED;
  229. .table{display: flex;flex-direction: column;overflow: hidden;}
  230. .upimg{padding: 20rpx;margin: 0 auto 6rpx;width: 64rpx;flex: 0 0 auto;
  231. image{width: 24rpx;height: 26rpx;}
  232. }
  233. .lmtit{font-weight: bold;font-size: 30rpx;color: #222327;}
  234. .lmtxt{
  235. display: flex;align-items: flex-start;font-weight: bold;font-size: 30rpx;
  236. .laber{color: #222327;flex: 0 0 auto;}
  237. .lmame{display: flex;flex-wrap: wrap;flex: 1;
  238. .tit{color: #1D64E2;display: flex;align-items: center;margin-right: 20rpx;}
  239. .delimg{
  240. width: 40rpx;height: 40rpx;display: flex;align-items: center;justify-content: center;
  241. image{width: 26rpx;height: 26rpx;margin-left: 12rpx;}
  242. }
  243. }
  244. }
  245. .btns{width: 100%;height: 80rpx;margin-top: 30rpx;
  246. background: #1D64E2;font-weight: bold;font-size: 30rpx;
  247. color: #FFFFFF;display: flex;align-items: center;justify-content: center;
  248. border-radius: 40rpx;}
  249. }
  250. </style>