index.vue 6.4 KB

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