增加小数类型出库

This commit is contained in:
bb_pan 2025-07-11 10:17:13 +08:00
parent 62c4993570
commit b31cb9aa72
4 changed files with 68 additions and 43 deletions

View File

@ -70,32 +70,43 @@ onMounted(async () => {
} catch (error) {
console.log(error)
uni.hideLoading()
showToast('登录失败')
// showToast('')
// :
uni.showModal({
title: '提示',
content: '登录失败, 请退出后重新登录',
showCancel: false,
confirmText: '确定',
})
}
}
})
//
const onHandleLogin = async () => {
const res = await appLoginAPI(loginForm)
if (res.code === 200) {
// 1. token
memberStore.setToken(res.data.access_token)
// 2 .
const result = await getUserInfoAPI()
console.log("xxxxxxxxxx",result)
memberStore.setUserInfo(result.user)
uni.showToast({ title: '登录成功!', icon: 'none' })
uni.setStorageSync('username', loginForm.username)
uni.setStorageSync('password', loginForm.password)
uni.setStorageSync('id', result.user.userId)
uni.setStorageSync('deptName', result.user?.dept?.deptName)
uni.setStorageSync('urlPermissions',result.urlPermissions?result.urlPermissions:[])
setTimeout(() => {
uni.switchTab({
url: '/pages/index/index',
})
}, 500)
try {
const res = await appLoginAPI(loginForm)
if (res.code === 200) {
// 1. token
memberStore.setToken(res.data.access_token)
// 2 .
const result = await getUserInfoAPI()
console.log("xxxxxxxxxx",result)
memberStore.setUserInfo(result.user)
uni.showToast({ title: '登录成功!', icon: 'none' })
uni.setStorageSync('username', loginForm.username)
uni.setStorageSync('password', loginForm.password)
uni.setStorageSync('id', result.user.userId)
uni.setStorageSync('deptName', result.user?.dept?.deptName)
uni.setStorageSync('urlPermissions',result.urlPermissions?result.urlPermissions:[])
setTimeout(() => {
uni.switchTab({
url: '/pages/index/index',
})
}, 500)
}
} catch (error) {
console.log('🚀 ~ onHandleLogin ~ error:', error)
}
}
</script>

View File

@ -98,7 +98,7 @@
v-model="item.preNum"
placeholder="请输入数量"
type="number"
@blur="checkPerNum(item)"
@change="checkPerNum(item)"
></uni-easyinput>
<!-- 编码 -->
<span v-else style="color: #409eff" @click="getCode(item)">{{
@ -308,16 +308,21 @@ const checkPhone = (rule, value, callback) => {
//
const checkPerNum = (item) => {
// 1
if (!/^[1-9]\d*$/.test(item.preNum)) {
uni.showToast({
icon: 'none',
title: '请输入正确的数量',
})
// 1
item.preNum = 1
return false
if (item.unitValue == 1) {
item.preNum = Number(String(item.preNum).replace(/[^\d.]/g, ''))
} else {
item.preNum = Number(String(item.preNum).replace(/[^\d]/g, ''))
}
// 1
// if (!/^[1-9]\d*$/.test(item.preNum)) {
// uni.showToast({
// icon: 'none',
// title: '',
// })
// // 1
// item.preNum = 1
// return false
// }
}
//
const changeTeamd = (e) => {
@ -352,7 +357,7 @@ const changeEquipment = (e) => {
// equipmentList.value id typeName
const equipment = findEquipmentById(equipmentList.value, e.parentId)
tableData.value.push({
tableData.value.unshift({
...JSON.parse(JSON.stringify(e)),
maTypeName: equipment.typeName,
preNum: e.manageType == '1' ? 1 : 0, // 退1

View File

@ -111,7 +111,7 @@
v-model="item.preNum"
placeholder="请输入数量"
type="number"
@blur="checkPerNum(item)"
@change="checkPerNum(item)"
></uni-easyinput>
<!-- 编码 -->
<span v-else style="color: #409eff" @click="getCode(item)">{{
@ -387,15 +387,20 @@ const checkPhone = (rule, value, callback) => {
//
const checkPerNum = (item) => {
// 1
if (!/^[1-9]\d*$/.test(item.preNum)) {
uni.showToast({
icon: 'none',
title: '请输入正确的数量',
})
// 1
item.preNum = 1
return false
if (item.unitValue == 1) {
item.preNum = Number(String(item.preNum).replace(/[^\d.]/g, ''))
} else {
item.preNum = Number(String(item.preNum).replace(/[^\d]/g, ''))
}
// if (!/^[1-9]\d*$/.test(item.preNum)) {
// uni.showToast({
// icon: 'none',
// title: '',
// })
// // 1
// item.preNum = 1
// return false
// }
if (opts.value.isOut) {
if (item.preNum > item.storageNum) {
uni.showToast({
@ -448,7 +453,7 @@ const changeEquipment = (e) => {
// equipmentList.value id typeName
const equipment = findEquipmentById(equipmentList.value, e.parentId)
tableData.value.push({
tableData.value.unshift({
...JSON.parse(JSON.stringify(e)),
storageNum: e.num,
maTypeName: equipment.typeName,

View File

@ -66,11 +66,15 @@ export const http = (options) => {
// 2. 401 表示token过期 去往登录页重新登录
uni.showToast({
icon: 'none',
title: `${res.data.msg}`,
title: `${res.data.msg || '账号已过期,请重新登录'}`,
})
const memberStore = useMemberStore()
memberStore.clearUserInfo()
memberStore.clearToken()
uni.removeStorageSync('idCard')
uni.removeStorageSync('id')
uni.removeStorageSync('deptName')
uni.removeStorageSync('urlPermissions')
const pages = getCurrentPages()
const currentPage = pages[pages.length - 1]
if (!currentPage.route.includes('login')) {
@ -82,7 +86,7 @@ export const http = (options) => {
} else if (res.data && res.data.code === 500) {
uni.showToast({
icon: 'none',
title: `${res.data.msg}`,
title: `${res.data.msg || '请求失败'}`,
})
reject(res)
} else {