feat(scanner): 多厂商PDA扫码器兼容方案及扫码功能重构

- 采用策略模式及配置表驱动方式支持多品牌扫码器广播注册
- 实现扫码广播的统一注册和注销管理,支持并发多个扫码广播接收器
- 重构扫码处理逻辑,统一处理扫码结果,支持条码和二维码识别
- 移除原有单一品牌扫码注册,整合商米、新大陆等扫码头支持
- 调整扫码相关页面代码,集成scanMixin,实现扫码广播注册和注销自动化
- 优化扫码结果处理,支持删除模式及整缸扫描状态区分
- 修正多处界面文本格式与代码风格,提高代码一致性和可维护性
- 升级manifest版本号至1.1.3,标记此功能更新
This commit is contained in:
郭鸿轩 2026-01-04 13:57:28 +08:00
parent 9e4be6db92
commit 9272ed0e23
6 changed files with 1262 additions and 1580 deletions

View File

@ -1,143 +1,175 @@
// common/scanMixin.js // common/scanMixin.js
// 多厂商PDA扫码器兼容方案 - 策略模式 + 配置表驱动
export default { export default {
data() { data() {
return { return {
scanReceiver: null, scanReceivers: [], // 支持多个接收器
isPageActive: false isPageActive: false,
registeredBrands: [] // 已注册的品牌
} }
}, },
methods: { methods: {
// 注册扫码广播(兼容多种设备) // 扫码器配置表 - 方便扩展新厂商
registerScanBroadcast(scanCallback) { getScannerConfigs() {
try { return [
// 先尝试注册商米扫码头 {
this.registerSunmiBroadcast(scanCallback) brand: 'newland', // 东集
.then(() => { name: '东集',
console.log('商米扫码头注册成功'); action: 'com.android.server.scannerservice.broadcast',
}) dataKey: 'scannerdata',
.catch((error) => { needSetup: true,
console.log('商米扫码头注册失败,尝试新大陆扫码头:', error); setupAction: 'com.android.scanner.service_settings',
// 如果商米扫码头注册失败,尝试新大陆扫码头 setupParams: {
this.registerNewlandBroadcast(scanCallback); action_barcode_broadcast: 'com.android.server.scannerservice.broadcast',
}); key_barcode_broadcast: 'scannerdata',
} catch (error) { endchar: 'ENTER'
console.error("注册扫码广播失败:", error); }
return false; },
} {
brand: 'sunmi', // 商米
name: '商米',
action: 'com.sunmi.scanner.ACTION_DATA_CODE_RECEIVED',
dataKey: 'data',
needSetup: false
},
// {
// brand: 'honeywell', // 霍尼韦尔
// name: '霍尼韦尔',
// action: 'com.honeywell.decode.intent.action.EDIT_DATA',
// dataKey: 'data',
// needSetup: false
// },
// {
// brand: 'zebra', // 斑马
// name: '斑马',
// action: 'com.symbol.datawedge.api.RESULT_ACTION',
// dataKey: 'com.symbol.datawedge.data_string',
// needSetup: false
// },
// {
// brand: 'idata', // 盈达聚力
// name: '盈达聚力',
// action: 'android.intent.action.SCANRESULT',
// dataKey: 'value',
// needSetup: false
// },
// {
// brand: 'urovo', // 优博讯
// name: '优博讯',
// action: 'android.intent.ACTION_DECODE_DATA',
// dataKey: 'barcode_string',
// needSetup: false
// }
];
}, },
// 注册商米扫码头广播接收器 // 注册所有扫码广播(推荐方式:同时注册所有厂商)
registerSunmiBroadcast(scanCallback) { registerScanBroadcast(scanCallback) {
return new Promise((resolve, reject) => { // #ifdef APP-PLUS
const configs = this.getScannerConfigs();
configs.forEach(config => {
try { try {
const main = plus.android.runtimeMainActivity(); this.registerSingleBroadcast(config, scanCallback);
const IntentFilter = plus.android.importClass("android.content.IntentFilter"); this.registeredBrands.push(config.brand);
console.log(`${config.name}扫码广播注册成功`);
const filter = new IntentFilter();
filter.addAction("com.sunmi.scanner.ACTION_DATA_CODE_RECEIVED");
const self = this;
const receiver = plus.android.implements(
"io.dcloud.feature.internal.reflect.BroadcastReceiver",
{
onReceive: (context, intent) => {
console.log('商米扫码广播接收isPageActive:', self.isPageActive);
// 只有当页面活动时才处理广播
if (!self.isPageActive) return;
try {
// 导入 Intent 类以使用其方法
const Intent = plus.android.importClass("android.content.Intent");
const scanResult = intent.getStringExtra("data");
const sourceBytes = intent.getByteArrayExtra("source_byte");
console.log('商米扫码结果:', scanResult, sourceBytes);
if (scanResult) {
self.handleScanResult(scanResult, scanCallback);
}
} catch (error) {
console.error('处理商米广播数据时出错:', error);
}
}
}
);
// 注册广播接收器
main.registerReceiver(receiver, filter);
this.scanReceiver = receiver;
console.log('商米扫码广播接收器注册成功');
resolve();
} catch (error) { } catch (error) {
console.error('注册商米广播接收器失败:', error); console.log(`${config.name}扫码广播注册失败:`, error);
reject(error);
} }
}); });
if (this.registeredBrands.length > 0) {
console.log('扫码广播注册完成,已注册厂商:', this.registeredBrands.join(', '));
return true;
}
console.error('所有扫码广播注册均失败');
return false;
// #endif
}, },
// 注册新大陆扫码头广播接收器 // 注册指定厂商的扫码广播
registerNewlandBroadcast(scanCallback) { registerScanBroadcastByBrand(brand, scanCallback) {
try { // #ifdef APP-PLUS
const main = plus.android.runtimeMainActivity(); const configs = this.getScannerConfigs();
const config = configs.find(c => c.brand === brand);
// 先配置扫码枪广播设置 if (!config) {
try { console.error(`未找到厂商配置: ${brand}`);
const Intent = plus.android.importClass("android.content.Intent"); return false;
const intent = new Intent("com.android.scanner.service_settings");
intent.putExtra(
"action_barcode_broadcast",
"com.android.server.scannerservice.broadcast"
);
intent.putExtra("key_barcode_broadcast", "scannerdata");
main.sendBroadcast(intent);
console.log('新大陆扫码枪广播配置完成');
} catch (error) {
console.error("配置新大陆扫码枪广播失败:", error);
}
// 注册广播接收器
const IntentFilter = plus.android.importClass(
"android.content.IntentFilter"
);
const filter = new IntentFilter();
filter.addAction("com.android.server.scannerservice.broadcast");
console.log("添加新大陆广播action完成");
const self = this;
const receiver = plus.android.implements(
"io.dcloud.feature.internal.reflect.BroadcastReceiver",
{
onReceive: (context, intent) => {
console.log('新大陆扫码广播接收isPageActive:', self.isPageActive);
// 只有当页面活动时才处理广播
if (!self.isPageActive) return;
try {
// 导入 Intent 类以使用其方法
const Intent = plus.android.importClass("android.content.Intent");
const scanResult = intent.getStringExtra("scannerdata");
console.log("新大陆扫码结果:", scanResult);
if (scanResult) {
self.handleScanResult(scanResult, scanCallback);
}
} catch (error) {
console.error("处理新大陆广播数据时出错:", error);
}
},
}
);
// 注册广播接收器
main.registerReceiver(receiver, filter);
this.scanReceiver = receiver;
console.log("新大陆扫码广播注册成功,等待扫码...");
} catch (error) {
console.error("注册新大陆扫码广播失败:", error);
throw error;
} }
try {
this.registerSingleBroadcast(config, scanCallback);
this.registeredBrands.push(config.brand);
console.log(`${config.name}扫码广播注册成功`);
return true;
} catch (error) {
console.error(`${config.name}扫码广播注册失败:`, error);
return false;
}
// #endif
},
// 单个广播注册的核心方法
registerSingleBroadcast(config, scanCallback) {
const main = plus.android.runtimeMainActivity();
// 如果需要预配置(如东集)
if (config.needSetup && config.setupAction) {
try {
const Intent = plus.android.importClass('android.content.Intent');
const setupIntent = new Intent(config.setupAction);
Object.keys(config.setupParams || {}).forEach(key => {
setupIntent.putExtra(key, config.setupParams[key]);
});
main.sendBroadcast(setupIntent);
console.log(`${config.name}扫码配置完成`);
} catch (error) {
console.error(`${config.name}扫码配置失败:`, error);
}
}
// 注册广播接收器
const IntentFilter = plus.android.importClass('android.content.IntentFilter');
const filter = new IntentFilter();
filter.addAction(config.action);
const self = this;
const receiver = plus.android.implements(
'io.dcloud.feature.internal.reflect.BroadcastReceiver',
{
onReceive: (context, intent) => {
console.log(`${config.name}扫码广播接收isPageActive:`, self.isPageActive);
if (!self.isPageActive) return;
try {
plus.android.importClass('android.content.Intent');
const scanResult = intent.getStringExtra(config.dataKey);
console.log(`${config.name}扫码结果:`, scanResult);
if (scanResult) {
self.handleScanResult(scanResult, scanCallback);
}
} catch (error) {
console.error(`处理${config.name}广播数据出错:`, error);
}
}
}
);
main.registerReceiver(receiver, filter);
// 保存接收器引用,用于后续注销
this.scanReceivers.push({
brand: config.brand,
receiver: receiver
});
}, },
// 处理扫码结果的统一方法 // 处理扫码结果的统一方法
@ -156,18 +188,30 @@ export default {
} }
}, },
// 取消扫码广播监听 // 取消所有扫码广播监听
unregisterScanBroadcast() { unregisterScanBroadcast() {
if (this.scanReceiver) { // #ifdef APP-PLUS
try { if (this.scanReceivers.length === 0) return;
const main = plus.android.runtimeMainActivity();
main.unregisterReceiver(this.scanReceiver); try {
this.scanReceiver = null; const main = plus.android.runtimeMainActivity();
console.log("扫码广播注销成功");
} catch (err) { this.scanReceivers.forEach(item => {
console.error("注销扫码广播失败:", err); try {
} main.unregisterReceiver(item.receiver);
console.log(`${item.brand}扫码广播注销成功`);
} catch (err) {
console.error(`${item.brand}扫码广播注销失败:`, err);
}
});
this.scanReceivers = [];
this.registeredBrands = [];
console.log('所有扫码广播注销完成');
} catch (err) {
console.error('注销扫码广播失败:', err);
} }
// #endif
}, },
// 通用的商品扫描处理方法 // 通用的商品扫描处理方法

