巡检记录接口对接

This commit is contained in:
Zy
2026-05-19 09:23:23 +08:00
parent 9d06785fd2
commit 82200a3617
17 changed files with 880 additions and 467 deletions

View File

@@ -0,0 +1,15 @@
/**
* @Description: 抽离 公共基础地址
* @Author: Zy
* @Date: 2026-05-18 15:36:10
* @LastEditor: Zy
* @LastEditTime: 2026-05-18 15:36:21
*/
let baseUrl = ''
if (process.env.NODE_ENV === 'development') {
baseUrl = 'http://192.168.0.239:8080' // 开发环境
} else {
baseUrl = 'http://192.168.0.239:8080' // 生产环境
}
export default baseUrl;

View File

@@ -3,9 +3,12 @@
* @Author: Zy * @Author: Zy
* @Date: 2026-05-15 11:37:01 * @Date: 2026-05-15 11:37:01
* @LastEditor: Zy * @LastEditor: Zy
* @LastEditTime: 2026-05-15 17:02:25 * @LastEditTime: 2026-05-18 15:34:07
*/ */
import request, { get, post } from './request.js' import request, {
get,
post
} from './request.js'
/** /**
* @typedef EmployeeItem 员工信息项 * @typedef EmployeeItem 员工信息项
@@ -61,8 +64,19 @@ export function getSystemUsers_employee(roleKey, keyword) {
* @param {string} [keyword=''] - 搜索关键词(可选),房屋号/业主姓名 * @param {string} [keyword=''] - 搜索关键词(可选),房屋号/业主姓名
* @returns {Promise<RowsResult<HouseItem>>} * @returns {Promise<RowsResult<HouseItem>>}
*/ */
export function getVillageHouseList_keyword(data, keyword) { export function getVillageHouseList_keyword(data, searchValue = '') {
return get( return get(
`/manage/replace/sdb/village/house?pageSize=${data.pageSize}&pageNum=${data.pageNum}&keyword=${keyword}` `/manage/replace/sdb/village/house?pageSize=${data.pageSize}&pageNum=${data.pageNum}&searchValue=${searchValue}`
) )
} }
/**
* @description: 管家端通用 文件上传
* @param {FormData} file
* @return
*/
export function uploadFile(file) {
return post('/resource/oss/upload', file)
}

View File

