From ca1eab1cf8a8050e5668eb7e78faea2a821c5cb2 Mon Sep 17 00:00:00 2001
From: chenhaozhe <cgz@hz-kingdee.com>
Date: 星期二, 08 七月 2025 12:11:04 +0800
Subject: [PATCH] 12
---
static/svgs/folder_bg.svg | 1
utils/common.js | 41 ++++
pages/wuliaosaoma/detail.vue | 25 ++
pages.json | 28 ++
pages/qitachuku/qitachuku.vue | 19 +
pages/qitaruku/qitaruku.vue | 24 ++
pages/wuliaosaoma/wuliaosaoma.vue | 169 ++++++++++++++++
components/blueToothConnector/blueToothConnector.vue | 230 +++++++++++++++++++++++
pages/index/index.vue | 18 +
9 files changed, 555 insertions(+), 0 deletions(-)
diff --git a/components/blueToothConnector/blueToothConnector.vue b/components/blueToothConnector/blueToothConnector.vue
new file mode 100644
index 0000000..3c1b562
--- /dev/null
+++ b/components/blueToothConnector/blueToothConnector.vue
@@ -0,0 +1,230 @@
+<template>
+ <view>
+ <!-- 钃濈墮杩炴帴鐘舵�� MAC鍦板潃 -->
+ <view class="connection-status">
+ <view>杩炴帴鐘舵�侊細</view>
+ </view>
+ <!-- 鎿嶄綔鍖� -->
+ <view class="buttons">
+ <button class="btn-c" @click="searchLabelPrinter()">鎼滅储鎵撳嵃鏈�</button>
+ <button class="btn-d" @click="closeBluetooth()">鏂紑杩炴帴</button>
+ </view>
+ <!-- 璁惧鍒楄〃 -->
+ <view v-for="(device, index) in discoveredDevices" :key="device.address">
+ <uni-card :title="device.name" :extra="connectedDeviceId === device.address?'宸茶繛鎺�':'鏈繛鎺�'"
+ style="margin: 10px;">
+ <view class="operation-zone">
+ <button class="op1" size="mini" plain @click="connectBT(device)">杩炴帴璁惧</button>
+ </view>
+ </uni-card>
+ </view>
+ </view>
+</template>
+
+<script>
+ import bluetoothTool from '@/plugins/BluetoothTool.js'
+ import permission from '@/plugins/permission.js'
+ import {
+ InputImage
+ } from '@psdk/frame-imageb';
+ import {
+ ConnectedDevice,
+ Lifecycle,
+ Raw,
+ FakeConnectedDevice,
+ WriteOptions,
+ } from '@psdk/frame-father';
+ export default {
+ name: "blueToothConnector",
+ data() {
+ return {
+ discoveredDevices: [], // 鏌ヨ鍒扮殑璁惧
+ connectedDeviceId: ""
+ };
+ },
+ methods: {
+ async checkPermission() { // 鎺堟潈
+ try {
+ let checkResult = await permission.androidPermissionCheck("bluetooth");
+ console.log("妫�娴嬩俊鎭細", checkResult);
+ if (checkResult.code == 1) {
+ let result = checkResult.data;
+ if (result == 1) {
+ console.log("鎺堟潈鎴愬姛!");
+ }
+ if (result == 0) {
+ console.log("鎺堟潈宸叉嫆缁�!");
+ }
+ if (result == -1) {
+ console.log("鎮ㄥ凡姘镐箙鎷掔粷鏉冮檺锛岃鍦ㄥ簲鐢ㄨ缃腑鎵嬪姩鎵撳紑!");
+ }
+ }
+ } catch (err) {
+ console.log("鎺堟潈澶辫触锛�", err);
+ }
+ },
+ async searchLabelPrinter() {
+ // 鏌ユ壘鎵撳嵃鏈�
+ var that = this
+ // 浣跨敤openBluetoothAdapter 鎺ュ彛锛屽厤鍘讳富鍔ㄧ敵璇锋潈闄愮殑楹荤儲
+ uni.openBluetoothAdapter({
+ success: async (res) => {
+ await this.checkPermission();
+ console.log('start discovery devices');
+ this.discoveredDevices = [];
+ console.log(res)
+ bluetoothTool.discoveryNewDevice();
+ },
+ fail: async (e) => {
+ console.error(e)
+ switch (e.code) {
+ case "10009":
+ this.showToast("姝よ澶囦笉鏀寔璁惧鎼滅储鍔熻兘!");
+ break;
+ default:
+ console.error(e);
+ }
+ }
+ })
+
+ },
+ onDevice(device) {
+ console.log("鐩戝惉瀵绘壘鍒版柊璁惧鐨勪簨浠�---------------")
+ console.log(device)
+ if (typeof device === 'undefined') return;
+ if (typeof device.name === 'undefined') return;
+ console.log(device.name);
+ if (device.name === '') return;
+ if (device.name === null) return;
+ if (device.name.toUpperCase().endsWith('_BLE') ||
+ device.name.toUpperCase().endsWith('-LE') ||
+ device.name.toUpperCase().endsWith('-BLE')) return;
+ const isDuplicate = this.discoveredDevices.find(item => item.address === device.address);
+ if (isDuplicate) return;
+ this.discoveredDevices.push(device);
+ },
+ connectBT(device) {
+ const vm = this;
+ uni.showLoading({
+ title: '杩炴帴涓�'
+ });
+ bluetoothTool.connDevice(device.address, (result) => {
+ console.log(result)
+ uni.hideLoading()
+ if (result) {
+ // // console.log(result);
+ bluetoothTool.cancelDiscovery();
+ // console.log(vm.$printer)
+ vm.$printer.init(new FakeConnectedDevice());
+ vm.connectedDeviceId = device.address;
+ uni.showToast({
+ icon: 'none',
+ title: '杩炴帴鎴愬姛'
+ })
+ } else {
+ uni.showToast({
+ icon: 'none',
+ title: '杩炴帴澶辫触'
+ })
+ }
+ });
+ },
+ stopSearchBT() {
+ console.log("鍋滄鎼滃闄勮繎鐨勮摑鐗欏鍥磋澶�---------------")
+ bluetoothTool.cancelDiscovery();
+ },
+ closeBluetooth() {
+ console.log("鍋滄钃濈墮杩炴帴")
+ const vm = this;
+ if (vm.connectedDeviceId != '') {
+ bluetoothTool.closeBtSocket();
+ vm.connectedDeviceId = "";
+ }
+ },
+ },
+ async mounted() {
+ //#ifdef APP-PLUS
+ // 钃濈墮
+ bluetoothTool.init({
+ listenBTStatusCallback: (state) => {
+ if (state == 'STATE_ON') {
+ console.log(state);
+ }
+ },
+ discoveryDeviceCallback: this.onDevice,
+ discoveryFinishedCallback: function() {
+ console.log("鎼滅储瀹屾垚");
+ },
+ readDataCallback: function(dataByteArr) {
+ /* if(that.receiveDataArr.length >= 200) {
+ that.receiveDataArr = [];
+ }
+ that.receiveDataArr.push.apply(that.receiveDataArr, dataByteArr); */
+ console.log("璇诲彇瀹屾垚" + dataByteArr);
+ },
+ connExceptionCallback: function(e) {
+ console.log(e);
+ }
+ });
+
+ // 鏌ョ湅杩炴帴璁惧
+ let pariedDevices = bluetoothTool.getPairedDevices()
+ console("宸查厤瀵硅澶�", pariedDevices)
+ //#endif
+ },
+ }
+</script>
+
+<style lang="scss" scoped>
+ .buttons {
+ width: 100%;
+ display: flex;
+ justify-content: center;
+ margin-top: 20rpx;
+
+ button {
+ border-radius: 50rpx;
+ width: 220rpx;
+ height: 66rpx;
+ line-height: 66rpx;
+ font-size: 28rpx;
+ }
+
+ .btn-a {
+ background-color: #acacac;
+ color: #fff;
+ }
+
+ .btn-b {
+ background-color: #41a863;
+ color: #fff;
+ }
+
+ .btn-c {
+ background-color: #3a78ff;
+ color: #fff;
+ }
+
+ .btn-d {
+ background-color: #da0000;
+ color: #fff;
+ }
+ }
+
+ .operation-zone {
+ display: flex;
+ justify-content: space-around;
+ margin-top: 10rpx;
+
+ .op1 {
+ border: 1px solid #41a863;
+ color: #41a863;
+ }
+
+ .op4 {
+ border: 1px solid #da0000;
+ color: #da0000;
+ }
+
+ }
+</style>
\ No newline at end of file
diff --git a/pages.json b/pages.json
index ab15a3f..c2230ab 100644
--- a/pages.json
+++ b/pages.json
@@ -299,6 +299,34 @@
{
"navigationBarTitleText" : "鏉$爜鎷嗙爜"
}
+ },
+ {
+ "path" : "pages/wuliaosaoma/wuliaosaoma",
+ "style" :
+ {
+ "navigationBarTitleText" : "鐗╂枡娓呭崟"
+ }
+ },
+ {
+ "path" : "pages/wuliaosaoma/detail",
+ "style" :
+ {
+ "navigationBarTitleText" : "鏉$爜妗f"
+ }
+ },
+ {
+ "path" : "pages/qitachuku/qitachuku",
+ "style" :
+ {
+ "navigationBarTitleText" : "鍏朵粬鍑哄簱鍗�"
+ }
+ },
+ {
+ "path" : "pages/qitaruku/qitaruku",
+ "style" :
+ {
+ "navigationBarTitleText" : "鍏朵粬鍏ュ簱鍗�"
+ }
}
],
"tabBar": {
diff --git a/pages/index/index.vue b/pages/index/index.vue
index 3d4f26f..af52f91 100644
--- a/pages/index/index.vue
+++ b/pages/index/index.vue
@@ -125,6 +125,24 @@
text: '鏉$爜鎷嗙爜',
url: '/pages/tiaomachaima/tiaomachaima',
id: 20,
+ },
+ {
+ img: '../../static/icon/icon16.png',
+ text: '鐗╂枡鎵爜',
+ url: '/pages/wuliaosaoma/wuliaosaoma',
+ id: 21,
+ },
+ {
+ img: '../../static/icon/icon16.png',
+ text: '鍏朵粬鍏ュ簱',
+ url: '/pages/qitaruku/qitaruku',
+ id: 21,
+ },
+ {
+ img: '../../static/icon/icon16.png',
+ text: '鍏朵粬鍑哄簱',
+ url: '/pages/qitachuku/qitachuku',
+ id: 22,
}
]
}
diff --git a/pages/qitachuku/qitachuku.vue b/pages/qitachuku/qitachuku.vue
new file mode 100644
index 0000000..8c3b35f
--- /dev/null
+++ b/pages/qitachuku/qitachuku.vue
@@ -0,0 +1,19 @@
+<template>
+ <view>
+
+ </view>
+</template>
+
+<script>
+ export default {
+ data() {
+ return {
+
+ };
+ }
+ }
+</script>
+
+<style lang="scss">
+
+</style>
diff --git a/pages/qitaruku/qitaruku.vue b/pages/qitaruku/qitaruku.vue
new file mode 100644
index 0000000..87c7e4a
--- /dev/null
+++ b/pages/qitaruku/qitaruku.vue
@@ -0,0 +1,24 @@
+<template>
+ <view>
+ <blueToothConnectorVue></blueToothConnectorVue>
+ </view>
+</template>
+
+<script>
+ import blueToothConnectorVue from '../../components/blueToothConnector/blueToothConnector.vue';
+ export default {
+ data() {
+ return {
+
+ };
+ },
+ components: {blueToothConnectorVue},
+ methods: {
+
+ }
+ }
+</script>
+
+<style lang="scss">
+
+</style>
diff --git a/pages/wuliaosaoma/detail.vue b/pages/wuliaosaoma/detail.vue
new file mode 100644
index 0000000..c42ae09
--- /dev/null
+++ b/pages/wuliaosaoma/detail.vue
@@ -0,0 +1,25 @@
+<template>
+ <view></view>
+</template>
+
+<script>
+ export default{
+ data(){
+ return {
+
+ }
+ }
+ }
+</script>
+
+<style lang="scss">
+ * {
+ box-sizing: border-box;
+ }
+
+ page{
+ >view {
+
+ }
+ }
+</style>
\ No newline at end of file
diff --git a/pages/wuliaosaoma/wuliaosaoma.vue b/pages/wuliaosaoma/wuliaosaoma.vue
new file mode 100644
index 0000000..60c6b6f
--- /dev/null
+++ b/pages/wuliaosaoma/wuliaosaoma.vue
@@ -0,0 +1,169 @@
+<template>
+ <view class="container">
+ <view class="header">
+ <view class="item">
+ <view class="left">婧愬崟鍙凤細</view>
+ <view class="right">
+ <input name="HBillNo" v-model="HBillNo" placeholder="璇锋壂鎻忔敹鏂欓�氱煡鍗�" disabled />
+ </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="HBillNo" placeholder="璇锋壂鎻忔敹鏂欓�氱煡鍗�" />
+ </view>
+ </view> -->
+ </view>
+ <view class="content">
+ <view class="over" v-if="HMaterList.length == 0">鏆傛棤鏁版嵁</view>
+ <view v-else class="mater-list-wrapper">
+ {{ HMaterList }}
+ </view>
+ </view>
+ </view>
+</template>
+
+<script>
+ import {
+ CommonUtils
+ } from "@/utils/common.js"
+ import {
+ getUserInfo
+ } from "@/utils/auth.js"
+ import {
+ string
+ } from "i/lib/util";
+ export default {
+ data() {
+ return {
+ CommonUtils,
+ userInfo: getUserInfo(),
+ HBillNo: '',
+ HMaterList: [],
+ pageInfo: {
+ page: 1,
+ size: 500,
+ total: 0,
+ }
+ };
+ },
+ methods: {
+ toScanCode() {
+ uni.scanCode({
+ onlyFromCamera: true,
+ success: (res) => {
+ if (this.CommonUtils.isEmpty(res.result) === false) {
+ console.log('鏉$爜鍐呭锛�' + res.result);
+ this.HBillNo = res.result
+ CommonUtils.doRequest(
+ "/Cg_POInStockBill/page", {
+ sWhere: ` and 鍗曟嵁鍙�='${res.result}'`,
+ user: this.userInfo.HEmpName,
+ page: this.pageInfo.page,
+ size: this.pageInfo.size
+ },
+ function(res) {
+ console.log(res)
+ let res1 = res.data
+
+ let {
+ count,
+ data
+ } = res1;
+ if (count > 0) {
+ console.log(data)
+ // this.HMaterList = data.reduce((acc, obj) => {
+ // acc.push({
+ // "HMaterID": obj['HMaterID'],
+ // "HMaterNo": obj['鐗╂枡浠g爜'],
+ // "HMaterName": obj['鐗╂枡鍚嶇О'],
+ // "HMaterType": obj['瑙勬牸鍨嬪彿'],
+ // "HQty": obj['鏁伴噺'],
+ // "HBarCode": "",
+ // "HBillNo": obj['鍗曟嵁鍙�']
+ // })
+ // }, [])
+
+ }
+ },
+ function(err) {
+ console.error(err)
+ }
+ )
+ }
+ }
+ });
+ },
+ },
+ onload() {
+
+ }
+ }
+</script>
+
+<style lang="scss">
+ * {
+ box-sizing: border-box;
+ }
+
+ input {
+ padding: 8rpx 20rpx;
+ font-size: 30rpx;
+ line-height: 30rpx;
+ }
+
+ .container {
+ display: flex;
+ flex-direction: column;
+
+ .header {
+ height: auto;
+ display: flex;
+ flex-direction: column;
+ gap: 20rpx;
+ padding: 20rpx 10rpx;
+
+ .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: 6rem;
+ }
+
+ .right {
+ flex: 1;
+ height: 100%;
+ padding: 6rpx 0;
+ border-radius: 22rpx;
+ border: 1px solid #e4e4e4;
+ background-color: #e4e4e4;
+
+ >input {
+ height: auto;
+ }
+ }
+ }
+ }
+
+ .content {
+ flex: 1;
+
+ .mater-list-wrapper {
+ background-image: url("@/static/svgs/folder_bg.svg");
+ }
+ }
+ }
+</style>
\ No newline at end of file
diff --git a/static/svgs/folder_bg.svg b/static/svgs/folder_bg.svg
new file mode 100644
index 0000000..0c09b52
--- /dev/null
+++ b/static/svgs/folder_bg.svg
@@ -0,0 +1 @@
+<svg width="100%" height="100%" viewBox="0 0 750 590" preserveAspectRatio="none" xmlns="http://www.w3.org/2000/svg"><!-- 鏍囬鍖哄煙 (鍥哄畾楂樺害 64px) --><g id="title" transform="translate(0)"><polyline fill="none" stroke="#000" points="0 64 0 0 300 0 375 64" stroke-width="3"/></g><!-- 鍐呭鍖哄煙 (鑷姩濉厖鍓╀綑楂樺害) --><g id="content" transform="translate(0 64)"><!-- 浣跨敤鐩稿鍧愭爣閲嶇粯鍐呭鍖哄煙 --><polyline fill="none" stroke="#000" points="375 0 750 0 750 526 0 526 0 0" stroke-width="3"/></g></svg>
\ No newline at end of file
diff --git a/utils/common.js b/utils/common.js
index 7c94684..65ea5c2 100644
--- a/utils/common.js
+++ b/utils/common.js
@@ -1,4 +1,10 @@
class commonUtils {
+ serverUrl
+
+ constructor() {
+ this.serverUrl = uni.getStorageSync('serverUrl') || 'http://47.96.97.237/API';
+ }
+
// 闃叉姈鍑芥暟
debounce(func, delay, immediate = false) {
let timer = null;
@@ -82,6 +88,41 @@
return /^\d+$/.test(str);
}
+ // uni-app 浣跨敤 灏佽璇锋眰鍑芥暟
+ 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()
+ }
}
export const CommonUtils = Object.freeze(new commonUtils());
\ No newline at end of file
--
Gitblit v1.9.1