manage.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. <!--
  2. * @Author: liuzhenlin 461480418@qq.ocm
  3. * @Date: 2023-01-13 16:47:26
  4. * @LastEditors: liuzhenlin
  5. * @LastEditTime: 2023-02-16 15:37:22
  6. * @Description: file content
  7. * @FilePath: \oms\pages\schedule\components\manage.vue
  8. -->
  9. <template>
  10. <view class="manage-container">
  11. <view class="calendar-container" id="calendar">
  12. <!-- 显示日历 -->
  13. <custom-calendar v-if="calendarVisible" @clickDate="clickDate"></custom-calendar>
  14. <!-- 当前一周的日历 -->
  15. <view v-else class="calendar-box">
  16. <view class="calendar-header">
  17. <view class="today">{{ currentDay }}</view>
  18. <view class="more-btn" @click="toMore">更多</view>
  19. </view>
  20. <view class="week-wrap">
  21. <view
  22. class="week-item"
  23. :class="{ isActived: currentDay == calendarList[i] }"
  24. @click="selectDate(calendarList[i])"
  25. v-for="(v, i) in weekList"
  26. :key="i">
  27. <view class="week">{{ v }}</view>
  28. <view class="date" v-if="calendarList[i]">{{ parseInt(calendarList[i].split('-')[2]) }}</view>
  29. <view class="date2" :class="{ festival: lunarDate.festival }">
  30. {{ lunarDate(calendarList[i])['IDayCn'] || '' }}
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. <!-- 日程待办列表 -->
  37. <view class="todo-wrap" v-if="todoData">
  38. <view class="todo-item" v-for="(v, i) in todoData" :key="i">
  39. <u-row>
  40. <u-col span="12">
  41. <view class="header">
  42. <u-row>
  43. <u-col span="12">
  44. <view class="flex_l">
  45. <view class="circle green"></view>
  46. <text class="tit-txt text-ellipsis">
  47. {{ v.schTitle }}
  48. </text>
  49. </view>
  50. </u-col>
  51. </u-row>
  52. <u-row>
  53. <u-col span="5">
  54. <view class="circle"></view>
  55. <view class="date" v-if="v.schType == 20">全天</view>
  56. <view class="date" v-else>
  57. {{ parseTime(v.schDate, '{h}:{i}') }}-{{ parseTime(v.schDateEnd, '{h}:{i}') }}
  58. </view>
  59. </u-col>
  60. </u-row>
  61. <!-- <view class="content flex">
  62. <text class="content-txt text-ellipsis">
  63. {{ v.schContent }}
  64. </text>
  65. </view> -->
  66. </view>
  67. </u-col>
  68. </u-row>
  69. </view>
  70. </view>
  71. <u-empty v-else mode="list" text="暂无待办"></u-empty>
  72. <!-- 新增按钮 -->
  73. <view v-if="false" class="fixed-btn center" @click="openAdd()">
  74. <u-icon name="plus" color="#fff" size="20"></u-icon>
  75. </view>
  76. <!-- 新增待办 -->
  77. <add :addVisible.sync="addVisible"></add>
  78. </view>
  79. </template>
  80. <script>
  81. import to from 'await-to-js'
  82. import CustomCalendar from '@/components/calendar'
  83. import calendar from '@/utils/date'
  84. import add from './components/add'
  85. import scheduleApi from '@/api/schedule'
  86. export default {
  87. name: 'omsManage',
  88. components: {
  89. CustomCalendar,
  90. add,
  91. },
  92. data() {
  93. return {
  94. todoData: null,
  95. calendarVisible: false, //日历
  96. calendarList: [], // 用于遍历显示
  97. weekList: ['一', '二', '三', '四', '五', '六', '日'], // 周
  98. currentDay: 0,
  99. addVisible: false, //新增待办
  100. }
  101. },
  102. computed: {
  103. lunarDate() {
  104. return (date) => {
  105. if (!date) return {}
  106. const year = date.split('-')[0]
  107. const month = date.split('-')[1]
  108. const day = date.split('-')[2]
  109. return calendar.solar2lunar(year, month, day)
  110. }
  111. },
  112. },
  113. mounted() {
  114. this.getWeek()
  115. this.getTodoData()
  116. },
  117. watch: {
  118. async addVisible(val) {
  119. if (!val) {
  120. this.getTodoData()
  121. }
  122. },
  123. async calendarVisible(val) {
  124. this.$emit('setBackVisible', val)
  125. },
  126. },
  127. methods: {
  128. // 打开新增
  129. openAdd() {
  130. this.addVisible = true
  131. console.log(this.addVisible)
  132. },
  133. // 获取周
  134. getWeek() {
  135. const dateOfToday = Date.now()
  136. const dayOfToday = (new Date().getDay() + 7 - 1) % 7
  137. const daysOfThisWeek = Array.from(new Array(7)).map((_, i) => {
  138. const date = new Date(dateOfToday + (i - dayOfToday) * 1000 * 60 * 60 * 24)
  139. return (
  140. date.getFullYear() +
  141. '-' +
  142. String(date.getMonth() + 1).padStart(2, '0') +
  143. '-' +
  144. String(date.getDate()).padStart(2, '0')
  145. )
  146. })
  147. console.log(daysOfThisWeek)
  148. // 当前周的全部日期
  149. this.calendarList = daysOfThisWeek
  150. console.log('calendarList', this.calendarList)
  151. // 当前日期
  152. this.currentDay = daysOfThisWeek[dayOfToday]
  153. },
  154. async getTodoData(date = null) {
  155. const params = { schDate: date || this.currentDay, dataType: '10', pageNum: 1, pageSize: 999 }
  156. const [err, res] = await to(scheduleApi.getList(params))
  157. console.log(res)
  158. if (err) return
  159. if (res && res.code == 200) {
  160. this.todoData = res.data.list
  161. }
  162. },
  163. // 选择日期
  164. selectDate(date) {
  165. this.currentDay = date
  166. this.getTodoData()
  167. },
  168. // 选择日历
  169. clickDate(date) {
  170. this.getTodoData(date)
  171. },
  172. // 跳转日历
  173. toMore() {
  174. this.calendarVisible = true
  175. },
  176. // 从日历返回
  177. back() {
  178. this.calendarVisible = false
  179. },
  180. },
  181. }
  182. </script>
  183. <style lang="scss" scoped>
  184. .manage-container {
  185. width: 100%;
  186. height: calc(100vh - 346rpx);
  187. overflow: auto;
  188. .calendar-container {
  189. padding-bottom: 56rpx;
  190. }
  191. .calendar-box {
  192. padding-top: 42rpx;
  193. .calendar-header {
  194. display: flex;
  195. justify-content: space-between;
  196. align-items: center;
  197. margin-bottom: 12rpx;
  198. .today {
  199. font-size: 32rpx;
  200. font-weight: bold;
  201. color: #323232;
  202. }
  203. .more-btn {
  204. width: 77rpx;
  205. height: 46rpx;
  206. border-radius: 25rpx;
  207. border: 2rpx solid #3e7ef8;
  208. font-size: 24rpx;
  209. color: #3e7ef8;
  210. text-align: center;
  211. line-height: 42rpx;
  212. }
  213. }
  214. .week-wrap {
  215. display: flex;
  216. justify-content: space-between;
  217. .week-item {
  218. padding: 14rpx 26rpx;
  219. font-size: 28rpx;
  220. text-align: center;
  221. .week {
  222. color: #969696;
  223. margin-bottom: 14rpx;
  224. }
  225. .date {
  226. color: #323232;
  227. }
  228. .date2 {
  229. font-size: 20rpx;
  230. color: #646464;
  231. }
  232. .festival {
  233. color: #f84141;
  234. }
  235. }
  236. .isActived {
  237. background: #3e7ef8;
  238. border-radius: 38rpx;
  239. .week {
  240. color: #fff;
  241. }
  242. .date {
  243. color: #fff;
  244. }
  245. .date2 {
  246. color: #fff;
  247. }
  248. }
  249. }
  250. }
  251. .todo-wrap {
  252. .todo-item {
  253. padding: 12rpx 32rpx 12rpx 46rpx;
  254. background: #f2f3f5;
  255. border-radius: 15rpx;
  256. margin-bottom: 32rpx;
  257. .tit-txt {
  258. font-size: 28rpx;
  259. font-weight: bold;
  260. color: #323232;
  261. }
  262. .content-txt {
  263. font-size: 28rpx;
  264. color: #646464;
  265. }
  266. .header {
  267. .circle {
  268. width: 20rpx;
  269. height: 20rpx;
  270. border-radius: 50%;
  271. margin-right: 12rpx;
  272. }
  273. .green {
  274. background: #19be6b;
  275. }
  276. .date {
  277. font-size: 24rpx;
  278. color: #969696;
  279. }
  280. }
  281. .content {
  282. padding: 12rpx 0 24rpx 40rpx;
  283. font-size: 28rpx;
  284. color: #646464;
  285. }
  286. }
  287. }
  288. .fixed-btn {
  289. position: fixed;
  290. width: 90rpx;
  291. height: 90rpx;
  292. bottom: 50rpx;
  293. right: 50rpx;
  294. background: #3e7ef8;
  295. border-radius: 50%;
  296. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  297. }
  298. }
  299. </style>