|
@@ -1,157 +1,166 @@
|
|
|
<template >
|
|
|
- <div class="scheduling-table-body">
|
|
|
- <div class="weeb-body" v-for="(its, inx) in timeObjArr" :key="inx">
|
|
|
- <template v-for="(item, index) in its">
|
|
|
- <div
|
|
|
- class="task"
|
|
|
- :class="resultTime(keyValues(inx), item) ? 'disabled' : ''"
|
|
|
- v-if="intersectionDay(keyValues(inx), item, inx)"
|
|
|
- :key="index"
|
|
|
- >
|
|
|
- <div class="task-content">
|
|
|
- <div class="task-content-title">{{ item.routeName }}</div>
|
|
|
- <div class="task-content-time">{{ item.times }}</div>
|
|
|
- <div class="task-set" v-if="matchingTime(keyValues(inx), item).isActive">
|
|
|
- <span @click="resultTime(keyValues(inx), item) ? null : addItem(keyValues(inx), item)">
|
|
|
- {{ matchingTime(keyValues(inx), item).partolName }}</span
|
|
|
- >
|
|
|
- </div>
|
|
|
- <div class="task-set" v-else-if="!resultTime(keyValues(inx), item)">
|
|
|
- <span @click="addItem(keyValues(inx), item)">设置</span>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
+ <div class="scheduling-table-body">
|
|
|
+ <div
|
|
|
+ class="weeb-body"
|
|
|
+ v-for="(its, inx) in timeObjArr"
|
|
|
+ :key="inx"
|
|
|
+ >
|
|
|
+ <template v-for="(item, index) in its">
|
|
|
+ <div
|
|
|
+ class="task"
|
|
|
+ :class="resultTime(keyValues(inx), item) ? 'disabled' : ''"
|
|
|
+ v-if="intersectionDay(keyValues(inx), item, inx)"
|
|
|
+ :key="index"
|
|
|
+ >
|
|
|
+ <div class="task-content">
|
|
|
+ <div class="task-content-title">{{ item.routeName }}</div>
|
|
|
+ <div class="task-content-time">{{ item.times }}</div>
|
|
|
+ <div
|
|
|
+ class="task-set"
|
|
|
+ v-if="matchingTime(keyValues(inx), item).isActive"
|
|
|
+ >
|
|
|
+ <span @click="resultTime(keyValues(inx), item) ? null : addItem(keyValues(inx), item)">
|
|
|
+ {{ matchingTime(keyValues(inx), item).partolName }}</span>
|
|
|
+ </div>
|
|
|
+ <div
|
|
|
+ class="task-set"
|
|
|
+ v-else-if="!resultTime(keyValues(inx), item)"
|
|
|
+ >
|
|
|
+ <span @click="addItem(keyValues(inx), item)">设置</span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
+ </template>
|
|
|
</div>
|
|
|
+ </div>
|
|
|
</template>
|
|
|
<script>
|
|
|
export default {
|
|
|
- props: {
|
|
|
- timeObj: {
|
|
|
- type: Object,
|
|
|
- default: () => {
|
|
|
- return {
|
|
|
- monday: '',
|
|
|
- tuesday: '',
|
|
|
- wednesday: '',
|
|
|
- thursday: '',
|
|
|
- friday: '',
|
|
|
- saturday: '',
|
|
|
- sunday: ''
|
|
|
- };
|
|
|
- }
|
|
|
- },
|
|
|
- timeObjArr: {
|
|
|
- type: Array,
|
|
|
- default: () => {
|
|
|
- return [[], [], [], [], [], [], []];
|
|
|
- }
|
|
|
- },
|
|
|
- calendarData: {
|
|
|
- type: Array,
|
|
|
- default: () => []
|
|
|
- },
|
|
|
- findUser: {
|
|
|
- type: Array,
|
|
|
- default: () => []
|
|
|
- }
|
|
|
+ props: {
|
|
|
+ timeObj: {
|
|
|
+ type: Object,
|
|
|
+ default: () => {
|
|
|
+ return {
|
|
|
+ monday: '',
|
|
|
+ tuesday: '',
|
|
|
+ wednesday: '',
|
|
|
+ thursday: '',
|
|
|
+ friday: '',
|
|
|
+ saturday: '',
|
|
|
+ sunday: ''
|
|
|
+ };
|
|
|
+ }
|
|
|
},
|
|
|
- data() {
|
|
|
- return {};
|
|
|
+ timeObjArr: {
|
|
|
+ type: Array,
|
|
|
+ default: () => {
|
|
|
+ return [[], [], [], [], [], [], []];
|
|
|
+ }
|
|
|
},
|
|
|
- methods: {
|
|
|
- addItem(itemTime, item) {
|
|
|
- new Promise((resolve) => {
|
|
|
- this.$store.dispatch('addPopup', {
|
|
|
- url: '/patrolManagement/popups/weekEditAdd.vue',
|
|
|
- width: '450px',
|
|
|
- height: '300px',
|
|
|
- props: {
|
|
|
- callback: resolve,
|
|
|
- findUser: this.findUser,
|
|
|
- dateDe: itemTime,
|
|
|
- item: item
|
|
|
- },
|
|
|
- title: '排班'
|
|
|
- });
|
|
|
- }).then(() => {
|
|
|
- this.$emit('getList', {
|
|
|
- startTime: `${this.timeObj.monday} 00:00:00`,
|
|
|
- endTime: `${this.timeObj.sunday} 23:59:59`
|
|
|
- });
|
|
|
- });
|
|
|
- },
|
|
|
- //对比 现在时间 选择的时间至灰处理
|
|
|
- resultTime(tis, item) {
|
|
|
- let thisTime = this.$moment().format('YYYY-MM-DD') + ' 00:00:00';
|
|
|
- let itemTime = this.$moment(tis + ' 00:00:00').format('YYYY-MM-DD HH:mm:ss');
|
|
|
- return this.$moment(thisTime).valueOf() > this.$moment(itemTime).valueOf();
|
|
|
- },
|
|
|
- intersectionDay(tis, item, index) {
|
|
|
- let startDate = this.$moment(item.startDate).format('YYYY-MM-DD HH:mm:ss');
|
|
|
- let endDate = this.$moment(item.endDate).format('YYYY-MM-DD HH:mm:ss');
|
|
|
- let thisDate = this.$moment(tis + ' 00:00:00').format('YYYY-MM-DD HH:mm:ss');
|
|
|
- let vra = item.periodValue.split(',').sort();
|
|
|
- //每周几
|
|
|
- if (item.periodType == 1) {
|
|
|
- return (
|
|
|
- this.$moment(startDate).valueOf() <= this.$moment(thisDate).valueOf() &&
|
|
|
- this.$moment(thisDate).valueOf() <= this.$moment(endDate).valueOf() &&
|
|
|
- vra.includes(vra[index])
|
|
|
- );
|
|
|
- //每隔几天
|
|
|
- } else if (item.periodType == 2) {
|
|
|
- let oneDay = 86400000;
|
|
|
- // 第一天重合
|
|
|
- if (this.$moment(thisDate).valueOf() - this.$moment(startDate).valueOf() == 0 || item.periodValue == 0) {
|
|
|
- return true;
|
|
|
- } else {
|
|
|
- return (
|
|
|
- this.$moment(startDate).valueOf() <= this.$moment(thisDate).valueOf() &&
|
|
|
- this.$moment(thisDate).valueOf() <= this.$moment(endDate).valueOf() &&
|
|
|
- ((this.$moment(thisDate).valueOf() - this.$moment(startDate).valueOf()) / oneDay) %
|
|
|
- (Number(item.periodValue) + 1) ==
|
|
|
- 0
|
|
|
- );
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- // 对比已设置内容
|
|
|
- matchingTime(tis, item) {
|
|
|
- let objs = {
|
|
|
- isActive: false
|
|
|
- };
|
|
|
- this.calendarData.map((items) => {
|
|
|
- if (tis == items.partrolDate) {
|
|
|
- items.rosterUserDtos.map((isv) => {
|
|
|
- if (isv.id == item.id && isv.partrolTime == item.times) {
|
|
|
- objs.isActive = true;
|
|
|
- Object.assign(objs, isv);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- return objs;
|
|
|
- },
|
|
|
- keyValues(index) {
|
|
|
- if (index == 0) {
|
|
|
- return this.timeObj.monday;
|
|
|
- } else if (index == 1) {
|
|
|
- return this.timeObj.tuesday;
|
|
|
- } else if (index == 2) {
|
|
|
- return this.timeObj.wednesday;
|
|
|
- } else if (index == 3) {
|
|
|
- return this.timeObj.thursday;
|
|
|
- } else if (index == 4) {
|
|
|
- return this.timeObj.friday;
|
|
|
- } else if (index == 5) {
|
|
|
- return this.timeObj.saturday;
|
|
|
- } else if (index == 6) {
|
|
|
- return this.timeObj.sunday;
|
|
|
+ calendarData: {
|
|
|
+ type: Array,
|
|
|
+ default: () => []
|
|
|
+ },
|
|
|
+ findUser: {
|
|
|
+ type: Array,
|
|
|
+ default: () => []
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data () {
|
|
|
+ return {};
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ addItem (itemTime, item) {
|
|
|
+ new Promise((resolve) => {
|
|
|
+ this.$store.dispatch('addPopup', {
|
|
|
+ url: '/patrolManagement/popups/weekEditAdd.vue',
|
|
|
+ width: '450px',
|
|
|
+ height: '370px',
|
|
|
+ props: {
|
|
|
+ callback: resolve,
|
|
|
+ findUser: this.findUser,
|
|
|
+ dateDe: itemTime,
|
|
|
+ item: item
|
|
|
+ },
|
|
|
+ title: '排班'
|
|
|
+ });
|
|
|
+ }).then(() => {
|
|
|
+ this.$emit('getList', {
|
|
|
+ startTime: `${this.timeObj.monday} 00:00:00`,
|
|
|
+ endTime: `${this.timeObj.sunday} 23:59:59`
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ //对比 现在时间 选择的时间至灰处理
|
|
|
+ resultTime (tis, item) {
|
|
|
+ let thisTime = this.$moment().format('YYYY-MM-DD') + ' 00:00:00';
|
|
|
+ let itemTime = this.$moment(tis + ' 00:00:00').format('YYYY-MM-DD HH:mm:ss');
|
|
|
+ return this.$moment(thisTime).valueOf() > this.$moment(itemTime).valueOf();
|
|
|
+ },
|
|
|
+ intersectionDay (tis, item, index) {
|
|
|
+ let startDate = this.$moment(item.startDate).format('YYYY-MM-DD HH:mm:ss');
|
|
|
+ let endDate = this.$moment(item.endDate).format('YYYY-MM-DD HH:mm:ss');
|
|
|
+ let thisDate = this.$moment(tis + ' 00:00:00').format('YYYY-MM-DD HH:mm:ss');
|
|
|
+ let vra = item.periodValue.split(',').sort();
|
|
|
+ //每周几
|
|
|
+ if (item.periodType == 1) {
|
|
|
+ return (
|
|
|
+ this.$moment(startDate).valueOf() <= this.$moment(thisDate).valueOf() &&
|
|
|
+ this.$moment(thisDate).valueOf() <= this.$moment(endDate).valueOf() &&
|
|
|
+ vra.includes(vra[index])
|
|
|
+ );
|
|
|
+ //每隔几天
|
|
|
+ } else if (item.periodType == 2) {
|
|
|
+ let oneDay = 86400000;
|
|
|
+ // 第一天重合
|
|
|
+ if (this.$moment(thisDate).valueOf() - this.$moment(startDate).valueOf() == 0 || item.periodValue == 0) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return (
|
|
|
+ this.$moment(startDate).valueOf() <= this.$moment(thisDate).valueOf() &&
|
|
|
+ this.$moment(thisDate).valueOf() <= this.$moment(endDate).valueOf() &&
|
|
|
+ ((this.$moment(thisDate).valueOf() - this.$moment(startDate).valueOf()) / oneDay) %
|
|
|
+ (Number(item.periodValue) + 1) ==
|
|
|
+ 0
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 对比已设置内容
|
|
|
+ matchingTime (tis, item) {
|
|
|
+ let objs = {
|
|
|
+ isActive: false
|
|
|
+ };
|
|
|
+ this.calendarData.map((items) => {
|
|
|
+ if (tis == items.partrolDate) {
|
|
|
+ items.rosterUserDtos.map((isv) => {
|
|
|
+ if (isv.id == item.id && isv.partrolTime == item.times) {
|
|
|
+ objs.isActive = true;
|
|
|
+ Object.assign(objs, isv);
|
|
|
}
|
|
|
+ });
|
|
|
}
|
|
|
+ });
|
|
|
+ return objs;
|
|
|
+ },
|
|
|
+ keyValues (index) {
|
|
|
+ if (index == 0) {
|
|
|
+ return this.timeObj.monday;
|
|
|
+ } else if (index == 1) {
|
|
|
+ return this.timeObj.tuesday;
|
|
|
+ } else if (index == 2) {
|
|
|
+ return this.timeObj.wednesday;
|
|
|
+ } else if (index == 3) {
|
|
|
+ return this.timeObj.thursday;
|
|
|
+ } else if (index == 4) {
|
|
|
+ return this.timeObj.friday;
|
|
|
+ } else if (index == 5) {
|
|
|
+ return this.timeObj.saturday;
|
|
|
+ } else if (index == 6) {
|
|
|
+ return this.timeObj.sunday;
|
|
|
+ }
|
|
|
}
|
|
|
+ }
|
|
|
};
|
|
|
</script>
|
|
|
<style lang="scss" scoped>
|