index.vue 7.3 KB

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