From a4130940c0be59e7af71e890436857cc66325b8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Mon, 23 Jun 2025 21:40:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=EF=BC=9A=E9=BB=84=E5=AE=B6?= =?UTF-8?q?=E6=98=8E=E9=A1=B9=E7=9B=AE=E7=9A=84=E5=BC=80=E5=8F=91=E5=B9=B6?= =?UTF-8?q?=E5=AD=98=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/AugmentWebviewStateStore.xml | 10 + .idea/modules.xml | 8 + .idea/template-10519.iml | 12 + src/api/hjm/hjmCar/model/index.ts | 2 + src/api/system/company/model/index.ts | 10 +- src/api/system/companyGit/index.ts | 2 +- src/api/system/companyParameter/index.ts | 2 +- .../system/companyParameter/model/index.ts | 2 +- src/api/system/organization/index.ts | 4 +- src/api/system/organization/model/index.ts | 4 +- src/api/system/userRole/index.ts | 14 + src/api/system/userRole/model/index.ts | 1 + src/api/system/userVerify/model/index.ts | 7 + src/app.ts | 4 +- src/hjm/BestSellers.tsx | 5 + src/hjm/fence.tsx | 216 ++++++---- src/hjm/list.tsx | 7 + src/hjm/query.tsx | 16 +- src/pages/index/ExpirationTime.tsx | 10 + src/pages/index/Header.tsx | 1 + src/pages/index/index.tsx | 4 + src/pages/user/components/UserCard.tsx | 13 +- src/pages/user/components/UserCell.tsx | 3 +- src/user/userVerify/admin.tsx | 91 ++++- src/user/userVerify/index.tsx | 378 ++++++++++-------- 25 files changed, 551 insertions(+), 275 deletions(-) create mode 100644 .idea/AugmentWebviewStateStore.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/template-10519.iml diff --git a/.idea/AugmentWebviewStateStore.xml b/.idea/AugmentWebviewStateStore.xml new file mode 100644 index 0000000..66245e6 --- /dev/null +++ b/.idea/AugmentWebviewStateStore.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..fe79e52 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/template-10519.iml b/.idea/template-10519.iml new file mode 100644 index 0000000..24643cc --- /dev/null +++ b/.idea/template-10519.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/src/api/hjm/hjmCar/model/index.ts b/src/api/hjm/hjmCar/model/index.ts index 6648a25..a5fe543 100644 --- a/src/api/hjm/hjmCar/model/index.ts +++ b/src/api/hjm/hjmCar/model/index.ts @@ -24,6 +24,8 @@ export interface HjmCar { parentOrganizationAdmin?: string; // 车辆编号 code?: string; + // 安装人员ID + installerId?: number; // 操作员ID driverId?: number; // 操作员 diff --git a/src/api/system/company/model/index.ts b/src/api/system/company/model/index.ts index c804858..ebc780f 100644 --- a/src/api/system/company/model/index.ts +++ b/src/api/system/company/model/index.ts @@ -1,7 +1,7 @@ -import type { PageParam } from '@/api'; -import type {CompanyParameter} from "~/api/system/companyParameter/model"; -import type {CompanyUrl} from "~/api/system/companyUrl/model"; -import type {CompanyGit} from "~/api/system/companyGit/model"; +import type { PageParam } from '@/api/index'; +import type {CompanyParameter} from "@/api/system/companyParameter/model"; +import type {CompanyUrl} from "@/api/system/companyUrl/model"; +import type {CompanyGit} from "@/api/system/companyGit/model"; /** * 企业信息 @@ -101,7 +101,7 @@ export interface Company { */ export interface CompanyParam extends PageParam { companyId?: number; - type?: number; + type?: any; official?: boolean; shortName?: string; companyName?: string; diff --git a/src/api/system/companyGit/index.ts b/src/api/system/companyGit/index.ts index 81af79d..2b5c1fd 100644 --- a/src/api/system/companyGit/index.ts +++ b/src/api/system/companyGit/index.ts @@ -1,7 +1,7 @@ import request from '@/utils/request'; import type { ApiResult, PageResult } from '@/api/index'; import type { CompanyGit, CompanyGitParam } from './model'; -import { SERVER_API_URL } from '@/config/index'; +import {SERVER_API_URL} from "@/utils/server"; /** * 分页查询代码仓库 diff --git a/src/api/system/companyParameter/index.ts b/src/api/system/companyParameter/index.ts index 198d75e..ee8f3e8 100644 --- a/src/api/system/companyParameter/index.ts +++ b/src/api/system/companyParameter/index.ts @@ -1,7 +1,7 @@ import request from '@/utils/request'; import type { ApiResult, PageResult } from '@/api/index'; import type { CompanyParameter, CompanyParameterParam } from './model'; -import {SERVER_API_URL} from '@/config/index'; +import {SERVER_API_URL} from "@/utils/server"; /** * 分页查询应用参数 diff --git a/src/api/system/companyParameter/model/index.ts b/src/api/system/companyParameter/model/index.ts index bf608d8..a2a58e8 100644 --- a/src/api/system/companyParameter/model/index.ts +++ b/src/api/system/companyParameter/model/index.ts @@ -1,4 +1,4 @@ -import type { PageParam } from '@/api'; +import type { PageParam } from '@/api/index'; /** * 应用参数 diff --git a/src/api/system/organization/index.ts b/src/api/system/organization/index.ts index fbfede2..c576227 100644 --- a/src/api/system/organization/index.ts +++ b/src/api/system/organization/index.ts @@ -9,7 +9,7 @@ import {SERVER_API_URL} from "@/utils/server"; export async function pageOrganizations(params: OrganizationParam) { const res = await request.get>>( SERVER_API_URL + '/system/organization/page', - { params } + params ); if (res.code === 0) { return res.data; @@ -23,7 +23,7 @@ export async function pageOrganizations(params: OrganizationParam) { export async function listOrganizations(params?: OrganizationParam) { const res = await request.get>( SERVER_API_URL + '/system/organization', - { params } + params ); if (res.code === 0 && res.data) { return res.data; diff --git a/src/api/system/organization/model/index.ts b/src/api/system/organization/model/index.ts index 1f9deaa..9a075f8 100644 --- a/src/api/system/organization/model/index.ts +++ b/src/api/system/organization/model/index.ts @@ -1,4 +1,4 @@ -import { PageParam } from '@/api'; +import { PageParam } from '@/api/index'; /** * 机构 @@ -38,5 +38,7 @@ export interface Organization { */ export interface OrganizationParam extends PageParam { organizationName?: string; + keywords?: string; + limit?: number; parentId?: number; } diff --git a/src/api/system/userRole/index.ts b/src/api/system/userRole/index.ts index 3dfa2e1..8670cdc 100644 --- a/src/api/system/userRole/index.ts +++ b/src/api/system/userRole/index.ts @@ -30,3 +30,17 @@ export async function updateUserRole(data: UserRole) { } return Promise.reject(new Error(res.message)); } + +/** + * 添加用户角色 + */ +export async function addUserRole(data: UserRole) { + const res = await request.post>( + SERVER_API_URL + '/system/user-role', + data + ); + if (res.code === 0) { + return res.message; + } + return Promise.reject(new Error(res.message)); +} diff --git a/src/api/system/userRole/model/index.ts b/src/api/system/userRole/model/index.ts index 835bbae..95f006d 100644 --- a/src/api/system/userRole/model/index.ts +++ b/src/api/system/userRole/model/index.ts @@ -26,5 +26,6 @@ export interface UserRole { */ export interface UserRoleParam extends PageParam { keywords?: any; + roleId?: number; userId?: number; } diff --git a/src/api/system/userVerify/model/index.ts b/src/api/system/userVerify/model/index.ts index 2d52441..cb974dd 100644 --- a/src/api/system/userVerify/model/index.ts +++ b/src/api/system/userVerify/model/index.ts @@ -32,6 +32,12 @@ export interface UserVerify { zzCode?: string; // 营业执照 zzImg?: string; + // 组织机构代码 + organizationId?: number; + // 组织机构名称 + organizationName?: string; + // 记录当前用户角色ID + userRoleId?: number; // 备注 comments?: string; // 状态, 0在线, 1离线 @@ -54,5 +60,6 @@ export interface UserVerify { export interface UserVerifyParam extends PageParam { id?: number; status?: number; + organizationId?: number; keywords?: string; } diff --git a/src/app.ts b/src/app.ts index b9b19e8..5f36060 100644 --- a/src/app.ts +++ b/src/app.ts @@ -5,7 +5,7 @@ import Taro, {useDidShow, useDidHide} from '@tarojs/taro' import './app.scss' import {loginByOpenId} from "@/api/layout"; import {TenantId} from "@/utils/config"; -import {saveStorageByLoginUser} from "@/utils/server"; +// import {saveStorageByLoginUser} from "@/utils/server"; import {mqttStart} from "@/api/hjm/hjmCar"; function App(props) { @@ -20,7 +20,7 @@ function App(props) { tenantId: TenantId }).then(data => { if (data) { - saveStorageByLoginUser(data.access_token, data.user) + // saveStorageByLoginUser(data.access_token, data.user) } }) } diff --git a/src/hjm/BestSellers.tsx b/src/hjm/BestSellers.tsx index 5136f7d..e1d83a8 100644 --- a/src/hjm/BestSellers.tsx +++ b/src/hjm/BestSellers.tsx @@ -38,6 +38,11 @@ const BestSellers = (props: any) => { ) })} + {props.data.length === 0 && ( + + 暂无数据 + + )} diff --git a/src/hjm/fence.tsx b/src/hjm/fence.tsx index eab5715..3d1dece 100644 --- a/src/hjm/fence.tsx +++ b/src/hjm/fence.tsx @@ -1,57 +1,127 @@ import {useEffect, useState} from "react"; -import {useRouter} from '@tarojs/taro' -import {getHjmCar, pageHjmCar} from "@/api/hjm/hjmCar"; +import {Map} from '@tarojs/components' +// import {Search} from '@nutui/icons-react-taro' +// import {Button, Input} from '@nutui/nutui-react-taro' +import {pageByQQMap} from "@/api/hjm/hjmCar"; import {HjmCar} from "@/api/hjm/hjmCar/model"; -import {Image,Cell} from '@nutui/nutui-react-taro' import './location.scss' - +import {HjmFence} from "@/api/hjm/hjmFence/model"; +import {getHjmFence} from "@/api/hjm/hjmFence"; +import {Market} from "../pages/index"; +interface Where { + latitude?: number; + longitude?: number; +} /** - * 电子围栏 + * 文章终极列表 * @constructor */ -const Fence = () => { - const {params} = useRouter(); - const [keywords, setKeywords] = useState() - const [item, setItem] = useState() +const Location = () => { + // const [keywords, setKeywords] = useState() + // const [item, setItem] = useState() + const [longitude, setLongitude] = useState(108.374959) + const [latitude, setLatitude] = useState(22.767024) + const [scale, setScale] = useState(16) + const [showCircles, setShowCircles] = useState(false) + const [points, setPoints] = useState([]) + const [fence, setFence] = useState() + const [markers, setMarkers] = useState([]) - // 打开地图选择位置 - // const chooseLocation = async () => { - // try { - // const res = await Taro.chooseLocation({ - // latitude, // 默认纬度 - // longitude // 默认经度 - // }) - // console.log('选择的位置:', res); - // } catch (err) { - // console.error('选择位置失败:', err); - // } + // const onKeywords = (keywords: string) => { + // setKeywords(keywords) // } - const reload = () => { - const id = Number(params.id); - // 执行搜索 - if (keywords) { - pageHjmCar({keywords}).then(res => { - if (res?.list && res?.list?.length > 0) { - const data = res?.list[0]; - setItem(data) - setKeywords(data.code) + + // 通用的坐标字符串转数组函数 + const parseCoordinateString = (coordStr: string) => { + if (!coordStr) return {points: []}; + + try { + // 分割坐标点 + const coordPairs = coordStr.split(';'); + + // 转为多边形点数组 + const points = coordPairs.map(coord => { + const [lat, lng] = coord.split(','); + return { + latitude: parseFloat(lat), + longitude: parseFloat(lng) } - }) - return false; - } - // 获取车辆信息 - if (id) { - getHjmCar(id).then(data => { - setItem(data) - setKeywords(data.code) - }) + }); + console.log(points,'pointspointspoints') + return {points}; + } catch (error) { + console.error('解析坐标字符串失败:', error); + return {points: []}; } } + const reload = () => { + setScale(11) + setLongitude(108.355702) + setLatitude(22.857968) + getHjmFence(4).then(data => { + setFence(data) + const coordStr = data.points || ''; + + // 使用通用函数解析坐标字符串 + const {points} = parseCoordinateString(coordStr); + console.log('解析结果 - 多边形点:', points); + setPoints(points); + setShowCircles(true) + console.log(fence,'fencefencefence') + }) + const where: Where = {} + where.latitude = latitude + where.longitude = longitude + pageByQQMap(where).then(res => { + if (res?.count == 0) { + const arr = [] + // @ts-ignore + arr.push({ + id: 10001, + latitude: 22.813371, + longitude: 108.323885, + title: '当前位置', + name: '当前位置' + }) + setMarkers(arr) + return false + } + if (res?.list && res?.list.length > 0) { + const data = res?.list; + const arr = [] + data?.map((item: HjmCar) => { + // @ts-ignore + arr.push({ + id: item.id, + latitude: item.latitude, + longitude: item.longitude, + label: { + content: `${item?.code}`, + color: '#000000', + fontSize: 12, + borderRadius: 5, + bgColor: '#FFFFFF', + // @ts-ignore + padding: '5px 5px', + borderWidth: 1 + }, + title: `${item.organization}`, + name: item.organization + }) + }) + setMarkers(arr) + } + }) + } + useEffect(() => { reload() }, []) + // 监听圈圈数据变化 + useEffect(() => { + }, [showCircles]) return ( <> @@ -82,35 +152,47 @@ const Fence = () => { {/* */} {/* */} {/**/} - {item ? ( - - - - - 车辆编号:{item?.code} - - - 快递公司:{item?.kuaidi} - - - 管理负责人:{item?.kuaidiAdmin} - - - 操作员:{item?.driver} - - - 保险状态:{item?.insuranceStatus} - - - GPS编号:{item?.gpsNo} - - - 电子围栏:{item?.fenceName} - - - - ) : ''} + {/*{item ? (*/} + {/* */} + {/* */} + {/* */} + {/* 操作人员:{item?.driver}*/} + {/* */} + {/* */} + {/* 电子围栏:{item?.fenceName} ({item?.inFence ? '围栏内' : '围栏外'})*/} + {/* */} + {/* */} + {/* 当前车速:{item?.speed}*/} + {/* */} + {/* */} + {/* 更新时间:{item?.updateTime}*/} + {/* */} + {/* */} + {/* */} + {/*) : ''}*/} + + {markers.length > 0 && ( + 0 ? [ + { + points: points, + color: '#ff0000', + strokeWidth: 3 + } + ] : []} + onTap={() => { + console.log('map tap') + }} + style={{width: '100%', height: '100vh'}} + /> + )} > ) } -export default Fence +export default Location diff --git a/src/hjm/list.tsx b/src/hjm/list.tsx index 4f20a66..2a5e6c2 100644 --- a/src/hjm/list.tsx +++ b/src/hjm/list.tsx @@ -41,6 +41,13 @@ const List = () => { where.organizationId = Taro.getStorageSync('OrganizationId'); } } + if(roleCode == 'Installer'){ + // @ts-ignore + where.installerId = Taro.getStorageSync('UserId') + } + if(roleCode == 'user'){ + return false; + } // 获取车辆列表 pageHjmCar(where).then(res => { diff --git a/src/hjm/query.tsx b/src/hjm/query.tsx index b433a50..5fff995 100644 --- a/src/hjm/query.tsx +++ b/src/hjm/query.tsx @@ -128,7 +128,8 @@ const Query = () => { // 安装车辆 updateHjmCar({ ...FormData, - status: 1 + status: 1, + installerId: Taro.getStorageSync('UserId') }).then(() => { Taro.showToast({title: `安装成功`, icon: 'success'}) setTimeout(() => { @@ -419,6 +420,11 @@ const Query = () => { if (carInfo.status == 1 && roleCode == 'kuaidiyuan') { // 2.1先查询名下有多少辆车 const carCount = await pageHjmCar({driverId: Taro.getStorageSync('UserId')}) + carCount?.list.map(d => { + if(d.code == code){ + // 只能绑定一辆车 + } + }) if (carCount?.count == 0) { // 2.2无车辆则认领 setClaimVehicle(true) @@ -504,7 +510,7 @@ const Query = () => { @@ -705,7 +711,7 @@ const Query = () => { 所属站点:{FormData?.organization} - 管理责任人:{FormData?.parentOrganizationAdmin} + 管理责任人:{FormData?.kuaidiAdmin} 保险状态:{FormData?.insuranceStatus} @@ -717,10 +723,10 @@ const Query = () => { 电子围栏:{FormData.fenceName} - 安装状态:{FormData.status == 2 ? '已绑定' : '未绑定'} + 安装状态:{FormData.status == 1 ? '已安装' : '未安装'} - 操作员:{FormData.status == 2 ? FormData.driver : '-'} + 操作员:{FormData.driver || '-'} { // 认领车辆 diff --git a/src/pages/index/ExpirationTime.tsx b/src/pages/index/ExpirationTime.tsx index 53264a4..4c632bb 100644 --- a/src/pages/index/ExpirationTime.tsx +++ b/src/pages/index/ExpirationTime.tsx @@ -4,6 +4,7 @@ import {Button} from '@nutui/nutui-react-taro' import {Target, Scan, Truck} from '@nutui/icons-react-taro' import {getUserInfo} from "@/api/layout"; import navTo from "@/utils/common"; +import {pageHjmCar} from "@/api/hjm/hjmCar"; const ExpirationTime = () => { const [isAdmin, setIsAdmin] = useState(false) @@ -45,6 +46,9 @@ const ExpirationTime = () => { if(Taro.getStorageSync('certification') == 'yz'){ setIsAdmin(true) } + if(Taro.getStorageSync('RoleCode') == 'Installer'){ + setIsAdmin(true) + } data.roles?.map((item, index) => { if (index == 0) { setRoleName(item.roleCode) @@ -53,6 +57,12 @@ const ExpirationTime = () => { } }) + pageHjmCar({driverId: Taro.getStorageSync('UserId')}).then(res => { + if(res?.list && res.list.length > 0){ + setIsAdmin(true) + } + }) + }, []) return ( diff --git a/src/pages/index/Header.tsx b/src/pages/index/Header.tsx index 7664f6c..4a56e37 100644 --- a/src/pages/index/Header.tsx +++ b/src/pages/index/Header.tsx @@ -33,6 +33,7 @@ const Header = (props: any) => { if (data) { setIsLogin(true); Taro.setStorageSync('UserId', data.userId) + Taro.setStorageSync('Phone',data.phone) // 机构ID Taro.setStorageSync('OrganizationId',data.organizationId) // 父级机构ID diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index a6d96cc..0c0798c 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -228,6 +228,7 @@ function Home() { if (!Taro.getStorageSync('access_token')) { return false; } + pageHjmCarByMap(latitude, longitude) if (!isAdmin) { return false; } @@ -315,6 +316,9 @@ function Home() { console.log('交警', '12312') setIsAdmin(true) } + if (Taro.getStorageSync('RoleCode') == 'Installer') { + setIsAdmin(true) + } setUserInfo(data) setIsLogin(true); Taro.setStorageSync('UserId', data.userId) diff --git a/src/pages/user/components/UserCard.tsx b/src/pages/user/components/UserCard.tsx index 0a42ca5..92013f0 100644 --- a/src/pages/user/components/UserCard.tsx +++ b/src/pages/user/components/UserCard.tsx @@ -1,5 +1,5 @@ import {Button} from '@nutui/nutui-react-taro' -import {Avatar, Tag} from '@nutui/nutui-react-taro' +import {Avatar, Tag, Space} from '@nutui/nutui-react-taro' import {getUserInfo, getWxOpenId} from '@/api/layout'; import Taro from '@tarojs/taro'; import {useEffect, useState} from "react"; @@ -163,11 +163,18 @@ function UserCard() { {IsLogin ? userInfo?.mobile : '请点击头像登录'} {IsLogin ? ( - + {roleName || '注册用户'} - + {/*{*/} + {/* userInfo?.organizationName && (*/} + {/* */} + {/* {userInfo?.organizationName}*/} + {/* */} + {/* )*/} + {/*}*/} + ) : ''} diff --git a/src/pages/user/components/UserCell.tsx b/src/pages/user/components/UserCell.tsx index a6d097f..4ae325b 100644 --- a/src/pages/user/components/UserCell.tsx +++ b/src/pages/user/components/UserCell.tsx @@ -19,6 +19,7 @@ const UserCell = () => { content: '确定要退出登录吗?', success: function (res) { if (res.confirm) { + Taro.clearStorageSync() Taro.removeStorageSync('access_token') Taro.removeStorageSync('TenantId') Taro.removeStorageSync('UserId') @@ -56,7 +57,7 @@ const UserCell = () => { /> { - roleName === 'kuaidi' && ( + (roleName === 'kuaidi' || roleName == 'zhandian') && ( { const [list, setList] = useState([]) const [loading, setLoading] = useState(false) const [keywords, setKeywords] = useState('') + // const [showTextArea, setShowTextArea] = useState(false) const [refreshing, setRefreshing] = useState(false) console.log(refreshing) // 获取状态显示 @@ -42,9 +43,20 @@ const List: React.FC = () => { if (showLoading) setLoading(true) setRefreshing(true) - const res = await pageUserVerify({ + const where = { keywords: keywords.trim(), - }) + } + + if (Taro.getStorageSync('RoleCode') == 'zhandian') { + // @ts-ignore + where.organizationId = Taro.getStorageSync('OrganizationId') + } + if (Taro.getStorageSync('RoleCode') == 'kuaidi') { + // @ts-ignore + where.OrganizationParentId = Taro.getStorageSync('OrganizationParentId') + } + + const res = await pageUserVerify(where) setList(res?.list || []) } catch (error) { @@ -67,12 +79,44 @@ const List: React.FC = () => { setKeywords(value) } - const onAddInsurance = () => { - Taro.navigateTo({ - url: '/hjm/violation/add' + 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' + }) + reload().then() + }) }) } + const onReject = async (item: UserVerify) => { + const role = await listUserRole({roleId: 1738,userId: item.userId}) + const userRole = role[0]; + if(userRole){ + userRole.roleId = 1701; + updateUserRole(userRole).then(() => { + updateUserVerify({ + ...item, + status: 2 + }).then(() => { + Taro.showToast({ + title: '操作成功', + icon: 'success' + }) + reload().then() + }) + }) + } + } + useEffect(() => { reload().then() }, []) @@ -137,10 +181,7 @@ const List: React.FC = () => { 加载中... ) : list.length === 0 ? ( - - - 立即报险 - + ) : ( @@ -183,6 +224,18 @@ const List: React.FC = () => { + + + + + 所属站点:{item.organizationName} + + + { } )} + + + onPass(item)}>通过 + onReject(item)}>驳回 + + + + {/*{showTextArea && (*/} + {/* changeComments(value)}*/} + {/* />*/} + {/*)}*/} ) })} diff --git a/src/user/userVerify/index.tsx b/src/user/userVerify/index.tsx index 5165e00..202af4e 100644 --- a/src/user/userVerify/index.tsx +++ b/src/user/userVerify/index.tsx @@ -1,5 +1,4 @@ import {useEffect, useState} from "react"; -import {Image} from '@nutui/nutui-react-taro' import {ConfigProvider} from '@nutui/nutui-react-taro' import Taro from '@tarojs/taro' @@ -8,19 +7,22 @@ import { Button, Input, Radio, + Cell, + SearchBar } from '@nutui/nutui-react-taro' import {UserVerify} from "@/api/system/userVerify/model"; import {addUserVerify, myUserVerify, updateUserVerify} from "@/api/system/userVerify"; -import {uploadFile} from "@/api/system/file"; +import {pageOrganizations} from "@/api/system/organization"; function Index() { const [isUpdate, setIsUpdate] = useState(false) const [submitText, setSubmitText] = useState('提交') + const [siteList, setSiteList] = useState([]) const [FormData, setFormData] = useState({ userId: undefined, - type: undefined, - phone: undefined, + type: 0, + phone: Taro.getStorageSync('Phone'), avatar: undefined, realName: undefined, idCard: undefined, @@ -29,6 +31,9 @@ function Index() { sfz2: undefined, zzCode: undefined, zzImg: undefined, + organizationId: undefined, + organizationName: undefined, + userRoleId: Taro.getStorageSync(''), status: undefined, statusText: undefined, comments: undefined @@ -47,43 +52,41 @@ function Index() { }) } }) + if(Taro.getStorageSync('Phone')){ + setFormData({...FormData, phone: Taro.getStorageSync('Phone')}) + } + } + + const submitFailed = (error: any) => { + console.log(error, 'err...') + } + + const searchSiteList = (keywords: string) => { + pageOrganizations({keywords,limit: 5}).then(res => { + setSiteList(res?.list || []) + }) + } + + const onOrganizationChange = (item) => { + console.log(item); + + setFormData({ + ...FormData, + organizationId: item.organizationId, + organizationName: item.organizationName + }) } // 提交表单 const submitSucceed = (values: any) => { - console.log('提交表单', values); + console.log('提交表单...',values) if (FormData.status != 2 && FormData.status != undefined) return false; - if (FormData.type == 0) { - if (!FormData.sfz1 || !FormData.sfz2) { - Taro.showToast({ - title: '请上传身份证正反面', - icon: 'none' - }); - return false; - } - if (!FormData.realName || !FormData.idCard) { - Taro.showToast({ - title: '请填写真实姓名和身份证号码', - icon: 'none' - }); - return false; - } - } - if (FormData.type == 1) { - if (!FormData.zzImg) { - Taro.showToast({ - title: '请上传营业执照', - icon: 'none' - }); - return false; - } - if (!FormData.name || !FormData.zzCode) { - Taro.showToast({ - title: '请填写主体名称和营业执照号码', - icon: 'none' - }); - return false; - } + if(FormData.organizationId == 0 || !FormData.organizationId){ + Taro.showToast({ + title: '请选择站点', + icon: 'none' + }); + return false; } if(!FormData.realName){ Taro.showToast({ @@ -92,6 +95,7 @@ function Index() { }); return false; } + console.log('提交表单', FormData); const saveOrUpdate = isUpdate ? updateUserVerify : addUserVerify; saveOrUpdate({...FormData, status: 0}).then(() => { Taro.showToast({title: `提交成功`, icon: 'success'}) @@ -107,40 +111,6 @@ function Index() { reload(); }) } - const submitFailed = (error: any) => { - console.log(error, 'err...') - } - - const uploadSfz1 = () => { - if (FormData.status != 2 && FormData.status != undefined) return false; - uploadFile().then(data => { - setFormData({ - ...FormData, - sfz1: data.url - }) - }); - } - - const uploadSfz2 = () => { - if (FormData.status != 2 && FormData.status != undefined) return false; - uploadFile().then(data => { - setFormData({ - ...FormData, - sfz2: data.url - }) - }); - } - - - const uploadZzImg = () => { - if (FormData.status != 2 && FormData.status != undefined) return false; - uploadFile().then(data => { - setFormData({ - ...FormData, - zzImg: data.url - }) - }); - } useEffect(() => { reload() @@ -173,27 +143,72 @@ function Index() { ) } > - - setFormData({...FormData, type: value})}> - - 个人 - - - 企业 - - - + {/**/} + {/* setFormData({...FormData, type: value})}>*/} + {/* */} + {/* 个人*/} + {/* */} + {/* */} + {/* 企业*/} + {/* */} + {/* */} + {/**/} + + {FormData.status != 1 && ( + <> + + searchSiteList(val)} maxLength={10} /> + + + + {siteList.map((item: any,index) => ( + onOrganizationChange(item)}> + {item.organizationName} + + ))} + + {/*{siteList.length == 0 && (*/} + {/* */} + {/* 没有搜索结果*/} + {/* */} + {/*)}*/} + + > + + )} + { // 个人类型 FormData.type == 0 && ( <> + + + setFormData({...FormData, idCard: value})} + value={FormData?.phone} + onChange={(value) => setFormData({...FormData, phone: value})} /> - - - - - - - - - - + {/**/} + {/* setFormData({...FormData, idCard: value})}*/} + {/* />*/} + {/**/} + {/**/} + {/* */} + {/* */} + {/* */} + {/* */} + {/* */} + {/* */} + {/* */} + {/* */} + {/**/} > ) } - { - // 企业类型 - FormData.type == 1 && ( - <> - - setFormData({...FormData, name: value})} - /> - - - setFormData({...FormData, zzCode: value})} - /> - - - - - - - > - ) - } - - setFormData({...FormData, realName: value})} - /> - + {/*{*/} + {/* // 企业类型*/} + {/* FormData.type == 1 && (*/} + {/* <>*/} + {/* */} + {/* setFormData({...FormData, name: value})}*/} + {/* />*/} + {/* */} + {/* */} + {/* setFormData({...FormData, zzCode: value})}*/} + {/* />*/} + {/* */} + {/* */} + {/* */} + {/* */} + {/* */} + {/* */} + {/* >*/} + {/* )*/} + {/*}*/} + {/**/} + {/* setFormData({...FormData, realName: value})}*/} + {/* />*/} + {/**/} { FormData.status != undefined && (