Commit 11800c2a by LJM

js

parent fcbb249c
......@@ -35,7 +35,7 @@
}
}
.uni-list-cell-db {
width: calc(100% - 369rpx);
width: calc(100% - 416rpx);
position: relative;
.icon-sanjiaoxing1 {
position: absolute;
......@@ -61,6 +61,14 @@
}
}
}
.scan-view {
width: 49rpx;
height: 100%;
.iconfont {
font-size: 30rpx;
color: #197adb;
}
}
}
}
.uni-table-box {
......
......@@ -12,6 +12,7 @@
<view class="box row verCenter">
<view class="label">扫描</view>
<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">
<text class="iconfont icon-sanjiaoxing1"></text>
<picker @change="bindPickerChange" :value="index" :range="array">
......@@ -22,7 +23,7 @@
</view>
<view class="addRow row rowCenter verCenter" @click="addRowChange()">新增行</view>
<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-th align="center">序号</uni-th>
<uni-th align="center">型号</uni-th>
......@@ -66,22 +67,45 @@
<script>
import { API } from '@/util/api.js';
import { debounce } from '@/util/util.js';
export default {
data() {
return {
timer: null, // 延时器的名字
box_sn: '',
code_str: '',
code_type: '',
code_type: 'digikey',
list: [],
listPop: [],
selectedIndexs: [],
index: -1,
index: 0,
array: ['扫描digikey', '扫描Mouser', '扫描Arrow', '扫描Rochester', '扫描TME', '扫描Chip1stop'],
arrar_val: ['digikey', 'Mouser', 'Arrow', 'Rochester', 'TME', 'Chip1stop']
};
},
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() {
this.request(API.getBoxSnAndNum, 'POST', { box_sn: '' }, true).then(res => {
if (res.err_code === 0) {
......@@ -139,16 +163,22 @@ export default {
this.selectedIndexs = e.detail.index;
},
scanChange(event) {
var val = event.target.value;
if (val) {
this.identifyQrCodeNumAndSn();
}
clearTimeout(this.timer);
this.timer = setTimeout(() => {
var val = event.target.value;
if (val) {
this.identifyQrCodeNumAndSn();
}
}, 800);
},
inputChange(event) {
var val = event.target.value;
if (val) {
this.getBoxSnAndNum();
}
clearTimeout(this.timer);
this.timer = setTimeout(() => {
var val = event.target.value;
if (val) {
this.getBoxSnAndNum();
}
}, 800);
},
deleteChange() {
if (this.selectedIndexs.length <= 0) {
......@@ -160,11 +190,21 @@ export default {
return false;
}
for (let i = 0; i < this.selectedIndexs.length; i++) {
console.log(this.selectedIndexs[i]);
this.list.splice(this.selectedIndexs[i], 1);
}
this.$forceUpdate();
this.$refs.table.clearSelection();
},
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 => {
if (res.err_code === 0) {
uni.downloadFile({
......
......@@ -66,8 +66,31 @@ const titleCase = (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 = {
request,
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