提交 30272f37 authored 作者: JaxBBLL's avatar JaxBBLL

fix

上级 21d7b477
import SqlliteDbUtil from "@/utils/sqllitedb"; import SqlliteDbUtil from "@/utils/sqllitedb";
import table from "./sqllite/table.js"; import table from "./sqllite/table.js";
import { import { fixNullVal } from "@/utils/common";
fixNullVal
} from "@/utils/common";
// 巡检 // 巡检
export default { export default {
async selectLastData(data) { async selectLastData(data) {
let sqllitedb = await SqlliteDbUtil.initSqlliteDB(); let sqllitedb = await SqlliteDbUtil.initSqlliteDB();
try { try {
let rs = await sqllitedb.selectSQL( let rs = await sqllitedb.selectSQL(
`SELECT * `SELECT *
FROM ${table.inspectionRecordName} FROM ${table.inspectionRecordName}
WHERE userId = '${data}' WHERE userId = '${data}'
AND createTime >= strftime('%s', 'now') - 7*24*60*60 AND createTime >= strftime('%s', 'now') - 7*24*60*60
AND inspectionType = 1 AND inspectionType = 1
AND synFlag = 1
ORDER BY createTime DESC ORDER BY createTime DESC
LIMIT 1;` LIMIT 1;`
); );
return rs; return rs;
} catch (e) { } catch (e) {
console.log(e.message); console.log(e.message);
} finally { } finally {
await sqllitedb.closeDB(); await sqllitedb.closeDB();
} }
}, },
async selectList() { async selectList() {
let sqllitedb = await SqlliteDbUtil.initSqlliteDB(); let sqllitedb = await SqlliteDbUtil.initSqlliteDB();
try { try {
let rs = await sqllitedb.selectSQL( let rs = await sqllitedb.selectSQL(
`select * from ${table.inspectionRecordName}` `select * from ${table.inspectionRecordName}`
); );
return rs; return rs;
} catch (e) { } catch (e) {
console.log(e.message); console.log(e.message);
} finally { } finally {
await sqllitedb.closeDB(); await sqllitedb.closeDB();
} }
}, },
async selectDataForTime(data) { async selectDataForTime(data) {
let sqllitedb = await SqlliteDbUtil.initSqlliteDB(); let sqllitedb = await SqlliteDbUtil.initSqlliteDB();
try { try {
let inspectionTimeCondition = ''; let inspectionTimeCondition = "";
if (Array.isArray(data.inspectionTime) && data.inspectionTime.length === 2) { if (
const startTime = new Date(data.inspectionTime[0]).getTime(); Array.isArray(data.inspectionTime) &&
const endTime = new Date(data.inspectionTime[1] + 'T23:59:59').getTime(); data.inspectionTime.length === 2
inspectionTimeCondition = `AND inspectionTime >= '${startTime}' AND inspectionTime <= '${endTime}'`; ) {
} const startTime = new Date(data.inspectionTime[0]).getTime();
let isAdmin = ''; const endTime = new Date(
if (data.userId) { data.inspectionTime[1] + "T23:59:59"
const userResult = await sqllitedb.selectSQL( ).getTime();
`SELECT isAdmin FROM ${table.userName} WHERE userId = '${data.userId}'` inspectionTimeCondition = `AND inspectionTime >= '${startTime}' AND inspectionTime <= '${endTime}'`;
); }
isAdmin = userResult?.[0]?.isAdmin || ''; let isAdmin = "";
} if (data.userId) {
const userCondition = isAdmin ? const userResult = await sqllitedb.selectSQL(
'' : `SELECT isAdmin FROM ${table.userName} WHERE userId = '${data.userId}'`
`AND userId = '${data.userId}'`; );
let sql = `SELECT id,inspectionType,inspectionCode isAdmin = userResult?.[0]?.isAdmin || "";
}
const userCondition = isAdmin ? "" : `AND userId = '${data.userId}'`;
let sql = `SELECT id,inspectionType,inspectionCode
,recordName ,recordName
,userName ,userName
,userId ,userId
...@@ -67,144 +69,142 @@ LIMIT 1;` ...@@ -67,144 +69,142 @@ LIMIT 1;`
,createTime,delFlag,inspectionData ,createTime,delFlag,inspectionData
FROM ${table.inspectionRecordName} FROM ${table.inspectionRecordName}
where 1=1 where 1=1
${data.inspectionType ? `AND inspectionType = '${data.inspectionType}'` : ''} ${data.inspectionType ? `AND inspectionType = '${data.inspectionType}'` : ""}
${data.synFlag ? `AND synFlag = '${data.synFlag}'` : ''} ${data.synFlag ? `AND synFlag = '${data.synFlag}'` : ""}
${data.isException ? `AND isException = '${data.isException}'` : ''} ${data.isException ? `AND isException = '${data.isException}'` : ""}
${inspectionTimeCondition} ${inspectionTimeCondition}
${userCondition} ${userCondition}
and delFlag = 0 and delFlag = 0
order by createTime desc` order by createTime desc`;
let rs = await sqllitedb.selectSQL( let rs = await sqllitedb.selectSQL(sql);
sql console.log("sql", sql);
); return rs;
console.log('sql', sql) } catch (e) {
return rs; console.log(e.message);
} catch (e) { } finally {
console.log(e.message); await sqllitedb.closeDB();
} finally { }
await sqllitedb.closeDB(); },
} async info(id) {
}, let sqllitedb = await SqlliteDbUtil.initSqlliteDB();
async info(id) { try {
let sqllitedb = await SqlliteDbUtil.initSqlliteDB(); let sql = `select * from ${table.inspectionRecordName} where id = '${id}'`;
try { let res = await sqllitedb.selectSQL(sql);
let sql = `select * from ${table.inspectionRecordName} where id = '${id}'`; if (res && res.length > 0) {
let res = await sqllitedb.selectSQL(sql); return res[0];
if (res && res.length > 0) { }
return res[0]; } catch (e) {
} console.log(e.message);
} catch (e) { } finally {
console.log(e.message); // await sqllitedb.closeDB();
} finally { }
// await sqllitedb.closeDB(); },
} async remove(arr) {
}, if (!id) {
async remove(arr) { return;
if (!id) { }
return; let sql = `delete from ${table.inspectionRecordName} where id in '${id}'`;
} try {
let sql = `delete from ${table.inspectionRecordName} where id in '${id}'`; let sqllitedb = await SqlliteDbUtil.initSqlliteDB();
try { await sqllitedb.executeSQL(sql);
let sqllitedb = await SqlliteDbUtil.initSqlliteDB(); } catch (e) {
await sqllitedb.executeSQL(sql); console.log(e.message);
} catch (e) { } finally {
console.log(e.message); // await sqllitedb.closeDB();
} finally { }
// await sqllitedb.closeDB(); },
} //更新同步
}, async updateSyncData(data) {
//更新同步 let ids = "(" + data.join(",") + ")";
async updateSyncData(data) { let sql = `update ${table.inspectionRecordName} set synFlag=1 where id in ${ids}`;
let ids = '(' + data.join(',') + ')' try {
let sql = `update ${table.inspectionRecordName} set synFlag=1 where id in ${ids}`; let sqllitedb = await SqlliteDbUtil.initSqlliteDB();
try { let rs = await sqllitedb.executeReturnDataSQL(sql);
let sqllitedb = await SqlliteDbUtil.initSqlliteDB(); return rs;
let rs = await sqllitedb.executeReturnDataSQL(sql); } catch (e) {
return rs console.log(e.message);
} catch (e) { } finally {
console.log(e.message); // await sqllitedb.closeDB();
} finally { }
// await sqllitedb.closeDB(); },
} async batchRemove(id) {
}, let sql = `update ${table.inspectionRecordName} set delFlag=1 where id = '${id}'`;
async batchRemove(id) { try {
let sql = `update ${table.inspectionRecordName} set delFlag=1 where id = '${id}'`; let sqllitedb = await SqlliteDbUtil.initSqlliteDB();
try { let rs = await sqllitedb.executeReturnDataSQL(sql);
let sqllitedb = await SqlliteDbUtil.initSqlliteDB(); return rs;
let rs = await sqllitedb.executeReturnDataSQL(sql); } catch (e) {
return rs console.log(e.message);
} catch (e) { } finally {
console.log(e.message); await sqllitedb.closeDB();
} finally { }
await sqllitedb.closeDB(); },
}
},
async remove(arr) { async remove(arr) {
if (!id) { if (!id) {
return; return;
} }
let sql = `delete from ${table.inspectionRecordName} where id = '${id}'`; let sql = `delete from ${table.inspectionRecordName} where id = '${id}'`;
try { try {
let sqllitedb = await SqlliteDbUtil.initSqlliteDB(); let sqllitedb = await SqlliteDbUtil.initSqlliteDB();
await sqllitedb.executeSQL(sql); await sqllitedb.executeSQL(sql);
} catch (e) { } catch (e) {
console.log(e.message); console.log(e.message);
} finally { } finally {
// await sqllitedb.closeDB(); // await sqllitedb.closeDB();
} }
}, },
async saveBatch(list) { async saveBatch(list) {
if (list.length === 0) { if (list.length === 0) {
return; return;
} }
console.log("开始保存用户信息...." + list.length); console.log("开始保存用户信息...." + list.length);
let sqllitedb = await SqlliteDbUtil.initSqlliteDB(); let sqllitedb = await SqlliteDbUtil.initSqlliteDB();
try { try {
for (let data of list) { for (let data of list) {
let column = ""; let column = "";
let values = ""; let values = "";
let idx = 0; let idx = 0;
for (let attr in data) { for (let attr in data) {
let dataField = table["inspectionRecord"].find((v) => { let dataField = table["inspectionRecord"].find((v) => {
if (v.field === attr) { if (v.field === attr) {
return v; return v;
} }
}); });
if (!dataField) { if (!dataField) {
continue; continue;
} }
column += dataField.field + ","; column += dataField.field + ",";
values += "'" + fixNullVal(data[attr]) + "',"; values += "'" + fixNullVal(data[attr]) + "',";
idx++; idx++;
} }
column = column.endsWith(",") ? column = column.endsWith(",")
column.substring(0, column.length - 1) : ? column.substring(0, column.length - 1)
column; : column;
values = values.endsWith(",") ? values = values.endsWith(",")
values.substring(0, values.length - 1) : ? values.substring(0, values.length - 1)
values; : values;
let sql = `insert into ${table.inspectionRecordName}(${column}) values(${values})`; let sql = `insert into ${table.inspectionRecordName}(${column}) values(${values})`;
let has = await this.info(data.id); let has = await this.info(data.id);
if (has && has.id) { if (has && has.id) {
await this.remove(data.id); await this.remove(data.id);
} }
await sqllitedb.executeSQL(sql); await sqllitedb.executeSQL(sql);
} }
} catch (e) { } catch (e) {
console.log(e.message); console.log(e.message);
} finally { } finally {
await sqllitedb.closeDB(); await sqllitedb.closeDB();
} }
console.log("导入完成..."); console.log("导入完成...");
}, },
async save(data) { async save(data) {
console.log("开始保存巡检记录", data); console.log("开始保存巡检记录", data);
let sqllitedb = await SqlliteDbUtil.initSqlliteDB(); let sqllitedb = await SqlliteDbUtil.initSqlliteDB();
try { try {
let sql = `insert into ${table.inspectionRecordName}( let sql = `insert into ${table.inspectionRecordName}(
inspectionType, inspectionType,
inspectionCode, inspectionCode,
recordName, recordName,
...@@ -234,24 +234,24 @@ LIMIT 1;` ...@@ -234,24 +234,24 @@ LIMIT 1;`
'${JSON.stringify(data.inspectionData)}' '${JSON.stringify(data.inspectionData)}'
); );
`; `;
let result = await sqllitedb.executeReturnDataSQL(sql); let result = await sqllitedb.executeReturnDataSQL(sql);
console.log(result, "有有有有有有"); console.log(result, "有有有有有有");
return result; return result;
} catch (e) { } catch (e) {
console.log(e.message); console.log(e.message);
} finally { } finally {
await sqllitedb.closeDB(); await sqllitedb.closeDB();
} }
console.log("导入完成..."); console.log("导入完成...");
}, },
async update(data) { async update(data) {
console.log("开始更新巡检记录", data); console.log("开始更新巡检记录", data);
let sqllitedb = await SqlliteDbUtil.initSqlliteDB(); let sqllitedb = await SqlliteDbUtil.initSqlliteDB();
try { try {
if (!data.id) { if (!data.id) {
throw new Error("更新操作需要提供 id"); throw new Error("更新操作需要提供 id");
} }
let sql = `UPDATE ${table.inspectionRecordName} SET let sql = `UPDATE ${table.inspectionRecordName} SET
inspectionType = '${data.inspectionType}', inspectionType = '${data.inspectionType}',
inspectionCode = '${data.inspectionCode}', inspectionCode = '${data.inspectionCode}',
recordName = '${data.recordName}', recordName = '${data.recordName}',
...@@ -266,31 +266,31 @@ LIMIT 1;` ...@@ -266,31 +266,31 @@ LIMIT 1;`
updateTime = '${data.updateTime}', updateTime = '${data.updateTime}',
inspectionData = '${JSON.stringify(data.inspectionData)}' inspectionData = '${JSON.stringify(data.inspectionData)}'
WHERE id = ${data.id}`; WHERE id = ${data.id}`;
await sqllitedb.executeSQL(sql); await sqllitedb.executeSQL(sql);
} catch (e) { } catch (e) {
console.log(e.message); console.log(e.message);
} finally { } finally {
await sqllitedb.closeDB(); await sqllitedb.closeDB();
} }
console.log("更新完成..."); console.log("更新完成...");
}, },
async updateSignImg(data) { async updateSignImg(data) {
console.log("开始更新巡检签名图片", data); console.log("开始更新巡检签名图片", data);
let sqllitedb = await SqlliteDbUtil.initSqlliteDB(); let sqllitedb = await SqlliteDbUtil.initSqlliteDB();
try { try {
if (!data.id) { if (!data.id) {
throw new Error("更新操作需要提供 id"); throw new Error("更新操作需要提供 id");
} }
let sql = `UPDATE ${table.inspectionRecordName} SET let sql = `UPDATE ${table.inspectionRecordName} SET
signImg = '${data.signImg}', signImg = '${data.signImg}',
synFlag = '${data.synFlag}' synFlag = '${data.synFlag}'
WHERE id = ${data.id}`; WHERE id = ${data.id}`;
await sqllitedb.executeSQL(sql); await sqllitedb.executeSQL(sql);
} catch (e) { } catch (e) {
console.log(e.message); console.log(e.message);
} finally { } finally {
await sqllitedb.closeDB(); await sqllitedb.closeDB();
} }
console.log("更新完成..."); console.log("更新完成...");
}, },
}; };
\ No newline at end of file
<template> <template>
<!-- 首页 --> <!-- 首页 -->
<view class="container"> <view class="container">
<!-- 第一个模块 --> <!-- 第一个模块 -->
<button @click="copyFile">拷贝</button> <view class="header">
<view class="header"> <view class="title">杭州内网监管在线-运维在线</view>
<view class="title">杭州内网监管在线-运维在线</view> <view class="header-buttons">
<view class="header-buttons"> <view class="log-button" @click="lookLog" v-if="isAdmin">操作日志</view>
<view class="log-button" @click="lookLog" v-if="isAdmin">操作日志</view> <div class="exit-button" @click="logOut">
<div class="exit-button" @click="logOut"> <image
<image class="logout" src="@/static/img/logout.svg" mode="aspectFit"></image> class="logout"
</div> src="@/static/img/logout.svg"
</view> mode="aspectFit"
</view> ></image>
</div>
</view>
</view>
<!-- 第二个模块 --> <!-- 第二个模块 -->
<view class="profile-section"> <view class="profile-section">
<view class="profile-box"> <view class="profile-box">
<view class="profile-left"> <view class="profile-left">
<view class="avatar"> <view class="avatar">
<image src="@/static/img/add-img/defaultAvatar.png" mode="aspectFit"></image> <image
<view class="change-password" @click="updatePassword">修改密码</view> src="@/static/img/add-img/defaultAvatar.png"
</view> mode="aspectFit"
<view class="username">{{ userName }}</view> ></image>
</view> <view class="change-password" @click="updatePassword"
<view class="profile-right"> >修改密码</view
<button class="inspection-button" @click="toInspectionManagement"> >
巡检管理 </view>
</button> <view class="username">{{ userName }}</view>
<button class="record-button" @click="toListingManagement"> </view>
设备上架管理 <view class="profile-right">
</button> <button class="inspection-button" @click="toInspectionManagement">
</view> 巡检管理
</view> </button>
</view> <button class="record-button" @click="toListingManagement">
设备上架管理
</button>
</view>
</view>
</view>
<!-- 第三个模块 --> <!-- 第三个模块 -->
<view class="card-section"> <view class="card-section">
<view class="card-container"> <view class="card-container">
<view class="card" v-for="(card, index) in cards" :key="index" <view
:style="{ backgroundImage: `url(${card.image})` }" @click="toList(card.url)"> class="card"
<view class="card-text">{{ card.text }}</view> v-for="(card, index) in cards"
</view> :key="index"
</view> :style="{ backgroundImage: `url(${card.image})` }"
</view> @click="toList(card.url)"
<!-- 退出账号弹出 --> >
<uni-popup ref="inputDialog2" type="dialog"> <view class="card-text">{{ card.text }}</view>
<uni-popup-dialog ref="inputClose2" mode="base" title="确定退出该账号?" @confirm="dialogInputConfirm2"> </view>
</uni-popup-dialog> </view>
</uni-popup> </view>
</view> <!-- 退出账号弹出 -->
<uni-popup ref="inputDialog2" type="dialog">
<uni-popup-dialog
ref="inputClose2"
mode="base"
title="确定退出该账号?"
@confirm="dialogInputConfirm2"
>
</uni-popup-dialog>
</uni-popup>
</view>
</template> </template>
<script> <script>
import { import { copyDirectory } from "@/utils/IoReadingAndWriting.js";
copyDirectory import inspectApi from "@/api/inspect.js";
} from "@/utils/IoReadingAndWriting.js" export default {
import inspectApi from "@/api/inspect.js" data() {
export default { return {
data() { cards: [
return { {
cards: [{ image: "../../static/img/jf.png",
image: "../../static/img/jf.png", text: "机房巡检",
text: "机房巡检", url: "/pages/inspectionContent/inspectionContentList?backValue=home",
url: "/pages/inspectionContent/inspectionContentList?backValue=home", },
}, {
{ image: "../../static/img/jd.png",
image: "../../static/img/jd.png", text: "井道巡检",
text: "井道巡检", url: "/pages/shaftInspection/shaftInspectionList?backValue=home",
url: "/pages/shaftInspection/shaftInspectionList?backValue=home", },
}, {
{ image: "../../static/img/sj.png",
image: "../../static/img/sj.png", text: "设备上架",
text: "设备上架", url: "/pages/listingManagement/index?backValue=home",
url: "/pages/listingManagement/index?backValue=home", },
}, ],
], userName: this.$store.state.now_user.user,
userName: this.$store.state.now_user.user, };
}; },
}, computed: {
computed: { isAdmin() {
isAdmin() { return this.$store.state.now_user.isAdmin;
return this.$store.state.now_user.isAdmin; },
}, },
}, created() {
created() { console.log(this.$store.state);
console.log(this.$store.state); },
}, methods: {
methods: { // 修改密码
async copyFile() { updatePassword() {
let res= await inspectApi.selectLastData(this.$store.state.now_user.userId) uni.navigateTo({
console.log(res,'=========') url: "/pages/index/editPd",
});
}, },
// 修改密码 //退出
updatePassword() { logOut() {
uni.navigateTo({ this.$refs.inputDialog2.open();
url: "/pages/index/editPd", },
}); // 查看操作日志
}, lookLog() {
//退出 uni.navigateTo({
logOut() { url: "/pages/index/operLog",
this.$refs.inputDialog2.open(); });
}, },
// 查看操作日志 // 三模块卡片跳转页面
lookLog() { toList(url) {
uni.navigateTo({ uni.navigateTo({
url: "/pages/index/operLog", url: url,
}); });
}, },
// 三模块卡片跳转页面 // 巡检管理
toList(url) { toInspectionManagement() {
uni.navigateTo({ uni.navigateTo({
url: url, url: "/pages/inspectionManagement/index?backValue=home",
}); });
}, },
// 巡检管理 toListingManagement() {
toInspectionManagement() { uni.navigateTo({
uni.navigateTo({ url: "/pages/listingManagement/index?backValue=home",
url: "/pages/inspectionManagement/index?backValue=home", });
}); },
}, // 井道巡检
toListingManagement() { toShaftInspection() {
uni.navigateTo({ uni.navigateTo({
url: "/pages/listingManagement/index?backValue=home", url: "/pages/shaftInspection/shaftInspectionNew?backValue=home",
}); });
}, },
// 井道巡检 //退出--弹出对话框
toShaftInspection() { dialogInputConfirm2() {
uni.navigateTo({ uni.redirectTo({
url: "/pages/shaftInspection/shaftInspectionNew?backValue=home", url: "/pages/login/login",
}); success: () => {
}, // uni.clearStorage(); //测试将所有缓存清除
//退出--弹出对话框 uni.setStorageSync("now_user", this.$store.state.now_user);
dialogInputConfirm2() { uni.setStorageSync(
uni.redirectTo({ "last_time",
url: "/pages/login/login", this.$store.state.now_user.LastSynchronizationTime || ""
success: () => { );
// uni.clearStorage(); //测试将所有缓存清除 },
uni.setStorageSync("now_user", this.$store.state.now_user); });
uni.setStorageSync( },
"last_time", },
this.$store.state.now_user.LastSynchronizationTime || "" };
);
},
});
},
},
};
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
.container { .container {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
padding: 20px; padding: 20px;
height: 100vh; height: 100vh;
background-image: linear-gradient(115deg, #e8f0fb 0%, #e1ebfa 100%); background-image: linear-gradient(115deg, #e8f0fb 0%, #e1ebfa 100%);
z-index: 1; z-index: 1;
} }
.header { .header {
width: 100%; width: 100%;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
padding: 10px; padding: 10px;
position: relative; position: relative;
margin-bottom: 147px; margin-bottom: 147px;
.title { .title {
position: absolute; position: absolute;
left: 50%; left: 50%;
transform: translateX(-50%); transform: translateX(-50%);
ont-family: PingFangSC-Medium; ont-family: PingFangSC-Medium;
font-size: 32px; font-size: 32px;
color: #000000; color: #000000;
text-align: center; text-align: center;
line-height: 40px; line-height: 40px;
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.16); text-shadow: 0 2px 4px rgba(0, 0, 0, 0.16);
font-weight: 500; font-weight: 500;
} }
.header-buttons { .header-buttons {
display: flex; display: flex;
align-items: center; align-items: center;
margin-left: auto; // 将按钮组推到最右侧 margin-left: auto; // 将按钮组推到最右侧
.log-button { .log-button {
width: 112px; width: 112px;
height: 36px; height: 36px;
background: #ffffff; background: #ffffff;
border-radius: 18px; border-radius: 18px;
margin-right: 10px; margin-right: 10px;
font-family: PingFangSC-Regular; font-family: PingFangSC-Regular;
font-size: 16px; font-size: 16px;
color: #000000; color: #000000;
line-height: 36px; line-height: 36px;
font-weight: 400; font-weight: 400;
text-align: center; text-align: center;
} }
.exit-button { .exit-button {
width: 36px; width: 36px;
height: 36px; height: 36px;
background: #ffffff; background: #ffffff;
border: 0.5px solid rgba(224, 224, 224, 1); border: 0.5px solid rgba(224, 224, 224, 1);
border-radius: 18px; border-radius: 18px;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
.logout { .logout {
width: 16px; width: 16px;
height: 16px; height: 16px;
} }
} }
} }
} }
.profile-section { .profile-section {
width: 720px; width: 720px;
.profile-box { .profile-box {
background-color: #fff; background-color: #fff;
border-radius: 12px; border-radius: 12px;
padding: 16px 32px; padding: 16px 32px;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
.profile-left { .profile-left {
display: flex; display: flex;
align-items: center; align-items: center;
.avatar { .avatar {
position: relative; position: relative;
width: 86px; width: 86px;
height: 86px; height: 86px;
border-radius: 50%; border-radius: 50%;
overflow: hidden; overflow: hidden;
image { image {
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
.change-password { .change-password {
position: absolute; position: absolute;
bottom: 0; bottom: 0;
left: 0; left: 0;
right: 0; right: 0;
background-color: rgba(0, 0, 0, 0.5); background-color: rgba(0, 0, 0, 0.5);
text-align: center; text-align: center;
height: 22px; height: 22px;
font-family: PingFangSC-Regular; font-family: PingFangSC-Regular;
font-size: 12px; font-size: 12px;
color: #ffffff; color: #ffffff;
line-height: 20px; line-height: 20px;
font-weight: 400; font-weight: 400;
} }
} }
.username { .username {
margin-left: 16px; margin-left: 16px;
font-family: PingFangSC-Medium; font-family: PingFangSC-Medium;
font-size: 20px; font-size: 20px;
color: #000000; color: #000000;
line-height: 28px; line-height: 28px;
font-weight: 500; font-weight: 500;
} }
} }
.profile-right { .profile-right {
display: flex; display: flex;
.inspection-button { .inspection-button {
width: 112px; width: 112px;
height: 36px; height: 36px;
background-image: linear-gradient(105deg, #68acfb 0%, #3774f6 100%); background-image: linear-gradient(105deg, #68acfb 0%, #3774f6 100%);
border-radius: 18px; border-radius: 18px;
font-family: PingFangSC-Regular; font-family: PingFangSC-Regular;
font-size: 16px; font-size: 16px;
color: #ffffff; color: #ffffff;
line-height: 36px; line-height: 36px;
font-weight: 400; font-weight: 400;
margin-right: 16px; margin-right: 16px;
} }
.record-button { .record-button {
width: 144px; width: 144px;
height: 36px; height: 36px;
background: #ffffff; background: #ffffff;
border: 1px solid rgba(55, 116, 246, 1); border: 1px solid rgba(55, 116, 246, 1);
border-radius: 18px; border-radius: 18px;
font-family: PingFangSC-Regular; font-family: PingFangSC-Regular;
font-size: 16px; font-size: 16px;
color: #3774f6; color: #3774f6;
line-height: 36px; line-height: 36px;
font-weight: 400; font-weight: 400;
} }
} }
} }
} }
.card-section { .card-section {
width: 720px; width: 720px;
margin-top: 20px; margin-top: 20px;
.card-container { .card-container {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
.card { .card {
width: 224px; width: 224px;
height: 194px; height: 194px;
border-radius: 10px; border-radius: 10px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
padding-top: 130px; padding-top: 130px;
background-size: cover; // 背景图覆盖整个卡片 background-size: cover; // 背景图覆盖整个卡片
background-position: center; // 背景图居中 background-position: center; // 背景图居中
.card-text { .card-text {
text-align: center; text-align: center;
font-family: PingFangSC-Semibold; font-family: PingFangSC-Semibold;
font-size: 16px; font-size: 16px;
color: #000000; color: #000000;
line-height: 24px; line-height: 24px;
font-weight: 600; font-weight: 600;
} }
} }
} }
} }
</style> </style>
\ No newline at end of file
...@@ -230,7 +230,7 @@ import startDialog from "./components/dialog.vue"; ...@@ -230,7 +230,7 @@ import startDialog from "./components/dialog.vue";
import assRoomApi from "@/api/assRoom.js"; import assRoomApi from "@/api/assRoom.js";
import inspectApi from "@/api/inspect"; import inspectApi from "@/api/inspect";
import { sqlToData, dataToSql } from "./shared"; import { sqlToData, dataToSql, getHistoryData } from "./shared";
import Dialog from "@/pages/inspectionManagement/dialog.vue"; import Dialog from "@/pages/inspectionManagement/dialog.vue";
export default { export default {
...@@ -267,6 +267,7 @@ export default { ...@@ -267,6 +267,7 @@ export default {
listData: [], listData: [],
isDialog: false, isDialog: false,
propList: [], propList: [],
did: "", // 最近7天数据的id
}; };
}, },
computed: { computed: {
...@@ -292,7 +293,55 @@ export default { ...@@ -292,7 +293,55 @@ export default {
}); });
} else { } else {
this.getRoomList().then((res) => { this.getRoomList().then((res) => {
this.init(res); // 获取7日(168小时)内最后一条巡检记录回显到页面(选项、文案、照片;异常项-不调出文案及照片)
getHistoryData().then((detailsInfo) => {
if (detailsInfo) {
// 处理历史数据(选项、文案、照片;异常项-不调出文案及照片)
console.log("detailsInfo", detailsInfo);
this.did = detailsInfo.id;
delete detailsInfo.id;
this.listData = this.listFormat(detailsInfo.originData);
this.detailsInfo = detailsInfo;
this.inspectionNumber = detailsInfo.inspectionNumber;
this.inspectionCode = `JFXJ${moment().format("yyyyMMDDHHmmss")}${
Math.floor(Math.random() * 900) + 100
}`;
this.cardsInfo = detailsInfo.originData;
this.isSubmit = 0;
this.isSign = false;
// 默认选中第一个机房
this.detailsItem = detailsInfo.originData[0].details;
if (
this.detailsItem.afxt &&
this.detailsItem.afxt.detail &&
this.detailsItem.afxt.detail[2].inspectionResult === 1
) {
this.detailsItem.afxt.detail =
this.detailsItem.afxt.detail.slice(0, 3);
}
this.allIsSubmitOne = detailsInfo.originData.every(
(item) => item.isSubmit == 1
);
let group1 = this.cardsInfo.slice(0, 5);
let group2 = this.cardsInfo.slice(5, 10);
let group3 = this.cardsInfo.slice(10);
if (!this.isSign) {
group2 = group2.reverse();
}
this.rows = [group1, group2, group3];
this.detailsInfo = detailsInfo;
} else {
this.init(res);
}
});
}); });
} }
} }
...@@ -308,7 +357,6 @@ export default { ...@@ -308,7 +357,6 @@ 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;
}); });
}, },
...@@ -356,20 +404,6 @@ export default { ...@@ -356,20 +404,6 @@ export default {
Math.floor(Math.random() * 900) + 100 Math.floor(Math.random() * 900) + 100
}`; }`;
} }
// if (this.detailsInfo.inspectionType) {
// const fillCheck = this.detailsInfo.fillCheck.split(",");
// setTimeout(() => {
// this.tabList.forEach((item, index) => {
// item.isVaild = fillCheck.includes(item.value);
// this.tempForm[index] &&
// this.setComponentData(item.refName, this.tempForm[index]);
// });
// }, 500);
// } else {
// this.baseInfo = this.$store.state.temp_data;
// }
resolve(); resolve();
}); });
}, },
...@@ -504,7 +538,7 @@ export default { ...@@ -504,7 +538,7 @@ export default {
toShaftInspection(name, jfType, value) { toShaftInspection(name, jfType, value) {
console.log("name, 跳转到具体的机房, value", name, jfType, value); console.log("name, 跳转到具体的机房, value", name, jfType, value);
uni.navigateTo({ uni.navigateTo({
url: `/pages/inspectionContent/inspectionContentNew?value=${value}&inspectionCode=${this.inspectionCode}&jfType=${jfType}&location=${name}&uid=${this.uid}&backValue=${this.backValue}`, url: `/pages/inspectionContent/inspectionContentNew?value=${value}&inspectionCode=${this.inspectionCode}&jfType=${jfType}&location=${name}&uid=${this.uid}&backValue=${this.backValue}&did=${this.did}`,
}); });
}, },
lookTable() { lookTable() {
......
...@@ -140,7 +140,7 @@ ...@@ -140,7 +140,7 @@
<script> <script>
import assRoomApi from "@/api/assRoom.js"; import assRoomApi from "@/api/assRoom.js";
import inspectApi from "@/api/inspect.js"; import inspectApi from "@/api/inspect.js";
import { dataToSql, sqlToData } from "./shared"; import { dataToSql, sqlToData, getHistoryData } from "./shared";
import { import {
pad_all_inspection_position, pad_all_inspection_position,
...@@ -253,6 +253,28 @@ export default { ...@@ -253,6 +253,28 @@ export default {
if (options.uid) { if (options.uid) {
this.getDetails(options.uid); this.getDetails(options.uid);
} else if (options.did) {
// 临时id
getHistoryData().then((detailsInfo) => {
console.log("history", detailsInfo);
if (detailsInfo) {
// 处理历史数据(选项、文案、照片;异常项-不调出文案及照片)
this.list = detailsInfo.originData[this.value - 1].details;
this.tabs.forEach((item) => {
if (
this.list[item.value] &&
this.list[item.value].status !== undefined
) {
item.status = this.list[item.value].status;
}
});
this.detailsInfo = detailsInfo;
uni.hideLoading();
} else {
this.init();
this.paramsObjFirst = this.getAllChildFormData();
}
});
} else { } else {
this.init(); this.init();
this.paramsObjFirst = this.getAllChildFormData(); this.paramsObjFirst = this.getAllChildFormData();
......
import moment from "moment"; import moment from "moment";
import store from "@/store"; import store from "@/store";
import inspectApi from "@/api/inspect.js";
// 将现有机房巡检数据转换为SQL数据所需要格式 // 将现有机房巡检数据转换为SQL数据所需要格式
export function dataToSql(data) { export function dataToSql(data) {
// let isException = 0; let synFlag = 0;
// if (data.isSubmit == 0) { if (data.synchronization === 1) {
// isException = 2; synFlag = 1;
// } else { } else {
// isException = data.isException; if (data.synchronization == 2 || !data.signImg) {
// } synFlag = 2;
} else {
synFlag = 0;
}
}
const send = { const send = {
inspectionType: data.inspectionType, inspectionType: data.inspectionType,
inspectionCode: data.inspectionCode, inspectionCode: data.inspectionCode,
...@@ -17,7 +22,7 @@ export function dataToSql(data) { ...@@ -17,7 +22,7 @@ export function dataToSql(data) {
isException: data.isException, // 是否异常:0 否 1 是 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.已同步 2.编辑 synFlag: synFlag, // 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()}`,
...@@ -78,3 +83,43 @@ export function sqlToData(sqlData) { ...@@ -78,3 +83,43 @@ export function sqlToData(sqlData) {
return ret; return ret;
} }
export function getHistoryData() {
return new Promise((resolve, reject) => {
inspectApi.selectLastData(store.state.now_user.userId).then((history) => {
if (history && history.length) {
const detailsInfo = sqlToData(history[0]);
// 处理历史数据(选项、文案、照片;异常项-不调出文案及照片)
console.log(JSON.stringify(detailsInfo));
setHistoryData(detailsInfo);
resolve(detailsInfo);
} else {
resolve(null);
}
});
});
}
function setHistoryData(list) {
list.originData.forEach((item) => {
// 如果该机房有异常项,则不调出文案及照片
if (item.status == 2) {
// 外面的异常标识
item.isSubmit = 0;
Object.keys(item.details).forEach((key) => {
const current = item.details[key];
if (current.status) {
// 内部的异常标识
current.detail.forEach((detail) => {
// 表单项的异常
if (detail.inspectionResult == 1) {
detail.conclusion = "";
detail.inspectionResultLable = "";
detail.photos = [];
}
});
}
});
}
});
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论