index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <template>
  2. <view class="container">
  3. <page-title>周报查询</page-title>
  4. <view class="cards-list">
  5. <view class="card only-card">
  6. <!-- 开始周 -->
  7. <view class="card-item first-card-item">
  8. <view class="card-item-name">开始周</view>
  9. <view class="card-item-description" @click="showBeginTimeChoose()">
  10. <view>{{pageForm.startMonth}}</view>
  11. <u-icon name="arrow-right" color="#343437" size="16" customStyle="margin-left:10rpx"></u-icon>
  12. </view>
  13. </view>
  14. <!-- 结束周 -->
  15. <view class="card-item">
  16. <view class="card-item-name">结束周</view>
  17. <view class="card-item-description" @click="showEndTimeChoose()">
  18. <view>{{pageForm.endMonth}}</view>
  19. <u-icon name="arrow-right" color="#343437" size="16" customStyle="margin-left:10rpx"></u-icon>
  20. </view>
  21. </view>
  22. <!-- 录入状态 -->
  23. <view class="card-item" @click="statusShowChoose()">
  24. <view class="card-item-name">录入状态</view>
  25. <view class="card-item-description">
  26. <view v-if="pageForm.status">{{pageForm.status}}</view>
  27. <view v-else class="remind-text">请选择状态</view>
  28. <u-icon name="arrow-right" color="#343437" size="16" customStyle="margin-left:10rpx"></u-icon>
  29. </view>
  30. </view>
  31. <!-- 行业分类 -->
  32. <view class="card-item" @click="hyflShowChoose()">
  33. <view class="card-item-name">行业分类</view>
  34. <view class="card-item-description">
  35. <view v-if="pageForm.hyfl">{{pageForm.hyfl}}</view>
  36. <view v-else class="remind-text">请选择分类</view>
  37. <u-icon name="arrow-right" color="#343437" size="16" customStyle="margin-left:10rpx"></u-icon>
  38. </view>
  39. </view>
  40. <view class="card-item">
  41. <view class="card-item-name">项目名称</view>
  42. <input v-model="pageForm.subName" class="card-item-input" placeholder="请填写项目名称"
  43. placeholder-style="color: #D8D8D8" maxlength="20" />
  44. </view>
  45. </view>
  46. <view class="confirm-btn" @click="confirmParams()">查询</view>
  47. </view>
  48. <!-- 开始时间 -->
  49. <u-datetime-picker :show="beginTimeShow" @confirm="beginTimeClose" @cancel="beginTimeClose" @close="beginTimeClose"
  50. v-model="startMonth" mode="date" closeOnClickOverlay></u-datetime-picker>
  51. <!-- 结束时间 -->
  52. <u-datetime-picker :show="endTimeShow" @confirm="endTimeClose" @cancel="endTimeClose" @close="endTimeClose"
  53. v-model="endMonth" mode="date" closeOnClickOverlay></u-datetime-picker>
  54. <!-- 录入状态选择 -->
  55. <u-picker :show="statusShow" :columns="statusColumns" @confirm="statusClose" @cancel="statusClose"
  56. @close="statusClose" closeOnClickOverlay></u-picker>
  57. <!-- 行业分类选择 -->
  58. <u-picker :show="hyflShow" :columns="hyflColumns" @confirm="hyflClose" @cancel="hyflClose" @close="hyflClose"
  59. closeOnClickOverlay></u-picker>
  60. </view>
  61. </template>
  62. <script setup>
  63. import {
  64. ref
  65. } from 'vue'
  66. import {
  67. onLoad
  68. } from "@dcloudio/uni-app"
  69. import {
  70. timeFormat
  71. } from "@/utils/timeFormatter.js"
  72. import {
  73. getWeeklyCondition
  74. } from "@/api/work/weeklyAndMonthly.js"
  75. function getCondition() {
  76. getWeeklyCondition().then(res => {
  77. hyflOrginal = res.data?.HYFL
  78. let hyflTemp = res.data?.HYFL.map(item => item.title)
  79. hyflTemp.unshift('请选择')
  80. hyflColumns.value.push(hyflTemp)
  81. })
  82. }
  83. let pageForm = ref({
  84. startMonth: null,
  85. endMonth: null,
  86. status: "所有",
  87. hyfl: null,
  88. subName: null,
  89. })
  90. // ====================================选择开始时间
  91. let startMonth = ref(null)
  92. let beginTimeShow = ref(false)
  93. function showBeginTimeChoose() {
  94. beginTimeShow.value = true
  95. }
  96. function beginTimeClose(e) {
  97. if (e) {
  98. let time = timeFormat(e.value)
  99. pageForm.value.startMonth = getMondayToSunday(time)
  100. }
  101. beginTimeShow.value = false
  102. }
  103. // ====================================选择结束时间
  104. let endMonth = ref(null)
  105. let endTimeShow = ref(false)
  106. function showEndTimeChoose() {
  107. endTimeShow.value = true
  108. }
  109. function endTimeClose(e) {
  110. if (e) {
  111. let time = timeFormat(e.value)
  112. pageForm.value.endMonth = getMondayToSunday(time)
  113. }
  114. endTimeShow.value = false
  115. }
  116. // 改变选择时间格式(周一至周天格式)
  117. function getMondayToSunday(date) {
  118. const chooseDay = new Date(date); // 选中的时间
  119. let nowTime = chooseDay.getTime(); // 选中的时间(时间戳化)
  120. let week = chooseDay.getDay() || 7; // 选中的是星期几
  121. let oneDayTime = 24 * 60 * 60 * 1000; // 一天的时间
  122. let mondayTime = nowTime - (week - 1) * oneDayTime; //周一
  123. let sundayTime = nowTime + (7 - week) * oneDayTime; //周日
  124. let mondayText = timeFormat(mondayTime); //周一文字化
  125. let sundayText = timeFormat(sundayTime); //周日文字化
  126. let mon1 = mondayText.replace("/", "-")
  127. let mon2 = mon1.replace("/", "-")
  128. let sun1 = sundayText.replace("/", "-")
  129. let sun2 = sun1.replace("/", "-")
  130. return mon2 + "至" + sun2
  131. }
  132. // ====================================选择录入状态
  133. let statusShow = ref(false)
  134. let statusColumns = ref([
  135. ["所有", "已录入", "未录入"]
  136. ])
  137. function statusShowChoose() {
  138. statusShow.value = true;
  139. }
  140. function statusClose(e) {
  141. if (e) pageForm.value.status = e.value[0];
  142. statusShow.value = false
  143. }
  144. // ====================================选择行业分类
  145. let hyflOrginal = []
  146. let hyflShow = ref(false)
  147. let hyflColumns = ref([])
  148. function hyflShowChoose() {
  149. hyflShow.value = true;
  150. }
  151. function hyflClose(e) {
  152. if (e) pageForm.value.hyfl = e.value[0];
  153. hyflShow.value = false
  154. }
  155. // 确认选择
  156. function confirmParams() {
  157. let sendParams = Object.assign({}, pageForm.value)
  158. sendParams.startMonth = sendParams.startMonth.substr(0, 10)
  159. sendParams.endMonth = sendParams.endMonth.substr(0, 10)
  160. let statusOrginal = {
  161. "所有": "0",
  162. "已录入": "1",
  163. "未录入": "2"
  164. }
  165. sendParams.status = statusOrginal[sendParams.status] ? statusOrginal[sendParams.status] : null
  166. let item = hyflOrginal.find(item => item.title === sendParams.hyfl)
  167. sendParams.hyfl = item ? item.id : null
  168. let url = "/pages/weekly/list/index?"
  169. for (let i in sendParams) {
  170. let item = null
  171. if (sendParams[i]) {
  172. item = `${i}=${sendParams[i]}&`
  173. } else {
  174. item = `${i}=&`
  175. }
  176. url = url += item
  177. }
  178. url = url.substr(0, url.length - 1);
  179. uni.navigateTo({
  180. url
  181. })
  182. }
  183. onLoad(() => {
  184. // 结束时间
  185. let now = new Date()
  186. let nowFormat = timeFormat(now)
  187. endMonth.value = nowFormat
  188. pageForm.value.endMonth = getMondayToSunday(nowFormat)
  189. // 开始时间
  190. let start = now - 1000 * 60 * 60 * 24 * 14
  191. let startFormat = timeFormat(start)
  192. startMonth.value = startFormat
  193. pageForm.value.startMonth = getMondayToSunday(startFormat)
  194. getCondition()
  195. })
  196. </script>
  197. <style lang="scss" scoped>
  198. </style>