numberinput

This commit is contained in:
2025-05-30 17:36:59 +08:00
parent c768b659f9
commit 0b888ad75e
6 changed files with 552 additions and 274 deletions

85
components/LimitInput.vue Normal file
View File

@@ -0,0 +1,85 @@
<template>
<div class="fxcol">
<input
class="filter-input i-border"
:disabled="disabled"
:type="type"
ref="input"
:value="numberValue"
:placeholder="placeholder"
oninput="value=value.replace(/[^\d.]/g,'')"
@input="handleChange"
/>
</div>
</template>
<script>
export default {
name: 'limitInput',
props: {
disabled: Boolean,
type: String,
placeholder: String,
value: '', // 传过来的值
max: Number,
min: Number,
defaultValue: '' // 默认值
},
data () {
return {
numberValue: this.value
}
},
watch: {
value (val) { // 监听传来的value值并传递给新定义的值
// debugger
this.numberValue = Number(val)
},
max (val) { // 因为最大值是根据上个值输入而变化的,所以要监听相应变化
this.max = val
},
min (val) { // 因为最小值是根据上个值输入而变化的,所以要监听相应变化
this.min = val
},
numberValue (val) { // emit input事件,可令父组件进行v-model绑定
this.$emit('input', val)
},
disabled (val) {
this.disabled = val
},
defaultValue (val) { // 要根据上面的值变化而相应变化,所以要监听
this.numberValue = val
}
},
methods: {
handleChange (event) {
let val = event.target.value.trim()
if (val < 0 || isNaN(val)) {
this.numberValue = 0
return
}
if (val) {
val = Number(val)
this.numberValue = val
if (val > Number(this.max)) this.numberValue = this.max
if (val < Number(this.min)) this.numberValue = this.min
} else {
this.numberValue = 0
}
}
},
mounted () {
if (this.defaultValue) {
this.numberValue = this.defaultValue
}
}
}
</script>
<style lang="stylus" scoped>
// input
// width 100%
.i-border
border 1px solid #a1a1a1
border-radius 3px
text-align center
</style>

123
components/NumberInput.vue Normal file
View File

@@ -0,0 +1,123 @@
<!-- components/number-input.vue -->
<template>
<input
type="text"
:value="displayValue"
@input="handleInput"
@blur="handleBlur"
:placeholder="placeholder"
:class="inputClass"
:style="inputStyle"
/>
</template>
<script>
export default {
name: "NumberInput",
props: {
value: {
type: [Number, String],
default: ''
},
min: {
type: Number,
default: 0.001
},
max: {
type: Number,
default: 100000
},
placeholder: {
type: String,
default: '请输入大于0的数字'
},
inputClass: {
type: String,
default: ''
},
inputStyle: {
type: String,
default: ''
}
},
data() {
return {
displayValue: this.value.toString()
};
},
watch: {
value(newVal) {
// 当外部value变化时更新显示值
this.displayValue = newVal.toString();
}
},
methods: {
handleInput(e) {
const rawValue = e.detail.value;
let filtered = rawValue
// 移除非数字和小数点的字符
.replace(/[^\d.]/g, '')
// 只保留第一个小数点
.replace(/(\.+)/g, '.')
.replace(/(\..*)\./g, '$1')
// 避免以0开头0后面没有小数点的情况
.replace(/^0+(\d)/, '$1');
// 处理开头是小数点的情况添加0前缀
if (filtered.startsWith('.')) {
filtered = '0' + filtered;
}
this.displayValue = filtered;
this.$emit('input', filtered);
},
handleBlur() {
let finalValue = this.displayValue;
// 空值处理
if (!finalValue) {
finalValue = this.min.toString();
}
// 处理以小数点结尾的情况
if (finalValue.endsWith('.')) {
finalValue = finalValue.slice(0, -1);
}
// 转换为数字
let numValue = parseFloat(finalValue);
// 验证数字有效性
if (isNaN(numValue)) {
numValue = this.min;
}
// 边界校验
if (numValue <= 0) {
numValue = this.min;
} else if (numValue > this.max) {
numValue = this.max;
} else if (numValue < this.min) {
numValue = this.min;
}
// 小数位处理最多3位
const numStr = numValue.toString();
const decimalIndex = numStr.indexOf('.');
if (decimalIndex !== -1) {
const decimalPart = numStr.slice(decimalIndex + 1);
if (decimalPart.length > 3) {
// 直接截断而非四舍五入
numValue = parseFloat(numStr.substring(0, decimalIndex + 4));
}
}
// 更新显示值并通知父组件
this.displayValue = numValue.toString();
this.$emit('input', numValue);
this.$emit('change', numValue);
}
}
}
</script>

