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

fix

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