提交 7409b5f4 authored 作者: zs's avatar zs

edit

上级 cb6b97ee
...@@ -31,7 +31,7 @@ export default { ...@@ -31,7 +31,7 @@ export default {
} catch (e) { } catch (e) {
console.log(e.message) console.log(e.message)
} finally { } finally {
await sqllitedb.closeDB(); // await sqllitedb.closeDB();
} }
}, },
async info(id) { async info(id) {
...@@ -45,7 +45,7 @@ export default { ...@@ -45,7 +45,7 @@ export default {
} catch (e) { } catch (e) {
console.log(e.message) console.log(e.message)
} finally { } finally {
await sqllitedb.closeDB(); // await sqllitedb.closeDB();
} }
}, },
......
import SqlliteDbUtil from "@/utils/sqllitedb"; import SqlliteDbUtil from "@/utils/sqllitedb";
import table from "./sqllite/table.js"; import table from "./sqllite/table.js";
import { fixNullVal } from "@/utils/common"; import {
fixNullVal
} from "@/utils/common";
// 巡检 // 巡检
export default { export default {
...@@ -17,11 +19,26 @@ export default { ...@@ -17,11 +19,26 @@ export default {
await sqllitedb.closeDB(); await sqllitedb.closeDB();
} }
}, },
async selectDataForTime() { async selectDataForTime(data) {
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} order by createTime desc` `SELECT id,inspectionType,inspectionCode
,recordName
,userName
,userId
,inspectionTime
,isException
,synFlag
,createTime
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() }'` : ''}
order by createTime desc`
); );
return rs; return rs;
} catch (e) { } catch (e) {
...@@ -41,7 +58,7 @@ export default { ...@@ -41,7 +58,7 @@ export default {
} catch (e) { } catch (e) {
console.log(e.message); console.log(e.message);
} finally { } finally {
await sqllitedb.closeDB(); // await sqllitedb.closeDB();
} }
}, },
async remove(id) { async remove(id) {
...@@ -55,7 +72,7 @@ export default { ...@@ -55,7 +72,7 @@ export default {
} 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) {
...@@ -83,12 +100,12 @@ export default { ...@@ -83,12 +100,12 @@ export default {
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);
......
...@@ -60,14 +60,10 @@ export default { ...@@ -60,14 +60,10 @@ export default {
}, },
////////// 初始化数据库//////////// ////////// 初始化数据库////////////
async initSqlLite() { async initSqlLite(sqllitedb) {
console.log('初始化数据库开始...') console.log('初始化数据库开始...')
let sqllitedb = null
try { try {
// 创建打开数据库,已经存在表则跳过 // 创建打开数据库,已经存在表则跳过
sqllitedb = await SqlliteDbUtil.initSqlliteDB()
console.log(sqllitedb, '是否存在')
// console.log('创建用户表...')
await sqllitedb.createTable(table.metadataName, table.metadata) await sqllitedb.createTable(table.metadataName, table.metadata)
await sqllitedb.createTable(table.userName, table.user) await sqllitedb.createTable(table.userName, table.user)
await sqllitedb.createTable(table.inspectionRecordName, table.inspectionRecord) // 巡检记录表 await sqllitedb.createTable(table.inspectionRecordName, table.inspectionRecord) // 巡检记录表
......
...@@ -3,18 +3,9 @@ ...@@ -3,18 +3,9 @@
<!-- 图片展示区域 --> <!-- 图片展示区域 -->
<view class="image-list"> <view class="image-list">
<!-- 添加按钮 --> <!-- 添加按钮 -->
<view <view v-if="images.length < maxCount" class="add-btn" @click="chooseImage">
v-if="images.length < maxCount"
class="add-btn"
@click="chooseImage"
>
</view> </view>
<view <view v-for="(item, index) in images" :key="index" class="image-item" @click="previewImage(index)">
v-for="(item, index) in images"
:key="index"
class="image-item"
@click="previewImage(index)"
>
<image :src="item" class="image" mode="aspectFill"></image> <image :src="item" class="image" mode="aspectFill"></image>
<text class="delete-icon" @click.stop="deleteImage(index)">×</text> <text class="delete-icon" @click.stop="deleteImage(index)">×</text>
</view> </view>
...@@ -31,7 +22,7 @@ ...@@ -31,7 +22,7 @@
</template> </template>
<script> <script>
export default { export default {
name: "CommonUpload", name: "CommonUpload",
props: { props: {
value: { value: {
...@@ -80,7 +71,7 @@ export default { ...@@ -80,7 +71,7 @@ export default {
// // 检查权限状态 // // 检查权限状态
// const hasPermission = await new Promise((resolve) => { // const hasPermission = await new Promise((resolve) => {
// plus.android.requestPermissions( // plus.android.requestPermissions(
// permissions, // ["android.permission.CAMERA"],
// (result) => { // (result) => {
// let granted = true; // let granted = true;
// for (let i = 0; i < result.granted.length; i++) { // for (let i = 0; i < result.granted.length; i++) {
...@@ -150,6 +141,17 @@ export default { ...@@ -150,6 +141,17 @@ export default {
// }, // },
// 选择图片 // 选择图片
chooseImage() { chooseImage() {
plus.android.requestPermissions(
["android.permission.CAMERA"],
(result) => {
console.log('success')
resolve();
},
(error) => {
console.error("权限请求失败:", error.message);
resolve(false);
}
);
const count = this.maxCount - this.images.length; // 剩余可选图片数量 const count = this.maxCount - this.images.length; // 剩余可选图片数量
uni.chooseImage({ uni.chooseImage({
count: count, count: count,
...@@ -162,6 +164,9 @@ export default { ...@@ -162,6 +164,9 @@ export default {
this.images.push(base64); this.images.push(base64);
} }
}, },
fail(e) {
console.log(e, 'faild')
},
}); });
}, },
// 预览图片 // 预览图片
...@@ -201,28 +206,31 @@ export default { ...@@ -201,28 +206,31 @@ export default {
}); });
}, },
}, },
}; };
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.upload-container { .upload-container {}
}
.image-list { .image-list {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
} }
.image-item {
.image-item {
position: relative; position: relative;
width: 72px; width: 72px;
height: 72px; height: 72px;
margin-right: 10px; margin-right: 10px;
} }
.image {
.image {
width: 100%; width: 100%;
height: 100%; height: 100%;
box-sizing: border-box; box-sizing: border-box;
} }
.delete-icon {
.delete-icon {
position: absolute; position: absolute;
top: -6.4px; top: -6.4px;
right: -6.4px; right: -6.4px;
...@@ -234,8 +242,9 @@ export default { ...@@ -234,8 +242,9 @@ export default {
text-align: center; text-align: center;
line-height: 12.8px; line-height: 12.8px;
font-size: 9.6px; font-size: 9.6px;
} }
.add-btn {
.add-btn {
position: relative; position: relative;
width: 72px; width: 72px;
height: 72px; height: 72px;
...@@ -243,6 +252,7 @@ export default { ...@@ -243,6 +252,7 @@ export default {
cursor: pointer; cursor: pointer;
margin-right: 10px; margin-right: 10px;
box-sizing: border-box; box-sizing: border-box;
&::before { &::before {
position: absolute; position: absolute;
content: ""; content: "";
...@@ -253,6 +263,7 @@ export default { ...@@ -253,6 +263,7 @@ export default {
top: 50%; top: 50%;
transform: translateX(-50%) translateY(-50%); transform: translateX(-50%) translateY(-50%);
} }
&::after { &::after {
position: absolute; position: absolute;
content: ""; content: "";
...@@ -263,10 +274,11 @@ export default { ...@@ -263,10 +274,11 @@ export default {
top: 50%; top: 50%;
transform: translateX(-50%) translateY(-50%); transform: translateX(-50%) translateY(-50%);
} }
} }
.tip {
.tip {
font-size: 12px; font-size: 12px;
color: #999; color: #999;
margin-top: 5px; margin-top: 5px;
} }
</style> </style>
\ No newline at end of file
...@@ -2,17 +2,17 @@ ...@@ -2,17 +2,17 @@
<view class="inspect-item" @click="toPage"> <view class="inspect-item" @click="toPage">
<view class="content" :class="details.synFlag == 1 ? 'synchronization' : ''"> <view class="content" :class="details.synFlag == 1 ? 'synchronization' : ''">
<view class="name">{{ <view class="name">{{
details.synFlag == 0 ? "未同步" : "已同步" synFlags[details.synFlag]
}}</view> }}</view>
<view class="info"> <view class="info">
<view class="info-row"> <view class="info-row">
<text class="title">{{ getLabel(details.inspectionType) }}</text> <text class="title">{{ getLabel(details.inspectionType) }}</text>
<text class="status">{{ Exception[details.isException] <text class="status" :class="{'error':details.isException == 1}">{{ details.isException == 0 ?'正常':'异常'
}}</text> }}</text>
</view> </view>
<view class="info-row info-row-code"> <view class="info-row info-row-code">
<text>巡检人:</text> <text>巡检人:</text>
<text class="code-num">{{details.inspectionBy}}</text> <text class="code-num">{{details.userName}}</text>
<text>编号:</text> <text>编号:</text>
<text class="code-num">{{ details.inspectionCode }}</text> <text class="code-num">{{ details.inspectionCode }}</text>
<text>巡检日期:</text> <text>巡检日期:</text>
...@@ -43,9 +43,9 @@ ...@@ -43,9 +43,9 @@
}, },
data() { data() {
return { return {
Exception: { synFlags: {
0: '正常', 0: '未同步',
1: '异常', 1: '已同步',
2: '巡检中' 2: '巡检中'
} }
} }
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
} }
// 转换为数字并使用 moment 格式化日期 // 转换为数字并使用 moment 格式化日期
const createTime = parseInt(this.details.createTime, 10); const createTime = parseInt(this.details.createTime, 10);
return moment(createTime).format('YYYY-MM-DD HH:mm:ss'); return moment(createTime).format('YYYY-MM-DD');
}, },
}, },
mounted() { mounted() {
...@@ -137,12 +137,18 @@ ...@@ -137,12 +137,18 @@
.status { .status {
padding: 0 6.4px; padding: 0 6.4px;
font-size: 9.6px; font-size: 9.6px;
color: #ffffff; color: #0CC991;
text-align: center; text-align: center;
line-height: 16px; line-height: 16px;
font-weight: 400; font-weight: 400;
background: #ffab24; background: #E6F9F3;
border-radius: 8px; border-radius: 11px;
}
.error {
background: #FDEBE9;
border-radius: 11px;
color: #F55A42
} }
.alarm { .alarm {
...@@ -199,10 +205,7 @@ ...@@ -199,10 +205,7 @@
color: #4a4a4a; color: #4a4a4a;
} }
.status {
background: #9c9c9c16 !important;
color: #4a4a4a !important;
}
} }
} }
</style> </style>
\ No newline at end of file
...@@ -2,57 +2,26 @@ ...@@ -2,57 +2,26 @@
<!-- 巡检管理搜索页 --> <!-- 巡检管理搜索页 -->
<view class="search-com"> <view class="search-com">
<view class="search-com-left"> <view class="search-com-left">
<uni-data-select <uni-data-select v-if="!hiddenSearch.includes('inspectionType')" class="uni-search-item"
v-if="!hiddenSearch.includes('inspectionType')" v-model="searchFrom.inspectionType" :localdata="inspectArr" @change="(e) => change(e, 'inspectionType')"
class="uni-search-item" placeholder="类型"></uni-data-select>
v-model="searchFrom.inspectionType"
:localdata="inspectArr"
@change="(e) => change(e, 'inspectionType')"
placeholder="类型"
:clear="true"
:key="new Date().getTime()"
></uni-data-select>
<uni-data-select <uni-data-select v-if="!hiddenSearch.includes('synFlag')" class="uni-search-item" v-model="searchFrom.synFlag" :localdata="synchronization" placeholder="状态"
v-if="!hiddenSearch.includes('synchronization')" @change="(e) => change(e, 'synFlag')"></uni-data-select>
class="uni-search-item"
v-model="searchFrom.synchronization"
:localdata="synchronization"
placeholder="状态"
@change="(e) => change(e, 'synchronization')"
:clear="true"
:key="new Date().getTime()"
></uni-data-select> <uni-data-select v-if="!hiddenSearch.includes('isException')" class="uni-search-item"
v-model="searchFrom.isException" :localdata="exceptionArr" placeholder="异常"
<uni-data-select @change="(e) => change(e, 'isException')" :key="new Date().getTime()"></uni-data-select>
v-if="!hiddenSearch.includes('isException')"
class="uni-search-item"
v-model="searchFrom.isException"
:localdata="exceptionArr"
placeholder="异常"
@change="(e) => change(e, 'isException')"
:clear="true"
:key="new Date().getTime()"
></uni-data-select>
</view> </view>
<view <view class="search-com-right" v-if="!hiddenSearch.includes('inspectionTime')">
class="search-com-right" <uni-datetime-picker class="uni-datetime-picker" type="daterange" v-model="searchFrom.inspectionTime"
v-if="!hiddenSearch.includes('inspectionTime')" :border="false" @change="(e) => change(e, 'inspectionTime')" />
>
<uni-datetime-picker
class="uni-datetime-picker"
type="daterange"
v-model="searchFrom.inspectionTime"
:border="false"
@change="(e) => change(e, 'inspectionTime')"
/>
</view> </view>
</view> </view>
</template> </template>
<script> <script>
export default { export default {
props: { props: {
hiddenSearch: { hiddenSearch: {
// 隐藏搜索项 // 隐藏搜索项
...@@ -66,49 +35,76 @@ export default { ...@@ -66,49 +35,76 @@ export default {
return { return {
searchFrom: { searchFrom: {
inspectionType: "", // 巡检类型 inspectionType: "", // 巡检类型
synchronization: "", // 同部数据 synFlag: "", // 同部数据
isException: "", // 有无异常 isException: "", // 有无异常
inspectionTime: "", // 时间选择 inspectionTime: "", // 时间选择
}, },
inspectArr: [ inspectArr: [{
{ value: "all", text: "全部" }, value: "",
{ value: "1", text: "机房巡检" }, text: "全部巡检"
{ value: "2", text: "井道巡检" }, },
{
value: "1",
text: "机房巡检"
},
{
value: "2",
text: "井道巡检"
},
], ],
synchronization: [ synchronization: [{
{ value: "all", text: "全部" }, value: "",
{ value: "2", text: "编辑中" }, text: "全部"
{ value: "0", text: "待同步" }, },
{ value: "1", text: "已同步" }, {
value: "2",
text: "编辑中"
},
{
value: "0",
text: "未同步"
},
{
value: "1",
text: "已同步"
},
], ],
exceptionArr: [ exceptionArr: [{
{ value: "all", text: "全部" }, value: "",
{ value: "1", text: "有" }, text: "全部"
{ value: "0", text: "无" }, },
{
value: "1",
text: "有"
},
{
value: "0",
text: "无"
},
], ],
}; };
}, },
methods: { methods: {
change(e, key) { change(e, key) {
this.searchFrom[key] = e; this.searchFrom[key] = e;
this.$emit("change", this.searchFrom); this.$emit("change", this.searchFrom);
}, },
}, },
}; };
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
.search-com { .search-com {
display: flex; display: flex;
align-items: center; align-items: center;
margin-top: 8px; margin-top: 8px;
// width: 50%; // width: 50%;
.search-com-left { .search-com-left {
display: flex; display: flex;
flex:1;
align-items: center; align-items: center;
.uni-search-item { .uni-search-item {
width: 132px; width: 132px;
height: 36px; height: 36px;
...@@ -118,8 +114,10 @@ export default { ...@@ -118,8 +114,10 @@ export default {
border: none !important; border: none !important;
} }
} }
.search-com-right { .search-com-right {
width: 300px; width: 300px;
.uni-datetime-picker { .uni-datetime-picker {
height: 36px; height: 36px;
background: #fff; background: #fff;
...@@ -127,5 +125,5 @@ export default { ...@@ -127,5 +125,5 @@ export default {
border: none !important; border: none !important;
} }
} }
} }
</style> </style>
\ No newline at end of file
...@@ -63,9 +63,7 @@ export default { ...@@ -63,9 +63,7 @@ export default {
props: { props: {
list: { list: {
type: Array, type: Array,
default: () => { default: () => {},
return [];
},
}, },
}, },
components: {}, components: {},
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
</block> </block>
</uni-nav-bar> </uni-nav-bar>
<!-- 搜索项 --> <!-- 搜索项 -->
<!-- <SearchCom @change="change" /> --> <SearchCom @change="change" />
<!-- 结果 --> <!-- 结果 -->
<view class="inspection-management-content"> <view class="inspection-management-content">
<view class="count-tatal"> <view class="count-tatal">
...@@ -27,10 +27,10 @@ ...@@ -27,10 +27,10 @@
<!-- 每月记录 --> <!-- 每月记录 -->
<view class="month-record-item" v-for="(item, index) in list" :key="index"> <view class="month-record-item" v-for="(item, index) in list" :key="index">
<view class="seconed-title"> <view class="seconed-title">
{{ '2025-04'}} {{index}}
</view> </view>
<view class="inspect-list"> <view class="inspect-list">
<InspectionItem :details="item" /> <InspectionItem v-for="(its,index) in item" :key="its.id" :details="its" />
</view> </view>
</view> </view>
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
<!-- 开始巡检 --> <!-- 开始巡检 -->
<!-- <view class="inspection-button" @click="toPage">开始巡检</view> --> <!-- <view class="inspection-button" @click="toPage">开始巡检</view> -->
<view class="inspection-button" @click="openDialog(true)">同步数据</view><!-- 打包弹窗 --> <view class="inspection-button" @click="openDialog(true)">同步数据</view><!-- 打包弹窗 -->
<Dialog v-show="isDialog && list.length" :list="list" @close="openDialog(false)"></Dialog> <Dialog v-show="isDialog" :list="propList" @close="openDialog(false)"></Dialog>
</view> </view>
</template> </template>
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
getAllInspections getAllInspections
} from "@/request/index.js"; } from "@/request/index.js";
import Empty from "@/components/empty/index.vue"; import Empty from "@/components/empty/index.vue";
import moment from "moment";
import inspectApi from "@/api/inspect"; import inspectApi from "@/api/inspect";
export default { export default {
components: { components: {
...@@ -69,6 +69,7 @@ ...@@ -69,6 +69,7 @@
return { return {
isDialog: false, // isDialog: false, //
list: [], // 展示数据 list: [], // 展示数据
propList: [],
all_data: [], // 所有数据 all_data: [], // 所有数据
searchForm: { searchForm: {
// 搜索条件 // 搜索条件
...@@ -77,10 +78,8 @@ ...@@ -77,10 +78,8 @@
}; };
}, },
async mounted() { async mounted() {
// this.getInspectRecord() this.init(this.searchForm)
let res = await inspectApi.selectDataForTime()
this.list = res
console.log(res.length, '永远永远永远永远=---=>')
}, },
computed: { computed: {
userInfo() { userInfo() {
...@@ -88,13 +87,6 @@ ...@@ -88,13 +87,6 @@
}, },
}, },
methods: { methods: {
async getInspectRecord() {
let res = await inspectApi.selectList()
console.log('阿斗者', res)
this.list = res || []
this.countNum = this.list.length
},
// 返回 // 返回
back() { back() {
uni.navigateTo({ uni.navigateTo({
...@@ -112,7 +104,29 @@ ...@@ -112,7 +104,29 @@
}); });
} }
}, },
init() { async init() {
console.log('这都是个啥', this.searchForm)
let res = await inspectApi.selectDataForTime(this.searchForm)
this.propList = res
this.countNum = res.length
const resultMap = {};
res.forEach(e => {
if (e.createTime) {
const createTime = parseInt(e.createTime, 10);
const yearMonth = moment(createTime).format('YYYY年M月');
e.yearMonth = yearMonth
if (!resultMap[yearMonth]) {
resultMap[yearMonth] = [];
}
// 将当前记录添加到对应的 yearMonth 数组中
resultMap[yearMonth].push({
...e
});
}
});
this.list = resultMap
return
const all_data = this.all_data || []; const all_data = this.all_data || [];
// this.isPackedDataBtn = // this.isPackedDataBtn =
// all_data.filter((item) => item.synchronization == 0).length > 0; // all_data.filter((item) => item.synchronization == 0).length > 0;
...@@ -194,8 +208,11 @@ ...@@ -194,8 +208,11 @@
}, },
change(e) { change(e) {
this.searchForm = e; this.searchForm = e;
if (e.inspectionTime && e.inspectionTime.length == 0) {
this.init(); delete this.searchForm.inspectionTime
}
console.log('搜索',this.searchForm)
this.init(this.searchForm);
}, },
toPage() { toPage() {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论