|
|
@ -13,29 +13,42 @@ |
|
|
|
</view> |
|
|
|
<view class=""> |
|
|
|
<view class=""> |
|
|
|
<win-com-scan ref="scan" @getResult="getScanResult" |
|
|
|
:placeholder='title' |
|
|
|
:clearResult="false" |
|
|
|
headerType="HMQ,HPQ"> |
|
|
|
<win-com-scan ref="scan" @getResult="getScanResult" :placeholder='title' :clearResult="false" |
|
|
|
headerType="HMQ,HPQ"> |
|
|
|
</win-com-scan> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
|
|
|
|
</view> |
|
|
|
</uni-popup> |
|
|
|
|
|
|
|
<comMessage ref="comMessage"></comMessage> |
|
|
|
</view> |
|
|
|
|
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
import { |
|
|
|
getBasicItemByCode |
|
|
|
} from '@/api/request2.js'; |
|
|
|
|
|
|
|
import { |
|
|
|
getLocationTypeName, |
|
|
|
getListLocationTypeDesc, |
|
|
|
checkDirectoryItemExist, |
|
|
|
getListItemTypeDesc, |
|
|
|
getItemTypeInfo |
|
|
|
} from '@/common/directory.js'; |
|
|
|
|
|
|
|
import winComScan from '@/mycomponents/scan/winComScan.vue' |
|
|
|
import comMessage from '@/mycomponents/common/comMessage.vue' |
|
|
|
|
|
|
|
export default { |
|
|
|
name: 'winScanItem', |
|
|
|
components: { |
|
|
|
winComScan |
|
|
|
winComScan, |
|
|
|
comMessage |
|
|
|
}, |
|
|
|
emits: ["getScanCode",'getScanResult'], |
|
|
|
emits: ["getScanCode", 'getScanResult'], |
|
|
|
props: { |
|
|
|
title: { |
|
|
|
type: String, |
|
|
@ -44,7 +57,11 @@ |
|
|
|
isShowRecord: { |
|
|
|
type: Boolean, |
|
|
|
default: true |
|
|
|
} |
|
|
|
}, |
|
|
|
itemCodeTypeList: { |
|
|
|
type: Array, |
|
|
|
default: [] |
|
|
|
}, |
|
|
|
}, |
|
|
|
data() { |
|
|
|
return { |
|
|
@ -80,22 +97,76 @@ |
|
|
|
this.$refs.scan.clearScanValue(); |
|
|
|
}, |
|
|
|
getScanResult(result) { |
|
|
|
this.result = result; |
|
|
|
if (result.label.barType == "QRCode") { |
|
|
|
this.code = result.label.itemCode; |
|
|
|
} else if (result.label.barType == "BarCode") { |
|
|
|
this.code = result.label.code; |
|
|
|
uni.showLoading({ |
|
|
|
title: '扫描中...', |
|
|
|
mask: true |
|
|
|
}); |
|
|
|
|
|
|
|
var scanResult = result; |
|
|
|
if (scanResult.label.barType == "QRCode") { |
|
|
|
this.code = scanResult.label.itemCode; |
|
|
|
} else if (scanResult.label.barType == "BarCode") { |
|
|
|
this.code = scanResult.label.code; |
|
|
|
} |
|
|
|
if (this.code == undefined) { |
|
|
|
uni.hideLoading(); |
|
|
|
this.showErrorMessage("扫描物料[" + this.code + "]为空,请输入正确的物料") |
|
|
|
return |
|
|
|
} |
|
|
|
this.callBack(); |
|
|
|
getBasicItemByCode(this.code).then(res => { |
|
|
|
uni.hideLoading(); |
|
|
|
if (res.data != null && res.data.list.length > 0) { |
|
|
|
var result =res.data.list[0]; |
|
|
|
var status =result.status; |
|
|
|
var type = result.type; |
|
|
|
var itemCode = result.code |
|
|
|
var itemName =result.name |
|
|
|
var uom = result.uom |
|
|
|
var std = result.uom |
|
|
|
result.package = scanResult.package |
|
|
|
if(status=="ENABLE"){ |
|
|
|
if(checkDirectoryItemExist(this.itemCodeTypeList,type)){ |
|
|
|
this.result =result; |
|
|
|
this.callBack() |
|
|
|
}else { |
|
|
|
var hint = getListItemTypeDesc(this.itemCodeTypeList); |
|
|
|
this.showErrorMessage("扫描物料[" + this.code + "]是[" + |
|
|
|
getItemTypeInfo(type).label + "],需要的物料类型是[" + hint + "]") |
|
|
|
} |
|
|
|
}else { |
|
|
|
this.showErrorMessage('物料【' + this.code + '】不可用'); |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.showErrorMessage('未查找到物料【' + this.code + '】'); |
|
|
|
} |
|
|
|
}).catch(error => { |
|
|
|
uni.hideLoading(); |
|
|
|
this.showErrorMessage(error) |
|
|
|
}) |
|
|
|
}, |
|
|
|
callBack() { |
|
|
|
this.closeScanPopup(); |
|
|
|
this.$refs.scan.clear(); |
|
|
|
this.$emit("getScanCode", this.code); |
|
|
|
// this.$emit("getScanCode", this.code); |
|
|
|
this.$emit("getScanResult", this.code, this.result); |
|
|
|
}, |
|
|
|
change(e) { |
|
|
|
this.isShow = e.show |
|
|
|
} |
|
|
|
}, |
|
|
|
showErrorMessage(message) { |
|
|
|
this.losefocus(); |
|
|
|
this.$refs.comMessage.showErrorMessage(message, res => { |
|
|
|
this.code = ''; |
|
|
|
this.getfocus(); |
|
|
|
}) |
|
|
|
}, |
|
|
|
getfocus() { |
|
|
|
this.$refs.scan.getfocus(); |
|
|
|
}, |
|
|
|
losefocus() { |
|
|
|
this.$refs.scan.losefocus(); |
|
|
|
}, |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
|