selectMember.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. <template>
  2. <view class="container u-f es-ver flex-1">
  3. <view class="u-f searchBox">
  4. <view class="u-f-ajc" @tap="goBack">
  5. <image class="es-icon-56" src="/static/image/black_back.png" mode=""></image>
  6. </view>
  7. <view class="u-f-ajc flex-1">
  8. <u-search placeholder="请输入会员昵称" v-model="keyword" :showAction="false" height="30px"
  9. @search="gettagUserlist" @change="searchKeyword"></u-search>
  10. </view>
  11. <view class="es-c-00 es-fs-28 es-ml-32 u-f-ajc">
  12. 取消
  13. </view>
  14. </view>
  15. <view class="es-c-33 es-fs-32 es-fw-500 es-mt-28" v-if="selectTagList && selectTagList.length>0">
  16. 选择标签
  17. </view>
  18. <view class="u-f es-mt-8 acea-row maxHeight" v-if="selectTagList && selectTagList.length>0">
  19. <view class="es-mr-20 es-mt-20 tabBox" v-for="(item, index) in selectTagList" :key="item.tagId"
  20. @tap="selectTag(index)" :class="[item.checked?'active':'es-c-22']">
  21. {{item.tag}}
  22. </view>
  23. </view>
  24. <view class="u-f u-f-jsb es-fs-24 es-mt-42">
  25. <view class="">
  26. <text class="es-c-99">已选择 </text>
  27. <text class="w-calc-22">{{this.params.selectUser.length}} </text>
  28. <text class="es-c-99">人:</text>
  29. </view>
  30. <view class="u-f-ajc" @tap="selectAll">
  31. <image v-if="isSelectAll" class="es-icon-44" src="/static/images/icon_circle_sel.png" mode=""></image>
  32. <image v-else class="es-icon-44" src="/static/images/check_icon.png" mode=""></image>
  33. <text class="es-fs-28 es-c-22 es-ml-12">全选</text>
  34. </view>
  35. </view>
  36. <view class="selectBox u-f maxHeight" v-if="this.params.selectUser.length>0">
  37. <view class="selectBox-list es-mr-24 es-mt-26" v-for="(item,index) in this.params.selectUser" :key='index'
  38. @tap="delUser(index)">
  39. <text class="es-fs-28 es-c-22 es-fw-400 es-mr-12">{{item.nickname}}</text>
  40. <image class="es-icon-24" src="/static/images/icon_close1.png" mode=""></image>
  41. </view>
  42. </view>
  43. <scroll-view scroll-y="true" class="flex-1 scroll-y mt20" :lower-threshold="300" @scrolltolower="reachBottom">
  44. <view class="tagbox-list x-f" style="white-space: nowrap;flex-wrap: wrap;">
  45. <view class="u-f-ajc flex-1" v-if="tagsuserlist.length<=0">
  46. <u-empty class="u-f-ajc" mode="data"></u-empty>
  47. </view>
  48. <view class="u-f es-mt-20 flex-1 user-list" v-for="(item,index) in tagsuserlist" :key='index'
  49. @tap="selectUser(index)" :class="[item.checked?'userSelectBg':'']">
  50. <view class="es-icon-88 es-br-ban es-mr-24">
  51. <image class="es-icon-88 es-br-ban" :src="item.avatar" mode=""></image>
  52. </view>
  53. <view class="flex-1 u-f u-f-jsb">
  54. <view class="">
  55. <view class="">
  56. <text class="es-fs-32 w-calc-22 es-fw-500 es-mr-16">{{item.nickname}}</text>
  57. <text class="es-fs-22 idBox">ID:{{item.userId}}</text>
  58. </view>
  59. <view class="es-fs-24 es-c-66 es-mt-10">
  60. 项目名称:{{item.projectName}}
  61. </view>
  62. </view>
  63. <view class="u-f-ajc">
  64. <image v-if="item.checked" class="es-icon-44" src="/static/images/icon_circle_sel.png"
  65. mode="">
  66. </image>
  67. <image v-else class="es-icon-44" src="/static/images/check_icon.png" mode=""></image>
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. </scroll-view>
  73. <view class="fixedBox u-f u-f-jsb">
  74. <button class="fixedBox-btn" @click="resetUser">重置</button>
  75. <button class="fixedBox-btn con-btn" @click="sure">确定</button>
  76. </view>
  77. </view>
  78. </template>
  79. <script>
  80. import {
  81. getallTags,
  82. getFsCourseList,
  83. getCourseVdieoList,
  84. getfsuserList,
  85. pageListByApp,
  86. } from "./api/manageCompany.js"
  87. export default {
  88. components: {
  89. // courseItem,
  90. // dropdownPanel
  91. },
  92. data() {
  93. return {
  94. keyword: '',
  95. selectTagList: [],
  96. tagsuserlist: [],
  97. timer: null,
  98. isEnableds: true,
  99. triggereds: false,
  100. isSelectAll: false,
  101. pagetag: [],
  102. parameter: {
  103. pageNum: 1,
  104. pageSize: 10
  105. },
  106. totalPage: 0,
  107. params: {
  108. selectUser: [],
  109. tagIds: [],
  110. },
  111. projectId: '',
  112. paramsId: ''
  113. }
  114. },
  115. onLoad(params) {
  116. if (params.projectId) {
  117. this.projectId = params.projectId
  118. }
  119. if (params.paramsId) {
  120. this.paramsId = params.paramsId
  121. }
  122. this.gettagUserlist('refresh')
  123. this.selectTagFun('refresh')
  124. },
  125. methods: {
  126. goBack() {
  127. uni.navigateBack()
  128. },
  129. sure() {
  130. uni.$emit('selectUserData', this.params.selectUser)
  131. uni.navigateBack()
  132. },
  133. //选择标签
  134. selectTag(index) {
  135. this.selectTagList[index].checked = !this.selectTagList[index].checked
  136. this.params.tagIds = this.columnsa.filter(item => item.checked).map(v => v.tagId)
  137. this.gettagUserlist('refresh')
  138. },
  139. //选择会员
  140. selectUser(index) {
  141. this.tagsuserlist[index].checked = !this.tagsuserlist[index].checked
  142. this.params.selectUser = this.tagsuserlist.filter(item => item.checked)
  143. this.isSelectAll = this.tagsuserlist.every(item => item.checked)
  144. },
  145. selectAll() {
  146. this.isSelectAll = !this.isSelectAll
  147. this.tagsuserlist.forEach(item => {
  148. item.checked = this.isSelectAll
  149. })
  150. this.params.selectUser = this.tagsuserlist.filter(item => item.checked)
  151. },
  152. delUser(index) {
  153. this.tagsuserlist.forEach(item => {
  154. if (item.userId == this.params.selectUser[index].userId) {
  155. item.checked = !item.checked
  156. }
  157. })
  158. this.params.selectUser = this.tagsuserlist.filter(item => item.checked)
  159. },
  160. getuserid() {
  161. //会员确定
  162. this.userName = this.tagsuserlist.filter(item => item.checked)
  163. .map(v => v.nickname)
  164. this.params.userIds = this.tagsuserlist.filter(item => item.checked).map(v => v.userId)
  165. this.showvip = !this.showvip
  166. if (this.recipientType == 2) {
  167. this.selectTagList = this.params.tagIds = this.params.tagNames = []
  168. }
  169. },
  170. //获取标签列表
  171. async selectTagFun(type) {
  172. uni.showLoading({
  173. title: '加载中...'
  174. })
  175. const data = {
  176. pageNum: this.parameter.pageNum,
  177. pageSize: this.parameter.pageSize,
  178. keyword: this.keyword,
  179. }
  180. getallTags(data).then(res => {
  181. if (res.code == 200) {
  182. uni.hideLoading()
  183. const dataList = res.data.list.map(item => {
  184. let check = false
  185. if (this.params.tagIds.length > 0 && this.params.tagIds.includs(item
  186. .tagId)) {
  187. check = true
  188. }
  189. return {
  190. ...item,
  191. checked: check,
  192. }
  193. })
  194. if (type == 'refresh') {
  195. this.columnsa = dataList
  196. } else {
  197. this.columnsa = [...this.columnsa, ...dataList]
  198. }
  199. if (res.data.isLastPage) {
  200. this.statusA = 'nomore'
  201. } else {
  202. this.statusA = 'loadmore'
  203. }
  204. this.pagetag = res.data
  205. this.selectTagList = this.columnsa
  206. } else {
  207. uni.hideLoading()
  208. uni.showToast({
  209. icon: 'none',
  210. title: res.msg
  211. })
  212. }
  213. })
  214. },
  215. resetUser() {
  216. this.keyword = ''
  217. this.params.tagIds = []
  218. this.params.selectUser = []
  219. this.tagsuserlist = this.tagsuserlist.map(item => {
  220. return {
  221. ...item,
  222. checked: false
  223. };
  224. })
  225. this.selectTagList = this.selectTagList.map(item => {
  226. return {
  227. ...item,
  228. checked: false
  229. };
  230. })
  231. this.gettagUserlist('refresh')
  232. },
  233. searchKeyword(e) {
  234. if (this.timer) {
  235. clearTimeout(this.timer)
  236. }
  237. this.timer = setTimeout(() => {
  238. this.keyword = e
  239. this.parameter.pageNum = 1
  240. this.gettagUserlist('refresh')
  241. this.timer = ''
  242. }, 1000)
  243. },
  244. reachBottom() {
  245. if (this.totalPage < this.parameter.pageNum) return
  246. this.parameter.pageNum++
  247. this.gettagUserlist()
  248. },
  249. //会员列表
  250. gettagUserlist(type) {
  251. const param = {
  252. pageNum: this.parameter.pageNum,
  253. pageSize: this.parameter.pageSize,
  254. keyword: this.keyword,
  255. projectId: this.projectId * 1,
  256. tagIds: this.params.tagIds
  257. }
  258. // pageListByApp(param).then(res => {
  259. getfsuserList(param).then(res => {
  260. if (res.code == 200) {
  261. this.viewload = false;
  262. let dataList = res.data.list.map((item) => {
  263. let checked = false
  264. if (this.paramsId && this.paramsId.split(',').includes(item.userId + '')) {
  265. checked = true
  266. }
  267. return {
  268. ...item,
  269. checked: checked
  270. };
  271. });
  272. if (type == 'refresh') {
  273. this.tagsuserlist = dataList;
  274. } else if (type == 'more') {
  275. this.tagsuserlist = dataList;
  276. } else {
  277. this.tagsuserlist = [...this.tagsuserlist, ...dataList];
  278. }
  279. if (this.paramsId) {
  280. this.params.selectUser = this.tagsuserlist.filter(item => item.checked)
  281. }
  282. if (res.data.isLastPage) {
  283. this.status = 'nomore';
  284. } else {
  285. this.status = 'loadmore';
  286. }
  287. this.pagetag = res.data;
  288. this.totalPage = Math.ceil(res.data.total / this.parameter.pageSize)
  289. } else {
  290. uni.showToast({
  291. icon: 'none',
  292. title: res.msg
  293. });
  294. }
  295. })
  296. },
  297. }
  298. }
  299. </script>
  300. <style lang="scss" scoped>
  301. .container {
  302. background-color: #fff;
  303. min-height: 100vh;
  304. height: 100%;
  305. padding: 24rpx;
  306. box-sizing: border-box;
  307. }
  308. .searchBox {
  309. padding-top: var(--status-bar-height);
  310. height: calc(var(--status-bar-height) + 88rpx);
  311. }
  312. .tabBox {
  313. background: #F5F7FA;
  314. border-radius: 8rpx;
  315. padding: 8rpx 24rpx;
  316. }
  317. .active {
  318. color: #2583EB;
  319. background: #F0FAFF;
  320. }
  321. .userSelectBg {
  322. background: rgba(37, 131, 235, 0.06);
  323. }
  324. .user-list {
  325. padding: 20rpx;
  326. border-radius: 24rpx;
  327. .idBox {
  328. background: #FFF6E5;
  329. color: #C89743;
  330. padding: 2rpx 12rpx;
  331. border-radius: 8rpx;
  332. }
  333. }
  334. .maxHeight {
  335. max-height: 200rpx;
  336. overflow-y: scroll;
  337. }
  338. .selectBox {
  339. flex-wrap: wrap;
  340. .selectBox-list {
  341. border-radius: 76rpx;
  342. padding: 12rpx 24rpx;
  343. border: 2rpx solid #F5F5F5;
  344. }
  345. }
  346. .scroll-y {
  347. overflow-y: auto;
  348. padding-bottom: 128rpx;
  349. }
  350. .fixedBox {
  351. position: fixed;
  352. bottom: 0;
  353. background-color: #fff;
  354. padding: 24rpx;
  355. width: 100%;
  356. .fixedBox-btn {
  357. flex: 1;
  358. height: 80rpx;
  359. line-height: 80rpx;
  360. margin: 0 20rpx;
  361. border-radius: 42rpx;
  362. border: none;
  363. font-family: PingFang SC, PingFang SC;
  364. font-weight: 400;
  365. font-size: 28rpx;
  366. color: #757575;
  367. background: #F5F7FA;
  368. &::after {
  369. border: none;
  370. }
  371. }
  372. .con-btn {
  373. background: #2583EB;
  374. color: #fff;
  375. }
  376. }
  377. </style>