scheduling.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <template>
  2. <div class="scheduling">
  3. <div class="search">
  4. <el-date-picker
  5. v-model="monthValue"
  6. value-format="yyyy-MM-dd"
  7. type="month"
  8. placeholder="选择时间"
  9. :clearable="false"
  10. ></el-date-picker>
  11. <div class="search-icon">
  12. <el-tooltip effect="light" placement="bottom" content="批量排班">
  13. <i class="zoniot_font zoniot-icon-piliangshenhe" @click="add()"></i>
  14. </el-tooltip>
  15. <el-tooltip effect="light" placement="bottom" content="返回">
  16. <i class="zoniot_font zoniot-icon-fanhui" @click="goback()"></i>
  17. </el-tooltip>
  18. </div>
  19. </div>
  20. <el-calendar first-day-of-week="7" v-model="monthValue">
  21. <template
  22. slot="dateCell"
  23. slot-scope="{ date, data }"
  24. v-if="data.type === 'current-month'"
  25. >
  26. <div class="showDateDay">{{ date | dateNewType }}</div>
  27. <div class="schedulingUser">
  28. <template v-for="(item, index) in calendarData">
  29. <div
  30. :key="index"
  31. v-if="data.day == item.partrolDate"
  32. @click="add(data, item)"
  33. >
  34. <template v-for="itx in item.rosterUserDtos">
  35. <div :key="itx" class="listTime">
  36. <span>{{ itx.partrolTime }}</span>
  37. <span>{{ itx.partolName }}</span>
  38. </div>
  39. </template>
  40. </div>
  41. </template>
  42. <div
  43. class="pointSet"
  44. v-if="date.getTime()>=new Date(new Date().toLocaleDateString()).getTime()"
  45. @click="add(data)"
  46. >点击设置</div>
  47. </div>
  48. </template>
  49. </el-calendar>
  50. </div>
  51. </template>
  52. <script>
  53. export default {
  54. data() {
  55. return {
  56. monthValue: '',
  57. findUser: [],
  58. thisObj: {},
  59. calendarData: []
  60. };
  61. },
  62. filters: {
  63. dateNewType(val) {
  64. return val.getDate();
  65. }
  66. },
  67. watch: {
  68. monthValue(e) {
  69. try {
  70. let timeArr = e.split('-');
  71. let time = new Date(timeArr[0], Number(timeArr[1]), 0);
  72. this.getShiftInformation({
  73. patrolRouteId: this.thisObj.id,
  74. startTime: `${timeArr[0]}-${timeArr[1]}-01`,
  75. endTime: `${timeArr[0]}-${timeArr[1]}-${time.getDate()}`
  76. });
  77. } catch {}
  78. }
  79. },
  80. methods: {
  81. add(dateDe, onj) {
  82. let title = '排班',
  83. isSingle = true;
  84. if (dateDe == undefined && onj == undefined) {
  85. title = '批量排班';
  86. isSingle = false;
  87. }
  88. if (dateDe !== undefined && onj !== undefined) {
  89. new Date(dateDe).getTime() >= new Date(new Date().toLocaleDateString()).getTime();
  90. return;
  91. }
  92. new Promise(resolve => {
  93. this.$store.dispatch('addPopup', {
  94. url: '/patrolManagement/popups/schedulingAdd.vue',
  95. width: '450px',
  96. height: '300px',
  97. props: {
  98. callback: resolve,
  99. findUser: this.findUser,
  100. dateDe,
  101. onj,
  102. thisObj: this.thisObj,
  103. isSingle: isSingle
  104. },
  105. title: title
  106. });
  107. }).then(() => {
  108. let newTime = this.$moment(this.monthValue).format('YYYY-MM-DD');
  109. let timeArr = newTime.split('-');
  110. let time = new Date(timeArr[0], Number(timeArr[1]), 0);
  111. this.getShiftInformation({
  112. patrolRouteId: this.thisObj.id,
  113. startTime: `${timeArr[0]}-${timeArr[1]}-01`,
  114. endTime: `${timeArr[0]}-${timeArr[1]}-${time.getDate()}`
  115. });
  116. });
  117. },
  118. goback() {
  119. this.$emit('initPage');
  120. },
  121. initDate(type) {
  122. this.monthValue = this.$moment().format(type);
  123. },
  124. getShiftInformation(obj) {
  125. this.$http.post('/sc-community/patrolRoute/getShiftInformation', obj).then(({ data, status, msg }) => {
  126. if (!!data) {
  127. this.calendarData = [];
  128. for (let inx in data) {
  129. let rosterUserDtos = [];
  130. data[inx].map(item => {
  131. rosterUserDtos.push({
  132. partrolTime: item.patrolTime,
  133. partolName: item.partolName
  134. });
  135. });
  136. this.calendarData.push({
  137. partrolDate: this.$moment(inx).format('YYYY-MM-DD'),
  138. rosterUserDtos: rosterUserDtos
  139. });
  140. }
  141. }
  142. });
  143. }
  144. },
  145. created() {
  146. this.initDate('YYYY-MM-DD');
  147. },
  148. mounted() {
  149. this.findUser = this.$parent.findUser;
  150. this.thisObj = this.$parent.thisObj;
  151. this.$el.querySelector('div.el-calendar__header').remove();
  152. }
  153. };
  154. </script>
  155. <style scoped lang='scss'>
  156. .scheduling {
  157. font-size: 12px;
  158. .showDateDay {
  159. font-size: 30px;
  160. text-align: center;
  161. }
  162. .schedulingUser {
  163. cursor: pointer;
  164. padding: 0 20px;
  165. line-height: 25px;
  166. .listTime {
  167. width: 100%;
  168. display: flex;
  169. justify-content: space-between;
  170. }
  171. }
  172. .pointSet {
  173. cursor: pointer;
  174. line-height: 35px;
  175. text-align: center;
  176. }
  177. /deep/ .el-calendar-table {
  178. &:not(.is-range) {
  179. td.next {
  180. pointer-events: none;
  181. }
  182. td.prev {
  183. pointer-events: none;
  184. }
  185. td.current {
  186. // pointer-events: none;
  187. }
  188. }
  189. .el-calendar-day {
  190. height: 110px;
  191. overflow: hidden;
  192. }
  193. }
  194. }
  195. </style>