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

edit

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