index.vue 7.4 KB

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