index.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <template>
  2. <view class="schedule-v">
  3. <view class="calendar-v">
  4. <calendar :lunar="true" :selected="selected" :showMonth="true" @change="change" @initdate="initdate"
  5. :key='key' />
  6. </view>
  7. <view class="u-p-20 block">
  8. <view class="block-a u-font-24">
  9. {{dateDay}}
  10. <div>{{changedate}}</div>
  11. </view>
  12. <view class="u-m-b-20 list-box">
  13. <view v-for="(item,index) in scheduleList" :key="index" class="list">
  14. <view class="u-m-t-20 u-flex item" @click="goDetail(item.id,item.creatorUserId)">
  15. <text class="u-font-28">{{item.allDay?'全天':item.startTime}}</text>
  16. <view class="u-flex-col u-m-l-20 u-p-l-20 content u-font-28">
  17. <view>{{item.title}}</view>
  18. <view class="u-font-24">{{item.content}}</view>
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. <view :class="scheduleList.length<3?'lunar1':'addlunar'">
  24. <view @click="goDetail()" class="add-title">+添加日程内容</view>
  25. </view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. import calendar from './calendar/uni-calendar.vue'
  31. import {
  32. List
  33. } from '@/api/workFlow/schedule.js'
  34. export default {
  35. components: {
  36. direction: 'col',
  37. calendar,
  38. },
  39. props: {
  40. config: {
  41. type: Object,
  42. default: () => {}
  43. }
  44. },
  45. data() {
  46. return {
  47. selected: [],
  48. showForm: false,
  49. horizontal: 'right',
  50. vertical: 'bottom',
  51. direction: 'horizontal',
  52. pattern: {
  53. color: '#7A7E83',
  54. backgroundColor: '#fff',
  55. selectedColor: '#007AFF',
  56. buttonColor: "#007AFF"
  57. },
  58. changedate: '',
  59. scheduleList: [],
  60. exhibitionList: [],
  61. startDate: '',
  62. endDate: '',
  63. dateDay: '',
  64. query: {},
  65. options: [{
  66. text: '删除',
  67. style: {
  68. backgroundColor: '#dd524d'
  69. }
  70. }],
  71. startTime: "",
  72. formVisible: false,
  73. userInfo: {},
  74. key: +new Date(),
  75. toDay: '',
  76. sysConfigInfo: {}
  77. }
  78. },
  79. onLoad() {
  80. this.userInfo = uni.getStorageSync('userInfo') || {}
  81. this.sysConfigInfo = uni.getStorageSync('sysConfigInfo') || {}
  82. },
  83. onShow() {
  84. uni.$on('refresh', () => {
  85. this.key = +new Date()
  86. });
  87. },
  88. onUnload() {
  89. uni.$off('refresh')
  90. },
  91. methods: {
  92. /* 初始化请求 */
  93. initdate(cale, nowDate) {
  94. let canlender = cale.canlender;
  95. let weeks = cale.weeks;
  96. for (let i = 0; i < canlender.length; i++) {
  97. if (canlender[i].fullDate === nowDate.fullDate) {
  98. let day = this.toChinaDay(nowDate.lunar.nWeek)
  99. this.toDay = nowDate.fullDate
  100. this.dateTime = nowDate.fullDate
  101. this.dateDay = nowDate.month + '月' + nowDate.date + '日' + " 周" + day +
  102. " (今天)"
  103. this.changedate = ''
  104. if (this.sysConfigInfo.showLunarCalendar) this.changedate = '农历 ' + canlender[i].lunar.IMonthCn +
  105. canlender[i].lunar.IDayCn;
  106. break;
  107. }
  108. }
  109. let data = {
  110. weeks: weeks,
  111. canlender: canlender
  112. }
  113. this.$nextTick(() => {
  114. this.handleScheduleList(data)
  115. })
  116. },
  117. handleScheduleList(data) {
  118. let canlender = data.canlender
  119. let startTime = this.startDate = canlender[0].lunar.cYear + '-' + canlender[0].lunar.cMonth + '-' +
  120. canlender[0].lunar
  121. .cDay;
  122. let endTime = this.endDate = canlender[canlender.length - 1].lunar.cYear + '-' + canlender[canlender
  123. .length - 1].lunar
  124. .cMonth + '-' + canlender[canlender.length - 1].lunar.cDay;
  125. let query = {
  126. startTime: startTime,
  127. endTime: endTime,
  128. dateTime: data.fulldate || this.toDay
  129. }
  130. List(query).then(res => {
  131. let signList = res.data.signList;
  132. if (res.data.todayList) {
  133. this.scheduleList = res.data.todayList.map(o => ({
  134. ...o,
  135. show: false
  136. }));
  137. }
  138. let selected = []
  139. for (let [key, value] of Object.entries(signList)) {
  140. const cYear = key.slice(0, 4)
  141. const cMonth = key.slice(4, 6)
  142. const cDay = key.slice(6, 8)
  143. let date = cYear + '-' + cMonth + '-' + cDay
  144. if (value && value != 0) {
  145. selected.push({
  146. date,
  147. info: ''
  148. })
  149. }
  150. }
  151. this.selected = selected
  152. })
  153. },
  154. change(e) {
  155. let weeks = e.cale.weeks;
  156. let canlender = e.cale.canlender;
  157. let lunar = e.lunar;
  158. lunar.cMonth = lunar.cMonth < 10 ? '0' + Number(lunar.cMonth) : lunar.cMonth
  159. lunar.cDay = lunar.cDay < 10 ? '0' + Number(lunar.cDay) : lunar.cDay
  160. let allDay = lunar.lYear + '-' + lunar.cMonth + '-' + lunar.cDay
  161. let srt = this.time(e.fulldate)
  162. let day = this.toChinaDay(lunar.nWeek)
  163. this.startTime = new Date(e.fulldate).getTime()
  164. this.dateDay = lunar.cMonth + '月' + lunar.cDay + '日' + " 周" + day +
  165. srt
  166. this.changedate = ''
  167. if (this.sysConfigInfo.showLunarCalendar) this.changedate = '农历 ' + lunar.IMonthCn + lunar.IDayCn;
  168. let data = {
  169. weeks: weeks,
  170. canlender: canlender,
  171. lunar: lunar,
  172. fulldate: e.fulldate
  173. }
  174. this.handleScheduleList(data)
  175. },
  176. goDetail(id = '', creatorUserId) {
  177. let type = this.userInfo.userId == creatorUserId ? true : false
  178. let url = id ? `/pages/workFlow/schedule/detail?id=${id}&type=${type}` :
  179. `/pages/workFlow/schedule/form?id=${id}&startTime=${this.startTime}&duration=${this.sysConfigInfo.duration}`
  180. uni.navigateTo({
  181. url
  182. })
  183. },
  184. open(index) {
  185. this.scheduleList[index].show = true;
  186. this.scheduleList.map((val, idx) => {
  187. if (index != idx) this.scheduleList[idx].show = false;
  188. })
  189. },
  190. toChinaDay(d) {
  191. if (d == 1) return '一'
  192. if (d == 2) return '二'
  193. if (d == 3) return '三'
  194. if (d == 4) return '四'
  195. if (d == 5) return '五'
  196. if (d == 6) return '六'
  197. if (d == 7) return '日'
  198. },
  199. time(date) {
  200. let time = new Date()
  201. if (new Date(date).getFullYear() == time.getFullYear() && new Date(date).getMonth() == time.getMonth()) {
  202. let time_str = "";
  203. if (new Date(date).getDate() === new Date().getDate()) {
  204. time_str = " (今天)";
  205. } else if (new Date(date).getDate() === (new Date().getDate() - 1)) {
  206. time_str = " (昨天)";
  207. } else if (new Date(date).getDate() === (new Date().getDate() + 1)) {
  208. time_str = " (明天)";
  209. } else if (new Date(date).getDate() < new Date().getDate()) {
  210. time_str = "";
  211. }
  212. return time_str;
  213. }
  214. return ''
  215. }
  216. }
  217. }
  218. </script>
  219. <style lang="scss">
  220. page {
  221. background-color: #f0f2f6;
  222. }
  223. .schedule-v {
  224. width: 100%;
  225. .block {
  226. .block-a {
  227. background-color: #fff;
  228. padding: 20rpx 30rpx;
  229. }
  230. .list-box {
  231. .list {
  232. .item {
  233. width: 100%;
  234. background-color: #fff;
  235. height: 120rpx;
  236. align-items: center;
  237. padding: 0 20rpx;
  238. .content {
  239. flex: 1;
  240. border-left: 4rpx solid #2A7DFD;
  241. justify-content: center;
  242. height: 80rpx;
  243. }
  244. }
  245. }
  246. }
  247. .lunar1 {
  248. height: 124rpx;
  249. line-height: 124rpx;
  250. background-color: #fff;
  251. }
  252. .addlunar {
  253. height: 124rpx;
  254. line-height: 124rpx;
  255. border-top: 1rpx solid rgb(228, 231, 237);
  256. }
  257. .add-title {
  258. margin-left: 20rpx;
  259. font-size: 24rpx;
  260. color: #C0C0C0;
  261. }
  262. }
  263. .uni-calendar-item__weeks-box-item {
  264. height: 3.23rem;
  265. }
  266. }
  267. </style>