提交 b88bc1e2 编写于 作者: qian.jie's avatar qian.jie

提交代码

上级 95bef419
......@@ -12,11 +12,11 @@
<div
ref="agment"
class="agment-box"
:class="{ w2: week == 2, w3: week == 3 }"
:class="{'w2':week==2,'w3':week==3}"
>
<FullCalendar :options="calendarOptions" />
</div>
<div
<div
class="agment-box-left"
:style="{ height: scrollerHeight }"
>
......@@ -24,7 +24,7 @@
<div
v-if="week == 2"
class="ag-left1"
/>
/>
<!-- v-if="week == 2" -->
<div
v-if="week == 3"
......@@ -48,11 +48,13 @@
{{ this.schedulingTypeValue.departmentName }}
</div>
</div>
<div style="margin-top: 24px">
<div
style="margin-top: 24px"
>
<p class="agment-head-title">
选择匹配优先级
</p>
<div :class="this.schedulingType == 3 ? 'agment-head-none' : ''">
<div :class="this.schedulingType == 3 ? 'agment-head-none' : '' ">
<div class="agment-head-priority">
<p
v-for="(item, index) in createList"
......@@ -110,9 +112,9 @@
},
data() {
return {
id: '',
doctorId: '',
schedulingTypeValue: {},
id:'',
doctorId:'',
schedulingTypeValue:{},
schedulingType: 1, // 1 新增 2 编辑 3 查看
createList: [],
listDate: [],
......@@ -189,30 +191,31 @@
workingTicketVisible: false, // 工作表票详情页面
scrollerHeight: 0,
loading: false,
isDoIt: false,
isDoIt:false
};
},
watch: {
week(newV, oldV) {
// if (this.haveWeek.indexOf(newV) == -1) {
// this.haveWeek.push(newV);
// this.handleInitSearch();
// }
if (newV !== oldV) {
console.log(newV, oldV, 'newV, oldV');
if (this.haveWeek.indexOf(newV) == -1) {
this.haveWeek.push(newV);
this.handleInitSearch();
this.saveDoctoreScheduling(2);
}
if(newV !== oldV) {
this.handleInitSearch();
this.saveDoctoreScheduling(2, oldV);
}
},
},
created() {
this.schedulingType = this.$route.query.type || 1;
this.id = this.$route.query.id;
(this.doctorId = this.$route.query.doctorId),
this.doctorId = this.$route.query.doctorId,
getDoctorInfo({ id: this.id }).then((res) => {
if (res.code == '000000') {
this.schedulingTypeValue = res.data;
this.currentIndex = res.data.level;
} else {
}else{
this.$toast(res.message);
}
});
......@@ -223,6 +226,7 @@
});
},
mounted() {
console.log(this.calendarOptions.events, 'this.calendarOptions.events');
this.scrollerHeight = this.$refs.agment.clientHeight + 'px';
// console.log(this.$refs.agment.clientHeight, 'this.$refs.agment.offsetHeight;');
this.init();
......@@ -249,7 +253,8 @@
},
handleInitSearch(isReset) {
if (isReset) {
this.calendarOptions.events = [];
this.calendarOptions.events = this.calendarOptions.events.filter((v) => (v.week !== this.week));
console.log(this.calendarOptions.events);
}
const objParms = {};
objParms.doctorId = this.doctorId;
......@@ -258,6 +263,7 @@
// this.currentIndex = this.schedulingTypeValue.level;
dutyRosterQuery(objParms).then((res) => {
if (res.code == '000000') {
this.calendarOptions.events = [];
this.handleInitData(res.data);
} else {
this.$toast(res.message);
......@@ -268,12 +274,14 @@
var newDate = null;
if (this.schedulingType != 3) {
newDate = [].concat(data.noAcceptList);
console.log(newDate, 'newDate');
} else {
var acceptList = [];
data.acceptList.forEach((item) => {
item.type = 88;
acceptList.push(item);
});
console.log(data.acceptList, 'data.acceptList');
newDate = [].concat(acceptList, data.noAcceptList);
}
// const keyAll = ['end', 'endStr', 'id', 'start', 'startStr'];
......@@ -284,6 +292,7 @@
dataObj['id'] = id;
dataObj['end'] = item.endTime;
dataObj['start'] = item.startTime;
console.log(item.type);
dataObj['type'] = item.type;
if (item.type == 88) {
dataObj['color'] = '#FFEDE9';
......@@ -339,7 +348,9 @@
.then((_) => {
console.log(_);
const index = this.getIdDeleteData(event.event.id);
return this.calendarOptions.events.splice(index, 1);
this.isDoIt = true;
this.calendarOptions.events.splice(index, 1);
console.log(this.calendarOptions.events);
})
.catch((_) => {
console.log(_);
......@@ -411,27 +422,33 @@
return indexObj;
},
handlePriority(index) {
this.isDoIt = true;
this.currentIndex = index;
},
resetDoctoreScheduling() {
this.handleInitSearch(true);
},
saveDoctoreScheduling(type) {
if (this.isDoIt) {
saveDoctoreScheduling(type, weekV = 0) {
if(this.isDoIt) {
console.log(this.week, 'this.week', weekV);
this.loading = true;
const objParms = {};
objParms.week = this.week;
objParms.week = weekV ? weekV : this.week;
objParms.workId = this.schedulingTypeValue.id;
objParms.level = this.currentIndex;
objParms.list = [];
const data = this.calendarOptions.events;
console.log(data, 'data');
data.forEach((item) => {
// if (item.week == this.week) {
const obj = {};
obj.startTime = this.dateFormat('YYYY-mm-dd HH:MM:SS', item.start);
obj.endTime = this.dateFormat('YYYY-mm-dd HH:MM:SS', item.end);
objParms.list.push(obj);
// }
console.log(item.week == (weekV ? weekV : this.week));
if (item.week == (weekV ? weekV : this.week)) {
console.log(item.week, this.week, weekV, 'this.week');
const obj = {};
obj.startTime = this.dateFormat('YYYY-mm-dd HH:MM:SS', item.start);
obj.endTime = this.dateFormat('YYYY-mm-dd HH:MM:SS', item.end);
console.log(obj, 'obj');
objParms.list.push(obj);
}
});
saveDutyRoster(objParms).then((res) => {
if (res.code === '000000') {
......@@ -439,10 +456,10 @@
// this.handleInitSearch(true);
// this.$router.go(0);
this.loading = false;
if (type == 1) {
if(type == 1) {
this.$message({
message: '排班保存成功',
type: 'success',
type: 'success'
});
}
this.isDoIt = false;
......
......@@ -55,8 +55,8 @@
import {
getFirstLevelLable,
childLabelList,
dutyRosterQuery,
saveDutyRoster,
// dutyRosterQuery,
// saveDutyRoster,
previewWork,
} from '@/api/serviceSchedule';
export default {
......@@ -89,23 +89,23 @@
// 引入的插件,比如fullcalendar/daygrid,fullcalendar/timegrid引入后才可显示月,周,日
plugins: [dayGridPlugin, interactionPlugin, timeGridPlugin],
initialView: 'timeGrid', // 默认为那个视图(月:dayGridMonth,周:timeGridWeek,日:timeGridDay)
duration: { days: 30 },
selectable: true,
duration: { days: 4 },
selectable: false,
selectMirror: true,
selectAllow: this.selectAllow,
// selectAllow: this.selectAllow,
selectOverlap: false,
select: this.selectInfo,
// select: this.selectInfo,
selectMinDistance: 0,
eventResize: this.eventResize,
eventDrop: this.eventDrop,
editable: true,
// eventResize: this.eventResize,
// eventDrop: this.eventDrop,
editable: false,
overlap: false,
defaultDate: new Date(),
datesSet: this.handleDatesSet,
// datesSet: this.handleDatesSet,
events: [],
slotEventOverlap: true,
header: {
center: 'month,agendaFourDay', // buttons for switching between views
// center: 'month,agendaFourDay', // buttons for switching between views
},
firstDay: 1, // 设置一周中显示的第一天是哪天,周日是0,周一是1,类推
locale: 'zh-cn', // 切换语言,当前为中文
......@@ -123,16 +123,16 @@
text: '本周',
},
},
dayHeaderContent: this.aaa,
headerToolbar: {
// 日历头部按钮位置
left: '',
center: 'prev myCustomButton next',
right: '',
},
dayHeaderContent: this.getHederList,
// headerToolbar: {
// // 日历头部按钮位置
// left: '',
// center: 'prev myCustomButton next',
// right: '',
// },
expandRows: true,
slotMinWidth: 50,
slotDuration: '00:30:00',
slotDuration: '00:05:00',
slotMinTime: '09:00',
slotMaxTime: '21:00',
slotLabelInterval: '',
......@@ -152,67 +152,34 @@
eventLimit: 4, // adjust to 6 only for timeGridWeek/timeGridDay
},
},
eventClick: this.handleEventClick,
// eventClick: this.handleEventClick,
},
workingTicketVisible: false, // 工作表票详情页面
scrollerHeight: 0,
loading: false,
// indexArr:[1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7],
doctorList: [
{
doctorId: 0,
doctorName: '张三',
},
{
doctorId: 0,
doctorName: '张三1',
},
{
doctorId: 0,
doctorName: '张三2',
},
{
doctorId: 0,
doctorName: '张三3',
},
{
doctorId: 0,
doctorName: '张三4',
},
{
doctorId: 0,
doctorName: '张三5',
},
{
doctorId: 0,
doctorName: '张三6',
},
{
doctorId: 0,
doctorName: '张三7',
},
{
doctorId: 0,
doctorName: '张三8',
},
{
doctorId: 0,
doctorName: '张三9',
},
],
doctorList: [],
index: 0,
};
},
watch: {},
created() {
this.getFirstLevelLable();
setTimeout(() => {
// this.calendarOptions.duration.days = this.doctorList.length;
console.log(22);
}, 2000);
},
mounted() {
this.init();
this.calendarOptions.events = [
{
end: '2021-10-30 14:30:00',
id: 10,
start: '2021-10-30 11:00:00',
color:'red'
},
{
end: '2021-10-31 14:30:00',
id: 10,
start: '2021-10-31 11:00:00',
color:'red'
}
];
},
methods: {
// 通过监听expand-change事件(当展开节点发生变化时触发)获取第二层数据,组装interfaceOptions数据
......@@ -267,9 +234,11 @@
previewWork({ ...params }).then((res) => {
if (res.code === '000000') {
this.doctorList = res.data.doctorList || [];
console.log(this.doctorList);
// this.calendarOptions.events = res.data.dutyWorkList || [];
this.handleInitData(res.data.dutyWorkList);
this.calendarOptions.duration.days = this.doctorList.length;
console.log(this.calendarOptions.events);
this.handleInitSearch(true);
console.log();
}
});
},
......@@ -281,10 +250,10 @@
* jsEvent是个javascript事件
* view是当前视图对象。
*/
aaa(e) {
console.log(e);
getHederList() {
console.log('1', this.index);
const italicEl = document.createElement('i');
if(this.doctorList.length) {
if (this.doctorList.length) {
italicEl.innerHTML = this.doctorList[this.index]['doctorName'];
}
if (this.index < this.doctorList.length) {
......@@ -293,241 +262,21 @@
console.log(italicEl);
return { domNodes: [italicEl] };
},
init() {
if (this.schedulingType == 1 || this.schedulingType == 2) {
this.calendarOptions.editable = true;
} else {
// 查看
this.calendarOptions.slotDuration = '00:05:00';
this.calendarOptions.selectable = false;
this.calendarOptions.editable = false;
}
this.handleInitSearch();
},
handleInitSearch(isReset) {
if (isReset) {
this.calendarOptions.events = [];
}
const objParms = {};
objParms.doctorId = this.doctorId;
objParms.week = this.week;
objParms.workId = this.id;
// this.currentIndex = this.schedulingTypeValue.level;
dutyRosterQuery(objParms).then((res) => {
if (res.code == '000000') {
this.handleInitData(res.data);
} else {
this.$toast(res.message);
}
});
},
handleInitData(data) {
var newDate = null;
if (this.schedulingType != 3) {
newDate = [].concat(data.noAcceptList);
} else {
var acceptList = [];
data.acceptList.forEach((item) => {
item.type = 88;
acceptList.push(item);
});
newDate = [].concat(acceptList, data.noAcceptList);
}
// const keyAll = ['end', 'endStr', 'id', 'start', 'startStr'];
newDate = [].concat(data);
newDate.forEach((item) => {
const dataObj = {};
const id = (this.calendarOptions.events.length + 1) * 10;
dataObj['week'] = this.week;
dataObj['id'] = id;
dataObj['doctorName'] = item.doctorName;
dataObj['doctorId'] = item.doctorId;
dataObj['end'] = item.endTime;
dataObj['start'] = item.startTime;
console.log(item.type);
dataObj['type'] = item.type;
if (item.type == 88) {
dataObj['color'] = '#FFEDE9';
}
dataObj['color'] = 'red';
this.calendarOptions.events.push(dataObj);
this.search();
});
},
handleDatesSet(dataInfo) {
const currentTime = new Date().getTime();
const getTime = new Date(dataInfo.startStr).getTime();
const cz = currentTime - getTime;
const oneHour = 1 * 60 * 60 * 1000 * 24;
const timeDifference = (cz / oneHour) | 0;
const headObj = this.calendarOptions.customButtons.myCustomButton;
if (timeDifference > 0 && timeDifference < 7) {
// 过去
this.week = 1;
headObj.text = '本周';
} else if (timeDifference < 0) {
// 未来
this.week = 3;
headObj.text = '下周';
} else {
// 现在
headObj.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];
}
});
oldData.splice(index, 1, dataObj);
this.getHandleTime(dataObj);
},
handleEventClick(event) {
if (!this.calendarOptions.selectable) {
return;
}
this.$confirm('你要取消日期吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then((_) => {
console.log(_);
const index = this.getIdDeleteData(event.event.id);
return this.calendarOptions.events.splice(index, 1);
})
.catch((_) => {
console.log(_);
});
// alert("你要取消日期吗");
},
eventDrop(event) {
event.revert();
return;
},
selectInfo(info) {
const startDay = new Date(info.start).getDay();
const endDay = new Date(info.end).getDay();
if (startDay != endDay) {
return this.$toast('不能夸天选择排班');
}
const id = (this.calendarOptions.events.length + 1) * 10;
info.id = id;
const keyAll = ['end', 'endStr', 'id', 'start', 'startStr', 'week'];
const dataObj = {};
keyAll.forEach((item) => {
if (item == 'week') {
dataObj[item] = this.week;
} else {
dataObj[item] = info[item];
}
console.log(this.calendarOptions.events, 'this.calendarOptions.events');
});
this.calendarOptions.events.push(dataObj);
},
selectAllow(info) {
const startDay = new Date(info.start).getDay();
const endDay = new Date(info.end).getDay();
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 data = this.calendarOptions.events;
const newDate = [];
let indexObj = false;
data.forEach((item) => {
const d = new Date(item.end).getTime();
const s = new Date(item.start).getTime();
if (s > infoStart && infoEnd >= d) {
indexObj = true;
} else if (s > infoStart && infoEnd >= s) {
indexObj = true;
} else {
const id = (newDate.length + 1) * 10;
item.id = id;
newDate.push(item);
}
});
this.calendarOptions.events = newDate;
return indexObj;
},
handlePriority(index) {
this.currentIndex = index;
},
resetDoctoreScheduling() {
this.handleInitSearch(true);
},
saveDoctoreScheduling() {
this.loading = true;
const objParms = {};
objParms.week = this.week;
objParms.workId = this.schedulingTypeValue.id;
objParms.level = this.currentIndex;
objParms.list = [];
const data = this.calendarOptions.events;
data.forEach((item) => {
if (item.week == this.week) {
const obj = {};
obj.startTime = this.dateFormat('YYYY-mm-dd HH:MM:SS', item.start);
obj.endTime = this.dateFormat('YYYY-mm-dd HH:MM:SS', item.end);
objParms.list.push(obj);
}
});
saveDutyRoster(objParms).then((res) => {
if (res.code === '000000') {
// this.$toast(res.message);
// this.handleInitSearch(true);
// this.$router.go(0);
this.loading = false;
this.$message({
message: '排班保存成功',
type: 'success',
});
} else {
// this.$toast(res.message);
this.$message.error(res.message || '排班保存失败');
}
});
},
dateFormat(fmt, date2) {
const date = new Date(date2);
let ret;
const opt = {
'Y+': date.getFullYear().toString(), // 年
'm+': (date.getMonth() + 1).toString(), // 月
'd+': date.getDate().toString(), // 日
'H+': date.getHours().toString(), // 时
'M+': date.getMinutes().toString(), // 分
'S+': date.getSeconds().toString() || '00', // 秒
// 有其他格式化字符需求可以继续添加,必须转化成字符串
};
for (const k in opt) {
ret = new RegExp('(' + k + ')').exec(fmt);
if (ret) {
fmt = fmt.replace(
ret[1],
ret[1].length == 1 ? opt[k] : opt[k].padStart(ret[1].length, '0')
);
}
}
return fmt;
},
},
};
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册