nav_filter.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <template>
  2. <view class="menu">
  3. <view class="menu_item">
  4. <i class="icon-font icon-filter_2" @click.stop="open"></i>
  5. <popup ref="popupRef" :title="title" isClose>
  6. <template #content>
  7. <view class="cont">
  8. <view class="filter_item">
  9. <view class="filter_item_label">
  10. <trans _t="创建时间" />
  11. </view>
  12. <view class="filter_time">
  13. <uni-datetime-picker v-model="params.begin" :border="false" :end="params.end" type="date"
  14. @change="beginChange">
  15. <view class="date_time">
  16. <view class="time_left">
  17. <up-icon name="calendar" color="#a8abb2" size="14" />
  18. <trans class="time_text" _t="开始日期" v-if="!params.begin" />
  19. <text class="time_text" v-else>{{ params.begin }}</text>
  20. </view>
  21. <view class="icons" v-if="params.begin" @click.stop="clear('begin')">
  22. <up-icon name="close-circle" color="#a8abb2" />
  23. </view>
  24. </view>
  25. </uni-datetime-picker>
  26. <view class="time_splice">—</view>
  27. <uni-datetime-picker v-model="params.end" type="date" :border="false" @change="endChange"
  28. :start="params.begin">
  29. <view class="date_time">
  30. <view class="time_left">
  31. <up-icon name="calendar" color="#a8abb2" size="14"></up-icon>
  32. <trans class="time_text" _t="结束日期" v-if="!params.end" />
  33. <text class="time_text" v-else>{{ params.end }}</text>
  34. </view>
  35. <view class="icons" v-if="params.end" @click.stop="clear('end')">
  36. <up-icon name="close-circle" color="#a8abb2" />
  37. </view>
  38. </view>
  39. </uni-datetime-picker>
  40. </view>
  41. </view>
  42. <template v-if="!isOrderTime">
  43. <view class="filter_item">
  44. <view class="filter_item_label">
  45. <trans _t="订单时间" />
  46. </view>
  47. </view>
  48. <view class="filter_status">
  49. <view class="status_item"
  50. :class="[(index == orderStatus.length - 1) && (orderStatus.length % 2 != 0) ? 'is-block' : '', active == index ? 'active' : '']"
  51. v-for="item, index in orderStatus" :key="index" @click="statusClick(item, index)">
  52. {{ item.value }}
  53. </view>
  54. </view>
  55. </template>
  56. </view>
  57. </template>
  58. <template #footer>
  59. <view class="footer_btn">
  60. <view class="btn" @click="reset">
  61. <trans _t="重置" />
  62. </view>
  63. <view class="btn btn_search" @click="submit">
  64. <trans _t="搜索" />
  65. </view>
  66. </view>
  67. </template>
  68. </popup>
  69. </view>
  70. </view>
  71. </template>
  72. <script setup>
  73. import { ref, reactive, computed } from "vue"
  74. import popup from "@/components/popup";
  75. import { useShopStore } from "@/store";
  76. const useShop = useShopStore();
  77. const props = defineProps({
  78. title: {
  79. type: String,
  80. default: '筛选'
  81. },
  82. isOrderTime: Boolean
  83. })
  84. const emit = defineEmits(['submit'])
  85. const popupRef = ref(null);
  86. const active = ref(-1)
  87. const orderStatus = computed(() => useShop.getOrderStatus)
  88. useShop.setOrderStatus();
  89. const params = reactive({
  90. begin: '',
  91. end: '',
  92. status: ''
  93. })
  94. const open = () => {
  95. popupRef.value && popupRef.value.open();
  96. }
  97. const close = () => {
  98. popupRef.value && popupRef.value.close();
  99. }
  100. const statusClick = (item, index) => {
  101. params.status = item.status;
  102. if (active.value == index) return active.value = -1;
  103. active.value = index;
  104. }
  105. const beginChange = (time) => {
  106. // console.log(time);
  107. }
  108. const endChange = (time) => { }
  109. const clear = (value) => {
  110. params[value] = ''
  111. }
  112. const reset = () => {
  113. params.begin = ''
  114. params.end = ''
  115. params.status = ''
  116. active.value = -1;
  117. emit('submit', params);
  118. close();
  119. }
  120. const submit = () => {
  121. emit('submit', params);
  122. close();
  123. }
  124. defineExpose({
  125. close
  126. })
  127. </script>
  128. <style lang="less" scoped>
  129. .menu {
  130. &_item {
  131. .icon-filter_2 {
  132. font-size: 24px;
  133. color: var(--text);
  134. padding-right: 8px;
  135. }
  136. .cont {
  137. width: 100%;
  138. .filter_item {
  139. .filter_item_label {
  140. color: var(--text-01);
  141. font-size: 28rpx;
  142. margin-bottom: 24rpx;
  143. }
  144. .filter_time {
  145. display: flex;
  146. align-items: center;
  147. margin-bottom: 24rpx;
  148. /deep/ .uni-calendar-item--checked {
  149. background-color: var(--black);
  150. }
  151. /deep/ .uni-datetime-picker--btn {
  152. background-color: var(--black);
  153. border-radius: 16rpx;
  154. font-size: 28rpx;
  155. }
  156. .date_time {
  157. box-shadow: 0 0 0 1px #dcdfe6 inset;
  158. display: flex;
  159. height: 42px;
  160. align-items: center;
  161. background-color: #f5f6f7;
  162. padding: 0 11px;
  163. border-radius: 8px;
  164. justify-content: space-between;
  165. .time_left {
  166. display: flex;
  167. align-items: center;
  168. }
  169. .time_text {
  170. margin-left: 8px;
  171. font-size: 26rpx;
  172. color: #aeaeae;
  173. }
  174. }
  175. .time_splice {
  176. color: var(--text);
  177. font-size: 28rpx;
  178. padding: 0 24rpx;
  179. }
  180. }
  181. }
  182. .filter_status {
  183. display: flex;
  184. gap: 24rpx;
  185. flex-wrap: wrap;
  186. .status_item {
  187. width: calc((100% - 24rpx) / 2);
  188. font-size: 24rpx;
  189. font-weight: 400;
  190. height: 72rpx;
  191. padding: 16rpx 30rpx;
  192. border-radius: 16rpx;
  193. border: 1px solid #dcdfe6;
  194. background-color: var(--light);
  195. display: flex;
  196. align-items: center;
  197. justify-content: center;
  198. color: var(--text-02);
  199. }
  200. .is-block {
  201. width: 100%;
  202. }
  203. .active {
  204. color: var(--light);
  205. background-color: var(--black);
  206. }
  207. }
  208. }
  209. .footer_btn {
  210. display: flex;
  211. column-gap: 24rpx;
  212. .btn {
  213. flex: 1;
  214. height: 76rpx;
  215. padding: 16rpx 30rpx;
  216. color: var(--black);
  217. border: 1px solid var(--black);
  218. display: flex;
  219. align-items: center;
  220. justify-content: center;
  221. border-radius: 16rpx;
  222. font-size: 24rpx;
  223. }
  224. .btn_search {
  225. background-color: var(--black);
  226. color: var(--light);
  227. }
  228. }
  229. }
  230. }
  231. </style>