index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. <template>
  2. <view>
  3. <view class="yearSelect">
  4. <uni-combox :candidates="yearRange" placeholder="请选择年份" v-model="selectYear"></uni-combox>
  5. </view>
  6. <view class="scroll_bar">
  7. <uni-list>
  8. <uni-list-item>
  9. <template v-slot:header>
  10. <view>
  11. <button class="week_button" @click="showDrawer" type="primary"> {{scrollInto}} </button>
  12. </view>
  13. </template>
  14. <template v-slot:body>
  15. <scroll-view id="tab-bar" class="scroll-h" :scroll-x="true" :show-scrollbar="false"
  16. :scroll-into-view="scrollInto">
  17. <view v-for="(tab,index) in tabBars" :key="tab.id" class="uni-tab-item" :id="tab.id" :data-current="index"
  18. @click="ontabtap">
  19. <text class="uni-tab-item-title"
  20. :class="tabIndex==index ? 'uni-tab-item-title-active' : ''">{{tab.name}}</text>
  21. </view>
  22. </scroll-view>
  23. </template>
  24. </uni-list-item>
  25. </uni-list>
  26. </view>
  27. <view class="diary_content">
  28. <uni-list>
  29. <uni-list-item>
  30. <template v-slot:header>
  31. <view class="date">日期</view>
  32. </template>
  33. <template v-slot:footer>
  34. <view class="content">
  35. <uni-row :gutter="10">
  36. <uni-col :span="8">任务</uni-col>
  37. <uni-col :span="8">完成</uni-col>
  38. <uni-col :span="8">反馈</uni-col>
  39. </uni-row>
  40. </view>
  41. </template>
  42. </uni-list-item>
  43. <uni-list-item @click="toEditDiary(scrollInto)" clickable>
  44. <template v-slot:header>
  45. <view class="date">
  46. <uni-row>本周</uni-row>
  47. <uni-row>11.11-11.17</uni-row>
  48. </view>
  49. </template>
  50. <template v-slot:footer>
  51. <view class="content">
  52. <uni-row :gutter="10">
  53. <uni-col :span="8">
  54. <uni-easyinput type="textarea" disabled v-model="TODO" autoHeight placeholder="请输入内容"></uni-easyinput>
  55. </uni-col>
  56. <uni-col :span="8">
  57. <uni-easyinput type="textarea" disabled v-model="DONE" autoHeight placeholder="请输入内容"></uni-easyinput>
  58. </uni-col>
  59. <uni-col :span="8">
  60. <uni-easyinput type="textarea" disabled v-model="BUG" autoHeight placeholder="请输入内容"></uni-easyinput>
  61. </uni-col>
  62. </uni-row>
  63. </view>
  64. </template>
  65. </uni-list-item>
  66. <uni-list-item @click="toEditDiary(day)" v-for="(day, index) in '一二三四五六日'" :key="index" clickable>
  67. <template v-slot:header>
  68. <view class="date">
  69. <uni-row :gutter="10">周{{day}}</uni-row>
  70. <uni-row :gutter="10">11.1{{index+1}}</uni-row>
  71. </view>
  72. </template>
  73. <template v-slot:footer>
  74. <view class="content">
  75. <uni-row :gutter="10">
  76. <uni-col :span="8">
  77. <uni-easyinput type="textarea" disabled v-model="TODO" autoHeight placeholder="请输入内容"></uni-easyinput>
  78. </uni-col>
  79. <uni-col :span="8">
  80. <uni-easyinput type="textarea" disabled v-model="DONE" autoHeight placeholder="请输入内容"></uni-easyinput>
  81. </uni-col>
  82. <uni-col :span="8">
  83. <uni-easyinput type="textarea" disabled v-model="BUG" autoHeight placeholder="请输入内容"></uni-easyinput>
  84. </uni-col>
  85. </uni-row>
  86. </view>
  87. </template>
  88. </uni-list-item>
  89. </uni-list>
  90. </view>
  91. <view class="drawer_container">
  92. <uni-drawer ref="rightDrawer" mode="left">
  93. <scroll-view style="height: 100%;" scroll-y="true">
  94. <view v-for="item in 60" :key="item">第 {{ item }} 周</view>
  95. </scroll-view>
  96. </uni-drawer>
  97. </view>
  98. </view>
  99. </template>
  100. <script setup lang="ts">
  101. import { onMounted, reactive, ref } from 'vue'
  102. import $tab from '@/plugins/tab.js'
  103. const TODO = ref('1. 完成 通讯录 页面\n2. 完成 人员信息 页面')
  104. const DONE = ref('1. 完成 通讯录 页面\n2. 完成 通讯录人员信息 页面\n3. 解决 地图无法正常显示定位 问题')
  105. const BUG = ref('原生 map 组件仅提供查看地图功能,不提供定位功能')
  106. function toEditDiary(day) {
  107. console.log('toEditDiary', day);
  108. // getWeekNumber(new Date())
  109. $tab.navigateTo('/pages/work/diary/edit?day=' + day)
  110. }
  111. const rightDrawer = ref(null)
  112. function showDrawer() {
  113. rightDrawer.value.open()
  114. }
  115. function closeDrawer() {
  116. rightDrawer.value.close()
  117. }
  118. const scrollInto = ref(1)
  119. const tabIndex = ref(0)
  120. let tabBars = reactive([])
  121. function ontabtap(e) {
  122. console.log('ontabtap', e);
  123. let index = e.target.dataset.current || e.currentTarget.dataset.current;
  124. switchTab(index);
  125. }
  126. function switchTab(index) {
  127. if (tabIndex.value === index) {
  128. return;
  129. }
  130. tabIndex.value = index;
  131. scrollInto.value = tabBars[index].id;
  132. }
  133. const selectYear = ref(-1)
  134. let yearRange = reactive([])
  135. onMounted(() => {
  136. tabBars = [
  137. {
  138. name: '第1周',
  139. id: '1'
  140. }, {
  141. name: '第2周',
  142. id: '2'
  143. }, {
  144. name: '第3周',
  145. id: '3'
  146. }, {
  147. name: '第4周',
  148. id: '4'
  149. }, {
  150. name: '第5周',
  151. id: '5'
  152. }, {
  153. name: '第6周',
  154. id: '6'
  155. }, {
  156. name: '第7周',
  157. id: '7'
  158. }, {
  159. name: '第8周',
  160. id: '8'
  161. }, {
  162. name: '第9周',
  163. id: '9'
  164. },
  165. ],
  166. yearRange = ['2023', '2024']
  167. let thisYear = yearRange.find((item) => Number(item) == new Date().getFullYear())
  168. console.log('thisYear', thisYear)
  169. selectYear.value = thisYear
  170. })
  171. function changeYear(e) {
  172. let a = getWeekNumber(new Date())
  173. console.log('changeYear', e)
  174. }
  175. function getWeekNumber(date) {
  176. // 创建一个新的日期对象,传入日期
  177. const tempDate = new Date('2019-12-31 15:56:02')
  178. let day = tempDate.getDay()
  179. // 调整到同一周的周四
  180. // day 为 0(即周日),则使用 7 代替 day
  181. tempDate.setDate(tempDate.getDate() + 4 - (day || 7))
  182. // 将日期调整到 周四 这年的第一天(1月1日)
  183. const year = new Date(tempDate.getFullYear(), 0, 1)
  184. // 计算并返回当前日期所在的周数
  185. const week = Math.ceil(((tempDate - year) / 86400000 + 1) / 7)
  186. let _date = {
  187. year: year.getFullYear(),
  188. week,
  189. day
  190. }
  191. console.log('_date', _date);
  192. return week
  193. }
  194. function getTotalWeeksInYear(date) {
  195. // 创建一个新的日期对象,传入日期
  196. const tempDate = new Date(date)
  197. const year = tempDate.getFullYear()
  198. const startOfYear = new Date(year, 0, 1); // 1 月 1 日
  199. const endOfYear = new Date(year, 11, 31); // 12 月 31 日
  200. }
  201. </script>
  202. <style lang="scss">
  203. .yearSelect {
  204. input {
  205. text-align: center;
  206. }
  207. }
  208. .year_button {
  209. border-radius: 0px;
  210. }
  211. .scroll_bar {
  212. .week_button {
  213. height: 80rpx;
  214. border-radius: 0 5px 5px 0;
  215. }
  216. ::v-deep .uni-list-item__container {
  217. padding-left: 0;
  218. }
  219. .scroll-h {
  220. width: 95%;
  221. /* #ifdef H5 */
  222. width: 100%;
  223. /* #endif */
  224. height: 80rpx;
  225. flex-direction: row;
  226. /* #ifndef APP-PLUS */
  227. white-space: nowrap;
  228. margin-left: 5px;
  229. margin-right: 5px;
  230. /* #endif */
  231. /* flex-wrap: nowrap; */
  232. // border-color: #cccccc;
  233. // border-bottom-style: solid;
  234. // border-bottom-width: 1px;
  235. .uni-tab-item {
  236. /* #ifndef APP-PLUS */
  237. display: inline-block;
  238. /* #endif */
  239. flex-wrap: nowrap;
  240. padding-left: 34rpx;
  241. padding-right: 34rpx;
  242. }
  243. .uni-tab-item-title {
  244. color: #555;
  245. font-size: 30rpx;
  246. height: 80rpx;
  247. line-height: 80rpx;
  248. flex-wrap: nowrap;
  249. /* #ifndef APP-PLUS */
  250. white-space: nowrap;
  251. /* #endif */
  252. }
  253. .uni-tab-item-title-active {
  254. color: #007AFF;
  255. }
  256. }
  257. }
  258. .diary_content {
  259. .date {
  260. text-align: center;
  261. width: 20%;
  262. }
  263. .content {
  264. text-align: center;
  265. width: 100%;
  266. .is-disabled {
  267. color: #000 !important;
  268. }
  269. }
  270. }
  271. </style>