提交 cb6b97ee authored 作者: BaoChunXian's avatar BaoChunXian
...@@ -46,6 +46,10 @@ export default { ...@@ -46,6 +46,10 @@ export default {
type: Array, type: Array,
default: () => ["camera"], // 默认从相机拍摄 default: () => ["camera"], // 默认从相机拍摄
}, },
sizeType: {
type: Array,
default: () => ["compressed"], // 默认压缩图 ["original", "compressed"]
},
}, },
data() { data() {
return { return {
...@@ -60,12 +64,96 @@ export default { ...@@ -60,12 +64,96 @@ export default {
this.$emit("input", newVal); // 同步更新父组件绑定的数据 this.$emit("input", newVal); // 同步更新父组件绑定的数据
}, },
}, },
methods: { methods: {
// 检查并请求权限
// async checkAndRequestPermission() {
// // 定义所需权限
// const permissions = [];
// if (this.sourceType.includes("camera")) {
// permissions.push("android.permission.CAMERA"); // 相机权限
// }
// if (this.sourceType.includes("album")) {
// permissions.push("android.permission.READ_EXTERNAL_STORAGE"); // 相册权限
// }
// // 检查权限状态
// const hasPermission = await new Promise((resolve) => {
// plus.android.requestPermissions(
// permissions,
// (result) => {
// let granted = true;
// for (let i = 0; i < result.granted.length; i++) {
// if (!result.granted[i]) {
// granted = false;
// break;
// }
// }
// resolve(granted);
// },
// (error) => {
// console.error("权限请求失败:", error.message);
// resolve(false);
// }
// );
// });
// if (!hasPermission) {
// // 用户拒绝授权,弹出提示
// uni.showModal({
// title: "权限提示",
// content:
// "您拒绝了必要的权限,可能导致功能无法正常使用。是否前往设置页面开启权限?",
// success: (modalRes) => {
// if (modalRes.confirm) {
// // 打开应用设置页面
// plus.runtime.openURL(
// "app-settings://", // 跳转到系统设置页面
// (err) => {
// console.error("跳转设置页面失败:", err.message);
// }
// );
// }
// },
// });
// return false;
// }
// return true;
// },
// // 选择图片
// async chooseImage() {
// // 检查权限
// const isAuthorized = await this.checkAndRequestPermission();
// if (!isAuthorized) return;
// const count = this.maxCount - this.images.length; // 剩余可选图片数量
// uni.chooseImage({
// count: count,
// sizeType: this.sizeType,
// sourceType: this.sourceType, // 使用传递的 sourceType
// success: async (res) => {
// const tempFilePaths = res.tempFilePaths;
// for (const filePath of tempFilePaths) {
// const base64 = await this.convertFileToBase64(filePath);
// this.images.push(base64);
// }
// },
// fail: (err) => {
// console.error("选择图片失败:", err);
// uni.showToast({
// title: "选择图片失败,请重试",
// icon: "none",
// });
// },
// });
// },
// 选择图片 // 选择图片
chooseImage() { chooseImage() {
const count = this.maxCount - this.images.length; // 剩余可选图片数量 const count = this.maxCount - this.images.length; // 剩余可选图片数量
uni.chooseImage({ uni.chooseImage({
count: count, count: count,
sizeType: this.sizeType,
sourceType: this.sourceType, // 使用传递的 sourceType sourceType: this.sourceType, // 使用传递的 sourceType
success: async (res) => { success: async (res) => {
const tempFilePaths = res.tempFilePaths; const tempFilePaths = res.tempFilePaths;
......
...@@ -23,15 +23,46 @@ ...@@ -23,15 +23,46 @@
@click="setInspectionResult(index, 1, item.lableArr[1])" @click="setInspectionResult(index, 1, item.lableArr[1])"
> >
{{ item.lableArr[1] }} {{ item.lableArr[1] }}
</view> </view </view>
><input </view>
<!-- <input
v-if="'value' in item" v-if="'value' in item"
class="input" class="input"
v-model="item.value" v-model="item.value"
type="text" type="text"
placeholder="请输入" placeholder="请输入"
maxlength="3" maxlength="3"
/>{{ item.unit }} /> -->
<template v-if="'value' in item">
<NumberInput
v-if="index == 0"
class="input"
v-model="item.value"
type="number"
allowNegative
:max="100"
:min="-100"
placeholder="请输入"
/>
<NumberInput
v-if="index == 1"
class="input"
v-model="item.value"
type="number"
:max="100"
:min="0"
placeholder="请输入"
/>
<NumberInput
v-else
class="input"
v-model="item.value"
type="number"
placeholder="请输入"
/>
</template>
{{ item.unit }}
</view> </view>
<template v-if="item.inspectionResult === 1"> <template v-if="item.inspectionResult === 1">
<view v-if="'conclusion' in item" class="form-item"> <view v-if="'conclusion' in item" class="form-item">
...@@ -81,6 +112,7 @@ ...@@ -81,6 +112,7 @@
</template> </template>
<script> <script>
import NumberInput from "@/components/NumberInput/index.vue";
import CommonUpload from "@/components/CommonUpload/index.vue"; import CommonUpload from "@/components/CommonUpload/index.vue";
import customPopup from "./customPopup.vue"; import customPopup from "./customPopup.vue";
import _ from "lodash"; import _ from "lodash";
...@@ -88,6 +120,7 @@ import mixin from "./mixin"; ...@@ -88,6 +120,7 @@ import mixin from "./mixin";
export default { export default {
mixins: [mixin], mixins: [mixin],
components: { components: {
NumberInput,
CommonUpload, CommonUpload,
customPopup, customPopup,
}, },
......
...@@ -23,14 +23,39 @@ ...@@ -23,14 +23,39 @@
@click="setInspectionResult(index, 1, item.lableArr[1])" @click="setInspectionResult(index, 1, item.lableArr[1])"
> >
{{ item.lableArr[1] }} {{ item.lableArr[1] }}
</view> </view </view>
><input </view>
<!-- <input
v-if="'value' in item" v-if="'value' in item"
class="input" class="input"
v-model="item.value" v-model="item.value"
type="text" type="text"
placeholder="请输入" placeholder="请输入"
/>{{ item.unit }} /> -->
<template v-if="'value' in item">
<NumberInput
v-if="index == 0"
class="input"
v-model="item.value"
type="number"
allowNegative
:max="100"
:min="-100"
placeholder="请输入"
/>
<NumberInput
v-if="index == 1"
class="input"
v-model="item.value"
type="number"
:max="100"
:min="0"
placeholder="请输入"
/>
</template>
{{ item.unit }}
</view> </view>
<template v-if="item.inspectionResult === 1"> <template v-if="item.inspectionResult === 1">
<view v-if="'conclusion' in item" class="form-item"> <view v-if="'conclusion' in item" class="form-item">
...@@ -80,6 +105,7 @@ ...@@ -80,6 +105,7 @@
</template> </template>
<script> <script>
import NumberInput from "@/components/NumberInput/index.vue";
import CommonUpload from "@/components/CommonUpload/index.vue"; import CommonUpload from "@/components/CommonUpload/index.vue";
import customPopup from "./customPopup.vue"; import customPopup from "./customPopup.vue";
import _ from "lodash"; import _ from "lodash";
...@@ -87,6 +113,7 @@ import mixin from "./mixin"; ...@@ -87,6 +113,7 @@ import mixin from "./mixin";
export default { export default {
mixins: [mixin], mixins: [mixin],
components: { components: {
NumberInput,
CommonUpload, CommonUpload,
customPopup, customPopup,
}, },
......
...@@ -23,15 +23,26 @@ ...@@ -23,15 +23,26 @@
@click="setInspectionResult(index, 1, item.lableArr[1])" @click="setInspectionResult(index, 1, item.lableArr[1])"
> >
{{ item.lableArr[1] }} {{ item.lableArr[1] }}
</view> </view </view>
><input </view>
<!-- <input
v-if="'value' in item && item.inspectionResult === 1" v-if="'value' in item && item.inspectionResult === 1"
class="input" class="input"
v-model="item.value" v-model="item.value"
type="text" type="text"
placeholder="请输入" placeholder="请输入"
maxlength="3" maxlength="3"
/>{{ item.inspectionResult === 1 ? item.unit : "" }} /> -->
<NumberInput
v-if="'value' in item && item.inspectionResult === 1"
class="input"
v-model="item.value"
type="number"
:max="10"
:min="0"
placeholder="请输入"
/>
{{ item.inspectionResult === 1 ? item.unit : "" }}
</view> </view>
<template v-if="item.inspectionResult === 1"> <template v-if="item.inspectionResult === 1">
<view v-if="'conclusion' in item" class="form-item"> <view v-if="'conclusion' in item" class="form-item">
...@@ -81,6 +92,7 @@ ...@@ -81,6 +92,7 @@
</template> </template>
<script> <script>
import NumberInput from "@/components/NumberInput/index.vue";
import CommonUpload from "@/components/CommonUpload/index.vue"; import CommonUpload from "@/components/CommonUpload/index.vue";
import customPopup from "./customPopup.vue"; import customPopup from "./customPopup.vue";
import _ from "lodash"; import _ from "lodash";
...@@ -88,6 +100,7 @@ import mixin from "./mixin"; ...@@ -88,6 +100,7 @@ import mixin from "./mixin";
export default { export default {
mixins: [mixin], mixins: [mixin],
components: { components: {
NumberInput,
CommonUpload, CommonUpload,
customPopup, customPopup,
}, },
......
...@@ -47,6 +47,9 @@ ...@@ -47,6 +47,9 @@
></image> ></image>
<button class="record-button" @click="toSign">重签</button> <button class="record-button" @click="toSign">重签</button>
</div> </div>
<button class="record-button ml-10" @click="onSyncData">
数据同步
</button>
</view> </view>
</view> </view>
</view> </view>
...@@ -285,6 +288,7 @@ export default { ...@@ -285,6 +288,7 @@ export default {
getRoomList() { getRoomList() {
return assRoomApi.selectRoomList(1).then((res) => { return assRoomApi.selectRoomList(1).then((res) => {
console.log("机房列表", res); console.log("机房列表", res);
console.log("机房列表", JSON.stringify(res));
return res; return res;
}); });
}, },
...@@ -534,7 +538,16 @@ export default { ...@@ -534,7 +538,16 @@ export default {
(item) => item.status == 2 (item) => item.status == 2
); );
this.detailsInfo.isException = isException ? 1 : 0; // 巡检异常 this.detailsInfo.isException = isException ? 1 : 0; // 巡检异常
console.log("isException", isException);
let allIsSubmitOne = this.detailsInfo.originData.every(
(item) => item.isSubmit === 1
);
if (!allIsSubmitOne) {
// 如果有机房没有巡检完,记录是编辑状态
this.detailsInfo.synchronization = 2;
}
this.realSave(this.detailsInfo); this.realSave(this.detailsInfo);
}, },
realSave(params, type = "sign") { realSave(params, type = "sign") {
...@@ -593,6 +606,9 @@ export default { ...@@ -593,6 +606,9 @@ export default {
urls: images, urls: images,
}); });
}, },
onSyncData() {
console.log(this.uid);
},
}, },
}; };
</script> </script>
......
...@@ -381,6 +381,16 @@ export default { ...@@ -381,6 +381,16 @@ export default {
this.detailsInfo.submitTime = moment().format("yyyy-MM-DD"); // 记录提交时间 this.detailsInfo.submitTime = moment().format("yyyy-MM-DD"); // 记录提交时间
this.detailsInfo.submitMonth = moment().format("yyyy-MM"); // 记录提交月份 this.detailsInfo.submitMonth = moment().format("yyyy-MM"); // 记录提交月份
this.listData = this.detailsInfo.originData; this.listData = this.detailsInfo.originData;
let allIsSubmitOne = this.detailsInfo.originData.every(
(item) => item.isSubmit === 1
);
if (!allIsSubmitOne) {
// 如果有机房没有巡检完,记录是编辑状态
this.detailsInfo.synchronization = 2;
}
return this.detailsInfo; return this.detailsInfo;
} else { } else {
let baseInfo = this.baseInfo; let baseInfo = this.baseInfo;
...@@ -430,7 +440,17 @@ export default { ...@@ -430,7 +440,17 @@ export default {
submitMonth: moment().format("yyyy-MM"), // 记录提交月份 submitMonth: moment().format("yyyy-MM"), // 记录提交月份
originData: tabList, //所有大楼和楼层的数据 originData: tabList, //所有大楼和楼层的数据
}; };
console.log("getParams,data", data); /**记录的isSubmit0暂存(编辑中) 1提交(待同步,已同步)
* 得检测每个机房是否巡检完
*/
let allIsSubmitOne = data.originData.every(
(item) => item.isSubmit === 1
);
if (!allIsSubmitOne) {
// 如果有机房没有巡检完,记录是编辑状态
data.synchronization = 2;
}
console.log("getParams", data);
this.listData = data.originData; this.listData = data.originData;
return data; return data;
} }
...@@ -528,6 +548,7 @@ export default { ...@@ -528,6 +548,7 @@ export default {
} }
const params = this.getParams(isSubmit); //数据获取 const params = this.getParams(isSubmit); //数据获取
console.log("提交时获取一次", params); console.log("提交时获取一次", params);
this.all_data = this.$store.state.all_data || [];
this.realSave(params).then(() => { this.realSave(params).then(() => {
let logContent = ""; let logContent = "";
...@@ -566,8 +587,11 @@ export default { ...@@ -566,8 +587,11 @@ export default {
// 更新日志 // 更新日志
const log_list = this.$store.state.log_list; const log_list = this.$store.state.log_list;
logContent.inspectionType = params.inspectionType; logContent.inspectionType = params.inspectionType;
console.log("logContent", logContent);
log_list.push(logContent); log_list.push(logContent);
this.$store.commit("SET_LOG_LIST", log_list); this.$store.commit("SET_LOG_LIST", log_list);
addLog(log_list).then((res) => { addLog(log_list).then((res) => {
console.log("日志文件写入成功"); console.log("日志文件写入成功");
}); });
......
...@@ -3,21 +3,21 @@ import store from "@/store"; ...@@ -3,21 +3,21 @@ import store from "@/store";
// 将现有机房巡检数据转换为SQL数据所需要格式 // 将现有机房巡检数据转换为SQL数据所需要格式
export function dataToSql(data) { export function dataToSql(data) {
let isException = 0; // let isException = 0;
if (data.isSubmit == 0) { // if (data.isSubmit == 0) {
isException = 2; // isException = 2;
} else { // } else {
isException = data.isException; // isException = data.isException;
} // }
const send = { const send = {
inspectionType: data.inspectionType, inspectionType: data.inspectionType,
inspectionCode: data.inspectionCode, inspectionCode: data.inspectionCode,
recordName: `${moment().format("yyyyMMDD")}-机房巡检`, recordName: `${moment().format("yyyyMMDD")}-机房巡检`,
inspectionTime: `${new Date().getTime()}`, inspectionTime: `${new Date().getTime()}`,
isException, // 是否异常:0 否 1 是 2.编辑 isException: data.isException, // 是否异常:0 否 1 是
userId: store.state.now_user.userId, userId: store.state.now_user.userId,
userName: store.state.now_user.user, userName: store.state.now_user.user,
synFlag: data.synchronization, // 0.未同步,1.已同步 synFlag: data.synchronization, // 0.未同步,1.已同步 2.编辑
signImg: data.signImg || "", signImg: data.signImg || "",
createBy: store.state.now_user.userId, createBy: store.state.now_user.userId,
createTime: data.id ? data.createTime : `${new Date().getTime()}`, createTime: data.id ? data.createTime : `${new Date().getTime()}`,
...@@ -29,9 +29,16 @@ export function dataToSql(data) { ...@@ -29,9 +29,16 @@ export function dataToSql(data) {
} }
export function sqlToData(sqlData) { export function sqlToData(sqlData) {
// 初始化 isSubmit 和 synchronization let isSubmit;
let isSubmit = sqlData.synFlag === 0 ? 0 : 1; // 如果未同步,则未提交;否则已提交 let synchronization;
let synchronization = sqlData.synFlag || 0; // 默认值为 0(未同步)
if (sqlData.synFlag === 0) {
isSubmit = 0;
synchronization = 0;
} else {
isSubmit = 1;
synchronization = sqlData.synFlag;
}
// 解析 inspectionData,确保其为 JSON 格式 // 解析 inspectionData,确保其为 JSON 格式
const originData = JSON.parse(sqlData.inspectionData || "[]"); const originData = JSON.parse(sqlData.inspectionData || "[]");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论