<template>
|
<view class="container">
|
<view class="header">
|
<view class="item">
|
<view class="left">条码编号:</view>
|
<view class="right">
|
<input name="HBarCode" v-model="barCodeInfoMeta.barCodeNo" placeholder="请扫描条码"
|
@confirm="searchbarCodeInfo" />
|
</view>
|
<view>
|
<uni-icons type="scan"
|
style="background-color: #3A78FF;padding: 6rpx;color: #fff;border-radius: 100%;font-weight: 500;"
|
size="20" @click="toScanCode"></uni-icons>
|
</view>
|
</view>
|
<view class="item">
|
<view class="left">拆码数量:</view>
|
<view class="right">
|
<input type="number" name="HSplitNum" v-model="barCodeInfoMeta.splitNum" placeholder="请输入拆码数量" />
|
</view>
|
</view>
|
<view class="item">
|
<view class="left">制单人:</view>
|
<view class="right">
|
<input type="text" disabled name="HMaker" v-model="barCodeInfoMeta.billMaker"
|
placeholder="请输入制单人" />
|
</view>
|
</view>
|
<view class="operation-zone">
|
<button class="btn-c" @click="searchbarCodeInfoMeta">拆码</button>
|
<button type="default" :class="cantGenerate?'':'btn-c'" @click="SaveBarCodeCreate"
|
:disabled="cantGenerate">生成</button>
|
</view>
|
</view>
|
<view class="divide"></view>
|
<view class="content">
|
<view class="barcode-detail" v-show="CommonUtils.isEmpty(Object.assign(barCodeInfo, {})) === false">
|
<view class="title">条码信息</view>
|
<uni-card>
|
<view class="detail">
|
<text>条码号:</text>{{barCodeInfo['条码编号'] || ''}}
|
</view>
|
<view class="detail">
|
<text>原数量:</text>{{barCodeInfo['数量'] || '0'}}
|
</view>
|
<view class="dWetail">
|
<text>物料编码:</text>{{barCodeInfo['物料代码'] || ''}}
|
</view>
|
<view class="detail">
|
<text>物料名称:</text>{{barCodeInfo['物料名称'] || ''}}
|
</view>
|
<view class="detail">
|
<text>规格型号:</text>{{barCodeInfo['规格型号'] || ''}}
|
</view>
|
<view class="detail">
|
<text>计量单位:</text>{{barCodeInfo['计量单位'] || ''}}
|
</view>
|
</uni-card>
|
</view>
|
<view class="divide"></view>
|
<view class="barcode-split" v-show="barCodeSplitInfo.length>0">
|
<view class="title">条码拆码</view>
|
<view class="barcode-split-list" v-for="(item,index) in barCodeSplitInfo" :key="index">
|
<uni-card @tap="ModityHQty(item)">
|
<view class="detail">
|
<text>条码编号:</text>{{item['HBarCode'] || ''}}
|
</view>
|
<view class="detail">
|
<text>条码数量:</text>{{item['HQty'] || '0'}}
|
</view>
|
<view class="detail split-num">
|
<text>拆分数量:</text>{{item['HSplitNum'] || '0'}}
|
</view>
|
<view class="detail">
|
<text>物料代码:</text>{{item['HNumber'] || ''}}
|
</view>
|
<view class="detail">
|
<text>物料名称:</text>{{item['HName'] || ''}}
|
</view>
|
<view class="detail">
|
<text>规格型号:</text>{{item['HModel'] || ''}}
|
</view>
|
<view class="detail">
|
<text>计量单位:</text>{{barCodeInfo['计量单位'] || ''}}
|
</view>
|
</uni-card>
|
</view>
|
</view>
|
</view>
|
<view class="over" v-if="barCodeSplitInfo.length == 0">暂无数据</view>
|
<view class="over" v-if="barCodeSplitInfo.length != 0">已到底</view>
|
<view>
|
<!-- 输入框示例 -->
|
<uni-popup ref="inputDialog" type="dialog">
|
<uni-popup-dialog ref="inputClose" mode="input" title="请输入拆码数量" :value="dialogVal" placeholder="请输入拆码数量"
|
@confirm="dialogInputConfirm"></uni-popup-dialog>
|
</uni-popup>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
import {
|
getUserInfo
|
} from "@/utils/auth.js";
|
import {
|
CommonUtils
|
} from "@/utils/common.js"
|
export default {
|
data() {
|
return {
|
CommonUtils,
|
userInfo: getUserInfo(),
|
serverUrl: uni.getStorageSync('serverUrl') || 'http://47.96.97.237/API',
|
barCodeInfoMeta: {
|
barCodeNo: "",
|
splitNum: "",
|
billMaker: getUserInfo().HEmpName,
|
billMakerID: getUserInfo().HEmpID
|
},
|
barCodeInfo: {
|
|
},
|
barCodeSplitInfo: [],
|
dialogVal: 0,
|
itemCache: {},
|
cantGenerate: true
|
};
|
},
|
methods: {
|
doRequest(url, data, resFunction, errFunction, method) {
|
uni.showLoading({
|
title: '加载中...'
|
})
|
uni.request({
|
method: method || "GET",
|
url: this.serverUrl + url,
|
data: data || "",
|
success: (res) => {
|
if (typeof resFunction === 'function') {
|
resFunction.call(this, res)
|
} else if (typeof errFunction === 'undefined') {
|
return
|
} else {
|
throw new TypeError("访问成功回调函数类型异常!")
|
}
|
},
|
fail: (err) => {
|
uni.showToast({
|
icon: "error",
|
title: "接口访问异常!",
|
duration: 2000
|
})
|
if (typeof errFunction === 'function') {
|
errFunction.call(this, err)
|
} else if (typeof errFunction === 'undefined') {
|
return
|
} else {
|
throw new TypeError("访问失败回调函数类型异常!")
|
}
|
}
|
})
|
uni.hideLoading()
|
},
|
async searchbarCodeInfoMeta() {
|
this.cantGenerate = true
|
if (CommonUtils.isEmpty(this.barCodeInfoMeta.barCodeNo) === true) {
|
return uni.showToast({
|
icon: 'none',
|
title: '条码编号不得为空!'
|
});
|
}
|
if (CommonUtils.isEmpty(this.barCodeInfoMeta.splitNum, true) === true) {
|
return uni.showToast({
|
icon: 'none',
|
title: '拆分数量不得为空!'
|
});
|
}
|
if (this.barCodeInfoMeta.splitNum > 10 || this.barCodeInfo.splitNum < 2) {
|
return uni.showToast({
|
icon: 'none',
|
title: '拆分数量必须在2~10之间!'
|
});
|
}
|
this.doRequest(
|
"/Gy_SplitBarCode/Info", {
|
HBarCodeNo: this.barCodeInfoMeta.barCodeNo,
|
HSplitBarNum: this.barCodeInfoMeta.splitNum
|
},
|
function(res) {
|
console.log(res)
|
this.barCodeSplitInfo = []
|
let res1 = res.data
|
let {
|
data,
|
count,
|
Message
|
} = res1
|
if (count > 0) {
|
|
if (data.length < 1) {
|
return uni.showToast({
|
icon: 'none',
|
title: Message
|
});
|
}
|
// this.barCodeInfo = data[0]
|
if (data[0]["HQty"] < this.barCodeInfoMeta.splitNum) {
|
return uni.showToast({
|
icon: 'none',
|
title: '拆分数量大于条码数量!'
|
});
|
}
|
let remainder = data[0]["HQty"] % this.barCodeInfoMeta.splitNum
|
let i
|
for (i = 0; i < this.barCodeInfoMeta.splitNum; i++) {
|
let barCodeItem = JSON.parse(JSON.stringify(data[0]));
|
this.barCodeSplitInfo.push(Object.assign(barCodeItem, {
|
HSplitNum: Math.floor(data[0]["HQty"] / this.barCodeInfoMeta
|
.splitNum),
|
HBarCode: data[0]["HBarCode"] + String.fromCharCode(('A'
|
.charCodeAt(0) + i))
|
}))
|
}
|
this.barCodeSplitInfo[i - 1]["HSplitNum"] += remainder
|
this.cantGenerate = false
|
} else {
|
uni.showToast({
|
icon: 'none',
|
title: '没有找到对应的单据'
|
});
|
}
|
},
|
function(err) {
|
console.error(err)
|
}
|
)
|
},
|
async searchbarCodeInfo() {
|
await this.$nextTick()
|
let urlEncode =
|
`/Gy_BarCodeBillList/page?sWhere= and 条码编号=\'\'${this.barCodeInfoMeta.barCodeNo}\'\'&user=${this.userInfo.HEmpName}&page=1&size=1`
|
.toString()
|
if (CommonUtils.isEmpty(this.barCodeInfoMeta.barCodeNo) == true) {
|
return uni.showToast({
|
icon: "fail",
|
title: "条码编号不能为空!"
|
})
|
}
|
this.doRequest(
|
urlEncode,
|
null,
|
function(res) {
|
console.log(res)
|
let res1 = res.data
|
let {
|
data,
|
count
|
} = res1
|
if (count > 0) {
|
this.barCodeInfo = data[0]
|
}
|
},
|
function(err) {
|
console.err(err)
|
}
|
)
|
},
|
ModityHQty(item) {
|
this.dialogVal = item["HSplitNum"]
|
this.itemCache = item
|
this.inputDialogToggle()
|
|
},
|
inputDialogToggle() {
|
this.$refs.inputDialog.open()
|
},
|
dialogInputConfirm(val) {
|
this.itemCache["HSplitNum"] = val
|
|
// 关闭窗口后,恢复默认内容
|
this.$refs.inputDialog.close()
|
|
},
|
SaveBarCodeCreate() {
|
// 校验拆码数量
|
let sum = this.barCodeSplitInfo.reduce((acc, obj) => {
|
return acc + obj["HSplitNum"]
|
}, 0)
|
|
if (sum > this.barCodeInfo["HQty"]) {
|
return uni.showToast({
|
icon: 'none',
|
title: '拆码数量和不得大于条码数量'
|
});
|
}
|
let msg =
|
`${this.barCodeInfoMeta["baoCodeNo"]};${this.barCodeInfoMeta["splitNum"]};${JSON.stringify(this.barCodeSplitInfo)};${this.userInfo["HEmpName"]}`
|
this.doRequest(
|
"/Sc_BarCode/Save_SplitBarCode", {
|
msg: msg
|
},
|
function(res) {
|
this.cantGenerate = true
|
uni.showToast({
|
title: '生成成功!'
|
});
|
},
|
function(err) {
|
console.err(err)
|
},
|
"POST"
|
)
|
|
},
|
toScanCode() {
|
var mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module")
|
mpaasScanModule.mpaasScan({
|
'hideAlbum': true,
|
'timeoutInterval':'10', //超时时间
|
'timeoutText':'未识别到二维码' //超时提醒
|
},(ret) => {
|
console.log(ret.resp_result)
|
if (this.CommonUtils.isEmpty(ret.resp_result) === false) {
|
console.log('条码内容:' + ret.resp_result);
|
this.barCodeInfoMeta.barCodeNo = ret.resp_result
|
|
this.searchbarCodeInfo()
|
// this.doRequest(
|
// "/Gy_SplitBarCode/Info", {
|
// HBarCodeNo: ret.resp_result,
|
// HSplitBarNum: 1
|
// },
|
// function(res) {
|
// console.log(res)
|
// this.barCodeSplitInfo = []
|
// let res1 = res.data
|
// let {
|
// data,
|
// count
|
// } = res1
|
// if (count > 0) {
|
// console.log(data[0])
|
// this.barCodeInfo = data[0]
|
// }
|
// },
|
// function(err) {
|
// console.error(err)
|
// }
|
// )
|
}
|
})
|
}
|
},
|
onLoad() {
|
}
|
}
|
</script>
|
|
<style lang="scss">
|
* {
|
box-sizing: border-box;
|
}
|
|
input {
|
padding: 8rpx 20rpx;
|
font-size: 30rpx;
|
line-height: 30rpx;
|
}
|
|
button {
|
padding: 0;
|
width: 150rpx;
|
font-size: 25rpx;
|
}
|
|
.uni-card {
|
margin: 0 !important;
|
}
|
|
.container {
|
.header {
|
padding: 20rpx 10rpx;
|
display: flex;
|
flex-direction: column;
|
gap: 20rpx;
|
|
.item {
|
display: flex;
|
flex-direction: row;
|
padding: 0 10rpx;
|
gap: 20rpx;
|
font-size: 30rpx;
|
// height: 1.5rem;
|
// justify-content: center;
|
align-items: center;
|
|
.left {
|
text-align: right;
|
width: 5rem;
|
}
|
|
.right {
|
flex: 1;
|
height: 100%;
|
padding: 6rpx 0;
|
border-radius: 22rpx;
|
border: 1px solid #e4e4e4;
|
background-color: #e4e4e4;
|
|
>input {
|
height: auto;
|
}
|
}
|
}
|
|
.operation-zone {
|
display: flex;
|
flex-direction: row;
|
justify-content: space-evenly;
|
|
.btn-c {
|
background-color: #3a78ff;
|
color: #fff;
|
}
|
}
|
}
|
|
.divide {
|
width: 100%;
|
height: 16rpx;
|
background-color: #e5e5e5;
|
}
|
|
.content {
|
flex: 1;
|
|
.barcode-detail,
|
.barcode-split {
|
padding: 30rpx;
|
display: flex;
|
flex-direction: column;
|
gap: 30rpx;
|
}
|
}
|
}
|
</style>
|