report-query.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <view class="query-box">
  3. <view class="query">
  4. <u-search placeholder="请输入报表名称" v-model="queryParams.reportTableName" :show-action="false" shape="square" clearabled
  5. @search="search" @clear="clear" search-icon="../../static/image/search.png">
  6. </u-search>
  7. <view class="screen" @click="search">
  8. <image class="screen-img" src="@/static/image/sx.png" alt="">
  9. <view >筛选</view>
  10. </view>
  11. </view>
  12. <view class="list-box">
  13. <uni-list>
  14. <uni-list-item v-for="item in reportList" :key="item.id" :title="item.reportTableName"
  15. :note="item.createTime" thumb="../../static/image/sjcx.png" thumb-size="medium" link
  16. :to="`/pages/reportForm/report-detail/index?id=${item.id}&title=${item.reportTableName}`">
  17. </uni-list-item>
  18. </uni-list>
  19. <view v-if="monthQuery" class="query-screen">
  20. <view>
  21. 报表时间选择
  22. </view>
  23. <view class="month">
  24. <view :class="monthCurrent===item.current?'month-select':'month-item'" v-for="item in monthList"
  25. :key="item.current" @click="monthChange(item.current)">
  26. {{item.name}}
  27. </view>
  28. </view>
  29. <uni-datetime-picker type="daterange" start-placeholder="起始时间"
  30. end-placeholder="终止时间" @change="change" />
  31. <view class="month-btn">
  32. <u-button class="reset" style="width:200rpx" @click="search">重置</u-button>
  33. <u-button type="primary" style="width:200rpx" @click="search">确认</u-button>
  34. </view>
  35. </view>
  36. <view class="modal" v-if="monthQuery"></view>
  37. <u-empty v-if="!reportList.length" class="empty" icon="../../static/data.png" text="暂无数据">
  38. </u-empty>
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. import {
  44. getLastWeek,
  45. getLastMonth,
  46. getLast3Month,
  47. getLast6Month
  48. } from '@/utils/date.js'
  49. export default {
  50. props: {
  51. queryParams: Object
  52. },
  53. data() {
  54. return {
  55. // 报表列表数据
  56. reportList: [],
  57. // 时间选择
  58. monthList: [{
  59. name: '近一周',
  60. current: 0
  61. },
  62. {
  63. name: '近1个月',
  64. current: 1
  65. },
  66. {
  67. name: '近3个月',
  68. current: 2
  69. },
  70. {
  71. name: '近6个月',
  72. current: 3
  73. }
  74. ],
  75. monthCurrent: 0,
  76. monthQuery: false,
  77. }
  78. },
  79. mounted() {
  80. this.getAllReport()
  81. this.$emit('handelDate', getLastWeek())
  82. },
  83. methods: {
  84. // 获取报表数据
  85. getAllReport() {
  86. uni.$http.get('/reportTable/getAllOkReportTable', this.queryParams).then(res => {
  87. const data = res.data
  88. if (data.code === 200) {
  89. this.reportList = data.data.reportTableList
  90. uni.stopPullDownRefresh()
  91. }
  92. })
  93. },
  94. // 打开筛选
  95. openQuery() {
  96. this.monthQuery = !this.monthQuery
  97. this.$emit('handelDate', getLastWeek())
  98. },
  99. // 切换时间
  100. monthChange(current) {
  101. this.monthCurrent = current
  102. switch (current) {
  103. case 1:
  104. this.$emit('handelDate', getLastMonth())
  105. break;
  106. case 2:
  107. this.$emit('handelDate', getLast3Month())
  108. break;
  109. case 3:
  110. this.$emit('handelDate', getLast6Month())
  111. break;
  112. default:
  113. this.$emit('handelDate', getLastWeek())
  114. break;
  115. }
  116. },
  117. // 选中范围时间
  118. change(val) {
  119. // this.$emit('handelDate', val)
  120. },
  121. //搜索
  122. search() {
  123. this.getAllReport()
  124. this.monthQuery = false
  125. this.monthCurrent = 0
  126. // this.$emit('reset')
  127. },
  128. //清空搜索框
  129. clear(){
  130. this.getAllReport()
  131. }
  132. }
  133. }
  134. </script>
  135. <style lang="scss" scoped>
  136. .query-box {
  137. .query {
  138. margin-top: 40rpx;
  139. padding: 0 40rpx;
  140. display: flex;
  141. justify-content: space-around;
  142. align-items: center;
  143. .screen {
  144. display: flex;
  145. align-items: center;
  146. margin-left: 30rpx;
  147. .screen-img {
  148. width: 40rpx;
  149. height: 40rpx;
  150. }
  151. }
  152. }
  153. .query-screen {
  154. width: 96vw;
  155. padding: 0 20rpx;
  156. background: #ffffff;
  157. position: absolute;
  158. top: 0;
  159. z-index: 999;
  160. .month {
  161. display: flex;
  162. justify-content: space-between;
  163. align-items: center;
  164. font-size: 28rpx;
  165. margin: 40rpx 0;
  166. .month-item {
  167. padding: 10rpx 20rpx;
  168. background: #ECECEC;
  169. color: #000000;
  170. border-radius: 12rpx;
  171. }
  172. .month-select {
  173. padding: 10rpx 20rpx;
  174. border-radius: 12rpx;
  175. background: #289BFF;
  176. color: #ffffff;
  177. }
  178. }
  179. .month-btn {
  180. display: flex;
  181. justify-content: space-around;
  182. margin-top: 40rpx;
  183. margin-bottom: 40rpx;
  184. .reset {
  185. background: #EAF4FF;
  186. color: #469DED;
  187. border: 1px solid #A3B8CB;
  188. }
  189. }
  190. }
  191. }
  192. .list-box {
  193. margin-top: 40rpx;
  194. position: relative;
  195. .modal {
  196. width: 100%;
  197. height: 76vh;
  198. position: absolute;
  199. top: 0;
  200. background: rgba(0, 0, 0, 0.5);
  201. }
  202. }
  203. </style>