dropdownPanel.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <template>
  2. <view class="filter-wrapper" :style="{ height: height + 'px'}" @touchmove.stop.prevent="discard">
  3. <view class="inner-wrapper">
  4. <view class="mask" :class="showMask ? 'show' : 'hide'" :style="{top: top}" @tap="tapMask"></view>
  5. <view class="navs">
  6. <view class="c-flex-center" :class="{ 'c-flex-center': index > 0, actNav: index === actNav }"
  7. v-for="(item, index) in navData" :key="index" @click="navClick(item,index)">
  8. <view v-if="item.special&&item.name=='批量'" class="x-f" style="align-items: end;">
  9. <u-icon name="file-text" :color="index === actNav ?'#2979ff':'#222'" size="20"></u-icon>
  10. {{index === actNav ? '取消批量':'批量'}}
  11. </view>
  12. <template v-else>
  13. <text style="width: max-content;">{{item.name}}</text>
  14. <image src="/static/manergevip/icon-pullup.png" mode="" class="icon-triangle"
  15. v-if="index === actNav"></image>
  16. <image src="/static/manergevip/icon-down.png" mode="" class="icon-triangle"
  17. v-else></image>
  18. </template>
  19. </view>
  20. </view>
  21. <view scroll-y="true" class="popup" :class="popupShow ? 'popupShow' : ''">
  22. <scroll-view scroll-y="true" style="height: 30vh;">
  23. <slot></slot>
  24. </scroll-view>
  25. <view class="footer x-bc">
  26. <view class="footer-btn" @click="reset">重置</view>
  27. <view class="footer-btn footer-blue" @click="confirm">确认</view>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. // import { getCurDateTime } from '@/libs/utils.js';
  35. export default {
  36. props: {
  37. height: {
  38. type: Number,
  39. default: 40
  40. },
  41. // top: {
  42. // type: String,
  43. // default: 'calc(var(--window-statsu-bar) + 44px)'
  44. // },
  45. border: {
  46. type: Boolean,
  47. default: false
  48. },
  49. filterData: {
  50. //必填
  51. type: Array,
  52. default: () => {
  53. return []
  54. }
  55. },
  56. ispopshow: {
  57. type: Boolean,
  58. default: false
  59. },
  60. itemname: {
  61. type: String,
  62. default: ''
  63. },
  64. defaultIndex: {
  65. //默认选中条件索引,超出一类时必填
  66. type: Array,
  67. default: () => {
  68. return [0];
  69. }
  70. }
  71. },
  72. data() {
  73. return {
  74. top: 0,
  75. navData: [],
  76. popupShow: false,
  77. showMask: false,
  78. actNav: null,
  79. selIndex: [] //选中条件索引
  80. };
  81. },
  82. watch: {
  83. // titname(newVal,oldVal){
  84. // console.log(newVal,oldVal)
  85. // if(newVal==2){
  86. // console.log(newVal,oldVal)
  87. // this.popupShow=false
  88. // this.showMask=false
  89. // }
  90. // }
  91. },
  92. created() {
  93. this.navData = this.filterData;
  94. this.selIndex = this.defaultIndex;
  95. // this.keepStatus();
  96. },
  97. mounted() {
  98. const query = uni.createSelectorQuery().in(this);
  99. query
  100. .select(".filter-wrapper")
  101. .boundingClientRect((data) => {
  102. // console.log(data)
  103. this.top = data.top + 'px'
  104. })
  105. .exec();
  106. },
  107. methods: {
  108. reset() {
  109. this.$emit('reset');
  110. this.showMask = false;
  111. this.popupShow = false;
  112. },
  113. confirm() {
  114. this.showMask = false;
  115. this.popupShow = false;
  116. this.$emit('confirm');
  117. },
  118. keepStatus() {
  119. // this.navData.forEach(itemnavData => {
  120. // itemnavData.map(child => {
  121. // child.select = false;
  122. // });
  123. // return itemnavData;
  124. // });
  125. // for (let i = 0; i < this.selIndex.length; i++) {
  126. // let selindex = this.selIndex[i];
  127. // this.navData[i][selindex].select = true;
  128. // }
  129. },
  130. navClick(item, index) {
  131. if (this.showMask && item.type == 'piliang') {
  132. this.popupShow = false
  133. this.showMask = false
  134. this.actNav = null
  135. return
  136. }
  137. this.titname = index
  138. this.$emit('onClick', item);
  139. if (index === this.actNav) return this.tapMask();
  140. this.actNav = index;
  141. if (item.stopPrevent) return
  142. this.popupShow = true;
  143. this.showMask = true;
  144. this.$emit('onChange', this.actNav);
  145. },
  146. handleOpt(index) {
  147. // this.selIndex[this.actNav] = index;
  148. // this.keepStatus();
  149. // setTimeout(() => {
  150. // this.tapMask();
  151. // }, 100);
  152. // let data = [];
  153. // let res = this.navData.forEach(item => {
  154. // let sel = item.filter(child => child.select);
  155. // data.push(sel);
  156. // });
  157. // console.log(data);
  158. // this.$emit('onSelected', data);
  159. },
  160. tapMask() {
  161. this.showMask = false;
  162. this.popupShow = false;
  163. this.actNav = null;
  164. },
  165. discard() {}
  166. }
  167. };
  168. </script>
  169. <style lang="scss" scoped>
  170. .c-flex-align {
  171. display: flex;
  172. align-items: center;
  173. }
  174. .c-flex-center {
  175. display: flex;
  176. align-items: center;
  177. justify-content: center;
  178. flex-direction: column;
  179. }
  180. .footer {
  181. font-family: PingFang SC, PingFang SC;
  182. font-weight: 400;
  183. font-size: 14px;
  184. color: #222;
  185. padding: 10px;
  186. &-btn {
  187. flex: 1;
  188. text-align: center;
  189. background-color: #fff;
  190. border: 1px solid #999;
  191. border-radius: 50px;
  192. padding: 10px 0;
  193. }
  194. &-blue {
  195. background-color: #1677ff;
  196. border: 1px solid #1677ff;
  197. color: #fff;
  198. margin-left: 10px;
  199. }
  200. }
  201. .filter-wrapper {
  202. // position: fixed;
  203. // left: 0;
  204. // width: 750rpx;
  205. // z-index: 999;
  206. .inner-wrapper {
  207. // position: relative;
  208. .navs {
  209. position: relative;
  210. font-family: PingFang SC, PingFang SC;
  211. font-weight: 400;
  212. font-size: 14px;
  213. color: #222;
  214. padding: 10px;
  215. display: flex;
  216. align-items: center;
  217. justify-content: space-between;
  218. background-color: #fff;
  219. z-index: 999;
  220. box-sizing: border-box;
  221. &>view {
  222. flex: 1;
  223. height: 100%;
  224. flex-direction: row;
  225. z-index: 999;
  226. }
  227. .date {
  228. justify-content: flex-end;
  229. }
  230. .actNav {
  231. color: #1677ff;
  232. font-weight: bold;
  233. }
  234. }
  235. .mask {
  236. z-index: 666;
  237. position: fixed;
  238. top: 0;
  239. left: 0;
  240. right: 0;
  241. bottom: 0;
  242. background-color: rgba(0, 0, 0, 0);
  243. transition: background-color 0.15s linear;
  244. &.show {
  245. background-color: rgba(0, 0, 0, 0.4);
  246. }
  247. &.hide {
  248. display: none;
  249. }
  250. }
  251. .popup {
  252. position: relative;
  253. // max-height: 500rpx;
  254. background-color: #fff;
  255. border-bottom-left-radius: 20rpx;
  256. border-bottom-right-radius: 20rpx;
  257. overflow: scroll;
  258. z-index: 999;
  259. transition: all 1s linear;
  260. opacity: 0;
  261. display: none;
  262. .item-opt {
  263. height: 100rpx;
  264. padding: 0 40rpx;
  265. color: #8b9aae;
  266. border-bottom: 2rpx solid #f5f6f9;
  267. }
  268. .actOpt {
  269. color: #1677ff;
  270. font-weight: bold;
  271. position: relative;
  272. &::after {
  273. content: '✓';
  274. font-weight: bold;
  275. font-size: 36rpx;
  276. position: absolute;
  277. right: 40rpx;
  278. }
  279. }
  280. }
  281. .popupShow {
  282. display: block;
  283. opacity: 1;
  284. }
  285. }
  286. .icon-triangle {
  287. width: 16rpx;
  288. height: 16rpx;
  289. margin-left: 10rpx;
  290. }
  291. }
  292. </style>