|
|
@@ -5,7 +5,8 @@
|
|
|
<view class="card_cylinder">
|
|
|
<view class="title_index">单位内编号 <span class="line_title">*</span></view>
|
|
|
<view style="display: flex;align-items: center;">
|
|
|
- <u-input border="surround" placeholder="点击输入" v-model="frequencyCoding"></u-input>
|
|
|
+ <input class="card_top_input" ref="inputRef" placeholder="点击输入" v-model="frequencyCoding"
|
|
|
+ :focus="firstFocus" @blur="blurInput"></input>
|
|
|
<view class="btn_add_card">
|
|
|
<u-button type="primary" text="添加" @click="addCode"></u-button>
|
|
|
</view>
|
|
|
@@ -65,6 +66,10 @@
|
|
|
scanCoding: '',
|
|
|
bottleType: 1,
|
|
|
cylinderTitle: '添加钢瓶',
|
|
|
+ firstFocus: false,
|
|
|
+ gradatimFlag: true,
|
|
|
+ continuous: null,
|
|
|
+ clearTime: null,
|
|
|
}
|
|
|
},
|
|
|
onLoad(value) {
|
|
|
@@ -105,12 +110,6 @@
|
|
|
delCode(index) {
|
|
|
this.codeList.splice(index, 1);
|
|
|
},
|
|
|
- // 输入钢瓶编号添加
|
|
|
- addCode() {
|
|
|
- this.codeList.push(this.frequencyCoding)
|
|
|
- this.codeList = Array.from(new Set(this.codeList));
|
|
|
- this.frequencyCoding = ''
|
|
|
- },
|
|
|
// 添加一条
|
|
|
addLine() {
|
|
|
this.scanType = 1
|
|
|
@@ -161,24 +160,103 @@
|
|
|
if (res.data.code == 0) {
|
|
|
var arr = res.data.data
|
|
|
if (this.scanType == 1) {
|
|
|
- this.codeList.push(arr.inner_code)
|
|
|
- this.codeList = Array.from(new Set(this.codeList));
|
|
|
+ if (this.gradatimFlag) {
|
|
|
+ this.gradatimFlag = false
|
|
|
+ this.fetchCylinder(arr.inner_code)
|
|
|
+ }
|
|
|
+ // this.codeList.push(arr.inner_code)
|
|
|
+ // this.codeList = Array.from(new Set(this.codeList));
|
|
|
} else {
|
|
|
- this.show = true
|
|
|
- this.codeList.push(arr.inner_code)
|
|
|
- this.codeList = Array.from(new Set(this.codeList));
|
|
|
- this.scanCoding = arr.inner_code
|
|
|
+ if (this.gradatimFlag) {
|
|
|
+ this.gradatimFlag = false
|
|
|
+ this.fetchCylinder(arr.inner_code, true)
|
|
|
+ }
|
|
|
+ // this.show = true
|
|
|
+ // this.codeList.push(arr.inner_code)
|
|
|
+ // this.codeList = Array.from(new Set(this.codeList));
|
|
|
+ // this.scanCoding = arr.inner_code
|
|
|
// 扫码间隔两秒
|
|
|
- setTimeout(() => {
|
|
|
- this.sweep()
|
|
|
- this.show = false
|
|
|
- }, 3000)
|
|
|
+ // setTimeout(() => {
|
|
|
+ // this.sweep()
|
|
|
+ // this.show = false
|
|
|
+ // }, 3000)
|
|
|
}
|
|
|
- uni.hideLoading();
|
|
|
}
|
|
|
+ uni.hideLoading();
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
+ // 输入钢瓶编号添加
|
|
|
+ addCode() {
|
|
|
+ const cnflag = hasChinese(this.frequencyCoding)
|
|
|
+ if (cnflag) {
|
|
|
+ uni.$u.toast('请输入正确单位内编号')
|
|
|
+ } else {
|
|
|
+ if (this.frequencyCoding) {
|
|
|
+ if (this.gradatimFlag) {
|
|
|
+ this.gradatimFlag = false
|
|
|
+ this.fetchCylinder(this.frequencyCoding)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ uni.$u.toast('请先输入单位内编号')
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function hasChinese(text) {
|
|
|
+ var pattern = /[\u4E00-\u9FA5]/; // Unicode编码范围包含中文字符
|
|
|
+ return pattern.test(text);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 失去焦点
|
|
|
+ blurInput(event, flag) {
|
|
|
+ let arrEvent = event.detail.value
|
|
|
+ this.firstFocus = false;
|
|
|
+ const cnflag = hasChinese(arrEvent)
|
|
|
+ if (cnflag) {
|
|
|
+ uni.$u.toast('请输入正确单位内编号')
|
|
|
+ } else {
|
|
|
+ if (this.gradatimFlag && arrEvent) {
|
|
|
+ if (this.clearTime) clearTimeout(this.clearTime)
|
|
|
+ this.gradatimFlag = false
|
|
|
+ this.fetchCylinder(arrEvent)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function hasChinese(text) {
|
|
|
+ var pattern = /[\u4E00-\u9FA5]/; // Unicode编码范围包含中文字符
|
|
|
+ return pattern.test(text);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ fetchCylinder(event, flag) {
|
|
|
+ this.$api.get('/api/gas-cylinder/' + event).then(res => {
|
|
|
+ if (res.code == 200) {
|
|
|
+ this.codeList.push(res.data.inner_code)
|
|
|
+ this.codeList = Array.from(new Set(this.codeList));
|
|
|
+ if (flag) {
|
|
|
+ if (this.arrTime) clearTimeout(this.arrTime)
|
|
|
+ this.show = true
|
|
|
+ this.scanCoding = res.data.inner_code
|
|
|
+ // 扫码间隔两秒
|
|
|
+ this.arrTime = setTimeout(() => {
|
|
|
+ this.show = false
|
|
|
+ this.sweep()
|
|
|
+ }, 3000)
|
|
|
+ this.gradatimFlag = true
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.clearTime = setTimeout(async () => {
|
|
|
+ this.frequencyCoding = ''
|
|
|
+ this.firstFocus = true;
|
|
|
+ }, 100)
|
|
|
+ } else if (res.data.code == 400) {
|
|
|
+ this.clearTime = setTimeout(async () => {
|
|
|
+ this.frequencyCoding = ''
|
|
|
+ }, 100)
|
|
|
+ uni.$u.toast(res.data.msg)
|
|
|
+ }
|
|
|
+ this.gradatimFlag = true
|
|
|
+ })
|
|
|
+ },
|
|
|
// 弹窗关闭
|
|
|
close() {
|
|
|
this.show = false
|
|
|
@@ -284,4 +362,13 @@
|
|
|
margin-bottom: 20rpx;
|
|
|
font-weight: 600;
|
|
|
}
|
|
|
+
|
|
|
+ .card_top_input {
|
|
|
+ width: 100%;
|
|
|
+ font-size: 14px;
|
|
|
+ color: #303133;
|
|
|
+ padding: 20rpx;
|
|
|
+ border-radius: 8rpx;
|
|
|
+ border: 1px solid #dadbde;
|
|
|
+ }
|
|
|
</style>
|