dorpdownSelect.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <view class="select-bg_bx">
  3. <view v-if="isShowTit" @click="switchCut" :class="['select-title',dropdownShow?'select_corlor':'']" >
  4. <text v-if="typeTime">{{selectItemId?menuObjActive:menuObj.title}}</text>
  5. <text v-else>{{menuObjActive?menuObjActive:getMyShopInfo.shopName}}</text>
  6. <i v-if="isShowMore" class="iconfont iconsanjiao_xia" ></i>
  7. </view>
  8. <view class="select-mark-view" v-show="dropdownShow" @click="switchCut" ></view>
  9. <view v-if="dropdownShow" :style="{ top }" class="select-fixed_bx" >
  10. <slot>
  11. <view class="select-item-box">
  12. <view class="title">{{menuObj.titleChild}}</view>
  13. <view class="item-child_box">
  14. <button v-for="(item,index) in menuObj.list" :key="index" @click="changeItem(item)" :class="['admin-button-com','mini-btn',selectItemId === item.id?'blue':'default']" >
  15. {{item.name}}
  16. </button>
  17. </view>
  18. </view>
  19. </slot>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. import DropdownList from "@/components/plugin/dropdown-list";
  25. import AppDatePicker from "@/components/app-date-picker";
  26. import rangeDatePick from '@/components/pyh-rdtpicker/pyh-rdtpicker.vue';
  27. import { mapGetters } from "vuex";
  28. export default {
  29. name: 'DorpdownSelect',
  30. components: {
  31. DropdownList, AppDatePicker, rangeDatePick
  32. },
  33. props: {
  34. menuObj: {
  35. type: Object,
  36. default: () => ({
  37. title: '时间',
  38. titleChild: '时间',
  39. list: [{ name: '昨天', id: '0' }, { name: '今天', id: '1' }, { name: '本月', id: '2' }, { name: '上月', id: '3' }, { name: '今年', id: '4' }]
  40. })
  41. },
  42. top: {
  43. type: String,
  44. default: 'auto'
  45. },
  46. selectItemId: {
  47. type: [String, Number],
  48. default: ''
  49. },
  50. isShowTit: {
  51. type: Boolean,
  52. default: true
  53. },
  54. typeTime: {
  55. type: Boolean,
  56. default: false
  57. },
  58. isShowMore: {
  59. type: Boolean,
  60. default: true
  61. }
  62. },
  63. data () {
  64. return {
  65. dropdownShow: false,
  66. selectItem: '',
  67. menuObjActive: '',
  68. }
  69. },
  70. computed: {
  71. ...mapGetters(["getMyShopInfo"]),
  72. formatSelect () {
  73. if (!this.$util.isEmpty(this.selectItemId) &&
  74. this.$util.isString(this.selectItemId) &&
  75. this.selectItemId.split('-').length > 1) {
  76. return true
  77. } else {
  78. return false
  79. }
  80. },
  81. },
  82. methods: {
  83. switchCut () {
  84. this.dropdownShow = !this.dropdownShow
  85. },
  86. changeItem (val) {
  87. console.log(this.menuObj)
  88. console.log('abc')
  89. if (val.id == this.selectItemId && val.name != '自定义') {
  90. return false
  91. }
  92. this.$emit('update:selectItemId', val.id)
  93. this.dropdownShow = false;
  94. this.$emit('update:menuObj', {
  95. ...this.menuObj,
  96. title: val.name
  97. })
  98. this.menuObjActive = val.name;
  99. this.$emit('selectSussess', {
  100. select: this.$util.isString(val) ? val : val.name,
  101. selectItem: val
  102. })
  103. },
  104. endTimeFn (e) {
  105. this.selectItemId = e.detail.value;
  106. this.dropdownShow = false;
  107. this.$emit('update:selectItemId', val.id)
  108. this.$emit('update:menuObj', {
  109. ...this.menuObj,
  110. title: e.detail.value
  111. })
  112. this.$emit('selectSussess', {
  113. select: e.detail.value,
  114. selectItem: val
  115. })
  116. }
  117. }
  118. }
  119. </script>
  120. <style lang="scss" scoped>
  121. .select-bg_bx {
  122. .select-title {
  123. color: #666666;
  124. font-size: 26px;
  125. & .iconsanjiao_xia {
  126. margin-left: 10px;
  127. }
  128. &.select_corlor {
  129. color: #3385ff;
  130. & .iconsanjiao_xia {
  131. transform: rotate(180deg);
  132. }
  133. }
  134. }
  135. .select-mark-view {
  136. height: 100vh;
  137. height: 100%;
  138. position: fixed;
  139. width: 100%;
  140. background-color: rgba(0, 0, 0, 0.5);
  141. left: 0;
  142. top: 0px;
  143. z-index: 900;
  144. }
  145. & .select-fixed_bx {
  146. position: fixed;
  147. width: 100%;
  148. background-color: #ffffff;
  149. left: 0upx;
  150. top:0upx;
  151. z-index: 999;
  152. padding: 120px 30px 40px;
  153. border-radius: 0px 0px 20px 20px;
  154. transition: all 0.5s ease-in-out;
  155. & .select-item-box {
  156. & .title {
  157. font-size: 24px;
  158. color: #333333;
  159. font-weight: 600;
  160. text-align: left;
  161. }
  162. & .item-child_box {
  163. padding: 20px 0 0;
  164. align-items: center;
  165. display: inline-block;
  166. & .admin-button-com {
  167. margin-bottom: 20px;
  168. margin-right: 20px;
  169. padding: 18px 50px;
  170. &.custom {
  171. width: 100%;
  172. }
  173. }
  174. }
  175. }
  176. }
  177. }
  178. </style>