提交 25dc648d authored 作者: zs's avatar zs

edit

上级 ca6366a6
......@@ -37,33 +37,20 @@ export default {
async info(id) {
let sqllitedb = await SqlliteDbUtil.initSqlliteDB();
try {
let sql = `select * from ${table.assRoomName} where id = '${id}'`;
let res = await sqllitedb.selectSQL(sql);
if (res && res.length > 0) {
return res[0];
}
return null;
} catch (e) {
console.log(e.message)
} finally {
await sqllitedb.closeDB();
}
},
async remove(id) {
if (!id) {
return;
}
let sql = `delete from ${table.assRoomName} 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) {
......
......@@ -21,7 +21,7 @@ export default {
let sqllitedb = await SqlliteDbUtil.initSqlliteDB();
try {
let rs = await sqllitedb.selectSQL(
`SELECT *,strftime( '%Y年%m月',createTime) AS yearMonth FROM ${table.inspectionRecordName} order by createTime desc`
`SELECT * FROM ${table.inspectionRecordName} order by createTime desc`
);
return rs;
} catch (e) {
......
......@@ -20,15 +20,22 @@ export default {
// 初始化目录
// await this.initDir()
// 初始化数据库
this.initSqlLite()
let sqllitedb = await SqlliteDbUtil.initSqlliteDB()
let isInit = await SqlliteDbUtil.checkIfDataImported(sqllitedb)
let sqllitedb = await SqlliteDbUtil.initSqlliteDB();
console.log('Database initialized.');
await this.initSqlLite(sqllitedb); // 确保表被创建
console.log('Tables created.');
let isInit = await SqlliteDbUtil.checkIfDataImported(sqllitedb); // 确保表存在后再查询
console.log('Data imported:', isInit);
if (!isInit) {
await userApi.saveBatch(userjson)
await hoistwayApi.saveBatch(hoistwayjson)
await assRoomApi.saveBatch(assroomjson)
await SqlliteDbUtil.markDataAsImported(sqllitedb)
}
// 初始化完成通知首页
uni.hideLoading()
},
......
......@@ -12,7 +12,7 @@ module.exports = {
userName: "SYS_USER",
user: [{
field: "userId",
format: "TEXTWW",
format: "TEXT",
},
{
field: "user",
......
......@@ -58,18 +58,11 @@ export default {
},
async info(id) {
let sqllitedb = await SqlliteDbUtil.initSqlliteDB()
try {
let sql = `select * from ${table.userName} where userId = '${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();
let sql = `select * from ${table.userName} where userId = '${id}'`;
let res = await sqllitedb.selectSQL(sql);
if (res && res.length > 0) {
return res[0]
}
},
async changePwd(data) {
......
差异被折叠。
......@@ -2,13 +2,12 @@
<view class="inspect-item" @click="toPage">
<view class="content" :class="details.synFlag == 1 ? 'synchronization' : ''">
<view class="name">{{
details.isSubmit == 0 ? "编辑中" :details.synFlag == 0 ? "待同步" : "已同步"
details.synFlag == 0 ? "未同步" : "已同步"
}}</view>
<view class="info">
<view class="info-row">
<text class="title">{{ getLabel(details.inspectionType) }}</text>
<text class="status">{{
details.isException>0?"异常":"正常"
<text class="status">{{ Exception[details.isException]
}}</text>
</view>
<view class="info-row info-row-code">
......@@ -17,7 +16,7 @@
<text>编号:</text>
<text class="code-num">{{ details.inspectionCode }}</text>
<text>巡检日期:</text>
<text class="code-num">{{ details.inspectionTime }}</text>
<text class="code-num">{{ formattedDate }}</text>
</view>
</view>
<view class="img">
......@@ -28,6 +27,7 @@
</view>
</template>
<script>
import moment from "moment";
import {
pad_inspection_type
} from "@/utils/dict.js";
......@@ -41,10 +41,28 @@
type: Boolean,
},
},
data() {
return {
Exception: {
0: '正常',
1: '异常',
2: '巡检中'
}
}
},
computed: {
formattedDate() {
if (!this.details.createTime) {
return '无效日期';
}
// 转换为数字并使用 moment 格式化日期
const createTime = parseInt(this.details.createTime, 10);
return moment(createTime).format('YYYY-MM-DD HH:mm:ss');
},
},
mounted() {
console.log(" this.details", this.details)
},
methods: {
getLabel(val) {
const temp =
......
......@@ -26,10 +26,9 @@
<view class="month-list">
<!-- 每月记录 -->
<view class="month-record-item" v-for="(item, index) in list" :key="index">
<view v-if="(item || []).length" class="seconed-title">
<view class="seconed-title">
{{ '2025-04'}}
</view>
<view class="inspect-list">
<InspectionItem :details="item" />
</view>
......
......@@ -115,7 +115,6 @@ export default class SqlliteDB {
name: this.dbName,
sql: sql,
success(res) {
console.log('SQL execution result:', res);
resolve(res); // 暂时直接返回,方便调试
},
fail(e) {
......@@ -127,7 +126,6 @@ export default class SqlliteDB {
}
// 增删改返回最后增加的id
async executeReturnDataSQL(sql) {
console.log('Executing SQL:', sql);
let _ = this
return new Promise((resolve, reject) => {
plus.sqlite.executeSql({
......@@ -141,7 +139,6 @@ export default class SqlliteDB {
success(result) {
if (result && result.length > 0) {
let lastInsertId = result[0].lastId;
console.log('Last Insert ID:', lastInsertId);
resolve({ success: true, lastInsertId: lastInsertId });
} else {
resolve({ success: true, lastInsertId: null });
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论