index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <template>
  2. <view class="container">
  3. <page-title>月报查询</page-title>
  4. <view class="cards-list">
  5. <view class="card only-card">
  6. <view class="card-item one-card-item">
  7. <view class="card-item-name">开始月份</view>
  8. <view class="card-item-description" @click="showBeginTimeChoose()">
  9. <view>{{pageForm.startMonth}}</view>
  10. <u-icon name="arrow-right" color="#D2D2D2" size="14" customStyle="margin-left:10rpx"></u-icon>
  11. </view>
  12. </view>
  13. <view class="card-item one-card-item">
  14. <view class="card-item-name">结束月份</view>
  15. <view class="card-item-description" @click="showEndTimeChoose()">
  16. <view>{{pageForm.endMonth}}</view>
  17. <u-icon name="arrow-right" color="#D2D2D2" size="14" customStyle="margin-left:10rpx"></u-icon>
  18. </view>
  19. </view>
  20. <!-- 录入状态 -->
  21. <view class="card-item one-card-item" @click="statusShowChoose()">
  22. <view class="card-item-name">录入状态</view>
  23. <view class="card-item-description">
  24. <view v-if="pageForm.status">{{pageForm.status}}</view>
  25. <view v-else class="remind-text">请选择状态</view>
  26. <u-icon name="arrow-right" color="#D2D2D2" size="14" customStyle="margin-left:10rpx"></u-icon>
  27. </view>
  28. </view>
  29. <!-- 行业分类 -->
  30. <view class="card-item one-card-item" @click="hyflShowChoose()">
  31. <view class="card-item-name">行业分类</view>
  32. <view class="card-item-description">
  33. <view v-if="pageForm.hyfl">{{pageForm.hyfl}}</view>
  34. <view v-else class="remind-text">请选择分类</view>
  35. <u-icon name="arrow-right" color="#D2D2D2" size="14" customStyle="margin-left:10rpx"></u-icon>
  36. </view>
  37. </view>
  38. <view class="card-item one-card-item">
  39. <view class="card-item-name">项目名称</view>
  40. <input v-model="pageForm.subName" class="card-item-input center-input"
  41. placeholder="请填写项目名称&nbsp;&nbsp;&nbsp;&nbsp;" placeholder-style="color: #D8D8D8;text-align:right;"
  42. maxlength="20" />
  43. </view>
  44. </view>
  45. <view class="" style="display: flex;justify-content: center;">
  46. <view class="confirm-btn" @click="confirmParams()">确定</view>
  47. </view>
  48. </view>
  49. <!-- 开始时间 -->
  50. <u-datetime-picker :show="beginTimeShow" @confirm="beginTimeClose" @cancel="beginTimeClose" @close="beginTimeClose"
  51. v-model="startMonth" mode="year-month" closeOnClickOverlay></u-datetime-picker>
  52. <!-- 结束时间 -->
  53. <u-datetime-picker :show="endTimeShow" @confirm="endTimeClose" @cancel="endTimeClose" @close="endTimeClose"
  54. v-model="endMonth" mode="year-month" closeOnClickOverlay></u-datetime-picker>
  55. <!-- 录入状态选择 -->
  56. <u-picker :show="statusShow" :columns="statusColumns" @confirm="statusClose" @cancel="statusClose"
  57. @close="statusClose" closeOnClickOverlay></u-picker>
  58. <!-- 行业分类选择 -->
  59. <u-picker :show="hyflShow" :columns="hyflColumns" @confirm="hyflClose" @cancel="hyflClose" @close="hyflClose"
  60. closeOnClickOverlay></u-picker>
  61. </view>
  62. </template>
  63. <script setup>
  64. import {
  65. ref
  66. } from 'vue'
  67. import {
  68. onLoad
  69. } from "@dcloudio/uni-app"
  70. import {
  71. timeFormat
  72. } from "@/utils/timeFormatter.js"
  73. import {
  74. getWeeklyCondition
  75. } from "@/api/work/weeklyAndMonthly.js"
  76. function getCondition() {
  77. getWeeklyCondition().then(res => {
  78. hyflOrginal = res.data?.HYFL
  79. let hyflTemp = res.data?.HYFL.map(item => item.title)
  80. hyflTemp.unshift('请选择')
  81. hyflColumns.value.push(hyflTemp)
  82. })
  83. }
  84. let pageForm = ref({
  85. startMonth: null,
  86. endMonth: null,
  87. status: "所有",
  88. hyfl: null,
  89. subName: null,
  90. })
  91. // ====================================选择开始时间
  92. let startMonth = ref(null)
  93. let beginTimeShow = ref(false)
  94. function showBeginTimeChoose() {
  95. beginTimeShow.value = true
  96. }
  97. function beginTimeClose(e) {
  98. if (e) {
  99. let time = timeFormat(e.value)
  100. time = time.substring(0, 7)
  101. pageForm.value.startMonth = time
  102. }
  103. beginTimeShow.value = false
  104. }
  105. // ====================================选择结束时间
  106. let endMonth = ref(null)
  107. let endTimeShow = ref(false)
  108. function showEndTimeChoose() {
  109. endTimeShow.value = true
  110. }
  111. function endTimeClose(e) {
  112. if (e) {
  113. let time = timeFormat(e.value)
  114. time = time.substring(0, 7)
  115. pageForm.value.endMonth = time
  116. }
  117. endTimeShow.value = false
  118. }
  119. // ====================================选择录入状态
  120. let statusShow = ref(false)
  121. let statusColumns = ref([
  122. ["所有", "已录入", "未录入"]
  123. ])
  124. function statusShowChoose() {
  125. statusShow.value = true;
  126. }
  127. function statusClose(e) {
  128. if (e) pageForm.value.status = e.value[0];
  129. statusShow.value = false
  130. }
  131. // ====================================选择行业分类
  132. let hyflOrginal = []
  133. let hyflShow = ref(false)
  134. let hyflColumns = ref([])
  135. function hyflShowChoose() {
  136. hyflShow.value = true;
  137. }
  138. function hyflClose(e) {
  139. if (e) pageForm.value.hyfl = e.value[0];
  140. hyflShow.value = false
  141. }
  142. function confirmParams() {
  143. const params = Object.assign({}, pageForm.value)
  144. let start01 = params.startMonth.replace('/', '-')
  145. let start02 = start01.replace('/', '-') + '-01'
  146. params.startMonth = start02
  147. let end01 = params.endMonth.replace('/', '-')
  148. let end02 = end01.replace('/', '-') + '-01'
  149. params.endMonth = end02
  150. let statusOrginal = {
  151. "所有": "0",
  152. "已录入": "1",
  153. "未录入": "2"
  154. }
  155. params.status = statusOrginal[params.status] ? statusOrginal[params.status] : null
  156. let item = hyflOrginal.find(item => item.title === params.hyfl)
  157. params.hyfl = item ? item.id : null
  158. let url = "/pages/monthly/list/index?"
  159. for (let i in params) {
  160. let item = null
  161. if (params[i]) {
  162. item = `${i}=${params[i]}&`
  163. } else {
  164. item = `${i}=&`
  165. }
  166. url = url += item
  167. }
  168. url = url.substr(0, url.length - 1);
  169. uni.navigateTo({
  170. url
  171. })
  172. }
  173. onLoad(async () => {
  174. // 结束时间
  175. let now = new Date();
  176. let year = now.getFullYear();
  177. let nowmonth = now.getMonth()
  178. let lastTime = new Date(now - 1000 * 60 * 60 * 24 * 30)
  179. let lastYear = lastTime.getFullYear()
  180. let lastMonth = lastTime.getMonth()
  181. if (nowmonth > 8) {
  182. nowmonth = nowmonth + 1
  183. } else {
  184. nowmonth = `0${nowmonth +1}`
  185. }
  186. if (lastMonth > 8) {
  187. lastMonth = lastMonth + 1
  188. } else {
  189. lastMonth = `0${lastMonth +1}`
  190. }
  191. // let nowFormat = timeFormat(now).substring(0, 7)
  192. let nowFormat = year + `/${nowmonth}`;
  193. endMonth.value = nowFormat
  194. pageForm.value.endMonth = nowFormat
  195. // 开始时间
  196. // let start = now - 1000 * 60 * 60 * 24 * 120
  197. // let startFormat = timeFormat(start).substring(0, 7)
  198. let startFormat = lastYear + `/${lastMonth}`;
  199. startMonth.value = startFormat
  200. pageForm.value.startMonth = startFormat
  201. getCondition()
  202. })
  203. </script>
  204. <style lang="scss" scoped>
  205. .one-card-item {
  206. justify-content: space-between;
  207. }
  208. .card .card-item .card-item-description {
  209. font-size: 28rpx !important;
  210. }
  211. .card .card-item .card-item-name {
  212. white-space: nowrap;
  213. }
  214. .confirm-btn {
  215. width: 328rpx;
  216. height: 72rpx;
  217. line-height: 72rpx;
  218. background: #002F69;
  219. border-radius: 38rpx;
  220. font-weight: 500;
  221. font-size: 36rpx;
  222. color: #FFFFFF;
  223. }
  224. </style>