|
@@ -73,6 +73,7 @@ const acupointData = computed(() => {
|
|
|
index: (index + 1) as any,
|
|
index: (index + 1) as any,
|
|
|
acupointName: acupoint.acupointName,
|
|
acupointName: acupoint.acupointName,
|
|
|
acuType: acupoint.acuType, // 添加 acuType 字段
|
|
acuType: acupoint.acuType, // 添加 acuType 字段
|
|
|
|
|
+ knowledgeId: acupoint.knowledgeId,
|
|
|
}));
|
|
}));
|
|
|
|
|
|
|
|
// 将穴位数据按4个一组重新组织,每行4个穴位
|
|
// 将穴位数据按4个一组重新组织,每行4个穴位
|
|
@@ -86,6 +87,7 @@ const acupointData = computed(() => {
|
|
|
index: '',
|
|
index: '',
|
|
|
acupointName: '',
|
|
acupointName: '',
|
|
|
acuType: '',
|
|
acuType: '',
|
|
|
|
|
+ knowledgeId: '',
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
groupedData.push({
|
|
groupedData.push({
|
|
@@ -173,6 +175,17 @@ watch(
|
|
|
{ immediate: false },
|
|
{ immediate: false },
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
|
|
+// 监听 operates 数据变化,强制刷新表格
|
|
|
|
|
+watch(
|
|
|
|
|
+ () => props.treatment?.operates,
|
|
|
|
|
+ () => {
|
|
|
|
|
+ nextTick(() => {
|
|
|
|
|
+ operateGridApi?.grid?.reloadData?.(operatesData.value);
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ { deep: true, immediate: false },
|
|
|
|
|
+);
|
|
|
|
|
+
|
|
|
const formatCountdown = (sec: number) => {
|
|
const formatCountdown = (sec: number) => {
|
|
|
const m = Math.floor(sec / 60)
|
|
const m = Math.floor(sec / 60)
|
|
|
.toString()
|
|
.toString()
|
|
@@ -187,7 +200,7 @@ function toTsWithOffset(input?: Date | number | string) {
|
|
|
if (!input) return 0;
|
|
if (!input) return 0;
|
|
|
if (typeof input === 'number') return input;
|
|
if (typeof input === 'number') return input;
|
|
|
if (input instanceof Date) return input.getTime();
|
|
if (input instanceof Date) return input.getTime();
|
|
|
- // 兼容 2025-10-13T15:09:26.000+0800
|
|
|
|
|
|
|
+
|
|
|
const normalized = String(input).replace(/([+-]\d{2})(\d{2})$/, '$1:$2');
|
|
const normalized = String(input).replace(/([+-]\d{2})(\d{2})$/, '$1:$2');
|
|
|
const t = new Date(normalized).getTime();
|
|
const t = new Date(normalized).getTime();
|
|
|
return Number.isFinite(t) ? t : 0;
|
|
return Number.isFinite(t) ? t : 0;
|
|
@@ -225,8 +238,9 @@ const remainSeconds = computed(() => {
|
|
|
// 如果没有父组件倒计时,则使用本地计算
|
|
// 如果没有父组件倒计时,则使用本地计算
|
|
|
const d: any = treatmentDetail.value || {};
|
|
const d: any = treatmentDetail.value || {};
|
|
|
const cur: any = d.currentOperate || {};
|
|
const cur: any = d.currentOperate || {};
|
|
|
- const totalMin = cur.treatmentTime ?? d.treatmentTime;
|
|
|
|
|
- const upd = cur.updateTime ?? d.updateTime ?? cur.operateDate;
|
|
|
|
|
|
|
+ const totalMin = cur?.treatmentTime;
|
|
|
|
|
+ // const upd = cur.updateTime ?? d.updateTime ?? cur.operateDate;
|
|
|
|
|
+ const upd = cur?.operateDate;
|
|
|
const total = Math.max(0, Math.floor(Number(totalMin || 0) * 60));
|
|
const total = Math.max(0, Math.floor(Number(totalMin || 0) * 60));
|
|
|
const passed = diffSeconds(upd, nowTick.value);
|
|
const passed = diffSeconds(upd, nowTick.value);
|
|
|
return Math.max(0, total - passed);
|
|
return Math.max(0, total - passed);
|
|
@@ -235,6 +249,8 @@ const remainSeconds = computed(() => {
|
|
|
const treatmentStartTime = ref<null | number>(null);
|
|
const treatmentStartTime = ref<null | number>(null);
|
|
|
const isEndingTreatment = ref(false);
|
|
const isEndingTreatment = ref(false);
|
|
|
|
|
|
|
|
|
|
+// 是否编辑了治疗时间
|
|
|
|
|
+const isTreatmentTimeEdited = ref(false);
|
|
|
// 计算是否倒计时结束
|
|
// 计算是否倒计时结束
|
|
|
const isTimerFinished = computed(() => {
|
|
const isTimerFinished = computed(() => {
|
|
|
return isInProgress.value && remainSeconds.value <= 0;
|
|
return isInProgress.value && remainSeconds.value <= 0;
|
|
@@ -251,7 +267,7 @@ const startSchemas: VbenFormSchema[] = [
|
|
|
{
|
|
{
|
|
|
fieldName: 'treatmentImageUrl',
|
|
fieldName: 'treatmentImageUrl',
|
|
|
label: $t('treatment.detail.treatmentPhoto'),
|
|
label: $t('treatment.detail.treatmentPhoto'),
|
|
|
- component: 'Avatar',
|
|
|
|
|
|
|
+ component: 'AvatarTwo',
|
|
|
componentProps: {
|
|
componentProps: {
|
|
|
accept: 'image/*',
|
|
accept: 'image/*',
|
|
|
},
|
|
},
|
|
@@ -260,7 +276,13 @@ const startSchemas: VbenFormSchema[] = [
|
|
|
fieldName: 'treatmentTime',
|
|
fieldName: 'treatmentTime',
|
|
|
label: $t('treatment.detail.treatmentTime'),
|
|
label: $t('treatment.detail.treatmentTime'),
|
|
|
component: 'InputNumber',
|
|
component: 'InputNumber',
|
|
|
- componentProps: { min: 1, placeholder: $t('treatment.detail.input') },
|
|
|
|
|
|
|
+ componentProps: {
|
|
|
|
|
+ min: 1,
|
|
|
|
|
+ placeholder: $t('treatment.detail.input'),
|
|
|
|
|
+ onChange: () => {
|
|
|
|
|
+ isTreatmentTimeEdited.value = true;
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
suffix: $t('treatment.detail.minutes'),
|
|
suffix: $t('treatment.detail.minutes'),
|
|
|
rules: 'required',
|
|
rules: 'required',
|
|
|
},
|
|
},
|
|
@@ -280,25 +302,52 @@ const [Modal, modalApi] = useVbenModal({
|
|
|
const values = await formApi.getValues();
|
|
const values = await formApi.getValues();
|
|
|
const minutes = Number(values.treatmentTime);
|
|
const minutes = Number(values.treatmentTime);
|
|
|
|
|
|
|
|
|
|
+ if (
|
|
|
|
|
+ values.treatmentImageUrl === undefined ||
|
|
|
|
|
+ values.treatmentImageUrl === null
|
|
|
|
|
+ ) {
|
|
|
|
|
+ values.treatmentImageUrl = '';
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
try {
|
|
try {
|
|
|
|
|
+ // 治疗中
|
|
|
if (treatmentDetail.value.itemState === 1) {
|
|
if (treatmentDetail.value.itemState === 1) {
|
|
|
values.id = treatmentDetail.value.currentOperate.id;
|
|
values.id = treatmentDetail.value.currentOperate.id;
|
|
|
|
|
+ if (!isTreatmentTimeEdited.value) {
|
|
|
|
|
+ // 说明治疗中的时候编辑了时间
|
|
|
|
|
+ values.treatmentTime = '';
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
values.recordId = treatmentDetail.value.id;
|
|
values.recordId = treatmentDetail.value.id;
|
|
|
await saveTreatmentMethod(values);
|
|
await saveTreatmentMethod(values);
|
|
|
notification.success({ message: $t('treatment.detail.saveSuccess') });
|
|
notification.success({ message: $t('treatment.detail.saveSuccess') });
|
|
|
|
|
|
|
|
- // 只有在保存成功后才设置治疗进行中状态
|
|
|
|
|
- // 这样可以避免在数据未更新时立即触发倒计时结束
|
|
|
|
|
- isInProgress.value = true;
|
|
|
|
|
- treatmentStartTime.value = Date.now();
|
|
|
|
|
|
|
+ // 判断是否需要重新计时
|
|
|
|
|
+ const isCurrentlyInProgress = treatmentDetail.value.itemState === 1;
|
|
|
|
|
|
|
|
- // 触发本地计时
|
|
|
|
|
- emit('startTreatment', {
|
|
|
|
|
- treatmentId: treatmentDetail.value.id,
|
|
|
|
|
- minutes: Math.max(1, minutes),
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ if (!isCurrentlyInProgress) {
|
|
|
|
|
+ // 治疗未开始,需要重新计时
|
|
|
|
|
+ isInProgress.value = true;
|
|
|
|
|
+ treatmentStartTime.value = Date.now();
|
|
|
|
|
+
|
|
|
|
|
+ // 触发本地计时
|
|
|
|
|
+ emit('startTreatment', {
|
|
|
|
|
+ treatmentId: treatmentDetail.value.id,
|
|
|
|
|
+ minutes: Math.max(1, minutes),
|
|
|
|
|
+ });
|
|
|
|
|
+ } else if (isTreatmentTimeEdited.value) {
|
|
|
|
|
+ // 治疗进行中且治疗时间被编辑了,需要重新计时
|
|
|
|
|
+ isInProgress.value = true;
|
|
|
|
|
+ treatmentStartTime.value = Date.now();
|
|
|
|
|
+
|
|
|
|
|
+ // 触发本地计时
|
|
|
|
|
+ emit('startTreatment', {
|
|
|
|
|
+ treatmentId: treatmentDetail.value.id,
|
|
|
|
|
+ minutes: Math.max(1, minutes),
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ // 如果只是修改备注或照片,不触发重新计时
|
|
|
|
|
|
|
|
// 触发刷新数据事件,更新标签页计数
|
|
// 触发刷新数据事件,更新标签页计数
|
|
|
emit('refreshData', { treatmentId: treatmentDetail.value.id });
|
|
emit('refreshData', { treatmentId: treatmentDetail.value.id });
|
|
@@ -326,6 +375,9 @@ const [AcupointModal, acupointModalApi] = useVbenModal({
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
const handleStartTreatment = (treatment: TreatmentModel.TreatmentDetail) => {
|
|
const handleStartTreatment = (treatment: TreatmentModel.TreatmentDetail) => {
|
|
|
|
|
+ // 重置编辑标记
|
|
|
|
|
+ isTreatmentTimeEdited.value = false;
|
|
|
|
|
+
|
|
|
// 基础默认值
|
|
// 基础默认值
|
|
|
const baseValues: Record<string, any> = {
|
|
const baseValues: Record<string, any> = {
|
|
|
recordId: treatment.id,
|
|
recordId: treatment.id,
|
|
@@ -336,6 +388,7 @@ const handleStartTreatment = (treatment: TreatmentModel.TreatmentDetail) => {
|
|
|
|
|
|
|
|
// 若处于治疗中,则回填当前操作项数据,供用户修改
|
|
// 若处于治疗中,则回填当前操作项数据,供用户修改
|
|
|
const maybeCurrent = (treatmentDetail.value as any)?.currentOperate;
|
|
const maybeCurrent = (treatmentDetail.value as any)?.currentOperate;
|
|
|
|
|
+ console.log(maybeCurrent, 'maybeCurrent');
|
|
|
if (treatmentDetail.value?.itemState === 1 && maybeCurrent) {
|
|
if (treatmentDetail.value?.itemState === 1 && maybeCurrent) {
|
|
|
formApi.setValues({
|
|
formApi.setValues({
|
|
|
...baseValues,
|
|
...baseValues,
|
|
@@ -380,12 +433,10 @@ watch(
|
|
|
() => isTimerFinished.value,
|
|
() => isTimerFinished.value,
|
|
|
async (finished) => {
|
|
async (finished) => {
|
|
|
if (!finished) return;
|
|
if (!finished) return;
|
|
|
-
|
|
|
|
|
// 防止重复调用
|
|
// 防止重复调用
|
|
|
if (isEndingTreatment.value) {
|
|
if (isEndingTreatment.value) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
isEndingTreatment.value = true;
|
|
isEndingTreatment.value = true;
|
|
|
try {
|
|
try {
|
|
|
await endTreatmentMethod([treatmentDetail.value.id]);
|
|
await endTreatmentMethod([treatmentDetail.value.id]);
|
|
@@ -408,12 +459,10 @@ const handleAcupointClick = async (
|
|
|
case 1: {
|
|
case 1: {
|
|
|
try {
|
|
try {
|
|
|
// 获取穴位
|
|
// 获取穴位
|
|
|
- const detail = await getAcupointDetailMethod(acupoint.id);
|
|
|
|
|
|
|
+ const detail = await getAcupointDetailMethod(acupoint.knowledgeId);
|
|
|
selectedAcupoint.value = { ...acupoint, ...detail } as any;
|
|
selectedAcupoint.value = { ...acupoint, ...detail } as any;
|
|
|
- } catch {
|
|
|
|
|
- notification.error({
|
|
|
|
|
- message: $t('treatment.detail.getAcupointDetailFailure'),
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error('获取穴位详情失败:', error);
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
@@ -422,10 +471,8 @@ const handleAcupointClick = async (
|
|
|
try {
|
|
try {
|
|
|
const detail = await getMeridianDetailMethod(acupoint.id);
|
|
const detail = await getMeridianDetailMethod(acupoint.id);
|
|
|
selectedAcupoint.value = { ...acupoint, ...detail } as any;
|
|
selectedAcupoint.value = { ...acupoint, ...detail } as any;
|
|
|
- } catch {
|
|
|
|
|
- notification.error({
|
|
|
|
|
- message: $t('treatment.detail.getMeridianDetailFailure'),
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error('获取经络详情失败:', error);
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|