first commit
This commit is contained in:
@@ -0,0 +1,970 @@
|
||||
// pages/surgery/create/index.js
|
||||
const { surgeryApi, doctorApi, deviceApi } = require("../../../utils/api");
|
||||
const dayjs = require("../../../miniprogram_npm/dayjs/index");
|
||||
|
||||
Page({
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
loading: true, // 页面加载状态
|
||||
submitting: false, // 表单提交状态
|
||||
isEditMode: false, // 是否为编辑模式
|
||||
surgeryId: null, // 编辑模式下的手术ID
|
||||
|
||||
// 表单数据
|
||||
formData: {
|
||||
surgery_id: "", // 手术编号
|
||||
surgery_name: "", // 手术名称
|
||||
patient: "", // 患者姓名
|
||||
surgery_time: "", // 完整手术时间戳
|
||||
surgery_time_display: "", // 显示的完整手术时间
|
||||
},
|
||||
|
||||
// 主刀医生相关
|
||||
doctors: [], // 医生列表
|
||||
selectedDoctor: null, // 已选择的医生
|
||||
selectedDoctorValue: "", // 级联选择器选中的医生值
|
||||
doctorSelectorVisible: false, // 医生选择器弹窗可见性
|
||||
departmentDoctors: [], // 按科室分组的医生列表
|
||||
activeTabIndex: 0, // 当前激活的科室标签索引
|
||||
|
||||
// 设备相关
|
||||
devices: [], // 设备列表
|
||||
deviceTree: [], // 树形结构的设备数据
|
||||
selectedSubDevices: [], // 已选择的设备
|
||||
selectedDeviceValues: [], // 已选择的设备值数组
|
||||
selectedDeviceValue: "", // 当前选中的设备值
|
||||
deviceSelectorVisible: false, // 设备选择器弹窗可见性
|
||||
|
||||
// 新增:设备状态追踪
|
||||
deviceStatus: {}, // 记录设备状态 {id: {status: 0/1, inUse: bool}}
|
||||
|
||||
// TreeSelect 组件所需的自定义键名配置
|
||||
treeSelectKeys: {
|
||||
label: "label",
|
||||
value: "value",
|
||||
children: "children",
|
||||
},
|
||||
|
||||
// 级联选择器
|
||||
cascaderVisible: false, // 级联选择器可见性
|
||||
doctorCascaderOptions: [], // 医生级联选择器选项
|
||||
|
||||
// 日期时间选择器相关
|
||||
dateTimePickerVisible: false, // 日期时间选择器可见性
|
||||
currentDate: "", // 当前日期时间用于默认值
|
||||
minDate: "", // 新增:允许的最小日期时间(当前时间)
|
||||
|
||||
// 设备时间选择器相关
|
||||
deviceStartTimePickerVisible: false, // 设备开始时间选择器可见性
|
||||
deviceEndTimePickerVisible: false, // 设备结束时间选择器可见性
|
||||
currentDeviceTimeIndex: -1, // 当前正在设置时间的设备索引
|
||||
currentDeviceStartTime: "", // 当前设备开始时间
|
||||
currentDeviceEndTime: "", // 当前设备结束时间
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
// 设置当前时间作为默认值和最小时间限制
|
||||
this.setCurrentDateTime();
|
||||
// 手术记录回显
|
||||
let formData = wx.getStorageSync("surgery_formData")
|
||||
let that = this
|
||||
if (formData) {
|
||||
wx.showModal({
|
||||
title: "是否显示未保存记录 ",
|
||||
cancelText: "否",
|
||||
confirmText: "是",
|
||||
success (res) {
|
||||
if (res.confirm) {
|
||||
that.setData({
|
||||
formData: {...formData},
|
||||
selectedDoctor: formData.doctor
|
||||
})
|
||||
} else if (res.cancel) {
|
||||
wx.removeStorageSync('surgery_formData')
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
// 检查是否为编辑模式
|
||||
if (options && options.id && options.mode === "edit") {
|
||||
const surgeryId = options.id;
|
||||
this.setData({
|
||||
isEditMode: true,
|
||||
surgeryId: surgeryId,
|
||||
});
|
||||
wx.setNavigationBarTitle({
|
||||
title: "编辑手术记录",
|
||||
});
|
||||
} else {
|
||||
wx.setNavigationBarTitle({
|
||||
title: "创建手术记录",
|
||||
});
|
||||
}
|
||||
|
||||
// 并行加载医生和设备数据
|
||||
Promise.all([this.fetchDoctors(), this.fetchDevices()])
|
||||
.then(() => {
|
||||
// 如果是编辑模式,加载现有手术数据
|
||||
if (this.data.isEditMode && this.data.surgeryId) {
|
||||
this.fetchSurgeryDetails(this.data.surgeryId);
|
||||
} else {
|
||||
this.setData({ loading: false });
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
this.setData({ loading: false });
|
||||
});
|
||||
},
|
||||
/*
|
||||
* 保存表单数据到本地
|
||||
*/
|
||||
saveData (doctor) {
|
||||
let formData = {...this.data.formData}
|
||||
if (doctor) formData.doctor = doctor
|
||||
wx.setStorageSync("surgery_formData", formData)
|
||||
},
|
||||
/**
|
||||
* 获取手术详情
|
||||
*/
|
||||
async fetchSurgeryDetails(surgeryId) {
|
||||
try {
|
||||
const res = await surgeryApi.getSurgeryById(surgeryId);
|
||||
|
||||
const surgery = res.data;
|
||||
if (!surgery) {
|
||||
throw new Error("未找到手术记录");
|
||||
}
|
||||
|
||||
// 格式化日期显示 - 使用安全的日期解析
|
||||
const surgeryTime = this.safeParseDate(surgery.surgery_time);
|
||||
const timestamp = surgeryTime.getTime();
|
||||
const formattedDateTime = dayjs(surgeryTime).format("YYYY年MM月DD日 HH:mm:ss");
|
||||
|
||||
// 更新表单数据
|
||||
this.setData({
|
||||
formData: {
|
||||
surgery_id: surgery.surgery_id || "",
|
||||
surgery_name: surgery.surgery_name || "",
|
||||
patient: surgery.patient || "",
|
||||
surgery_time: timestamp,
|
||||
surgery_time_display: formattedDateTime,
|
||||
},
|
||||
});
|
||||
|
||||
// 设置选中的医生
|
||||
if (surgery.doctor) {
|
||||
|
||||
// 检查选项中是否包含当前医生
|
||||
const targetDoctorId = surgery.doctor.id;
|
||||
const findDoctorInOptions = (options) => {
|
||||
for (const dept of options) {
|
||||
for (const doctor of dept.children || []) {
|
||||
if (doctor.doctor && doctor.doctor.id === targetDoctorId) {
|
||||
return doctor;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const foundDoctor = findDoctorInOptions(this.data.doctorCascaderOptions);
|
||||
|
||||
this.setSelectedDoctor(surgery.doctor);
|
||||
} else {
|
||||
// 手术数据中没有医生信息
|
||||
}
|
||||
|
||||
// 设置选中的设备
|
||||
if (surgery.surgerySubDevices && Array.isArray(surgery.surgerySubDevices)) {
|
||||
const selectedDevices = [];
|
||||
|
||||
surgery.surgerySubDevices.forEach((surgerySubDevice) => {
|
||||
if (surgerySubDevice.subDevice) {
|
||||
// 为子设备添加设备名称和时间信息
|
||||
const subDevice = {
|
||||
...surgerySubDevice.subDevice,
|
||||
device_name: surgerySubDevice.subDevice.device ? surgerySubDevice.subDevice.device.name : "未知设备",
|
||||
// 添加设备时间信息
|
||||
startTime: surgerySubDevice.start_time || null,
|
||||
endTime: surgerySubDevice.end_time || null,
|
||||
startTimeDisplay: surgerySubDevice.start_time ? dayjs(surgerySubDevice.start_time).format('YYYY-MM-DD HH:mm') : '点击设置',
|
||||
endTimeDisplay: surgerySubDevice.end_time ? dayjs(surgerySubDevice.end_time).format('YYYY-MM-DD HH:mm') : '点击设置',
|
||||
};
|
||||
|
||||
selectedDevices.push(subDevice);
|
||||
|
||||
// 更新设备状态
|
||||
if (this.data.deviceStatus[subDevice.id]) {
|
||||
const updatedDeviceStatus = { ...this.data.deviceStatus };
|
||||
updatedDeviceStatus[subDevice.id].inUse = true;
|
||||
this.setData({
|
||||
deviceStatus: updatedDeviceStatus,
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.setData({
|
||||
selectedSubDevices: selectedDevices,
|
||||
});
|
||||
} else {
|
||||
// 手术数据中没有设备信息
|
||||
}
|
||||
|
||||
this.setData({ loading: false });
|
||||
} catch (error) {
|
||||
this.showMessage("获取手术详情失败,请返回重试", "error");
|
||||
this.setData({ loading: false });
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 根据医生数据设置选中的医生
|
||||
*/
|
||||
setSelectedDoctor(doctor) {
|
||||
if (!doctor || !doctor.id) return;
|
||||
|
||||
// 查找并设置医生级联选择器的值
|
||||
const doctorValue = `doctor_${doctor.id}`;
|
||||
|
||||
this.setData({
|
||||
selectedDoctor: doctor,
|
||||
selectedDoctorValue: doctorValue,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 安全的日期解析函数
|
||||
*/
|
||||
safeParseDate(dateStr) {
|
||||
if (!dateStr) return new Date();
|
||||
|
||||
// 尝试不同的日期格式
|
||||
const formats = [
|
||||
dateStr, // 原始格式
|
||||
dateStr.replace(' ', 'T'), // ISO格式
|
||||
dateStr.replace(' ', 'T') + '+08:00', // 带时区的ISO格式
|
||||
new Date(dateStr) // 直接解析
|
||||
];
|
||||
|
||||
for (let i = 0; i < formats.length; i++) {
|
||||
try {
|
||||
const date = typeof formats[i] === 'string' ? new Date(formats[i]) : formats[i];
|
||||
if (!isNaN(date.getTime())) {
|
||||
return date;
|
||||
}
|
||||
} catch (e) {
|
||||
// 日期格式解析失败
|
||||
}
|
||||
}
|
||||
|
||||
// 如果都失败了,返回当前时间
|
||||
return new Date();
|
||||
},
|
||||
|
||||
/**
|
||||
* 设置当前日期时间作为默认值和最小时间限制
|
||||
*/
|
||||
setCurrentDateTime() {
|
||||
const now = new Date();
|
||||
const formattedDateTime = dayjs(now).format("YYYY-MM-DD HH:mm:ss");
|
||||
|
||||
this.setData({
|
||||
currentDate: formattedDateTime,
|
||||
minDate: formattedDateTime, // 设置最小时间为当前时间
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取医生列表
|
||||
*/
|
||||
async fetchDoctors() {
|
||||
try {
|
||||
// 调用API获取医生列表数据
|
||||
const res = await doctorApi.getDoctors();
|
||||
|
||||
// 后端返回的是分页格式:{list: [...], total: ...}
|
||||
const doctorData = res.data;
|
||||
if (!doctorData || !doctorData.list || !Array.isArray(doctorData.list)) {
|
||||
throw new Error("获取医生数据格式错误");
|
||||
}
|
||||
|
||||
// 过滤确保医生数据完整(包含科室信息)
|
||||
const validDoctors = doctorData.list.filter((doctor) => doctor && doctor.id && doctor.name && doctor.department && doctor.department.name);
|
||||
|
||||
// 按科室分组医生,为级联选择器准备数据
|
||||
const departmentsMap = new Map();
|
||||
validDoctors.forEach((doctor) => {
|
||||
const deptId = doctor.department.id;
|
||||
const deptName = doctor.department.name;
|
||||
|
||||
if (!departmentsMap.has(deptId)) {
|
||||
departmentsMap.set(deptId, {
|
||||
label: deptName,
|
||||
value: `dept_${deptId}`,
|
||||
children: [],
|
||||
});
|
||||
}
|
||||
|
||||
// 将医生添加到对应科室的children中
|
||||
departmentsMap.get(deptId).children.push({
|
||||
label: doctor.name,
|
||||
value: `doctor_${doctor.id}`,
|
||||
// 保存原始医生对象用于选中后的数据处理
|
||||
doctor: doctor,
|
||||
});
|
||||
});
|
||||
|
||||
// 将Map转换为数组
|
||||
const doctorCascaderOptions = Array.from(departmentsMap.values());
|
||||
|
||||
this.setData({
|
||||
loading: false,
|
||||
doctors: validDoctors,
|
||||
doctorCascaderOptions,
|
||||
});
|
||||
} catch (error) {
|
||||
this.setData({ loading: false });
|
||||
this.showMessage("获取医生列表失败,请重试", "error");
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取设备数据并构建树形结构
|
||||
*/
|
||||
async fetchDevices() {
|
||||
try {
|
||||
// 调用API获取所有设备数据
|
||||
const res = await deviceApi.getDevices();
|
||||
|
||||
// 后端返回的是分页格式:{list: [...], total: ...}
|
||||
const deviceData = res.data;
|
||||
if (!deviceData || !deviceData.list || !Array.isArray(deviceData.list)) {
|
||||
throw new Error("获取设备数据格式错误");
|
||||
}
|
||||
|
||||
const devices = deviceData.list;
|
||||
|
||||
// 获取所有子设备
|
||||
const subDevicesRes = await deviceApi.getAllSubDevices();
|
||||
const subDevicesData = subDevicesRes.data;
|
||||
|
||||
// 后端返回的是分页格式:{list: [...], total: ...}
|
||||
const subDevices = subDevicesData.list || [];
|
||||
|
||||
// 构建设备状态字典
|
||||
const deviceStatus = {};
|
||||
subDevices.forEach((subDevice) => {
|
||||
deviceStatus[subDevice.id] = {
|
||||
status: subDevice.status || 0, // 0表示可用,1表示占用
|
||||
inUse: false, // 当前表单中是否被选择
|
||||
};
|
||||
});
|
||||
|
||||
// 构建树形结构数据
|
||||
const deviceTree = devices.map((device) => {
|
||||
// 找出该设备下的所有子设备
|
||||
const children = subDevices
|
||||
.filter((sub) => sub.device_id === device.id)
|
||||
.map((sub) => {
|
||||
const subDeviceName = sub.name || `设备${sub.id}`;
|
||||
const statusText = sub.status === 1 ? " (占用中)" : "";
|
||||
return {
|
||||
label: `${subDeviceName}${statusText}`, // 显示占用状态
|
||||
value: `subdevice_${sub.id}`,
|
||||
// 移除基于状态的禁用设置,允许选择占用中的设备
|
||||
// 保存完整的子设备数据
|
||||
subDevice: {
|
||||
...sub,
|
||||
name: sub.name || `设备${sub.id}`, // 确保有名称
|
||||
device_name: device.name, // 添加设备名称,方便显示
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
label: device.name,
|
||||
value: `device_${device.id}`,
|
||||
// 只有当没有子设备时才禁用主设备选择,不再因子设备被占用而禁用
|
||||
disabled: children.length === 0,
|
||||
children,
|
||||
};
|
||||
});
|
||||
|
||||
this.setData({
|
||||
devices,
|
||||
deviceTree,
|
||||
deviceStatus,
|
||||
});
|
||||
} catch (error) {
|
||||
this.showMessage("获取设备数据失败,请重试", "warning");
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 处理输入框内容变更
|
||||
*/
|
||||
onInputChange(e) {
|
||||
const { field } = e.currentTarget.dataset;
|
||||
const { value } = e.detail;
|
||||
this.setData({
|
||||
[`formData.${field}`]: value,
|
||||
});
|
||||
this.saveData()
|
||||
},
|
||||
|
||||
/**
|
||||
* 显示日期时间选择器
|
||||
*/
|
||||
showDateTimePicker() {
|
||||
this.setData({
|
||||
dateTimePickerVisible: true,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 日期时间选择器确认事件
|
||||
*/
|
||||
onDateTimeConfirm(e) {
|
||||
// 使用 dayjs 格式化日期时间显示
|
||||
const formattedDateTime = dayjs(e.detail.value).format("YYYY年MM月DD日 HH:mm:ss");
|
||||
const timestamp = new Date(e.detail.value).getTime();
|
||||
|
||||
this.setData({
|
||||
"formData.surgery_time": timestamp,
|
||||
"formData.surgery_time_display": formattedDateTime,
|
||||
dateTimePickerVisible: false,
|
||||
});
|
||||
this.saveData()
|
||||
},
|
||||
|
||||
/**
|
||||
* 日期时间选择器取消事件
|
||||
*/
|
||||
onDateTimeCancel() {
|
||||
this.setData({
|
||||
dateTimePickerVisible: false,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 日期时间选择器变化事件
|
||||
*/
|
||||
onDateTimeChange(e) {
|
||||
// 日期时间选择器变化事件
|
||||
},
|
||||
|
||||
/**
|
||||
* 日期时间选择器选择事件
|
||||
*/
|
||||
onDateTimePick(e) {
|
||||
// 日期时间选择器选择事件
|
||||
},
|
||||
|
||||
/**
|
||||
* 显示医生选择器弹窗 - 使用级联选择器选项卡风格
|
||||
*/
|
||||
showDoctorSelector() {
|
||||
if (this.data.doctorCascaderOptions.length === 0) {
|
||||
this.showMessage("暂无可选医生", "warning");
|
||||
return;
|
||||
}
|
||||
|
||||
this.setData({
|
||||
doctorSelectorVisible: true,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 级联选择器关闭事件
|
||||
*/
|
||||
onDoctorCascaderClose(e) {
|
||||
this.setData({
|
||||
doctorSelectorVisible: false,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 级联选择器变更事件
|
||||
*/
|
||||
onDoctorCascaderChange(e) {
|
||||
const { value, selectedOptions } = e.detail;
|
||||
|
||||
if (value && value.startsWith("doctor_")) {
|
||||
// 获取医生 ID
|
||||
const doctorId = Number(value.split("_")[1]);
|
||||
|
||||
// 查找选中的医生数据
|
||||
const findDoctor = (options, doctorId) => {
|
||||
for (const dept of options) {
|
||||
for (const doctorOption of dept.children || []) {
|
||||
if (doctorOption.doctor && doctorOption.doctor.id === doctorId) {
|
||||
return doctorOption.doctor;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const selectedDoctor = findDoctor(this.data.doctorCascaderOptions, doctorId);
|
||||
|
||||
if (selectedDoctor) {
|
||||
this.setData({
|
||||
selectedDoctor,
|
||||
selectedDoctorValue: value,
|
||||
doctorSelectorVisible: false, // 选择后自动关闭选择器
|
||||
});
|
||||
this.showMessage(`已选择医生:${selectedDoctor.name}(${selectedDoctor.department.name})`, "success");
|
||||
}
|
||||
this.saveData(selectedDoctor)
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 级联选择器选择事件
|
||||
*/
|
||||
onDoctorCascaderPick(e) {
|
||||
// 级联选择器选择事件
|
||||
},
|
||||
|
||||
/**
|
||||
* 处理设备选择变更事件
|
||||
*/
|
||||
onDeviceChange(e) {
|
||||
const { value } = e.detail;
|
||||
|
||||
// 找出选中的子设备
|
||||
const selectedSubDevices = [];
|
||||
const findSubDevices = (tree, values) => {
|
||||
if (!tree || !values) return;
|
||||
|
||||
for (const node of tree) {
|
||||
if (node.children) {
|
||||
for (const child of node.children) {
|
||||
if (values.includes(child.value) && child.subDevice) {
|
||||
selectedSubDevices.push(child.subDevice);
|
||||
}
|
||||
}
|
||||
|
||||
// 递归检查子节点
|
||||
findSubDevices(node.children, values);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
findSubDevices(this.data.deviceTree, value);
|
||||
|
||||
this.setData({
|
||||
selectedDeviceValues: value,
|
||||
selectedSubDevices,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 显示设备选择器
|
||||
*/
|
||||
showDeviceSelector() {
|
||||
if (this.data.deviceTree.length === 0) {
|
||||
this.showMessage("暂无可选设备", "warning");
|
||||
return;
|
||||
}
|
||||
|
||||
this.setData({
|
||||
deviceSelectorVisible: true,
|
||||
selectedDeviceValue: "", // 重置选择值,确保每次打开时都从顶层开始选择
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 设备选择器关闭事件
|
||||
*/
|
||||
onDeviceCascaderClose(e) {
|
||||
this.setData({
|
||||
deviceSelectorVisible: false,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 设备级联选择器变更事件
|
||||
*/
|
||||
onDeviceCascaderChange(e) {
|
||||
const { value, selectedOptions } = e.detail;
|
||||
|
||||
if (value && value.startsWith("subdevice_")) {
|
||||
// 获取子设备 ID
|
||||
const subDeviceId = Number(value.split("_")[1]);
|
||||
|
||||
// 查找选中的子设备数据
|
||||
const findSubDevice = (options, subDeviceId) => {
|
||||
for (const device of options) {
|
||||
for (const subDeviceOption of device.children || []) {
|
||||
if (subDeviceOption.subDevice && subDeviceOption.subDevice.id === subDeviceId) {
|
||||
return subDeviceOption.subDevice;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const selectedSubDevice = findSubDevice(this.data.deviceTree, subDeviceId);
|
||||
|
||||
if (selectedSubDevice) {
|
||||
|
||||
// 删除设备占用的判断,允许选择任何设备
|
||||
// 原有代码:
|
||||
// if (selectedSubDevice.status === 1) {
|
||||
// this.showMessage(`设备 ${selectedSubDevice.sub_device_name} 当前已占用,请选择其他设备`, "warning");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// 检查是否已经选择过该设备
|
||||
const existingDeviceIndex = this.data.selectedSubDevices.findIndex((device) => device.id === selectedSubDevice.id);
|
||||
|
||||
if (existingDeviceIndex === -1) {
|
||||
// 如果是新设备,添加到已选择的设备列表中
|
||||
const updatedDevices = [...this.data.selectedSubDevices, {
|
||||
...selectedSubDevice,
|
||||
startTime: this.data.formData.surgery_time || new Date().getTime(),
|
||||
startTimeDisplay: this.data.formData.surgery_time_display || dayjs().format("YYYY-MM-DD HH:mm:ss"),
|
||||
endTime: null,
|
||||
endTimeDisplay: "未设置",
|
||||
}];
|
||||
|
||||
// 更新设备状态为已选择
|
||||
const updatedDeviceStatus = { ...this.data.deviceStatus };
|
||||
updatedDeviceStatus[selectedSubDevice.id].inUse = true;
|
||||
|
||||
this.setData({
|
||||
selectedSubDevices: updatedDevices,
|
||||
selectedDeviceValue: value,
|
||||
deviceSelectorVisible: false,
|
||||
deviceStatus: updatedDeviceStatus,
|
||||
});
|
||||
|
||||
// 添加后延迟提示,确保界面已更新
|
||||
setTimeout(() => {
|
||||
this.showMessage(`已添加设备: ${selectedSubDevice.device_name}-${selectedSubDevice.name}`, "success");
|
||||
}, 100);
|
||||
} else {
|
||||
this.showMessage("该设备已被选择", "warning");
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 设备级联选择器选择事件
|
||||
*/
|
||||
onDeviceCascaderPick(e) {
|
||||
// 设备级联选择器选择事件
|
||||
},
|
||||
|
||||
/**
|
||||
* 显示设备开始时间选择器
|
||||
*/
|
||||
showDeviceStartTimePicker(e) {
|
||||
const { index } = e.currentTarget.dataset;
|
||||
const device = this.data.selectedSubDevices[index];
|
||||
|
||||
this.setData({
|
||||
currentDeviceTimeIndex: index,
|
||||
currentDeviceStartTime: device.startTime || this.data.formData.surgery_time || this.data.currentDate,
|
||||
deviceStartTimePickerVisible: true,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 显示设备结束时间选择器
|
||||
*/
|
||||
showDeviceEndTimePicker(e) {
|
||||
const { index } = e.currentTarget.dataset;
|
||||
const device = this.data.selectedSubDevices[index];
|
||||
|
||||
this.setData({
|
||||
currentDeviceTimeIndex: index,
|
||||
currentDeviceEndTime: device.endTime || this.data.currentDate,
|
||||
deviceEndTimePickerVisible: true,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 设备开始时间选择器确认事件
|
||||
*/
|
||||
onDeviceStartTimeConfirm(e) {
|
||||
const { currentDeviceTimeIndex } = this.data;
|
||||
|
||||
if (currentDeviceTimeIndex === -1) return;
|
||||
|
||||
// 格式化时间显示
|
||||
const formattedDateTime = dayjs(e.detail.value).format("YYYY-MM-DD HH:mm:ss");
|
||||
const timestamp = new Date(e.detail.value).getTime();
|
||||
|
||||
// 更新设备时间信息
|
||||
const updatedDevices = [...this.data.selectedSubDevices];
|
||||
updatedDevices[currentDeviceTimeIndex] = {
|
||||
...updatedDevices[currentDeviceTimeIndex],
|
||||
startTime: timestamp,
|
||||
startTimeDisplay: formattedDateTime,
|
||||
};
|
||||
|
||||
this.setData({
|
||||
selectedSubDevices: updatedDevices,
|
||||
deviceStartTimePickerVisible: false,
|
||||
currentDeviceTimeIndex: -1,
|
||||
});
|
||||
|
||||
this.showMessage(`设备开始时间已设置: ${formattedDateTime}`, "success");
|
||||
},
|
||||
|
||||
/**
|
||||
* 设备开始时间选择器取消事件
|
||||
*/
|
||||
onDeviceStartTimeCancel() {
|
||||
this.setData({
|
||||
deviceStartTimePickerVisible: false,
|
||||
currentDeviceTimeIndex: -1,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 设备结束时间选择器确认事件
|
||||
*/
|
||||
onDeviceEndTimeConfirm(e) {
|
||||
const { currentDeviceTimeIndex } = this.data;
|
||||
|
||||
if (currentDeviceTimeIndex === -1) return;
|
||||
|
||||
// 格式化时间显示
|
||||
const formattedDateTime = dayjs(e.detail.value).format("YYYY-MM-DD HH:mm:ss");
|
||||
const timestamp = new Date(e.detail.value).getTime();
|
||||
|
||||
// 更新设备时间信息
|
||||
const updatedDevices = [...this.data.selectedSubDevices];
|
||||
updatedDevices[currentDeviceTimeIndex] = {
|
||||
...updatedDevices[currentDeviceTimeIndex],
|
||||
endTime: timestamp,
|
||||
endTimeDisplay: formattedDateTime,
|
||||
};
|
||||
|
||||
this.setData({
|
||||
selectedSubDevices: updatedDevices,
|
||||
deviceEndTimePickerVisible: false,
|
||||
currentDeviceTimeIndex: -1,
|
||||
});
|
||||
|
||||
this.showMessage(`设备结束时间已设置: ${formattedDateTime}`, "success");
|
||||
},
|
||||
|
||||
/**
|
||||
* 设备结束时间选择器取消事件
|
||||
*/
|
||||
onDeviceEndTimeCancel() {
|
||||
this.setData({
|
||||
deviceEndTimePickerVisible: false,
|
||||
currentDeviceTimeIndex: -1,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 删除已选择的设备
|
||||
*/
|
||||
removeDevice(e) {
|
||||
const { index } = e.currentTarget.dataset;
|
||||
const removedDevice = this.data.selectedSubDevices[index];
|
||||
|
||||
const newSelectedDevices = [...this.data.selectedSubDevices];
|
||||
newSelectedDevices.splice(index, 1);
|
||||
|
||||
// 更新设备状态为未选择
|
||||
const updatedDeviceStatus = { ...this.data.deviceStatus };
|
||||
updatedDeviceStatus[removedDevice.id].inUse = false;
|
||||
|
||||
this.setData({
|
||||
selectedSubDevices: newSelectedDevices,
|
||||
deviceStatus: updatedDeviceStatus,
|
||||
});
|
||||
|
||||
this.showMessage(`已删除设备: ${removedDevice.device_name}-${removedDevice.name}`, "warning");
|
||||
},
|
||||
|
||||
/**
|
||||
* 验证表单数据
|
||||
*/
|
||||
validateForm() {
|
||||
const { surgery_id, surgery_name, patient, surgery_time } = this.data.formData;
|
||||
const { selectedDoctor } = this.data;
|
||||
console.log(1, surgery_id);
|
||||
|
||||
// 验证手术编号
|
||||
if (!surgery_id) {
|
||||
this.showMessage("请填写手术编号", "error");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (typeof surgery_id !== "string" || surgery_id.trim().length < 3 || surgery_id.trim().length > 50) {
|
||||
this.showMessage("手术编号格式不正确,长度应在3-50个字符之间", "error");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 验证手术名称
|
||||
if (!surgery_name) {
|
||||
this.showMessage("请填写手术名称", "error");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 验证患者姓名
|
||||
if (!patient) {
|
||||
this.showMessage("请填写患者姓名", "error");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 验证手术时间
|
||||
if (!surgery_time) {
|
||||
this.showMessage("请选择手术时间", "error");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 验证医生选择
|
||||
if (!selectedDoctor) {
|
||||
this.showMessage("请选择主刀医生", "error");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* 处理表单提交
|
||||
*/
|
||||
async handleSubmit() {
|
||||
if (!this.validateForm()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.setData({ submitting: true });
|
||||
|
||||
try {
|
||||
const { surgery_id, surgery_name, patient, surgery_time } = this.data.formData;
|
||||
const { selectedDoctor, selectedSubDevices } = this.data;
|
||||
|
||||
// 将时间转换为数据库需要的格式(YYYY-MM-DD HH:mm:ss)
|
||||
const formattedDateTime = dayjs(surgery_time).format('YYYY-MM-DD HH:mm:ss');
|
||||
|
||||
// 构建提交数据,确保与网页端数据结构一致
|
||||
const submitData = {
|
||||
surgery_id, // 手术编号
|
||||
surgery_name, // 手术名称
|
||||
surgery_time: formattedDateTime, // 手术时间(本地时间格式)
|
||||
surgery_doctor_id: selectedDoctor.id, // 主刀医生ID
|
||||
patient, // 患者姓名
|
||||
sub_device_ids: selectedSubDevices.map((device) => device.id), // 使用设备ID列表
|
||||
// 添加设备时间信息
|
||||
device_times: selectedSubDevices.map((device) => ({
|
||||
sub_device_id: device.id,
|
||||
start_time: device.startTime ? dayjs(device.startTime).format('YYYY-MM-DD HH:mm:ss') : null,
|
||||
end_time: device.endTime ? dayjs(device.endTime).format('YYYY-MM-DD HH:mm:ss') : null,
|
||||
})),
|
||||
};
|
||||
let res;
|
||||
if (this.data.isEditMode) {
|
||||
// 调用更新手术API
|
||||
res = await surgeryApi.updateSurgery(this.data.surgeryId, submitData);
|
||||
this.showMessage("更新手术记录成功", "success");
|
||||
} else {
|
||||
// 调用创建手术API
|
||||
res = await surgeryApi.createSurgery(submitData);
|
||||
this.showMessage("创建手术记录成功", "success");
|
||||
}
|
||||
|
||||
// 延迟返回上一页,让用户看到成功提示
|
||||
setTimeout(() => {
|
||||
// 通过全局变量通知列表页面数据已变更
|
||||
const pages = getCurrentPages();
|
||||
if (pages.length > 1) {
|
||||
const prevPage = pages[pages.length - 2];
|
||||
// 如果上一个页面是手术列表页,标记数据已变更
|
||||
if (prevPage.route === 'pages/surgery/index' && prevPage.markDataChanged) {
|
||||
prevPage.markDataChanged();
|
||||
}
|
||||
}
|
||||
wx.removeStorageSync("surgery_formData")
|
||||
wx.navigateBack();
|
||||
}, 1500);
|
||||
} catch (error) {
|
||||
// 简化错误处理,使错误信息更简洁
|
||||
let errorMessage = this.data.isEditMode ? "更新失败,请稍后重试" : "创建失败,请稍后重试";
|
||||
|
||||
// 检查error.message直接是否包含错误信息
|
||||
if (error.message && typeof error.message === "string") {
|
||||
|
||||
if (error.message.includes("手术编号已存在") || error.message.includes("该手术编号已存在")) {
|
||||
errorMessage = `手术编号已重复,请更换`;
|
||||
} else if (error.message.includes("医生") && error.message.includes("时间")) {
|
||||
errorMessage = `医生时间冲突,请调整`;
|
||||
} else {
|
||||
errorMessage = error.message;
|
||||
}
|
||||
}
|
||||
// 检查error.data.message(原有逻辑)
|
||||
else if (error.data && error.data.message) {
|
||||
|
||||
if (error.data.message.includes("手术编号已存在") || error.data.message.includes("该手术编号已存在")) {
|
||||
errorMessage = `手术编号已重复,请更换`;
|
||||
} else if (error.data.message.includes("医生") && error.data.message.includes("时间")) {
|
||||
errorMessage = `医生时间冲突,请调整`;
|
||||
} else {
|
||||
errorMessage = error.data.message;
|
||||
}
|
||||
}
|
||||
// 检查error.data.msg(后端返回的标准格式)
|
||||
else if (error.data && error.data.msg) {
|
||||
|
||||
if (error.data.msg.includes("手术编号已存在") || error.data.msg.includes("该手术编号已存在")) {
|
||||
errorMessage = `手术编号已重复,请更换`;
|
||||
} else if (error.data.msg.includes("医生") && error.data.msg.includes("时间")) {
|
||||
errorMessage = `医生时间冲突,请调整`;
|
||||
} else {
|
||||
errorMessage = error.data.msg;
|
||||
}
|
||||
}
|
||||
|
||||
this.showMessage(errorMessage, "error");
|
||||
} finally {
|
||||
this.setData({ submitting: false });
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 显示消息提示
|
||||
*/
|
||||
showMessage(message, type = "info") {
|
||||
// 确保消息显示
|
||||
|
||||
// 先尝试使用 t-message 组件
|
||||
const t = this.selectComponent("#t-message");
|
||||
if (t && typeof t.show === "function") {
|
||||
wx.nextTick(() => {
|
||||
t.show({
|
||||
message,
|
||||
type,
|
||||
duration: 3000,
|
||||
});
|
||||
});
|
||||
} else {
|
||||
// 如果组件不可用,降级使用原生toast
|
||||
let icon = "none";
|
||||
if (type === "success") icon = "success";
|
||||
if (type === "error") icon = "error";
|
||||
|
||||
wx.showToast({
|
||||
title: message,
|
||||
icon: icon,
|
||||
duration: 2000,
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"navigationBarTitleText": "创建手术记录",
|
||||
"usingComponents": {
|
||||
"t-button": "tdesign-miniprogram/button/button",
|
||||
"t-input": "tdesign-miniprogram/input/input",
|
||||
"t-textarea": "tdesign-miniprogram/textarea/textarea",
|
||||
"t-cell": "tdesign-miniprogram/cell/cell",
|
||||
"t-message": "tdesign-miniprogram/message/message",
|
||||
"t-loading": "tdesign-miniprogram/loading/loading",
|
||||
"t-cascader": "tdesign-miniprogram/cascader/cascader",
|
||||
"t-calendar": "tdesign-miniprogram/calendar/calendar",
|
||||
"t-date-time-picker": "tdesign-miniprogram/date-time-picker/date-time-picker",
|
||||
"t-tree-select": "tdesign-miniprogram/tree-select/tree-select"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
<view class="container">
|
||||
<t-message id="t-message" />
|
||||
|
||||
<!-- 加载状态 -->
|
||||
<view class="loading-container" wx:if="{{loading}}">
|
||||
<t-loading theme="circular" size="40rpx" loading />
|
||||
<text>加载中...</text>
|
||||
</view>
|
||||
|
||||
<!-- 表单内容 -->
|
||||
<block wx:else>
|
||||
<view class="form-group">
|
||||
<view class="form-item">
|
||||
<text class="label">手术编号 <text class="required">*</text></text>
|
||||
<t-input
|
||||
value="{{formData.surgery_id}}"
|
||||
placeholder="请输入手术编号"
|
||||
bindchange="onInputChange"
|
||||
data-field="surgery_id"
|
||||
maxlength="50"
|
||||
disabled="{{isEditMode}}"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<view class="form-item">
|
||||
<text class="label">手术名称 <text class="required">*</text></text>
|
||||
<t-input
|
||||
value="{{formData.surgery_name}}"
|
||||
placeholder="请输入手术名称"
|
||||
bindchange="onInputChange"
|
||||
data-field="surgery_name"
|
||||
maxlength="100"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<view class="form-item">
|
||||
<text class="label">患者姓名 <text class="required">*</text></text>
|
||||
<t-input
|
||||
value="{{formData.patient}}"
|
||||
placeholder="请输入患者姓名"
|
||||
bindchange="onInputChange"
|
||||
data-field="patient"
|
||||
maxlength="50"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<!-- 手术时间选择 -->
|
||||
<view class="form-item">
|
||||
<text class="label">手术时间 <text class="required">*</text></text>
|
||||
<view class="datetime-picker-wrapper" bindtap="showDateTimePicker">
|
||||
<t-cell
|
||||
title="{{formData.surgery_time_display || '请选择手术时间'}}"
|
||||
arrow
|
||||
hover
|
||||
data-mode="formData.surgery_time"
|
||||
note="{{formData.surgery_time ? '' : '必选'}}"
|
||||
t-class="picker-cell"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="form-item">
|
||||
<text class="label">主刀医生 <text class="required">*</text></text>
|
||||
<t-cell
|
||||
title="{{selectedDoctor ? selectedDoctor.name : '请选择主刀医生'}}"
|
||||
arrow
|
||||
hover
|
||||
note="{{selectedDoctor ? selectedDoctor.department.name : '必选'}}"
|
||||
bind:click="showDoctorSelector"
|
||||
t-class="picker-cell"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<!-- 设备选择部分 - 使用与手术详情页一致的样式 -->
|
||||
<view class="form-item">
|
||||
<view class="device-selection-header">
|
||||
<text>设备列表</text>
|
||||
<view class="add-device-btn" bind:tap="showDeviceSelector">添加设备</view>
|
||||
</view>
|
||||
|
||||
<!-- 已选择的设备列表 - 新样式 -->
|
||||
<view class="selected-devices-list" wx:if="{{selectedSubDevices.length > 0}}">
|
||||
<block wx:for="{{selectedSubDevices}}" wx:key="id">
|
||||
<view class="device-item">
|
||||
<view class="device-item-content">
|
||||
<view class="device-info">
|
||||
<view class="device-name">{{item.device_name}}-{{item.name}}</view>
|
||||
</view>
|
||||
<view class="device-action">
|
||||
<view class="delete-btn" bind:tap="removeDevice" data-index="{{index}}">删除</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 设备时间选择 -->
|
||||
<view class="device-time-section">
|
||||
<view class="time-picker-group">
|
||||
<view class="time-picker-item">
|
||||
<text class="time-label">开始时间</text>
|
||||
<view class="time-picker" bindtap="showDeviceStartTimePicker" data-index="{{index}}">
|
||||
<text class="time-value">{{item.startTimeDisplay || '点击设置'}}</text>
|
||||
<text class="picker-arrow">></text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="time-picker-item">
|
||||
<text class="time-label">结束时间</text>
|
||||
<view class="time-picker" bindtap="showDeviceEndTimePicker" data-index="{{index}}">
|
||||
<text class="time-value">{{item.endTimeDisplay || '点击设置'}}</text>
|
||||
<text class="picker-arrow">></text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
|
||||
<!-- 无设备提示 -->
|
||||
<view class="no-devices" wx:else>
|
||||
<text>暂无选择设备,请点击"添加设备"按钮添加</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="submit-container">
|
||||
<t-button
|
||||
theme="primary"
|
||||
size="large"
|
||||
loading="{{submitting}}"
|
||||
disabled="{{submitting}}"
|
||||
bind:tap="handleSubmit"
|
||||
block>{{isEditMode ? '保存修改' : '创建手术记录'}}</t-button>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<!-- 日期时间选择器 -->
|
||||
<t-date-time-picker
|
||||
title="选择手术时间"
|
||||
visible="{{dateTimePickerVisible}}"
|
||||
mode="second"
|
||||
format="YYYY-MM-DD HH:mm:ss"
|
||||
value="{{formData.surgery_time || currentDate}}"
|
||||
confirm-btn="确认"
|
||||
cancel-btn="取消"
|
||||
bind:confirm="onDateTimeConfirm"
|
||||
bind:cancel="onDateTimeCancel"
|
||||
bind:pick="onDateTimePick"
|
||||
bind:change="onDateTimeChange"
|
||||
auto-close
|
||||
show-week
|
||||
|
||||
/>
|
||||
|
||||
<!-- 医生选择器 - 使用级联选择器选项卡风格 -->
|
||||
<t-cascader
|
||||
visible="{{doctorSelectorVisible}}"
|
||||
options="{{doctorCascaderOptions}}"
|
||||
title="选择主刀医生"
|
||||
theme="tab"
|
||||
value="{{selectedDoctorValue}}"
|
||||
bind:change="onDoctorCascaderChange"
|
||||
bind:pick="onDoctorCascaderPick"
|
||||
bind:close="onDoctorCascaderClose"
|
||||
/>
|
||||
|
||||
<!-- 设备选择器 - 使用级联选择器选项卡风格 -->
|
||||
<t-cascader
|
||||
visible="{{deviceSelectorVisible}}"
|
||||
options="{{deviceTree}}"
|
||||
title="选择使用设备"
|
||||
theme="tab"
|
||||
value="{{selectedDeviceValue}}"
|
||||
bind:change="onDeviceCascaderChange"
|
||||
bind:pick="onDeviceCascaderPick"
|
||||
bind:close="onDeviceCascaderClose"
|
||||
/>
|
||||
|
||||
<!-- 设备开始时间选择器 -->
|
||||
<t-date-time-picker
|
||||
title="选择设备开始使用时间"
|
||||
visible="{{deviceStartTimePickerVisible}}"
|
||||
mode="second"
|
||||
format="YYYY-MM-DD HH:mm:ss"
|
||||
value="{{currentDeviceStartTime || currentDate}}"
|
||||
confirm-btn="确认"
|
||||
cancel-btn="取消"
|
||||
bind:confirm="onDeviceStartTimeConfirm"
|
||||
bind:cancel="onDeviceStartTimeCancel"
|
||||
auto-close
|
||||
show-week
|
||||
/>
|
||||
|
||||
<!-- 设备结束时间选择器 -->
|
||||
<t-date-time-picker
|
||||
title="选择设备结束使用时间"
|
||||
visible="{{deviceEndTimePickerVisible}}"
|
||||
mode="second"
|
||||
format="YYYY-MM-DD HH:mm:ss"
|
||||
value="{{currentDeviceEndTime || currentDate}}"
|
||||
confirm-btn="确认"
|
||||
cancel-btn="取消"
|
||||
bind:confirm="onDeviceEndTimeConfirm"
|
||||
bind:cancel="onDeviceEndTimeCancel"
|
||||
auto-close
|
||||
show-week
|
||||
/>
|
||||
</view>
|
||||
@@ -0,0 +1,305 @@
|
||||
/* pages/surgery/create/index.wxss */
|
||||
|
||||
.container {
|
||||
padding: 30rpx;
|
||||
background-color: #f6f6f6;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.loading-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 300rpx;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
background-color: #fff;
|
||||
border-radius: 12rpx;
|
||||
padding: 20rpx 30rpx;
|
||||
margin-bottom: 30rpx;
|
||||
box-shadow: 0 2rpx 6rpx rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.form-item {
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.label {
|
||||
display: block;
|
||||
font-size: 28rpx;
|
||||
margin-bottom: 16rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.required {
|
||||
color: #e34d59;
|
||||
}
|
||||
|
||||
.picker-cell {
|
||||
padding: 20rpx !important;
|
||||
border-radius: 8rpx;
|
||||
background-color: #f8f8f8 !important;
|
||||
}
|
||||
|
||||
/* 原生选择器样式 */
|
||||
.picker-view {
|
||||
padding: 24rpx;
|
||||
background-color: #f8f8f8;
|
||||
border-radius: 8rpx;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.time-picker {
|
||||
margin-top: 16rpx;
|
||||
}
|
||||
|
||||
.picker-note {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
margin-top: 8rpx;
|
||||
padding-left: 24rpx;
|
||||
}
|
||||
|
||||
/* 设备选择相关样式 - 更新 */
|
||||
.device-selection-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.device-selection-header text {
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.add-device-btn {
|
||||
color: #06a56c;
|
||||
font-size: 26rpx;
|
||||
padding: 10rpx 20rpx;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.selected-devices-list {
|
||||
margin-top: 12rpx;
|
||||
background-color: #f8f8f8;
|
||||
border-radius: 8rpx;
|
||||
padding: 12rpx;
|
||||
display: block; /* 确保设备列表容器显示 */
|
||||
}
|
||||
|
||||
.device-item {
|
||||
background-color: #fff;
|
||||
border-radius: 8rpx;
|
||||
margin-bottom: 12rpx;
|
||||
padding: 8rpx;
|
||||
box-shadow: 0 1rpx 4rpx rgba(0, 0, 0, 0.05);
|
||||
display: block; /* 确保设备项显示 */
|
||||
}
|
||||
|
||||
.device-item:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.device-item-content {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 16rpx;
|
||||
}
|
||||
|
||||
.device-info {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.device-name {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.device-action {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.delete-btn {
|
||||
padding: 8rpx 20rpx;
|
||||
background-color: #e34d59;
|
||||
color: #fff;
|
||||
border-radius: 4rpx;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.remove-icon {
|
||||
padding: 10rpx;
|
||||
color: #e34d59;
|
||||
}
|
||||
|
||||
.no-devices {
|
||||
text-align: center;
|
||||
color: #999;
|
||||
font-size: 26rpx;
|
||||
padding: 30rpx 0;
|
||||
background-color: #f8f8f8;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
.submit-container {
|
||||
margin-top: 60rpx;
|
||||
padding-bottom: 40rpx;
|
||||
}
|
||||
|
||||
/* 年月日时分秒选择器样式 */
|
||||
.datetime-picker-mask {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.datetime-picker-container {
|
||||
position: fixed;
|
||||
bottom: -500rpx;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
background-color: #fff;
|
||||
border-radius: 24rpx 24rpx 0 0;
|
||||
z-index: 1001;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.datetime-picker-container.show {
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
.datetime-picker-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 24rpx 32rpx;
|
||||
border-bottom: 1rpx solid #f0f0f0;
|
||||
}
|
||||
|
||||
.datetime-picker-header .title {
|
||||
font-size: 32rpx;
|
||||
color: #333;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.datetime-picker-header .cancel-btn,
|
||||
.datetime-picker-header .confirm-btn {
|
||||
font-size: 28rpx;
|
||||
padding: 8rpx 10rpx;
|
||||
}
|
||||
|
||||
.datetime-picker-header .cancel-btn {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.datetime-picker-header .confirm-btn {
|
||||
color: #0052d9;
|
||||
}
|
||||
|
||||
.datetime-picker-body {
|
||||
padding: 20rpx 0;
|
||||
height: 300rpx;
|
||||
}
|
||||
|
||||
.picker-item {
|
||||
line-height: 50px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.time-display {
|
||||
padding: 20rpx;
|
||||
background-color: #f8f8f8;
|
||||
border-radius: 8rpx;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
/* 自定义级联选择器样式 */
|
||||
:host {
|
||||
--td-cascader-active-color: #0052d9;
|
||||
}
|
||||
|
||||
/* 设备选择器的自定义样式 */
|
||||
.custom-picker {
|
||||
--td-picker-confirm-color: #0052d9;
|
||||
}
|
||||
|
||||
.custom-confirm-btn {
|
||||
color: #0052d9 !important;
|
||||
}
|
||||
|
||||
.custom-cancel-btn {
|
||||
color: #999 !important;
|
||||
}
|
||||
|
||||
/* 设备时间选择部分样式 */
|
||||
.device-time-section {
|
||||
margin-top: 16rpx;
|
||||
padding: 16rpx;
|
||||
background-color: #f8f9fa;
|
||||
border-radius: 8rpx;
|
||||
border: 1px solid #e9ecef;
|
||||
}
|
||||
|
||||
.time-picker-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12rpx;
|
||||
}
|
||||
|
||||
.time-picker-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 12rpx 16rpx;
|
||||
background-color: #fff;
|
||||
border-radius: 6rpx;
|
||||
border: 1px solid #dee2e6;
|
||||
}
|
||||
|
||||
.time-picker-item .time-label {
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.time-picker {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8rpx;
|
||||
padding: 8rpx 12rpx;
|
||||
background-color: #f8f9fa;
|
||||
border-radius: 4rpx;
|
||||
border: 1px solid #dee2e6;
|
||||
min-width: 200rpx;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.time-picker .time-value {
|
||||
font-size: 24rpx;
|
||||
color: #333;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.time-picker .picker-arrow {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
|
||||
.time-picker:active .picker-arrow {
|
||||
transform: translateX(4rpx);
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
// pages/surgery/detail/index.js
|
||||
const { surgeryApi } = require("../../../utils/api");
|
||||
const dayjs = require("../../../miniprogram_npm/dayjs/index");
|
||||
|
||||
Page({
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
surgeryId: null, // 手术ID
|
||||
surgery: null, // 手术数据
|
||||
loading: true, // 加载状态
|
||||
loadError: false, // 加载错误状态
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
if (options && options.id) {
|
||||
const surgeryId = Number(options.id);
|
||||
this.setData({ surgeryId });
|
||||
this.fetchSurgeryDetail(surgeryId);
|
||||
} else {
|
||||
wx.showToast({
|
||||
title: '参数错误',
|
||||
icon: 'error'
|
||||
});
|
||||
// 返回上一页
|
||||
setTimeout(() => {
|
||||
wx.navigateBack();
|
||||
}, 1500);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取手术详情数据
|
||||
*/
|
||||
async fetchSurgeryDetail(surgeryId) {
|
||||
this.setData({
|
||||
loading: true,
|
||||
loadError: false
|
||||
});
|
||||
|
||||
try {
|
||||
// 修正API调用方法名 - 从getSurgeryDetail改为getSurgeryById
|
||||
const res = await surgeryApi.getSurgeryById(surgeryId);
|
||||
|
||||
// 处理手术数据,格式化日期和设备数据
|
||||
const surgery = res.data;
|
||||
|
||||
// 处理医生和科室信息
|
||||
const hasDoctor = !!surgery.doctor;
|
||||
const hasDepartment = !!surgery.doctor?.department;
|
||||
const doctorName = hasDoctor ? surgery.doctor.name : '未知医生';
|
||||
const departmentName = hasDepartment ? surgery.doctor.department.name : '未知科室';
|
||||
|
||||
// 格式化设备数据,将设备名称和子设备名称结合显示
|
||||
let devices = [];
|
||||
if (surgery.surgerySubDevices && surgery.surgerySubDevices.length > 0) {
|
||||
devices = surgery.surgerySubDevices.map(item => {
|
||||
// 获取主设备名称和子设备名称(通常是编号)
|
||||
const deviceName = item.subDevice.device.name || '未知设备';
|
||||
const subDeviceName = item.subDevice.name || '';
|
||||
|
||||
// 格式化使用时间
|
||||
let startTimeDisplay = '未设置';
|
||||
let endTimeDisplay = '未设置';
|
||||
if (item.start_time) {
|
||||
startTimeDisplay = dayjs(item.start_time).format('YYYY-MM-DD HH:mm');
|
||||
}
|
||||
if (item.end_time) {
|
||||
endTimeDisplay = dayjs(item.end_time).format('YYYY-MM-DD HH:mm');
|
||||
}
|
||||
|
||||
return {
|
||||
id: item.sub_device_id,
|
||||
surgerySubDeviceId: item.id,
|
||||
// 组合成"设备名称-子设备号"的格式
|
||||
displayName: `${deviceName}-${subDeviceName}`,
|
||||
startTime: item.start_time,
|
||||
endTime: item.end_time,
|
||||
startTimeDisplay,
|
||||
endTimeDisplay
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
const formattedSurgery = {
|
||||
...surgery,
|
||||
formattedTime: dayjs(surgery.surgery_time).format('YYYY年MM月DD日 HH:mm'),
|
||||
doctorName,
|
||||
departmentName,
|
||||
devices
|
||||
};
|
||||
|
||||
this.setData({
|
||||
surgery: formattedSurgery,
|
||||
loading: false
|
||||
});
|
||||
} catch (error) {
|
||||
this.setData({
|
||||
loading: false,
|
||||
loadError: true
|
||||
});
|
||||
wx.showToast({
|
||||
title: '获取手术详情失败',
|
||||
icon: 'error'
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 返回上一级页面
|
||||
*/
|
||||
goBack() {
|
||||
wx.navigateBack();
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"t-navbar": "tdesign-miniprogram/navbar/navbar",
|
||||
"t-skeleton": "tdesign-miniprogram/skeleton/skeleton",
|
||||
"t-empty": "tdesign-miniprogram/empty/empty",
|
||||
"t-cell": "tdesign-miniprogram/cell/cell",
|
||||
"t-tag": "tdesign-miniprogram/tag/tag",
|
||||
"t-message": "tdesign-miniprogram/message/message"
|
||||
},
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<view class="detail-container">
|
||||
<t-navbar title="手术详情" left-arrow bind:go-back="goBack" />
|
||||
|
||||
<block wx:if="{{loading}}">
|
||||
<!-- 加载中骨架屏 -->
|
||||
<view class="skeleton-container">
|
||||
<t-skeleton theme="paragraph" loading></t-skeleton>
|
||||
</view>
|
||||
</block>
|
||||
<block wx:elif="{{loadError}}">
|
||||
<!-- 加载错误提示 -->
|
||||
<view class="error-container">
|
||||
<t-empty icon="error-circle" description="加载失败,请返回重试" />
|
||||
</view>
|
||||
</block>
|
||||
<block wx:elif="{{surgery}}">
|
||||
<view class="detail-card">
|
||||
<!-- 手术基本信息 -->
|
||||
<view class="info-section">
|
||||
<view class="info-header">手术信息</view>
|
||||
<view class="info-content">
|
||||
<view class="info-item">
|
||||
<text class="label">手术编号</text>
|
||||
<text class="value">{{surgery.surgery_id}}</text>
|
||||
</view>
|
||||
<view class="info-item">
|
||||
<text class="label">手术名称</text>
|
||||
<text class="value">{{surgery.surgery_name}}</text>
|
||||
</view>
|
||||
<view class="info-item">
|
||||
<text class="label">患者姓名</text>
|
||||
<text class="value">{{surgery.patient}}</text>
|
||||
</view>
|
||||
<view class="info-item">
|
||||
<text class="label">手术时间</text>
|
||||
<text class="value">{{surgery.formattedTime}}</text>
|
||||
</view>
|
||||
<view class="info-item">
|
||||
<text class="label">主刀医生</text>
|
||||
<text class="value doctor">{{surgery.doctorName}}</text>
|
||||
</view>
|
||||
<view class="info-item">
|
||||
<text class="label">所属科室</text>
|
||||
<text class="value department">{{surgery.departmentName}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 设备信息部分,修改为更简洁的列表 -->
|
||||
<view class="device-section">
|
||||
<view class="info-header">使用设备 ({{surgery.devices.length}})</view>
|
||||
<view class="device-list">
|
||||
<block wx:if="{{surgery.devices && surgery.devices.length > 0}}">
|
||||
<view class="device-card" wx:for="{{surgery.devices}}" wx:key="id">
|
||||
<view class="device-header">
|
||||
<text class="device-name">{{item.displayName}}</text>
|
||||
</view>
|
||||
<view class="device-time-info">
|
||||
<view class="time-item">
|
||||
<text class="time-label">开始时间:</text>
|
||||
<text class="time-value">{{item.startTimeDisplay}}</text>
|
||||
</view>
|
||||
<view class="time-item">
|
||||
<text class="time-label">结束时间:</text>
|
||||
<text class="time-value">{{item.endTimeDisplay}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
<block wx:else>
|
||||
<view class="no-device">
|
||||
<t-empty icon="info-circle" description="无使用设备记录" />
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
<block wx:else>
|
||||
<!-- 数据为空的提示 -->
|
||||
<view class="empty-container">
|
||||
<t-empty icon="info-circle-filled" description="无法获取手术详情" />
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
@@ -0,0 +1,132 @@
|
||||
/* pages/surgery/detail/index.wxss */
|
||||
page {
|
||||
background-color: #f7f8fa;
|
||||
}
|
||||
|
||||
.detail-container {
|
||||
padding-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.skeleton-container {
|
||||
padding: 24rpx;
|
||||
}
|
||||
|
||||
.detail-card {
|
||||
margin: 24rpx;
|
||||
background-color: #ffffff;
|
||||
border-radius: 8rpx;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
/* 信息区块样式 */
|
||||
.info-section {
|
||||
padding: 24rpx;
|
||||
border-bottom: 1px solid #f2f2f2;
|
||||
}
|
||||
|
||||
.device-section {
|
||||
padding: 24rpx;
|
||||
}
|
||||
|
||||
.info-header {
|
||||
font-size: 32rpx;
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
|
||||
.info-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.info-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.label {
|
||||
width: 160rpx;
|
||||
font-size: 28rpx;
|
||||
color: #888;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.value {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
/* 医生和科室标签样式 */
|
||||
.doctor {
|
||||
color: #0052d9;
|
||||
}
|
||||
|
||||
.department {
|
||||
color: #06a56c;
|
||||
}
|
||||
|
||||
/* 新的设备列表样式 */
|
||||
.device-list {
|
||||
padding: 0 10rpx;
|
||||
}
|
||||
|
||||
.device-card {
|
||||
background-color: #f8f9fa;
|
||||
border: 1px solid #e9ecef;
|
||||
border-radius: 8rpx;
|
||||
padding: 20rpx;
|
||||
margin: 12rpx 0;
|
||||
}
|
||||
|
||||
.device-header {
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.device-name {
|
||||
font-size: 28rpx;
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.device-time-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8rpx;
|
||||
}
|
||||
|
||||
.time-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.time-label {
|
||||
font-size: 24rpx;
|
||||
color: #888;
|
||||
width: 120rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.time-value {
|
||||
font-size: 24rpx;
|
||||
color: #333;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.no-device {
|
||||
padding: 40rpx 0;
|
||||
}
|
||||
|
||||
/* 错误和空状态容器 */
|
||||
.error-container,
|
||||
.empty-container {
|
||||
padding: 100rpx 24rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
@@ -0,0 +1,558 @@
|
||||
// pages/surgery/index.js
|
||||
const { surgeryApi } = require("../../utils/api");
|
||||
const dayjs = require("../../miniprogram_npm/dayjs/index");
|
||||
const Toast = require("../../miniprogram_npm/tdesign-miniprogram/toast/index");
|
||||
|
||||
Page({
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
surgeries: [], // 手术列表数据
|
||||
surgeriesList: [],
|
||||
// 分页参数
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
total: 0,
|
||||
|
||||
// 状态控制
|
||||
loading: true, // 初始加载状态
|
||||
refreshing: false, // 下拉刷新状态
|
||||
loadingMore: false, // 加载更多状态
|
||||
loadError: false, // 加载错误状态
|
||||
noMoreData: false, // 没有更多数据状态
|
||||
isFinish: false, // 是否选中未完成
|
||||
|
||||
confirmDialogVisible: false, // 确认删除对话框可见性
|
||||
currentSurgeryId: null, // 当前操作的手术ID
|
||||
|
||||
// 数据变更状态管理
|
||||
dataHasChanged: false, // 标记数据是否已变更(从编辑/创建页面返回时)
|
||||
lastShowTime: 0, // 上次显示页面的时间戳
|
||||
showTimeout: null, // 防抖定时器
|
||||
|
||||
// TDesign 组件配置
|
||||
loadingProps: {
|
||||
theme: 'circular',
|
||||
size: '40rpx',
|
||||
layout: 'horizontal'
|
||||
},
|
||||
|
||||
loadingTexts: [
|
||||
'下拉刷新',
|
||||
'松手刷新',
|
||||
'正在刷新...',
|
||||
'刷新完成'
|
||||
]
|
||||
|
||||
// 不再在这里全局定义swipeButtons,而是为每个手术项动态生成
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad() {
|
||||
this.loadSurgeries();
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
const currentTime = Date.now();
|
||||
|
||||
// 清除之前的定时器(防抖)
|
||||
if (this.data.showTimeout) {
|
||||
clearTimeout(this.data.showTimeout);
|
||||
}
|
||||
|
||||
// 检查是否需要刷新数据
|
||||
const shouldRefresh = this.shouldRefreshData(currentTime);
|
||||
|
||||
if (shouldRefresh) {
|
||||
// 设置新的定时器,延迟500ms执行刷新,避免快速切换页面导致的重复请求
|
||||
const timeoutId = setTimeout(() => {
|
||||
this.performSmartRefresh();
|
||||
}, 500);
|
||||
|
||||
this.setData({
|
||||
showTimeout: timeoutId,
|
||||
lastShowTime: currentTime,
|
||||
dataHasChanged: false
|
||||
});
|
||||
} else {
|
||||
// 更新最后显示时间
|
||||
this.setData({ lastShowTime: currentTime });
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 点击未完成
|
||||
*/
|
||||
clickunfinished ({detail}) {
|
||||
this.setData({isFinish: detail.checked})
|
||||
this.filterSurgeriesList()
|
||||
},
|
||||
/**
|
||||
* 过滤手术未完成
|
||||
*/
|
||||
filterSurgeriesList(arr = []) {
|
||||
if (arr.length > 0) this.data.surgeriesList.push(...arr)
|
||||
let list = []
|
||||
if (this.data.isFinish) {
|
||||
list = this.data.surgeries.filter((item) => {
|
||||
if (item.surgerySubDevices && item.surgerySubDevices.length > 0){
|
||||
if (item.surgerySubDevices.some(subDevice => !subDevice.end_time)) {
|
||||
return item
|
||||
}
|
||||
}
|
||||
})
|
||||
this.setData({
|
||||
surgeries: list
|
||||
})
|
||||
} else {
|
||||
this.setData({
|
||||
surgeries: this.data.surgeriesList
|
||||
})
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 判断是否需要刷新数据
|
||||
*/
|
||||
shouldRefreshData(currentTime) {
|
||||
// 如果正在加载或刷新,则不执行
|
||||
if (this.data.loading || this.data.refreshing || this.data.loadingMore) {
|
||||
return false;
|
||||
}
|
||||
// 如果数据已变更(从编辑页面返回的标记),则需要刷新
|
||||
if (this.data.dataHasChanged) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 如果还没有加载过数据,则需要加载
|
||||
if (this.data.surgeries.length === 0 && !this.data.loadError) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 如果距离上次显示超过5分钟,考虑刷新(防止数据过期)
|
||||
const timeSinceLastShow = currentTime - this.data.lastShowTime;
|
||||
if (timeSinceLastShow > 5 * 60 * 1000) { // 5分钟
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* 执行智能刷新策略
|
||||
*/
|
||||
async performSmartRefresh() {
|
||||
try {
|
||||
// 1. 首先尝试增量更新(只刷新第一页,检查是否有新数据)
|
||||
const freshData = await this.fetchSurgeriesData(1, this.data.pageSize);
|
||||
const freshFirstPage = freshData.formattedSurgeries;
|
||||
|
||||
// 2. 比较数据是否有变化
|
||||
const hasChanges = this.detectChanges(this.data.surgeries, freshFirstPage);
|
||||
|
||||
if (hasChanges) {
|
||||
console.log('📋 检测到数据变化,执行增量更新');
|
||||
await this.performIncrementalUpdate(freshData);
|
||||
} else {
|
||||
console.log('📋 数据无变化,保持当前状态');
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('📋 智能刷新失败,回退到完整刷新:', error);
|
||||
// 如果智能刷新失败,回退到完整的刷新
|
||||
this.loadSurgeries();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 检测数据是否有变化
|
||||
*/
|
||||
detectChanges(currentData, freshData) {
|
||||
// 如果数据数量不同,肯定有变化
|
||||
if (currentData.length !== freshData.length) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 如果当前没有数据,而新数据有,则有变化
|
||||
if (currentData.length === 0 && freshData.length > 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 比较前几个项目的ID和时间戳
|
||||
const compareCount = Math.min(currentData.length, freshData.length, 3);
|
||||
for (let i = 0; i < compareCount; i++) {
|
||||
const currentItem = currentData[i];
|
||||
const freshItem = freshData[i];
|
||||
|
||||
// 比较ID
|
||||
if (currentItem.id !== freshItem.id) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 比较更新时间(如果有的话)
|
||||
if (currentItem.updated_at !== freshItem.updated_at) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 比较手术时间
|
||||
if (currentItem.surgery_time !== freshItem.surgery_time) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* 执行增量更新
|
||||
*/
|
||||
async performIncrementalUpdate(freshFirstPage) {
|
||||
// 只在第1页时自动更新,其他页面不进行任何操作
|
||||
if (this.data.page === 1) {
|
||||
this.setData({
|
||||
surgeries: freshFirstPage.formattedSurgeries,
|
||||
total: freshFirstPage.total,
|
||||
noMoreData: freshFirstPage.formattedSurgeries.length < this.data.pageSize
|
||||
});
|
||||
|
||||
// 简单的数据更新提示
|
||||
wx.showToast({
|
||||
title: '数据已更新',
|
||||
icon: 'success',
|
||||
duration: 1000
|
||||
});
|
||||
}
|
||||
// 如果用户在第2页+,不做任何操作,让用户自己选择是否下拉刷新
|
||||
},
|
||||
|
||||
/**
|
||||
* 设置数据变更标记(从其他页面调用)
|
||||
*/
|
||||
markDataChanged() {
|
||||
this.setData({ dataHasChanged: true });
|
||||
},
|
||||
|
||||
/**
|
||||
* 初始加载手术数据
|
||||
*/
|
||||
async loadSurgeries() {
|
||||
this.setData({
|
||||
loading: true,
|
||||
loadError: false,
|
||||
page: 1,
|
||||
noMoreData: false
|
||||
});
|
||||
|
||||
try {
|
||||
const res = await this.fetchSurgeriesData(1, this.data.pageSize);
|
||||
|
||||
this.setData({
|
||||
surgeries: res.formattedSurgeries,
|
||||
surgeriesList: res.formattedSurgeries,
|
||||
total: res.total,
|
||||
page: 1,
|
||||
noMoreData: res.formattedSurgeries.length < this.data.pageSize,
|
||||
loading: false
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
this.setData({
|
||||
loading: false,
|
||||
loadError: true,
|
||||
});
|
||||
wx.showToast({
|
||||
title: "获取手术列表失败",
|
||||
icon: "error",
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 下拉刷新
|
||||
*/
|
||||
async onRefresh() {
|
||||
if (this.data.refreshing || this.data.loadingMore) return;
|
||||
this.setData({
|
||||
refreshing: true,
|
||||
page: 1,
|
||||
noMoreData: false
|
||||
});
|
||||
|
||||
try {
|
||||
const res = await this.fetchSurgeriesData(1, this.data.pageSize);
|
||||
|
||||
this.setData({
|
||||
surgeries: res.formattedSurgeries,
|
||||
total: res.total,
|
||||
page: 1,
|
||||
noMoreData: res.formattedSurgeries.length < this.data.pageSize
|
||||
});
|
||||
wx.showToast({
|
||||
title: '刷新成功',
|
||||
icon: 'success',
|
||||
duration: 1500
|
||||
});
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
title: '刷新失败',
|
||||
icon: 'error'
|
||||
});
|
||||
} finally {
|
||||
this.setData({ refreshing: false });
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 滑动底部加载更多
|
||||
*/
|
||||
async onScrollToLower() {
|
||||
// 如果正在加载或没有更多数据,则返回
|
||||
if (this.data.loadingMore || this.data.noMoreData || this.data.refreshing) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.setData({
|
||||
loadingMore: true,
|
||||
page: this.data.page + 1
|
||||
});
|
||||
try {
|
||||
const res = await this.fetchSurgeriesData(this.data.page, this.data.pageSize);
|
||||
this.filterSurgeriesList(res.formattedSurgeries)
|
||||
// 合并数据
|
||||
this.setData({
|
||||
// surgeries: this.data.surgeries.concat(res.formattedSurgeries),
|
||||
total: res.total,
|
||||
noMoreData: res.formattedSurgeries.length < this.data.pageSize
|
||||
});
|
||||
} catch (error) {
|
||||
// 恢复页码
|
||||
this.setData({
|
||||
page: this.data.page - 1
|
||||
});
|
||||
|
||||
wx.showToast({
|
||||
title: '加载更多失败',
|
||||
icon: 'error'
|
||||
});
|
||||
} finally {
|
||||
this.setData({ loadingMore: false });
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取手术数据的核心方法
|
||||
*/
|
||||
async fetchSurgeriesData(page, pageSize) {
|
||||
const res = await surgeryApi.getSurgeries({
|
||||
page: page,
|
||||
pageSize: pageSize
|
||||
});
|
||||
|
||||
// 处理手术数据,格式化日期并确保医生和科室数据存在
|
||||
// 后端返回的是分页格式:{list: [...], total: ...}
|
||||
const surgeryList = res.data.list || res.data || [];
|
||||
const formattedSurgeries = surgeryList.map((surgery) => {
|
||||
// 诊断医生信息缺失问题
|
||||
const hasDoctor = !!surgery.doctor;
|
||||
const hasDepartment = !!surgery.doctor?.department;
|
||||
|
||||
// 确保医生和科室信息存在并设置默认值
|
||||
const doctorName = hasDoctor ? surgery.doctor.name : "未知医生";
|
||||
const departmentName = hasDepartment ? surgery.doctor.department.name : "未知科室";
|
||||
|
||||
// 计算使用的设备数量
|
||||
const deviceCount = surgery.surgerySubDevices ? surgery.surgerySubDevices.length : 0;
|
||||
|
||||
// 检查是否有未设置结束时间的设备
|
||||
let hasUnfinishedDevice = false;
|
||||
if (surgery.surgerySubDevices && surgery.surgerySubDevices.length > 0) {
|
||||
hasUnfinishedDevice = surgery.surgerySubDevices.some(subDevice => !subDevice.end_time);
|
||||
}
|
||||
|
||||
// 为每个手术记录添加专属的侧滑按钮配置
|
||||
const surgerySwipeButtons = [
|
||||
{
|
||||
text: "编辑",
|
||||
style: "background-color: #0052d9; color: white; width: 120rpx; height: 100%; display: flex; align-items: center; justify-content: center;",
|
||||
data: { id: surgery.id, type: "edit" },
|
||||
},
|
||||
{
|
||||
text: "删除",
|
||||
style: "background-color: #e34d59; color: white; width: 120rpx; height: 100%; display: flex; align-items: center; justify-content: center;",
|
||||
data: { id: surgery.id, type: "delete" },
|
||||
},
|
||||
];
|
||||
|
||||
return {
|
||||
...surgery,
|
||||
formattedTime: dayjs(surgery.surgery_time).format("YYYY年MM月DD日 HH:mm"),
|
||||
// 添加独立的属性,确保即使嵌套对象不存在也能显示
|
||||
doctorName: doctorName,
|
||||
departmentName: departmentName,
|
||||
// 添加设备数量
|
||||
deviceCount: deviceCount,
|
||||
// 添加样式状态标记
|
||||
hasUnfinishedDevice: hasUnfinishedDevice,
|
||||
// 添加侧滑按钮配置
|
||||
swipeButtons: surgerySwipeButtons,
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
formattedSurgeries,
|
||||
total: res.data.total || surgeryList.length
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* 查看手术详情
|
||||
*/
|
||||
viewSurgeryDetail(e) {
|
||||
const surgeryId = e.currentTarget.dataset.id;
|
||||
// 跳转到手术详情页
|
||||
wx.navigateTo({
|
||||
url: `/pages/surgery/detail/index?id=${surgeryId}`,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 侧滑单元格点击事件处理
|
||||
*/
|
||||
onSwipeCellClick(e) {
|
||||
const { index } = e.detail;
|
||||
const btnData = e.detail.data;
|
||||
|
||||
if (!btnData || !btnData.id) {
|
||||
Toast({
|
||||
message: "操作失败,请重试",
|
||||
theme: "error",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const surgeryId = btnData.id;
|
||||
const actionType = btnData.type;
|
||||
|
||||
|
||||
// 查找对应的手术记录数据
|
||||
const surgery = this.data.surgeries.find((item) => item.id === surgeryId);
|
||||
if (!surgery) {
|
||||
Toast({
|
||||
message: "找不到对应的手术记录",
|
||||
theme: "error",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// 根据操作类型执行相应的动作
|
||||
if (actionType === "edit" || index === 0) {
|
||||
// 编辑操作
|
||||
this.handleEdit(surgery);
|
||||
} else if (actionType === "delete" || index === 1) {
|
||||
// 删除操作
|
||||
this.handleDelete(surgery);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 处理编辑操作
|
||||
*/
|
||||
handleEdit(surgery) {
|
||||
// 跳转到编辑页面,实际上是复用创建页面
|
||||
wx.navigateTo({
|
||||
url: `/pages/surgery/create/index?id=${surgery.id}&mode=edit`,
|
||||
success: () => {
|
||||
},
|
||||
fail: (err) => {
|
||||
Toast({
|
||||
message: "页面跳转失败",
|
||||
theme: "error",
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 处理删除操作
|
||||
*/
|
||||
handleDelete(surgery) {
|
||||
// 显示确认对话框
|
||||
this.setData({
|
||||
currentSurgeryId: surgery.id,
|
||||
confirmDialogVisible: true,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 确认删除
|
||||
*/
|
||||
async confirmDelete() {
|
||||
const surgeryId = this.data.currentSurgeryId;
|
||||
|
||||
try {
|
||||
await surgeryApi.deleteSurgery(surgeryId);
|
||||
// 删除成功,刷新列表
|
||||
wx.showToast({
|
||||
title: "删除成功",
|
||||
icon: "success",
|
||||
});
|
||||
|
||||
// 重新加载数据
|
||||
this.loadSurgeries();
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
title: "删除失败",
|
||||
icon: "error",
|
||||
});
|
||||
} finally {
|
||||
// 关闭对话框
|
||||
this.setData({
|
||||
confirmDialogVisible: false,
|
||||
currentSurgeryId: null,
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 取消删除
|
||||
*/
|
||||
cancelDelete() {
|
||||
this.setData({
|
||||
confirmDialogVisible: false,
|
||||
currentSurgeryId: null,
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 浮动按钮点击事件处理函数
|
||||
*/
|
||||
handleClick() {
|
||||
// 跳转到手术创建页面
|
||||
wx.navigateTo({
|
||||
url: "/pages/surgery/create/index",
|
||||
success: () => {
|
||||
},
|
||||
fail: (err) => {
|
||||
wx.showToast({
|
||||
title: "页面跳转失败",
|
||||
icon: "error",
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面卸载时清理资源
|
||||
*/
|
||||
onUnload() {
|
||||
// 清除定时器,避免内存泄漏
|
||||
if (this.data.showTimeout) {
|
||||
clearTimeout(this.data.showTimeout);
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"t-cell": "tdesign-miniprogram/cell/cell",
|
||||
"t-cell-group": "tdesign-miniprogram/cell-group/cell-group",
|
||||
"t-skeleton": "tdesign-miniprogram/skeleton/skeleton",
|
||||
"t-loading": "tdesign-miniprogram/loading/loading",
|
||||
"t-empty": "tdesign-miniprogram/empty/empty",
|
||||
"t-divider": "tdesign-miniprogram/divider/divider",
|
||||
"t-tag": "tdesign-miniprogram/tag/tag",
|
||||
"t-image": "tdesign-miniprogram/image/image",
|
||||
"t-toast": "tdesign-miniprogram/toast/toast",
|
||||
"t-message": "tdesign-miniprogram/message/message",
|
||||
"t-fab": "tdesign-miniprogram/fab/fab",
|
||||
"t-swipe-cell": "tdesign-miniprogram/swipe-cell/swipe-cell",
|
||||
"t-dialog": "tdesign-miniprogram/dialog/dialog",
|
||||
"t-pull-down-refresh": "tdesign-miniprogram/pull-down-refresh/pull-down-refresh",
|
||||
"t-search": "tdesign-miniprogram/search/search",
|
||||
"t-radio": "tdesign-miniprogram/radio/radio"
|
||||
},
|
||||
"navigationBarTitleText": "手术",
|
||||
"enablePullDownRefresh": true,
|
||||
"backgroundColor": "#f7f8fa"
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
<t-pull-down-refresh
|
||||
value="{{refreshing}}"
|
||||
loadingProps="{{loadingProps}}"
|
||||
loadingTexts="{{loadingTexts}}"
|
||||
bind:refresh="onRefresh"
|
||||
bind:scrolltolower="onScrollToLower"
|
||||
maxBarHeight="200"
|
||||
loadingBarHeight="80"
|
||||
lowerThreshold="100"
|
||||
enable-back-to-top="{{true}}"
|
||||
>
|
||||
<view class="surgery-searchbar">
|
||||
<view class="surgery-radio">
|
||||
<t-radio default-checked="{{isFinish}}" allow-uncheck icon="line" label="未完成" bind:change="clickunfinished"/>
|
||||
</view>
|
||||
<view class="surgery-search"><t-search placeholder="请输入患者ID" /></view>
|
||||
</view>
|
||||
<view class="surgery-container">
|
||||
<!-- 初始加载骨架屏 -->
|
||||
<block wx:if="{{loading && surgeries.length === 0}}">
|
||||
<view wx:for="{{5}}" wx:key="index" class="skeleton-item">
|
||||
<t-skeleton theme="paragraph" loading></t-skeleton>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<!-- 加载错误提示 -->
|
||||
<block wx:elif="{{loadError}}">
|
||||
<view class="error-container">
|
||||
<t-empty icon="error-circle" description="加载失败,请下拉刷新重试" />
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<!-- 手术列表 -->
|
||||
<block wx:elif="{{surgeries && surgeries.length > 0}}">
|
||||
<view class="surgery-list">
|
||||
<block wx:for="{{surgeries}}" wx:key="id">
|
||||
<t-swipe-cell class="swipe-cell-container" right="{{item.swipeButtons}}" bind:click="onSwipeCellClick">
|
||||
<view class="surgery-card {{item.hasUnfinishedDevice ? 'surgery-card--unfinished' : ''}}" bindtap="viewSurgeryDetail" data-id="{{item.id}}">
|
||||
<view class="surgery-title">
|
||||
{{item.surgery_name}}
|
||||
<view wx:if="{{item.hasUnfinishedDevice}}" class="unfinished-indicator">
|
||||
<text class="unfinished-text">未设置结束时间</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="surgery-info">
|
||||
<view class="info-item patient">
|
||||
<text>患者: {{item.patient}}</text>
|
||||
</view>
|
||||
<view class="info-item time">
|
||||
<text>时间: {{item.formattedTime}}</text>
|
||||
</view>
|
||||
<view class="info-item doctor-dept">
|
||||
<text class="doctor">{{item.doctorName}}</text>
|
||||
<text class="dept">{{item.departmentName}}</text>
|
||||
</view>
|
||||
<!-- 添加设备数量显示 -->
|
||||
<view class="info-item device-count">
|
||||
<text class="count">使用设备: {{item.deviceCount}}个</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="surgery-id-tag">{{item.surgery_id}}</view>
|
||||
</view>
|
||||
</t-swipe-cell>
|
||||
</block>
|
||||
</view>
|
||||
|
||||
<!-- 加载更多状态 -->
|
||||
<view wx:if="{{loadingMore}}" class="loading-more">
|
||||
<t-loading text="加载更多..." size="40rpx" theme="circular" />
|
||||
</view>
|
||||
|
||||
<!-- 没有更多数据 -->
|
||||
<view wx:if="{{noMoreData && surgeries.length > 0}}" class="no-more">
|
||||
<view class="no-more-line"></view>
|
||||
<text class="no-more-text">没有更多手术记录了</text>
|
||||
<view class="no-more-line"></view>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<!-- 空数据提示 -->
|
||||
<block wx:else>
|
||||
<view class="empty-container">
|
||||
<t-empty icon="info-circle-filled" description="暂无手术记录" />
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<t-fab icon="add" bind:click="handleClick" aria-label="增加"></t-fab>
|
||||
</view>
|
||||
</t-pull-down-refresh>
|
||||
|
||||
<!-- Toast 消息提示 -->
|
||||
<t-toast id="t-toast" />
|
||||
<!-- 确认删除的对话框 -->
|
||||
<t-dialog
|
||||
visible="{{confirmDialogVisible}}"
|
||||
title="确认删除"
|
||||
content="确定要删除此手术记录吗?此操作不可撤销。"
|
||||
confirm-btn="删除"
|
||||
cancel-btn="取消"
|
||||
bind:confirm="confirmDelete"
|
||||
bind:cancel="cancelDelete"
|
||||
/>
|
||||
@@ -0,0 +1,240 @@
|
||||
/* pages/surgery/index.wxss */
|
||||
page {
|
||||
background-color: #f7f8fa;
|
||||
}
|
||||
.surgery-searchbar {
|
||||
position: fixed;
|
||||
display: flex;
|
||||
z-index: 10;
|
||||
width: 100%;
|
||||
background: white;
|
||||
padding: 0 10px;
|
||||
gap: 0 10px;
|
||||
align-items: center;
|
||||
box-sizing: border-box;
|
||||
top: 0;
|
||||
}
|
||||
.surgery-radio {
|
||||
border-radius: 10px;
|
||||
}
|
||||
.surgery-search {
|
||||
flex: 1;
|
||||
}
|
||||
.surgery-container {
|
||||
padding: 24rpx 0;
|
||||
margin-top: 50px;
|
||||
}
|
||||
|
||||
/* 骨架屏样式 */
|
||||
.skeleton-item {
|
||||
background-color: #fff;
|
||||
border-radius: 8rpx;
|
||||
padding: 24rpx;
|
||||
margin: 16rpx 24rpx;
|
||||
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
/* 手术列表样式 */
|
||||
.surgery-list {
|
||||
padding: 0 24rpx;
|
||||
}
|
||||
|
||||
/* 滑动单元格容器 */
|
||||
.swipe-cell-container {
|
||||
margin-bottom: 16rpx;
|
||||
border-radius: 8rpx;
|
||||
overflow: hidden;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.surgery-card {
|
||||
background-color: #ffffff;
|
||||
border-radius: 8rpx;
|
||||
padding: 24rpx;
|
||||
position: relative;
|
||||
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* 有未完成设备的卡片样式 - 淡黄色背景 */
|
||||
.surgery-card--unfinished {
|
||||
background-color: #fff8e6;
|
||||
border-left: 6rpx solid #faad14;
|
||||
box-shadow: 0 2rpx 12rpx rgba(250, 173, 20, 0.15);
|
||||
}
|
||||
|
||||
/* 淡黄色卡片内的文本颜色调整 */
|
||||
.surgery-card--unfinished .surgery-title {
|
||||
color: #8b6914;
|
||||
}
|
||||
|
||||
.surgery-card--unfinished .info-item {
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.surgery-card--unfinished .doctor {
|
||||
background-color: rgba(250, 173, 20, 0.15);
|
||||
color: #8b6914;
|
||||
}
|
||||
|
||||
.surgery-card--unfinished .dept {
|
||||
background-color: rgba(250, 173, 20, 0.1);
|
||||
color: #8b6914;
|
||||
}
|
||||
|
||||
.surgery-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
margin-bottom: 16rpx;
|
||||
padding-right: 100rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
/* 未完成设备状态指示器 */
|
||||
.unfinished-indicator {
|
||||
margin-left: 16rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.unfinished-text {
|
||||
font-size: 22rpx;
|
||||
color: #faad14;
|
||||
background-color: rgba(250, 173, 20, 0.1);
|
||||
padding: 4rpx 12rpx;
|
||||
border-radius: 12rpx;
|
||||
border: 1rpx solid rgba(250, 173, 20, 0.3);
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.surgery-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8rpx;
|
||||
}
|
||||
|
||||
.info-item {
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.doctor-dept {
|
||||
margin-top: 8rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.doctor {
|
||||
font-size: 28rpx;
|
||||
color: #0052d9;
|
||||
background-color: #eef4ff;
|
||||
padding: 4rpx 12rpx;
|
||||
border-radius: 4rpx;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.dept {
|
||||
font-size: 28rpx;
|
||||
color: #06a56c;
|
||||
background-color: #e8f6f1;
|
||||
padding: 4rpx 12rpx;
|
||||
border-radius: 4rpx;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
/* 设备数量样式 */
|
||||
.device-count {
|
||||
margin-top: 8rpx;
|
||||
}
|
||||
|
||||
.device-count .count {
|
||||
font-size: 28rpx;
|
||||
color: #e54d42;
|
||||
background-color: #feecea;
|
||||
padding: 4rpx 12rpx;
|
||||
border-radius: 4rpx;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.surgery-id-tag {
|
||||
position: absolute;
|
||||
top: 24rpx;
|
||||
right: 24rpx;
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
/* 空状态和错误容器 */
|
||||
.empty-container,
|
||||
.error-container {
|
||||
padding: 100rpx 24rpx;
|
||||
}
|
||||
|
||||
/* 侧滑按钮样式 - 修改部分 */
|
||||
.swipe-cell-btn {
|
||||
height: 100% !important;
|
||||
width: 120rpx !important;
|
||||
display: flex !important;
|
||||
align-items: center !important;
|
||||
justify-content: center !important;
|
||||
font-size: 28rpx !important;
|
||||
}
|
||||
|
||||
.edit-btn {
|
||||
background-color: #0052d9 !important;
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
.delete-btn {
|
||||
background-color: #e34d59 !important;
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
/* 加载更多样式 */
|
||||
.loading-more {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 40rpx 0;
|
||||
}
|
||||
|
||||
/* 没有更多数据样式 */
|
||||
.no-more {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 40rpx 24rpx;
|
||||
margin: 20rpx 0;
|
||||
}
|
||||
|
||||
.no-more-line {
|
||||
flex: 1;
|
||||
height: 1px;
|
||||
background-color: #e0e0e0;
|
||||
}
|
||||
|
||||
.no-more-text {
|
||||
margin: 0 24rpx;
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
/* TDesign pull-down-refresh 容器调整 */
|
||||
.surgery-container {
|
||||
min-height: 100vh;
|
||||
padding: 24rpx 0;
|
||||
}
|
||||
|
||||
/* 修改TDesign原生样式,确保按钮高度与卡片一致 */
|
||||
.surgery-list .t-swipe-cell__right {
|
||||
height: 100% !important;
|
||||
display: flex !important;
|
||||
align-items: stretch !important;
|
||||
}
|
||||
Reference in New Issue
Block a user