114
This commit is contained in:
@@ -36,10 +36,10 @@
|
|||||||
this.focusState = true
|
this.focusState = true
|
||||||
},
|
},
|
||||||
handleBlur (e) {
|
handleBlur (e) {
|
||||||
this.$emit('input', e.target.value)
|
const newVal = e.target.value
|
||||||
// if (e.target.value.length) {
|
if (newVal !== this.value) {
|
||||||
// this.$emit('handleChange', e.target.value)
|
this.$emit('input', newVal)
|
||||||
// }
|
}
|
||||||
this.focusState = false
|
this.focusState = false
|
||||||
},
|
},
|
||||||
toDel () {
|
toDel () {
|
||||||
|
|||||||
126
components/SearchBox_back.vue
Normal file
126
components/SearchBox_back.vue
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
<template>
|
||||||
|
<view class="search_wraper">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
class="filter_input pdr120"
|
||||||
|
confirm-type="go"
|
||||||
|
:value="value"
|
||||||
|
:focus="focusState"
|
||||||
|
@focus="handleFocus"
|
||||||
|
@blur="handleBlur"
|
||||||
|
@input="handleInput"
|
||||||
|
@confirm="handleConfirm">
|
||||||
|
<view class="zd-row buttons_wraper">
|
||||||
|
<uni-icons v-show="value !== '' && value !== null && value !== undefined" class="pdr10" type="clear" size="24" color="#666" @tap="toDel"></uni-icons>
|
||||||
|
<uni-icons type="scan" size="22" :color="focusState ? '#ff6a00' : '#4e6ef2'" @tap="focusState=true"></uni-icons>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import permision from "@/utils/permission.js"
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
focusState: false,
|
||||||
|
inputTimestamps: [], // 记录每次输入的时间戳
|
||||||
|
autoTimer: null, // 自动提交定时器
|
||||||
|
lastEmittedValue: '' // 上一次触发 handleChange 的值,用于去重
|
||||||
|
};
|
||||||
|
},
|
||||||
|
model: {
|
||||||
|
prop: 'value',
|
||||||
|
event: 'input'
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
value: String
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
handleFocus () {
|
||||||
|
this.focusState = true;
|
||||||
|
},
|
||||||
|
handleBlur (e) {
|
||||||
|
this.$emit('input', e.target.value);
|
||||||
|
this.focusState = false;
|
||||||
|
},
|
||||||
|
handleInput(e) {
|
||||||
|
const newValue = e.detail.value;
|
||||||
|
// 更新 v-model
|
||||||
|
this.$emit('input', newValue);
|
||||||
|
|
||||||
|
// 记录当前输入时间戳
|
||||||
|
const now = Date.now();
|
||||||
|
this.inputTimestamps.push(now);
|
||||||
|
// 只保留最近10次记录,避免数组过长
|
||||||
|
if (this.inputTimestamps.length > 10) this.inputTimestamps.shift();
|
||||||
|
|
||||||
|
// 清除之前的自动提交定时器
|
||||||
|
if (this.autoTimer) clearTimeout(this.autoTimer);
|
||||||
|
|
||||||
|
// 启动新定时器,等待输入稳定后判断
|
||||||
|
this.autoTimer = setTimeout(() => {
|
||||||
|
this.checkAutoSubmit(newValue);
|
||||||
|
}, 150);
|
||||||
|
},
|
||||||
|
checkAutoSubmit(currentValue) {
|
||||||
|
if (!currentValue) return;
|
||||||
|
if (currentValue === this.lastEmittedValue) return;
|
||||||
|
|
||||||
|
const timestamps = this.inputTimestamps;
|
||||||
|
if (timestamps.length < 2) {
|
||||||
|
// 只有一次输入,认为是手动输入,不自动提交
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 计算最近两次输入的最大间隔
|
||||||
|
let maxInterval = 0;
|
||||||
|
for (let i = 1; i < timestamps.length; i++) {
|
||||||
|
const interval = timestamps[i] - timestamps[i-1];
|
||||||
|
if (interval > maxInterval) maxInterval = interval;
|
||||||
|
}
|
||||||
|
// 如果最大间隔小于80ms,认为是扫码快速输入,自动提交
|
||||||
|
if (maxInterval < 80) {
|
||||||
|
this.emitChange(currentValue);
|
||||||
|
}
|
||||||
|
// 否则认为手动输入,不自动提交,等待回车
|
||||||
|
},
|
||||||
|
handleConfirm(e) {
|
||||||
|
const newValue = e.detail.value;
|
||||||
|
// 清除自动提交定时器,防止重复
|
||||||
|
if (this.autoTimer) clearTimeout(this.autoTimer);
|
||||||
|
this.$emit('input', newValue);
|
||||||
|
this.emitChange(newValue);
|
||||||
|
},
|
||||||
|
emitChange(val) {
|
||||||
|
if (!val) return;
|
||||||
|
if (val === this.lastEmittedValue) return;
|
||||||
|
this.lastEmittedValue = val;
|
||||||
|
this.$emit('handleChange', val);
|
||||||
|
// 提交后清空时间戳记录,避免影响下一次输入
|
||||||
|
this.inputTimestamps = [];
|
||||||
|
},
|
||||||
|
toDel() {
|
||||||
|
// 清空时清除定时器,重置状态
|
||||||
|
if (this.autoTimer) clearTimeout(this.autoTimer);
|
||||||
|
this.$emit('input', '');
|
||||||
|
this.lastEmittedValue = '';
|
||||||
|
this.inputTimestamps = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="stylus">
|
||||||
|
@import '../common/style/mixin.styl';
|
||||||
|
.search_wraper
|
||||||
|
position relative
|
||||||
|
_wh(100%, 80rpx)
|
||||||
|
.pdr120
|
||||||
|
padding-right: 120rpx;
|
||||||
|
.buttons_wraper
|
||||||
|
position absolute
|
||||||
|
top 0
|
||||||
|
right 10rpx
|
||||||
|
_wh(auto, 80rpx)
|
||||||
|
.pdr10
|
||||||
|
padding-right 10rpx
|
||||||
|
</style>
|
||||||
@@ -2,8 +2,8 @@
|
|||||||
"name" : "西门子",
|
"name" : "西门子",
|
||||||
"appid" : "__UNI__EF964CB",
|
"appid" : "__UNI__EF964CB",
|
||||||
"description" : "西门子LMS手持系统",
|
"description" : "西门子LMS手持系统",
|
||||||
"versionName" : "1.0.9",
|
"versionName" : "1.1.4",
|
||||||
"versionCode" : 109,
|
"versionCode" : 114,
|
||||||
"transformPx" : false,
|
"transformPx" : false,
|
||||||
/* 5+App特有相关 */
|
/* 5+App特有相关 */
|
||||||
"app-plus" : {
|
"app-plus" : {
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
<view class="zd-col-17">
|
<view class="zd-col-17">
|
||||||
<search-box
|
<search-box
|
||||||
v-model="point"
|
v-model="point"
|
||||||
@handleChange="handlePointChange"
|
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -21,10 +20,10 @@
|
|||||||
<view class="zd-col-17">
|
<view class="zd-col-17">
|
||||||
<search-box
|
<search-box
|
||||||
v-model="vehicle"
|
v-model="vehicle"
|
||||||
@handleChange="handleVehicleChange"
|
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<button type="primary" class="mgt20" @tap="handleAddItem">添加</button>
|
||||||
</view>
|
</view>
|
||||||
<view class="zd_wrapper grid-wraper">
|
<view class="zd_wrapper grid-wraper">
|
||||||
<view class="slide_new">
|
<view class="slide_new">
|
||||||
@@ -42,21 +41,14 @@
|
|||||||
<td>{{e.vehicle_code}}</td>
|
<td>{{e.vehicle_code}}</td>
|
||||||
<td><view class="delete-btn" @tap="deleteItem(i)">删除</view></td>
|
<td><view class="delete-btn" @tap="deleteItem(i)">删除</view></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-if="uncompletedItem" class="uncompleted-row">
|
|
||||||
<td>{{uncompletedItem.point_code || '待扫描'}}</td>
|
|
||||||
<td>{{uncompletedItem.vehicle_code || '待扫描'}}</td>
|
|
||||||
<td>
|
|
||||||
<view class="clear-btn" @tap="clearUncompleted">清空</view>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<view v-if="dataList.length === 0 && !uncompletedItem" class="tip">请扫描点位和载具编码</view>
|
<view v-if="dataList.length === 0" class="tip">请扫描点位和载具编码</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="zd-row submit-bar">
|
<view class="zd-row submit-bar">
|
||||||
<button class="zd-col-24 button-primary" :class="{'button-info': !dataList.length}" :disabled="disabled" @tap="_emptyVehicleWarehousing">提交</button>
|
<button class="zd-col-24 button-primary" :class="{'button-info': !canSubmit}" :disabled="disabled" @tap="_emptyVehicleWarehousing">提交</button>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
@@ -75,73 +67,76 @@
|
|||||||
title: '',
|
title: '',
|
||||||
point: '',
|
point: '',
|
||||||
vehicle: '',
|
vehicle: '',
|
||||||
uncompletedItem: null,
|
|
||||||
dataList: [],
|
dataList: [],
|
||||||
disabled: false
|
disabled: false
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
canSubmit() {
|
||||||
|
return this.dataList.length > 0 || (this.point && this.vehicle);
|
||||||
|
}
|
||||||
|
},
|
||||||
onLoad (options) {
|
onLoad (options) {
|
||||||
this.title = options.title
|
this.title = options.title
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handlePointChange(value) {
|
handleAddItem() {
|
||||||
if (value) {
|
if (!this.point || !this.vehicle) {
|
||||||
setTimeout(() => { this.point = '' }, 500)
|
uni.showToast({
|
||||||
if (!this.uncompletedItem) {
|
title: '请完整填写点位和载具编码',
|
||||||
this.uncompletedItem = { point_code: value }
|
icon: 'none'
|
||||||
} else {
|
|
||||||
this.uncompletedItem.point_code = value
|
|
||||||
}
|
|
||||||
this.checkAndAddToList()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
handleVehicleChange(value) {
|
|
||||||
if (value) {
|
|
||||||
setTimeout(() => { this.vehicle = '' }, 500)
|
|
||||||
if (!this.uncompletedItem) {
|
|
||||||
this.uncompletedItem = { vehicle_code: value }
|
|
||||||
} else {
|
|
||||||
this.uncompletedItem.vehicle_code = value
|
|
||||||
}
|
|
||||||
this.checkAndAddToList()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
checkAndAddToList() {
|
|
||||||
if (!this.uncompletedItem) return
|
|
||||||
const { point_code, vehicle_code } = this.uncompletedItem
|
|
||||||
if (point_code && vehicle_code) {
|
|
||||||
const exists = this.dataList.some(item =>
|
|
||||||
item.point_code === point_code && item.vehicle_code === vehicle_code
|
|
||||||
)
|
|
||||||
if (!exists) {
|
|
||||||
this.dataList.push({
|
|
||||||
point_code,
|
|
||||||
vehicle_code
|
|
||||||
})
|
})
|
||||||
this.uncompletedItem = null
|
return
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
const exists = this.dataList.some(item =>
|
||||||
|
item.point_code === this.point && item.vehicle_code === this.vehicle
|
||||||
|
)
|
||||||
|
|
||||||
|
if (exists) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '该组合已存在',
|
title: '该组合已存在',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
})
|
})
|
||||||
this.uncompletedItem = null
|
return
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
this.dataList.push({
|
||||||
clearUncompleted() {
|
point_code: this.point,
|
||||||
this.uncompletedItem = null
|
vehicle_code: this.vehicle
|
||||||
|
})
|
||||||
|
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.point = ''
|
||||||
|
this.vehicle = ''
|
||||||
|
})
|
||||||
},
|
},
|
||||||
deleteItem(index) {
|
deleteItem(index) {
|
||||||
this.dataList.splice(index, 1)
|
this.dataList.splice(index, 1)
|
||||||
},
|
},
|
||||||
async _emptyVehicleWarehousing () {
|
async _emptyVehicleWarehousing () {
|
||||||
this.disabled = true
|
this.disabled = true
|
||||||
if (!this.dataList.length) {
|
let submitData = []
|
||||||
|
if (this.dataList.length > 0) {
|
||||||
|
submitData = this.dataList
|
||||||
|
}
|
||||||
|
else if (this.point && this.vehicle) {
|
||||||
|
submitData = [{
|
||||||
|
point_code: this.point,
|
||||||
|
vehicle_code: this.vehicle
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
uni.showToast({
|
||||||
|
title: '请填写点位和载具编码或添加列表数据',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
this.disabled = false
|
this.disabled = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let res = await emptyVehicleWarehousing(this.dataList)
|
let res = await emptyVehicleWarehousing(submitData)
|
||||||
this.clearUp()
|
this.clearUp()
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: res.message,
|
title: res.message,
|
||||||
@@ -155,7 +150,6 @@
|
|||||||
clearUp () {
|
clearUp () {
|
||||||
this.point = ''
|
this.point = ''
|
||||||
this.vehicle = ''
|
this.vehicle = ''
|
||||||
this.uncompletedItem = null
|
|
||||||
this.disabled = false
|
this.disabled = false
|
||||||
this.dataList = []
|
this.dataList = []
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user