提交 28d77f08 authored 作者: zs's avatar zs

edit

上级 19bf2018
......@@ -20,8 +20,15 @@ export default {
}
},
async selectDataForTime(data) {
console.log('传进来了',data.inspectionTime)
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]).getTime();
inspectionTimeCondition = `AND inspectionTime >= '${startTime}' AND inspectionTime <= '${endTime}'`;
}
let rs = await sqllitedb.selectSQL(
`SELECT id,inspectionType,inspectionCode
,recordName
......@@ -30,16 +37,17 @@ export default {
,inspectionTime
,isException
,synFlag
,createTime
,createTime,delFlag
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.inspectionTime ? `AND inspectionTime >='${new Date(data.inspectionTime[0]).getTime() }'` : ''}
${data.inspectionTime ? `AND inspectionTime <='${new Date(data.inspectionTime[1]).getTime() }'` : ''}
${inspectionTimeCondition}
and delFlag = 0
order by createTime desc`
);
return rs;
} catch (e) {
console.log(e.message);
......@@ -61,11 +69,11 @@ export default {
// await sqllitedb.closeDB();
}
},
async remove(id) {
async remove(arr) {
if (!id) {
return;
}
let sql = `delete from ${table.inspectionRecordName} where id = '${id}'`;
let sql = `delete from ${table.inspectionRecordName} where id in '${id}'`;
try {
let sqllitedb = await SqlliteDbUtil.initSqlliteDB();
await sqllitedb.executeSQL(sql);
......@@ -75,7 +83,35 @@ export default {
// await sqllitedb.closeDB();
}
},
async saveBatch(list) {
async batchRemove(id) {
let sql = `update ${table.inspectionRecordName} set delFlag=1 where id = '${id}'`;
console.log(sql)
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;
}
......
......@@ -100,7 +100,7 @@ module.exports = {
},
{
field: "delFlag",
format: "TEXT",
format: "INTEGER DEFAULT 0 ",
},
{
field: "isException",
......
<template>
<view class="inspect-item" @click="toPage">
<view class="inspect-item" @click="toPage" @longpress="onLongPress">
<view class="content" :class="details.synFlag == 1 ? 'synchronization' : ''">
<view class="name">{{
synFlags[details.synFlag]
......@@ -85,6 +85,17 @@
url: `${url}&uid=${this.details.id}`,
});
},
onLongPress(){
uni.showModal({
title: '删除确认',
content: '确定要删除此项吗?',
success: (res) => {
if (res.confirm) {
this.$emit('longpress',this.details)
}
}
});
}
},
};
</script>
......
......@@ -5,7 +5,7 @@
<text class="title">待打包数据</text>
</view>
<view class="row-item count-num">
<text class="num">{{ notSynchronizationList.length }}</text>
<text class="num">{{ list.length }}</text>
<text></text>
</view>
......
......@@ -30,7 +30,8 @@
{{index}}
</view>
<view class="inspect-list">
<InspectionItem v-for="(its,index) in item" :key="its.id" :details="its" />
<InspectionItem v-for="(its,idx) in item" :details="its" @longpress="onLongPress"
/>
</view>
</view>
......@@ -75,6 +76,7 @@
// 搜索条件
},
countNum: 0, // 统计查询总数
currentIndexToDelete: null
};
},
async mounted() {
......@@ -105,9 +107,8 @@
}
},
async init() {
console.log('这都是个啥', this.searchForm)
let res = await inspectApi.selectDataForTime(this.searchForm)
this.propList = res
this.propList = res.filter(e => e.synFlag == 0)
this.countNum = res.length
const resultMap = {};
res.forEach(e => {
......@@ -127,79 +128,8 @@
});
this.list = resultMap
return
const all_data = this.all_data || [];
// this.isPackedDataBtn =
// all_data.filter((item) => item.synchronization == 0).length > 0;
const {
inspectionTime = []
} = this.searchForm;
const startTime = inspectionTime[0];
const endTime = inspectionTime[1];
// 第一步: 筛选有效的时间范围
const timeFrame = all_data.filter((item) => {
if (!inspectionTime.length) {
return true;
} else {
return (
new Date(startTime).getTime() <=
new Date(item.submitTime).getTime() &&
new Date(item.submitTime).getTime() <= new Date(endTime).getTime()
);
}
});
// 属于同一个月的数据 聚合
const tempAllData = {};
timeFrame.forEach((item) => {
const val = tempAllData[item.submitMonth] || [];
if (val.length) {
tempAllData[item.submitMonth].push(item);
} else {
tempAllData[item.submitMonth] = [item];
}
});
const keys = Object.keys(tempAllData);
// 第二步: 根据搜索条件过滤
const list = keys.map((key) => {
return {
time: key,
list: this.coverData(tempAllData[key]),
};
});
this.countNum = 0;
list.forEach((item) => {
this.countNum += item.list.length;
});
this.list = list;
console.log("this.list", this.list);
},
coverData(arr = []) {
console.log("arr", arr);
const {
isException = "",
inspectionType = "",
synchronization = "",
} = this.searchForm;
return arr.filter((item) => {
return (
(!isException ||
isException == "all" ||
item.isException == isException) &&
(!inspectionType ||
inspectionType == "all" ||
item.inspectionType == inspectionType) &&
(!synchronization ||
synchronization == "all" ||
item.synchronization == synchronization)
);
});
},
openDialog(show) {
this.isDialog = show;
if (!show) {
......@@ -211,10 +141,21 @@
if (e.inspectionTime && e.inspectionTime.length == 0) {
delete this.searchForm.inspectionTime
}
console.log('搜索',this.searchForm)
console.log('搜索', this.searchForm)
this.init(this.searchForm);
},
async onLongPress(item) {
let rs = await inspectApi.batchRemove(item.id)
if(rs){
await this.init()
}
},
deleteItem() {
if (this.currentIndexToDelete !== null) {
this.list.splice(this.currentIndexToDelete, 1);
this.currentIndexToDelete = null; // 重置索引
}
},
toPage() {
uni.showLoading();
......
......@@ -137,6 +137,7 @@ export default class SqlliteDB {
name: _.dbName,
sql: queryLastInsertIdSql,
success(result) {
console.log('理论上',result)
if (result && result.length > 0) {
let lastInsertId = result[0].lastId;
resolve({ success: true, lastInsertId: lastInsertId });
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论