提交 6f01af85 编写于 作者: zhongyao.qiao's avatar zhongyao.qiao

feat 问诊排版时间调整

上级 dd6155e3
...@@ -17,4 +17,4 @@ VUE_APP_IS_LOCAL=true ...@@ -17,4 +17,4 @@ VUE_APP_IS_LOCAL=true
VUE_APP_APPID=wxf4e66242d31c81c2 VUE_APP_APPID=wxf4e66242d31c81c2
#本地token #本地token
VUE_APP_TOKEN=D321743AA7464709A42053132F5D2F8D VUE_APP_TOKEN=B638EE700AD348B8B432E7DF53A48E87
...@@ -2,7 +2,7 @@ module.exports = { ...@@ -2,7 +2,7 @@ module.exports = {
root: true, root: true,
parserOptions: { parserOptions: {
parser: 'babel-eslint', parser: 'babel-eslint',
sourceType: 'module' sourceType: 'module',
}, },
env: { env: {
browser: true, browser: true,
...@@ -12,76 +12,98 @@ module.exports = { ...@@ -12,76 +12,98 @@ module.exports = {
extends: ['plugin:vue/recommended', 'eslint:recommended'], extends: ['plugin:vue/recommended', 'eslint:recommended'],
// 全局变量 // 全局变量
globals: { globals: {
'gdp': true, gdp: true,
}, },
// add your custom rules here // add your custom rules here
//it is base on https://github.com/vuejs/eslint-config-vue //it is base on https://github.com/vuejs/eslint-config-vue
rules: { rules: {
'no-console': 0, 'no-console': 0,
'no-debugger': 0, 'no-debugger': 0,
'comma-spacing': [2, { // 控制逗号前面没有空格,后面必须有空格 'comma-spacing': [
'before': false, 2,
'after': true {
}], // 控制逗号前面没有空格,后面必须有空格
'arrow-spacing': [2, { // 要求箭头函数前后有空格 before: false,
'before': true, after: true,
'after': true },
}], ],
'no-multi-spaces': 2,// 禁止使用多个空格, 'arrow-spacing': [
'no-spaced-func': 2,// 禁止 function 标识符和括号之间出现空格,this.getList () 报错 2,
'semi-spacing': [2, {// 强制分号之前不允许有空格 {
'before': false, // 要求箭头函数前后有空格
'after': true before: true,
}], after: true,
'space-infix-ops': 2,// 要求操作符前后必须有空格: 2 + 3 2 === 2 3 > 2 },
],
'no-multi-spaces': 2, // 禁止使用多个空格,
'no-spaced-func': 2, // 禁止 function 标识符和括号之间出现空格,this.getList () 报错
'semi-spacing': [
2,
{
// 强制分号之前不允许有空格
before: false,
after: true,
},
],
'space-infix-ops': 2, // 要求操作符前后必须有空格: 2 + 3 2 === 2 3 > 2
'spaced-comment': [2, 'always'], // 强制在注释中 // 或 /* 使用一致的空格 'spaced-comment': [2, 'always'], // 强制在注释中 // 或 /* 使用一致的空格
'array-bracket-spacing': [2, 'never'],// 指定数组的元素之间要以空格隔开(, 后面), never参数:[ 之后和 ] 之前不能带空格,always参数:[ 之后和 ] 之前必须带空格 'array-bracket-spacing': [2, 'never'], // 指定数组的元素之间要以空格隔开(, 后面), never参数:[ 之后和 ] 之前不能带空格,always参数:[ 之后和 ] 之前必须带空格
"space-before-blocks": 2, // if/function等的大括号之前需要有空格 'space-before-blocks': 2, // if/function等的大括号之前需要有空格
"vue/script-indent": 'off', 'vue/script-indent': 'off',
'no-undef-init': 2,// 禁止将变量初始化为 undefined,保存时会将let a = undefined变成let a 'no-undef-init': 2, // 禁止将变量初始化为 undefined,保存时会将let a = undefined变成let a
'semi': [2, 'always'],//强制结尾必须有分号; semi: [2, 'always'], //强制结尾必须有分号;
'prefer-const': 2,// 要求使用 const 声明那些声明后不再被修改的变量 'prefer-const': 2, // 要求使用 const 声明那些声明后不再被修改的变量
'quotes': [2, 'single'],//js中强制使用单引号 quotes: [2, 'single'], //js中强制使用单引号
'no-multiple-empty-lines': [2, {// 不允许多个空行,最多一行 'no-multiple-empty-lines': [
'max': 1 2,
}], {
'vue/order-in-components': ['error', { // 不允许多个空行,最多一行
'order': [ max: 1,
'el', },
'name', ],
'parent', 'vue/order-in-components': [
'functional', 'error',
['delimiters', 'comments'], {
['components', 'directives', 'filters'], order: [
'extends', 'el',
'mixins', 'name',
'inheritAttrs', 'parent',
'model', 'functional',
['props', 'propsData'], ['delimiters', 'comments'],
'data', ['components', 'directives', 'filters'],
'computed', 'extends',
'watch', 'mixins',
'LIFECYCLE_HOOKS', 'inheritAttrs',
'methods', 'model',
['template', 'render'], ['props', 'propsData'],
'renderError' 'data',
] 'computed',
}], 'watch',
'vue/attributes-order': ['error', { 'LIFECYCLE_HOOKS',
'order': [ 'methods',
'DEFINITION', ['template', 'render'],
'LIST_RENDERING', 'renderError',
'CONDITIONALS', ],
'RENDER_MODIFIERS', },
'GLOBAL', ],
'UNIQUE', 'vue/attributes-order': [
'TWO_WAY_BINDING', 'error',
'OTHER_DIRECTIVES', {
'OTHER_ATTR', order: [
'EVENTS', 'DEFINITION',
'CONTENT' 'LIST_RENDERING',
] 'CONDITIONALS',
}], 'RENDER_MODIFIERS',
} 'GLOBAL',
} 'UNIQUE',
'TWO_WAY_BINDING',
'OTHER_DIRECTIVES',
'OTHER_ATTR',
'EVENTS',
'CONTENT',
],
},
],
},
};
...@@ -146,137 +146,137 @@ ...@@ -146,137 +146,137 @@
</div> </div>
</template> </template>
<script> <script>
import dayjs from 'dayjs'; import FullCalendar from '@fullcalendar/vue';
import FullCalendar from '@fullcalendar/vue'; import dayGridPlugin from '@fullcalendar/daygrid';
import dayGridPlugin from '@fullcalendar/daygrid'; import interactionPlugin from '@fullcalendar/interaction';
import timeGridPlugin from '@fullcalendar/timegrid'; import timeGridPlugin from '@fullcalendar/timegrid';
import interactionPlugin from '@fullcalendar/interaction'; import {
import { dutyRosterQuery,
dutyRosterQuery, getDoctorInfo,
saveDutyRoster, getLevel,
getLevel, getLevelAndDayCount,
getDoctorInfo, saveDutyRoster,
saveLevelAndDayCount, saveLevelAndDayCount,
getLevelAndDayCount, } from '@/api/serviceSchedule';
} from '@/api/serviceSchedule'; import dayjs from 'dayjs';
export default { export default {
name: 'Scheduing', name: 'Scheduing',
components: { components: {
FullCalendar, FullCalendar,
}, },
data() { data() {
return { return {
maxPreNum: '', maxPreNum: '',
chooseList: true, chooseList: true,
id: '', id: '',
doctorId: '', doctorId: '',
schedulingTypeValue: {}, schedulingTypeValue: {},
schedulingType: 1, // 1 新增 2 编辑 3 查看 schedulingType: 1, // 1 新增 2 编辑 3 查看
createList: [], createList: [],
listDate: [], listDate: [],
week: 1, // 1:当前周 2:上一周 3:下一周 week: 1, // 1:当前周 2:上一周 3:下一周
currentIndex: 3, currentIndex: 3,
haveWeek: [1], haveWeek: [1],
businessHours: true, businessHours: true,
calendarOptions: { calendarOptions: {
// 引入的插件,比如fullcalendar/daygrid,fullcalendar/timegrid引入后才可显示月,周,日 // 引入的插件,比如fullcalendar/daygrid,fullcalendar/timegrid引入后才可显示月,周,日
plugins: [dayGridPlugin, interactionPlugin, timeGridPlugin], plugins: [dayGridPlugin, interactionPlugin, timeGridPlugin],
initialView: 'timeGridWeek', // 默认为那个视图(月:dayGridMonth,周:timeGridWeek,日:timeGridDay) initialView: 'timeGridWeek', // 默认为那个视图(月:dayGridMonth,周:timeGridWeek,日:timeGridDay)
selectable: true, selectable: true,
selectMirror: true, selectMirror: true,
selectAllow: this.selectAllow, selectAllow: this.selectAllow,
selectOverlap: false, selectOverlap: false,
select: this.selectInfo, select: this.selectInfo,
selectMinDistance: 0, selectMinDistance: 0,
eventOverlap: false, eventOverlap: false,
navLinks: true, navLinks: true,
navLinkDayClick: this.navLinkDayClick, navLinkDayClick: this.navLinkDayClick,
// eventDurationEditable:false, // eventDurationEditable:false,
eventDrop: this.eventDrop, eventDrop: this.eventDrop,
editable: true, editable: true,
overlap: false, overlap: false,
defaultDate: new Date(), defaultDate: new Date(),
datesSet: this.handleDatesSet, datesSet: this.handleDatesSet,
events: [], events: [],
slotEventOverlap: true, slotEventOverlap: true,
header: { header: {
center: 'month,agendaFourDay', // buttons for switching between views center: 'month,agendaFourDay', // buttons for switching between views
}, },
firstDay: 1, // 设置一周中显示的第一天是哪天,周日是0,周一是1,类推 firstDay: 1, // 设置一周中显示的第一天是哪天,周日是0,周一是1,类推
locale: 'zh-cn', // 切换语言,当前为中文 locale: 'zh-cn', // 切换语言,当前为中文
eventColor: '#fff', // 全部日历日程背景色3BB2E3 eventColor: '#fff', // 全部日历日程背景色3BB2E3
eventBackgroundColor: '#E7F4F5', eventBackgroundColor: '#E7F4F5',
// themeSystem: 'bootstrap', // 主题色(本地测试未能生效) // themeSystem: 'bootstrap', // 主题色(本地测试未能生效)
// initialDate: moment().format('YYYY-MM-DD'), // 自定义设置背景颜色时一定要初始化日期时间 // initialDate: moment().format('YYYY-MM-DD'), // 自定义设置背景颜色时一定要初始化日期时间
timeGridEventMinHeight: '40', // 设置事件的最小高度 timeGridEventMinHeight: '40', // 设置事件的最小高度
aspectRatio: 1.35, // 设置日历单元格宽度与高度的比例。 aspectRatio: 1.35, // 设置日历单元格宽度与高度的比例。
// displayEventTime: false, // 是否显示时间 // displayEventTime: false, // 是否显示时间
allDaySlot: false, // 周,日视图时,all-day 不显示 allDaySlot: false, // 周,日视图时,all-day 不显示
eventLimit: true, // 设置月日程,与all-day slot的最大显示数量,超过的通过弹窗显示 eventLimit: true, // 设置月日程,与all-day slot的最大显示数量,超过的通过弹窗显示
customButtons: { customButtons: {
myCustomButton: { myCustomButton: {
text: '本周', text: '本周',
},
},
headerToolbar: {
// 日历头部按钮位置
left: '',
center: 'prev myCustomButton next',
right: '',
}, },
expandRows: true, },
slotMinWidth: 50, headerToolbar: {
slotDuration: '01:00:00', // 日历头部按钮位置
slotMinTime: '09:00', left: '',
slotMaxTime: '21:00', center: 'prev myCustomButton next',
slotLabelInterval: '', right: '',
scrollTime: false, },
slotLabelFormat: { expandRows: true,
hour: 'numeric', slotMinWidth: 50,
minute: '2-digit', slotDuration: '01:00:00',
meridiem: 'short', slotMinTime: '06:00',
hour12: false, // 设置时间为24小时 slotMaxTime: '23:00',
slotLabelInterval: '',
scrollTime: false,
slotLabelFormat: {
hour: 'numeric',
minute: '2-digit',
meridiem: 'short',
hour12: false, // 设置时间为24小时
},
eventLimitNum: {
// 事件显示数量限制(本地测试未能生效)
dayGrid: {
eventLimit: 5,
}, },
eventLimitNum: { timeGrid: {
// 事件显示数量限制(本地测试未能生效) eventLimit: 4, // adjust to 6 only for timeGridWeek/timeGridDay
dayGrid: {
eventLimit: 5,
},
timeGrid: {
eventLimit: 4, // adjust to 6 only for timeGridWeek/timeGridDay
},
}, },
eventClick: this.handleEventClick,
}, },
workingTicketVisible: false, // 工作表票详情页面 eventClick: this.handleEventClick,
scrollerHeight: 0,
loading: false,
isDoIt: false,
getStartWeek: '',
copyArr: [],
centerDialogVisible: false,
maxNumValue: '',
showFirNum: '',
showMaxNum: '',
};
},
computed: {},
watch: {
week(newV, oldV) {
if (this.haveWeek.indexOf(newV) == -1) {
this.haveWeek.push(newV);
this.handleInitSearch();
}
if (newV !== oldV) {
this.handleInitSearch();
this.saveDoctoreScheduling(2, oldV);
}
}, },
workingTicketVisible: false, // 工作表票详情页面
scrollerHeight: 0,
loading: false,
isDoIt: false,
getStartWeek: '',
copyArr: [],
centerDialogVisible: false,
maxNumValue: '',
showFirNum: '',
showMaxNum: '',
};
},
computed: {},
watch: {
week(newV, oldV) {
if (this.haveWeek.indexOf(newV) == -1) {
this.haveWeek.push(newV);
this.handleInitSearch();
}
if (newV !== oldV) {
this.handleInitSearch();
this.saveDoctoreScheduling(2, oldV);
}
}, },
created() { },
this.schedulingType = this.$route.query.type || 1; created() {
this.id = this.$route.query.id; this.schedulingType = this.$route.query.type || 1;
(this.doctorId = this.$route.query.doctorId), this.id = this.$route.query.id;
(this.doctorId = this.$route.query.doctorId),
getDoctorInfo({ id: this.id }).then((res) => { getDoctorInfo({ id: this.id }).then((res) => {
if (res.code == '000000') { if (res.code == '000000') {
this.schedulingTypeValue = res.data; this.schedulingTypeValue = res.data;
...@@ -285,412 +285,409 @@ ...@@ -285,412 +285,409 @@
this.$toast(res.message); this.$toast(res.message);
} }
}); });
getLevel().then((res) => { getLevel().then((res) => {
if (res.code == '000000') { if (res.code == '000000') {
this.createList = res.data; this.createList = res.data;
} }
}); });
}, },
mounted() { mounted() {
this.scrollerHeight = this.$refs.agment.clientHeight + 'px'; this.scrollerHeight = this.$refs.agment.clientHeight + 'px';
this.init(); this.init();
},
methods: {
/**
* 点击日历日程事件
*
* info: 事件信息
* event是日程(事件)对象
* jsEvent是个javascript事件
* view是当前视图对象。
*/
init() {
// schedulingType 1,2 表示编辑新加,其他表示查看
if (this.schedulingType == 1 || this.schedulingType == 2) {
this.calendarOptions.editable = true;
} else {
// 查看
this.calendarOptions.slotDuration = '01:00:00';
this.calendarOptions.selectable = false;
this.calendarOptions.editable = false;
}
this.handleInitSearch();
this.getLevelAndDayCount();
}, },
methods: { getLevelAndDayCount(newV) {
/** const params = {
* 点击日历日程事件 workId: newV ? newV : this.id,
* };
* info: 事件信息 getLevelAndDayCount(params).then((res) => {
* event是日程(事件)对象 if (res.code === '000000') {
* jsEvent是个javascript事件 console.log(res, 'res');
* view是当前视图对象。 this.currentIndex = res.data.level;
*/ this.maxNumValue = res.data.preNum;
init() { (this.showFirNum = res.data.level),
// schedulingType 1,2 表示编辑新加,其他表示查看
if (this.schedulingType == 1 || this.schedulingType == 2) {
this.calendarOptions.editable = true;
} else {
// 查看
this.calendarOptions.slotDuration = '01:00:00';
this.calendarOptions.selectable = false;
this.calendarOptions.editable = false;
}
this.handleInitSearch();
this.getLevelAndDayCount();
},
getLevelAndDayCount(newV) {
const params = {
workId: newV ? newV : this.id,
};
getLevelAndDayCount(params).then((res) => {
if (res.code === '000000') {
console.log(res, 'res');
this.currentIndex = res.data.level;
this.maxNumValue = res.data.preNum;
(this.showFirNum = res.data.level),
(this.showMaxNum = res.data.preNum); (this.showMaxNum = res.data.preNum);
}
});
},
navLinkDayClick(date) {
const day = dayjs(date).day();
const dayDate = dayjs(date).date();
const dayFormat = dayjs(date).format('YYYY-MM-DD');
let selectDate = dayFormat + ' ' + '09:00:00';
selectDate = dayjs(selectDate).unix();
const nowDate = dayjs(new Date()).unix();
let isAddAllDay = true;
const haveSelectDate = this.calendarOptions.events;
const len = haveSelectDate.length;
const differenceTime = ((nowDate - selectDate) / 3600) | 0;
if (differenceTime > 0 && differenceTime >= 24) {
return this.$message.info('你不能添加过去的时间的排班');
}
for (var i = 0; i < len; i++) {
const itemDay = dayjs(haveSelectDate[i].start).day();
if (!haveSelectDate[i].constraint && day === itemDay) {
haveSelectDate[i].allStatus && (isAddAllDay = false);
const index = this.getIdDeleteData(haveSelectDate[i].id);
this.isDoIt = true;
this.calendarOptions.events.splice(index, 1);
i--;
}
} }
if (isAddAllDay) { });
// 添加日期 },
const selectAllDay = [ navLinkDayClick(date) {
{ startTime: '09:00:00', endTime: '12:00:00' }, const day = dayjs(date).day();
{ startTime: '13:00:00', endTime: '21:00:00' }, const dayDate = dayjs(date).date();
]; const dayFormat = dayjs(date).format('YYYY-MM-DD');
selectAllDay.forEach((item) => { let selectDate = dayFormat + ' ' + '06:00:00';
const allDayData = {}; selectDate = dayjs(selectDate).unix();
allDayData.id = const nowDate = dayjs(new Date()).unix();
dayDate + (this.calendarOptions.events.length + 1) * 10; let isAddAllDay = true;
allDayData.week = this.week; const haveSelectDate = this.calendarOptions.events;
allDayData.end = dayFormat + ' ' + item.endTime; const len = haveSelectDate.length;
allDayData.start = dayFormat + ' ' + item.startTime; const differenceTime = ((nowDate - selectDate) / 3600) | 0;
allDayData.allStatus = true; if (differenceTime > 0 && differenceTime >= 24) {
console.log(allDayData); return this.$message.info('你不能添加过去的时间的排班');
this.calendarOptions.events.push(allDayData); }
}); for (var i = 0; i < len; i++) {
const itemDay = dayjs(haveSelectDate[i].start).day();
if (!haveSelectDate[i].constraint && day === itemDay) {
haveSelectDate[i].allStatus && (isAddAllDay = false);
const index = this.getIdDeleteData(haveSelectDate[i].id);
this.isDoIt = true; this.isDoIt = true;
this.calendarOptions.events.splice(index, 1);
i--;
} }
}, }
getCopyData(lastWeekData) { if (isAddAllDay) {
const copyDate = []; // 添加日期
const addDay = 7; const selectAllDay = [{ startTime: '06:00:00', endTime: '23:00:00' }];
lastWeekData.noAcceptList.map((item) => { selectAllDay.forEach((item) => {
const nowWeekTime = {}; const allDayData = {};
nowWeekTime['startTime'] = dayjs(item.startTime) allDayData.id =
.add(addDay, 'day') dayDate + (this.calendarOptions.events.length + 1) * 10;
.format('YYYY-MM-DD HH:mm:ss'); allDayData.week = this.week;
nowWeekTime['endTime'] = dayjs(item.endTime) allDayData.end = dayFormat + ' ' + item.endTime;
.add(addDay, 'day') allDayData.start = dayFormat + ' ' + item.startTime;
.format('YYYY-MM-DD HH:mm:ss'); allDayData.allStatus = true;
copyDate.push(nowWeekTime); console.log(allDayData);
this.calendarOptions.events.push(allDayData);
}); });
this.calendarOptions.events = [];
lastWeekData.noAcceptList = copyDate;
this.isDoIt = true; this.isDoIt = true;
}, }
handleInitSearch(isReset, isLoopLast) { },
// getCopyData(lastWeekData) {
if (isReset && isLoopLast != 1) { const copyDate = [];
this.calendarOptions.events = this.calendarOptions.events.filter( const addDay = 7;
(v) => v.week !== this.week lastWeekData.noAcceptList.map((item) => {
); const nowWeekTime = {};
} nowWeekTime['startTime'] = dayjs(item.startTime)
let copyWeek = ''; .add(addDay, 'day')
if (isLoopLast == 1) { .format('YYYY-MM-DD HH:mm:ss');
if (this.week == 1) { nowWeekTime['endTime'] = dayjs(item.endTime)
copyWeek = 2; .add(addDay, 'day')
} else if (this.week == 3) { .format('YYYY-MM-DD HH:mm:ss');
copyWeek = 1; copyDate.push(nowWeekTime);
} else if (this.week == 4) { });
copyWeek = 3; this.calendarOptions.events = [];
} else if (this.week == 5) { lastWeekData.noAcceptList = copyDate;
copyWeek = 4; this.isDoIt = true;
} },
handleInitSearch(isReset, isLoopLast) {
//
if (isReset && isLoopLast != 1) {
this.calendarOptions.events = this.calendarOptions.events.filter(
(v) => v.week !== this.week
);
}
let copyWeek = '';
if (isLoopLast == 1) {
if (this.week == 1) {
copyWeek = 2;
} else if (this.week == 3) {
copyWeek = 1;
} else if (this.week == 4) {
copyWeek = 3;
} else if (this.week == 5) {
copyWeek = 4;
} }
const searchLastWeek = {}; }
searchLastWeek.doctorId = this.doctorId; const searchLastWeek = {};
searchLastWeek.week = isLoopLast == 1 ? copyWeek : this.week; searchLastWeek.doctorId = this.doctorId;
// isLoopLast == 1 表示 copy searchLastWeek.week = isLoopLast == 1 ? copyWeek : this.week;
searchLastWeek.workId = this.id; // isLoopLast == 1 表示 copy
dutyRosterQuery(searchLastWeek).then((res) => { searchLastWeek.workId = this.id;
if (res.code == '000000') { dutyRosterQuery(searchLastWeek).then((res) => {
console.log(res.data.noAcceptList, 'res.data.noAcceptList'); if (res.code == '000000') {
if (isLoopLast == 1 && !res.data.noAcceptList.length) { console.log(res.data.noAcceptList, 'res.data.noAcceptList');
return this.$toast('没有上周的排班信息可以用'); if (isLoopLast == 1 && !res.data.noAcceptList.length) {
} else { return this.$toast('没有上周的排班信息可以用');
this.calendarOptions.events = [];
}
if (isLoopLast == 1 && res.data.noAcceptList.length) {
this.getCopyData(res.data);
}
this.handleInitData(res.data);
} else { } else {
this.$toast(res.message); this.calendarOptions.events = [];
} }
}); if (isLoopLast == 1 && res.data.noAcceptList.length) {
}, this.getCopyData(res.data);
handleInitData(weekData) { }
var newDate = null; this.handleInitData(res.data);
if (this.schedulingType != 3) {
newDate = [].concat(weekData.noAcceptList);
} else { } else {
var acceptList = []; this.$toast(res.message);
weekData.acceptList.forEach((item) => {
item.type = 88;
acceptList.push(item);
});
newDate = [].concat(acceptList, weekData.noAcceptList);
} }
newDate.forEach((item) => { });
const selectDate = {}; },
const id = (this.calendarOptions.events.length + 1) * 10; handleInitData(weekData) {
selectDate['week'] = this.week; var newDate = null;
selectDate['id'] = id; if (this.schedulingType != 3) {
selectDate['end'] = item.endTime; newDate = [].concat(weekData.noAcceptList);
selectDate['start'] = item.startTime; } else {
selectDate['type'] = item.type; var acceptList = [];
if (item.type == 88) { weekData.acceptList.forEach((item) => {
selectDate['color'] = '#FFEDE9'; item.type = 88;
} acceptList.push(item);
this.calendarOptions.events.push(selectDate);
}); });
this.limmitDateFun(); newDate = [].concat(acceptList, weekData.noAcceptList);
}, }
limmitDateFun() { newDate.forEach((item) => {
for (let i = 0; i < 7; i++) { const selectDate = {};
const limitTime = {}; const id = (this.calendarOptions.events.length + 1) * 10;
const day = dayjs(this.getEveryDay) selectDate['week'] = this.week;
.add(i, 'day') selectDate['id'] = id;
.format('YYYY-MM-DD HH:mm:ss'); selectDate['end'] = item.endTime;
limitTime.start = dayjs(day) selectDate['start'] = item.startTime;
.add(12, 'hour') selectDate['type'] = item.type;
.format('YYYY-MM-DD HH:mm:ss'); if (item.type == 88) {
limitTime.end = dayjs(day) selectDate['color'] = '#FFEDE9';
.add(13, 'hour')
.format('YYYY-MM-DD HH:mm:ss');
limitTime.constraint = 'businessHours';
limitTime.color = '#ccc';
limitTime.display = 'background';
limitTime.editable = false;
this.calendarOptions.events.push(limitTime);
}
console.log('obj', this.getEveryDay);
},
handleDatesSet(dataInfo) {
this.getEveryDay = dayjs(dataInfo.start).format('YYYY-MM-DD HH:mm:ss');
const currentTime = new Date().getTime(); // 今天的时间戳
const getTime = new Date(dataInfo.start).getTime(); // 每周周一的时间戳
const cz = currentTime - getTime; // 每周周一时间戳 - 今天的时间
const oneHour = 1 * 60 * 60 * 1000 * 24; // 一天的时间戳
const timeDifference = (cz / oneHour) | 0; // 每周一时间距离今天时间数量
const weekHeadTitle = this.calendarOptions.customButtons.myCustomButton;
console.log(timeDifference, 'timeDifference', cz / oneHour);
// debugger;
const exactTime = cz / oneHour;
if (timeDifference == 0 && exactTime > 0) {
this.week = 1;
weekHeadTitle.text = '本周';
return;
} }
if (timeDifference > 0 && timeDifference <= 6) { this.calendarOptions.events.push(selectDate);
// 过去 });
this.week = 1; // this.limmitDateFun();
weekHeadTitle.text = '本周'; },
} else if (timeDifference >= -6 && timeDifference <= 0) { limmitDateFun() {
// 未来 for (let i = 0; i < 7; i++) {
this.week = 3; const limitTime = {};
weekHeadTitle.text = '下周'; const day = dayjs(this.getEveryDay)
} else if (timeDifference >= -13 && timeDifference <= -7) { .add(i, 'day')
// 未来 .format('YYYY-MM-DD HH:mm:ss');
this.week = 4;
weekHeadTitle.text = '第二周'; limitTime.start = dayjs(day)
} else if (timeDifference >= -20 && timeDifference <= -14) { .add(12, 'hour')
// 未来 .format('YYYY-MM-DD HH:mm:ss');
this.week = 5; limitTime.end = dayjs(day)
weekHeadTitle.text = '第三周'; .add(13, 'hour')
} else if (timeDifference >= 7) { .format('YYYY-MM-DD HH:mm:ss');
// 现在 limitTime.constraint = 'businessHours';
weekHeadTitle.text = '上周'; limitTime.color = '#ccc';
this.week = 2; limitTime.display = 'background';
limitTime.editable = false;
this.calendarOptions.events.push(limitTime);
}
},
handleDatesSet(dataInfo) {
this.getEveryDay = dayjs(dataInfo.start).format('YYYY-MM-DD HH:mm:ss');
const currentTime = new Date().getTime(); // 今天的时间戳
const getTime = new Date(dataInfo.start).getTime(); // 每周周一的时间戳
const cz = currentTime - getTime; // 每周周一时间戳 - 今天的时间
const oneHour = 1 * 60 * 60 * 1000 * 24; // 一天的时间戳
const timeDifference = (cz / oneHour) | 0; // 每周一时间距离今天时间数量
const weekHeadTitle = this.calendarOptions.customButtons.myCustomButton;
console.log(timeDifference, 'timeDifference', cz / oneHour);
// debugger;
const exactTime = cz / oneHour;
if (timeDifference == 0 && exactTime > 0) {
this.week = 1;
weekHeadTitle.text = '本周';
return;
}
if (timeDifference > 0 && timeDifference <= 6) {
// 过去
this.week = 1;
weekHeadTitle.text = '本周';
} else if (timeDifference >= -6 && timeDifference <= 0) {
// 未来
this.week = 3;
weekHeadTitle.text = '下周';
} else if (timeDifference >= -13 && timeDifference <= -7) {
// 未来
this.week = 4;
weekHeadTitle.text = '第二周';
} else if (timeDifference >= -20 && timeDifference <= -14) {
// 未来
this.week = 5;
weekHeadTitle.text = '第三周';
} else if (timeDifference >= 7) {
// 现在
weekHeadTitle.text = '上周';
this.week = 2;
}
},
eventResize(event) {
const index = this.getIdDeleteData(event.event.id);
const oldData = this.calendarOptions.events;
const keyAll = Object.keys(oldData[index]);
const dataObj = {};
keyAll.forEach((item) => {
if (item === 'week' || item === 'type') {
dataObj[item] = oldData[index][item];
} else {
dataObj[item] = event.event[item];
} }
}, });
eventResize(event) { oldData.splice(index, 1, dataObj);
this.getHandleTime(dataObj);
},
handleEventClick(event) {
if (!this.calendarOptions.selectable || event.event.constraint) {
return;
}
this.$confirm('你要取消日期吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}).then((_) => {
console.log(_);
const index = this.getIdDeleteData(event.event.id); const index = this.getIdDeleteData(event.event.id);
const oldData = this.calendarOptions.events; this.isDoIt = true;
const keyAll = Object.keys(oldData[index]); this.calendarOptions.events.splice(index, 1);
const dataObj = {}; });
keyAll.forEach((item) => { },
if (item === 'week' || item === 'type') { eventDrop(event) {
dataObj[item] = oldData[index][item]; event.revert();
} else { return;
dataObj[item] = event.event[item]; },
} // 每小时接诊上限人数
}); getMaxNumValue(value) {
oldData.splice(index, 1, dataObj); console.log(value, 'getMaxNumValue');
this.getHandleTime(dataObj); this.maxNumValue = value;
}, },
handleEventClick(event) { // 提交优先级和人数
if (!this.calendarOptions.selectable || event.event.constraint) { submitSetData() {
return; const params = {
doctorId: this.doctorId,
level: this.currentIndex,
workId: this.id,
preNum: this.maxNumValue,
};
saveLevelAndDayCount(params).then((res) => {
if (res.code === '000000') {
this.$message({
message: '设置成功',
type: 'success',
});
this.centerDialogVisible = false;
this.getLevelAndDayCount();
} }
this.$confirm('你要取消日期吗?', '提示', { });
confirmButtonText: '确定', },
cancelButtonText: '取消', selectInfo(info) {
type: 'warning', console.log(info, 'infoinfoinfo');
}).then((_) => { const day = dayjs(info.start).date();
console.log(_); const id = day + (this.calendarOptions.events.length + 1) * 10;
const index = this.getIdDeleteData(event.event.id); info.id = id;
this.isDoIt = true; const keyAll = ['end', 'id', 'start', 'week'];
this.calendarOptions.events.splice(index, 1); const selectTime = {};
keyAll.forEach((item) => {
if (item == 'week') {
selectTime[item] = this.week;
} else {
selectTime[item] = info[item];
}
});
console.log(selectTime, 'dataObjdataObj');
this.calendarOptions.events.push(selectTime);
},
selectAllow(info) {
this.isDoIt = true;
const startDay = new Date(info.start).getDay();
const endDay = new Date(info.end).getDay();
console.log(dayjs(info.start).format('YYYY-MM-DD HH:mm:ss'));
if (startDay != endDay) {
return false;
}
const currentDate = new Date();
const start = info.start;
const end = info.end;
return start <= end && start >= currentDate;
},
getIdDeleteData(eventId) {
// 删除现有排班
const data = this.calendarOptions.events;
const index = data.findIndex((event) => event.id == eventId);
return index;
},
getHandleTime(info) {
// 对于排班交叉部分处理
const infoStart = new Date(info.start).getTime();
const infoEnd = new Date(info.end).getTime();
const haveSelectTime = this.calendarOptions.events;
const correctDate = [];
let isRepeat = false;
haveSelectTime.forEach((item) => {
const selectEndTime = new Date(item.end).getTime();
const selectStartTime = new Date(item.start).getTime();
if (selectStartTime > infoStart && infoEnd >= selectEndTime) {
isRepeat = true;
} else if (selectStartTime > infoStart && infoEnd >= selectStartTime) {
isRepeat = true;
} else {
const id = (correctDate.length + 1) * 10;
item.id = id;
correctDate.push(item);
}
});
this.calendarOptions.events = correctDate;
return isRepeat;
},
handlePriority(index) {
this.isDoIt = true;
this.currentIndex = index;
},
resetDoctoreScheduling() {
this.handleInitSearch(true);
},
copyDoctoreScheduling() {
this.handleInitSearch(true, 1);
},
saveDoctoreScheduling(type, weekV = 0) {
if (this.isDoIt) {
this.loading = true;
const saveParms = {};
saveParms.week = weekV ? weekV : this.week;
saveParms.workId = this.schedulingTypeValue.id;
const lastData = [];
const haveSelectDate = this.calendarOptions.events;
haveSelectDate.forEach((item) => {
if (item.week == (weekV ? weekV : this.week)) {
const saveDate = {};
saveDate.startTime = dayjs(item.start).format(
'YYYY-MM-DD HH:mm:ss'
);
saveDate.endTime = dayjs(item.end).format('YYYY-MM-DD HH:mm:ss');
lastData.push(saveDate);
}
}); });
}, console.log('saveParms=======', saveParms);
eventDrop(event) { // saveParms.list = lastData.filter((item) => {
event.revert(); // return item.startTime.split(' ')[1] !== '12:00:00';
return; // });
}, saveParms.list = lastData.slice(0);
// 每小时接诊上限人数 saveDutyRoster(saveParms).then((res) => {
getMaxNumValue(value) {
console.log(value, 'getMaxNumValue');
this.maxNumValue = value;
},
// 提交优先级和人数
submitSetData() {
const params = {
doctorId: this.doctorId,
level: this.currentIndex,
workId: this.id,
preNum: this.maxNumValue,
};
saveLevelAndDayCount(params).then((res) => {
if (res.code === '000000') { if (res.code === '000000') {
this.loading = false;
this.$message({ this.$message({
message: '设置成功', message: '排班保存成功',
type: 'success', type: 'success',
}); });
this.centerDialogVisible = false; this.isDoIt = false;
this.getLevelAndDayCount(); this.handleInitSearch(true);
}
});
},
selectInfo(info) {
console.log(info, 'infoinfoinfo');
const day = dayjs(info.start).date();
const id = day + (this.calendarOptions.events.length + 1) * 10;
info.id = id;
const keyAll = ['end', 'id', 'start', 'week'];
const selectTime = {};
keyAll.forEach((item) => {
if (item == 'week') {
selectTime[item] = this.week;
} else { } else {
selectTime[item] = info[item]; this.$message.error(res.message || '排班保存失败');
} }
}); });
console.log(selectTime, 'dataObjdataObj'); if (!this.maxNumValue && this.maxNumValue != 0) {
this.calendarOptions.events.push(selectTime); return this.$message({
}, message: '请设置优先级和接诊上限设置',
selectAllow(info) { type: 'warning',
this.isDoIt = true;
const startDay = new Date(info.start).getDay();
const endDay = new Date(info.end).getDay();
const startHour = dayjs(info.start).hour();
console.log(dayjs(info.start).format('YYYY-MM-DD HH:mm:ss'));
if (startDay != endDay || startHour == 12) {
return false;
}
const currentDate = new Date();
const start = info.start;
const end = info.end;
return start <= end && start >= currentDate;
},
getIdDeleteData(eventId) {
// 删除现有排班
const data = this.calendarOptions.events;
const index = data.findIndex((event) => event.id == eventId);
return index;
},
getHandleTime(info) {
// 对于排班交叉部分处理
const infoStart = new Date(info.start).getTime();
const infoEnd = new Date(info.end).getTime();
const haveSelectTime = this.calendarOptions.events;
const correctDate = [];
let isRepeat = false;
haveSelectTime.forEach((item) => {
const selectEndTime = new Date(item.end).getTime();
const selectStartTime = new Date(item.start).getTime();
if (selectStartTime > infoStart && infoEnd >= selectEndTime) {
isRepeat = true;
} else if (selectStartTime > infoStart && infoEnd >= selectStartTime) {
isRepeat = true;
} else {
const id = (correctDate.length + 1) * 10;
item.id = id;
correctDate.push(item);
}
});
this.calendarOptions.events = correctDate;
return isRepeat;
},
handlePriority(index) {
this.isDoIt = true;
this.currentIndex = index;
},
resetDoctoreScheduling() {
this.handleInitSearch(true);
},
copyDoctoreScheduling() {
this.handleInitSearch(true, 1);
},
saveDoctoreScheduling(type, weekV = 0) {
if (this.isDoIt) {
this.loading = true;
const saveParms = {};
saveParms.week = weekV ? weekV : this.week;
saveParms.workId = this.schedulingTypeValue.id;
const lastData = [];
const haveSelectDate = this.calendarOptions.events;
haveSelectDate.forEach((item) => {
if (item.week == (weekV ? weekV : this.week)) {
const saveDate = {};
saveDate.startTime = dayjs(item.start).format(
'YYYY-MM-DD HH:mm:ss'
);
saveDate.endTime = dayjs(item.end).format('YYYY-MM-DD HH:mm:ss');
lastData.push(saveDate);
}
});
console.log('saveParms=======', saveParms);
saveParms.list = lastData.filter((item) => {
return item.startTime.split(' ')[1] !== '12:00:00';
});
saveDutyRoster(saveParms).then((res) => {
if (res.code === '000000') {
this.loading = false;
this.$message({
message: '排班保存成功',
type: 'success',
});
this.isDoIt = false;
this.handleInitSearch(true);
} else {
this.$message.error(res.message || '排班保存失败');
}
}); });
if (!this.maxNumValue && this.maxNumValue != 0) {
return this.$message({
message: '请设置优先级和接诊上限设置',
type: 'warning',
});
}
} }
}, }
}, },
}; },
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
......
...@@ -107,16 +107,16 @@ ...@@ -107,16 +107,16 @@
</template> </template>
<script> <script>
import { departmentAll } from '@/api/diagnosis'; import { departmentAll } from '@/api/diagnosis';
import FullCalendar from '@fullcalendar/vue'; import {
import dayGridPlugin from '@fullcalendar/daygrid'; getPlatformUpper,
import timeGridPlugin from '@fullcalendar/timegrid'; previewWork,
import interactionPlugin from '@fullcalendar/interaction'; setPlatformUpper,
import resourceTimeGridPlugin from '@fullcalendar/resource-timegrid'; } from '@/api/serviceSchedule';
import { import dayGridPlugin from '@fullcalendar/daygrid';
previewWork, import interactionPlugin from '@fullcalendar/interaction';
setPlatformUpper, import resourceTimeGridPlugin from '@fullcalendar/resource-timegrid';
getPlatformUpper, import timeGridPlugin from '@fullcalendar/timegrid';
} from '@/api/serviceSchedule'; import FullCalendar from '@fullcalendar/vue';
export default { export default {
name: 'Index', name: 'Index',
components: { components: {
...@@ -164,8 +164,8 @@ ...@@ -164,8 +164,8 @@
resourceAreaWidth: '5%', resourceAreaWidth: '5%',
allDaySlot: false, // 周,日视图时,all-day 不显示 allDaySlot: false, // 周,日视图时,all-day 不显示
slotDuration: '01:00:00', slotDuration: '01:00:00',
slotMinTime: '09:00', slotMinTime: '06:00',
slotMaxTime: '21:00', slotMaxTime: '23:00',
slotLabelInterval: '', slotLabelInterval: '',
scrollTime: false, scrollTime: false,
initialDate: '2021-10-31', initialDate: '2021-10-31',
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册