report-query.vue 5.8 KB

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