修改
This commit is contained in:
@@ -1,34 +1,135 @@
|
|||||||
<template>
|
<template>
|
||||||
<input
|
<input
|
||||||
class="filter_input"
|
|
||||||
type="number"
|
type="number"
|
||||||
:value="value"
|
:value="displayValue"
|
||||||
:placeholder="placeholder"
|
@input="handleInput"
|
||||||
@input="onInput"
|
@blur="handleBlur"
|
||||||
@confirm="onInput"
|
:class="inputClass"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
|
name: "NumberInput",
|
||||||
props: {
|
props: {
|
||||||
value: {
|
value: [Number, String],
|
||||||
type: [Number, String],
|
inputClass: {
|
||||||
default: '',
|
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: {
|
methods: {
|
||||||
onInput(event) {
|
handleInput(e) {
|
||||||
// 获取输入值
|
let value = e.detail.value;
|
||||||
const value = event.detail ? event.detail.value : event.target.value;
|
|
||||||
// 格式化输入值
|
// 1. 过滤非法字符
|
||||||
let formattedValue = value.replace(/[^0-9.]/g, '')
|
let filtered = value.replace(/[^\d.]/g, "");
|
||||||
formattedValue = parseFloat(formattedValue)
|
|
||||||
formattedValue = formattedValue > 0 ? formattedValue : ''
|
// 2. 处理多余的小数点
|
||||||
this.$emit('input', formattedValue);
|
if (this.mode === "integer") {
|
||||||
event.target.value = formattedValue
|
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>
|
</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>
|
<span class="filter_label">载具编码</span>
|
||||||
</view>
|
</view>
|
||||||
<view class="zd-col-17">
|
<view class="zd-col-17">
|
||||||
<search-box v-model="val2"/>
|
<search-box v-model="val1"/>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="zd-row border-bottom">
|
<view class="zd-row border-bottom">
|
||||||
<view class="zd-col-7">
|
<view class="zd-col-7">
|
||||||
<span class="filter_label">物料信息</span>
|
<span class="filter_label">物料编码</span>
|
||||||
</view>
|
</view>
|
||||||
<view class="zd-col-17">
|
<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>
|
</view>
|
||||||
<view class="zd-row border-bottom">
|
<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>
|
<input type="text" class="filter_input filter_input_disabled" v-model="currentData.material_spec" disabled>
|
||||||
</view>
|
</view>
|
||||||
</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-row border-bottom">
|
||||||
<view class="zd-col-7">
|
<view class="zd-col-7">
|
||||||
<span class="filter_label">物料数量</span>
|
<span class="filter_label">物料数量</span>
|
||||||
</view>
|
</view>
|
||||||
<view class="zd-col-17">
|
<view class="zd-col-17">
|
||||||
<NumberInput v-model="currentData.qty" />
|
<NumberInput
|
||||||
</view>
|
v-model="qty"
|
||||||
</view>
|
input-class="filter_input"
|
||||||
<view class="zd-row border-bottom">
|
mode="decimal"
|
||||||
<view class="zd-col-7">
|
:decimalLength="3"
|
||||||
<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"/>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="zd-row submit-bar">
|
<view class="zd-row submit-bar">
|
||||||
<button class="zd-col-6 button-default" @tap="toEmpty">清空</button>
|
<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>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
@@ -92,11 +73,8 @@
|
|||||||
return {
|
return {
|
||||||
title: '',
|
title: '',
|
||||||
val1: '',
|
val1: '',
|
||||||
val2: '',
|
qty: null,
|
||||||
val3: '',
|
|
||||||
currentData: {},
|
currentData: {},
|
||||||
options: [],
|
|
||||||
index: '',
|
|
||||||
disabled: false
|
disabled: false
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -106,6 +84,7 @@
|
|||||||
onShow() {
|
onShow() {
|
||||||
if (this.$store.getters.publicObj !== '') {
|
if (this.$store.getters.publicObj !== '') {
|
||||||
this.currentData = this.$store.getters.publicObj
|
this.currentData = this.$store.getters.publicObj
|
||||||
|
this.qty = this.currentData.qty
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -116,19 +95,18 @@
|
|||||||
},
|
},
|
||||||
toEmpty () {
|
toEmpty () {
|
||||||
this.currentData = {}
|
this.currentData = {}
|
||||||
this.index = ''
|
this.qty = null
|
||||||
this.disabled = false
|
this.disabled = false
|
||||||
this.$store.dispatch('setPublicObj', '')
|
this.$store.dispatch('setPublicObj', '')
|
||||||
},
|
},
|
||||||
async _groupPlate () {
|
async _groupPlate () {
|
||||||
this.disabled = true
|
this.disabled = true
|
||||||
if (JSON.stringify(this.currentData) === '{}') {
|
if (JSON.stringify(this.currentData) === '{}' || !this.val1 || !this.qty) {
|
||||||
this.disabled = false
|
this.disabled = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
this.currentData.stor_code = this.index
|
let res = await groupPlate(this.currentData.material_id, this.qty, this.val1)
|
||||||
let res = await groupPlate(this.currentData.material_id, this.val3, this.currentData.qty, this.val2, this.val1)
|
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: res.message,
|
title: res.message,
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
|
|||||||
@@ -8,13 +8,12 @@
|
|||||||
<view class="zd-col-7">
|
<view class="zd-col-7">
|
||||||
<span class="filter_label">站点信息</span>
|
<span class="filter_label">站点信息</span>
|
||||||
</view>
|
</view>
|
||||||
<view class="zd-col-12">
|
<view class="zd-col-17">
|
||||||
<search-box
|
<search-box
|
||||||
v-model="val2"
|
v-model="val2"
|
||||||
@handleChange="handleChange"
|
@handleChange="handleChange"
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
<button class="mini-btn" type="primary" size="mini" style="margin-right: 0" @tap="_getVehicleMaterial(val2)">查询</button>
|
|
||||||
</view>
|
</view>
|
||||||
<view class="zd-row border-bottom">
|
<view class="zd-row border-bottom">
|
||||||
<view class="zd-col-7">
|
<view class="zd-col-7">
|
||||||
@@ -119,9 +118,6 @@
|
|||||||
},
|
},
|
||||||
selectChange (e) {
|
selectChange (e) {
|
||||||
this.index = e
|
this.index = e
|
||||||
if (e) {
|
|
||||||
this._getVehicleMaterial(e)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
handleChange (e) {
|
handleChange (e) {
|
||||||
if (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',
|
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