Commit 11800c2a by LJM

js

parent fcbb249c
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
} }
} }
.uni-list-cell-db { .uni-list-cell-db {
width: calc(100% - 369rpx); width: calc(100% - 416rpx);
position: relative; position: relative;
.icon-sanjiaoxing1 { .icon-sanjiaoxing1 {
position: absolute; position: absolute;
...@@ -61,6 +61,14 @@ ...@@ -61,6 +61,14 @@
} }
} }
} }
.scan-view {
width: 49rpx;
height: 100%;
.iconfont {
font-size: 30rpx;
color: #197adb;
}
}
} }
} }
.uni-table-box { .uni-table-box {
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
<view class="box row verCenter"> <view class="box row verCenter">
<view class="label">扫描</view> <view class="label">扫描</view>
<input v-model="code_str" @input="scanChange" placeholder-style="font-size:24rpx;" class="uni-input" placeholder="扫描焦点" style="width: 261rpx;" /> <input v-model="code_str" @input="scanChange" placeholder-style="font-size:24rpx;" class="uni-input" placeholder="扫描焦点" style="width: 261rpx;" />
<view class="scan-view row rowCenter verCenter" @click="scodeChange()"><text class="iconfont icon-juxing6"></text></view>
<view class="uni-list-cell-db"> <view class="uni-list-cell-db">
<text class="iconfont icon-sanjiaoxing1"></text> <text class="iconfont icon-sanjiaoxing1"></text>
<picker @change="bindPickerChange" :value="index" :range="array"> <picker @change="bindPickerChange" :value="index" :range="array">
...@@ -22,7 +23,7 @@ ...@@ -22,7 +23,7 @@
</view> </view>
<view class="addRow row rowCenter verCenter" @click="addRowChange()">新增行</view> <view class="addRow row rowCenter verCenter" @click="addRowChange()">新增行</view>
<view class="uni-table-box"> <view class="uni-table-box">
<uni-table type="selection" border stripe emptyText="暂无更多数据" @selection-change="selectionChange"> <uni-table type="selection" ref="table" border stripe emptyText="暂无更多数据" @selection-change="selectionChange">
<uni-tr> <uni-tr>
<uni-th align="center">序号</uni-th> <uni-th align="center">序号</uni-th>
<uni-th align="center">型号</uni-th> <uni-th align="center">型号</uni-th>
...@@ -66,22 +67,45 @@ ...@@ -66,22 +67,45 @@
<script> <script>
import { API } from '@/util/api.js'; import { API } from '@/util/api.js';
import { debounce } from '@/util/util.js';
export default { export default {
data() { data() {
return { return {
timer: null, // 延时器的名字
box_sn: '', box_sn: '',
code_str: '', code_str: '',
code_type: '', code_type: 'digikey',
list: [], list: [],
listPop: [], listPop: [],
selectedIndexs: [], selectedIndexs: [],
index: -1, index: 0,
array: ['扫描digikey', '扫描Mouser', '扫描Arrow', '扫描Rochester', '扫描TME', '扫描Chip1stop'], array: ['扫描digikey', '扫描Mouser', '扫描Arrow', '扫描Rochester', '扫描TME', '扫描Chip1stop'],
arrar_val: ['digikey', 'Mouser', 'Arrow', 'Rochester', 'TME', 'Chip1stop'] arrar_val: ['digikey', 'Mouser', 'Arrow', 'Rochester', 'TME', 'Chip1stop']
}; };
}, },
methods: { methods: {
scodeChange() {
this.code_str = '';
uni.scanCode({
success: res => {
console.log(res);
if (res.errMsg == 'scanCode:ok') {
this.code_str = res.result;
if (res.result) {
this.identifyQrCodeNumAndSn();
}
}
},
fail: function(res) {
console.log(res);
uni.showToast({
title: '扫码失败',
icon: 'error'
});
}
});
},
getBoxSnAndNumAll() { getBoxSnAndNumAll() {
this.request(API.getBoxSnAndNum, 'POST', { box_sn: '' }, true).then(res => { this.request(API.getBoxSnAndNum, 'POST', { box_sn: '' }, true).then(res => {
if (res.err_code === 0) { if (res.err_code === 0) {
...@@ -139,16 +163,22 @@ export default { ...@@ -139,16 +163,22 @@ export default {
this.selectedIndexs = e.detail.index; this.selectedIndexs = e.detail.index;
}, },
scanChange(event) { scanChange(event) {
var val = event.target.value; clearTimeout(this.timer);
if (val) { this.timer = setTimeout(() => {
this.identifyQrCodeNumAndSn(); var val = event.target.value;
} if (val) {
this.identifyQrCodeNumAndSn();
}
}, 800);
}, },
inputChange(event) { inputChange(event) {
var val = event.target.value; clearTimeout(this.timer);
if (val) { this.timer = setTimeout(() => {
this.getBoxSnAndNum(); var val = event.target.value;
} if (val) {
this.getBoxSnAndNum();
}
}, 800);
}, },
deleteChange() { deleteChange() {
if (this.selectedIndexs.length <= 0) { if (this.selectedIndexs.length <= 0) {
...@@ -160,11 +190,21 @@ export default { ...@@ -160,11 +190,21 @@ export default {
return false; return false;
} }
for (let i = 0; i < this.selectedIndexs.length; i++) { for (let i = 0; i < this.selectedIndexs.length; i++) {
console.log(this.selectedIndexs[i]);
this.list.splice(this.selectedIndexs[i], 1); this.list.splice(this.selectedIndexs[i], 1);
} }
this.$forceUpdate(); this.$forceUpdate();
this.$refs.table.clearSelection();
}, },
exportChange() { exportChange() {
if (!this.box_sn) {
uni.showModal({
title: '提示',
content: '请输入箱号',
showCancel: false
});
return false;
}
this.request(API.getBoxSnAndNum, 'POST', { box_sn: this.box_sn, export: 1 }, true).then(res => { this.request(API.getBoxSnAndNum, 'POST', { box_sn: this.box_sn, export: 1 }, true).then(res => {
if (res.err_code === 0) { if (res.err_code === 0) {
uni.downloadFile({ uni.downloadFile({
......
...@@ -66,8 +66,31 @@ const titleCase = (str) => { ...@@ -66,8 +66,31 @@ const titleCase = (str) => {
return str; return str;
} }
/**
* 节流
*/
const debounce = (fn, wait) => {
let delay = wait || 500
let timer
return function() {
let args = arguments;
if (timer) {
clearTimeout(timer)
console.log('拦截')
}
let callNow = !timer
timer = setTimeout(() => {
console.log('发送')
timer = null
}, delay)
if (callNow) fn.apply(this, args)
}
}
module.exports = { module.exports = {
request, request,
getPlatform, getPlatform,
titleCase titleCase,
} debounce
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment