index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <div class="app-container app-calendar-container">
  3. <div>
  4. <el-button type="primary" @click="handlePerFormList('ADD')">排期配置</el-button>
  5. </div>
  6. <div v-loading="loading">
  7. <el-calendar v-model="timeValue" v-if="showCalendar">
  8. <template
  9. slot="dateCell"
  10. slot-scope="{date, data}">
  11. <div @click.stop="selectTime(data.day)">
  12. <span>{{ data.day.split('-').slice(1).join('-') }}</span>
  13. <div style="width: 100%; display: flex;flex-wrap: wrap;" >
  14. <div
  15. :key="index"
  16. :style="{marginLeft: index%2 == 0?'':'20px',color: item.status == 1 ?'#67c23a':'#909399'}"
  17. v-for="(item,index) in getPerFormList(data)"
  18. @click.stop="handlePerFormDeatils(item)"
  19. >
  20. {{ item.performTimeStart }}-{{ item.performTimeEnd }}
  21. </div>
  22. </div>
  23. </div>
  24. </template>
  25. </el-calendar>
  26. <!-- <calendarBox /> -->
  27. </div>
  28. <!-- 排期详情 -->
  29. <perFormDeatils ref="perFormDeatils" @getList="getList" />
  30. <!-- 排期列表 -->
  31. <perFormListBox ref="perFormListBox" @getList="getList" />
  32. </div>
  33. </template>
  34. <script>
  35. import { calendarList } from '@/api/ticketMr/schedulingConfiguration'
  36. import moment from "moment"
  37. import calendarBox from './dialog/calendarBox.vue';
  38. import perFormDeatils from './dialog/perFormDeatils.vue';
  39. import perFormListBox from './dialog/perFormListBox.vue';
  40. export default {
  41. name: "SchedulingConfiguration",
  42. dicts: [],
  43. components: { calendarBox,perFormDeatils,perFormListBox },
  44. data() {
  45. return {
  46. // 遮罩层
  47. loading: true,
  48. // 弹出层标题
  49. title: "",
  50. // 查询参数
  51. queryParams: {
  52. startDate: null,
  53. endDate: null,
  54. },
  55. timeValue: new Date(),
  56. perFormList: [],
  57. showCalendar: false,
  58. };
  59. },
  60. created() {
  61. this.showCalendar = false
  62. this.queryParams = {
  63. startDate: moment(this.timeValue).startOf('month').format("YYYY-MM-DD"),
  64. endDate: moment(this.timeValue).endOf('month').format("YYYY-MM-DD"),
  65. }
  66. this.getList();
  67. },
  68. methods: {
  69. /** 查询列表 */
  70. getList() {
  71. this.loading = true;
  72. let params = JSON.parse(JSON.stringify(this.queryParams))
  73. calendarList(this.addDateRange({...params}, this.dateRange))
  74. .then(response => {
  75. console.log(response)
  76. this.perFormList = response.data.rows
  77. this.showCalendar = true
  78. this.loading = false;
  79. }
  80. ).catch(() => {
  81. this.loading = false;
  82. });
  83. },
  84. getPerFormList(data) {
  85. let list = []
  86. this.perFormList.forEach((item,index)=>{
  87. if(item.performDate == data.day) {
  88. console.log("dsfsdfdsfdsf")
  89. list = item.list
  90. }
  91. })
  92. return list
  93. },
  94. selectTime(value){
  95. console.log("value====",value)
  96. // this.queryParams = {
  97. // startDate: moment(value).startOf('month').format("YYYY-MM-DD"),
  98. // endDate: moment(value).endOf('month').format("YYYY-MM-DD"),
  99. // }
  100. // this.getList();
  101. },
  102. /** 修改按钮操作 */
  103. handleUpdate(row) {
  104. this.$refs["addAndEdit"].openDialog("修改数据", row);
  105. },
  106. /** 排期详情 */
  107. handlePerFormDeatils(row) {
  108. this.$refs["perFormDeatils"].openDialog("排期详情", row);
  109. },
  110. /** 排期列表 */
  111. handlePerFormList() {
  112. this.$refs["perFormListBox"].openDialog("排期详情", null);
  113. },
  114. // 获取日历显示时间范围
  115. getRange(date){
  116. // 日历第一天
  117. let firstDay = '';
  118. // 日历最后一天
  119. let lastDay = '';
  120. // 今天
  121. const today = date ? date : new Date()
  122. // 上月
  123. const m = today.getMonth()
  124. // 本月
  125. const cm = m + 1
  126. // 下月
  127. const lm = m + 2 > 12 ? 1 : m + 2
  128. // 要显示的本月
  129. const currentMonth = cm < 10 ? '0' + cm : cm
  130. // 要显示的本本年
  131. const currentYear = today.getFullYear()
  132. // 要显示的上个月的年份,m = 0 则当前1月,上月则是去年12月
  133. const prevYear = m == 0 ? currentYear - 1 : currentYear
  134. const prevMonth = m == 0 ? 12 : m < 10 ? '0' + m : m
  135. // 上个月天数
  136. const pmd = new Date(prevYear, m, 0).getDate()
  137. // 下个月的年份,当前12月,则需要加一年
  138. const lastYear = cm + 1 > 12 ? currentYear + 1 : currentYear
  139. const lastMonth = lm < 10 ? '0' + lm : lm
  140. // 1号是周几
  141. const firstWeek = new Date(today.setDate(1)).getDay()
  142. // 如果是周日,则不需要显示上个月
  143. if (firstWeek == 0) {
  144. firstDay = `${currentYear}-${currentMonth}-01`
  145. }
  146. // 其他周几,对应用上个月的天数往前推算
  147. else {
  148. firstDay = `${prevYear}-${prevMonth}-${pmd - (firstWeek - 1)}`
  149. }
  150. // 这个月天数
  151. const currentMonthDate = new Date(currentYear, cm, 0).getDate()
  152. // 最后一天是周几
  153. const lastWeek = new Date(today.setDate(currentMonthDate)).getDay()
  154. // 周六显示当月最后一天
  155. if (lastWeek == 6) {
  156. lastDay = `${currentYear}-${currentMonth}-${currentMonthDate}`
  157. }
  158. // 其他周几,对应往后推算
  159. else {
  160. const day = ['06', '05', '04', '03', '02', '01']
  161. lastDay = `${lastYear}-${lastMonth}-${day[lastWeek]}`
  162. }
  163. console.log('第一天', firstDay)
  164. console.log('最后一天', lastDay)
  165. this.queryParams = {
  166. startDate: firstDay,
  167. endDate: lastDay,
  168. }
  169. this.getList();
  170. }
  171. },
  172. watch:{
  173. timeValue(newValue,oldValue){
  174. let time = moment(newValue).format("YYYY-DD-MM")
  175. if (newValue.getFullYear() !== oldValue.getFullYear() || newValue.getMonth() !== oldValue.getMonth()) {
  176. this.getRange(newValue)
  177. }
  178. }
  179. }
  180. };
  181. </script>
  182. <style scoped lang="scss">
  183. .is-selected {
  184. color: #1989FA;
  185. }
  186. .app-calendar-container ::v-deep .el-calendar-table .el-calendar-day {
  187. height: auto;
  188. min-height: 86px;
  189. }
  190. </style>