View File

@ -2,8 +2,8 @@
"name" : "浩拓技术", "name" : "浩拓技术",
"appid" : "__UNI__F79F300", "appid" : "__UNI__F79F300",
"description" : "浩拓纺织平台", "description" : "浩拓纺织平台",
"versionName" : "1.1.2", "versionName" : "1.1.3",
"versionCode" : 112, "versionCode" : 103,
"transformPx" : false, "transformPx" : false,
"app-plus" : { "app-plus" : {
"optimization" : { "optimization" : {

View File

@ -6,31 +6,17 @@
<text class="title" style="width: 200px">日期{{ BillDate }}</text> <text class="title" style="width: 200px">日期{{ BillDate }}</text>
</u-form-item> </u-form-item>
<u-form-item> <u-form-item>
<text class="title" style="width: 200px" <text class="title" style="width: 200px">客户名称{{ CustomerName }}</text>
>客户名称{{ CustomerName }}</text <text class="title" style="width: 200px"> {{ SaleUserName }}</text>
>
<text class="title" style="width: 200px"
> {{ SaleUserName }}</text
>
</u-form-item> </u-form-item>
<u-form-item> <u-form-item>
<text class="title" style="width: 200px" <text class="title" style="width: 200px">仓库名称{{ StoreName }}{{ ToStoreName }}</text>
>仓库名称{{ StoreName }}{{ ToStoreName }}</text
>
</u-form-item> </u-form-item>
<u-form-item> <u-form-item>
<text class="title" style="width: 200px" <text class="title" style="width: 200px">备注内容{{ BillRemark }}</text>
>备注内容{{ BillRemark }}</text
>
</u-form-item> </u-form-item>
<u-form-item label-width="130" label="条码资料:"> <u-form-item label-width="130" label="条码资料:">
<input <input type="text" v-model="QRBarCode" maxlength="-1" style="width: 170px" @confirm="SalePickBillDetailScan" />
type="text"
v-model="QRBarCode"
maxlength="-1"
style="width: 170px"
@confirm="SalePickBillDetailScan"
/>
<checkbox-group @change="handleAllCrockNoChange"> <checkbox-group @change="handleAllCrockNoChange">
<checkbox :checked="AllCrockNoScanStatus">整缸</checkbox> <checkbox :checked="AllCrockNoScanStatus">整缸</checkbox>
</checkbox-group> </checkbox-group>
@ -41,58 +27,38 @@
</u-form> </u-form>
<u-form ref="uForm"> <u-form ref="uForm">
<u-form-item> <u-form-item>
<text class="title" style="width: 400px" <text class="title" style="width: 400px">成品名称{{ FabricGoodsNo }}{{ FabricGoodsName }}</text>
>成品名称{{ FabricGoodsNo }}{{ FabricGoodsName }}</text
>
</u-form-item> </u-form-item>
<u-form-item> <u-form-item>
<text class="title" style="width: 400px" <text class="title" style="width: 400px">色号颜色{{ GoodsCodeNo }}{{ GoodsCodeName }}</text>
>色号颜色{{ GoodsCodeNo }}{{ GoodsCodeName }}</text
>
</u-form-item> </u-form-item>
<u-form-item> <u-form-item>
<text class="title" style="width: 200px">成品缸号{{ CrockNo }}</text> <text class="title" style="width: 200px">成品缸号{{ CrockNo }}</text>
<text class="title" style="width: 200px" <text class="title" style="width: 200px">成品卷号{{ GoodsBillNo }}</text>
>成品卷号{{ GoodsBillNo }}</text
>
</u-form-item> </u-form-item>
<u-form-item> <u-form-item>
<text class="title">{{ BillDataMessage }}</text> <text class="title">{{ BillDataMessage }}</text>
</u-form-item> </u-form-item>
<u-form-item> <u-form-item>
<text class="title" style="width: 130px" <text class="title" style="width: 130px">配布条数{{ BillSumRoll }}</text>
>配布条数{{ BillSumRoll }}</text
>
<text class="title" style="width: 130px">数量{{ BillSumQty }}</text> <text class="title" style="width: 130px">数量{{ BillSumQty }}</text>
<text class="title" style="width: 120px">米数{{ BillSumMQty }}</text> <text class="title" style="width: 120px">米数{{ BillSumMQty }}</text>
</u-form-item> </u-form-item>
<u-form-item> <u-form-item>
<text class="title" style="width: 130px" <text class="title" style="width: 130px">已配条数{{ BillScanRoll }}</text>
>已配条数{{ BillScanRoll }}</text
>
<text class="title" style="width: 130px">数量{{ BillScanQty }}</text> <text class="title" style="width: 130px">数量{{ BillScanQty }}</text>
<text class="title" style="width: 120px">米数{{ BillScanMQty }}</text> <text class="title" style="width: 120px">米数{{ BillScanMQty }}</text>
</u-form-item> </u-form-item>
<view class="submitView"> <view class="submitView">
<u-button <u-button type="primary" class="submitBtn" :ripple="true" :loading="submitLoading" ripple-bg-color="#909399"
type="primary" @click="submitBtnFun">
class="submitBtn"
:ripple="true"
:loading="submitLoading"
ripple-bg-color="#909399"
@click="submitBtnFun"
>
{{ pageType ? "保存" : "提交" }} {{ pageType ? "保存" : "提交" }}
</u-button> </u-button>
</view> </view>
</u-form> </u-form>
<view class="u-demo-area"> <view class="u-demo-area">
<u-toast ref="uToast"></u-toast> <u-toast ref="uToast"></u-toast>
<wyb-table <wyb-table ref="table" :headers="headersMaster" :contents="GoodsDetailList" />
ref="table"
:headers="headersMaster"
:contents="GoodsDetailList"
/>
</view> </view>
</view> </view>
</template> </template>
@ -105,8 +71,10 @@ import util, {
playErrorAudio, playErrorAudio,
} from "../../common/util"; } from "../../common/util";
import wybTable from "@/components/wyb-table/wyb-table.vue"; import wybTable from "@/components/wyb-table/wyb-table.vue";
import scanMixin from "@/common/scanMixin.js";
let that = ""; let that = "";
export default { export default {
mixins: [scanMixin],
data() { data() {
return { return {
SaleBillNo: "", // SaleBillNo: "", //
@ -115,7 +83,7 @@ export default {
align: "center", align: "center",
index: 0, index: 0,
pageType: "", pageType: "",
submitLoading: false, submitLoading: false,
actionSheetShow: false, actionSheetShow: false,
QRBarCode: "", QRBarCode: "",
BillNo: "", BillNo: "",
@ -192,8 +160,7 @@ export default {
], ],
scanningInput: "", // scanningInput: "", //
lastKeyTime: 0, // lastKeyTime: 0, //
scanReceiver: null, // scanReceiver isPageActive scanMixin
isPageActive: false, //
}; };
}, },
@ -214,14 +181,13 @@ export default {
}, },
onUnload() { onUnload() {
// #ifdef APP-PLUS
this.isPageActive = false; this.isPageActive = false;
// #ifdef APP-PLUS
this.unregisterScanBroadcast(); this.unregisterScanBroadcast();
// #endif // #endif
}, },
onHide() { onHide() {
//
this.isPageActive = false; this.isPageActive = false;
// #ifdef APP-PLUS // #ifdef APP-PLUS
this.unregisterScanBroadcast(); this.unregisterScanBroadcast();
@ -229,10 +195,15 @@ export default {
}, },
onShow() { onShow() {
//
this.isPageActive = true; this.isPageActive = true;
// #ifdef APP-PLUS // #ifdef APP-PLUS
this.registerScanBroadcast(); this.registerScanBroadcast((scanResult) => {
console.log("配布单详情-扫码结果:", scanResult);
this.QRBarCode = scanResult;
this.$nextTick(() => {
this.handleScans();
});
});
// #endif // #endif
}, },
@ -323,247 +294,93 @@ export default {
icon: 'success' icon: 'success'
}); });
}, },
handleScans() { handleScans() {
// //
let aBarCodeDelStatus = 1; // 1=3= let aBarCodeDelStatus = 1; // 1=3=
if (this.BarCodeDelStatus) { if (this.BarCodeDelStatus) {
aBarCodeDelStatus = 3; aBarCodeDelStatus = 3;
}
//
let aAllCrockNoScanStatus = 2; // 0=1=
if (this.AllCrockNoScanStatus) {
aAllCrockNoScanStatus = "1";
}
//
let cleanCode = this.QRBarCode.replace(/\s+/g, '').replace(/[\r\n]/g, '');
console.log("this.QRBarCode ---->>" + cleanCode);
//
let aQRBarCode = "";
let aBarCode = "";
if (cleanCode.startsWith("66^") || cleanCode.startsWith("99^") || /[\u4E00-\u9FA5]/.test(cleanCode)) {
aQRBarCode = cleanCode;
} else {
aBarCode = cleanCode;
}
if (aQRBarCode == "" && aBarCode == "") {
this.QRBarCode = "";
this.showError('请扫描二维码或者条码');
return;
}
console.log('请求参数', aBarCodeDelStatus);
console.log('请求参数', aBarCode);
console.log('请求参数', aQRBarCode);
console.log('请求参数', this.BillMasterID);
console.log('请求参数 SaleBillNo', this.SaleBillNo);
console.log('请求参数 token', uni.getStorageSync("userToken").Token);
//
util.request({
url: "/product/fpmArrangeOrder/updateFpmArrangeOrder",
method: "PUT",
header: {
Platform: 2,
Authorization: uni.getStorageSync("userToken").Token,
},
data: {
arrange_type: aBarCodeDelStatus, // 1=3=
bar_code: aBarCode, // 使
qr_code: aQRBarCode, // 使
id: parseInt(this.BillMasterID), // ID
// order_no: this.SaleBillNo, //
},
success: (res) => {
console.log('API响应:', res);
if (res.data.code == 0 && res.data.msg == "success") {
var aResultData = res.data.data;
this.playSuccess();
this.FabricGoodsNo = aResultData.product_code;
this.FabricGoodsName = aResultData.product_name;
this.GoodsCodeNo = aResultData.product_color_code;
this.GoodsCodeName = aResultData.product_color_name;
this.CrockNo = aResultData.dyelot_number;
this.GoodsBillNo = aResultData.volume_number;
this.QRBarCode = "";
if (aBarCodeDelStatus == 1) {
this.showSuccess("扫描成功!");
} else {
this.showSuccess("删除成功!");
}
this.SalePickDetail();
} else {
this.showError("扫描出错," + res.data.msg);
this.QRBarCode = "";
}
},
fail: (error) => {
console.error('API请求失败:', error);
this.QRBarCode = "";
this.showError("连接服务器出错,请检查后台服务是否启动!");
},
});
},
// 广
registerScanBroadcast() {
try {
//
this.registerSunmiBroadcast()
.then(() => {
console.log('商米扫码头注册成功');
})
.catch((error) => {
console.log('商米扫码头注册失败,尝试新大陆扫码头:', error);
//
this.registerNewlandBroadcast();
});
} catch (error) {
console.error("注册扫码广播失败:", error);
} }
},
// 广 //
registerSunmiBroadcast() { let aAllCrockNoScanStatus = 2; // 0=1=
return new Promise((resolve, reject) => { if (this.AllCrockNoScanStatus) {
try { aAllCrockNoScanStatus = "1";
const main = plus.android.runtimeMainActivity(); }
const IntentFilter = plus.android.importClass("android.content.IntentFilter");
const filter = new IntentFilter(); //
filter.addAction("com.sunmi.scanner.ACTION_DATA_CODE_RECEIVED"); let cleanCode = this.QRBarCode.replace(/\s+/g, '').replace(/[\r\n]/g, '');
const receiver = plus.android.implements( console.log("this.QRBarCode ---->>" + cleanCode);
"io.dcloud.feature.internal.reflect.BroadcastReceiver",
{
onReceive: (context, intent) => {
console.log('商米扫码广播接收isPageActive:', this.isPageActive);
// 广
if (!this.isPageActive) return;
try { //
const scanResult = intent.getStringExtra("data"); let aQRBarCode = "";
const sourceBytes = intent.getByteArrayExtra("source_byte"); let aBarCode = "";
console.log('商米扫码结果:', scanResult, sourceBytes); if (cleanCode.startsWith("66^") || cleanCode.startsWith("99^") || /[\u4E00-\u9FA5]/.test(cleanCode)) {
aQRBarCode = cleanCode;
} else {
aBarCode = cleanCode;
}
if (scanResult) { if (aQRBarCode == "" && aBarCode == "") {
this.handleScanResult(scanResult); this.QRBarCode = "";
} this.showError('请扫描二维码或者条码');
} catch (error) { return;
console.error('处理商米广播数据时出错:', error); }
}
} console.log('请求参数', aBarCodeDelStatus);
console.log('请求参数', aBarCode);
console.log('请求参数', aQRBarCode);
console.log('请求参数', this.BillMasterID);
console.log('请求参数 SaleBillNo', this.SaleBillNo);
console.log('请求参数 token', uni.getStorageSync("userToken").Token);
//
util.request({
url: "/product/fpmArrangeOrder/updateFpmArrangeOrder",
method: "PUT",
header: {
Platform: 2,
Authorization: uni.getStorageSync("userToken").Token,
},
data: {
arrange_type: aBarCodeDelStatus, // 1=3=
bar_code: aBarCode, // 使
qr_code: aQRBarCode, // 使
id: parseInt(this.BillMasterID), // ID
// order_no: this.SaleBillNo, //
},
success: (res) => {
console.log('API响应:', res);
if (res.data.code == 0 && res.data.msg == "success") {
var aResultData = res.data.data;
this.playSuccess();
this.FabricGoodsNo = aResultData.product_code;
this.FabricGoodsName = aResultData.product_name;
this.GoodsCodeNo = aResultData.product_color_code;
this.GoodsCodeName = aResultData.product_color_name;
this.CrockNo = aResultData.dyelot_number;
this.GoodsBillNo = aResultData.volume_number;
this.QRBarCode = "";
if (aBarCodeDelStatus == 1) {
this.showSuccess("扫描成功!");
} else {
this.showSuccess("删除成功!");
} }
);
// 广 this.SalePickDetail();
main.registerReceiver(receiver, filter); } else {
this.scanReceiver = receiver; this.showError("扫描出错," + res.data.msg);
console.log('商米扫码广播接收器注册成功'); this.QRBarCode = "";
resolve();
} catch (error) {
console.error('注册商米广播接收器失败:', error);
reject(error);
}
});
},
// 广
registerNewlandBroadcast() {
try {
const main = plus.android.runtimeMainActivity();
// 广
try {
const Intent = plus.android.importClass("android.content.Intent");
const intent = new Intent("com.android.scanner.service_settings");
intent.putExtra(
"action_barcode_broadcast",
"com.android.server.scannerservice.broadcast"
);
intent.putExtra("key_barcode_broadcast", "scannerdata");
main.sendBroadcast(intent);
console.log('新大陆扫码枪广播配置完成');
} catch (error) {
console.error("配置新大陆扫码枪广播失败:", error);
}
// 广
const IntentFilter = plus.android.importClass(
"android.content.IntentFilter"
);
const filter = new IntentFilter();
filter.addAction("com.android.server.scannerservice.broadcast");
console.log("添加新大陆广播action完成");
const receiver = plus.android.implements(
"io.dcloud.feature.internal.reflect.BroadcastReceiver",
{
onReceive: (context, intent) => {
console.log('新大陆扫码广播接收isPageActive:', this.isPageActive);
// 广
if (!this.isPageActive) return;
try {
const scanResult = intent.getStringExtra("scannerdata");
console.log("新大陆扫码结果:", scanResult);
if (scanResult) {
this.handleScanResult(scanResult);
}
} catch (error) {
console.error("处理新大陆广播数据时出错:", error);
}
},
} }
); },
fail: (error) => {
// 广 console.error('API请求失败:', error);
main.registerReceiver(receiver, filter); this.QRBarCode = "";
this.scanReceiver = receiver; this.showError("连接服务器出错,请检查后台服务是否启动!");
console.log("新大陆扫码广播注册成功,等待扫码..."); },
} catch (error) { });
console.error("注册新大陆扫码广播失败:", error);
throw error;
}
},
//
handleScanResult(scanResult) {
try {
//
let cleanCode = scanResult.replace(/\s+/g, '').replace(/[\r\n]/g, '');
console.log("配布单详情-扫码结果:", cleanCode);
this.QRBarCode = cleanCode;
this.$nextTick(() => {
this.handleScans();
});
} catch (error) {
console.error("处理扫码结果时出错:", error);
}
},
// 广
unregisterScanBroadcast() {
if (this.scanReceiver) {
try {
const main = plus.android.runtimeMainActivity();
main.unregisterReceiver(this.scanReceiver);
this.scanReceiver = null;
console.log("扫码广播注销成功");
} catch (error) {
console.error("注销扫码广播失败:", error);
}
}
}, },
SalePickBillDetailScan() { SalePickBillDetailScan() {
@ -601,13 +418,13 @@ export default {
} }
}, },
// //
submitOrder: function() { submitOrder: function () {
this.submitLoading = true this.submitLoading = true
this.$u.api.outFpmArrangeOrder({ this.$u.api.outFpmArrangeOrder({
id: parseInt(this.BillMasterID) id: parseInt(this.BillMasterID)
}).then(res => { }).then(res => {
this.submitLoading = false this.submitLoading = false
console.log('outFpmArrangeOrder res',res) console.log('outFpmArrangeOrder res', res)
if (res) { if (res) {
this.BillDataMessage = "成功生成出仓单!"; this.BillDataMessage = "成功生成出仓单!";
this.playSuccess(); this.playSuccess();
@ -617,7 +434,7 @@ export default {
return; return;
} }
}).catch(error => { }).catch(error => {
this.submitLoading = false this.submitLoading = false
this.playError(); this.playError();
this.BillDataMessage = "连接服务器出错,请检查后台服务是否启动!"; this.BillDataMessage = "连接服务器出错,请检查后台服务是否启动!";
}); });
@ -676,7 +493,7 @@ page {
margin-right: 12rpx; margin-right: 12rpx;
} }
.cpInput > input { .cpInput>input {
box-sizing: border-box; box-sizing: border-box;
border: 1rpx solid #dddddd; border: 1rpx solid #dddddd;
width: 100%; width: 100%;
@ -690,7 +507,7 @@ page {
margin-right: 12rpx; margin-right: 12rpx;
} }
.cpInput1 > input { .cpInput1>input {
box-sizing: border-box; box-sizing: border-box;
border: 1rpx solid #dddddd; border: 1rpx solid #dddddd;
width: 100%; width: 100%;

View File

@ -2,12 +2,12 @@
<view class="wrap"> <view class="wrap">
<u-form ref="uForm"> <u-form ref="uForm">
<u-form-item> <u-form-item>
<text class="title" style="width:200px;">单号{{GoodsCheckBillNo}}</text> <text class="title" style="width:200px;">单号{{ GoodsCheckBillNo }}</text>
<text class="title" style="width:200px;">日期{{GoodsCheckBillDate}}</text> <text class="title" style="width:200px;">日期{{ GoodsCheckBillDate }}</text>
</u-form-item> </u-form-item>
<u-form-item> <u-form-item>
<text class="title" style="width:200px;">仓库名称{{StoreName}}</text> <text class="title" style="width:200px;">仓库名称{{ StoreName }}</text>
<text class="title" style="width:200px;">仓位名称{{StoreStationName}}</text> <text class="title" style="width:200px;">仓位名称{{ StoreStationName }}</text>
</u-form-item> </u-form-item>
<u-form-item label-width="150" label="条码资料:"> <u-form-item label-width="150" label="条码资料:">
<input type="text" v-model="QRBarCode" maxlength="-1" style="width:200px;" <input type="text" v-model="QRBarCode" maxlength="-1" style="width:200px;"
@ -17,32 +17,32 @@
</checkbox-group> </checkbox-group>
</u-form-item> </u-form-item>
<u-form-item> <u-form-item>
<text class="title">{{BillDataMessage}}</text> <text class="title">{{ BillDataMessage }}</text>
</u-form-item> </u-form-item>
<u-form-item> <u-form-item>
<text class="title" style="width:200px;">成品编号{{FabricGoodsNo}}</text> <text class="title" style="width:200px;">成品编号{{ FabricGoodsNo }}</text>
<text class="title" style="width:200px;">成品重量{{GoodsQty}}KG</text> <text class="title" style="width:200px;">成品重量{{ GoodsQty }}KG</text>
</u-form-item> </u-form-item>
<u-form-item> <u-form-item>
<text class="title" style="width:200px;">成品色号{{GoodsCodeNo}}</text> <text class="title" style="width:200px;">成品色号{{ GoodsCodeNo }}</text>
<text class="title" style="width:200px;">成品颜色{{GoodsCodeName}}</text> <text class="title" style="width:200px;">成品颜色{{ GoodsCodeName }}</text>
</u-form-item> </u-form-item>
<u-form-item> <u-form-item>
<text class="title" style="width:200px;">成品缸号{{CrockNo}}</text> <text class="title" style="width:200px;">成品缸号{{ CrockNo }}</text>
<text class="title" style="width:200px;">缸号卷号{{GoodsBillNo}}</text> <text class="title" style="width:200px;">缸号卷号{{ GoodsBillNo }}</text>
</u-form-item> </u-form-item>
<u-form-item> <u-form-item>
<text class="title" style="width:200px;">本架盘前{{BillSumOldRoll}}</text> <text class="title" style="width:200px;">本架盘前{{ BillSumOldRoll }}</text>
<text class="title" style="width:200px;">本架实盘{{BillSumNewRoll}}</text> <text class="title" style="width:200px;">本架实盘{{ BillSumNewRoll }}</text>
</u-form-item> </u-form-item>
<u-form-item> <u-form-item>
<text class="title" style="width:200px;">本色盘前{{GoodsCodeNoSumOldRoll}}</text> <text class="title" style="width:200px;">本色盘前{{ GoodsCodeNoSumOldRoll }}</text>
<text class="title" style="width:200px;">本色实盘{{GoodsCodeNoSumNewRoll}}</text> <text class="title" style="width:200px;">本色实盘{{ GoodsCodeNoSumNewRoll }}</text>
</u-form-item> </u-form-item>
<u-form-item> <u-form-item>
<text class="title" style="width:200px;">本缸盘前{{CrockNoSumOldRoll}}</text> <text class="title" style="width:200px;">本缸盘前{{ CrockNoSumOldRoll }}</text>
<text class="title" style="width:200px;">本缸实盘{{CrockNoSumNewRoll}}</text> <text class="title" style="width:200px;">本缸实盘{{ CrockNoSumNewRoll }}</text>
</u-form-item> </u-form-item>
</u-form> </u-form>
<view class="u-demo-area"> <view class="u-demo-area">
@ -55,417 +55,425 @@
<view class="submitView"> <view class="submitView">
<u-button type="primary" style="width:100px;" class="commitBtn" :ripple="true" ripple-bg-color="#909399" <u-button type="primary" style="width:100px;" class="commitBtn" :ripple="true" ripple-bg-color="#909399"
@click="commitBtnFun"> @click="commitBtnFun">
{{CommitType ? '消审' : '审核'}} {{ CommitType ? '消审' : '审核' }}
</u-button> </u-button>
</view> </view>
</view> </view>
</template> </template>
<script> <script>
import util, { import util, {
parFabricGoodsBarCode2D, parFabricGoodsBarCode2D,
parYarnGoodsBarCode2D, parYarnGoodsBarCode2D,
playSuccessAudio, playSuccessAudio,
playErrorAudio playErrorAudio
} from '../../common/util'; } from '../../common/util';
import scanMixin from '@/common/scanMixin.js'; import scanMixin from '@/common/scanMixin.js';
import wybTable from '@/components/wyb-table/wyb-table.vue'; import wybTable from '@/components/wyb-table/wyb-table.vue';
//let that = ''; //let that = '';
export default { export default {
mixins: [scanMixin], mixins: [scanMixin],
data() { data() {
return { return {
borderColor: '#e4e7ed', borderColor: '#e4e7ed',
align: 'center', align: 'center',
index: 0, index: 0,
CommitType: '', CommitType: '',
CommitProcName: '', CommitProcName: '',
actionSheetShow: false, actionSheetShow: false,
QRBarCode: '', QRBarCode: '',
GoodsCheckBillID: 0, GoodsCheckBillID: 0,
GoodsCheckBillNo: '', GoodsCheckBillNo: '',
GoodsCheckBillDate: '', GoodsCheckBillDate: '',
GoodsCheckBillMasterNo: '', GoodsCheckBillMasterNo: '',
StoreNameID: '', StoreNameID: '',
StoreName: '', StoreName: '',
StoreStationID: '', StoreStationID: '',
StoreStationNo: '', StoreStationNo: '',
StoreStationName: '', StoreStationName: '',
CustomerName: '', CustomerName: '',
FabricGoodsNo: '', FabricGoodsNo: '',
FabricGoodsName: '', FabricGoodsName: '',
GoodsCodeNo: '', GoodsCodeNo: '',
GoodsCodeName: '', GoodsCodeName: '',
CrockNo: '', CrockNo: '',
GoodsBillNo: '', GoodsBillNo: '',
GoodsQty: 0, GoodsQty: 0,
StoreStationNameFocus: false, StoreStationNameFocus: false,
BillSumOldRoll: 0, BillSumOldRoll: 0,
BillSumNewRoll: 0, BillSumNewRoll: 0,
GoodsCodeNoSumOldRoll: 0, GoodsCodeNoSumOldRoll: 0,
GoodsCodeNoSumNewRoll: 0, GoodsCodeNoSumNewRoll: 0,
CrockNoSumOldRoll: 0, CrockNoSumOldRoll: 0,
CrockNoSumNewRoll: 0, CrockNoSumNewRoll: 0,
BarCodeDelStatus: false, BarCodeDelStatus: false,
GoodsDetailList: [], GoodsDetailList: [],
BillDataMessage: '', BillDataMessage: '',
headersMaster: [{ headersMaster: [{
label: '成品编号', label: '成品编号',
key: 'product_code' key: 'product_code'
}, { }, {
label: '成品名称', label: '成品名称',
key: 'product_name' key: 'product_name'
}, { }, {
label: '成品色号', label: '成品色号',
key: 'product_color_code' key: 'product_color_code'
}, { }, {
label: '成品颜色', label: '成品颜色',
key: 'product_color_name' key: 'product_color_name'
}, { }, {
label: '成品缸号', label: '成品缸号',
key: 'dyelot_number' key: 'dyelot_number'
}, { }, {
label: '盘前条数', label: '盘前条数',
key: 'roll' key: 'roll'
}, { }, {
label: '实盘条数', label: '实盘条数',
key: 'check_roll' key: 'check_roll'
}, { }, {
label: '盈亏条数', label: '盈亏条数',
key: 'different_roll' key: 'different_roll'
}], }],
// scanReceiver isPageActive scanMixin // scanReceiver isPageActive scanMixin
} }
}, },
onLoad(e) { onLoad(e) {
//that = this; //that = this;
if (e.billid) { if (e.billid) {
this.GoodsCheckBillID = e.billid; this.GoodsCheckBillID = e.billid;
this.GoodsCheckBillDetailData(); this.GoodsCheckBillDetailData();
} }
}, },
onShow() { onShow() {
// mixin onShow //
if (this.$options.mixins && this.$options.mixins[0] && this.$options.mixins[0].onShow) { this.isPageActive = true;
this.$options.mixins[0].onShow.call(this);
}
// #ifdef APP-PLUS // #ifdef APP-PLUS
this.registerScanBroadcast((scanResult) => { this.registerScanBroadcast((scanResult) => {
console.log("扫码结果:", scanResult); console.log("扫码结果:", scanResult);
// //
if(!this.QRBarCode){ this.QRBarCode = scanResult;
console.log("请先扫描资料!", scanResult); this.$nextTick(() => {
this.QRBarCode = scanResult; this.GoodsCheckBillDetailScan();
this.$nextTick(() => { });
this.GoodsCheckBillDetailScan(); });
}); // #endif
return; },
}
onHide() {
this.isPageActive = false;
// #ifdef APP-PLUS
this.unregisterScanBroadcast();
// #endif
},
onUnload() {
this.isPageActive = false;
// #ifdef APP-PLUS
this.unregisterScanBroadcast();
// #endif
},
methods: {
//
showError(message) {
this.playError();
uni.showModal({
title: '提示',
content: message,
showCancel: false
}); });
// #endif
}, },
methods: {
//
showError(message) {
this.playError();
uni.showModal({
title: '提示',
content: message,
showCancel: false
});
},
playSuccess() { playSuccess() {
util.playSuccessAudio(); util.playSuccessAudio();
}, },
playError() { playError() {
util.playErrorAudio(); util.playErrorAudio();
}, },
BarCodeDelChange: function() { BarCodeDelChange: function () {
this.BarCodeDelStatus = !this.BarCodeDelStatus; this.BarCodeDelStatus = !this.BarCodeDelStatus;
}, },
GoodsCheckBillDetailScan() { GoodsCheckBillDetailScan() {
if (this.StoreNameID == 0 && this.GoodsCheckBillNo == '') { if (this.StoreNameID == 0 && this.GoodsCheckBillNo == '') {
this.QRBarCode = ''; this.QRBarCode = '';
this.showError('请先新增单据'); this.showError('请先新增单据');
return; return;
} }
// //
let cleanCode = this.QRBarCode.replace(/\s+/g, '').replace(/[\r\n]/g, ''); let cleanCode = this.QRBarCode.replace(/\s+/g, '').replace(/[\r\n]/g, '');
console.log("this.QRBarCode ---->>" + cleanCode); console.log("this.QRBarCode ---->>" + cleanCode);
var aQRBarCode = ''; var aQRBarCode = '';
var aBarCode = ''; var aBarCode = '';
if (cleanCode.startsWith('66^')>0 || cleanCode.startsWith('99^')>0 || /[\u4E00-\u9FA5]/.test(cleanCode)){ if (cleanCode.startsWith('66^') > 0 || cleanCode.startsWith('99^') > 0 || /[\u4E00-\u9FA5]/.test(cleanCode)) {
aQRBarCode = cleanCode aQRBarCode = cleanCode
}else { } else {
aBarCode = cleanCode; aBarCode = cleanCode;
} }
if (aQRBarCode == '' && aBarCode == ''){ if (aQRBarCode == '' && aBarCode == '') {
this.QRBarCode = ''; this.QRBarCode = '';
this.aBarCode = '' this.aBarCode = ''
this.showError('请扫描二维码或者条码'); this.showError('请扫描二维码或者条码');
return; return;
} }
let aBarCodeDelStatus = 1 let aBarCodeDelStatus = 1
if (this.BarCodeDelStatus) { if (this.BarCodeDelStatus) {
aBarCodeDelStatus = 3; aBarCodeDelStatus = 3;
}; };
util.request({ util.request({
url: '/product/productCheckOrder/updateProductCheckOrder', url: '/product/productCheckOrder/updateProductCheckOrder',
method: 'put', method: 'put',
data: { data: {
'arrange_type': aBarCodeDelStatus, 'arrange_type': aBarCodeDelStatus,
'id': parseInt(this.GoodsCheckBillID), 'id': parseInt(this.GoodsCheckBillID),
'bar_code': aBarCode, 'bar_code': aBarCode,
'qr_code': aQRBarCode, 'qr_code': aQRBarCode,
}, },
success: (res) => { success: (res) => {
console.log("-->>--" + JSON.stringify(res.data)); console.log("-->>--" + JSON.stringify(res.data));
if (res.data.code == '0'){ if (res.data.code == '0') {
let aResultData = res.data.data; let aResultData = res.data.data;
this.FabricGoodsNo = aResultData.product_code; this.FabricGoodsNo = aResultData.product_code;
this.FabricGoodsName = aResultData.product_name; this.FabricGoodsName = aResultData.product_name;
this.GoodsCodeNo = aResultData.product_color_code; this.GoodsCodeNo = aResultData.product_color_code;
this.GoodsCodeName = aResultData.product_color_name; this.GoodsCodeName = aResultData.product_color_name;
this.CrockNo = aResultData.dyelot_number; this.CrockNo = aResultData.dyelot_number;
this.GoodsBillNo = aResultData.volume_number; this.GoodsBillNo = aResultData.volume_number;
this.GoodsQty = aResultData.weight / 10000; this.GoodsQty = aResultData.weight / 10000;
this.BillSumOldRoll = aResultData.warehouse_bin_check_before_roll/100; this.BillSumOldRoll = aResultData.warehouse_bin_check_before_roll / 100;
this.BillSumNewRoll = aResultData.warehouse_bin_check_roll/100; this.BillSumNewRoll = aResultData.warehouse_bin_check_roll / 100;
this.GoodsCodeNoSumOldRoll = aResultData.color_check_before_roll/100; this.GoodsCodeNoSumOldRoll = aResultData.color_check_before_roll / 100;
this.GoodsCodeNoSumNewRoll = aResultData.color_check_roll/100; this.GoodsCodeNoSumNewRoll = aResultData.color_check_roll / 100;
this.CrockNoSumOldRoll = aResultData.dye_check_before_roll/100; this.CrockNoSumOldRoll = aResultData.dye_check_before_roll / 100;
this.CrockNoSumNewRoll = aResultData.dye_check_roll/100; this.CrockNoSumNewRoll = aResultData.dye_check_roll / 100;
this.playSuccess();
this.GoodsCheckBillDetailData();
this.BillDataMessage = res.data.msg;
this.QRBarCode = '';
}
else {
this.showError(res.data.msg);
this.QRBarCode = '';
}
},
fail: (error) => {
this.showError('连接服务器出错,请检查后台服务是否启动!');
console.log('error', error)
},
})
},
GoodsCheckBillDetailData: function () {
console.log("--aaa->>" + this.GoodsCheckBillID);
console.log("--aaa->>" + this.GoodsCheckBillID);
util.request({
url: '/product/productCheckOrder/getProductCheckOrder',
method: 'get',
data: {
'id': parseInt(this.GoodsCheckBillID),
},
success: (res) => {
console.log("-->>--" + JSON.stringify(res.data.data));
this.GoodsDetailList = [];
this.GoodsCheckBillNo = res.data.data.order_no;
this.StoreName = res.data.data.warehouse_name
this.StoreStationName = res.data.data.warehouse_bin_name;
this.GoodsCheckBillDate = this.$u.timeFormat(res.data.data.check_time, 'yyyy-mm-dd')
/* this.BillSumOldRoll = res.data.data.item_data.roll;
this.BillSumNewRoll = res.data.data.item_data.check_roll; */
var aResultData = res.data.data.item_data;
this.BillSumOldRoll = 0;
this.BillSumNewRoll = 0;
for (var i = 0; i < aResultData.length; i++) {
aResultData[i].roll = aResultData[i].roll / 100;
aResultData[i].check_roll = aResultData[i].check_roll / 100;
aResultData[i].different_roll = aResultData[i].different_roll / 100;
this.BillSumOldRoll = this.BillSumOldRoll + aResultData[i].roll;
this.BillSumNewRoll = this.BillSumNewRoll + aResultData[i].check_roll;
};
this.GoodsDetailList = aResultData;
},
})
},
//
commitBtnFun: function () {
if (this.BillMasterID <= 0) {
this.showError('当前单据未提交,不能审核或消审!');
return;
}
var aCommitRecallName = '审核';
if (this.CommitType == '') {
aCommitRecallName = '审核';
} else {
aCommitRecallName = '消审';
}
// if (this.CommitProcName == '') {
// this.playError();
// this.BillDataMessage = '' + aCommitRecallName + '';
// return;
// }
console.log('GoodsCheckBillID', this.GoodsCheckBillID)
util.request({
url: '/product/productCheckOrder/updateProductCheckOrderAuditStatusPass',
method: 'put',
data: {
'id': parseInt(this.GoodsCheckBillID),
},
success: (res) => {
console.log('审核', res)
if (res.data.code == '0') {
var aResultData = JSON.parse(res.data.data);
console.log('aResultData', aResultData)
if (aResultData.code == '0' && aResultData.msg ==
'success') {
this.playSuccess(); this.playSuccess();
this.GoodsCheckBillDetailData(); this.BillDataMessage = aCommitRecallName + "成功!";
this.BillDataMessage = res.data.msg;
this.QRBarCode = '';
}
else {
this.showError(res.data.msg);
this.QRBarCode = '';
}
},
fail: (error) => {
this.showError('连接服务器出错,请检查后台服务是否启动!');
console.log('error',error)
},
})
},
GoodsCheckBillDetailData: function() { if (aCommitRecallName == '审核') {
console.log("--aaa->>" + this.GoodsCheckBillID); this.CommitType = '已审核'
console.log("--aaa->>" + this.GoodsCheckBillID);
util.request({
url: '/product/productCheckOrder/getProductCheckOrder',
method: 'get',
data: {
'id': parseInt(this.GoodsCheckBillID),
},
success: (res) => {
console.log("-->>--" + JSON.stringify(res.data.data));
this.GoodsDetailList = [];
this.GoodsCheckBillNo = res.data.data.order_no;
this.StoreName = res.data.data.warehouse_name
this.StoreStationName = res.data.data.warehouse_bin_name;
this.GoodsCheckBillDate = this.$u.timeFormat(res.data.data.check_time, 'yyyy-mm-dd')
/* this.BillSumOldRoll = res.data.data.item_data.roll;
this.BillSumNewRoll = res.data.data.item_data.check_roll; */
var aResultData = res.data.data.item_data;
this.BillSumOldRoll = 0;
this.BillSumNewRoll = 0;
for (var i = 0; i < aResultData.length; i++) {
aResultData[i].roll = aResultData[i].roll / 100;
aResultData[i].check_roll = aResultData[i].check_roll / 100;
aResultData[i].different_roll = aResultData[i].different_roll / 100;
this.BillSumOldRoll = this.BillSumOldRoll + aResultData[i].roll;
this.BillSumNewRoll = this.BillSumNewRoll + aResultData[i].check_roll;
};
this.GoodsDetailList = aResultData;
},
})
},
//
commitBtnFun: function() {
if (this.BillMasterID <= 0) {
this.showError('当前单据未提交,不能审核或消审!');
return;
}
var aCommitRecallName = '审核';
if (this.CommitType == '') {
aCommitRecallName = '审核';
} else {
aCommitRecallName = '消审';
}
// if (this.CommitProcName == '') {
// this.playError();
// this.BillDataMessage = '' + aCommitRecallName + '';
// return;
// }
console.log('GoodsCheckBillID',this.GoodsCheckBillID)
util.request({
url: '/product/productCheckOrder/updateProductCheckOrderAuditStatusPass',
method: 'put',
data: {
'id': parseInt(this.GoodsCheckBillID),
},
success: (res) => {
console.log('审核',res)
if (res.data.code == '0') {
var aResultData = JSON.parse(res.data.data);
console.log('aResultData',aResultData)
if (aResultData.code == '0' && aResultData.msg ==
'success') {
this.playSuccess();
this.BillDataMessage = aCommitRecallName + "成功!";
if (aCommitRecallName == '审核') {
this.CommitType = '已审核'
} else {
this.CommitType = ''
}
} else { } else {
this.showError(aCommitRecallName + '出错!' + aResultData.BillDataMessage); this.CommitType = ''
return;
} }
} else { } else {
this.showError(aCommitRecallName + '出错' + res.data.msg); this.showError(aCommitRecallName + '出错!' + aResultData.BillDataMessage);
return; return;
} }
}, } else {
fail: (error) => { this.showError(aCommitRecallName + '出错,' + res.data.msg);
this.showError('连接服务器出错,请检查后台服务是否启动!'); return;
}, }
}) },
}, fail: (error) => {
this.showError('连接服务器出错,请检查后台服务是否启动!');
},
})
},
}
} }
}
</script> </script>
<style> <style>
page { page {
background-color: #F8F8F8; background-color: #F8F8F8;
padding-bottom: 260rpx; padding-bottom: 260rpx;
} }
.u-radio { .u-radio {
width: 200rpx !important; width: 200rpx !important;
} }
.submitView { .submitView {
width: 100%; width: 100%;
padding: 16rpx 0 26rpx; padding: 16rpx 0 26rpx;
background-color: #FFFFFF; background-color: #FFFFFF;
position: fixed; position: fixed;
bottom: 0; bottom: 0;
left: 0; left: 0;
border-top: 1rpx solid #f1f1f1; border-top: 1rpx solid #f1f1f1;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
z-index: 100; z-index: 100;
} }
.submitBtn { .submitBtn {
width: 666rpx; width: 666rpx;
} }
.productBox { .productBox {
background-color: #FFFFFF; background-color: #FFFFFF;
margin-top: 32rpx; margin-top: 32rpx;
padding: 26rpx 0; padding: 26rpx 0;
} }
.tjcpName { .tjcpName {
width: 686rpx; width: 686rpx;
height: 40rpx; height: 40rpx;
font-size: 16px; font-size: 16px;
font-weight: bold; font-weight: bold;
border-left: 6rpx solid #007AFF; border-left: 6rpx solid #007AFF;
padding-left: 12rpx; padding-left: 12rpx;
margin-left: 26rpx; margin-left: 26rpx;
margin-top: 26rpx; margin-top: 26rpx;
} }
.cpInput { .cpInput {
width: 150rpx !important; width: 150rpx !important;
margin-right: 12rpx; margin-right: 12rpx;
} }
.cpInput>input { .cpInput>input {
box-sizing: border-box; box-sizing: border-box;
border: 1rpx solid #DDDDDD; border: 1rpx solid #DDDDDD;
width: 100%; width: 100%;
height: 60rpx; height: 60rpx;
border-radius: 10rpx; border-radius: 10rpx;
padding: 0 10rpx; padding: 0 10rpx;
} }
.cpInput1 { .cpInput1 {
width: 200rpx !important; width: 200rpx !important;
margin-right: 12rpx; margin-right: 12rpx;
} }
.cpInput1>input { .cpInput1>input {
box-sizing: border-box; box-sizing: border-box;
border: 1rpx solid #DDDDDD; border: 1rpx solid #DDDDDD;
width: 100%; width: 100%;
height: 60rpx; height: 60rpx;
border-radius: 10rpx; border-radius: 10rpx;
padding: 0 10rpx; padding: 0 10rpx;
} }
.clearIcon { .clearIcon {
position: absolute; position: absolute;
right: 6rpx; right: 6rpx;
top: 6rpx; top: 6rpx;
} }
.greenPrice { .greenPrice {
font-size: 16px; font-size: 16px;
color: #19BE6B !important; color: #19BE6B !important;
font-weight: bold; font-weight: bold;
} }
.disFlex { .disFlex {
display: flex; display: flex;
align-items: center; align-items: center;
margin-bottom: 8rpx; margin-bottom: 8rpx;
} }
.inputName { .inputName {
color: #ADADAD; color: #ADADAD;
font-size: 16px; font-size: 16px;
} }
.addHKQS { .addHKQS {
display: flex; display: flex;
align-items: center; align-items: center;
padding: 16rpx 26rpx; padding: 16rpx 26rpx;
font-size: 15px; font-size: 15px;
font-weight: bold; font-weight: bold;
width: 100%; width: 100%;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
} }
</style> </style>

File diff suppressed because it is too large Load Diff

View File

@ -3,12 +3,7 @@
<common-navbar title="工作台" :showBack="false"> <common-navbar title="工作台" :showBack="false">
<template #right> <template #right>
<view class="scan_box"> <view class="scan_box">
<u-icon <u-icon name="scan" color="#333333" size="46" @click="handleScan"></u-icon>
name="scan"
color="#333333"
size="46"
@click="handleScan"
></u-icon>
</view> </view>
</template> </template>
</common-navbar> </common-navbar>
@ -21,10 +16,7 @@
</view> </view>
<view class="grid-text">成品配布</view> <view class="grid-text">成品配布</view>
</u-grid-item> </u-grid-item>
<u-grid-item <u-grid-item :index="1" @click="navTo('/pages/storegoods/QRBarCodeReview')">
:index="1"
@click="navTo('/pages/storegoods/QRBarCodeReview')"
>
<view class="home-icon icon-color02"> <view class="home-icon icon-color02">
<i class="iconfont icon-mall-bag"></i> <i class="iconfont icon-mall-bag"></i>
</view> </view>
@ -35,44 +27,31 @@
<view class="workbench-title">成品管理</view> <view class="workbench-title">成品管理</view>
<view class="toolbar"> <view class="toolbar">
<u-grid class="grid" :col="4" :border="false"> <u-grid class="grid" :col="4" :border="false">
<u-grid-item <u-grid-item :index="0" @click="navTo('/pages/storegoods/dyeworksDyeback')">
:index="0"
@click="navTo('/pages/storegoods/dyeworksDyeback')"
>
<view class="home-icon icon-color04"> <view class="home-icon icon-color04">
<i class="iconfont icon-finance"></i> <i class="iconfont icon-finance"></i>
</view> </view>
<view class="grid-text">染整进仓</view> <view class="grid-text">染整进仓</view>
</u-grid-item> </u-grid-item>
<u-grid-item <u-grid-item :index="1" @click="navTo('/pages/storegoods/storeGoodsBusinessIn')">
:index="1"
@click="navTo('/pages/storegoods/storeGoodsBusinessIn')"
>
<view class="home-icon icon-color03"> <view class="home-icon icon-color03">
<i class="iconfont icon-mall-bag"></i> <i class="iconfont icon-mall-bag"></i>
</view> </view>
<view class="grid-text">成品进仓</view> <view class="grid-text">成品进仓</view>
</u-grid-item> </u-grid-item>
<u-grid-item <u-grid-item :index="2" @click="navTo('/pages/storegoods/storeGoodsBusinessOut')">
:index="2"
@click="navTo('/pages/storegoods/storeGoodsBusinessOut')"
>
<view class="home-icon icon-color12"> <view class="home-icon icon-color12">
<i class="iconfont icon-baoxiaodan"></i> <i class="iconfont icon-baoxiaodan"></i>
</view> </view>
<view class="grid-text">成品出仓</view> <view class="grid-text">成品出仓</view>
</u-grid-item> </u-grid-item>
<u-grid-item <u-grid-item @click="navTo('/pages/storegoods/storeGoodsBusinessCheck')">
@click="navTo('/pages/storegoods/storeGoodsBusinessCheck')"
>
<view class="home-icon icon-color04"> <view class="home-icon icon-color04">
<i class="iconfont icon-shenpi"></i> <i class="iconfont icon-shenpi"></i>
</view> </view>
<view class="grid-text">成品盘点</view> <view class="grid-text">成品盘点</view>
</u-grid-item> </u-grid-item>
<u-grid-item <u-grid-item @click="navTo('/pages/storegoods/storeGoodsBusinessStationMoveOnly')">
@click="navTo('/pages/storegoods/storeGoodsBusinessStationMoveOnly')"
>
<view class="home-icon icon-color04"> <view class="home-icon icon-color04">
<i class="iconfont icon-shenpi"></i> <i class="iconfont icon-shenpi"></i>
</view> </view>
@ -151,6 +130,7 @@
</template> </template>
<script> <script>
import CommonNavbar from "@/components/common-navbar/index"; import CommonNavbar from "@/components/common-navbar/index";
import scanMixin from '@/common/scanMixin.js';
/** /**
* Copyright (c) 2013-Now http://aidex.vip All rights reserved. * Copyright (c) 2013-Now http://aidex.vip All rights reserved.
*/ */
@ -158,6 +138,7 @@ export default {
components: { components: {
CommonNavbar, CommonNavbar,
}, },
mixins: [scanMixin],
data() { data() {
return { return {
show: false, show: false,
@ -168,34 +149,17 @@ export default {
//{image: '/static/aidex/banner/banner03.png'} //{image: '/static/aidex/banner/banner03.png'}
], ],
todoCount: 3, todoCount: 3,
scanReceiver: null, // scanReceiver isPageActive scanMixin
isPageActive: false,
}; };
}, },
onLoad() { onLoad() {
// #ifdef APP-PLUS // #ifdef APP-PLUS
this.isPageActive = true; // 使 scanMixin 广
this.registerScanBroadcast(); this.registerScanBroadcast(this.handleScanCode);
// #endif // #endif
}, },
// onUnload, onHide, onShow scanMixin
onUnload() {
// #ifdef APP-PLUS
this.isPageActive = false;
this.unregisterBroadcast();
// #endif
},
onHide() {
//
this.isPageActive = false;
},
onShow() {
//
this.isPageActive = true;
},
computed: { computed: {
contentStyle() { contentStyle() {
@ -206,6 +170,15 @@ export default {
}, },
}, },
methods: { methods: {
// -
handleScanCode(scanResult) {
console.log('工作台-扫码结果:', scanResult);
const cleanResult = scanResult.trim().replace(/[\r\n]/g, '');
uni.navigateTo({
url: '/pages/saleship/salepickscandetail?order_no=' + cleanResult
});
},
navTo(url) { navTo(url) {
uni.navigateTo({ uni.navigateTo({
url: url, url: url,
@ -217,11 +190,11 @@ export default {
itemClick(index) { itemClick(index) {
console.log(index); console.log(index);
}, },
// //
handleScan() { handleScan() {
// uni.navigateTo({ // uni.navigateTo({
// url: '/pages/saleship/salepickscandetail?order_no=FPD-PB-202412270196' // url: '/pages/saleship/salepickscandetail?order_no=FPD-PB-202412270196'
// }) // })
// return // return
// #ifdef APP-PLUS || MP-WEIXIN // #ifdef APP-PLUS || MP-WEIXIN
uni.scanCode({ uni.scanCode({
@ -229,9 +202,9 @@ export default {
success: (res) => { success: (res) => {
console.log('扫码成功:', res); console.log('扫码成功:', res);
const cleanResult = res.result.trim().replace(/[\r\n]/g, ''); const cleanResult = res.result.trim().replace(/[\r\n]/g, '');
uni.navigateTo({ uni.navigateTo({
url: '/pages/saleship/salepickscandetail?order_no=' + cleanResult url: '/pages/saleship/salepickscandetail?order_no=' + cleanResult
}) })
}, },
fail: (err) => { fail: (err) => {
console.error('扫码失败:', err); console.error('扫码失败:', err);
@ -275,99 +248,32 @@ export default {
}); });
} }
}, },
// 广 // registerScanBroadcast unregisterScanBroadcast scanMixin
registerScanBroadcast() {
try {
console.log('开始注册扫码广播');
const main = plus.android.runtimeMainActivity();
// 广
try {
const Intent = plus.android.importClass('android.content.Intent');
const intent = new Intent('com.android.scanner.service_settings');
intent.putExtra('action_barcode_broadcast', 'com.android.server.scannerservice.broadcast');
intent.putExtra('key_barcode_broadcast', 'scannerdata');
main.sendBroadcast(intent);
console.log('扫码枪广播配置已发送');
} catch (error) {
console.error('配置扫码枪广播失败:', error);
}
// 广
const IntentFilter = plus.android.importClass('android.content.IntentFilter');
const filter = new IntentFilter();
filter.addAction('com.android.server.scannerservice.broadcast');
const receiver = plus.android.implements('io.dcloud.feature.internal.reflect.BroadcastReceiver', {
onReceive: (context, intent) => {
// 广
if (!this.isPageActive) return;
try {
console.log("Workbench intent:", intent);
const scanResult = intent.getStringExtra('scannerdata');
console.log('工作台-扫码结果:', scanResult);
if (scanResult) {
this.$nextTick(() => {
const cleanResult = scanResult.trim().replace(/[\r\n]/g, '');
uni.navigateTo({
url: '/pages/saleship/salepickscandetail?order_no=' + cleanResult
});
});
}
} catch (error) {
console.error('处理广播数据时出错:', error, error.stack);
}
}
});
// 广
main.registerReceiver(receiver, filter);
this.scanReceiver = receiver;
console.log('扫码广播注册成功,等待扫码...');
} catch (error) {
console.error('注册扫码广播失败:', error);
console.error('错误详情:', error.message);
console.error('错误堆栈:', error.stack);
}
},
// 广
unregisterBroadcast() {
if (this.scanReceiver) {
try {
const main = plus.android.runtimeMainActivity();
main.unregisterReceiver(this.scanReceiver);
this.scanReceiver = null;
console.log('扫码广播注销成功');
} catch (error) {
console.error('注销扫码广播失败:', error);
}
}
},
}, },
}; };
</script> </script>
<style lang="scss"> <style lang="scss">
@import "index.scss"; @import "index.scss";
.scan_box { .scan_box {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
.scan_text { .scan_text {
font-size: 12px; font-size: 12px;
color: #2979ff; color: #2979ff;
} }
} }
.banner-box { .banner-box {
padding: 0 2%; padding: 0 2%;
width: 96%; width: 96%;
height: 170rpx; height: 170rpx;
margin: 30rpx 0 30rpx; margin: 30rpx 0 30rpx;
} }
.u-swiper-wrap { .u-swiper-wrap {
padding: 0 10px; padding: 0 10px;
} }
@ -378,6 +284,7 @@ export default {
display: inline-block; display: inline-block;
margin: 0 1.5%; margin: 0 1.5%;
} }
.banner-pic image { .banner-pic image {
width: 100%; width: 100%;
height: 170rpx; height: 170rpx;
@ -394,12 +301,14 @@ export default {
position: relative; position: relative;
top: -3px; top: -3px;
} }
.workbench-title { .workbench-title {
font-size: 32rpx; font-size: 32rpx;
font-weight: bold; font-weight: bold;
color: #333333; color: #333333;
padding: 15px 30rpx; padding: 15px 30rpx;
} }
.home-icon i.icon-tongzhi { .home-icon i.icon-tongzhi {
font-size: 22px; font-size: 22px;
} }