|
|
|
|
@ -84,8 +84,8 @@
|
|
|
|
|
<el-checkbox-group v-model="auto_print" style="margin-left: 12px;">
|
|
|
|
|
<el-checkbox label="1">预约完成后打印申请单</el-checkbox>
|
|
|
|
|
</el-checkbox-group>
|
|
|
|
|
<el-button class="do_button" type="primary" style="margin-left: 20px;" :disabled="buttonsDisabled">最优时间</el-button>
|
|
|
|
|
<el-button class="do_button" type="primary" :disabled="buttonsDisabled">单天全检</el-button>
|
|
|
|
|
<el-button class="do_button" type="primary" style="margin-left: 20px;" @click="optimalTimeClick">最优时间</el-button>
|
|
|
|
|
<el-button class="do_button" type="primary" @click="">单天全检</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<el-date-picker v-model="startDate" type="date" placeholder="跳转日期" @change="DatePickerChange()" />
|
|
|
|
|
@ -157,7 +157,7 @@
|
|
|
|
|
CheckIsDaiJian,
|
|
|
|
|
PlanYuYue,
|
|
|
|
|
CheckEntrstItemGroup2,
|
|
|
|
|
DoctorCancelYuYue,GetConfigInfo2,CreateJianChaShenQingDanPdf
|
|
|
|
|
DoctorCancelYuYue,GetConfigInfo2,CreateJianChaShenQingDanPdf,GetOptimalPlan
|
|
|
|
|
} from '@/api/api.js'
|
|
|
|
|
import {
|
|
|
|
|
ElMessage,
|
|
|
|
|
@ -187,6 +187,10 @@
|
|
|
|
|
special_privileges:{
|
|
|
|
|
type: Array,
|
|
|
|
|
default: () => []
|
|
|
|
|
},
|
|
|
|
|
scope: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: 'all'
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
let entrustTableRef = ref(null)
|
|
|
|
|
@ -210,6 +214,10 @@
|
|
|
|
|
let handleType = ref('add');
|
|
|
|
|
let startDate = ref('');
|
|
|
|
|
let systemConfigs=ref([]);//系统参数
|
|
|
|
|
let cachedListData = ref([]) // 缓存列表原始数据,每次GetMainInfo更新
|
|
|
|
|
let cachedPlans = ref([]) // 缓存号源原始数据,每次GetEnablePlanFunc更新
|
|
|
|
|
let zhanWeiCount = ref(0) // 当前选中项目的号位需求数
|
|
|
|
|
let hasAutoAssignedFirstPlan = ref(false) // 首次自动分配标志
|
|
|
|
|
let TanChuangMsgDialogVisible=ref(false)
|
|
|
|
|
const getWeekday = (date1) => {
|
|
|
|
|
let days = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
|
|
|
|
|
@ -383,6 +391,8 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// 缓存列表原始数据(深拷贝,与显示列表解耦)
|
|
|
|
|
cachedListData.value = JSON.parse(JSON.stringify(entrustTableDate.value))
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
ElMessage.error(res.msg)
|
|
|
|
|
@ -463,15 +473,20 @@
|
|
|
|
|
entrustid: selectedEntrustId.value,
|
|
|
|
|
episodeid: props.episode_id,
|
|
|
|
|
appointment_type: props.appointment_type,
|
|
|
|
|
date: date_list.value
|
|
|
|
|
date: date_list.value,
|
|
|
|
|
scope: props.scope,
|
|
|
|
|
do_user: props.do_user
|
|
|
|
|
}).then(res => {
|
|
|
|
|
planLoading.value = false
|
|
|
|
|
planTableData.value = []
|
|
|
|
|
zhenShiList.value=[]
|
|
|
|
|
if (res.status) {
|
|
|
|
|
let plans = res.data.plan_list
|
|
|
|
|
let zhanWeiCount=res.data.zhanWeiCount
|
|
|
|
|
let zwCount=res.data.zhanWeiCount
|
|
|
|
|
let is_emergency=res.data.is_emergency
|
|
|
|
|
// 保存号源数据到顶层变量,供PlanClick使用
|
|
|
|
|
cachedPlans.value = plans
|
|
|
|
|
zhanWeiCount.value = zwCount
|
|
|
|
|
if (plans.length > 0) {
|
|
|
|
|
|
|
|
|
|
if (activeZhenShi.value == '') activeZhenShi.value = plans[0].department_resources_name
|
|
|
|
|
@ -506,7 +521,7 @@
|
|
|
|
|
);
|
|
|
|
|
let plan_enable = false
|
|
|
|
|
if (matchingPlan) {
|
|
|
|
|
if (matchingPlan.count - matchingPlan.used_count >= zhanWeiCount && matchingPlan.plan_enable===true) {
|
|
|
|
|
if (matchingPlan.count - matchingPlan.used_count >= zwCount && matchingPlan.plan_enable===true) {
|
|
|
|
|
plan_enable = true
|
|
|
|
|
}
|
|
|
|
|
if(is_emergency===true && matchingPlan.plan_enable===true && canEmergency.value==true){
|
|
|
|
|
@ -529,15 +544,67 @@
|
|
|
|
|
planTableData.value.push(row);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 默认选中第一个有号源的 plan(按后端排序:时间最近、号源最多)
|
|
|
|
|
// 优先高亮已分配或已预约的号源
|
|
|
|
|
selectedPlanId.value = 0
|
|
|
|
|
const firstAvailable = plans.find(v =>
|
|
|
|
|
v.department_resources_name == activeZhenShi.value &&
|
|
|
|
|
(v.count - v.used_count) >= zhanWeiCount &&
|
|
|
|
|
v.plan_enable === true
|
|
|
|
|
);
|
|
|
|
|
if (firstAvailable) {
|
|
|
|
|
selectedPlanId.value = firstAvailable.id
|
|
|
|
|
const highlightPlanId = findHighlightPlanId()
|
|
|
|
|
if (highlightPlanId) {
|
|
|
|
|
selectedPlanId.value = highlightPlanId
|
|
|
|
|
} else {
|
|
|
|
|
// 没有匹配的,才高亮第一个可用号源
|
|
|
|
|
const firstAvailable = plans.find(v =>
|
|
|
|
|
v.department_resources_name == activeZhenShi.value &&
|
|
|
|
|
(v.count - v.used_count) >= zwCount &&
|
|
|
|
|
v.plan_enable === true
|
|
|
|
|
);
|
|
|
|
|
if (firstAvailable) {
|
|
|
|
|
selectedPlanId.value = firstAvailable.id
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 首次加载时自动分配最优时间
|
|
|
|
|
if (!hasAutoAssignedFirstPlan.value) {
|
|
|
|
|
hasAutoAssignedFirstPlan.value = true
|
|
|
|
|
const unbookedRows = entrustTableDate.value.filter(v => v.list_status === 0)
|
|
|
|
|
if (unbookedRows.length > 0) {
|
|
|
|
|
const items = unbookedRows.map(v => ({
|
|
|
|
|
id: v.id,
|
|
|
|
|
entrust_id: v.entrust_id,
|
|
|
|
|
department_resources_name: v.department_resources?.department_resources_name || '',
|
|
|
|
|
date: v.reservation_date || '',
|
|
|
|
|
begin_time: v.period_begin_time || '',
|
|
|
|
|
end_time: v.period_end_time || ''
|
|
|
|
|
}))
|
|
|
|
|
GetOptimalPlan({
|
|
|
|
|
type: 'optimal_time',
|
|
|
|
|
regnum: props.reg_num,
|
|
|
|
|
entrustid: selectedEntrustId.value,
|
|
|
|
|
episodeid: props.episode_id,
|
|
|
|
|
appointment_type: props.appointment_type,
|
|
|
|
|
items: items,
|
|
|
|
|
scope: props.scope,
|
|
|
|
|
do_user: props.do_user
|
|
|
|
|
}).then(res => {
|
|
|
|
|
if (res.status) {
|
|
|
|
|
res.data.forEach(item => {
|
|
|
|
|
const target = entrustTableDate.value.find(v => v.id === item.id)
|
|
|
|
|
if (!target) return
|
|
|
|
|
if (!target.department_resources) {
|
|
|
|
|
target.department_resources = {}
|
|
|
|
|
}
|
|
|
|
|
target.department_resources.department_resources_name = item.department_resources_name
|
|
|
|
|
target.reservation_date = item.date
|
|
|
|
|
target.period_begin_time = item.begin_time
|
|
|
|
|
target.period_end_time = item.end_time
|
|
|
|
|
target.temp_plan_id = item.plan_id
|
|
|
|
|
})
|
|
|
|
|
// 更新高亮
|
|
|
|
|
const newHighlightId = findHighlightPlanId()
|
|
|
|
|
if (newHighlightId) {
|
|
|
|
|
selectedPlanId.value = newHighlightId
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
@ -585,13 +652,134 @@
|
|
|
|
|
selectedPlanId.value = 0
|
|
|
|
|
GetEnablePlanFunc()
|
|
|
|
|
}
|
|
|
|
|
// 从已分配或已预约的行中,找到在当前排班下可高亮的号源ID
|
|
|
|
|
const findHighlightPlanId = () => {
|
|
|
|
|
// 优先找申请中行的临时分配号源
|
|
|
|
|
for (const row of entrustTableDate.value) {
|
|
|
|
|
if (row.list_status === 0 && row.temp_plan_id) {
|
|
|
|
|
const plan = cachedPlans.value.find(v =>
|
|
|
|
|
v.id === row.temp_plan_id &&
|
|
|
|
|
v.department_resources_name === activeZhenShi.value
|
|
|
|
|
)
|
|
|
|
|
if (plan) return plan.id
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 再找已预约行的roster_id
|
|
|
|
|
for (const row of entrustTableDate.value) {
|
|
|
|
|
if (row.list_status === 1 && row.roster_id) {
|
|
|
|
|
const plan = cachedPlans.value.find(v =>
|
|
|
|
|
v.id === row.roster_id &&
|
|
|
|
|
v.department_resources_name === activeZhenShi.value
|
|
|
|
|
)
|
|
|
|
|
if (plan) return plan.id
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
const PlanClick = (planid) => {
|
|
|
|
|
console.log(planid)
|
|
|
|
|
if (planid != undefined) {
|
|
|
|
|
selectedPlanId.value = planid
|
|
|
|
|
checkDaijianFuc()
|
|
|
|
|
if (planid == undefined) return
|
|
|
|
|
|
|
|
|
|
// 从缓存中找到对应号源数据
|
|
|
|
|
const plan = cachedPlans.value.find(v => v.id === planid)
|
|
|
|
|
if (!plan) return
|
|
|
|
|
|
|
|
|
|
// 判断剩余号源是否足够
|
|
|
|
|
const remaining = plan.count - plan.used_count
|
|
|
|
|
if (remaining < zhanWeiCount.value) {
|
|
|
|
|
ElMessage.warning(`剩余号源不足,当前仅剩 ${remaining} 个号位,所选项目需 ${zhanWeiCount.value} 个号位`)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
selectedPlanId.value = planid
|
|
|
|
|
checkDaijianFuc()
|
|
|
|
|
|
|
|
|
|
// 同步更新显示列表中的排班、预约日期、预约时间
|
|
|
|
|
selectedRows.value.forEach(row => {
|
|
|
|
|
const target = entrustTableDate.value.find(v => v.id === row.id)
|
|
|
|
|
if (!target) return
|
|
|
|
|
// 排班
|
|
|
|
|
if (!target.department_resources) {
|
|
|
|
|
target.department_resources = {}
|
|
|
|
|
}
|
|
|
|
|
target.department_resources.department_resources_name = plan.department_resources_name
|
|
|
|
|
// 预约日期
|
|
|
|
|
target.reservation_date = plan.date
|
|
|
|
|
// 预约时间
|
|
|
|
|
target.period_begin_time = plan.begin_time
|
|
|
|
|
target.period_end_time = plan.end_time
|
|
|
|
|
// 保存临时分配的号源ID
|
|
|
|
|
target.temp_plan_id = planid
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// 最优时间按钮点击
|
|
|
|
|
const optimalTimeClick = () => {
|
|
|
|
|
if (selectedEntrustId.value.length === 0) {
|
|
|
|
|
ElMessage.error("请选择检查项目")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
planLoading.value = true
|
|
|
|
|
|
|
|
|
|
// 清空当前勾选行的临时排班信息(从缓存恢复原始数据)
|
|
|
|
|
selectedRows.value.forEach(row => {
|
|
|
|
|
const cachedRow = cachedListData.value.find(v => v.id === row.id)
|
|
|
|
|
if (!cachedRow) return
|
|
|
|
|
const target = entrustTableDate.value.find(v => v.id === row.id)
|
|
|
|
|
if (!target) return
|
|
|
|
|
target.department_resources = cachedRow.department_resources
|
|
|
|
|
target.reservation_date = cachedRow.reservation_date
|
|
|
|
|
target.period_begin_time = cachedRow.period_begin_time
|
|
|
|
|
target.period_end_time = cachedRow.period_end_time
|
|
|
|
|
target.temp_plan_id = undefined
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// 收集所有申请中行的当前信息
|
|
|
|
|
const items = entrustTableDate.value
|
|
|
|
|
.filter(v => v.list_status === 0)
|
|
|
|
|
.map(v => ({
|
|
|
|
|
id: v.id,
|
|
|
|
|
entrust_id: v.entrust_id,
|
|
|
|
|
department_resources_name: v.department_resources?.department_resources_name || '',
|
|
|
|
|
date: v.reservation_date || '',
|
|
|
|
|
begin_time: v.period_begin_time || '',
|
|
|
|
|
end_time: v.period_end_time || ''
|
|
|
|
|
}))
|
|
|
|
|
|
|
|
|
|
// 调用后端接口
|
|
|
|
|
GetOptimalPlan({
|
|
|
|
|
type: 'optimal_time',
|
|
|
|
|
regnum: props.reg_num,
|
|
|
|
|
entrustid: selectedEntrustId.value,
|
|
|
|
|
episodeid: props.episode_id,
|
|
|
|
|
appointment_type: props.appointment_type,
|
|
|
|
|
items: items,
|
|
|
|
|
scope: props.scope,
|
|
|
|
|
do_user: props.do_user
|
|
|
|
|
}).then(res => {
|
|
|
|
|
planLoading.value = false
|
|
|
|
|
if (res.status) {
|
|
|
|
|
// 更新显示列表
|
|
|
|
|
res.data.forEach(item => {
|
|
|
|
|
const target = entrustTableDate.value.find(v => v.id === item.id)
|
|
|
|
|
if (!target) return
|
|
|
|
|
if (!target.department_resources) {
|
|
|
|
|
target.department_resources = {}
|
|
|
|
|
}
|
|
|
|
|
target.department_resources.department_resources_name = item.department_resources_name
|
|
|
|
|
target.reservation_date = item.date
|
|
|
|
|
target.period_begin_time = item.begin_time
|
|
|
|
|
target.period_end_time = item.end_time
|
|
|
|
|
target.temp_plan_id = item.plan_id
|
|
|
|
|
})
|
|
|
|
|
// 更新高亮
|
|
|
|
|
if (res.data.length > 0) {
|
|
|
|
|
selectedPlanId.value = res.data[0].plan_id
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
ElMessage.error(res.msg)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
const checkDaijianFuc = () => {
|
|
|
|
|
planLoading.value = true
|
|
|
|
|
|