cm-screen-drawer.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. <template>
  2. <view class="drawer-content">
  3. <!--右抽屉-->
  4. <tui-drawer mode="right" :visible="rightDrawer" @close="closeDrawer">
  5. <view
  6. class="drawer-container clearfix"
  7. scroll-y
  8. :style="{ paddingTop: '0px', paddingBottom: isIphoneX ? '180rpx' : '146rpx' }"
  9. >
  10. <scroll-view class="tui-drawer-scroll" scroll-y :style="{ height: drawerH + 'px' }">
  11. <view class="drawer-title">更多筛选</view>
  12. <view class="drawer-main">
  13. <view class="drawer-main-name">日期</view>
  14. <view class="drawer-main-time">
  15. <view class="drawer-main-time-input">
  16. <picker mode="date" :value="date" :start="startDate" :end="endDate" @change="bindStartDateChange">
  17. <text class="input-text">{{ queryData.startAddTime }}</text>
  18. </picker>
  19. <text class="iconfont icon-riqi"></text>
  20. </view>
  21. <view class="line">-</view>
  22. <view class="drawer-main-time-input">
  23. <picker mode="date" :value="date" :start="startDate" :end="endDate" @change="bindEndDateChange">
  24. <text class="input-text">{{ queryData.endAddTime }}</text>
  25. </picker>
  26. <text class="iconfont icon-riqi"></text>
  27. </view>
  28. </view>
  29. <view class="drawer-main-name">咨询类别</view>
  30. <view class="drawer-main-brand clearfix">
  31. <view
  32. class="drawer-brand-list"
  33. :class="category.isChecked ? 'checked' : ''"
  34. v-for="(category, index) in categorys"
  35. :key="index"
  36. @click="choiceCategorys(category, index)"
  37. >
  38. {{ category.className }}
  39. </view>
  40. </view>
  41. <template v-if="manager > 0">
  42. <view class="drawer-main-name">小组</view>
  43. <view class="drawer-main-brand clearfix">
  44. <view
  45. class="drawer-brand-list"
  46. :class="isCheckedGroups ? 'checked' : ''"
  47. @click="choiceGroupsAll"
  48. >全部</view
  49. >
  50. <view
  51. class="drawer-brand-list"
  52. :class="group.isChecked ? 'checked' : ''"
  53. v-for="(group, index) in groups"
  54. :key="index"
  55. @click="choiceGroups(group, index)"
  56. >
  57. {{ group.leaderName }}
  58. </view>
  59. </view>
  60. </template>
  61. <template v-if="leaderId>0">
  62. <view class="drawer-main-name" v-if="members.length>0">组员</view>
  63. <view class="drawer-main-brand clearfix" v-if="members.length>0">
  64. <view
  65. class="drawer-brand-list"
  66. :class="member.isChecked ? 'checked' : ''"
  67. v-for="(member, index) in members"
  68. :key="index"
  69. @click="choiceMembers(member, index)"
  70. >
  71. {{ member.groupName }}
  72. </view>
  73. </view>
  74. </template>
  75. </view>
  76. </scroll-view>
  77. <view class="drawer-input btn" :style="{ paddingBottom: isIphoneX ? '68rpx' : '34rpx' }">
  78. <view class="drawer-btn clear" @click="closeDrawer">取消</view>
  79. <view class="drawer-btn comfrim" @click="handSearchConfirm">确定</view>
  80. </view>
  81. </view>
  82. </tui-drawer>
  83. </view>
  84. </template>
  85. <script>
  86. export default {
  87. name: 'rightDrawer',
  88. props: {
  89. rightDrawer: {
  90. type: Boolean,
  91. default: false
  92. }
  93. },
  94. data() {
  95. const currentDate = this.getDate({
  96. format: true
  97. })
  98. return {
  99. CustomBar: this.CustomBar, // 顶部导航栏高度
  100. isIphoneX: this.$store.state.isIphoneX,
  101. isCheckedGroups:false,
  102. checkedIndex: 0,
  103. checkedGroupsIndex: 0,
  104. checkedMemberIndex: 0,
  105. isShowClose: false,
  106. dataList: [],
  107. date: currentDate,
  108. manager:0,
  109. leaderId:0,
  110. height: 0,
  111. drawerH: 0 ,// 抽屉内部scrollview高度
  112. categorys:[],
  113. checkedCategorysList:[],
  114. groups:[],
  115. members:[],
  116. queryData:{
  117. startAddTime:'',
  118. endAddTime:'',
  119. consult:'',
  120. leaderId:0,
  121. groupId:0,
  122. }
  123. }
  124. },
  125. created() {
  126. this.SetScrollHeight()
  127. this.getUserClubConsults()
  128. },
  129. computed: {
  130. startDate() {
  131. return this.getDate('start')
  132. },
  133. endDate() {
  134. return this.getDate('end')
  135. }
  136. },
  137. methods: {
  138. async getUserClubConsults() {
  139. const userInfo = await this.$api.getStorage()
  140. this.manager = userInfo.manager ? userInfo.manager : 0
  141. this.leaderId = userInfo.leaderId ? userInfo.leaderId : 0
  142. //查询咨询类别
  143. this.UserService.getUserClubConsults()
  144. .then(response => {
  145. this.categorys = response.data.map((el, index) => {
  146. el.isChecked = false
  147. return el
  148. })
  149. if(this.manager > 0){
  150. this.getUserClubTeams()
  151. }
  152. if(this.leaderId > 0){
  153. this.getUserClubTeamsRroups(this.leaderId)
  154. }
  155. })
  156. .catch(error => {
  157. console.log('=========>获取咨询类别列表失败')
  158. })
  159. },
  160. getUserClubTeams() {
  161. this.UserService.getUserClubTeams()
  162. .then(response => {
  163. this.groups = response.data.map((el, index) => {
  164. el.isChecked = false
  165. return el
  166. })
  167. })
  168. .catch(error => {
  169. console.log('=========>获取小组列表失败')
  170. })
  171. },
  172. getUserClubTeamsRroups(leaderId) {
  173. this.UserService.getUserClubTeamsRroups({leaderId:leaderId})
  174. .then(response => {
  175. this.members = response.data.map((el, index) => {
  176. el.isChecked = false
  177. return el
  178. })
  179. })
  180. .catch(error => {
  181. console.log('=========>获取咨询类别列表失败')
  182. })
  183. },
  184. choiceCategorys(category,idx){
  185. //选择分类
  186. category.isChecked = !category.isChecked
  187. if (category.isChecked) {
  188. if(!this.contains(this.checkedCategorysList,category.id)){
  189. this.checkedCategorysList.push(category.id)
  190. }
  191. } else {
  192. this.checkedCategorysList.splice(this.checkedCategorysList.indexOf(category.id),1)
  193. }
  194. this.queryData.consult = this.checkedCategorysList.join(',')
  195. },
  196. contains(arr, val) {// 校验
  197. return arr.some(item => item === val)
  198. },
  199. choiceGroupsAll() {
  200. // 点击选择全部小组
  201. this.isCheckedGroups = true
  202. this.queryData.leaderId = ''
  203. this.groups.forEach(el => {
  204. el.isChecked = false
  205. })
  206. },
  207. choiceGroups(group,idx){
  208. //选择小组
  209. this.isCheckedGroups = false
  210. this.checkedGroupsIndex = idx
  211. this.groups.forEach((el, index) => {
  212. if (this.checkedGroupsIndex == index) {
  213. el.isChecked = true
  214. this.queryData.leaderId = group.leaderId
  215. this.getUserClubTeamsRroups(group.leaderId)
  216. } else {
  217. el.isChecked = false
  218. }
  219. })
  220. },
  221. choiceMembers(member, idx) {
  222. //选择组员
  223. this.checkedMemberIndex = idx
  224. this.members.forEach((el, index) => {
  225. if (this.checkedMemberIndex == index) {
  226. el.isChecked = true
  227. this.queryData.groupId = member.groupId
  228. } else {
  229. el.isChecked = false
  230. }
  231. })
  232. },
  233. closeDrawer(){
  234. this.$parent.isScreenDrawer = false
  235. },
  236. handSearchConfirm(){
  237. //确定筛选
  238. this.$emit('handSearchConfirm', this.queryData)
  239. this.$parent.isScreenDrawer = false
  240. },
  241. bindStartDateChange(event){
  242. //开始时间
  243. console.log('开始时间==>',event.detail.value)
  244. this.queryData.startAddTime = event.detail.value
  245. },
  246. bindEndDateChange(event){
  247. //结束时间
  248. console.log('结束时间==>',event.detail.value)
  249. this.queryData.endAddTime = event.detail.value
  250. },
  251. SetScrollHeight() {
  252. let obj = {}
  253. const { windowHeight, pixelRatio } = wx.getSystemInfoSync()
  254. uni.getSystemInfo({
  255. success: res => {
  256. this.height = obj.top ? obj.top + obj.height + 8 : res.statusBarHeight + 44
  257. this.drawerH = res.windowHeight - uni.upx2px(180) - this.height
  258. }
  259. })
  260. this.windowHeight = windowHeight - 1
  261. this.scrollHeight = windowHeight - 1
  262. },
  263. getDate(type) {
  264. const date = new Date()
  265. let year = date.getFullYear()
  266. let month = date.getMonth() + 1
  267. let day = date.getDate()
  268. if (type === 'start') {
  269. year = year - 1
  270. } else if (type === 'end') {
  271. year = year + 1
  272. }
  273. month = month > 9 ? month : '0' + month
  274. day = day > 9 ? day : '0' + day
  275. return `${year}-${month}-${day}`
  276. }
  277. }
  278. }
  279. </script>
  280. <style lang="scss">
  281. /*screen*/
  282. .drawer-container {
  283. width: 580rpx;
  284. height: 100%;
  285. padding: 80rpx 0;
  286. overflow: hidden;
  287. box-sizing: border-box;
  288. background-color: #FFFFFF;
  289. .drawer-title {
  290. width: 100%;
  291. height: 72rpx;
  292. line-height: 72rpx;
  293. box-sizing: border-box;
  294. padding: 0 30rpx;
  295. float: left;
  296. background-color: #f7f7f7;
  297. font-size: $font-size-26;
  298. color: #333333;
  299. font-weight: bold;
  300. text-align: left;
  301. }
  302. .drawer-main {
  303. width: 100%;
  304. height: auto;
  305. box-sizing: border-box;
  306. float: left;
  307. .drawer-main-name{
  308. width: 100%;
  309. height: 80rpx;
  310. line-height: 80rpx;
  311. text-align: left;
  312. font-size: $font-size-26;
  313. color: #333333;
  314. box-sizing: border-box;
  315. padding: 0 20rpx;
  316. font-weight: bold;
  317. }
  318. .drawer-main-time{
  319. width: 100%;
  320. height: 56rpx;
  321. box-sizing: border-box;
  322. .line{
  323. color: #999999;
  324. float: left;
  325. line-height: 56rpx;
  326. }
  327. .drawer-main-time-input{
  328. width: 228rpx;
  329. height: 56rpx;
  330. background: #F7F7F7;
  331. border-radius: 28rpx;
  332. box-sizing: border-box;
  333. padding: 0 20rpx;
  334. line-height: 56rpx;
  335. float: left;
  336. margin: 0 20rpx;
  337. position: relative;
  338. .input-text{
  339. display: block;
  340. height: 56rpx;
  341. font-size: 26rpx;
  342. color: #666666;
  343. }
  344. .icon-riqi{
  345. color: #E15616;
  346. display: block;
  347. width: 40rpx;
  348. height: 56rpx;
  349. position: absolute;
  350. right: 10rpx;
  351. top: 0;
  352. line-height: 56rpx;
  353. }
  354. }
  355. }
  356. .drawer-main-brand {
  357. width: 100%;
  358. height: auto;
  359. box-sizing: border-box;
  360. padding: 0 20rpx;
  361. background-color: #ffffff;
  362. .drawer-brand-list {
  363. width: 160rpx;
  364. height: 56rpx;
  365. line-height: 56rpx;
  366. text-align: center;
  367. font-size: 26rpx;
  368. background-color: #f7f7f7;
  369. color: #999999;
  370. border-radius: 30rpx;
  371. box-sizing: border-box;
  372. padding: 0 15rpx;
  373. float: left;
  374. margin: 12rpx 24rpx 12rpx 0;
  375. text-overflow: ellipsis;
  376. overflow: hidden;
  377. display: -webkit-box;
  378. -webkit-line-clamp: 1;
  379. line-clamp: 1;
  380. -webkit-box-orient: vertical;
  381. &.checked {
  382. background-color: #fef6f3;
  383. color: #e15616;
  384. }
  385. &:nth-child(3n) {
  386. margin-right: 0;
  387. }
  388. }
  389. }
  390. }
  391. .drawer-input {
  392. width: 100%;
  393. float: left;
  394. box-sizing: border-box;
  395. padding: 24rpx 10rpx 0 10rpx;
  396. border: 1px solid rgba(0, 0, 0, 0.2);
  397. border-radius: 4rpx;
  398. position: relative;
  399. background-color: #ffffff;
  400. &.btn {
  401. border: none;
  402. display: flex;
  403. position: fixed;
  404. left: 0;
  405. bottom: 0;
  406. }
  407. .drawer-btn {
  408. width: 210rpx;
  409. height: 84rpx;
  410. border-radius: 42rpx;
  411. background: $btn-confirm;
  412. line-height: 84rpx;
  413. text-align: center;
  414. font-size: $font-size-26;
  415. color: #ffffff;
  416. flex: 1;
  417. margin: 0 10rpx;
  418. &.comfrim {
  419. background: $btn-confirm;
  420. }
  421. &.clear {
  422. background: #FFE6DC;
  423. color: $color-system;
  424. }
  425. }
  426. }
  427. }
  428. </style>