提交 ca6366a6 authored 作者: BaoChunXian's avatar BaoChunXian

feayt: 井道巡检

上级 7a83284c
...@@ -178,4 +178,22 @@ export default { ...@@ -178,4 +178,22 @@ export default {
} }
console.log("更新完成..."); console.log("更新完成...");
}, },
async updateSignImg(data) {
console.log("开始更新巡检签名图片", data);
let sqllitedb = await SqlliteDbUtil.initSqlliteDB();
try {
if (!data.id) {
throw new Error("更新操作需要提供 id");
}
let sql = `UPDATE ${table.inspectionRecordName} SET
signImg = '${data.signImg}'
WHERE id = ${data.id}`;
await sqllitedb.executeSQL(sql);
} catch (e) {
console.log(e.message);
} finally {
await sqllitedb.closeDB();
}
console.log("更新完成...");
},
}; };
<template> <template>
<view class="inspect-item" @click="toPage"> <view class="inspect-item" @click="toPage">
<view class="content" :class="details.synchronization == 1 ? 'synchronization' : ''"> <view class="content" :class="details.synFlag == 1 ? 'synchronization' : ''">
<view class="name">{{ <view class="name">{{
details.isSubmit == 0 ? "编辑中" :details.synchronization == 0 ? "待同步" : "已同步" details.isSubmit == 0 ? "编辑中" :details.synFlag == 0 ? "待同步" : "已同步"
}}</view> }}</view>
<view class="info"> <view class="info">
<view class="info-row"> <view class="info-row">
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
}`; }`;
uni.navigateTo({ uni.navigateTo({
url: `${url}&uid=${this.details.uid}`, url: `${url}&uid=${this.details.id}`,
}); });
}, },
}, },
......
...@@ -54,8 +54,8 @@ export default { ...@@ -54,8 +54,8 @@ export default {
props: { props: {
// 父组件传递的详情 // 父组件传递的详情
detailsItem: { detailsItem: {
type: Object, type: Array,
default: () => {}, default: () => ([]),
}, },
}, },
data() { data() {
......
差异被折叠。
...@@ -40,6 +40,17 @@ ...@@ -40,6 +40,17 @@
<button v-if="!isSign" class="record-button" @click="toSign"> <button v-if="!isSign" class="record-button" @click="toSign">
巡检人签字 巡检人签字
</button> </button>
<view v-else class="action-container">
<image
class="sign-img"
:src="detailsInfo.signImg"
mode="aspectFit">
</image>
<button class="record-button small" @click="toSign">
重签
</button>
<view class="inspection-button" @click="openDialog(true)">数据同步</view>
</view>
</view> </view>
</view> </view>
</view> </view>
...@@ -127,10 +138,10 @@ ...@@ -127,10 +138,10 @@
<!-- 左侧模块 --> <!-- 左侧模块 -->
<view class="left-side"> <view class="left-side">
<view <view
v-for="(tab, index) in tabsDetail.slice(0, 6)" v-for="(tab, index) in tabsDetail.slice(0, 7)"
:key="index" :key="index"
:class="['tab-item', { active: activeTab === index }]" :class="['tab-item', { active: activeTab === index }]"
@click="getActiveTabDetails(index)" @click="getActiveTabDetails(index, tab)"
> >
{{ tab }} {{ tab }}
</view> </view>
...@@ -155,7 +166,7 @@ ...@@ -155,7 +166,7 @@
status1: position.status == 1, status1: position.status == 1,
status2: position.status == 2, status2: position.status == 2,
}" }"
@click="getDetailsItem(item.value, position.dictValue)" @click="getDetailsItem(item.value, position.dictCode)"
> >
<view class="card-content"> <view class="card-content">
<view class="status-line"> <view class="status-line">
...@@ -189,6 +200,11 @@ ...@@ -189,6 +200,11 @@
</view> </view>
</view> </view>
<signDialog ref="signDialog" @confirm="handlePopupConfirm"></signDialog> <signDialog ref="signDialog" @confirm="handlePopupConfirm"></signDialog>
<!-- <Dialog
v-show="showSyncDialog"
:list="list"
@close="openDialog(false)"
></Dialog> -->
</view> </view>
</template> </template>
...@@ -202,17 +218,21 @@ import { ...@@ -202,17 +218,21 @@ import {
LOG_TYPE_ENUM, LOG_TYPE_ENUM,
} from "@/utils/IoReadingAndWriting.js"; } from "@/utils/IoReadingAndWriting.js";
import { getInspectionDetails } from "@/request/index.js"; import { getInspectionDetails } from "@/request/index.js";
import inspectApi from "@/api/inspect";
import signDialog from "@/components/signDialog.vue"; import signDialog from "@/components/signDialog.vue";
import detail from "./model/detail.vue"; import detail from "./model/detail.vue";
import Dialog from './model/dialog.vue'
import { sqlToData, dataToSql } from "./shared";
export default { export default {
components: { components: {
signDialog, signDialog,
detail, detail,
Dialog
}, },
data() { data() {
return { return {
tabs: ["所有井道"], // 选项卡内容 tabs: ["所有井道"], // 选项卡内容
tabsDetail: [], tabsDetail: ["所有井道"],
activeTab: 0, // 默认选中的选项卡 activeTab: 0, // 默认选中的选项卡
inspectionNumber: 0, // 已巡检的井道数量 inspectionNumber: 0, // 已巡检的井道数量
cards: [ cards: [
...@@ -243,6 +263,8 @@ export default { ...@@ -243,6 +263,8 @@ export default {
all_data: [], //所有数据 all_data: [], //所有数据
detailsItem: {}, //单个井道详情 detailsItem: {}, //单个井道详情
isShow: false, isShow: false,
showSyncDialog: false,
list: []
}; };
}, },
computed: { computed: {
...@@ -287,7 +309,7 @@ export default { ...@@ -287,7 +309,7 @@ export default {
}; };
}); });
this.cardsInfo = this.tabList; this.cardsInfo = this.tabList;
this.inspectionCode = `JFXJ${moment().format("yyyyMMDDHHmmss")}${ this.inspectionCode = `JDXJ${moment().format("yyyyMMDDHHmmss")}${
Math.floor(Math.random() * 900) + 100 Math.floor(Math.random() * 900) + 100
}`; }`;
console.log("this.tabList", this.tabList); console.log("this.tabList", this.tabList);
...@@ -308,8 +330,9 @@ export default { ...@@ -308,8 +330,9 @@ export default {
}); });
}, },
// 获取井道详情 // 获取井道详情
getDetailsItem(value, dictValue) { getDetailsItem(value, dictCode) {
let item = this.detailsInfo.originData[value - 1].position[dictValue - 1]; let item = this.detailsInfo.originData.find(building => building.value === value)?.position.find(pos => pos.dictCode === dictCode)
if (item.status < 1) { if (item.status < 1) {
uni.showToast({ uni.showToast({
title: "该井道暂无数据", title: "该井道暂无数据",
...@@ -329,25 +352,45 @@ export default { ...@@ -329,25 +352,45 @@ export default {
this.cardsInfo = [this.tabList[index - 1]]; this.cardsInfo = [this.tabList[index - 1]];
} }
}, },
getActiveTabDetails(index) { getActiveTabDetails(index, tab) {
this.activeTab = index; this.activeTab = index;
this.cardsInfo = [this.tabList[index]];
// this.cardsInfo = [selected];
// this.cardsInfo = [this.tabList[index]];
if (this.activeTab == 0) {
this.cardsInfo = this.tabList;
} else {
let selected = this.tabList.find( t => t.name === tab)
this.cardsInfo = [selected];
}
this.isShow = false; this.isShow = false;
}, },
// 回显数据 // 回显数据
getDetails(uid) { getDetails(uid) {
uni.showLoading(); uni.showLoading();
getInspectionDetails(uid) inspectApi
.info(uid)
.then((res) => { .then((res) => {
const detailsInfo = res; console.log(res)
const detailsInfo = sqlToData(res);
console.log("detailsInfo", detailsInfo); console.log("detailsInfo", detailsInfo);
this.detailsInfo = detailsInfo; this.detailsInfo = detailsInfo;
this.inspectionNumber = detailsInfo.inspectionNumber; this.inspectionNumber = detailsInfo.inspectionNumber;
this.inspectionCode = detailsInfo.inspectionCode; if(detailsInfo.synchronization === 1) {
// 已同步数据的查看详情时,只展示'已巡检'的井道信息,过滤未巡检的井道
let defaultList = detailsInfo.originData
this.cardsInfo = this.tabList = defaultList.filter(building => {
building.position = building.position.filter(pos => pos.status === 1)
return building.position.length
})
} else {
this.cardsInfo = this.tabList = detailsInfo.originData; this.cardsInfo = this.tabList = detailsInfo.originData;
}
this.inspectionCode = detailsInfo.inspectionCode;
// this.cardsInfo = this.tabList = detailsInfo.originData;
this.isSubmit = this.detailsInfo.isSubmit; this.isSubmit = this.detailsInfo.isSubmit;
this.isSign = this.detailsInfo.isSign; this.isSign = !!this.detailsInfo.signImg;
this.cardsInfo.forEach((item) => { this.cardsInfo.forEach((item) => {
this.tabs.push(item.name); this.tabs.push(item.name);
this.tabsDetail.push(item.name); this.tabsDetail.push(item.name);
...@@ -419,10 +462,18 @@ export default { ...@@ -419,10 +462,18 @@ export default {
addLog(log_list).then((res) => { addLog(log_list).then((res) => {
console.log("日志文件写入成功"); console.log("日志文件写入成功");
}); });
if(type === 'sign') {
console.log(123456)
inspectApi.updateSignImg({
id: params.id,
signImg: params.signImg
})
}
uni.showToast({ uni.showToast({
title: type == "sign" ? "签字成功" : "同步成功", title: type == "sign" ? "签字成功" : "同步成功",
icon: "success", icon: "success",
}); });
this.getActiveTabDetails(0); this.getActiveTabDetails(0);
}, },
lookTable() { lookTable() {
...@@ -447,6 +498,19 @@ export default { ...@@ -447,6 +498,19 @@ export default {
}); });
} }
}, },
openDialog(val) {
if(val) {
this.list = [
{
time: this.detailsInfo.submitMonth,
list: [this.detailsInfo]
}
]
} else {
this.list = []
}
this.showSyncDialog = val
}
}, },
}; };
</script> </script>
...@@ -580,6 +644,32 @@ export default { ...@@ -580,6 +644,32 @@ export default {
line-height: 28.8px; line-height: 28.8px;
font-weight: 400; font-weight: 400;
} }
.action-container {
display: flex;
.record-button.small {
width: 75px;
margin-right: 10px;
}
.inspection-button {
display: flex;
align-items: center;
justify-content: center;
width: 115.2px;
height: 28.8px;
color: #fff;
background-image: linear-gradient(180deg, #3773f6 0%, #2c57f6 99%);
box-shadow: 0px 8px 19.2px 0px rgba(51, 104, 246, 0.24);
border-radius: 14.4px;
}
.sign-img {
width: 80px;
height: 28.8px;
margin-right: 10px;
border: 1px solid #ccc;
// border-right: none;
border-radius: 3px;
}
}
} }
} }
} }
......
...@@ -142,6 +142,7 @@ ...@@ -142,6 +142,7 @@
><custom-popup ><custom-popup
ref="customPopup" ref="customPopup"
:inspectionItem="tabs[activeTab].label" :inspectionItem="tabs[activeTab].label"
:fixedWords="['已检查', '正常', '异常', '需处理', '已处理']"
@confirm="handlePopupConfirm" @confirm="handlePopupConfirm"
></custom-popup> ></custom-popup>
</view> </view>
...@@ -165,6 +166,8 @@ import { getInspectionDetails, getDarft } from "@/request/index.js"; ...@@ -165,6 +166,8 @@ import { getInspectionDetails, getDarft } from "@/request/index.js";
import moment from "moment"; import moment from "moment";
import customPopup from "./model/customPopup.vue"; import customPopup from "./model/customPopup.vue";
import _ from "lodash"; import _ from "lodash";
import inspectApi from "@/api/inspect";
import { sqlToData, dataToSql } from "./shared";
export default { export default {
components: { components: {
...@@ -273,9 +276,10 @@ export default { ...@@ -273,9 +276,10 @@ export default {
// 回显数据 // 回显数据
getDetails(uid) { getDetails(uid) {
uni.showLoading(); uni.showLoading();
getInspectionDetails(uid) inspectApi
.info(uid)
.then((res) => { .then((res) => {
const detailsInfo = res; const detailsInfo = sqlToData(res);
console.log("getDetails", res); console.log("getDetails", res);
let list = let list =
detailsInfo.originData[this.value - 1].position[this.dictValue - 1] detailsInfo.originData[this.value - 1].position[this.dictValue - 1]
...@@ -505,7 +509,7 @@ export default { ...@@ -505,7 +509,7 @@ export default {
return !arr.some((obj) => obj.inspectionResult === 1); return !arr.some((obj) => obj.inspectionResult === 1);
}, },
// 提交 // 提交
submit(isSubmit = 1) { async submit(isSubmit = 1) {
// 校验是否通过 // 校验是否通过
if (isSubmit && !this.isAllTabValid().valid) { if (isSubmit && !this.isAllTabValid().valid) {
uni.showToast({ uni.showToast({
...@@ -519,6 +523,19 @@ export default { ...@@ -519,6 +523,19 @@ export default {
let logContent = ""; let logContent = "";
console.log("this.uid", this.uid); console.log("this.uid", this.uid);
console.log("all_data", this.all_data); console.log("all_data", this.all_data);
// 写数据到indexedDB
// 处理数据
const send = dataToSql(params);
let api;
if (this.uid) {
send.id = this.uid
api = inspectApi.update
} else {
api = inspectApi.save
}
try {
let saveRes = await api(send)
if (this.uid) { if (this.uid) {
const index = this.all_data.findIndex( const index = this.all_data.findIndex(
(element) => element.uid == this.uid (element) => element.uid == this.uid
...@@ -559,16 +576,19 @@ export default { ...@@ -559,16 +576,19 @@ export default {
addLog(log_list).then((res) => { addLog(log_list).then((res) => {
console.log("日志文件写入成功"); console.log("日志文件写入成功");
}); });
// 清空基础缓存信息 // 清空基础缓存信息
// this.$store.commit("SET_TEMP_DATA", {}); // 缓存[巡检信息] // this.$store.commit("SET_TEMP_DATA", {}); // 缓存[巡检信息]
uni.showToast({ uni.showToast({
title: isSubmit ? "提交成功" : "保存草稿成功", title: isSubmit ? "提交成功1" : "保存草稿成功",
icon: "success", icon: "success",
}); });
uni.navigateTo({ uni.navigateTo({
url: `/pages/shaftInspection/shaftInspectionList?uid=${params.uid}&backValue=${this.backValue}`, url: `/pages/shaftInspection/shaftInspectionList?uid=${ this.uid ? this.uid : saveRes.lastInsertId}&backValue=${this.backValue}`,
}); });
} catch (err) {
console.log('err',err)
}
}, },
// 检查所有Tab 的必填项是否填写完整 // 检查所有Tab 的必填项是否填写完整
isAllTabValid() { isAllTabValid() {
...@@ -587,7 +607,10 @@ export default { ...@@ -587,7 +607,10 @@ export default {
tabIndex: i, tabIndex: i,
}; };
} }
// 如果巡检结论为正常,则不对摘要和现场照片做必填校验
if(item.inspectionResult === 0) {
continue
}
// 2. 检查是否填写了情况摘要 // 2. 检查是否填写了情况摘要
if (!item.conclusion || item.conclusion.trim() === "") { if (!item.conclusion || item.conclusion.trim() === "") {
return { return {
......
import moment from "moment";
import store from "@/store";
// 将现有机房巡检数据转换为SQL数据所需要格式
export function dataToSql(data) {
let synFlag = 0;
if (data.isSubmit == 0) {
synFlag = 0;
} else {
synFlag = data.synchronization;
}
const send = {
inspectionType: data.inspectionType,
inspectionCode: data.inspectionCode,
recordName: `${moment().format("yyyyMMDD")}-井道巡检`,
inspectionTime: moment().format("yyyy-MM-DD HH:mm"),
isException: data.isException, // 是否异常:0 否 1 是 2 巡检中
userId: store.state.now_user.userId,
userName: store.state.now_user.user,
synFlag: synFlag, // 0.未同步,1.已同步,2.编辑
signImg: data.signImg || "",
createBy: store.state.now_user.userId,
createTime: data.id ? data.createTime : `${new Date().getTime()}`,
updateTime: `${new Date().getTime()}`,
updateBy: store.state.now_user.userId,
inspectionData: data.originData,
};
console.log("dataToSql", send);
return send;
}
export function sqlToData(sqlData) {
try {
let isSubmit;
let synchronization;
if (sqlData.synFlag === 0) {
isSubmit = 0;
synchronization = 0;
} else {
isSubmit = 1;
synchronization = sqlData.synFlag;
}
const originData = JSON.parse(sqlData.inspectionData || "{}");
console.log(originData)
const inspectedItems = originData.reduce((acc,cur) => {
acc.push(...cur.position)
return acc
}, []).filter((item) => item.status == 1 || item.status == 2)
console.log(inspectedItems)
// 获取已经巡检过的数量
const inspectionNumber = inspectedItems.length;
const ret = {
id: sqlData.id,
inspectionType: sqlData.inspectionType,
inspectionCode: sqlData.inspectionCode,
isException: sqlData.isException,
signImg: sqlData.signImg,
createTime: sqlData.createTime,
isSubmit: isSubmit,
synchronization: synchronization,
originData,
inspectionNumber
};
console.log(ret)
return ret;
} catch (err) {
console.log(err)
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论