修改
This commit is contained in:
@@ -1,34 +1,135 @@
|
||||
<template>
|
||||
<input
|
||||
class="filter_input"
|
||||
type="number"
|
||||
:value="value"
|
||||
:placeholder="placeholder"
|
||||
@input="onInput"
|
||||
@confirm="onInput"
|
||||
:value="displayValue"
|
||||
@input="handleInput"
|
||||
@blur="handleBlur"
|
||||
:class="inputClass"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "NumberInput",
|
||||
props: {
|
||||
value: {
|
||||
type: [Number, String],
|
||||
default: '',
|
||||
value: [Number, String],
|
||||
inputClass: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
// 输入模式:integer(纯整数), decimal(纯小数), mixed(混合)
|
||||
mode: {
|
||||
type: String,
|
||||
default: "mixed",
|
||||
validator: (v) => ["integer", "decimal", "mixed"].includes(v),
|
||||
},
|
||||
// 小数位数限制
|
||||
decimalLength: {
|
||||
type: Number,
|
||||
default: 2,
|
||||
},
|
||||
// 最小值
|
||||
min: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
// 最大值
|
||||
max: {
|
||||
type: Number,
|
||||
default: Infinity,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
displayValue: this.value?.toString() || "",
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
value(newVal) {
|
||||
this.displayValue = newVal?.toString() || "";
|
||||
},
|
||||
placeholder: String
|
||||
},
|
||||
methods: {
|
||||
onInput(event) {
|
||||
// 获取输入值
|
||||
const value = event.detail ? event.detail.value : event.target.value;
|
||||
// 格式化输入值
|
||||
let formattedValue = value.replace(/[^0-9.]/g, '')
|
||||
formattedValue = parseFloat(formattedValue)
|
||||
formattedValue = formattedValue > 0 ? formattedValue : ''
|
||||
this.$emit('input', formattedValue);
|
||||
event.target.value = formattedValue
|
||||
}
|
||||
handleInput(e) {
|
||||
let value = e.detail.value;
|
||||
|
||||
// 1. 过滤非法字符
|
||||
let filtered = value.replace(/[^\d.]/g, "");
|
||||
|
||||
// 2. 处理多余的小数点
|
||||
if (this.mode === "integer") {
|
||||
filtered = filtered.replace(/\./g, ""); // 整数模式删除所有小数点
|
||||
} else {
|
||||
const firstDotIndex = filtered.indexOf(".");
|
||||
if (firstDotIndex !== -1) {
|
||||
// 只保留第一个小数点
|
||||
filtered =
|
||||
filtered.substring(0, firstDotIndex + 1) +
|
||||
filtered.substring(firstDotIndex + 1).replace(/\./g, "");
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 处理前导0
|
||||
if (filtered.startsWith("0") && filtered.length > 1 && !filtered.startsWith("0.")) {
|
||||
filtered = filtered.replace(/^0+/, "0").replace(/^0([^.])/, "$1");
|
||||
}
|
||||
|
||||
// 4. 处理开头的小数点
|
||||
if (filtered.startsWith(".")) {
|
||||
if (this.mode === "integer") {
|
||||
filtered = "";
|
||||
} else {
|
||||
filtered = "0" + filtered;
|
||||
}
|
||||
}
|
||||
|
||||
this.displayValue = filtered;
|
||||
},
|
||||
|
||||
handleBlur() {
|
||||
let value = this.displayValue;
|
||||
|
||||
// 空值处理
|
||||
if (value === "" || value === ".") {
|
||||
this.$emit("input", "");
|
||||
return;
|
||||
}
|
||||
|
||||
// 处理结尾的小数点
|
||||
if (value.endsWith(".")) {
|
||||
value = value.slice(0, -1);
|
||||
}
|
||||
|
||||
// 转换为数字
|
||||
const numValue = Number(value);
|
||||
|
||||
// 小数位数处理
|
||||
let processedValue = value;
|
||||
if (this.mode !== "integer" && value.includes(".")) {
|
||||
const parts = value.split(".");
|
||||
if (parts[1].length > this.decimalLength) {
|
||||
processedValue = `${parts[0]}.${parts[1].slice(0, this.decimalLength)}`;
|
||||
}
|
||||
}
|
||||
|
||||
// 范围校验
|
||||
let finalNum = Number(processedValue);
|
||||
if (finalNum < this.min) finalNum = this.min;
|
||||
if (finalNum > this.max) finalNum = this.max;
|
||||
|
||||
// 更新值
|
||||
this.displayValue = finalNum.toString();
|
||||
this.$emit("input", finalNum);
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.number-input {
|
||||
border: 1px solid #ddd;
|
||||
padding: 8px 12px;
|
||||
border-radius: 4px;
|
||||
font-size: 14px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -9,15 +9,15 @@
|
||||
<span class="filter_label">载具编码</span>
|
||||
</view>
|
||||
<view class="zd-col-17">
|
||||
<search-box v-model="val2"/>
|
||||
<search-box v-model="val1"/>
|
||||
</view>
|
||||
</view>
|
||||
<view class="zd-row border-bottom">
|
||||
<view class="zd-col-7">
|
||||
<span class="filter_label">物料信息</span>
|
||||
<span class="filter_label">物料编码</span>
|
||||
</view>
|
||||
<view class="zd-col-17">
|
||||
<input type="text" class="filter_input" v-model="currentData.material_name" @tap="toJump">
|
||||
<input type="text" class="filter_input" v-model="currentData.material_code" @tap="toJump">
|
||||
</view>
|
||||
</view>
|
||||
<view class="zd-row border-bottom">
|
||||
@@ -36,43 +36,24 @@
|
||||
<input type="text" class="filter_input filter_input_disabled" v-model="currentData.material_spec" disabled>
|
||||
</view>
|
||||
</view>
|
||||
<view class="zd-row border-bottom">
|
||||
<view class="zd-col-7">
|
||||
<span class="filter_label filter_input_disabled">物料编码</span>
|
||||
</view>
|
||||
<view class="zd-col-17">
|
||||
<input type="text" class="filter_input filter_input_disabled" v-model="currentData.material_code" disabled>
|
||||
</view>
|
||||
</view>
|
||||
<view class="zd-row border-bottom">
|
||||
<view class="zd-col-7">
|
||||
<span class="filter_label">物料数量</span>
|
||||
</view>
|
||||
<view class="zd-col-17">
|
||||
<NumberInput v-model="currentData.qty" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="zd-row border-bottom">
|
||||
<view class="zd-col-7">
|
||||
<span class="filter_label">物料批次</span>
|
||||
</view>
|
||||
<view class="zd-col-17">
|
||||
<input type="text" class="filter_input" v-model="val3">
|
||||
</view>
|
||||
</view>
|
||||
<view class="zd-row border-bottom">
|
||||
<view class="zd-col-7">
|
||||
<span class="filter_label">源单编码</span>
|
||||
</view>
|
||||
<view class="zd-col-17">
|
||||
<search-box v-model="val1"/>
|
||||
<NumberInput
|
||||
v-model="qty"
|
||||
input-class="filter_input"
|
||||
mode="decimal"
|
||||
:decimalLength="3"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="zd-row submit-bar">
|
||||
<button class="zd-col-6 button-default" @tap="toEmpty">清空</button>
|
||||
<button class="zd-col-16 button-primary" :class="{'button-info': JSON.stringify(currentData) === '{}'}" :disabled="disabled" @tap="_groupPlate">组盘确认</button>
|
||||
<button class="zd-col-16 button-primary" :class="{'button-info': JSON.stringify(currentData) === '{}' || !val1 || !qty}" :disabled="disabled" @tap="_groupPlate">组盘确认</button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@@ -92,11 +73,8 @@
|
||||
return {
|
||||
title: '',
|
||||
val1: '',
|
||||
val2: '',
|
||||
val3: '',
|
||||
qty: null,
|
||||
currentData: {},
|
||||
options: [],
|
||||
index: '',
|
||||
disabled: false
|
||||
};
|
||||
},
|
||||
@@ -106,6 +84,7 @@
|
||||
onShow() {
|
||||
if (this.$store.getters.publicObj !== '') {
|
||||
this.currentData = this.$store.getters.publicObj
|
||||
this.qty = this.currentData.qty
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -116,19 +95,18 @@
|
||||
},
|
||||
toEmpty () {
|
||||
this.currentData = {}
|
||||
this.index = ''
|
||||
this.qty = null
|
||||
this.disabled = false
|
||||
this.$store.dispatch('setPublicObj', '')
|
||||
},
|
||||
async _groupPlate () {
|
||||
this.disabled = true
|
||||
if (JSON.stringify(this.currentData) === '{}') {
|
||||
if (JSON.stringify(this.currentData) === '{}' || !this.val1 || !this.qty) {
|
||||
this.disabled = false
|
||||
return
|
||||
}
|
||||
try {
|
||||
this.currentData.stor_code = this.index
|
||||
let res = await groupPlate(this.currentData.material_id, this.val3, this.currentData.qty, this.val2, this.val1)
|
||||
let res = await groupPlate(this.currentData.material_id, this.qty, this.val1)
|
||||
uni.showToast({
|
||||
title: res.message,
|
||||
icon: 'none'
|
||||
|
||||
@@ -8,13 +8,12 @@
|
||||
<view class="zd-col-7">
|
||||
<span class="filter_label">站点信息</span>
|
||||
</view>
|
||||
<view class="zd-col-12">
|
||||
<view class="zd-col-17">
|
||||
<search-box
|
||||
v-model="val2"
|
||||
@handleChange="handleChange"
|
||||
/>
|
||||
</view>
|
||||
<button class="mini-btn" type="primary" size="mini" style="margin-right: 0" @tap="_getVehicleMaterial(val2)">查询</button>
|
||||
</view>
|
||||
<view class="zd-row border-bottom">
|
||||
<view class="zd-col-7">
|
||||
@@ -119,9 +118,6 @@
|
||||
},
|
||||
selectChange (e) {
|
||||
this.index = e
|
||||
if (e) {
|
||||
this._getVehicleMaterial(e)
|
||||
}
|
||||
},
|
||||
handleChange (e) {
|
||||
if (e) {
|
||||
|
||||
@@ -39,9 +39,9 @@ export const getMaterialList = (search, page, size) => request({
|
||||
})
|
||||
|
||||
// 物料组盘确认
|
||||
export const groupPlate = (mid, pcsn, qty, vcode, ecode, siteCode) => request({
|
||||
export const groupPlate = (mid, qty, vcode) => request({
|
||||
url:'api/pda/iosIn/groupPlate',
|
||||
data: {material_id: mid, pcsn: pcsn, qty: qty, vehicle_code: vcode, ext_code: ecode, siteCode}
|
||||
data: {material_id: mid, qty: qty, vehicle_code: vcode}
|
||||
})
|
||||
|
||||
// 定点确认
|
||||
|
||||
Reference in New Issue
Block a user