@@ -3,7 +3,7 @@
* @Author: Zy * @Author: Zy
* @Date: 2026-05-15 08:50:47 * @Date: 2026-05-15 08:50:47
* @LastEditor: Zy * @LastEditor: Zy
* @LastEditTime: 2026-05-15 16:47:31 * @LastEditTime: 2026-05-16 15:42:36
*/ */
import request, { import request, {
filterParams, filterParams,

View File

@@ -0,0 +1,74 @@
/**
* @Description: 巡检记录 API
* @Author: Zy
* @Date: 2026-05-16 15:43:07
* @LastEditor: Zy
* @LastEditTime: 2026-05-18 16:35:05
*/
import request, {
filterParams,
get,
put,
post
} from "./request.js";
/**
* @typedef PointsType 巡检任务表
* @property {string} id = [巡检点ID]
* @property {string[]} itemNames = [巡检项目名称]
* @property {string[]} itemIds = [巡检项目ID]
* @property {string} pointName = [巡检点名称]
* */
/**
* @typedef InspectionListType 巡检任务表
* @property {string} id = [巡检任务ID]
* @property {string} taskName = [巡检任务名称]
* @property {string} taskTime = [巡检任务执行时间]
* @property {string} taskStatus = [巡检状态]
* @property {string} planName = [巡检计划]
* @property {string} inspectorName = [巡检人员]
* @property {string} executeDate = [巡检日期]
* @property {PointsType[]} points = [巡检点]
* @property {string[]} [itemslist] = [巡检项目]
* */
/**
* @description: 获取巡检任务列表
* @param { RequestParams<{ date?:string }> } data
* @return { Promise<RowsResult<InspectionListType>> }
*/
export const getInspectionList = (data) => {
return get('/api/inspection/today/list', filterParams(data))
}
/**
* @description: 获取 巡检任务详情
* @param {string} id
* @return
*/
export const getInspectionMain = (id) => {
return get('/api/inspection/today/detail', {
taskId: id
})
}
/**
* @typedef inspectionPointParams 巡检任务表
* @property {string} pointId = [巡检点ID]
* @property {string} imgUrl = [巡检点,图片上传]
* @property {string} remark = [巡检点 巡检描述]
* @property {string} taskId = [巡检任务ID]
* @property {number} status = [巡检点状态] 0正常1异常
* */
/**
* @description: 巡检点上传
* @param {inspectionPointParams} data
*/
export const putInsepctionPoint = (data) => {
return post('/api/inspection/today/pointImg', data)
}

View File

@@ -1,4 +1,50 @@
/**
* @Description: 仪表换新API
* @Author: Zy
* @Date: 2026-05-16 15:53:23
* @LastEditor: Zy
* @LastEditTime: 2026-05-16 16:38:54
*/
import request, { import request, {
filterParams,
get, get,
post post,
put
} from "./request.js" } from "./request.js"
/**
* 设备类型枚举
* @typedef {1 | 2} DeviceType
* @description 1=水表 2=电表
*/
/**
* @typedef ReplaceMentRecordList 巡检任务表
* @property {string} deviceCode = [设备编号]
* @property {DeviceType} deviceType = [设备类型]
* @property {string} houseId = [楼栋ID]
* @property {string} buildingName = [楼栋名称]
* @property {string} unitNo = [单元号]
* @property {string} houseNo = [房屋号]
* @property {string} addressCn = [房屋地址]
* @property {string} addressHyphen = [房屋地址]
* @property {string} createTime = [创建时间]
* */
/**
* 获取仪表换新记录
* @param {RequestParams} data 请求参数
* @return {Promise<RowsResult<ReplaceMentRecordList>>}
*/
export const getReplaceMainList = (data) => {
return get('/manage/replace/sdb/record/list', filterParams(data))
}
/**
* @description: 添加仪表API
* @param {{ deviceType:DeviceType, deviceCode:string,houseId:string }} data
*/
export const AddReplaceMainList = (data) => {
return put('/manage/replace/sdb/replace/device', filterParams(data))
}

View File

@@ -1,9 +1,4 @@
let baseUrl = '' import baseUrl from './BaseUrl.js'
if (process.env.NODE_ENV === 'development') {
baseUrl = 'http://192.168.0.239:8080' // 开发环境
} else {
baseUrl = 'http://192.168.0.239:8080' // 生产环境
}
export default function request(url, data = {}, method = 'GET') { export default function request(url, data = {}, method = 'GET') {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {

View File

@@ -24,6 +24,7 @@
<script setup> <script setup>
import { ref, watch } from 'vue' import { ref, watch } from 'vue'
import baseUrl from '@/api/BaseUrl.js'
// ====================== // ======================
// Props(可配置) // Props(可配置)
@@ -102,7 +103,6 @@ function choose() {
sizeType: props.sizeType, sizeType: props.sizeType,
success: async res => { success: async res => {
const tempPaths = res.tempFilePaths const tempPaths = res.tempFilePaths
// 如果没传上传接口,只返回临时路径 // 如果没传上传接口,只返回临时路径
if (!props.uploadUrl) { if (!props.uploadUrl) {
const newItems = tempPaths.map(path => ({ url: path })) const newItems = tempPaths.map(path => ({ url: path }))
@@ -135,9 +135,13 @@ async function uploadSingle(filePath) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
uni.uploadFile({ uni.uploadFile({
url: props.uploadUrl, url: `${baseUrl}${props.uploadUrl}`,
filePath: filePath, filePath: filePath,
name: props.fileFieldName, name: props.fileFieldName,
header: {
Authorization: 'Bearer ' + (uni.getStorageSync('token') || ''),
clientid: 'butler'
},
// ✅ 新增:携带额外参数 // ✅ 新增:携带额外参数
formData: props.extraData, formData: props.extraData,
success: res => { success: res => {

View File

@@ -1,24 +1,35 @@
// 全局 JSDoc 类型定义 全项目所有文件通用 // 全局 JSDoc 类型定义 全项目所有文件通用
/** /**
* 【全局】通用分页接口返回结构1 * 【全局】通用分页接口返回结构
* @template T - 列表项类型 * @template T - 列表项类型
* @typedef {Object} RowsResult * @typedef RowsResult 分页结构
* @property {number} code 响应码,200=成功 * @property {number} code 响应码,200=成功
* @property {string} msg 响应消息 * @property {string} msg 响应消息
* @property {number} total 总条数 * @property {number} total 总条数
* @property {T[]} rows 数据列表 * @property {T[]} rows 数据列表
*/ */
/** /**
* 【全局】通用接口返回结构2 * 返回结果
* @template T - 列表项类型 * @template T
* @typedef {Object} DataResult * @typedef {Object} DataResult
* @property {T} data 列表数据
* @property {number} code 响应码,200=成功 * @property {number} code 响应码,200=成功
* @property {string} msg 响应消息 * @property {string} msg 响应消息
* @property {T} data 数据列表
*/ */
/**
* 分页参数
* @typedef {Object} PageType
* @property {number} pageSize 每页条数
* @property {number} pageNum 当前页码
*/
/**
* 通用请求参数(T 不传时 = PageType)
* @template [T=undefined]
* @typedef {T extends undefined ? PageType : PageType & T} RequestParams
*/
/** /**
* 【全局】角色标识枚举 * 【全局】角色标识枚举

View File

@@ -5,33 +5,32 @@
<view class="title_box flex items-center justify-between"> <view class="title_box flex items-center justify-between">
<view class="title flex items-center"> <view class="title flex items-center">
<view class="line"> </view> <view class="line"> </view>
<text>{{ info.taskName }}</text> <text>{{ info.villageName }} - {{ info.taskName }}</text>
</view>
<view class="inspection_status" v-if="info.status === 0"> <text>已巡检</text> </view>
<view class="inspection_status todo" v-else>
<text>未巡检</text>
</view> </view>
<view class="inspection_status"> <text>已巡检</text> </view>
</view> </view>
<view class="info"> <view class="info">
<view class="item"> <view class="item">
<text>巡检项目:</text> <text>巡检项目:</text>
<text>{{ info.items.join('; ') }}</text> <text>{{ info.planName }}</text>
</view> </view>
<view class="item"> <view class="item">
<text>巡检时间:</text> <text>巡检时间:</text>
<text>{{ info.time }}</text> <text>07:00:00 - 09:00:00</text>
</view> </view>
<view class="item"> <view class="item">
<text>巡检小区:</text> <text>巡检小区:</text>
<text>{{ info.villageName }}</text> <text>{{ info.villageName }}</text>
</view> </view>
<view class="" v-for="(item, index) in baseFormData" :key="index">
<view class="item"> <view class="item">
<text>巡检路线:</text> <text>巡检路线:</text>
<text>{{ info.planName }}</text> <text>{{ item.routeName }}</text>
</view> </view>
<view class="item"> <view class="item">
<text>巡检点:</text> <text>巡检点:</text>
<text>{{ info.point.join('; ') }}</text> <text v-for="(ite, ind) in item.points" :key="ind">{{ ite.pointName }};</text>
</view>
</view> </view>
</view> </view>
</view> </view>
@@ -39,39 +38,49 @@
<view class="inspecton_result_title"> <view class="inspecton_result_title">
<text>巡检结果</text> <text>巡检结果</text>
</view> </view>
<view class="inspection_body" v-for="(item, index) in result" :key="index"> <view class="inspection_body" v-for="(item, index) in baseFormData" :key="index">
<view v-for="(ite, ind) in item.points" :key="ind">
<view class="inspection_items">
<text class="label">巡检路线:</text>
<text style="font-weight: 550">{{ item.routeName }}</text>
</view>
<view class="inspection_items"> <view class="inspection_items">
<text class="label">巡检点:</text> <text class="label">巡检点:</text>
<text>{{ item.pointName }}</text> <text>{{ ite.pointName }}</text>
</view> </view>
<view class="inspection_items"> <view class="inspection_items">
<text class="label">巡检人:</text> <text class="label">巡检人:</text>
<text>{{ item.user }}</text> <text>{{ ite.resientName }}</text>
</view> </view>
<view class="inspection_items"> <view class="inspection_items">
<text class="label">手机号码:</text> <text class="label">手机号码:</text>
<text>{{ item.phone }}</text> <text>{{ ite.phone }}</text>
</view> </view>
<view class="inspection_items"> <view class="inspection_items">
<text class="label">巡检时间:</text> <text class="label">巡检时间:</text>
<text>{{ item.time }}</text> <text>{{ ite.time }}</text>
</view>
<view class="inspection_items">
<text class="label">巡检状态:</text>
<text>{{ ite.status === 0 ? '正常' : '异常' }}</text>
</view> </view>
<view class="inspection_items"> <view class="inspection_items">
<view class="label">巡检结果:</view> <view class="label">巡检结果:</view>
<view class="desction_value">{{ item.descrtion }}</view> <view class="desction_value">{{ ite.descrtion }}</view>
</view> </view>
<view class="inspection_items"> <view class="inspection_items">
<view class="label">巡检照片:</view> <view class="label">巡检照片:</view>
<image <image
lazy-load lazy-load
class="inspection_photo" class="inspection_photo"
v-for="(ite, ind) in item.photos" v-for="(it, ind) in ite.files"
:key="ind" :key="ind"
:src="ite" :src="it"
mode="scaleToFill" mode="scaleToFill"
></image> ></image>
</view> </view>
<view class="linedash" v-show="index + 1 !== result.length"> </view> <view class="linedash" v-show="ind + 1 !== item.points.length"> </view>
</view>
</view> </view>
</view> </view>
</view> </view>
@@ -80,57 +89,65 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref } from 'vue' import { ref } from 'vue'
import { getInspectionMain } from '@/api/insepction.js'
import { onLoad } from '@dcloudio/uni-app'
const taskid = ref('')
const info = ref({ const info = ref({
items: ['设备巡检', '电力检查'], planName: '',
time: '07:00:00-12:00:00', remindTime: '',
villageName: '幸福苑小区', routes: [],
taskName: '幸福苑小区-B1层地下车区', taskId: '',
status: 0, // 0 已巡检 1未巡检 taskName: '',
planName: '常规巡检路线1', taskTime: '',
point: ['安全出口1号', '巡检点2号', '巡检点3号'] villageName: ''
}) })
const result = ref([ const baseFormData = ref([])
{
pointName: '安全出口1号', function init() {
user: '李相龙', if (!taskid.value) return
phone: '1502360831', getInspectionMain(taskid.value)
time: '2026-10-25 08:10:01', .then(res => {
descrtion: '设备正常运转,电力系统正常,设备使用正常', info.value = res.data
photos: [ if (!res.data.routes) return
'https://picsum.photos/80', let result = res.data.routes
'https://picsum.photos/80', .map(item => {
'https://picsum.photos/80', if (!item.points || item.points.length <= 0) return false
'https://picsum.photos/80' const points = item.points.map(ite => {
] return {
}, pointId: ite.pointId,
{ pointName: ite.pointName,
pointName: '巡检点2号', status: ite.status ?? 0,
user: '李相龙', desition: ite.remark,
phone: '1502360831', files: ite.imgUrl ? ite.imgUrl.split(',') : [],
time: '2026-10-25 10:10:01', phone: '',
descrtion: '部分墙体漏水', time: '',
photos: [ resientName: ''
'https://picsum.photos/80',
'https://picsum.photos/80',
'https://picsum.photos/80',
'https://picsum.photos/80'
]
},
{
pointName: '巡检点3号',
user: '李相龙',
phone: '1502360831',
time: '2026-10-25 12:10:01',
descrtion: '正常',
photos: [
'https://picsum.photos/80',
'https://picsum.photos/80',
'https://picsum.photos/80',
'https://picsum.photos/80'
]
} }
]) })
return {
routeName: item.routeName,
routeId: item.routeId,
description: item.description,
points: points
}
})
.filter(item => item !== false)
baseFormData.value = result
console.log(result)
})
.catch(err => {
uni.showToast({
icon: 'error',
title: '网络异常'
})
})
}
onLoad(options => {
taskid.value = options.id
init()
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@@ -237,7 +254,9 @@ const result = ref([
} }
.linedash { .linedash {
width: 100%; width: 100%;
border: 2rpx dashed #ccc; height: 0;
border: 1rpx dashed #ccc;
margin: 40rpx 0;
} }
} }
} }

View File

@@ -3,42 +3,52 @@
<view class="page_padding"> <view class="page_padding">
<view class="inspection_record_box flex-1 flex flex-col"> <view class="inspection_record_box flex-1 flex flex-col">
<navBar @clickLeft="navBack" title="巡检记录"></navBar> <navBar @clickLeft="navBack" title="巡检记录"></navBar>
<TabsComponents :tabslist="tabslist" @update="handleChangeTabs"></TabsComponents> <TabsComponents :tabslist="tabslist" @update="handleChangeTabs"></TabsComponents>
<view class="timebox">
<view class="daybox flex items-center">
<uni-datetime-picker
type="date"
:clear-icon="false"
@change="handleChangeTime"
v-model="queryParmas.date"
>
<view class="day">{{ showDate }}</view>
</uni-datetime-picker>
<view class="searchiconbox flex items-center">
<view class="arrow"> </view>
<view class="arrow1"> </view>
</view>
</view>
</view>
<scroll-view <scroll-view
class="record_body record-list" class="record_body record-list"
scroll-y scroll-y
lower-threshold="60" lower-threshold="160"
@scrolltolower="scrolltolower" @scrolltolower="scrolltolower"
> >
<!-- v-for --> <view
<view class="record_item" v-for="(item, index) in list" :key="index"> class="record_list_item"
<view class="time"> v-for="(ite, index) in list"
<view>{{ item.day }}</view> :key="index"
</view> @tap="handleTap(ite)"
<view class="record_list_box"> >
<!-- v-for -->
<view class="record_list_item" v-for="(ite, ind) in item.list" :key="ind">
<view class="title flex items-center"> <view class="title flex items-center">
<view class="title_name"> {{ ite.title }} </view> <view class="title_name"> {{ ite.taskName }} </view>
<view class="title_status" v-if="ite.status === 0"> 已巡检 </view> <view class="title_status" v-if="isComputed(ite.taskStatus)"> 已巡检 </view>
<view class="title_status noinspection" v-else> 未巡检 </view> <view class="title_status noinspection" v-else> 未巡检 </view>
</view> </view>
<view class="items"> <view class="items" v-if="ite.points">
<!-- v-for --> <view class="item" v-for="(itemname, itemindex) in ite.itemslist" :key="itemindex">
<view class="item" v-for="(it, inde) in ite.items" :key="inde"> <text>{{ itemname }}</text>
<text>{{ it }}</text>
</view> </view>
</view> </view>
<view class="time"> <view class="time">
<text>巡检时间:</text> <text>巡检时间:</text>
<text>{{ ite.time }}</text> <text>{{ ite.taskTime }}</text>
</view> </view>
<view class="time user"> <view class="time user">
<text>巡检人:</text> <text>巡检人:</text>
<text>{{ ite.user }}</text> <text>{{ ite.inspectorName }}</text>
</view>
</view>
</view> </view>
</view> </view>
</scroll-view> </scroll-view>
@@ -49,62 +59,48 @@
<script setup lang="ts"> <script setup lang="ts">
import TabsComponents from '@/components/tabs/tabs.vue' import TabsComponents from '@/components/tabs/tabs.vue'
import navBar from '@/components/navbar/navbar.vue' import navBar from '@/components/navbar/navbar.vue'
import { ref } from 'vue' import { computed, ref } from 'vue'
import { getInspectionList } from '@/api/insepction.js'
import { parseTime } from '@/utils/time.js'
import { onShow } from '@dcloudio/uni-app'
const isComputed = (status: string) => {
const awaitlist = ['未完成', '待执行', '执行中']
return !awaitlist.includes(status)
}
const tabslist = [ const tabslist = [
{ {
name: '全部', name: '全部',
value: 0 value: 2
}, },
{ {
name: '未巡检', name: '未巡检',
value: 1 value: 0
}, },
{ {
name: ' 已巡检', name: ' 已巡检',
value: 2 value: 1
} }
] ]
function handleChangeTabs(val: number) {}
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
const list = ref([ const list = ref([])
{
day: '10月11日',
list: [
{
title: '标题1',
status: 0,
items: ['设备巡检'],
time: '07:00:00-09:00:00',
user: '李兴'
},
{
title: '标题3',
status: 0,
items: ['设备巡检'],
time: '07:00:00-09:00:00',
user: '湖色'
}
]
}
])
const queryParmas = ref({ const queryParmas = ref({
date: '',
status: 2,
pageNum: 1, pageNum: 1,
pageSize: 5 pageSize: 10
})
const showDate = computed(() => {
return parseTime(queryParmas.value.date, '{m}月{d}日')
}) })
const isLoading = ref(false) // 加载锁 const isLoading = ref(false) // 加载锁
const hasMore = ref(true) // 是否还有更多数据 const hasMore = ref(true) // 是否还有更多数据
const total = ref(21) const total = ref(0)
function scrolltolower() {
// 必须加这两个判断!
if (isLoading.value || !hasMore.value) {
return
}
queryParmas.value.pageNum += 1
getlist()
}
function getlist() { function getlist() {
// 1. 如果正在加载或没有更多数据,直接返回 // 1. 如果正在加载或没有更多数据,直接返回
if (isLoading.value || !hasMore.value) return if (isLoading.value || !hasMore.value) return
@@ -114,51 +110,76 @@ function getlist() {
title: '加载中', title: '加载中',
mask: true mask: true
}) })
const { pageNum, pageSize } = queryParmas.value const { pageNum, pageSize, date } = queryParmas.value
getInspectionList({
const startId = (pageNum - 1) * pageSize + 1 pageSize,
const arr = Array.from({ length: pageSize }).map((_, index) => { pageNum,
const realId = startId + index // ✅ 修复 ID 错误 date
// ✅ 随机生成 0、1、2
const randomStatus = Math.floor(Math.random() * 2)
return {
day: '10月' + realId + '日',
list: [
{
title: '标题1',
status: randomStatus,
items: ['设备巡检'],
time: '07:00:00-09:00:00',
user: '李兴'
},
{
title: '标题3',
status: randomStatus,
items: ['设备巡检'],
time: '07:00:00-09:00:00',
user: '湖色'
}
]
}
}) })
.then(res => {
// 追加数据(正确方式) list.value = res.rows
list.value = [...list.value, ...arr] let items: Set<string> = new Set()
// 判断是否还有更多 res.rows.forEach(item => {
hasMore.value = list.value.length < total.value if (!item.points || item.points.length <= 0) return
item.points.forEach(ite => {
ite.itemNames.forEach(it => items.add(it))
})
item.itemslist = Array.from(items)
console.log(item.itemslist)
})
hasMore.value = list.value.length < res.total
total.value = res.total
})
.finally(() => {
isLoading.value = false isLoading.value = false
uni.hideLoading() uni.hideLoading()
})
} }
getlist()
function resetList() { function handleChangeTime(event: string) {
list.value = []
queryParmas.value.pageNum = 1
hasMore.value = true hasMore.value = true
queryParmas.value.date = event
getlist()
}
function handleTap(ite) {
if (isComputed(ite.taskStatus)) {
uni.navigateTo({
url: '/pageSubPack/inspection/inspection_main?id=' + ite.id
})
} else {
uni.navigateTo({
url: '/pageSubPack/inspection/inspection_upload?id=' + ite.id
})
}
}
function scrolltolower() {
if (isLoading.value || !hasMore.value) {
return
}
queryParmas.value.pageNum += 1
getlist()
}
function handleChangeTabs(val: number) {
queryParmas.value.status = val
queryParmas.value.pageNum = 1
queryParmas.value.pageSize = 10
getlist() getlist()
} }
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
function init() {
queryParmas.value.date = parseTime(new Date(), '{y}-{m}-{d}')
getlist()
}
onShow(() => {
hasMore.value = true
console.log('show')
init()
})
// 返回上一页 // 返回上一页
const navBack = () => { const navBack = () => {
uni.navigateBack() uni.navigateBack()
@@ -174,15 +195,8 @@ const navBack = () => {
height: 100vh; height: 100vh;
overflow: hidden; overflow: hidden;
box-sizing: border-box; box-sizing: border-box;
.record_body { .timebox {
margin-top: 20rpx; width: 178rpx;
flex: 1;
overflow: hidden;
overflow-y: auto;
box-sizing: border-box;
.record_item {
& > .time {
width: 168rpx;
height: 48rpx; height: 48rpx;
background: #ffffff; background: #ffffff;
border-radius: 24rpx; border-radius: 24rpx;
@@ -191,11 +205,50 @@ const navBack = () => {
font-weight: 400; font-weight: 400;
font-size: 28rpx; font-size: 28rpx;
color: #666666; color: #666666;
margin-bottom: 20rpx; margin-bottom: 20rpx;
margin-top: 20rpx;
.daybox {
height: 100%;
box-sizing: border-box;
position: relative;
.day {
flex: 1;
font-size: 28rpx;
text-align: left;
padding-left: 15rpx;
} }
.record_list_box { .searchiconbox {
margin-bottom: 20rpx; width: 38rpx;
height: 48rpx;
padding-right: 10rpx;
flex-direction: column;
justify-content: center;
.arrow,
.arrow1 {
border: 1rpx solid #ccc;
width: 8rpx;
height: 8rpx;
}
.arrow {
border-right-color: transparent;
border-top-color: transparent;
transform: rotateZ(135deg);
}
.arrow1 {
border-left-color: transparent;
border-bottom-color: transparent;
transform: rotateZ(135deg);
}
}
}
}
.record_body {
flex: 1;
overflow: hidden;
overflow-y: auto;
box-sizing: border-box;
.record_list_item { .record_list_item {
margin-bottom: 20rpx; margin-bottom: 20rpx;
background: #ffffff; background: #ffffff;
@@ -259,7 +312,5 @@ const navBack = () => {
} }
} }
} }
}
}
} }
</style> </style>

View File

@@ -5,16 +5,16 @@
<view class="inspection_title flex flex-between"> <view class="inspection_title flex flex-between">
<view class="title flex"> <view class="title flex">
<text class="line"></text> <text class="line"></text>
<text>幸福苑小区- B1层地下车库</text> <text>{{ info.villageName }} - {{ info.taskName }}</text>
</view> </view>
<view class="status"> <view class="status" v-if="!isComputed">
<text>未巡检</text> <text>未巡检</text>
</view> </view>
</view> </view>
<view class="inspection_item_info_box"> <view class="inspection_item_info_box">
<view class="inspection_item"> <view class="inspection_item">
<text>巡检项目:</text> <text>巡检项目:</text>
<text>设备巡检</text> <text>{{ info.planName }}</text>
</view> </view>
<view class="inspection_item"> <view class="inspection_item">
<text>巡检时间:</text> <text>巡检时间:</text>
@@ -22,74 +22,59 @@
</view> </view>
<view class="inspection_item"> <view class="inspection_item">
<text>巡检小区:</text> <text>巡检小区:</text>
<text>幸福苑小区</text> <text>{{ info.villageName }}</text>
</view> </view>
<view class="" v-for="(item, index) in baseFormData" :key="index">
<view class="inspection_item"> <view class="inspection_item">
<text>巡检路线:</text> <text>巡检路线:</text>
<text>常规巡检路线1</text> <text>{{ item.routeName }}</text>
</view> </view>
<view class="inspection_item"> <view class="inspection_item">
<text>巡检点:</text> <text>巡检点:</text>
<text>安全巡检点1;</text> <text v-for="(ite, ind) in item.points" :key="ind">{{ ite.ponitName }};</text>
<text>安全巡检点2;</text>
<text>安全巡检点3;</text>
<text>安全巡检点4;</text>
</view> </view>
</view> </view>
</view> </view>
<view class="inspection_info_upload_box"> </view>
<view class="header"> <text>巡检结果</text> </view> <view class="inspection_info_upload_box" v-if="baseFormData.length > 0">
<view class="info_body" :key="index" v-for="(item, index) in baseFormData"> <view class="inspection_routes" v-for="(item, index) in baseFormData" :key="index">
<view class="info_title" style="margin-bottom: 20rpx"> {{ item.name }} </view> <view class="header">
<uni-forms :modelValue="item" :rules="rules" label-position="left" label-width="150"> <text>{{ item.routeName }} - 巡检结果</text>
</view>
<view class="info_body" v-for="(ite, ind) in item.points" :key="ind">
<view class="info_title" style="margin-bottom: 20rpx"> {{ ite.ponitName }} </view>
<uni-forms :modelValue="ite" :rules="rules" label-position="left" label-width="150">
<uni-forms-item label="巡检状态" required> <uni-forms-item label="巡检状态" required>
<uni-data-checkbox <uni-data-checkbox
:disabled="item.complated" :disabled="ite.complated"
v-model="item.status" v-model="ite.status"
:localdata="statuslist" :localdata="statuslist"
/> />
</uni-forms-item> </uni-forms-item>
<uni-forms-item label="巡检描述"> <uni-forms-item label="巡检描述" v-if="!ite.complated">
<uni-easyinput <uni-easyinput
type="textarea" type="textarea"
:disabled="item.complated" :disabled="ite.complated"
:input-border="true" :input-border="true"
v-model="item.desition" v-model="ite.desition"
placeholder="请输入" placeholder="请输入"
></uni-easyinput> ></uni-easyinput>
</uni-forms-item> </uni-forms-item>
<uni-forms-item label="巡检时间"> <view class="items_picker_box flex" style="align-items: baseline" v-else>
<uni-datetime-picker <view class="label"> 巡检描述 </view>
type="datetime" <view class="desitionbox flex-1">
:disabled="item.complated" <text class="desition">{{ ite.desition }}</text>
return-type="timestamp" </view>
v-model="item.datetimesingle"
/>
</uni-forms-item>
<!-- <uni-forms-item label="巡检照片">
<uni-file-picker
@delete="deleteFile"
@select="select"
mode="grid"
v-model="item.files"
:auto-upload="false"
:sourceType="['camera']"
file-mediatype="image"
>
<view class="filePicker flex-center">
<uni-icons color="#a6a6a6" type="plusempty" size="25"> </uni-icons>
</view> </view>
</uni-file-picker>
</uni-forms-item> -->
<view class="items_picker_box"> <view class="items_picker_box">
<view class="label"> 巡检照片 </view> <view class="label"> 巡检照片 </view>
<view class="filePickerbox" v-if="!item.complated"> <view class="filePickerbox" v-if="!ite.complated">
<filePicker <filePicker
v-model="item.files" v-model="ite.files"
:sourceType="['camera']" :sourceType="['camera']"
file-field-name="file" file-field-name="file"
:extra-data="uploadParams" :extra-data="uploadParams"
@success="onUploadSuccess" uploadUrl="/resource/oss/upload"
@fail="onUploadFail" @fail="onUploadFail"
></filePicker> ></filePicker>
</view> </view>
@@ -97,31 +82,32 @@
<image <image
class="img" class="img"
mode="scaleToFill" mode="scaleToFill"
v-for="(ite, ind) in item.files" v-for="(ite, ind) in ite.files"
lazy-load lazy-load
:key="ind" :key="ind"
:src="ite" :src="ite"
@tap="previewImages(item.files, index)" @tap="previewImages(ite.files, index)"
></image> ></image>
</view> </view>
</view> </view>
</uni-forms> </uni-forms>
<view class="submitbox" @tap="handleSubmit(item.id)"> <view class="submitbox" @tap="handleSubmit(ite)" v-if="!ite.complated">
<text>提交</text> <text>提交</text>
</view> </view>
<view class="line" v-if="index + 1 !== baseFormData.length"> </view> <view class="line" v-if="ind + 1 === baseFormData.length"> </view>
</view>
</view> </view>
<!-- <view class="submitbox">
<text>提交</text>
</view> -->
</view> </view>
</view> </view>
</view> </view>
</template> </template>
<script setup> <script setup>
import { ref } from 'vue' import { computed, ref } from 'vue'
import filePicker from '@/components/filePicker/filePicker.vue' import filePicker from '@/components/filePicker/filePicker.vue'
import { getInspectionMain } from '@/api/insepction.js'
import { onLoad } from '@dcloudio/uni-app'
import { putInsepctionPoint } from '@/api/insepction.js'
const statuslist = [ const statuslist = [
{ {
@@ -133,27 +119,16 @@ const statuslist = [
value: 1 value: 1
} }
] ]
const taskid = ref('')
const baseFormData = ref([]) const baseFormData = ref([])
const info = ref({ const info = ref({
point: Array.from({ length: 4 }).map((_, index) => { planName: '',
let obj1 = { remindTime: '',
name: `巡检点${index + 1}`, routes: [],
id: index + '' taskId: '',
} taskName: '',
let obj = { taskTime: '',
id: index, villageName: ''
name: obj1.name,
desition: '', // 描述
datetimesingle: '', // 时间
status: 0, // 状态 0正常1异常
files: [], // 图片
complated: false, // 巡检点完成检查
fileUrls: '' // 图片
}
baseFormData.value.push(obj)
return obj1
})
}) })
const rules = { const rules = {
status: { status: {
@@ -166,36 +141,86 @@ const rules = {
} }
} }
// ---------------------------------------------- function init() {
const uploadParams = ref({ if (!taskid.value) return
type: 'repair', // 上传类型:报修 getInspectionMain(taskid.value)
businessId: '123456', // 关联业务ID .then(res => {
userId: '789' // 用户ID info.value = res.data
if (!res.data.routes) return
let result = res.data.routes
.map(item => {
if (!item.points || item.points.length <= 0) return false
const points = item.points.map(ite => {
return {
pointId: ite.pointId,
ponitName: ite.pointName,
status: ite.status ?? 0,
desition: ite.remark,
complated: ite.status !== null,
files: ite.imgUrl ? ite.imgUrl.split(',') : []
}
})
return {
routeName: item.routeName,
routeId: item.routeId,
description: item.description,
points: points
}
})
.filter(item => item !== false)
baseFormData.value = result
console.log(result)
console.log(isComputed.value)
})
.catch(err => {
uni.showToast({
icon: 'error',
title: '网络异常'
})
})
}
onLoad(options => {
taskid.value = options.id
// taskid.value = '2044684785371725826'
init()
}) })
// 选择文件 // ----------------------------------------------
function onUploadSuccess(e) { const uploadParams = ref({})
console.log('上传成功', e)
}
function onUploadFail(e) { function onUploadFail(e) {
console.log('上传失败', e) console.log('上传失败', e)
} }
function submit() {
console.log('最终要提交的图片URL', imageList.value)
// 这里调用你的提交接口
}
/** 提交巡检点 检查情况 */ /** 提交巡检点 检查情况 */
function handleSubmit(id) { function handleSubmit(item) {
console.log(typeof id, id, baseFormData.value) console.log(item, baseFormData.value)
const find = baseFormData.value.find(item => item.id === id) let obj = {
if (find) { pointId: item.pointId,
find.complated = true imgUrl: item.files.length > 0 ? item.files.join(',') : '',
remark: item.desition,
status: item.status,
taskId: taskid.value
} }
console.log(obj)
putInsepctionPoint(obj)
.then(res => {
item.complated = true
console.log(isComputed.value)
console.log(res)
})
.catch(err => {
console.log(err)
})
} }
const isComputed = computed(() => {
// 遍历每一项
return baseFormData.value.every(item => {
// 每一项里的所有 points 都必须是已完成
return item.points.every(point => point.complated)
})
})
/** /**
* 预览图片 * 预览图片
* @param {Array} images - 所有图片的URL数组 * @param {Array} images - 所有图片的URL数组
@@ -279,12 +304,22 @@ function previewImages(images, currentIndex) {
} }
.info_body { .info_body {
margin-bottom: 40rpx; margin-bottom: 40rpx;
.desitionbox {
.desition {
font-size: small;
color: #ccc;
line-height: 1;
letter-spacing: 1px;
}
}
} }
.info_title { .info_title {
font-weight: 550; font-weight: 550;
} }
.line { .line {
width: 100%; width: 100%;
margin-top: 40rpx;
margin-bottom: 40rpx;
border: 1rpx dashed #ccc; border: 1rpx dashed #ccc;
} }
.items_picker_box { .items_picker_box {
@@ -320,7 +355,6 @@ function previewImages(images, currentIndex) {
color: #ffffff; color: #ffffff;
line-height: 80rpx; line-height: 80rpx;
margin-top: 40rpx; margin-top: 40rpx;
margin-bottom: 40rpx;
} }
} }
</style> </style>

View File

@@ -46,6 +46,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, computed } from 'vue' import { ref, computed } from 'vue'
import TabsComponents from '@/components/tabs/tabs.vue' import TabsComponents from '@/components/tabs/tabs.vue'
import { onShow } from '@dcloudio/uni-app'
// tabs ========================================================= // tabs =========================================================
const activeValue = ref(0) const activeValue = ref(0)
const tabslist = ref([ const tabslist = ref([
@@ -125,6 +126,12 @@ const list = ref([
status: 1 // 0未巡检 1已巡检 status: 1 // 0未巡检 1已巡检
} }
]) ])
function getInspectionList() {
getInspectionList()
}
onShow(() => getInspectionList())
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

View File

@@ -2,7 +2,7 @@
<view class="page_container addreplacement_box"> <view class="page_container addreplacement_box">
<uni-forms border :modelValue="formData" label-position="left"> <uni-forms border :modelValue="formData" label-position="left">
<uni-forms-item label="仪表类型"> <uni-forms-item label="仪表类型">
<uni-data-checkbox v-model="formData.type" :localdata="items"></uni-data-checkbox> <uni-data-checkbox v-model="formData.deviceType" :localdata="items"></uni-data-checkbox>
</uni-forms-item> </uni-forms-item>
<uni-forms-item label="设备编号"> <uni-forms-item label="设备编号">
<view class="flex items-center justify-between"> <view class="flex items-center justify-between">
@@ -14,7 +14,13 @@
:clearable="true" :clearable="true"
> >
</uni-easyinput> </uni-easyinput>
<uni-icons @tap="handleScan" size="48rpx" type="scan" color="#737373"></uni-icons> <uni-icons
class="scanicons"
@tap="handleScan"
size="48rpx"
type="scan"
color="#737373"
></uni-icons>
</view> </view>
</uni-forms-item> </uni-forms-item>
<uni-forms-item label="房屋号"> <uni-forms-item label="房屋号">
@@ -42,19 +48,22 @@
<script setup> <script setup>
import { ref } from 'vue' import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app' import { onLoad } from '@dcloudio/uni-app'
import { AddReplaceMainList } from '@/api/instrument.js'
const formData = ref({ const formData = ref({
type: 1, deviceType: 2,
deviceCode: '', deviceCode: '',
houseId: '' houseId: ''
}) })
// 水表,电表列表
const items = [ const items = [
{ {
text: '水表', text: '水表',
value: 1 value: 2
}, },
{ {
text: '电表', text: '电表',
value: 2 value: 1
} }
] ]
@@ -74,15 +83,51 @@ function handleClick() {
} }
/** 处理 扫码 */ /** 处理 扫码 */
function handleScan() { function handleScan() {
// 允许从相机和相册扫码
uni.scanCode({ uni.scanCode({
success: function (res) { success: function (res) {
formData.value.deviceCode = res.result formData.value.deviceCode = res.result
},
error: err => {
uni.showToast({
icon: 'error',
title: '扫描异常'
})
} }
}) })
} }
function handleSubmit() {} function handleSubmit() {
formData.value.deviceCode = formData.value.deviceCode.trim()
formData.value.houseId = formData.value.houseId.trim()
if (!formData.value.deviceCode.trim()) {
uni.showToast({
icon: 'exception',
title: '检查设备编号'
})
}
if (!formData.value.houseId.trim()) {
uni.showToast({
icon: 'exception',
title: '选择房屋'
})
}
AddReplaceMainList(formData.value)
.then(() => {
uni.showToast({
icon: 'success',
title: '操作成功',
success() {
uni.navigateBack()
}
})
})
.catch(err => {
uni.showToast({
icon: 'error',
title: '检查编号'
})
})
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@@ -116,5 +161,9 @@ function handleSubmit() {}
color: #ffffff; color: #ffffff;
line-height: 80rpx; line-height: 80rpx;
} }
.scanicons {
margin-left: 20rpx;
}
} }
</style> </style>

View File

@@ -4,23 +4,25 @@
<view <view
@click="handleClick" @click="handleClick"
class="search_view flex-center" class="search_view flex-center"
v-if="!queryParmas.keyword.trim() && Searching" v-if="!queryParmas.searchValue.trim() && Searching"
> >
<uni-icons type="search" size="34rpx" color="rgba(0,0,0,0.26)"></uni-icons> <uni-icons type="search" size="34rpx" color="rgba(0,0,0,0.26)"></uni-icons>
<text>请输入关键字进行搜索</text> <text>请输入关键字进行搜索</text>
</view> </view>
<uni-easyinput <uni-easyinput
@blur="handleInput" @blur="handleInput"
@change="handleSearch" @clear="handleInput"
@confirm="handleSearch"
@input="handleInputString"
:focus="true" :focus="true"
ref="inputRef" ref="inputRef"
v-model="queryParmas.keyword" v-model="queryParmas.searchValue"
v-else v-else
/> />
</view> </view>
<view class="search_list flex-1 flex"> <view class="search_list flex-1 flex">
<scroll-view lower-threshold="160" scroll-y="true" @scrolltolower="scrolltolower"> <scroll-view lower-threshold="160" scroll-y="true" @scrolltolower="scrolltolower">
<radio-group @change="radioChange"> <radio-group @change="radioChange" v-if="searchlist.length > 0">
<label v-for="(item, index) in searchlist" :key="index"> <label v-for="(item, index) in searchlist" :key="index">
<view <view
class="search_item flex flex-between" class="search_item flex flex-between"
@@ -39,6 +41,9 @@
</view> </view>
</label> </label>
</radio-group> </radio-group>
<view class="noData" v-else>
<text>暂无数据</text>
</view>
</scroll-view> </scroll-view>
</view> </view>
@@ -54,18 +59,31 @@ import { getVillageHouseList_keyword } from '@/api/common.js'
const Searching = ref(true) const Searching = ref(true)
const queryParmas = ref({ const queryParmas = ref({
keyword: '', searchValue: '',
pageNum: 1, pageNum: 1,
pageSize: 10 pageSize: 10
}) })
/** 点击时切换到input,并聚焦 */ /** 点击时切换到input,并聚焦 */
function handleClick() { function handleClick() {
Searching.value = false Searching.value = false
queryParmas.value.searchValue = ''
} }
/** 判断 失去焦点时 切换回 view */ /** 判断 失去焦点时 切换回 view */
function handleInput() { function handleInput() {
if (queryParmas.value.keyword.trim()) { const value = queryParmas.value.searchValue.trim()
if (value) {
handleSearch()
} else if (value === '') {
queryParmas.value.searchValue = ''
Searching.value = true Searching.value = true
handleSearch()
}
}
function handleInputString() {
if (queryParmas.value.searchValue.trim() === '') {
queryParmas.value.searchValue = ''
Searching.value = true
handleSearch()
} }
} }
@@ -102,13 +120,20 @@ function getlist() {
title: '加载中', title: '加载中',
mask: true mask: true
}) })
getVillageHouseList_keyword(queryParmas.value, queryParmas.value.keyword) getVillageHouseList_keyword(queryParmas.value, queryParmas.value.searchValue)
.then(res => { .then(res => {
// 追加数据(正确方式) // 追加数据(正确方式)
searchlist.value = [...searchlist.value, ...res.rows] searchlist.value = [...searchlist.value, ...res.rows]
total.value = res.total
// 判断是否还有更多 // 判断是否还有更多
hasMore.value = searchlist.value.length < total.value hasMore.value = searchlist.value.length < total.value
}) })
.catch(() => {
uni.showToast({
icon: 'error',
title: '网络异常'
})
})
.finally(() => { .finally(() => {
isLoading.value = false isLoading.value = false
uni.hideLoading() uni.hideLoading()
@@ -126,6 +151,7 @@ function resetList() {
// Search // Search
function handleSearch() { function handleSearch() {
hasMore.value = true
queryParmas.value.pageNum = 1 queryParmas.value.pageNum = 1
queryParmas.value.pageSize = 10 queryParmas.value.pageSize = 10
searchlist.value = [] searchlist.value = []
@@ -211,6 +237,13 @@ function handleSelecthouse() {
} }
} }
} }
.noData {
text-align: center;
color: rgba(0, 0, 0, 0.26);
font-size: larger;
padding-top: 50rpx;
letter-spacing: 10rpx;
}
.action_btn { .action_btn {
width: 670rpx; width: 670rpx;

View File

@@ -17,16 +17,16 @@
<image lazy-load src="/static/imgs/home.png" class="icon" mode=""></image> <image lazy-load src="/static/imgs/home.png" class="icon" mode=""></image>
<view class="instrument_info"> <view class="instrument_info">
<view class="instrument_title"> <view class="instrument_title">
<text>{{ item.title }}</text> <text>{{ item.addressCn }}</text>
</view> </view>
<view class="instrument_time"> <view class="instrument_time">
<text>换新时间时间:{{ item.time }}</text> <text>换新时间时间:{{ item.createTime }}</text>
</view> </view>
</view> </view>
</view> </view>
<view class="instrument_type"> <view class="instrument_type">
<text v-if="item.type === 2">电表</text> <text v-if="item.deviceType === '1'">电表</text>
<text v-else>水表</text> <text v-else-if="item.deviceType === '2'">水表</text>
</view> </view>
</view> </view>
<!-- 底部加载状态提示 --> <!-- 底部加载状态提示 -->
@@ -42,7 +42,10 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed, nextTick, ref } from 'vue' import { computed, nextTick, ref } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import TabsComponents from '@/components/tabs/tabs.vue' import TabsComponents from '@/components/tabs/tabs.vue'
import { getReplaceMainList } from '@/api/instrument.js'
/** 加载状态 */ /** 加载状态 */
const statusmore = computed(() => { const statusmore = computed(() => {
if (isLoading.value === true) { if (isLoading.value === true) {
@@ -65,25 +68,35 @@ const tabslist = [
}, },
{ {
name: '水表', name: '水表',
value: 1 value: 2
}, },
{ {
name: '电表', name: '电表',
value: 2 value: 1
} }
] ]
// 切换tabs
function handleChangeTabs(val: number) { function handleChangeTabs(val: number) {
queryParmas.value.deviceType = val
if (val === 0) {
queryParmas.value.deviceType = undefined
}
queryParmas.value.pageNum = 1 queryParmas.value.pageNum = 1
infolist.value = [] infolist.value = []
hasMore.value = true
getlist() getlist()
} }
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
const infolist = ref([]) const infolist = ref([])
const queryParmas = ref({ const queryParmas = ref({
pageNum: 1, pageNum: 1,
pageSize: 10 pageSize: 10,
deviceType: undefined
}) })
const total = ref(21) // 总数
const total = ref(0)
// 上滑加载
function scrolltolower() { function scrolltolower() {
// 必须加这两个判断! // 必须加这两个判断!
if (isLoading.value || !hasMore.value) { if (isLoading.value || !hasMore.value) {
@@ -92,6 +105,7 @@ function scrolltolower() {
queryParmas.value.pageNum += 1 queryParmas.value.pageNum += 1
getlist() getlist()
} }
function getlist() { function getlist() {
// 1. 如果正在加载或没有更多数据,直接返回 // 1. 如果正在加载或没有更多数据,直接返回
if (isLoading.value || !hasMore.value) return if (isLoading.value || !hasMore.value) return
@@ -101,29 +115,29 @@ function getlist() {
title: '加载中', title: '加载中',
mask: true mask: true
}) })
const { pageNum, pageSize } = queryParmas.value const { pageNum, pageSize, deviceType } = queryParmas.value
getReplaceMainList({
const startId = (pageNum - 1) * pageSize + 1 pageNum,
const arr = Array.from({ length: pageSize }).map((_, index) => { pageSize,
const realId = startId + index // ✅ 修复 ID 错误 deviceType
// ✅ 随机生成 0、1、2
const randomStatus = Math.floor(Math.random() * 2)
return {
title: 'M2栋3单元18' + realId + '室(M2-3-1801)',
time: '2023-08-01 10:05:46',
type: randomStatus //1水表 2电表
}
}) })
.then(res => {
// 追加数据(正确方式) infolist.value = [...infolist.value, ...res.rows]
infolist.value = [...infolist.value, ...arr] total.value = res.total
// 判断是否还有更多
hasMore.value = infolist.value.length < total.value hasMore.value = infolist.value.length < total.value
})
.finally(() => {
isLoading.value = false isLoading.value = false
uni.hideLoading() uni.hideLoading()
})
} }
getlist() onShow(() => {
infolist.value = []
hasMore.value = true
getlist()
})
// 重置
function resetList() { function resetList() {
infolist.value = [] infolist.value = []
queryParmas.value.pageNum = 1 queryParmas.value.pageNum = 1
@@ -131,6 +145,7 @@ function resetList() {
getlist() getlist()
} }
// 跳转到 仪表换新
function handleClick() { function handleClick() {
uni.navigateTo({ uni.navigateTo({
url: '/pageSubPack/instrument/addreplacement' url: '/pageSubPack/instrument/addreplacement'

View File

@@ -74,7 +74,7 @@
"enablePullDownRefresh": true, "enablePullDownRefresh": true,
"onReachBottomDistance": 100 "onReachBottomDistance": 100
} }
}, }
] ]
}, },
{ {

View File

@@ -0,0 +1,46 @@
/**
* 日期格式化
*/
export function parseTime(time, pattern) {
if (arguments.length === 0 || !time) {
return null;
}
const format = pattern || '{y}-{m}-{d} {h}:{i}:{s}';
let date;
if (typeof time === 'object') {
date = time;
} else {
if (typeof time === 'string' && /^[0-9]+$/.test(time)) {
time = parseInt(time);
} else if (typeof time === 'string') {
time = time
.replace(new RegExp(/-/gm), '/')
.replace('T', ' ')
.replace(new RegExp(/\.[\d]{3}/gm), '');
}
if (typeof time === 'number' && time.toString().length === 10) {
time = time * 1000;
}
date = new Date(time);
}
const formatObj = {
y: date.getFullYear(),
m: date.getMonth() + 1,
d: date.getDate(),
h: date.getHours(),
i: date.getMinutes(),
s: date.getSeconds(),
a: date.getDay()
};
return format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
let value = formatObj[key];
// Note: getDay() returns 0 on Sunday
if (key === 'a') {
return ['日', '一', '二', '三', '四', '五', '六'][value];
}
if (result.length > 0 && value < 10) {
value = '0' + value;
}
return value || 0;
});
}