提交 25410e74 authored 作者: JaxBBLL's avatar JaxBBLL

fix

上级 6ca835ae
import SqlliteDbUtil from "@/utils/sqllitedb";
import table from "./sqllite/table.js";
import {
fixNullVal
} from "@/utils/common";
import { fixNullVal } from "@/utils/common";
// 巡检
export default {
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 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() {
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`
);
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(id) {
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 selectDataForTime() {
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`
);
return rs;
} catch (e) {
console.log(e.message);
} finally {
await sqllitedb.closeDB();
}
column = column.endsWith(",")
? column.substring(0, column.length - 1)
: column;
values = values.endsWith(",")
? values.substring(0, values.length - 1)
: values;
},
async info(id) {
let sqllitedb = await SqlliteDbUtil.initSqlliteDB();
try {
let sql = `select * from ${table.inspectionRecordName} where id = '${id}'`;
let res = await sqllitedb.selectSQL(sql);
debugger;
if (res && res.length > 0) {
return res[0];
}
} catch (e) {
console.log(e.message);
} finally {
await sqllitedb.closeDB();
}
},
async remove(id) {
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;
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,
......@@ -145,24 +138,24 @@ export default {
'${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}',
......@@ -177,12 +170,12 @@ export default {
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("更新完成...");
},
};
\ No newline at end of file
await sqllitedb.executeSQL(sql);
} catch (e) {
console.log(e.message);
} finally {
await sqllitedb.closeDB();
}
console.log("更新完成...");
},
};
......@@ -18,7 +18,7 @@
<CommonUpload
v-model="item.photos"
:max-count="9999"
@change="onPhotoChange"
@input="onPhotoChange"
>
</CommonUpload>
</view>
......@@ -112,10 +112,7 @@ export default {
// 处理弹窗确认
handlePopupConfirm(summary) {
this.itemData.detail[this.currentIndex].conclusion = summary; // 回显到文字显示区域
this.$emit("sync", {
conclusion: summary,
photos: this.itemData.detail[this.currentIndex].photos,
});
this.$emit("sync", this.itemData);
},
// 处理】数据
getFromData() {
......@@ -163,10 +160,7 @@ export default {
},
onPhotoChange(val) {
this.itemData.detail[this.currentIndex].photos = val;
this.$emit("sync", {
conclusion: this.itemData.detail[this.currentIndex].conclusion,
photos: val,
});
this.$emit("sync", this.itemData);
},
},
};
......
......@@ -22,7 +22,7 @@
<view class="profile-left">
<view class="avatar">
<image
src="@/static/img/add-img/home1.png"
src="@/static/img/add-img/defaultAvatar.png"
mode="aspectFit"
></image>
</view>
......
......@@ -761,12 +761,10 @@ export default {
this.switchTab((this.activeTab + 1) % this.tabs.length);
},
setQtValue(data) {
console.log("setQtValue", data);
this.detailsInfo.originData.forEach((item) => {
if (item.details && item.details.qt && item.details.qt.detail) {
item.details.qt.detail.forEach((current) => {
item.conclusion = data.conclusion;
item.photos = data.photos;
});
if (item.details) {
item.details.qt = data;
}
});
console.log("setQtValue", this.detailsInfo);
......
......@@ -13,7 +13,7 @@ export function dataToSql(data) {
inspectionType: data.inspectionType,
inspectionCode: data.inspectionCode,
recordName: `${moment().format("yyyyMMDD")}-机房巡检`,
inspectionTime: moment().format("yyyy-MM-DD HH:mm"),
inspectionTime: `${new Date().getTime()}`,
isException: data.isException, // 是否异常:0 否 1 是 2 巡检中
userId: store.state.now_user.userId,
userName: store.state.now_user.user,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论