View File

@@ -254,310 +254,326 @@
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/EmptyVehicleInStore",
,{
"path" : "pages/SecondPhase/EmptyVehicleInStore",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/EmptyBoxInStore",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/DeliveryUnbind",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/DeliveryUnbindConfirm",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/production/SboProdProgress",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/production/SboProcess",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/production/BakeProcess",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/production/ManmadeBake",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/production/SurfaceProcess",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/slitting/SlittingFeeding",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/slitting/ZjCasing",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/slitting/ZjDelivery",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/slitting/ZjInStore",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/slitting/ZjOutStore",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/point/PointManage",
,{
"path" : "pages/SecondPhase/EmptyBoxInStore",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/point/ErrorOutUnlock",
}
,{
"path" : "pages/SecondPhase/DeliveryUnbind",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/finished/ReturnToStore",
}
,{
"path" : "pages/SecondPhase/DeliveryUnbindConfirm",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/finished/abnorToStore",
}
,{
"path" : "pages/SecondPhase/production/SboProdProgress",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/slitting/SlittingCutting",
}
,{
"path" : "pages/SecondPhase/production/SboProcess",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/slitting/DoInitShaft",
}
,{
"path" : "pages/SecondPhase/production/BakeProcess",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/production/ZjCheck",
}
,{
"path" : "pages/SecondPhase/production/ManmadeBake",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/slitting/PaperBind",
}
,{
"path" : "pages/SecondPhase/production/SurfaceProcess",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/slitting/CacheCut",
}
,{
"path" : "pages/SecondPhase/slitting/SlittingFeeding",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/slitting/CacheClean",
}
,{
"path" : "pages/SecondPhase/slitting/ZjCasing",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/finished/BoxWeight",
}
,{
"path" : "pages/SecondPhase/slitting/ZjDelivery",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/slitting/ShaftSave",
}
,{
"path" : "pages/SecondPhase/slitting/ZjInStore",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/slitting/ZjSave",
}
,{
"path" : "pages/SecondPhase/slitting/ZjOutStore",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/slitting/StockingArea",
}
,{
"path" : "pages/SecondPhase/slitting/TubeStock",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/slitting/AGVPass",
}
,{
"path" : "pages/SecondPhase/slitting/TestNumInput",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/production/ZjContainer",
}
,{
"path" : "pages/SecondPhase/point/PointManage",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/lvt/EmptyBox",
}
,{
"path" : "pages/SecondPhase/point/ErrorOutUnlock",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/point/ManPass",
}
,{
"path" : "pages/SecondPhase/finished/ReturnToStore",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/production/PrintTable",
}
,{
"path" : "pages/SecondPhase/finished/abnorToStore",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/slitting/SubRollWeight",
}
,{
"path" : "pages/SecondPhase/slitting/SlittingCutting",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/slitting/UpperShaftCut",
}
,{
"path" : "pages/SecondPhase/slitting/DoInitShaft",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/ProductManage/AxisApply",
}
,{
"path" : "pages/SecondPhase/production/ZjCheck",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/slitting/UpperShaftCut2",
}
,{
"path" : "pages/SecondPhase/slitting/PaperBind",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/production/ZjInStore",
}
,{
"path" : "pages/SecondPhase/slitting/CacheCut",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/slitting/CacheClean",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/finished/BoxWeight",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/slitting/ShaftSave",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/slitting/ZjSave",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/slitting/StockingArea",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/slitting/AGVPass",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/production/ZjContainer",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/lvt/EmptyBox",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/point/ManPass",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/production/PrintTable",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/slitting/SubRollWeight",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/slitting/UpperShaftCut",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/ProductManage/AxisApply",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/slitting/UpperShaftCut2",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/production/ZjInStore",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/production/BoxStock",
@@ -566,143 +582,143 @@
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/slitting/CallShaft",
}
,{
"path" : "pages/SecondPhase/slitting/CallShaft",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/ProductManage/UnAxisBack",
}
,{
"path" : "pages/ProductManage/UnAxisBack",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/ProductManage/CallPaperShaft",
}
,{
"path" : "pages/ProductManage/CallPaperShaft",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/ProductManage/UpperShaftCut",
}
,{
"path" : "pages/ProductManage/UpperShaftCut",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/EmptyBoxOutStore",
}
,{
"path" : "pages/SecondPhase/EmptyBoxOutStore",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/SubRollPackUnbind",
}
,{
"path" : "pages/SecondPhase/SubRollPackUnbind",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/ProductManage/RemainShaftBack",
}
,{
"path" : "pages/ProductManage/RemainShaftBack",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/slitting/CallAxisSeq",
}
,{
"path" : "pages/SecondPhase/slitting/CallAxisSeq",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/slitting/SlittingCutting2",
}
,{
"path" : "pages/SecondPhase/slitting/SlittingCutting2",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/slitting/RollCacheManage",
}
,{
"path" : "pages/SecondPhase/slitting/RollCacheManage",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/ProductManage/RequestShaft",
}
,{
"path" : "pages/ProductManage/RequestShaft",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/ProductManage/ScanRoll",
}
,{
"path" : "pages/ProductManage/ScanRoll",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/BoxReturn",
}
,{
"path" : "pages/SecondPhase/BoxReturn",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/slitting/BaitRoll",
}
,{
"path" : "pages/SecondPhase/slitting/BaitRoll",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/slitting/EmptyAxisReturn",
}
,{
"path" : "pages/SecondPhase/slitting/EmptyAxisReturn",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/ManMaintain",
}
,{
"path" : "pages/SecondPhase/ManMaintain",
"style" :
{
"navigationStyle": "custom"
}
}
,{
"path" : "pages/SecondPhase/slitting/CacheSave",
}
,{
"path" : "pages/SecondPhase/slitting/CacheSave",
"style" :
{
"navigationStyle": "custom"
}
}
}
],
"globalStyle": {
// "pageOrientation": "landscape",

View File

@@ -0,0 +1,24 @@
<template>
<view class="container">
<number-input
v-model="numberValue"
:min="0.01"
:max="999.999"
input-class="filter_input"
/>
<text>当前值: {{ numberValue }}</text>
</view>
</template>
<script>
import NumberInput from '@/components/NumberInput.vue';
export default {
components: { NumberInput },
data() {
return {
numberValue: 1.0
};
}
};
</script>

View File

@@ -18,6 +18,20 @@
<uni-data-select v-model="index2" :localdata="options2" @change="selectChange2"></uni-data-select>
</view>
</view>
<view class="filter_item">
<view class="filter_label_wraper">
<span class="filter_label">子卷重量</span>
</view>
<view class="filter_input_wraper">
<!-- <input type="number" class="filter_input" v-model="val3"> -->
<number-input
v-model="numberValue"
:min="0"
:max="999.999"
input-class="filter_input"
/>
</view>
</view>
</view>
<view class="zd_wrapper grid-wraper">
<view class="slide_new">
@@ -62,14 +76,18 @@
<script>
import NavBar from '@/components/NavBar.vue'
import SearchBox from '@/components/SearchBox.vue'
import NumberInput from '@/components/NumberInput.vue'
import {showPapervehicleView, moveStock, queryProductArea, queryPaperMaterial} from '@/utils/getData4.js'
export default {
components: {
NavBar,
SearchBox
SearchBox,
NumberInput
},
data() {
return {
numberValue: 1,
// val3: '',
title: '',
top: 0,
options1: [],
@@ -150,4 +168,15 @@
}
}
}
</script>
</script>
<style>
.custom-input {
border: 1px solid #ccc;
border-radius: 4px;
/* padding: 8px 12px; */
font-size: 16px;
width: 100%;
height: 30px;
line-height: 30px;
}
</style>

View File

@@ -110,6 +110,7 @@ export const allAuthority = () => {
{menu_id: '8', title: '空轴绑定', path: '/pages/SecondPhase/slitting/EmptyAxisBind'},
{menu_id: '8', title: '空轴退回', path: '/pages/SecondPhase/slitting/EmptyAxisReturn'},
{menu_id: '8', title: '分切暂存维护', path: '/pages/SecondPhase/slitting/CacheSave'},
{menu_id: '8', title: '管芯备货', path: '/pages/SecondPhase/slitting/TubeStock'}
]},
{menu_id: '10', path: 'RF15', title: '打包间管理', sonTree: [
{menu_id: '1', title: '子卷包装解绑', path: '/pages/SecondPhase/SubRollPackUnbind'},