first commit
This commit is contained in:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user