report-query.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <view class="query-box">
  3. <view class="query">
  4. <u-search placeholder="请输入报表名称" v-model="queryParams.reportTableName" :show-action="false" shape="square"
  5. clearabled @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="item.imgUrl" 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="起始时间" end-placeholder="终止时间"
  30. @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. let imgs = ['../../static/image/1.png', '../../static/image/2.png',
  91. '../../static/image/3.png', '../../static/image/4.png'
  92. ]
  93. this.reportList.map((item) => {
  94. switch (item.reportTableType) {
  95. case 0:
  96. item.imgUrl = '../../static/image/2.png'
  97. break;
  98. case 1:
  99. item.imgUrl = '../../static/image/1.png'
  100. break;
  101. case 2:
  102. item.imgUrl = '../../static/image/4.png'
  103. break;
  104. case 5:
  105. item.imgUrl = '../../static/image/3.png'
  106. break;
  107. }
  108. })
  109. uni.stopPullDownRefresh()
  110. }
  111. })
  112. },
  113. // 打开筛选
  114. openQuery() {
  115. this.monthQuery = !this.monthQuery
  116. this.$emit('handelDate', getLastWeek())
  117. },
  118. // 切换时间
  119. monthChange(current) {
  120. this.monthCurrent = current
  121. switch (current) {
  122. case 1:
  123. this.$emit('handelDate', getLastMonth())
  124. break;
  125. case 2:
  126. this.$emit('handelDate', getLast3Month())
  127. break;
  128. case 3:
  129. this.$emit('handelDate', getLast6Month())
  130. break;
  131. default:
  132. this.$emit('handelDate', getLastWeek())
  133. break;
  134. }
  135. },
  136. // 选中范围时间
  137. change(val) {
  138. // this.$emit('handelDate', val)
  139. },
  140. //搜索
  141. search() {
  142. this.getAllReport()
  143. this.monthQuery = false
  144. this.monthCurrent = 0
  145. // this.$emit('reset')
  146. },
  147. //清空搜索框
  148. clear() {
  149. this.getAllReport()
  150. }
  151. }
  152. }
  153. </script>
  154. <style lang="scss" scoped>
  155. .query-box {
  156. .query {
  157. margin-top: 40rpx;
  158. padding: 0 40rpx;
  159. display: flex;
  160. justify-content: space-around;
  161. align-items: center;
  162. .screen {
  163. display: flex;
  164. align-items: center;
  165. margin-left: 30rpx;
  166. .screen-img {
  167. width: 40rpx;
  168. height: 40rpx;
  169. }
  170. }
  171. }
  172. .query-screen {
  173. width: 96vw;
  174. padding: 0 20rpx;
  175. background: #ffffff;
  176. position: absolute;
  177. top: 0;
  178. z-index: 999;
  179. .month {
  180. display: flex;
  181. justify-content: space-between;
  182. align-items: center;
  183. font-size: 28rpx;
  184. margin: 40rpx 0;
  185. .month-item {
  186. padding: 10rpx 20rpx;
  187. background: #ECECEC;
  188. color: #000000;
  189. border-radius: 12rpx;
  190. }
  191. .month-select {
  192. padding: 10rpx 20rpx;
  193. border-radius: 12rpx;
  194. background: #289BFF;
  195. color: #ffffff;
  196. }
  197. }
  198. .month-btn {
  199. display: flex;
  200. justify-content: space-around;
  201. margin-top: 40rpx;
  202. margin-bottom: 40rpx;
  203. .reset {
  204. background: #EAF4FF;
  205. color: #469DED;
  206. border: 1px solid #A3B8CB;
  207. }
  208. }
  209. }
  210. }
  211. .list-box {
  212. margin-top: 40rpx;
  213. position: relative;
  214. .modal {
  215. width: 100%;
  216. height: 76vh;
  217. position: absolute;
  218. top: 0;
  219. background: rgba(0, 0, 0, 0.5);
  220. }
  221. }
  222. </style>