index.vue 7.7 KB

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