Compare commits

...

2 Commits

View File

@ -17,7 +17,7 @@
:autoplay="true" :autoplay="true"
height="500" height="500"
:interval="3000" :interval="3000"
border-radius="12" border-radius="12"
> >
<view slot="indicator" class="indicator"> <view slot="indicator" class="indicator">
<view <view
@ -34,22 +34,26 @@
<!-- 设备基本信息区 --> <!-- 设备基本信息区 -->
<view class="equipment-info"> <view class="equipment-info">
<view class="info-card"> <view class="info-card">
<text class="device-id">{{equipmentDetail.name || '未知设备'}}</text> <text class="device-id">{{
<text class="device-model">{{equipmentDetail.model || '未知型号'}}</text> equipmentDetail.name || "未知设备"
}}</text>
<text class="device-model">{{
equipmentDetail.model || "未知型号"
}}</text>
</view> </view>
</view> </view>
<!-- 维保记录区 --> <!-- 维保记录区 -->
<view class="maintenance-records"> <view class="maintenance-records">
<view class="section-title"> <view class="section-title">
<text style="z-index:1;">维保记录</text> <text style="z-index: 1">维保记录</text>
<view class="title-underline"></view> <view class="title-underline"></view>
</view> </view>
<view class="record-list"> <view class="record-list">
<view <view
class="record-item" class="record-item"
v-for="(record, index) in maintenanceRecords" v-for="(record, index) in maintenanceRecords || []"
:key="index" :key="index"
> >
<view class="record-image"> <view class="record-image">
@ -102,7 +106,7 @@
custom-style="font-size:32rpx;" custom-style="font-size:32rpx;"
placeholder="请选择维保类型" placeholder="请选择维保类型"
type="select" type="select"
v-model="maintenanceType" v-model="recordForm.type"
@click="handleClickType()" @click="handleClickType()"
:clearable="false" :clearable="false"
/> />
@ -118,9 +122,9 @@
:maxlength="100" :maxlength="100"
/> />
<view class="word-count"> <view class="word-count">
{{ recordForm.description ? recordForm.description.length : 0 }} {{ recordForm.description ? recordForm.description.length : 0 }}
<view class="word-count-max">/100</view> <view class="word-count-max">/100</view>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
@ -163,10 +167,10 @@ export default {
title: "默认图片" title: "默认图片"
}], }],
currentImageIndex: 0, currentImageIndex: 0,
// //
topLevel: 0, topLevel: 0,
// //
scrollTop: 0, scrollTop: 0,
// //
equipmentDetail: {}, equipmentDetail: {},
maintenanceRecords: [], maintenanceRecords: [],
@ -182,9 +186,8 @@ export default {
showTypePicker: false, showTypePicker: false,
maintenanceType: "", maintenanceType: "",
maintenanceTypes: [ maintenanceTypes: [
{ label: "三方险", value: 1 }, { label: "例行检查", value: 0 },
{ label: "设备险", value: 2 }, { label: "电池损坏", value: 1 },
{ label: "运营险", value: 3 },
], ],
recordForm: { recordForm: {
type: "", type: "",
@ -193,8 +196,8 @@ export default {
}; };
}, },
onLoad(e) { onLoad(e) {
this.deviceId = e.id; this.deviceId = e.id;
}, },
mounted() { mounted() {
// ID // ID
this.loadDeviceDetail(); this.loadDeviceDetail();
@ -205,14 +208,14 @@ export default {
async loadDeviceDetail() { async loadDeviceDetail() {
try { try {
const detail = await this.$api.getDevicesDetail(this.deviceId); const detail = await this.$api.getDevicesDetail(this.deviceId);
console.log('设备详情:', detail); console.log("设备详情:", detail);
if (detail) { if (detail) {
this.equipmentDetail = detail; this.equipmentDetail = detail;
// //
if (detail.deviceImages && detail.deviceImages.length > 0) { if (detail.deviceImages && detail.deviceImages.length > 0) {
this.equipmentImages = detail.deviceImages.map(img => ({ this.equipmentImages = detail.deviceImages.map((img) => ({
image: img.fileFullPath, image: img.fileFullPath,
title: img.sourceFileName title: img.sourceFileName,
})); }));
} else { } else {
this.equipmentImages = [{ this.equipmentImages = [{
@ -222,10 +225,10 @@ export default {
} }
} }
} catch (err) { } catch (err) {
console.error('获取设备详情失败:', err); console.error("获取设备详情失败:", err);
uni.showToast({ uni.showToast({
title: '获取设备详情失败', title: "获取设备详情失败",
icon: 'none' icon: "none",
}); });
} }
}, },
@ -234,21 +237,23 @@ export default {
async loadMaintenanceRecords() { async loadMaintenanceRecords() {
try { try {
const res = await this.$api.getMaintenanceRecords({ const res = await this.$api.getMaintenanceRecords({
aircraftId: this.deviceId aircraftId: this.deviceId,
}); });
if (res && res.records) { if (res && res.records && res.records.length > 0) {
this.maintenanceRecords = res.records.map(record => ({ this.maintenanceRecords = res.records.map((record) => ({
type: this.getMaintenanceTypeName(record.maintenanceType), type: this.getMaintenanceTypeName(record.maintenanceType),
operator: record.createBy || '未知', operator: record.createBy || "未知",
time: record.createTime || '未知时间', time: record.createTime || "未知时间",
description: record.remark || '无' description: record.remark || "无",
})); }));
} else {
this.maintenanceRecords = [];
} }
} catch (err) { } catch (err) {
console.error('获取维保记录失败:', err); console.error("获取维保记录失败:", err);
uni.showToast({ uni.showToast({
title: '获取维保记录失败', title: "获取维保记录失败",
icon: 'none' icon: "none",
}); });
} }
}, },
@ -256,18 +261,18 @@ export default {
// //
getMaintenanceTypeName(type) { getMaintenanceTypeName(type) {
const typeMap = { const typeMap = {
0: '例行检查', 0: "例行检查",
1: '电池损坏', 1: "电池损坏",
}; };
return typeMap[type] || '未知类型'; return typeMap[type] || "未知类型";
}, },
onPageScroll(e) { onPageScroll(e) {
const level = e.scrollTop/60; const level = e.scrollTop / 60;
if(level<=1) this.topLevel = level; if (level <= 1) this.topLevel = level;
else this.topLevel = 1; else this.topLevel = 1;
this.scrollTop = e.scrollTop; this.scrollTop = e.scrollTop;
}, },
// //
showAddRecordModal() { showAddRecordModal() {
this.showRecordPopup = true; this.showRecordPopup = true;
@ -278,7 +283,7 @@ export default {
}; };
this.maintenanceType = ""; this.maintenanceType = "";
}, },
// //
closeAddAction() { closeAddAction() {
// this.clearForm(); // this.clearForm();
this.showRecordPopup = false; this.showRecordPopup = false;
@ -302,7 +307,9 @@ export default {
} }
// //
const selectedType = this.maintenanceTypes.find(t => t.label === this.recordForm.type); const selectedType = this.maintenanceTypes.find(
(t) => t.label === this.recordForm.type
);
if (!selectedType) { if (!selectedType) {
uni.showToast({ uni.showToast({
title: "请选择正确的维保类型", title: "请选择正确的维保类型",
@ -326,17 +333,18 @@ export default {
aircraftId: this.deviceId, aircraftId: this.deviceId,
employeesId: employeesId, employeesId: employeesId,
maintenanceType: selectedType.value, maintenanceType: selectedType.value,
remark: this.recordForm.description remark: this.recordForm.description,
}); createTime: new Date().toISOString(),
});
uni.showToast({ uni.showToast({
title: '添加成功', title: "添加成功",
icon: 'success' icon: "success",
}); });
// //
await this.loadMaintenanceRecords(); await this.loadMaintenanceRecords();
// //
this.showRecordPopup = false; this.showRecordPopup = false;
this.recordForm = { this.recordForm = {
@ -345,22 +353,23 @@ export default {
}; };
this.maintenanceType = ""; this.maintenanceType = "";
} catch (err) { } catch (err) {
console.error('添加维保记录失败:', err); console.error("添加维保记录失败:", err);
uni.showToast({ uni.showToast({
title: '添加失败', title: "添加失败",
icon: 'none' icon: "none",
}); });
} }
}, },
// //
handleTypeSelect(e) { handleTypeSelect(e) {
if (e && e.indexs && e.indexs.length > 0) { if (e && typeof e[0] === "number") {
const selected = this.maintenanceTypes[e.indexs[0]]; const selected = this.maintenanceTypes[e[0]];
if (selected) { if (selected) {
this.recordForm.type = selected.label; this.recordForm.type = selected.label;
this.maintenanceType = selected.label; this.maintenanceType = selected.label;
} }
console.log("选中的维保类型:", this.recordForm.type);
} }
}, },
}, },
@ -372,11 +381,11 @@ export default {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
// min-height: 100vh; // min-height: 100vh;
background-color: #F5F5F5; background-color: #f5f5f5;
.detail-container { .detail-container {
flex: 1; flex: 1;
min-height: 100vh; min-height: 100vh;
} }
// //
@ -388,18 +397,18 @@ export default {
// margin-bottom: 20rpx; // margin-bottom: 20rpx;
} }
::v-deep .u-indicator-item-dot { ::v-deep .u-indicator-item-dot {
width: 20rpx; width: 20rpx;
height: 20rpx; height: 20rpx;
border-radius: 50%; border-radius: 50%;
opacity: 0.5; opacity: 0.5;
margin: 0 8rpx; margin: 0 8rpx;
margin-bottom: 25rpx; margin-bottom: 25rpx;
background-color: #999999 !important; /* 默认颜色 */ background-color: #999999 !important; /* 默认颜色 */
} }
::v-deep .u-indicator-item-dot-active { ::v-deep .u-indicator-item-dot-active {
opacity: 1; opacity: 1;
background-color: #fee547 !important; /* 选中颜色 */ background-color: #fee547 !important; /* 选中颜色 */
} }
.indicator { .indicator {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
@ -440,10 +449,10 @@ export default {
// box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.05); // box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.05);
.device-id { .device-id {
font-family: Source Han Sans SC; font-family: Source Han Sans SC;
font-weight: bold; font-weight: bold;
font-size: 36rpx; font-size: 36rpx;
color: #333333; color: #333333;
} }
.device-model { .device-model {
@ -460,9 +469,9 @@ export default {
background-color: #ffffff; background-color: #ffffff;
border-radius: 16rpx; border-radius: 16rpx;
padding: 30rpx 20rpx; padding: 30rpx 20rpx;
margin: 24rpx; margin: 24rpx;
margin-top: 0; margin-top: 0;
.section-title { .section-title {
font-size: 36rpx; font-size: 36rpx;
font-weight: bold; font-weight: bold;
@ -487,22 +496,23 @@ export default {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 26rpx; gap: 26rpx;
.record-item:first-child { .record-item:first-child {
box-shadow: 0rpx -6rpx 10rpx 0rpx rgba(226,226,226,0.3), 0rpx 6rpx 8rpx 0rpx rgba(218,218,218,0.3); box-shadow: 0rpx -6rpx 10rpx 0rpx rgba(226, 226, 226, 0.3),
} 0rpx 6rpx 8rpx 0rpx rgba(218, 218, 218, 0.3);
}
.record-item { .record-item {
display: flex; display: flex;
gap: 20rpx; gap: 20rpx;
padding: 30rpx 20rpx 37rpx 20rpx; padding: 30rpx 20rpx 37rpx 20rpx;
border-radius: 8rpx; border-radius: 8rpx;
box-shadow: 0rpx 6rpx 10rpx 0rpx rgba(200,199,193,0.3); box-shadow: 0rpx 6rpx 10rpx 0rpx rgba(200, 199, 193, 0.3);
.record-image { .record-image {
width: 123rpx; width: 123rpx;
height: 123rpx; height: 123rpx;
border-radius: 12rpx; border-radius: 12rpx;
border: 3rpx solid #FEE547; border: 3rpx solid #fee547;
.thumbnail { .thumbnail {
width: 100%; width: 100%;
height: 100%; height: 100%;
@ -514,13 +524,13 @@ export default {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: space-between; justify-content: space-between;
gap: 8rpx; gap: 8rpx;
.info-top { .info-top {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 8rpx; gap: 8rpx;
.record-type { .record-type {
font-family: Source Han Sans SC; font-family: Source Han Sans SC;
font-weight: bold; font-weight: bold;
@ -540,10 +550,10 @@ export default {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 8rpx; gap: 8rpx;
font-family: Source Han Sans SC; font-family: Source Han Sans SC;
font-weight: 400; font-weight: 400;
font-size: 28rpx; font-size: 28rpx;
color: #666666; color: #666666;
} }
} }
} }
@ -638,23 +648,31 @@ export default {
} }
.textarea-container { .textarea-container {
position: relative; position: relative;
height: 420rpx; height: 420rpx;
.u-input {
height: 100%;
font-size: 32rpx;
color: #333333;
padding: 20rpx 30rpx;
border-radius: 12rpx;
background-color: #f5f5f5;
}
.word-count { .word-count {
position: absolute; position: absolute;
right: 20rpx; right: 20rpx;
bottom: 103rpx; bottom: 103rpx;
font-family: Arial; font-family: Arial;
font-weight: 400; font-weight: 400;
font-size: 32rpx; font-size: 32rpx;
color: #B3B3B3; color: #b3b3b3;
.word-count-max { .word-count-max {
color: #333333; color: #333333;
display: inline-block; display: inline-block;
} }
} }
} }
// //
.record-form { .record-form {
padding: 40rpx 30rpx; padding: 40rpx 30rpx;