u
This commit is contained in:
1 parent
6c20d0c80d
commit
4aaa93df7d
66 files changed
+4375
-1311
No files matched your search
@@ -2,7 +2,7 @@
|
||||
import type { FieldValidateError, FormExpose, FormRules } from 'sard-uniapp'
|
||||
import { getWindowInfo, toast } from 'sard-uniapp'
|
||||
import { reactive, ref } from 'vue'
|
||||
import { loaddataApi, loginApi } from '@/request/api'
|
||||
import { loginApi } from '@/request/api'
|
||||
import { useUserStore } from '@/store'
|
||||
|
||||
const userStore = useUserStore()
|
||||
@@ -12,7 +12,7 @@ const startOffset = ref(getWindowInfo().statusBarHeight + 60)
|
||||
const _loading = ref(false)
|
||||
|
||||
const formModel = reactive({
|
||||
orgid: userStore.userInfo.orgid,
|
||||
orgid: 'g3hd',
|
||||
userid: userStore.userInfo.userid,
|
||||
password: '',
|
||||
})
|
||||
@@ -42,47 +42,50 @@ async function onSubmit() {
|
||||
password: formModel.password,
|
||||
})
|
||||
|
||||
if (!res?.data) {
|
||||
toast.fail('登录失败,请检查账号密码')
|
||||
return
|
||||
}
|
||||
|
||||
userStore.userInfo = {
|
||||
...userStore.userInfo,
|
||||
orgid: formModel.orgid,
|
||||
userid: formModel.userid,
|
||||
token: res.data,
|
||||
}
|
||||
|
||||
let username = ''
|
||||
try {
|
||||
const userRes = await loaddataApi({
|
||||
viewname: 'v_b_truck',
|
||||
soption: '',
|
||||
orderfield: '',
|
||||
searchcondition: `b_id = '${formModel.userid}'`,
|
||||
})
|
||||
if (userRes?.data?.length > 0) {
|
||||
username = userRes.data[0].v_worker_name || ''
|
||||
if (res.success) {
|
||||
userStore.userInfo = {
|
||||
...userStore.userInfo,
|
||||
orgid: formModel.orgid,
|
||||
userid: formModel.userid,
|
||||
token: res.data.token,
|
||||
username: res.data.username,
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
console.warn('获取用户信息失败', err)
|
||||
|
||||
uni.showToast({
|
||||
title: '登录成功',
|
||||
icon: 'success',
|
||||
})
|
||||
|
||||
uni.switchTab({
|
||||
url: '/pages/home/index',
|
||||
})
|
||||
}
|
||||
|
||||
userStore.userInfo = {
|
||||
...userStore.userInfo,
|
||||
username,
|
||||
}
|
||||
// if (!res?.data) {
|
||||
// toast.fail('登录失败,请检查账号密码')
|
||||
// return
|
||||
// }
|
||||
|
||||
uni.showToast({
|
||||
title: '登录成功',
|
||||
icon: 'success',
|
||||
})
|
||||
// userStore.userInfo = {
|
||||
// ...userStore.userInfo,
|
||||
// orgid: formModel.orgid,
|
||||
// userid: formModel.userid,
|
||||
// token: res.data,
|
||||
// }
|
||||
|
||||
uni.switchTab({
|
||||
url: '/pages/home/index',
|
||||
})
|
||||
// userStore.userInfo = {
|
||||
// ...userStore.userInfo,
|
||||
// username,
|
||||
// }
|
||||
|
||||
// uni.showToast({
|
||||
// title: '登录成功',
|
||||
// icon: 'success',
|
||||
// })
|
||||
|
||||
// uni.switchTab({
|
||||
// url: '/pages/home/index',
|
||||
// })
|
||||
}
|
||||
catch (err: any) {
|
||||
// 表单验证错误
|
||||
@@ -91,7 +94,6 @@ async function onSubmit() {
|
||||
}
|
||||
else {
|
||||
console.error(err)
|
||||
toast.fail(err.message || '登录异常')
|
||||
}
|
||||
}
|
||||
finally {
|
||||
@@ -122,7 +124,7 @@ async function onSubmit() {
|
||||
</view>
|
||||
|
||||
<view class="form-list">
|
||||
<sar-form-item-plain name="orgid">
|
||||
<!-- <sar-form-item-plain name="orgid">
|
||||
<view class="form-label">
|
||||
<text>机构码</text>
|
||||
</view>
|
||||
@@ -137,7 +139,7 @@ async function onSubmit() {
|
||||
</template>
|
||||
</sar-input>
|
||||
</view>
|
||||
</sar-form-item-plain>
|
||||
</sar-form-item-plain> -->
|
||||
<sar-form-item-plain name="userid">
|
||||
<view class="form-label">
|
||||
账号
|
||||
|
||||
@@ -1,49 +1,322 @@
|
||||
<script lang="ts" setup>
|
||||
import { toast } from 'sard-uniapp'
|
||||
import { deleteAliyunFileApi, recognizeOcrBoxApi } from '@/request/api'
|
||||
import { imageCompress, uploadFileToAliyun } from '@/utils/file'
|
||||
|
||||
const boxImage = ref('')
|
||||
|
||||
const ocrFinish = ref(false)
|
||||
const isError = ref(false)
|
||||
const ocrScore = ref('0.00')
|
||||
|
||||
const form = ref({
|
||||
boxNumber: '',
|
||||
boxImageUrl: '',
|
||||
})
|
||||
|
||||
function handleChooseBox() {
|
||||
uni.chooseImage({
|
||||
count: 1,
|
||||
success: (res) => {
|
||||
if (Array.isArray(res.tempFiles) && res.tempFiles.length > 0) {
|
||||
const tempFile: any = res.tempFiles[0]
|
||||
|
||||
boxImage.value = tempFile.path
|
||||
|
||||
imageCompress(tempFile.path).then((compressRes) => {
|
||||
uploadFileToAliyun(compressRes.path, tempFile.name, 'image').then((res) => {
|
||||
if (res.url) {
|
||||
form.value.boxImageUrl = res.url
|
||||
|
||||
ocrFinish.value = false
|
||||
|
||||
toast.loading('OCR识别中,请稍等 . . .', {
|
||||
overlay: true,
|
||||
transparent: false,
|
||||
})
|
||||
|
||||
recognizeOcrBoxApi({
|
||||
fileUrl: form.value.boxImageUrl,
|
||||
}).then((ocrRes) => {
|
||||
if (ocrRes.success) {
|
||||
toast.success('识别成功,请检查箱号是否正确')
|
||||
|
||||
const score = Number(ocrRes?.data?.score ?? 0)
|
||||
ocrScore.value = `${(Math.floor(score * 10000) / 100).toFixed(2)}%`
|
||||
|
||||
form.value.boxNumber = ocrRes.data.boxNumber
|
||||
|
||||
isError.value = false
|
||||
}
|
||||
}).catch(() => {
|
||||
isError.value = true
|
||||
}).finally(() => {
|
||||
ocrFinish.value = true
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
function handleDeleteBoxImage() {
|
||||
if (!form.value.boxImageUrl) {
|
||||
boxImage.value = ''
|
||||
form.value.boxImageUrl = ''
|
||||
form.value.boxNumber = ''
|
||||
return
|
||||
}
|
||||
|
||||
toast.loading('正在删除中 . . .', {
|
||||
overlay: true,
|
||||
transparent: false,
|
||||
})
|
||||
|
||||
console.log(form.value.boxImageUrl)
|
||||
|
||||
deleteAliyunFileApi(form.value.boxImageUrl).then((res) => {
|
||||
if (res.success) {
|
||||
boxImage.value = ''
|
||||
form.value.boxImageUrl = ''
|
||||
form.value.boxNumber = ''
|
||||
|
||||
toast.success('删除成功')
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view class="container">
|
||||
<view class="item">
|
||||
<sar-tag theme="primary" mark size="large">
|
||||
1、集装箱照片
|
||||
</sar-tag>
|
||||
<view class="g3-container">
|
||||
<view class="g3-content">
|
||||
<view class="step">
|
||||
<view class="step-header">
|
||||
<sar-tag theme="primary" mark="right" size="large">
|
||||
1、集装箱号识别(OCR自动识别)
|
||||
</sar-tag>
|
||||
</view>
|
||||
|
||||
<view
|
||||
style="padding: 32rpx;"
|
||||
>
|
||||
<sar-input
|
||||
placeholder="请输入"
|
||||
/>
|
||||
<view class="step-content box">
|
||||
<view v-if="ocrFinish" class="header ">
|
||||
<sar-alert
|
||||
v-if="!isError"
|
||||
type="success"
|
||||
show-icon
|
||||
closable
|
||||
:root-style="{
|
||||
width: '100%',
|
||||
}"
|
||||
>
|
||||
识别成功,请检查箱号是否正确!
|
||||
<view>
|
||||
准确率:{{ ocrScore }}
|
||||
</view>
|
||||
</sar-alert>
|
||||
<sar-alert
|
||||
v-else
|
||||
type="danger"
|
||||
show-icon
|
||||
closable
|
||||
:root-style="{
|
||||
width: '100%',
|
||||
}"
|
||||
>
|
||||
识别失败,请检查手动填写集装箱号
|
||||
</sar-alert>
|
||||
</view>
|
||||
|
||||
<view />
|
||||
<view class="box-main">
|
||||
<view v-if="!boxImage" class="box-placeholder" @click="handleChooseBox">
|
||||
<sar-icon name="image" size="56rpx" color="#999" />
|
||||
<text class="placeholder-text">
|
||||
上传箱号图片,自动识别箱号
|
||||
</text>
|
||||
</view>
|
||||
|
||||
<view v-else class="box-image">
|
||||
<wd-img
|
||||
:src="boxImage"
|
||||
width="100%"
|
||||
height="100%"
|
||||
:enable-preview="true"
|
||||
/>
|
||||
|
||||
<view class="delete-btn" @click="handleDeleteBoxImage()">
|
||||
<sar-icon name="close" size="20rpx" color="#fff" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="box-input">
|
||||
<view class="header">
|
||||
<view>集装箱号</view>
|
||||
<view class="format">
|
||||
格式: 4字母 + 7数字
|
||||
</view>
|
||||
</view>
|
||||
<sar-input
|
||||
v-model="form.boxNumber"
|
||||
placeholder="请输入箱号"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="step">
|
||||
<view class="step-header">
|
||||
<sar-tag theme="primary" mark="right" size="large">
|
||||
2、其它照片录入
|
||||
</sar-tag>
|
||||
</view>
|
||||
<view class="step-content">
|
||||
<sar-upload />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="item">
|
||||
<sar-tag theme="primary" mark size="large">
|
||||
2、装货照片
|
||||
</sar-tag>
|
||||
</view>
|
||||
|
||||
<view class="actions">
|
||||
<sar-button round>
|
||||
确定提交
|
||||
</sar-button>
|
||||
<view class="g3-footer">
|
||||
<view class="footer-main">
|
||||
<view class="submit-btn">
|
||||
确认上传
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.container {
|
||||
.g3-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.item {
|
||||
padding: 16rpx 0rpx;
|
||||
height: 100%;
|
||||
|
||||
.g3-content {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 16rpx 0rpx;
|
||||
}
|
||||
|
||||
.g3-footer {
|
||||
width: 100%;
|
||||
|
||||
.footer-main {
|
||||
padding: 16rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.actions {
|
||||
padding: 36rpx;
|
||||
margin-top: 32rpx;
|
||||
.step {
|
||||
margin-bottom: 32rpx;
|
||||
|
||||
.step-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
|
||||
.step-content {
|
||||
padding: 0rpx 32rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.box {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
.box-main {
|
||||
height: 326rpx;
|
||||
border: 1px dashed #ddd;
|
||||
border-radius: 16rpx;
|
||||
}
|
||||
|
||||
.box-placeholder {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
background-color: #ecedee;
|
||||
|
||||
.placeholder-text {
|
||||
color: #999;
|
||||
font-size: 28rpx;
|
||||
margin-top: 8rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.box-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
.delete-btn {
|
||||
position: absolute;
|
||||
top: 12rpx;
|
||||
right: 12rpx;
|
||||
|
||||
width: 44rpx;
|
||||
height: 44rpx;
|
||||
|
||||
border-radius: 50%;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
|
||||
color: #fff;
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
z-index: 10;
|
||||
}
|
||||
}
|
||||
|
||||
.box-input {
|
||||
margin-top: 16rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
font-size: 28rpx;
|
||||
margin-bottom: 12rpx;
|
||||
width: 100%;
|
||||
.format {
|
||||
color: #999;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.tip {
|
||||
color: #999;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.submit-btn {
|
||||
width: 100%;
|
||||
height: 72rpx;
|
||||
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
border-radius: 999px;
|
||||
|
||||
font-size: 30rpx;
|
||||
font-weight: 600;
|
||||
color: #fff;
|
||||
background: linear-gradient(135deg, #3a6ee8, #5c8df6);
|
||||
box-shadow: 0 6rpx 12rpx rgba(58, 110, 232, 0.18);
|
||||
transition: all 0.15s;
|
||||
}
|
||||
|
||||
.submit-btn:active {
|
||||
transform: scale(0.98);
|
||||
box-shadow: 0 3rpx 6rpx rgba(58, 110, 232, 0.15);
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user