提交 2eee7568 authored 作者: JaxBBLL's avatar JaxBBLL

fix

上级 6ca36df7
......@@ -10,5 +10,14 @@ export default {
this.itemData.status = 1;
}
},
setQtValue(data) {
// 公用-全部机房】其它问题----有填写过内容的,直接带出
if (this.isQt) {
this.itemData.detail.forEach((item) => {
item.conclusion = data.conclusion;
item.photos = data.photos;
});
}
},
},
};
......@@ -15,31 +15,20 @@
</view>
<view class="form-item">
<text class="form-label"><text class="required"></text>现场照片</text>
<CommonUpload v-model="item.photos" :max-count="5"> </CommonUpload>
<!-- <view class="photo-box">
<view class="photo-container">
<view
v-for="(photo, itemIndex) in item && item.photos"
:key="itemIndex"
class="photo-item"
>
<image :src="photo" class="photo"></image>
<text class="delete-photo" @click="deletePhoto(index, itemIndex)"
>×</text
>
</view>
<view @click="takePhoto(index)" class="photo-btn"> + </view>
</view>
<view class="photo-limit"
>请对检查项进行拍照留存(限5张)。发现“异常、告警”时,需拍照留存。</view
>
</view> -->
</view> </view
><custom-popup
<CommonUpload
v-model="item.photos"
:max-count="9999"
@change="onPhotoChange"
>
</CommonUpload>
</view>
</view>
<custom-popup
ref="customPopup"
:inspectionItem="inspectionItem"
@confirm="handlePopupConfirm"
></custom-popup>
>
</custom-popup>
</view>
</template>
......@@ -111,55 +100,6 @@ export default {
},
mounted() {},
methods: {
// 拍照
takePhoto(index) {
uni.chooseImage({
count: 1,
sourceType: ["camera"], // 可以从相机拍摄
success: async (res) => {
if (this.photos.length < 5) {
const base64 = await this.convertFileToBase64(res.tempFilePaths[0]);
this.itemData.detail[index].photos.push(base64);
} else {
uni.showToast({
title: "最多只能上传5张照片",
icon: "none",
});
}
},
});
},
// 转化为base64
convertFileToBase64(filePath) {
return new Promise((resolve, reject) => {
plus.io.resolveLocalFileSystemURL(
filePath,
function (entry) {
entry.file(
function (file) {
const reader = new plus.io.FileReader();
reader.onloadend = function (evt) {
const base64 = evt.target.result; // 获取 Base64 数据
resolve(base64); // 返回 Base64 数据
};
reader.readAsDataURL(file); // 读取文件并转换为 Base64
},
function (error) {
reject("获取文件对象失败:" + error.message);
}
);
},
function (error) {
reject("解析文件路径失败:" + error.message);
}
);
});
},
// 删除照片
deletePhoto(index, itemIndex) {
this.itemData.detail[index].photos.splice(itemIndex, 1);
},
// 设置巡检结论
setInspectionResult(index, value) {
this.itemData.detail[index].inspectionResult = value; // 0正常 1异常
......@@ -172,6 +112,11 @@ export default {
// 处理弹窗确认
handlePopupConfirm(summary) {
this.itemData.detail[this.currentIndex].conclusion = summary; // 回显到文字显示区域
console.log("qt");
this.$emit("sync", {
conclusion: summary,
photos: this.itemData.detail[this.currentIndex].photos,
});
},
// 处理】数据
getFromData() {
......@@ -217,6 +162,13 @@ export default {
areAllInspectionResultsOne(arr) {
return arr.every((obj) => obj.inspectionResult === 0);
},
onPhotoChange(val) {
this.itemData.detail[this.currentIndex].photos = val;
this.$emit("sync", {
conclusion: this.itemData.detail[this.currentIndex].conclusion,
photos: val,
});
},
},
};
</script>
......
......@@ -111,6 +111,7 @@
ref="qt"
inspectionItem="其它"
:defaultData="list.qt || {}"
@sync="setQtValue"
></qt>
</view>
</view>
......@@ -145,6 +146,7 @@
<script>
import assRoomApi from "@/api/assRoom.js";
import inspectApi from "@/api/assRoom.js";
import { dataToSql } from "./shared";
import {
......@@ -497,7 +499,7 @@ export default {
},
realSave(data) {
const send = dataToSql(data);
assRoomApi.saveBatch([send]).then((res) => {
inspectApi.save(send).then((res) => {
console.log(res);
});
},
......@@ -755,6 +757,16 @@ export default {
closePopup() {
this.switchTab((this.activeTab + 1) % this.tabs.length);
},
setQtValue(data) {
this.tabs.forEach((item) => {
let refName = item.value;
// 通过 this.$refs[refName] 获取子组件实例
const childComponent = this.$refs[refName];
if (childComponent && childComponent.setQtValue) {
childComponent.setQtValue(data);
}
});
},
},
};
</script>
......
......@@ -10,6 +10,7 @@ export function dataToSql(data) {
synFlag = data.synchronization;
}
const send = {
id: data.id,
inspectionType: data.inspectionType,
inspectionCode: data.inspectionCode,
recordName: `${moment().format("yyyyMMDD")}-机房巡检`,
......@@ -24,18 +25,35 @@ export function dataToSql(data) {
creatTime: data.id ? data.creatTime : `${new Date().getTime()}`,
updateTime: `${new Date().getTime()}`,
inspectionData: data.originData,
// isSubmit: 1,
// isSign: false,
// signImg: "",
// conclusion: "",
// creatTime: "1744023337279",
// items: [],
// synchronization: 0,
// submitTime: "2025-04-07",
// submitMonth: "2025-04",
// originData: data.originData,
};
console.log("dataToSql", send);
return send;
}
export function sqlToData(sqlData) {
let isSubmit;
let synchronization;
if (sqlData.synFlag === 0) {
isSubmit = 0;
synchronization = 0;
} else {
isSubmit = 1;
synchronization = sqlData.synFlag;
}
const originalData = {
id: sqlData.id,
inspectionType: sqlData.inspectionType,
inspectionCode: sqlData.inspectionCode,
isException: sqlData.isException,
inspectionNumber: sqlData.inspectionNumber,
signImg: sqlData.signImg,
originData: sqlData.inspectionData,
creatTime: sqlData.creatTime,
isSubmit: isSubmit,
synchronization: synchronization,
};
return originalData;
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论