manage.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  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. },
  132. // 获取周
  133. getWeek() {
  134. const dateOfToday = Date.now()
  135. const dayOfToday = (new Date().getDay() + 7 - 1) % 7
  136. const daysOfThisWeek = Array.from(new Array(7)).map((_, i) => {
  137. const date = new Date(dateOfToday + (i - dayOfToday) * 1000 * 60 * 60 * 24)
  138. return (
  139. date.getFullYear() +
  140. '-' +
  141. String(date.getMonth() + 1).padStart(2, '0') +
  142. '-' +
  143. String(date.getDate()).padStart(2, '0')
  144. )
  145. })
  146. // 当前周的全部日期
  147. this.calendarList = daysOfThisWeek
  148. // 当前日期
  149. this.currentDay = daysOfThisWeek[dayOfToday]
  150. },
  151. async getTodoData(date = null) {
  152. const params = { schDate: date || this.currentDay, dataType: '10', pageNum: 1, pageSize: 999 }
  153. const [err, res] = await to(scheduleApi.getList(params))
  154. if (err) return
  155. if (res && res.code == 200) {
  156. this.todoData = res.data.list
  157. }
  158. },
  159. // 选择日期
  160. selectDate(date) {
  161. this.currentDay = date
  162. this.getTodoData()
  163. },
  164. // 选择日历
  165. clickDate(date) {
  166. this.getTodoData(date)
  167. },
  168. // 跳转日历
  169. toMore() {
  170. this.calendarVisible = true
  171. },
  172. // 从日历返回
  173. back() {
  174. this.calendarVisible = false
  175. },
  176. },
  177. }
  178. </script>
  179. <style lang="scss" scoped>
  180. .manage-container {
  181. width: 100%;
  182. height: calc(100vh - 346rpx);
  183. overflow: auto;
  184. .calendar-container {
  185. padding-bottom: 56rpx;
  186. }
  187. .calendar-box {
  188. padding-top: 42rpx;
  189. .calendar-header {
  190. display: flex;
  191. justify-content: space-between;
  192. align-items: center;
  193. margin-bottom: 12rpx;
  194. .today {
  195. font-size: 32rpx;
  196. font-weight: bold;
  197. color: #323232;
  198. }
  199. .more-btn {
  200. width: 77rpx;
  201. height: 46rpx;
  202. border-radius: 25rpx;
  203. border: 2rpx solid #3e7ef8;
  204. font-size: 24rpx;
  205. color: #3e7ef8;
  206. text-align: center;
  207. line-height: 42rpx;
  208. }
  209. }
  210. .week-wrap {
  211. display: flex;
  212. justify-content: space-between;
  213. .week-item {
  214. padding: 14rpx 26rpx;
  215. font-size: 28rpx;
  216. text-align: center;
  217. .week {
  218. color: #969696;
  219. margin-bottom: 14rpx;
  220. }
  221. .date {
  222. color: #323232;
  223. }
  224. .date2 {
  225. font-size: 20rpx;
  226. color: #646464;
  227. }
  228. .festival {
  229. color: #f84141;
  230. }
  231. }
  232. .isActived {
  233. background: #3e7ef8;
  234. border-radius: 38rpx;
  235. .week {
  236. color: #fff;
  237. }
  238. .date {
  239. color: #fff;
  240. }
  241. .date2 {
  242. color: #fff;
  243. }
  244. }
  245. }
  246. }
  247. .todo-wrap {
  248. .todo-item {
  249. padding: 12rpx 32rpx 12rpx 46rpx;
  250. background: #f2f3f5;
  251. border-radius: 15rpx;
  252. margin-bottom: 32rpx;
  253. .tit-txt {
  254. font-size: 28rpx;
  255. font-weight: bold;
  256. color: #323232;
  257. }
  258. .content-txt {
  259. font-size: 28rpx;
  260. color: #646464;
  261. }
  262. .header {
  263. .circle {
  264. width: 20rpx;
  265. height: 20rpx;
  266. border-radius: 50%;
  267. margin-right: 12rpx;
  268. }
  269. .green {
  270. background: #19be6b;
  271. }
  272. .date {
  273. font-size: 24rpx;
  274. color: #969696;
  275. }
  276. }
  277. .content {
  278. padding: 12rpx 0 24rpx 40rpx;
  279. font-size: 28rpx;
  280. color: #646464;
  281. }
  282. }
  283. }
  284. .fixed-btn {
  285. position: fixed;
  286. width: 90rpx;
  287. height: 90rpx;
  288. bottom: 50rpx;
  289. right: 50rpx;
  290. background: #3e7ef8;
  291. border-radius: 50%;
  292. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  293. }
  294. }
  295. </style>