修复已知问题
This commit is contained in:
@@ -1,10 +1,22 @@
|
||||
import {useEffect, useState} from "react";
|
||||
import {useRouter} from '@tarojs/taro'
|
||||
import {getHjmCar, pageHjmCar} from "@/api/hjm/hjmCar";
|
||||
import Taro, {useRouter} from '@tarojs/taro'
|
||||
import {getHjmCar, pageHjmCar, updateHjmCar} from "@/api/hjm/hjmCar";
|
||||
import {HjmCar} from "@/api/hjm/hjmCar/model";
|
||||
import {Image,Cell} from '@nutui/nutui-react-taro'
|
||||
import './location.scss'
|
||||
import {copyText} from "@/utils/common";
|
||||
import {View} from '@tarojs/components'
|
||||
import {
|
||||
Form,
|
||||
Button,
|
||||
Input,
|
||||
Radio,
|
||||
Cell,
|
||||
Image
|
||||
} from '@nutui/nutui-react-taro'
|
||||
import {Scan} from '@nutui/icons-react-taro'
|
||||
import {pageDictData} from "@/api/system/dict-data";
|
||||
import {DictData} from "@/api/system/dict-data/model";
|
||||
import {TenantId} from "@/utils/config";
|
||||
|
||||
/**
|
||||
* 文章终极列表
|
||||
@@ -14,6 +26,166 @@ const Query = () => {
|
||||
const {params} = useRouter();
|
||||
const [keywords, setKeywords] = useState<string>()
|
||||
const [item, setItem] = useState<HjmCar>()
|
||||
const [dict, setDict] = useState<DictData[]>([])
|
||||
|
||||
const [FormData, setFormData] = useState<HjmCar>(
|
||||
{
|
||||
// 自增ID
|
||||
id: undefined,
|
||||
// 车辆名称
|
||||
name: undefined,
|
||||
// 车辆图片
|
||||
image: undefined,
|
||||
// 类型 0汽车 1其他车
|
||||
type: undefined,
|
||||
// 快递公司
|
||||
kuaidi: undefined,
|
||||
// 管理负责人
|
||||
kuaidiAdmin: undefined,
|
||||
organization: undefined,
|
||||
organizationParentId: undefined,
|
||||
parentOrganization: undefined,
|
||||
parentOrganizationAdmin: undefined,
|
||||
// 车辆编号
|
||||
code: undefined,
|
||||
// 操作员
|
||||
driver: undefined,
|
||||
// 保险状态
|
||||
insuranceStatus: undefined,
|
||||
// GPS设备编号
|
||||
gpsNo: undefined,
|
||||
// 电子围栏
|
||||
fence: undefined,
|
||||
// 位置
|
||||
location: undefined,
|
||||
// 经度
|
||||
longitude: undefined,
|
||||
// 纬度
|
||||
latitude: undefined,
|
||||
// 地址
|
||||
address: undefined,
|
||||
// 用户ID
|
||||
userId: undefined,
|
||||
// 排序(数字越小越靠前)
|
||||
sortNumber: undefined,
|
||||
// 备注
|
||||
comments: undefined,
|
||||
// 状态, 0正常, 1冻结
|
||||
status: undefined,
|
||||
// 是否删除, 0否, 1是
|
||||
deleted: undefined,
|
||||
// 租户id
|
||||
tenantId: undefined,
|
||||
// 创建时间
|
||||
createTime: undefined,
|
||||
// 更新时间
|
||||
updateTime: undefined,
|
||||
}
|
||||
)
|
||||
|
||||
// 提交表单
|
||||
const submitSucceed = (values: any) => {
|
||||
updateHjmCar({...values, ...FormData, status: 1}).then(() => {
|
||||
Taro.showToast({title: `保存成功`, icon: 'success'})
|
||||
setTimeout(() => {
|
||||
return Taro.navigateBack()
|
||||
}, 1000)
|
||||
}).catch(() => {
|
||||
Taro.showToast({
|
||||
title: '保存失败',
|
||||
icon: 'error'
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
const submitFailed = (error: any) => {
|
||||
console.log(error, 'err...')
|
||||
}
|
||||
|
||||
const saveGpsNo = () => {
|
||||
Taro.scanCode({
|
||||
onlyFromCamera: true,
|
||||
scanType: ['barCode', 'qrCode'],
|
||||
success: (res) => {
|
||||
// 更新表单数据
|
||||
setFormData({
|
||||
...FormData,
|
||||
gpsNo: res.result
|
||||
});
|
||||
Taro.showToast({
|
||||
title: '扫码成功' + res.result,
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
});
|
||||
},
|
||||
fail: (err) => {
|
||||
console.log('扫码失败', err);
|
||||
Taro.showToast({
|
||||
title: '扫码失败',
|
||||
icon: 'error',
|
||||
duration: 2000
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 拍照上传功能
|
||||
const takePhoto = () => {
|
||||
Taro.chooseImage({
|
||||
count: 1,
|
||||
sizeType: ['compressed'],
|
||||
sourceType: ['camera'], // 只允许拍照
|
||||
success: async (res) => {
|
||||
const tempFilePath = res.tempFilePaths[0];
|
||||
console.log(tempFilePath, 'tempFilePath')
|
||||
// 上传图片到OSS
|
||||
Taro.uploadFile({
|
||||
url: 'https://server.gxwebsoft.com/api/oss/upload',
|
||||
filePath: tempFilePath,
|
||||
name: 'file',
|
||||
header: {
|
||||
'content-type': 'application/json',
|
||||
TenantId
|
||||
},
|
||||
success: (res) => {
|
||||
const data = JSON.parse(res.data);
|
||||
if (data && data.code === 0) {
|
||||
console.log(data.data.url, '1url.....')
|
||||
updateHjmCar({
|
||||
id: FormData.id,
|
||||
image: data.data.downloadUrl + '?x-oss-process=image/resize,w_750/quality,Q_90'
|
||||
}).then(() => {
|
||||
Taro.showToast({
|
||||
title: '上传成功',
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
});
|
||||
setFormData({...FormData,image: data.data.downloadUrl + '?x-oss-process=image/resize,w_750/quality,Q_90'})
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
fail: (err) => {
|
||||
console.log('拍照失败', err);
|
||||
Taro.showToast({
|
||||
title: '拍照失败',
|
||||
icon: 'error',
|
||||
duration: 2000
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 删除图片
|
||||
// const removeImage = (index: number) => {
|
||||
// const newImages = uploadedImages.filter((_, i) => i !== index);
|
||||
// setUploadedImages(newImages);
|
||||
// setFormData({
|
||||
// ...FormData,
|
||||
// image: newImages.join(',')
|
||||
// });
|
||||
// }
|
||||
|
||||
// 打开地图选择位置
|
||||
// const chooseLocation = async () => {
|
||||
@@ -29,6 +201,10 @@ const Query = () => {
|
||||
// }
|
||||
const reload = () => {
|
||||
const id = Number(params.id);
|
||||
// 获取数据字典
|
||||
pageDictData({dictCode: 'InsuranceStatus'}).then(res => {
|
||||
setDict(res?.list || [])
|
||||
})
|
||||
// 执行搜索
|
||||
if (keywords) {
|
||||
pageHjmCar({keywords}).then(res => {
|
||||
@@ -45,6 +221,21 @@ const Query = () => {
|
||||
getHjmCar(id).then(data => {
|
||||
setItem(data)
|
||||
setKeywords(data.code)
|
||||
setFormData(data)
|
||||
|
||||
// 初始化已上传的图片
|
||||
// if (data.image) {
|
||||
// const images = data.image.split(',').filter(img => img.trim());
|
||||
// setUploadedImages(images);
|
||||
// }
|
||||
|
||||
console.log(data.status, '1213')
|
||||
if (data.status == 0) {
|
||||
Taro.setNavigationBarTitle({
|
||||
title: '安装设备'
|
||||
})
|
||||
setFormData({...data, driver: Taro.getStorageSync('RealName')})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -56,62 +247,158 @@ const Query = () => {
|
||||
|
||||
return (
|
||||
<>
|
||||
{/*<div className={'fixed z-20 top-5 left-0 w-full'}>*/}
|
||||
{/* <div className={'px-4'}>*/}
|
||||
{/* <div*/}
|
||||
{/* style={{*/}
|
||||
{/* display: 'flex',*/}
|
||||
{/* alignItems: 'center',*/}
|
||||
{/* background: '#fff',*/}
|
||||
{/* padding: '0 10px',*/}
|
||||
{/* borderRadius: '20px'*/}
|
||||
{/* }}*/}
|
||||
{/* >*/}
|
||||
{/* <Search/>*/}
|
||||
{/* <Input*/}
|
||||
{/* placeholder="车辆编号"*/}
|
||||
{/* value={keywords}*/}
|
||||
{/* onChange={onKeywords}*/}
|
||||
{/* />*/}
|
||||
{/* <div*/}
|
||||
{/* className={'flex items-center'}*/}
|
||||
{/* >*/}
|
||||
{/* <Button type="warning" onClick={reload}>*/}
|
||||
{/* 查询*/}
|
||||
{/* </Button>*/}
|
||||
{/* </div>*/}
|
||||
{/* </div>*/}
|
||||
{/* </div>*/}
|
||||
{/*</div>*/}
|
||||
{item ? (
|
||||
|
||||
{/* 未安装 */}
|
||||
{item?.status == 0 ? (
|
||||
<div className={'car-info w-full bg-white'}>
|
||||
<div className={'px-0'}>
|
||||
<Form
|
||||
divider
|
||||
initialValues={FormData}
|
||||
labelPosition="left"
|
||||
onFinish={(values) => submitSucceed(values)}
|
||||
onFinishFailed={(errors) => submitFailed(errors)}
|
||||
footer={
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
width: '100%'
|
||||
}}
|
||||
>
|
||||
<Button nativeType="submit" block type="info">
|
||||
提交
|
||||
</Button>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<Form.Item
|
||||
label={'车辆编号'}
|
||||
name="code"
|
||||
rules={[{message: '请输入车辆编号'}]}
|
||||
>
|
||||
<View onClick={() => copyText(`${item?.code}`)}>{item?.code}</View>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={'快递公司品牌'}
|
||||
name="parentOrganization"
|
||||
rules={[{message: '快递公司品牌'}]}
|
||||
>
|
||||
<Input placeholder="快递公司品牌" disabled type="text"/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={'管理责任人'}
|
||||
name="parentOrganizationAdmin"
|
||||
rules={[{message: '管理责任人'}]}
|
||||
>
|
||||
<Input placeholder="管理责任人" disabled type="text"/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={'电子围栏'}
|
||||
name="fence"
|
||||
rules={[{message: '电子围栏'}]}
|
||||
>
|
||||
<Input placeholder="电子围栏" type="text"/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="保险状态"
|
||||
name="insuranceStatus"
|
||||
rules={[
|
||||
{message: '保险状态'}
|
||||
]}
|
||||
>
|
||||
<Radio.Group value={FormData.insuranceStatus} disabled direction="horizontal">
|
||||
{
|
||||
dict?.map((item, index) => (
|
||||
<Radio key={index} value={item.dictDataCode}>
|
||||
{item.dictDataName}
|
||||
</Radio>
|
||||
))
|
||||
}
|
||||
</Radio.Group>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={'GPS编号'}
|
||||
name="gpsNo"
|
||||
rules={[{message: 'GPS编号'}]}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
background: '#fff',
|
||||
}}
|
||||
>
|
||||
<Input
|
||||
placeholder="请填入GPS设备编号"
|
||||
value={FormData.gpsNo}
|
||||
onChange={(value) => setFormData({...FormData, gpsNo: value})}
|
||||
/>
|
||||
<div
|
||||
className="right"
|
||||
style={{display: 'flex', alignItems: 'center'}}
|
||||
>
|
||||
<Scan onClick={saveGpsNo}/>
|
||||
</div>
|
||||
</div>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={'拍照上传'}
|
||||
name="image"
|
||||
rules={[{message: '请上传照片'}]}
|
||||
onClick={takePhoto}
|
||||
>
|
||||
<div style={{display: 'flex', flexDirection: 'column', gap: '10px'}}>
|
||||
<Image src={FormData.image} mode={'scaleToFill'}
|
||||
radius="10%" width="80" height="80"/>
|
||||
</div>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={'操作员'}
|
||||
name="driver"
|
||||
rules={[{message: '操作员'}]}
|
||||
>
|
||||
<Input placeholder="操作员" type="text"/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</div>
|
||||
</div>
|
||||
) : ''}
|
||||
|
||||
{/* 已安装 */}
|
||||
{item?.status == 1 ? (
|
||||
<div className={'car-info w-full bg-white'}>
|
||||
<Image src={item?.image} mode={'aspectFit'} width={'100%'} height={'300px'}/>
|
||||
<div className={'px-2'}>
|
||||
<Cell className={'car-info-item-title'} onClick={() => copyText(`${item?.code}`)}>
|
||||
车辆编号:{item?.code}
|
||||
</Cell>
|
||||
<Cell className={'car-info-item-title'}>
|
||||
快递公司:{item?.parentOrganization}
|
||||
</Cell>
|
||||
<Cell className={'car-info-item-title'}>
|
||||
管理负责人:{item?.parentOrganizationAdmin}
|
||||
</Cell>
|
||||
<Cell className={'car-info-item-content'}>
|
||||
操作员:{item?.driver}
|
||||
</Cell>
|
||||
<Cell className={'car-info-item-content'}>
|
||||
保险状态:{item?.insuranceStatus}
|
||||
</Cell>
|
||||
<Cell className={'car-info-item-content'}>
|
||||
GPS编号:{item?.gpsNo}
|
||||
</Cell>
|
||||
<Cell className={'car-info-item-content'}>
|
||||
电子围栏:{item?.fence}
|
||||
</Cell>
|
||||
<Cell className={'car-info-item-title'} onClick={() => copyText(`${item?.code}`)}>
|
||||
车辆编号:{item?.code}
|
||||
</Cell>
|
||||
<Cell className={'car-info-item-title'}>
|
||||
快递公司品牌:{item?.parentOrganization}
|
||||
</Cell>
|
||||
<Cell className={'car-info-item-title'}>
|
||||
管理责任人:{item?.parentOrganizationAdmin}
|
||||
</Cell>
|
||||
<Cell className={'car-info-item-content'}>
|
||||
操作员:{item?.driver}
|
||||
</Cell>
|
||||
<Cell className={'car-info-item-content'}>
|
||||
保险状态:{item?.insuranceStatus}
|
||||
</Cell>
|
||||
<Cell className={'car-info-item-content'}>
|
||||
GPS编号:{item?.gpsNo}
|
||||
</Cell>
|
||||
<Cell className={'car-info-item-content'}>
|
||||
电子围栏:{item?.fence}
|
||||
</Cell>
|
||||
{/*<Cell className={'car-info-item-content'}>*/}
|
||||
{/* 状态:{item?.status == 1 ? '已安装' : '未安装'}*/}
|
||||
{/*</Cell>*/}
|
||||
</div>
|
||||
</div>
|
||||
) : ''}
|
||||
</>
|
||||
)
|
||||
}
|
||||
// @ts-ignore
|
||||
export default Query
|
||||
|
||||
@@ -16,7 +16,7 @@ const Index = () => {
|
||||
|
||||
const reload = () => {
|
||||
// 获取车辆列表
|
||||
pageHjmCar({userId: Taro.getStorageSync('UserId')}).then(res => {
|
||||
pageHjmCar({}).then(res => {
|
||||
setList(res?.list || [])
|
||||
})
|
||||
}
|
||||
|
||||
@@ -15,5 +15,6 @@ export function saveStorageByLoginUser(token: string, user: User) {
|
||||
Taro.setStorageSync('access_token', token)
|
||||
Taro.setStorageSync('UserId', user.userId)
|
||||
Taro.setStorageSync('Phone', user.phone)
|
||||
Taro.setStorageSync('RealName', user.realName)
|
||||
Taro.setStorageSync('User', user)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user