From 78bc420fb8a5c0d7e951439221826ba55f9e3bff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Fri, 27 Jun 2025 18:58:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=B7=B2=E7=9F=A5=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/AugmentWebviewStateStore.xml | 2 +- src/api/hjm/hjmCar/model/index.ts | 4 ++ src/hjm/query.tsx | 10 ++++- src/hjm/violation/list.tsx | 43 +++++++++++++++---- src/pages/index/Header.tsx | 4 +- src/pages/user/components/UserCell.tsx | 58 +++++++------------------- src/user/userVerify/admin.tsx | 30 +++++++------ src/utils/request.ts | 2 +- src/utils/time.ts | 40 +++++++++++++++++- 9 files changed, 124 insertions(+), 69 deletions(-) diff --git a/.idea/AugmentWebviewStateStore.xml b/.idea/AugmentWebviewStateStore.xml index e261587..7d42d65 100644 --- a/.idea/AugmentWebviewStateStore.xml +++ b/.idea/AugmentWebviewStateStore.xml @@ -3,7 +3,7 @@ diff --git a/src/api/hjm/hjmCar/model/index.ts b/src/api/hjm/hjmCar/model/index.ts index a5fe543..79f05f6 100644 --- a/src/api/hjm/hjmCar/model/index.ts +++ b/src/api/hjm/hjmCar/model/index.ts @@ -26,6 +26,8 @@ export interface HjmCar { code?: string; // 安装人员ID installerId?: number; + // 安装时间 + installTime?: string; // 操作员ID driverId?: number; // 操作员 @@ -56,6 +58,8 @@ export interface HjmCar { userId?: number; // 认领状态 claim?: number; + // 认领时间 + claimTime?: string; // 排序(数字越小越靠前) sortNumber?: number; // 备注 diff --git a/src/hjm/query.tsx b/src/hjm/query.tsx index c94bbb4..130f453 100644 --- a/src/hjm/query.tsx +++ b/src/hjm/query.tsx @@ -21,6 +21,7 @@ import {DictData} from "@/api/system/dict-data/model"; import {myUserVerify} from "@/api/system/userVerify"; import {listUserRole} from "@/api/system/userRole"; import {TenantId} from "@/utils/config"; +import {getCurrentDate} from "@/utils/time"; // 图片数据接口 interface UploadedImageData { @@ -129,7 +130,8 @@ const Query = () => { updateHjmCar({ ...FormData, status: 1, - installerId: Taro.getStorageSync('UserId') + installerId: Taro.getStorageSync('UserId'), + installTime: getCurrentDate(), }).then(() => { Taro.showToast({title: `安装成功`, icon: 'success'}) setTimeout(() => { @@ -324,6 +326,7 @@ const Query = () => { updateHjmCar({ ...FormData, claim: 1, + claimTime: getCurrentDate(), driverId: Taro.getStorageSync('UserId'), driverName: Taro.getStorageSync('RealName') }).then(() => { @@ -383,6 +386,11 @@ const Query = () => { if (code) { const carInfo = await getHjmCarByCode(code); if (carInfo) { + // updateHjmCar({ + // ...carInfo, + // claimTime: getCurrentDate(), + // installTime: getCurrentDate() + // }) // 赋值车辆信息 setFormData(carInfo) setKeywords(carInfo.code) diff --git a/src/hjm/violation/list.tsx b/src/hjm/violation/list.tsx index 47e72fc..fea5eb2 100644 --- a/src/hjm/violation/list.tsx +++ b/src/hjm/violation/list.tsx @@ -5,7 +5,8 @@ import { Button, Input, Tag, - Space + Space, + Pagination } from '@nutui/nutui-react-taro' import {Search, Calendar, Truck, File, AddCircle} from '@nutui/icons-react-taro' import Taro from '@tarojs/taro' @@ -21,6 +22,10 @@ const List: React.FC = () => { const [loading, setLoading] = useState(false) const [keywords, setKeywords] = useState('') const [refreshing, setRefreshing] = useState(false) + const [page, setPage] = useState(1) + const [limit, setLimit] = useState(10) + const [total, setTotal] = useState(0) + console.log(refreshing) // 获取状态显示 const getStatusDisplay = (status?: number) => { @@ -37,19 +42,22 @@ const List: React.FC = () => { } const reload = async (showLoading = true) => { + setLimit(10) try { if (showLoading) setLoading(true) setRefreshing(true) - const where = { + const where: any = { keywords: keywords.trim(), + page, + limit, } const roleCode = Taro.getStorageSync('RoleCode'); if(roleCode == 'kuaidi'){ - if(Taro.getStorageSync('OrganizationId') == Taro.getStorageSync('OrganizationParentId')){ + if(Taro.getStorageSync('OrganizationParentId') == 0){ // @ts-ignore - where.organizationParentId = Taro.getStorageSync('OrganizationParentId'); + where.organizationParentId = Taro.getStorageSync('OrganizationId'); }else { // @ts-ignore where.organizationId = Taro.getStorageSync('OrganizationId'); @@ -58,6 +66,7 @@ const List: React.FC = () => { const res = await pageHjmViolation(where) setList(res?.list || []) + setTotal(res?.count || 0) } catch (error) { console.error('获取报险记录失败:', error) Taro.showToast({ @@ -86,7 +95,11 @@ const List: React.FC = () => { useEffect(() => { reload().then() - }, []) + }, [page, limit]) + + const onPageChange = (current: number) => { + setPage(current) + } return ( <> @@ -149,9 +162,6 @@ const List: React.FC = () => { ) : list.length === 0 ? ( - ) : (
@@ -275,6 +285,23 @@ const List: React.FC = () => {
) } + + {/* 分页 */} + {list.length > 0 && ( +
+ +
+ )} ) } diff --git a/src/pages/index/Header.tsx b/src/pages/index/Header.tsx index 5d59507..a0e20c0 100644 --- a/src/pages/index/Header.tsx +++ b/src/pages/index/Header.tsx @@ -29,7 +29,7 @@ const Header = (props: any) => { setStatusBarHeight(res.statusBarHeight) }, }) - getUserInfo().then((data) => { + getUserInfo().then( async (data) => { if (data) { console.log(data.organizationName,'0000') setIsLogin(true); @@ -38,7 +38,7 @@ const Header = (props: any) => { // 机构ID Taro.setStorageSync('OrganizationId',data.organizationId) // 父级机构ID - getOrganization(Number(data.organizationId)).then(res => { + await getOrganization(Number(data.organizationId)).then(res => { Taro.setStorageSync('OrganizationParentId',res.parentId) }) // 所属站点名称 diff --git a/src/pages/user/components/UserCell.tsx b/src/pages/user/components/UserCell.tsx index 270d580..ab3bfdd 100644 --- a/src/pages/user/components/UserCell.tsx +++ b/src/pages/user/components/UserCell.tsx @@ -75,6 +75,22 @@ const UserCell = () => { }} /> + + + + 违章记录 + + } + align="center" + extra={} + onClick={() => { + navTo('/hjm/violation/list', true) + }} + /> + ) } @@ -137,48 +153,6 @@ const UserCell = () => { ) } - { - roleName === 'youzheng' && ( - - - - 违章记录 - - } - align="center" - extra={} - onClick={() => { - navTo('/hjm/violation/list', true) - }} - /> - - ) - } - - { - roleName === 'kuaidi' && ( - - - - 违章记录 - - } - align="center" - extra={} - onClick={() => { - navTo('/hjm/violation/list', true) - }} - /> - - ) - } - {/**/} {/* 管理*/} diff --git a/src/user/userVerify/admin.tsx b/src/user/userVerify/admin.tsx index ebfed90..a99dc87 100644 --- a/src/user/userVerify/admin.tsx +++ b/src/user/userVerify/admin.tsx @@ -11,7 +11,7 @@ import {Search, Calendar, Truck, File} from '@nutui/icons-react-taro' import Taro from '@tarojs/taro' import {UserVerify} from "@/api/system/userVerify/model"; import {pageUserVerify, updateUserVerify} from "@/api/system/userVerify"; -import {listUserRole, updateUserRole} from "@/api/system/userRole"; +import {addUserRole, listUserRole, updateUserRole} from "@/api/system/userRole"; /** @@ -82,19 +82,23 @@ const List: React.FC = () => { const onPass = async (item: UserVerify) => { const role = await listUserRole({roleId: 1701,userId: item.userId}) const userRole = role[0]; - userRole.roleId = 1738; - updateUserRole(userRole).then(() => { - updateUserVerify({ - ...item, - status: 1 - }).then(() => { - Taro.showToast({ - title: '操作成功', - icon: 'success' + // 审核通过 + updateUserVerify({ + ...item, + status: 1 + }).then(() => { + if(userRole){ + updateUserRole({ + ...userRole, + roleId: 1738 + }) + } + Taro.showToast({ + title: '操作成功', + icon: 'success' + }) + reload().then() }) - reload().then() - }) - }) } const onReject = async (item: UserVerify) => { diff --git a/src/utils/request.ts b/src/utils/request.ts index 78d155c..7bbba37 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -4,7 +4,7 @@ import {BaseUrl, TenantId} from "@/utils/config"; let baseUrl = BaseUrl if(process.env.NODE_ENV === 'development'){ - baseUrl = 'http://localhost:9000/api' + // baseUrl = 'http://localhost:9000/api' } export function request(options:any) { const token = Taro.getStorageSync('access_token'); diff --git a/src/utils/time.ts b/src/utils/time.ts index 50687a8..e255130 100644 --- a/src/utils/time.ts +++ b/src/utils/time.ts @@ -16,7 +16,7 @@ export function formatCurrentDate() { /** * 获取当前时分秒 */ -export function formatHhmmss(){ +export function formatHhmmss() { // 创建一个Date对象,表示当前日期和时间 const now = new Date(); // 获取当前的小时 @@ -37,3 +37,41 @@ export function getCurrentHour() { const hour = String(now.getHours()).padStart(2, '0'); return `${String(Number(hour) - 8).padStart(2, '0')}`; } + +/** + * 获取当前日期 格式为 yyyy-mm-dd HH:mm:ss + */ +export function getCurrentDate() { +// 创建一个Date对象,自动设置为当前日期和时间 + const currentDate = new Date(); + +// 获取年份 + const year = currentDate.getFullYear(); + +// 获取月份(注意月份是从0开始计数的) + let month = currentDate.getMonth() + 1; + +// 获取日期 + let day = currentDate.getDate(); + +// 添加前导零(如果月份或日期是一位数,则添加前导零) + // @ts-ignore + month = (month < 10 ? '0' : '') + month; + // @ts-ignore + day = (day < 10 ? '0' : '') + day; + + // 获取当前小时 + const hour = currentDate.getHours(); + // 获取当前分钟 + const minute = currentDate.getMinutes(); + // 获取当前秒数 + const second = currentDate.getSeconds(); + +// 构建日期字符串 + var formattedDate = year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second; + +// 输出格式化的日期 + console.log(formattedDate); + return formattedDate; +} +