数量选择编码

This commit is contained in:
bb_pan 2025-07-03 19:15:03 +08:00
parent c2d716bb99
commit 663a51e2a5
5 changed files with 874 additions and 27 deletions

View File

@ -183,6 +183,12 @@
"navigationBarTitleText": "数量出库"
}
},
{
"path": "pages/picking/outbound/numCodeSelect",
"style": {
"navigationBarTitleText": "编码选择"
}
},
// 1.
{

View File

@ -37,6 +37,12 @@
@input="onChangeNumber"
/>
</uni-forms-item>
<uni-forms-item label="出库数量:">
<div style="display: flex; align-items: center">
<button type="primary" size="mini" @click="onSelectCode">编码选择</button>
<div style="margin-left: 10px">已选 {{ maCodeList.length }} 个编码</div>
</div>
</uni-forms-item>
</uni-forms>
<view class="outbound-btn" @tap="onHandleOutbound"> 出库 </view>
@ -46,14 +52,13 @@
<script setup>
import { computed, ref } from 'vue'
import { setOutboundNumAPI } from '@/services/picking/outbound.js'
import { onLoad } from '@dcloudio/uni-app'
import { setOutboundNumAPI, leaseOutByInfoApi } from '@/services/picking/outbound.js'
import { onLoad, onShow } from '@dcloudio/uni-app'
const loading = ref(false)
const formData = ref({})
const outboundNum = ref(0)
// const query = defineProps() //
// const queryParams = JSON.parse(query.queryParams)
const queryParams = ref({})
const maCodeList = ref([])
//
const maxNum = computed(() => {
@ -64,12 +69,35 @@ const maxNum = computed(() => {
return queryParams.value.storageNum > waitNum ? waitNum : queryParams.value.storageNum
})
onShow(() => {
uni.$on('maCodeList', (data) => {
console.log('🚀 ~ uni.$on ~ data:', data)
maCodeList.value = data.maCodeList || []
// const maxOutboundNum = queryParams.value.preNum - queryParams.value.alNum
// if (maCodeList.value.length > maxOutboundNum) {
// maCodeList.value = maCodeList.value.slice(0, maxOutboundNum)
// }
// console.log(' maCodeList:', maCodeList.value)
})
})
onLoad((options) => {
queryParams.value = options.queryParams ? JSON.parse(options.queryParams) : {}
outboundNum.value = queryParams.value.preNum - queryParams.value.alNum
console.log("xxxxxxxxxxxxxx", queryParams.value)
console.log('xxxxxxxxxxxxxx', queryParams.value)
})
//
const onSelectCode = () => {
uni.navigateTo({
url: `/pages/picking/outbound/numCodeSelect?queryParams=${JSON.stringify({
...queryParams.value,
maCodeList: maCodeList.value,
})}`,
})
}
// change
const onChangeNumber = (e) => {
// outboundNum.value
@ -101,13 +129,20 @@ const onHandleOutbound = async () => {
})
return
}
if(outboundNum.value > queryParams.value.storageNum) {
if (outboundNum.value > queryParams.value.storageNum) {
uni.showToast({
title: '出库数量不能大于库存数量',
icon: 'none',
})
return
}
if (maCodeList.value.length > 0 && maCodeList.value.length != outboundNum.value) {
uni.showToast({
title: `已选编码数量(${maCodeList.value.length})与出库数量(${outboundNum.value})不一致`,
icon: 'none',
})
return
}
if (loading.value) {
uni.showToast({
@ -134,11 +169,20 @@ const onHandleOutbound = async () => {
inputNum: outboundNum.value,
leaseType: 0,
outNum: preNum,
publishTask:queryParams.value.publishTask,
publishTask: queryParams.value.publishTask,
leaseProject: queryParams.value.leaseProject,
leaseUnit: queryParams.value.leaseUnit,
maCodeList: maCodeList.value,
}
console.log('出库参数', params)
try {
const res = await setOutboundNumAPI({ leaseOutDetailsList: [params] })
let res = null
if (maCodeList.value.length > 0) {
res = await leaseOutByInfoApi({ leaseOutDetailsList: [params] })
} else {
res = await setOutboundNumAPI({ leaseOutDetailsList: [params] })
}
console.log('出库结果', res)
loading.value = false
uni.hideLoading()
@ -197,9 +241,9 @@ const onHandleOutbound = async () => {
.uni-forms-item__content {
display: flex;
align-items: center;
align-items: flex-end;
min-height: unset;
justify-content: flex-start;
justify-content: center;
}
.form-view {
@ -208,7 +252,7 @@ const onHandleOutbound = async () => {
font-weight: 500;
line-height: 1.8;
text-align: left;
justify-content: flex-start;
justify-content: center;
}
//

View File

@ -0,0 +1,731 @@
<template>
<!-- 编码出库-->
<view class="page-container">
<!-- 表单信息区域 -->
<scroll-view scroll-y style="height: 100vh">
<view class="form-section">
<view class="section-header" @tap="toggleForm">
<text class="title">任务信息</text>
<text class="toggle-icon" :class="{ 'is-expanded': isExpanded }"></text>
</view>
<view class="form-content" :class="{ 'is-expanded': isExpanded }">
<uni-forms :model="formData" label-width="100" :border="true">
<uni-forms-item label="领料单位:" name="leaseUnit">
<span class="form-view">{{ queryParams.leaseUnit }}</span>
</uni-forms-item>
<uni-forms-item label="领料工程:" name="leaseProject">
<span class="form-view">{{ queryParams.leaseProject }}</span>
</uni-forms-item>
<uni-forms-item label="物资类型:" name="maTypeName">
<span class="form-view">{{ queryParams.maTypeName }}</span>
</uni-forms-item>
<uni-forms-item label="规格型号:" name="typeName">
<span class="form-view">{{ queryParams.typeName }}</span>
</uni-forms-item>
<uni-forms-item label="待出库数量:" name="maxNum">
<span class="form-view">{{ maxNum }}</span>
</uni-forms-item>
</uni-forms>
</view>
</view>
<view class="table-list-item">
<uni-row :gutter="24" style="display: flex; align-items: center">
<uni-col :span="6">出库方式</uni-col>
<!-- <uni-col :span="6">
<view class="coding-btn" @tap="onCodeIdentify">编码识别</view>
</uni-col>
-->
<uni-col :span="6">
<view class="coding-btn" @tap="scanStart">二维码添加</view>
</uni-col>
<uni-col :span="6">
<view class="coding-btn" @tap="boxScan">标准箱添加</view>
</uni-col>
</uni-row>
</view>
<ScanQrCode
ref="scanQrCodeRef"
@scanSuccess="handleScanSuccess"
@scanError="handleScanError"
/>
<ScanQrCodeBox
ref="scanQrCodeRefBox"
@scanSuccessBox="handleScanSuccessBox"
@scanErrorBox="handleScanErrorBox"
/>
<view class="table-list-item">
<uni-row :gutter="24" style="display: flex; align-items: center">
<uni-col :span="6">
<view> 设备编码 </view>
</uni-col>
<uni-col :span="12">
<view>
<uni-easyinput
v-model="queryCodeParams.maCode"
placeholder="请输入内容"
/>
</view>
</uni-col>
<uni-col :span="6">
<view class="coding-btn search-btn" @tap="onCodeSearch">编码检索</view>
</uni-col>
</uni-row>
</view>
<scroll-view
scroll-y
@scrolltolower="onScrollTolower"
style="padding-bottom: 90rpx; height: 70vh"
>
<view class="table-list-item" v-for="item in codeDeviceList" :key="item.maId">
<uni-row :gutter="24">
<uni-col :span="6">物资类型</uni-col>
<uni-col :span="14">
<view class="cont">{{ item.materialName }}</view>
</uni-col>
<uni-col :span="4">
<checkbox-group @change="onChangeChecked(item)">
<label>
<checkbox
color="#409eff"
borderColor="#409eff"
activeBorderColor="#409eff"
:checked="item.checked"
:disabled="maxNum === isSelectNum && !item.checked"
style="transform: scale(0.7)"
/>
</label>
</checkbox-group>
</uni-col>
</uni-row>
<uni-row :gutter="24">
<uni-col :span="6">规格型号</uni-col>
<uni-col :span="16">
<view class="cont">{{ item.materialModel }}</view>
</uni-col>
</uni-row>
<uni-row :gutter="24">
<uni-col :span="6">设备编码</uni-col>
<uni-col :span="16">
<view class="cont">{{ item.maCode }}</view>
</uni-col>
</uni-row>
<uni-row :gutter="24">
<uni-col :span="6">设备状态</uni-col>
<uni-col :span="16">
<view class="cont">{{ item.maStatus }}</view>
</uni-col>
</uni-row>
<uni-row :gutter="24">
<uni-col :span="6">设备数量</uni-col>
<uni-col :span="16">
<view class="cont">1</view>
</uni-col>
</uni-row>
</view>
<view class="loading-text">
{{ '没有更多数据了~' }}
</view>
</scroll-view>
</scroll-view>
<view class="outbound-btn" @tap="onHandleOutbound"> 添加编码 </view>
</view>
</template>
<script setup>
import { ref, computed, onUnmounted } from 'vue'
import { onLoad, onShow } from '@dcloudio/uni-app'
import {
getCodeDetailAPI,
getCodeDeviceListAPI,
setOutboundNumAPI,
getCodeScanAPI,
getInfoByTypeId,
getBoxDetailsAPI,
} from '@/services/picking/outbound.js'
import { getBoxBindByCode } from '@/services/standard.js'
import { debounce } from 'lodash-es'
import ScanQrCode from '@/pages/devicesSearch/ScanQrCode.vue'
import ScanQrCodeBox from '@/pages/devicesSearch/ScanQrCodeBox.vue'
const loading = ref(false)
const scanQrCodeRef = ref(null)
const scanQrCodeRefBox = ref(null)
const queryParams = ref({})
const formData = ref({})
const codeDeviceList = ref([])
const maxNum = ref(0)
const total = ref(0)
const boxCode = ref('')
const boxInfo = ref({})
//
const queryCodeParams = ref({
pageNum: 1,
pageSize: 10,
typeId: '',
})
const qrCodeScan = ref('')
const codeData = ref({})
//
const isExpanded = ref(false)
//
const toggleForm = () => {
isExpanded.value = !isExpanded.value
}
//
onLoad((options) => {
console.log(queryParams.value)
queryParams.value = JSON.parse(options.queryParams)
})
onShow(() => {
console.log(queryParams.value)
getCodeDetailData(queryParams.value.id, queryParams.value.publishTask, queryParams.value.typeId) //
})
//
const getCodeDetailData = async (id, publishTask, typeId) => {
console.log('yyyyyyyyyy', id, publishTask, typeId)
const res = await getCodeDetailAPI({ id: id, publishTask: publishTask, typeId: typeId })
console.log('zzzzzzzzz', res)
formData.value = res.data
console.log('xxxxxxxxxxxxxx', formData.value, maxNum.value)
maxNum.value = formData.value.preNum - formData.value.alNum
queryCodeParams.value.typeId = queryParams.value.typeId
queryCodeParams.value.pageNum = 1
codeDeviceList.value = []
getCodeDeviceListData() //
}
//
const getCodeDeviceListData = async () => {
// ID
const res = await getInfoByTypeId(queryCodeParams.value)
codeDeviceList.value = res.data
if (queryParams.value.maCodeList.length > 0) {
const checkedIds = queryParams.value.maCodeList.map((e) => e.maId)
codeDeviceList.value.forEach((item) => {
item.checked = checkedIds.includes(item.maId)
})
} else {
codeDeviceList.value.forEach((item) => {
item.checked = false
})
}
}
//
const onCodeSearch = () => {
queryCodeParams.value.pageNum = 1
codeDeviceList.value = []
getCodeDeviceListData()
}
//
const onScrollTolower = debounce(() => {
// console.log('--')
}, 500)
// <EFBFBD><EFBFBD>
const finish = computed(() => {
if (total.value === codeDeviceList.value.length) return true
})
//
const onChangeChecked = (item) => {
item.checked = !item.checked
}
//
const isSelectNum = computed(() => {
const isSelectList = codeDeviceList.value.filter((e) => e.checked === true)
if (maxNum.value === isSelectList.length) {
uni.showToast({
title: '勾选设备已达到最大待出库数量!',
icon: 'none',
})
}
return isSelectList.length
})
//
const onHandleOutbound = async () => {
const isSelect = codeDeviceList.value.some((e) => e.checked === true)
if (!isSelect) {
uni.showToast({
title: '请添加编码',
icon: 'none',
})
return
}
if (loading.value) {
uni.showToast({
title: '请勿重复提交!',
icon: 'none',
})
return
}
loading.value = true
//
const maCodeList = []
codeDeviceList.value.map((e) => {
if (e.checked) {
maCodeList.push({
maId: e.maId,
maCode: e.maCode,
typeId: queryParams.value.typeId,
})
}
})
console.log('maCodeList', maCodeList)
uni.$emit('maCodeList', { maCodeList })
uni.navigateBack()
}
//
const boxScan = async () => {
if (maxNum.value == 0) {
uni.showToast({
title: '待出库数量已为0',
icon: 'none',
})
} else {
boxCode.value = ''
if (scanQrCodeRefBox.value) {
scanQrCodeRefBox.value.scanQrCode()
}
}
}
//
const handleScanSuccessBox = (result) => {
boxCode.value = result?.text || ''
if (boxCode.value === '') {
uni.showToast({ title: '扫码识别失败', icon: 'none' })
} else {
boxOut()
}
}
//
const handleScanErrorBox = (error) => {
console.error('扫描出错:', error.message)
uni.showToast({ title: error.message, icon: 'none' })
}
//
const boxOut = async () => {
console.log(queryParams)
try {
const res = await getBoxDetailsAPI({ boxCode: 'BOX-20250220221725' })
console.log('🚀 ~ boxOut ~ res:', res)
if (res.code === 200 && res.data && res.data.length > 0) {
const maCodeList = res.data.map((item) => ({
maId: item.maId,
maCode: item.maCode,
typeId: queryParams.value.typeId,
}))
uni.$emit('maCodeList', { maCodeList })
uni.navigateBack()
}
} catch (error) {
console.log('🚀 ~ boxOut ~ error:', error)
}
}
//
const boxOutBound = async () => {
//
const { typeId, parentId } = queryParams.value
//
const paramsList = []
boxInfo.value.recordList.map((e) => {
paramsList.push({
leaseType: 0,
boxId: e.boxId,
maId: e.maId,
maCode: e.maCode,
manageType: 0,
outType: 3, // 0123
outNum: 1,
parentId,
typeId,
})
})
console.log(paramsList)
const res = await setOutboundNumAPI({ leaseOutDetailsList: paramsList })
if (res.code === 200) {
uni.showToast({
title: '出库成功!',
icon: 'none',
})
getCodeDetailData(
queryParams.value.id,
queryParams.value.publishTask,
queryParams.value.typeId,
) //
}
}
//
const onCodeIdentify = () => {
console.log('编码识别--')
if (maxNum.value == 0) {
uni.showToast({
title: '待出库数量已为0',
icon: 'none',
})
} else {
uni.navigateTo({
url: `/pages/picking/outbound/codeOutScan?queryParams=${JSON.stringify(
queryParams.value,
)}`,
})
}
}
//
const scanStart = () => {
if (maxNum.value == 0) {
uni.showToast({
title: '待出库数量已为0',
icon: 'none',
})
} else {
if (scanQrCodeRef.value) {
scanQrCodeRef.value.scanQrCode()
}
}
}
//
const handleScanSuccess = (result) => {
qrCodeScan.value = result?.text?.split('?qrcode=')[1] || result?.text
if (qrCodeScan.value === '') {
uni.showToast({ title: '扫码识别失败', icon: 'none' })
} else {
getMaInfoScan()
}
}
//
const handleScanError = (error) => {
console.error('扫描出错:', error.message)
uni.showToast({ title: error.message, icon: 'none' })
}
//
const getMaInfoScan = async () => {
let param = {
qrCode: qrCodeScan.value,
}
const res = await getCodeScanAPI(param)
console.log(res)
if (res.code == 200) {
if (res.data && res.data.recordList.length > 0) {
codeData.value = res.data.recordList[0]
confirmCodeOutBound()
} else {
uni.showToast({ title: res.data.msg, icon: 'none' })
}
} else {
uni.showToast({ title: res.data.msg, icon: 'none' })
}
}
//
const confirmCodeOutBound = async () => {
//
const { typeId, parentId } = queryParams.value
//
const paramsList = []
paramsList.push({
leaseType: 0,
maId: codeData.value.maId,
maCode: codeData.value.maCode,
manageType: 0,
// 0123
outType: 2,
outNum: 1,
parentId,
typeId,
typeName: codeData.value.typeName,
typeModelName: codeData.value.typeModelName,
})
const res = await setOutboundNumAPI({ leaseOutDetailsList: paramsList })
console.log('333333333333', res)
if (res.code === 200) {
uni.showToast({
title: '出库成功!',
icon: 'none',
})
getCodeDetailData(
queryParams.value.id,
queryParams.value.publishTask,
queryParams.value.typeId,
) //
setTimeout(() => {
scanStart()
}, 800)
}
}
</script>
<style lang="scss" scoped>
.page-container {
display: flex;
height: 100%;
flex-direction: column;
background-color: #f7f8fa;
padding: 24rpx;
.table-list-item {
background: #fff;
padding: 15rpx 32rpx;
border-radius: 20rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.06);
margin-bottom: 24rpx;
//
:deep(.uni-forms) {
.uni-forms-item {
margin-bottom: 24rpx;
padding: 0;
&:last-child {
margin-bottom: 0;
}
.uni-forms-item__label {
color: #8c8c8c;
font-size: 28rpx;
font-weight: 500;
padding: 0;
line-height: 1.8;
}
.uni-forms-item__content {
display: flex;
align-items: center;
min-height: unset;
}
}
}
//
.coding-btn {
padding: 16rpx 0;
background: linear-gradient(135deg, #4b8eff 0%, #3784fb 100%);
border-radius: 12rpx;
text-align: center;
color: #fff;
font-size: 28rpx;
font-weight: 600;
box-shadow: 0 6rpx 20rpx rgba(55, 132, 251, 0.2);
transition: all 0.3s ease;
&:active {
transform: scale(0.98);
opacity: 0.9;
}
//
&.search-btn {
padding: 12rpx 0;
background: #fff;
color: #ff9800;
border: 2rpx solid rgba(255, 152, 0, 0.5);
background: linear-gradient(
to bottom,
rgba(255, 152, 0, 0.05),
rgba(255, 152, 0, 0.1)
);
box-shadow: none;
font-weight: 600;
letter-spacing: 1rpx;
&:active {
background: rgba(255, 152, 0, 0.15);
border-color: rgba(255, 152, 0, 0.6);
transform: translateY(1rpx);
}
}
}
//
:deep(.uni-row) {
// margin-bottom: 20rpx;
&:last-child {
margin-bottom: 0;
}
.uni-col-6 {
color: #8c8c8c;
font-size: 28rpx;
font-weight: 500;
}
.cont {
color: #262626;
font-size: 28rpx;
font-weight: 500;
line-height: 1.8;
}
}
//
:deep(.uni-easyinput__content) {
background-color: #f7f8fa;
border: 2rpx solid #e8e8e8;
border-radius: 12rpx;
height: 75rpx;
transition: all 0.3s ease;
&:focus-within {
border-color: #3784fb;
box-shadow: 0 0 0 2rpx rgba(55, 132, 251, 0.1);
}
.uni-easyinput__content-input {
font-size: 28rpx;
color: #262626;
}
}
//
:deep(checkbox) {
.wx-checkbox-input {
width: 36rpx;
height: 36rpx;
border-radius: 8rpx;
border: 2rpx solid #e8e8e8;
background: transparent;
&.wx-checkbox-input-checked {
background: #3784fb;
border-color: #3784fb;
&::before {
font-size: 28rpx;
color: #fff;
}
}
&.wx-checkbox-input-disabled {
background: #f5f5f5;
border-color: #e8e8e8;
}
}
}
}
//
.outbound-btn {
position: fixed;
bottom: 40rpx;
left: 50%;
transform: translateX(-50%);
width: 90%;
height: 88rpx;
background: linear-gradient(135deg, #4b8eff 0%, #3784fb 100%);
text-align: center;
line-height: 88rpx;
color: #fff;
border-radius: 12rpx;
font-size: 32rpx;
font-weight: 600;
box-shadow: 0 6rpx 20rpx rgba(55, 132, 251, 0.2);
transition: all 0.3s ease;
&:active {
transform: translateX(-50%) scale(0.98);
opacity: 0.9;
}
}
}
//
.loading-text {
text-align: center;
font-size: 26rpx;
color: #8c8c8c;
padding: 32rpx 0;
letter-spacing: 1rpx;
}
.form-section {
background: #fff;
border-radius: 20rpx;
margin-bottom: 24rpx;
overflow: hidden;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.06);
//
.section-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 24rpx 32rpx;
background: #fff;
cursor: pointer;
transition: all 0.3s ease;
&:active {
background: #f7f8fa;
}
.title {
font-size: 32rpx;
font-weight: 600;
color: #262626;
}
.toggle-icon {
font-size: 40rpx;
color: #8c8c8c;
transform: rotate(90deg);
transition: transform 0.3s ease;
display: inline-block;
&.is-expanded {
transform: rotate(-90deg);
}
}
}
//
.form-content {
max-height: 0;
overflow: hidden;
transition: max-height 0.3s ease-out;
&.is-expanded {
max-height: 1000rpx; //
}
:deep(.uni-forms) {
padding: 0 32rpx 32rpx;
}
:deep(.uni-forms-item) {
margin-bottom: 24rpx;
&:last-child {
margin-bottom: 0;
}
.uni-forms-item__label {
color: #8c8c8c;
}
.form-view {
color: #262626;
font-size: 28rpx;
}
}
}
}
</style>

View File

@ -9,14 +9,18 @@
<uni-forms-item label="机具规格:" name="maModel" required>
<select-one style="width: 100%; height: 90rpx" :options="maModelList" placeholder="请选择机具规格"
:key="new Date()" @change="onMaModelChange" @clear="onMaModelClear" />
:key="maName" @change="onMaModelChange" @clear="onMaModelClear" />
</uni-forms-item>
<uni-forms-item label="机具编码:" name="maCode" required>
<uni-easyinput v-model="maCode" maxlength="30" placeholder="请输入机具编码" />
<div style="display: flex; justify-content: space-between; align-items: center;">
<uni-easyinput v-model="prefix" maxlength="30" placeholder="前缀"/>
<span style="margin: 0 10rpx;"> - </span>
<uni-easyinput type="number" v-model="postfix" maxlength="30" placeholder="后缀"/>
</div>
</uni-forms-item>
<uni-forms-item label="出厂厂家:" name="supplier" required>
<select-one style="width: 100%; height: 90rpx" :options="supplierList" placeholder="请选择出厂厂家"
:key="new Date()" @change="onSupplierChange" @clear="onSupplierClear" />
:key="supplier" @change="onSupplierChange" @clear="onSupplierClear" />
</uni-forms-item>
<uni-forms-item label="检修员:" name="repairMan" required>
@ -33,6 +37,18 @@
</uni-forms>
</div>
<div class="card">
<div style="display: flex; justify-content: space-between; align-items: center">
<button type="primary" size="mini" @click="handleFillCode" style="margin-right: 10px;">填充编码</button>
<!-- 填充数量 -->
<uni-easyinput type="number" v-model="fillNum" maxlength="30" placeholder="请输入填充数量" @blur="handleFillNumBlur" />
</div>
<div style="display: flex; flex-wrap: wrap; justify-content: flex-start;max-height: 200px; overflow-y: auto">
<div v-for="(item, index) in maCode" :key="index" style="margin-right: 10px;">{{ item }}</div>
</div>
</div>
<div class="btn">
<button class="btn-cont" @click="clearForm">清空</button>
<button class="btn-cont" @click="confirmAdd">确认</button>
@ -57,7 +73,7 @@
const maName = ref('') //
const maModel = ref('') //
const maCode = ref('') //
const maCode = ref([]) //
const supplier = ref('') //
const repairMan = ref('王鹏') //
const checkMan = ref('高民') //
@ -66,17 +82,49 @@
const maNameList = ref([]) //
const maModelList = ref([]) //
const supplierList = ref([]) //
const prefix = ref()
const postfix = ref()
const fillNum = ref(1) //
//
const clearForm = () => {
maName.value = ''
maModel.value = ''
maCode.value = ''
maCode.value = []
supplier.value = ''
repairMan.value = ''
checkMan.value = ''
phone.value = ''
}
//
const handleFillCode = () => {
if (!prefix.value || !postfix.value) {
uni.showToast({
title: '请填写编码前缀和后缀',
icon: 'none'
})
return
}
const prefixValue = prefix.value.trim()
const postfixValue = postfix.value.trim()
const fillNumValue = fillNum.value
const codeList = []
const startNum = parseInt(postfixValue, 10)
const padLen = postfixValue.length
for (let i = 0; i < fillNumValue; i++) {
const num = String(startNum + i).padStart(padLen, '0')
codeList.push(`${prefixValue}${num}`)
}
maCode.value = codeList
console.log('🚀 ~ handleFillCode ~ maCode.value:', maCode.value)
}
const handleFillNumBlur = () => {
//
fillNum.value = Math.ceil(String(fillNum.value).replace(/[^\d]/g, ''))
}
const onMaNameChange = (item) => {
maName.value = item.label;
maModel.value = null; //
@ -159,7 +207,7 @@
icon: 'none'
})
}
if (!maCode.value) {
if (maCode.value.length === 0) {
return uni.showToast({
title: '请输入机具编码',
icon: 'none'
@ -193,7 +241,7 @@
const postData = {
maName: maName.value,
maModel: maModel.value,
maCode: maCode.value,
maCodeList: maCode.value,
supplier: supplier.value,
repairMan: repairMan.value,
checkMan: checkMan.value,
@ -210,18 +258,9 @@
})
clearForm()
uni.navigateBack()
} else {
uni.showToast({
title: res.msg || '新增失败',
icon: 'none'
})
}
} catch (error) {
console.error(error)
uni.showToast({
title: '请求失败,请稍后重试',
icon: 'none'
})
}
}
onLoad(() => {

View File

@ -100,3 +100,30 @@ export const leaseOutBackApi = (data) => {
data,
})
}
// 数量编码查询
export const getInfoByTypeId = (data) => {
return http({
method: 'GET',
url: '/material/ma_machine/getInfoByTypeId',
data,
})
}
// 数量编码出库
export const leaseOutByInfoApi = (data) => {
return http({
method: 'POST',
url: '/material/lease_apply_info/leaseOutByInfo',
data,
})
}
// 标准箱详情
export const getBoxDetailsAPI = (data) => {
return http({
method: 'GET',
url: '/material/bm_qrcode_box/getBoxDetails',
data,
})
}