Sfoglia il codice sorgente

提交汉印热敏纸打印机连接打印

caojunjie 2 anni fa
parent
commit
19da308384

+ 330 - 0
common/bluetooth.js

@@ -0,0 +1,330 @@
+import Vue from 'vue';
+let main, Context, BManager, BluetoothAdapter, BAdapter, BluetoothDevice, IntentFilter;
+import {
+	SET_INFODATA,
+	SET_CONNECTBLEDATA,
+	SET_REQUEST_DATA
+} from '@/store/actionsType.js';
+import {
+	GET_CONNECTBLEDATA
+} from '@/store/gettersType.js';
+/**
+ * 蓝牙初始化和注册
+ */
+Vue.prototype.$init_bluetooth = function() {
+	console.log('蓝牙初始化');
+	let _this = this;
+	//获取android应用Activity活动对象
+	main = plus.android.runtimeMainActivity();
+	//引入Context类
+	Context = plus.android.importClass("android.content.Context");
+	// Context.BLUETOOTH_SERVICE  获取Context类的静态常量(蓝牙服务,获取BluetoothManager,以使用蓝牙)
+	BManager = main.getSystemService(Context.BLUETOOTH_SERVICE);
+	//获取蓝牙适配器对象类
+	BluetoothAdapter = plus.android.importClass("android.bluetooth.BluetoothAdapter");
+	//蓝牙本地适配器(对象)
+	BAdapter = BluetoothAdapter.getDefaultAdapter();
+	//引入蓝牙设备类(创建与相应设备的连接或查询有关该设备的信息,例如名称,地址,类和绑定状态)
+	BluetoothDevice = plus.android.importClass('android.bluetooth.BluetoothDevice');
+	//引入过滤器类 (IntentFilter可以匹配Intent中的动作,类别,数据)
+	IntentFilter = plus.android.importClass('android.content.IntentFilter');
+}
+/**
+ * 检查蓝牙是否开启
+ * 1.用户没有开启,提示开启
+ * 2.用户蓝牙已经开启
+ */
+Vue.prototype.$check_bluetooth_open = function() {
+	let _this = this;
+	/**
+	 * BAdapter.isEnabled(); 判断蓝牙是否打开
+	 * BAdapter.enable();  //开启蓝牙
+	 * BAdapter.disable();  //关闭蓝牙
+	 */
+	return new Promise((resolve, reject) => {
+		if (!BAdapter.isEnabled()) {
+			//蓝牙未打开
+			uni.showModal({
+				title: "提示",
+				content: "蓝牙未开启,是否开启蓝牙~",
+				success: function(res) {
+					if (res.confirm) {
+						//开启蓝牙
+						BAdapter.enable();
+						resolve(true);
+					} else if (res.cancel) {
+						resolve(false);
+					}
+				}
+			})
+			// 后续提示框提示或用户手动打开
+		} else {
+			//蓝牙已打开
+			resolve(true);
+		}
+	})
+}
+
+/**
+ * 检测手机是否已经连接蓝牙设备
+ */
+Vue.prototype.$check_bluetooth_connect = function() {
+	let _this = this;
+	// 先清空vuex原来已有的数据
+	_this.$store.dispatch(SET_CONNECTBLEDATA, []);
+	return new Promise((resolve, reject) => {
+		// 获取android应用已配对的蓝牙设备类
+		let lists = BAdapter.getBondedDevices();
+		// 引入类
+		plus.android.importClass(lists);
+		// 获取已配对蓝牙设备的个数
+		let len = lists.size();
+		// iterator()  把一个容器的所有对象,做成一个线性表(List),而iterator本身是一个指针
+		let iterator = lists.iterator();
+		// console.log(iterator.hasNext());
+		plus.android.importClass(iterator);
+		/**
+		 * iterator.hasNext()  true如果迭代具有更多元素
+		 * iterator.next() 放回迭代中的下一个元素
+		 * iterator.remove() 从基础集合中移除此迭代器返回的最后一个元素(可选操作)
+		 */
+		while (iterator.hasNext()) {
+			let d = iterator.next();
+			plus.android.importClass(d);
+			let matchList = {
+				name: d.getName(),
+				mac: d.getAddress()
+			}
+			console.log(matchList);
+			_this.$store.dispatch(SET_CONNECTBLEDATA, matchList);
+			resolve({
+				code: true,
+				msg: matchList
+			});
+		}
+
+		//获取一个已连接的设备
+		// plus.android.importClass(BManager); //引入相关的method函数
+		// //蓝牙适配器
+		// let BAdapter = BManager.getAdapter();
+		// // console.log(BAdapter);
+		// plus.android.importClass(BAdapter); //引入相关的method函数,这样之后才会有isEna;
+		// let lists = BAdapter.getBondedDevices();
+		// // console.log(lists);
+		// plus.android.importClass(lists);
+		// let iterator = lists.iterator();
+		// // console.log(iterator);
+		// plus.android.importClass(iterator);
+		// // console.log(iterator.hasNext());
+		// if(iterator.hasNext()){   //判断下一个元素的有无
+		// 	let d = iterator.next();
+		// 	plus.android.importClass(d);
+		// 	//已连接蓝牙的数据
+		// 	// console.log(d.getAddress());
+		// 	console.log(d.getAddress() + "----" + d.getName());
+		// 	// _this.match_list = {
+		// 	// 	name: d.getName(),
+		// 	// 	mac: d.getAddress()
+		// 	// };
+		// 	let matchList = {
+		// 		name: d.getName(),
+		// 		mac: d.getAddress()
+		// 	}
+		// 	_this.$store.dispatch(SET_CONNECTBLEDATA,matchList);
+		// 	// console.log(_this.$store.getters.GET_CONNECTBLEDATA)
+		// 	/** 
+		// 	 * 连接打印机
+		// 	 */
+		//     resolve({code:true,msg:matchList});
+		// }else{
+		// 	resolve({code:false})
+		// }
+	})
+}
+/**
+ * 打开蓝牙
+ */
+Vue.prototype.$open_bluetooth = function() {
+	let _this = this;
+	return new Promise((resolve, reject) => {
+		if (!BAdapter.isEnabled()) {
+			BAdapter.enable(); //启动蓝牙
+			uni.showToast({
+				icon: "none",
+				title: '蓝牙已打开',
+				duration: 3000
+			})
+			resolve(true);
+		}
+	})
+}
+/**
+ * 关闭蓝牙 
+ */
+Vue.prototype.$close_bluetooth = function() {
+	let _this = this;
+	if (BAdapter.isEnabled()) {
+		BAdapter.disable(); //关闭蓝牙  
+		uni.showToast({
+			icon: "none",
+			title: '蓝牙已关闭',
+			duration: 2000
+		})
+	} else {
+		uni.showToast({
+			icon: "none",
+			title: '蓝牙已关闭',
+			duration: 2000
+		})
+	}
+}
+/**
+ * 搜索蓝牙设备
+ */
+Vue.prototype.$search_bluetooth = function() {
+	let _this = this;
+	let obj = {};
+	return new Promise((resolve, reject) => {
+		// console.log(BAdapter.isEnabled());
+		// console.log(JSON.stringify(_this.$store.getters));
+		// BAdapter.isconnect("DC:1D:30:7C:74:96");
+		//判断蓝牙是否开启
+		if (!BAdapter.isEnabled()) {
+			uni.showModal({
+				title: "提示",
+				content: "蓝牙未开启,是否开启蓝牙~",
+				success: function(res) {
+					if (res.confirm) {
+						console.log('用户点击确定');
+						obj.code = false; //用户点击确定,开启蓝牙
+						obj.msg = "蓝牙未开启";
+						resolve(obj);
+						// _this.$open_bluetooth();
+					} else if (res.cancel) {
+						// resolve()
+						obj.code = null;
+						resolve(obj);
+					}
+				}
+			})
+		} else {
+			obj.code = true;
+			obj.msg = "开启搜索蓝牙";
+			resolve(obj);
+		}
+	})
+}
+/**
+ * 监听蓝牙设备信息
+ */
+Vue.prototype.$search_pipei = function() {
+	let timer = null;
+	let _this = this;
+	//提示蓝牙开启权限访问
+	uni.openBluetoothAdapter({
+		success(res) {
+			if (res.errMsg === "openBluetoothAdapter:ok") {
+				//这里是开启蓝牙搜寻
+				uni.startBluetoothDevicesDiscovery({
+					allowDuplicatesKey: false,
+					success: (res) => {
+						console.log('startBluetoothDevicesDiscovery success', res)
+						uni.showLoading({
+							title: "蓝牙搜索中...",
+							mask: true
+						})
+						//每次搜索都把之前的清空
+						// _this.bArray = [];
+						// _this.no_match_list = [];
+						_this.$store.dispatch(SET_INFODATA, []);
+						let bArray = []; //用于蓝牙去重
+						let filter = new IntentFilter(); //实例化过滤器类
+						let BDevice = new BluetoothDevice(); //实例化蓝牙设备类
+						// let connect = _this.$store.state.Bluetooth.connectBLEData;
+						// console.log("已连接:" + JSON.stringify(connect));
+						BAdapter.startDiscovery(); //开启搜索 
+						let receiver = plus.android.implements(
+							'io.dcloud.android.content.BroadcastReceiver', {
+								onReceive: function(context, intent) { //回调 
+									try {
+										plus.android.importClass(intent);
+										if (intent.getAction() ==
+											"android.bluetooth.adapter.action.DISCOVERY_FINISHED"
+											) {
+											main.unregisterReceiver(receiver); //取消监听 
+										} else {
+											// Intent中获取设备对象
+											BDevice = intent.getParcelableExtra(
+												BluetoothDevice.EXTRA_DEVICE);
+											console.log(BDevice.getName() + "---" +
+												BDevice.getAddress());
+											console.log(BDevice.getName())
+											// 判断如果蓝牙没有名称则不显示
+											if (BDevice.getName() !== null) {
+												//蓝牙去重
+												let address = BDevice.getAddress();
+												//已经连接的蓝牙
+												if (bArray.indexOf(address) == -1) {
+													bArray.push(address);
+													_this.$store.dispatch(
+													SET_INFODATA, {
+														name: BDevice.getName(),
+														mac: BDevice
+														.getAddress()
+													})
+												}
+											}
+											//如果intent为空则取消蓝牙监听
+											if (BDevice == null) {
+												main.unregisterReceiver(
+												receiver); //取消监听 
+												uni.hideLoading()
+												//获取已匹配的蓝牙
+												// that.bluetooth_list() 
+												return;
+											}
+											if (timer != null) {
+										 	clearTimeout(timer);
+											}
+											timer = setTimeout(() => {
+												main.unregisterReceiver(
+													receiver); //取消监听
+												uni.hideLoading();
+											}, 3000);
+										}
+									} catch (e) {
+										uni.showToast({
+											icon: "none",
+								  	title: "蓝牙搜寻错误~",
+											duration: 3000,
+											mask: true
+										})
+									}
+								}
+							});
+
+						filter.addAction(BDevice.ACTION_FOUND); //可发现
+						filter.addAction(BAdapter.ACTION_DISCOVERY_STARTED);
+						filter.addAction(BAdapter.ACTION_DISCOVERY_FINISHED); //搜索结果
+						filter.addAction(BAdapter.ACTION_STATE_CHANGED);
+						main.registerReceiver(receiver, filter); //注册监听
+					},
+					fail: (err) => {
+						uni.showToast({
+							icon: "none",
+							title: "蓝牙搜寻失败~",
+							duration: 3000,
+							mask: true
+						})
+					}
+				})
+			}
+		},
+		fail(err) {
+			uni.showToast({
+				icon: "none",
+				title: "蓝牙搜索失败"
+			})
+		}
+	})
+}

+ 54 - 36
common/dateFormat.js

@@ -1,44 +1,62 @@
-export function dateFormat(date, format = 'YYYY-MM-DD HH:mm:ss'){
+export function dateFormat(date, format = 'YYYY-MM-DD HH:mm:ss') {
 	const config = {
 		YYYY: date.getFullYear(),
-		MM: date.getMonth()<9?'0'+Number(date.getMonth()+1):Number(date.getMonth()+1),
-		DD: date.getDate()<10?'0'+date.getDate():date.getDate(),
-		HH: date.getHours()<10?'0'+date.getHours():date.getHours(),
-		mm: date.getMinutes()<10?'0'+date.getMinutes():date.getMinutes(),
-		ss: date.getSeconds()<10?'0'+date.getSeconds():date.getSeconds(),
+		MM: date.getMonth() < 9 ? '0' + Number(date.getMonth() + 1) : Number(date.getMonth() + 1),
+		DD: date.getDate() < 10 ? '0' + date.getDate() : date.getDate(),
+		HH: date.getHours() < 10 ? '0' + date.getHours() : date.getHours(),
+		mm: date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes(),
+		ss: date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds(),
 	}
 	for (const key in config) {
 		format = format.replace(key, config[key])
 	}
 	return format
+}
+
+export function unitConvert(num) {
+	var moneyUnits = ["元", "万元", "亿元", "万亿"]
+	var dividend = 10000;
+	var curentNum = Number(num);
+	//转换数字 
+	var curentUnit = moneyUnits[0];
+	//转换单位 
+	for (var i = 0; i < 4; i++) {
+		curentUnit = moneyUnits[i]
+		if (strNumSize(curentNum) < 5) {
+			break;
+		}
+		curentNum = curentNum / dividend
+	}
+	var m = {
+		num: 0,
+		unit: ""
+	}
+	m.num = curentNum.toFixed(2)
+	m.unit = curentUnit;
+	return m;
+}
+export function DX(n) {
+	if (!/^(0|[1-9]\d*)(\.\d+)?$/.test(n))
+		return "数据非法";
+	var unit = "千百拾亿千百拾万千百拾元角分",
+		str = "";
+	n += "00";
+	var p = n.indexOf('.');
+	if (p >= 0)
+		n = n.substring(0, p) + n.substr(p + 1, 2);
+	unit = unit.substr(unit.length - n.length);
+	for (var i = 0; i < n.length; i++)
+		str += '零壹贰叁肆伍陆柒捌玖'.charAt(n.charAt(i)) + unit.charAt(i);
+	return str.replace(/零(千|百|拾|角)/g, "零").replace(/(零)+/g, "零").replace(/零(万|亿|元)/g, "$1").replace(/(亿)万|壹(拾)/g,
+		"$1$2").replace(/^元零?|零分/g, "").replace(/元$/g, "元整");
+}
+
+export function strNumSize(tempNum) {
+	var stringNum = tempNum.toString()
+	var index = stringNum.indexOf(".")
+	var newNum = stringNum;
+	if (index != -1) {
+		newNum = stringNum.substring(0, index)
+	}
+	return newNum.length
 }
-
-export function unitConvert(num) {
-    var moneyUnits = ["元", "万元", "亿元", "万亿"] 
-    var dividend = 10000;
-    var curentNum = Number(num);
-    //转换数字 
-    var curentUnit = moneyUnits[0];
-    //转换单位 
-    for (var i = 0; i <4; i++) { 
-        curentUnit = moneyUnits[i] 
-        if(strNumSize(curentNum)<5){ 
-            break;
-        }
-        curentNum = curentNum / dividend 
-    } 
-    var m = {num: 0, unit: ""}
-    m.num = curentNum.toFixed(2)
-    m.unit = curentUnit;
-    return m;
-}
- 
-export function strNumSize(tempNum){ 
-    var stringNum = tempNum.toString() 
-    var index = stringNum.indexOf(".") 
-    var newNum = stringNum;
-    if(index!=-1){
-        newNum = stringNum.substring(0,index) 
-    } 
-    return newNum.length
-}

+ 149 - 0
common/mock/index.js

@@ -0,0 +1,149 @@
+/*
+ * mock 存放全局静态数据
+ */
+import Vue from 'vue';
+const allMock = {
+	test: ['静态数据'],
+	//面单数据
+	order_data: {
+		SALES_SLIP: "XS202211056",
+		CUSTOMER_NAME: "青岛山高汽车科技服务有限公司",
+		SALES_DATE: '2022-12-24'
+	},
+	printTemplate: {
+		"pagConfig": {
+			"pageLeft": "0",
+			"pageTop": "0",
+			"pageHeight": "60",
+			"pageWidth": "74"
+		},
+		"printItem": [
+			{
+				"top": "10",
+				"left": "120",
+				"textAlign": "start",
+				"width": "247",
+				"fontSize": 9,
+				"text": "销售单",
+				"type": "text",
+				"fontWeight": "400",
+				"height": "20"
+			},
+			{
+				"top": "30",
+				"left": "10",
+				"textAlign": "start",
+				"width": "148",
+				"fontSize": 9,
+				"text": "NO.",
+				"type": "text",
+				"fontWeight": "20",
+				"height": "20"
+			},
+			{
+				"dataId": "SALES_SLIP",
+				"top": "30",
+				"left": "30",
+				"textAlign": "start",
+				"width": "148",
+				"fontSize": 9,
+				"text": "",
+				"type": "field",
+				"fontWeight": "400",
+				"height": "20"
+			},
+			{
+				"top": "50",
+				"left": "10",
+				"textAlign": "start",
+				"width": "150",
+				"fontSize": 8,
+				"text": "客户:",
+				"type": "text",
+				"fontWeight": "400",
+				"height": "20"
+			},
+			{
+				"dataId": "CUSTOMER_NAME",
+				"top": "50",
+				"left": "40",
+				"textAlign": "start",
+				"width": "160",
+				"fontSize": 8,
+				"text": "",
+				"type": "field",
+				"fontWeight": "400",
+				"height": "20"
+			},
+			{
+				"top": "50",
+				"left": "185",
+				"textAlign": "start",
+				"width": "100",
+				"fontSize": 6,
+				"text": "销售日期:",
+				"type": "text",
+				"fontWeight": "400",
+				"height": "20"
+			},
+			{
+				"dataId": "SALES_DATE",
+				"top": "50",
+				"left": "220",
+				"textAlign": "start",
+				"width": "148",
+				"fontSize": 6,
+				"text": "",
+				"type": "field",
+				"fontWeight": "400",
+				"height": "20"
+			},
+			{
+				"top": "70",
+				"left": "20",
+				"textAlign": "start",
+				"width": "40",
+				"fontSize": 8,
+				"text": "产品",
+				"type": "text",
+				"fontWeight": "400",
+				"height": "20"
+			},
+			{
+				"top": "70",
+				"left": "130",
+				"textAlign": "start",
+				"width": "40",
+				"fontSize": 8,
+				"text": "数量",
+				"type": "text",
+				"fontWeight": "400",
+				"height": "20"
+			},
+			{
+				"top": "70",
+				"left": "160",
+				"textAlign": "start",
+				"width": "50",
+				"fontSize": 8,
+				"text": "单价",
+				"type": "text",
+				"fontWeight": "400",
+				"height": "20"
+			},
+			{
+				"top": "70",
+				"left": "215",
+				"textAlign": "start",
+				"width": "60",
+				"fontSize": 8,
+				"text": "金额",
+				"type": "text",
+				"fontWeight": "400",
+				"height": "20"
+			}
+		]
+	}
+}
+
+export default allMock;

File diff suppressed because it is too large
+ 206 - 0
common/print.js


+ 2 - 2
common/setting.js

@@ -9,8 +9,8 @@ module.exports = {
 	// 版本号
 	version: '1.0.0',
 	// 开发环境接口Url
-	devUrl: 'http://192.168.1.111:1080',
-	// devUrl: 'http://121.37.83.47:10004',
+	// devUrl: 'http://192.168.0.101:1080',
+	devUrl: 'http://121.37.83.47:10004',
 	// 线上环境接口Url
 	prodUrl: 'http://121.37.83.47:10004',
 	// 后端数据的接收方式application/json;charset=UTF-8或者application/x-www-form-urlencoded;charset=UTF-8

+ 9 - 0
main.js

@@ -14,6 +14,15 @@ Vue.use(uView)
 const vuexStore = require("@/store/$u.mixin.js");
 Vue.mixin(vuexStore);
 
+import '@/common/bluetooth.js';
+//全局数据状态管理 vuex
+// import store from '@/store/index.js';
+// Vue.prototype.$store = store;
+//全局公用静态数据
+import Mock from '@/common/mock/index.js';
+Vue.prototype.$Mock = Mock;
+App.mpType = 'app'
+
 // 创建对象
 const app = new Vue({
 	store,

+ 20 - 2
manifest.json

@@ -2,8 +2,8 @@
     "name" : "易车配批发精灵",
     "appid" : "__UNI__E1B82BE",
     "description" : "",
-    "versionName" : "1.0.33",
-    "versionCode" : 33,
+    "versionName" : "1.0.36",
+    "versionCode" : 36,
     "transformPx" : false,
     /* 5+App特有相关 */
     "app-plus" : {
@@ -37,6 +37,8 @@
                     "<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>",
                     "<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
                     "<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
+                    "<uses-permission android:name=\"android.permission.BLUETOOTH\"/>",
+                    "<uses-permission android:name=\"android.permission.BLUETOOTH_ADMIN\"/>",
                     "<uses-permission android:name=\"android.permission.BROADCAST_SMS\"/>",
                     "<uses-permission android:name=\"android.permission.CALL_PHONE\"/>",
                     "<uses-permission android:name=\"android.permission.CAMERA\"/>",
@@ -110,6 +112,22 @@
                     }
                 }
             }
+        },
+        "nativePlugins" : {
+            "Hanyin-Plugin" : {
+                "__plugin_info__" : {
+                    "name" : "HanyinPlugin",
+                    "description" : "汉印便携式打印机",
+                    "platforms" : "Android",
+                    "url" : "",
+                    "android_package_name" : "",
+                    "ios_bundle_id" : "",
+                    "isCloud" : false,
+                    "bought" : -1,
+                    "pid" : "",
+                    "parameters" : {}
+                }
+            }
         }
     },
     /* 快应用特有相关 */

BIN
nativeplugins/Hanyin-Plugin/android/hanyin_plugin1.0.4.aar


+ 21 - 0
nativeplugins/Hanyin-Plugin/package.json

@@ -0,0 +1,21 @@
+{
+	"name": "HanyinPlugin",
+	"id": "Hanyin-Plugin",
+	"version": "1.0.4",
+	"description": "汉印便携式打印机",
+	"_dp_type":"nativeplugin",
+	"_dp_nativeplugin":{
+		"android": {
+			"plugins": [
+				{
+					"type": "module",
+					"name": "Hanyin-Plugin",
+					"class": "com.example.hanyin_plugin.Methods"
+				}
+			],
+			"integrateType": "aar",
+			"minSdkVersion" : 19,
+			"targetSdkVersion": 31
+		}
+	}
+}

+ 19 - 4
pages.json

@@ -92,9 +92,9 @@
 		"pages": [{
 			"path": "productLaunch/index",
 			"style": {
-				"navigationBarTitleText": "产品上架",
-				"app-plus": {
-					"titleNView": false
+				"navigationBarTitleText": "产品上架",
+				"app-plus": {
+					"titleNView": false
 				}
 			}
 		}]
@@ -152,7 +152,17 @@
 			}, {
 				"path": "salesSlip/salesOrderDetails",
 				"style": {
-					"navigationBarTitleText": "销售明细"
+					"navigationBarTitleText": "销售明细",
+					"titleNView": {
+						"buttons": [{
+							"text": "\ue630",
+							"fontSrc": "/static/typeface/iconfont.ttf",
+							"fontSize": "16px",
+							"float": "right",
+							"color": "#fff"
+						}],
+						"backgroundImage": "linear-gradient(to bottom, #FD4B09, #FF6F3B)"
+					}
 				}
 			}, {
 				"path": "purchase/salesOrderDetails",
@@ -352,6 +362,11 @@
 						"titleNView": false
 					}
 				}
+			}, {
+				"path": "bluetooth/index",
+				"style": {
+					"navigationBarTitleText": "蓝牙设备"
+				}
 			}
 		]
 	}],

+ 2 - 1
pages/tabBar/home.vue

@@ -174,7 +174,8 @@
 						this.$u.route('/pages/views/visit/visit');
 						break
 					case 'productLaunch':
-						this.$u.route('/pages/views/productLaunch/index');
+						this.$u.route('/pages/views/productLaunch/index');
+						// this.$u.route('/pages/views/bluetooth/index');
 						break
 					default:
 						this.$refs.uToast.success("该功能暂未开发~")

+ 335 - 0
pages/views/bluetooth/index.vue

@@ -0,0 +1,335 @@
+<template>
+	<view class="content">
+		{{GET_REQUEST_DATA}}
+		<view>
+			<view class="bluetoothConnected">
+				<view class="bluetoothList" v-for="(item,index) in GET_CONNECTBLEDATA" :key="index"
+					@tap="confirm_bluetooth(item)">
+					<view class="bluetoothList-name">名称:{{item.name}}</view>
+					<view class="bluetoothList-mac">地址:{{item.mac}}</view>
+				</view>
+			</view>
+			<button type="default" @click="search_bluetooth">搜索蓝牙</button>
+			<button @click="senBleLabel">打印</button>
+			<view class="bluetoothItem" v-if="GET_INFODATA">
+				<view class="bluetoothList" v-for="(item,index) in GET_INFODATA" :key="index"
+					@tap="confirm_bluetooth(item)">
+					<view class="bluetoothList-name">名称:{{item.name}}</view>
+					<view class="bluetoothList-mac">地址:{{item.mac}}</view>
+				</view>
+			</view>
+		</view>
+	</view>
+</template>
+
+<script>
+	import printConnect from "@/common/print.js"; //引入打印机模板文件 
+	let _this = null;
+	import {
+		mapGetters,
+		mapActions
+	} from 'vuex';
+	import {
+		GET_INFODATA,
+		GET_CONNECTBLEDATA,
+		GET_REQUEST_DATA
+	} from "@/store/gettersType.js";
+	import {
+		SET_CONNECTBLEDATA,
+		SET_REQUEST_DATA
+	} from '@/store/actionsType.js';
+	// #ifdef APP-PLUS
+	const HanyinPlugin = uni.requireNativePlugin('Hanyin-Plugin'); //汉印
+	// #endif
+	let print;
+	import store from 'store';
+	import {
+		DX
+	} from '@/common/dateFormat.js';
+	export default {
+		data() {
+			return {
+				bArray: [], //用于搜索蓝牙去重用的
+				no_match_list: [], //没有配对的蓝牙列表
+				match_list: "", //已连接蓝牙打印机
+				val: "",
+				dateTimer: "",
+				valArr: [],
+				form:{},
+				amountNumber:{},
+				connectedPrint:{}
+				// 巴枪参数
+				// broadcase_actions: "com.android.receive_scan_action",
+				// broadcast_flag: "data"
+			};
+		},
+		computed: {
+			...mapGetters([GET_INFODATA, GET_CONNECTBLEDATA,GET_REQUEST_DATA])
+		},
+		onShow() {
+			// console.log(this.$store.state.connectedPrint)
+			// this.connectedPrint = this.$store.state.connectedPrint
+			uni.hideLoading();
+			//检查是否已连接蓝牙
+			this.$check_bluetooth_connect();
+			console.log('onShow');
+		},
+		onHide() {
+			console.log('onHide');
+		},
+		onUnload() {
+			console.log('onUnload');
+		},
+		onLoad(options) {
+			_this = this;
+			_this.form = JSON.parse(options.data)
+			console.log(JSON.parse(options.data))
+			_this.amountNumber = {
+				deliveryAll: 0, //送货总数量
+				cost: 0, //成本
+				grossProfit: 0, //毛利
+				delivery: 0, //送货
+				saleAll: 0, //销售数量
+				amount: 0
+			}
+			for (let item of _this.form.orderItemsList) {
+				_this.amountNumber.saleAll += Number(item.storageInQuantity)
+				_this.amountNumber.cost += Number(item.storageInQuantity) * Number(item.purchasePrice)
+				_this.amountNumber.delivery += Number(item.actualQuantity)
+				_this.amountNumber.deliveryAll += Number(item.actualQuantity)
+				_this.amountNumber.amount += Number(item.amount)
+				_this.amountNumber.grossProfit += Number(item.amount) - (item.purchasePrice ? Number(item.storageInQuantity) * Number(item.purchasePrice) : 0)
+			}
+			_this.form.purchaseAmount = this.amountNumber.amount
+			_this.$init_bluetooth();
+		},
+		methods: {
+			...mapActions([SET_CONNECTBLEDATA]),
+			senBleLabel() {
+				// console.log(this.$Mock.order_data);
+				return this.$store.dispatch(SET_REQUEST_DATA, {name:this.name,mac:this.mac});
+				if (!print) return;
+				this.$Mock.printTemplate.pagConfig = 0
+				console.log(this.$Mock.printTemplate.pagConfig)
+				let data = []
+				let i = 0
+				for(let item of this.form.orderItemsList){
+					data.push({
+						"top": Number(i*40+90),
+						"left": "0",
+						"textAlign": "start",
+						"width": "270",
+						"fontSize": 9,
+						"text": item.cname,
+						"type": "text",
+						"fontWeight": "400",
+						"height": "20"
+					})
+					data.push({
+						"top": Number(i*40+110),
+						"left": "140",
+						"textAlign": "start",
+						"width": "40",
+						"fontSize": 8,
+						"text": Number(item.storageInQuantity),
+						"type": "text",
+						"fontWeight": "400",
+						"height": "20"
+					})
+					data.push({
+						"top": Number(i*40+110),
+						"left": "160",
+						"textAlign": "start",
+						"width": "50",
+						"fontSize": 8,
+						"text": item.price,
+						"type": "text",
+						"fontWeight": "400",
+						"height": "20"
+					})
+					data.push({
+						"top": Number(i*40+110),
+						"left": "210",
+						"textAlign": "start",
+						"width": "60",
+						"fontSize": 8,
+						"text": item.amount,
+						"type": "text",
+						"fontWeight": "400",
+						"height": "20"
+					})
+					i++
+				}
+				data.push({
+					"top": Number(i*40+90),
+					"left": "20",
+					"textAlign": "start",
+					"width": "270",
+					"fontSize": 9,
+					"text": "合计:",
+					"type": "text",
+					"fontWeight": "400",
+					"height": "20"
+				})
+				data.push({
+					"top": Number(i*40+90),
+					"left": "140",
+					"textAlign": "start",
+					"width": "40",
+					"fontSize": 8,
+					"text": this.amountNumber.saleAll,
+					"type": "text",
+					"fontWeight": "400",
+					"height": "20"
+				})
+				data.push({
+					"top": Number(i*40+90),
+					"left": "210",
+					"textAlign": "start",
+					"width": "60",
+					"fontSize": 8,
+					"text": this.form.orderAmount,
+					"type": "text",
+					"fontWeight": "400",
+					"height": "20"
+				})
+				
+				
+				data.push({
+					"top": Number(i*40+110),
+					"left": "20",
+					"textAlign": "start",
+					"width": "270",
+					"fontSize": 9,
+					"text": "产品合计:",
+					"type": "text",
+					"fontWeight": "400",
+					"height": "20"
+				})
+				data.push({
+					"top": Number(i*40+110),
+					"left": "70",
+					"textAlign": "start",
+					"width": "70",
+					"fontSize": 8,
+					"text": this.amountNumber.amount,
+					"type": "text",
+					"fontWeight": "400",
+					"height": "20"
+				})
+				data.push({
+					"top": Number(i*40+110),
+					"left": "140",
+					"textAlign": "start",
+					"width": "60",
+					"fontSize": 8,
+					"text": "合计金额:",
+					"type": "text",
+					"fontWeight": "400",
+					"height": "20"
+				})
+				data.push({
+					"top": Number(i*40+110),
+					"left": "190",
+					"textAlign": "start",
+					"width": "80",
+					"fontSize": 8,
+					"text": DX(this.amountNumber.amount),
+					"type": "text",
+					"fontWeight": "400",
+					"height": "40"
+				})
+				
+				
+				data.push({
+					"top": Number(i*40+130),
+					"left": "20",
+					"textAlign": "start",
+					"width": "270",
+					"fontSize": 9,
+					"text": "订货电话:"+this.form.clientAttn,
+					"type": "text",
+					"fontWeight": "400",
+					"height": "20"
+				})
+				data.push({
+					"top": Number(i*40+150),
+					"left": "20",
+					"textAlign": "start",
+					"width": "270",
+					"fontSize": 9,
+					"text": "制单人:"+this.form.client,
+					"type": "text",
+					"fontWeight": "400",
+					"height": "20"
+				})
+				data.push({
+					"top": Number(i*40+150),
+					"left": "140",
+					"textAlign": "start",
+					"width": "80",
+					"fontSize": 8,
+					"text": "收货人(签字):",
+					"type": "text",
+					"fontWeight": "400",
+					"height": "20"
+				})
+				console.log((this.form.orderItemsList.length*40)/3)
+				print.startPrint({
+					SALES_SLIP:this.form.sysNo,
+					CUSTOMER_NAME:this.form.corpsName,
+					SALES_DATE:this.form.businesDate.slice(0, 10)
+				},{pageHeight:(this.form.orderItemsList.length*40)/3},data);
+			},
+			// 连接打印机
+			confirm_bluetooth(item) {
+				let {
+					name,
+					mac
+				} = item;
+				//判断蓝牙是否打开
+				this.$check_bluetooth_open().then(res => {
+					console.log(res);
+					//进行打印机连接
+					if (res) {
+						print = new printConnect(item); //打印机连接
+					}
+				})
+			},
+			//搜索没匹配的蓝牙设备
+			search_bluetooth(address) {
+				let _this = this;
+				//检查蓝牙是否开启
+				this.$check_bluetooth_open().then(ores => {
+					if (ores) {
+						console.log(ores);
+						//搜索蓝牙
+						_this.$search_bluetooth().then(bres => {
+							console.log(bres);
+							if (bres.code) {
+								_this.$search_pipei().then(pres => {
+									console.log(pres);
+								})
+							}
+						})
+					}
+				})
+			}
+		}
+	}
+</script>
+
+<style lang="scss">
+	.bluetoothItem {
+		width: 100%;
+		height: 100%;
+
+		.bluetoothList {
+			display: flex;
+			flex-direction: column;
+			padding: 20rpx;
+			border-bottom: 1rpx solid #BEBEBE;
+			font-size: 18rpx;
+		}
+	}
+</style>

+ 11 - 6
pages/views/purchase/selectProduct.vue

@@ -231,7 +231,8 @@
 					this.tabbarData = []
 					queryCommodity({
 						goodsTypeId: item.id,
-						storageId: this.mainForm.storageId, //仓库id
+						storageId: this.mainForm.storageId, //仓库id
+						billType:"CG",
 						...this.formTwo
 					}).then(resTwo => {
 						this.total = resTwo.data.total || []
@@ -257,7 +258,8 @@
 					});
 					queryCommodity({
 						goodsTypeId: this.tabbarData[0].id,
-						storageId: this.mainForm.storageId, //仓库id
+						storageId: this.mainForm.storageId, //仓库id
+						billType:"CG",
 						...this.formTwo
 					}).then(res => {
 						this.total = res.data.total || []
@@ -358,7 +360,8 @@
 						}
 						queryCommodity({
 							goodsTypeId: null,
-							storageId: this.mainForm.storageId, //仓库id
+							storageId: this.mainForm.storageId, //仓库id
+						billType:"CG",
 							...this.formTwo
 						}).then(resTwo => {
 							this.total = resTwo.data.total || []
@@ -389,7 +392,8 @@
 				});
 				queryCommodity({
 					goodsTypeId: this.tabbarTwo[index].id,
-					storageId: this.mainForm.storageId, //仓库id
+					storageId: this.mainForm.storageId, //仓库id
+						billType:"CG",
 					...this.formTwo
 				}).then(res => {
 					this.tabbarData = []
@@ -417,7 +421,8 @@
 				});
 				queryCommodity({
 					// goodsTypeId: this.tabbar[index].id,
-					storageId: this.mainForm.storageId, //仓库id
+					storageId: this.mainForm.storageId, //仓库id
+					billType:"CG",
 					...this.formTwo
 				}).then(res => {
 					this.tabbarData = []
@@ -434,7 +439,7 @@
 			selectProduct(item) {
 				partsDetails({
 					goodsId: item.id, //商品id
-					storageId: this.mainForm.storageId, //仓库id
+					// storageId: this.mainForm.storageId, //仓库id
 				}).then(res => {
 					this.form = res.data
 					this.form.surplusRouteQuantity = res.data.stockGoods ? res.data.stockGoods

+ 191 - 150
pages/views/salesSlip/salesOrderDetails.vue

@@ -149,29 +149,31 @@
 					<u-form-item label="应收金额" prop="mailbox" borderBottom>
 						<u-input v-model="form.orderAmount" inputAlign="right" border="none" placeholder="请输入" disabled
 							disabledColor="#ffffff" />
-					</u-form-item>
-					<view v-if="form.confirmStatus == 1">
-						<u-form-item label="已收金额" @click="filterAll(['settlmentAmount','settlmentAmount'])" prop="mailbox"
-							borderBottom>
-							<u-input v-model="form.settlmentAmount" inputAlign="right" border="none" placeholder="请输入"
-								disabled disabledColor="#ffffff" />
-						</u-form-item>
-						<u-form-item label="本次收款" prop="mailbox" borderBottom>
-							<u-input type="number" clearable v-model="form.currentAmount" inputAlign="right" border="none" placeholder="请输入"
-								:disabled="form.confirmStatus == 0 || (form.orderAmount - form.settlmentAmount) == 0" disabledColor="#ffffff" />
-						</u-form-item>
-						<u-form-item label="收款账户" prop="mailbox" borderBottom @click="filterAll(['account','account'])">
-							<u-input v-model="form.account" inputAlign="right" border="none" placeholder="请选择" disabled
-								disabledColor="#ffffff">
-								<template slot="suffix" style="text-align: center;">
-									<u-icon name="plus-circle" size="18" @click.native.stop="newCompany()"></u-icon>
-								</template>
-							</u-input>
-						</u-form-item>
-						<u-form-item label="收款单号" prop="mailbox" borderBottom>
-							<u-input v-model="form.receiptNo" inputAlign="right" border="none" disabled
-								disabledColor="#ffffff" />
-						</u-form-item>
+					</u-form-item>
+					<view v-if="form.confirmStatus == 1">
+						<u-form-item label="已收金额" @click="filterAll(['settlmentAmount','settlmentAmount'])"
+							prop="mailbox" borderBottom>
+							<u-input v-model="form.settlmentAmount" inputAlign="right" border="none" placeholder="请输入"
+								disabled disabledColor="#ffffff" />
+						</u-form-item>
+						<u-form-item label="本次收款" prop="mailbox" borderBottom>
+							<u-input type="number" clearable v-model="form.currentAmount" inputAlign="right"
+								border="none" placeholder="请输入"
+								:disabled="form.confirmStatus == 0 || (form.orderAmount - form.settlmentAmount) == 0"
+								disabledColor="#ffffff" />
+						</u-form-item>
+						<u-form-item label="收款账户" prop="mailbox" borderBottom @click="filterAll(['account','account'])">
+							<u-input v-model="form.account" inputAlign="right" border="none" placeholder="请选择" disabled
+								disabledColor="#ffffff">
+								<template slot="suffix" style="text-align: center;">
+									<u-icon name="plus-circle" size="18" @click.native.stop="newCompany()"></u-icon>
+								</template>
+							</u-input>
+						</u-form-item>
+						<u-form-item label="收款单号" prop="mailbox" borderBottom>
+							<u-input v-model="form.receiptNo" inputAlign="right" border="none" disabled
+								disabledColor="#ffffff" />
+						</u-form-item>
 					</view>
 				</view>
 			</view>
@@ -179,20 +181,18 @@
 				style="width: calc(96%);margin: 0 auto;background-color: #fff;border-radius: 20rpx;margin-top: 20rpx;">
 				<u-cell-group :border="false">
 					<u-cell :border="false" center title="图片信息" arrow-direction="down">
-						<view slot="icon" style="width: 10rpx;height: 35rpx;background-color: #fd4b09;"></view>
-						<view slot="value">
-							<view
-								v-if="form.confirmStatus == 1"
-								@click.stop="saveAttachment"
-								style="padding: 2rpx 20rpx;border:1rpx solid #FD4B09;border-radius: 100rpx;color: #FD4B09;">
-								保存
-							</view>
+						<view slot="icon" style="width: 10rpx;height: 35rpx;background-color: #fd4b09;"></view>
+						<view slot="value">
+							<view v-if="form.confirmStatus == 1" @click.stop="saveAttachment"
+								style="padding: 2rpx 20rpx;border:1rpx solid #FD4B09;border-radius: 100rpx;color: #FD4B09;">
+								保存
+							</view>
 						</view>
 					</u-cell>
 				</u-cell-group>
 				<view style="padding: 0 10rpx;">
-					<u-upload :fileList="fileList1" @afterRead="afterRead"
-						@delete="deletePic" name="1" multiple :maxCount="10"></u-upload>
+					<u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple
+						:maxCount="10"></u-upload>
 				</view>
 			</view>
 		</u--form>
@@ -222,22 +222,26 @@
 					style="width: 20%;background-color: #fd4b09;display: grid;justify-items: center;">
 					<u-icon name="close" color="#fff"></u-icon>
 					<view style="color: #fff;">撤销提交</view>
-				</view>
-				<view v-if="form.confirmStatus == 1" style="width: 40%;">
-					<view @click="confirmReceipt" v-if="(form.orderAmount - form.settlmentAmount) > 0"
-						style="background-color: #5ac725;display: grid;justify-items: center;height: 100%;">
-						<u-icon name="checkmark" color="#fff"></u-icon>
-						<view style="color: #fff;">确认收款</view>
-					</view>
-					<view v-else
-						style="background-color: #b3b3b3;display: grid;justify-items: center;height: 100%;">
-						<u-icon name="checkmark" color="#fff"></u-icon>
-						<view style="color: #fff;">已全部收款</view>
-					</view>
 				</view>
-				
+				<view v-if="form.confirmStatus == 1" style="width: 40%;">
+					<view @click="confirmReceipt" v-if="(form.orderAmount - form.settlmentAmount) > 0"
+						style="background-color: #5ac725;display: grid;justify-items: center;height: 100%;">
+						<u-icon name="checkmark" color="#fff"></u-icon>
+						<view style="color: #fff;">确认收款</view>
+					</view>
+					<view v-else style="background-color: #b3b3b3;display: grid;justify-items: center;height: 100%;">
+						<u-icon name="checkmark" color="#fff"></u-icon>
+						<view style="color: #fff;">已全部收款</view>
+					</view>
+				</view>
 			</view>
 		</view>
+		<view v-if="choice" class="choice" @touchmove.stop.prevent="moveHandle">
+			<u-cell-group>
+				<u-cell icon="setting-fill" title="未连接"></u-cell>
+				<u-cell icon="integral-fill" title="保存图片"></u-cell>
+			</u-cell-group>
+		</view>
 		<u-datetime-picker :show="timeOpen" v-model="datetime" mode="date" @cancel="timeOpen = false"
 			@confirm="confirmTiem"></u-datetime-picker>
 		<u-picker :show="showOpen" :columns="columns" keyName="dictValue" @cancel="showOpen = false"
@@ -255,8 +259,9 @@
 		revoke,
 		removeItem,
 		removeId,
-		copyOrder,
-		collectPayment,saveAtta
+		copyOrder,
+		collectPayment,
+		saveAtta
 	} from '@/api/views/sale/salesOrderDetails.js'
 	import http from '@/http/api.js'
 	import {
@@ -266,6 +271,9 @@
 	import {
 		dateFormat
 	} from '@/common/dateFormat'
+	// #ifdef APP-PLUS
+	const HanyinPlugin = uni.requireNativePlugin('Hanyin-Plugin'); //汉印
+	// #endif
 	export default {
 		data() {
 			return {
@@ -277,6 +285,7 @@
 				fileList1: [],
 				screen: [],
 				showOpen: false,
+				choice: false,
 				columns: [],
 				amountNumber: {
 					deliveryAll: 0,
@@ -290,13 +299,26 @@
 		},
 		onLoad(data) {
 			this.refresh(data.id)
+			// #ifdef APP-PLUS
+			HanyinPlugin.IsOpened(res => {
+				console.log(res.state)
+				if (res.state == true) {
+					console.log(Bluetooth)
+				}
+			});
+			// #endif
+		},
+		onNavigationBarButtonTap(e) {
+			this.choice = !this.choice
+			// uni.$u.route('/pages/views/bluetooth/index',{data:JSON.stringify(this.form)});
 		},
 		methods: {
-			newCompany() {
-				uni.$u.route('/pages/views/product/createCompany',{
-					code:"account",
-					title:"收款账户"
-				});
+			moveHandle(){},
+			newCompany() {
+				uni.$u.route('/pages/views/product/createCompany', {
+					code: "account",
+					title: "收款账户"
+				});
 			},
 			calculationContract() {
 				let data = {
@@ -350,11 +372,14 @@
 								}
 								for (let item of this_.form.orderItemsList) {
 									this_.amountNumber.saleAll += Number(item.storageInQuantity)
-									this_.amountNumber.cost += Number(item.storageInQuantity) * Number(item.purchasePrice)
+									this_.amountNumber.cost += Number(item.storageInQuantity) * Number(
+										item.purchasePrice)
 									this_.amountNumber.delivery += Number(item.actualQuantity)
 									this_.amountNumber.deliveryAll += Number(item.actualQuantity)
 									this_.amountNumber.amount += Number(item.amount)
-									this_.amountNumber.grossProfit += Number(item.amount) - (item.purchasePrice ? Number(item.storageInQuantity) * Number(item.purchasePrice) : 0)
+									this_.amountNumber.grossProfit += Number(item.amount) - (item
+										.purchasePrice ? Number(item.storageInQuantity) * Number(
+											item.purchasePrice) : 0)
 								}
 								this.form.purchaseAmount = this.amountNumber.amount
 							})
@@ -364,13 +389,13 @@
 			},
 			deleteDoc() {
 				if (this.form.id) {
-					let this_ = this
-					if(this_.form.confirmStatus == 1){
-						return uni.showToast({
-							icon: "none",
-							title: '禁止删除',
-							mask: true
-						});
+					let this_ = this
+					if (this_.form.confirmStatus == 1) {
+						return uni.showToast({
+							icon: "none",
+							title: '禁止删除',
+							mask: true
+						});
 					}
 					uni.showModal({
 						title: '提示',
@@ -443,7 +468,7 @@
 				this.showOpen = false
 			},
 			//集合筛选条件
-			filterAll(screen) {
+			filterAll(screen) {
 				if (screen[1] == "account") {
 					if (this.form.confirmStatus == 0) {
 						return uni.showToast({
@@ -451,22 +476,22 @@
 							title: '禁止操作',
 							mask: true
 						});
-					}else if((this.form.orderAmount - this.form.settlmentAmount) == 0){
-						return uni.showToast({
-							icon: "none",
-							title: '禁止操作',
-							mask: true
-						});
+					} else if ((this.form.orderAmount - this.form.settlmentAmount) == 0) {
+						return uni.showToast({
+							icon: "none",
+							title: '禁止操作',
+							mask: true
+						});
 					}
-				} else {
-					if(screen[1] !== "settlmentAmount"){
-						if (this.form.confirmStatus == 1) {
-							return uni.showToast({
-								icon: "none",
-								title: '禁止操作',
-								mask: true
-							});
-						}
+				} else {
+					if (screen[1] !== "settlmentAmount") {
+						if (this.form.confirmStatus == 1) {
+							return uni.showToast({
+								icon: "none",
+								title: '禁止操作',
+								mask: true
+							});
+						}
 					}
 				}
 				this.screen = screen
@@ -515,90 +540,91 @@
 						this.amountNumber.delivery += Number(item.actualQuantity)
 						this.amountNumber.deliveryAll += Number(item.actualQuantity)
 						this.amountNumber.amount += Number(item.amount)
-						this.amountNumber.grossProfit += Number(item.amount) - (item.purchasePrice ? Number(item.storageInQuantity) * Number(item.purchasePrice) : 0)
+						this.amountNumber.grossProfit += Number(item.amount) - (item.purchasePrice ? Number(item
+							.storageInQuantity) * Number(item.purchasePrice) : 0)
 					}
-					this.form.purchaseAmount = this.amountNumber.amount
-					setTimeout(function() {
-						uni.hideLoading();
+					this.form.purchaseAmount = this.amountNumber.amount
+					setTimeout(function() {
+						uni.hideLoading();
 					}, 500);
 				})
 			},
 			//确认收款
-			confirmReceipt() {
-				let this_ = this
-				let form = {
-					...this_.form,
-					orderFilesList: this_.fileList1
-				}
-				if (form.orderFilesList.length > 0) {
-					form.orderFilesList.forEach(item => delete item.status)
-				}
-				if(!form.currentAmount){
-					return uni.showToast({
-						icon: "none",
-						title: '本次收款金额不能为空',
-						mask: true,
-						duration:2000
-					});
-				}
-				if(!form.account){
-					return uni.showToast({
-						icon: "none",
-						title: '未选择收款账户',
-						mask: true,
-						duration:2000
-					});
+			confirmReceipt() {
+				let this_ = this
+				let form = {
+					...this_.form,
+					orderFilesList: this_.fileList1
+				}
+				if (form.orderFilesList.length > 0) {
+					form.orderFilesList.forEach(item => delete item.status)
+				}
+				if (!form.currentAmount) {
+					return uni.showToast({
+						icon: "none",
+						title: '本次收款金额不能为空',
+						mask: true,
+						duration: 2000
+					});
+				}
+				if (!form.account) {
+					return uni.showToast({
+						icon: "none",
+						title: '未选择收款账户',
+						mask: true,
+						duration: 2000
+					});
 				}
 				uni.showModal({
 					title: '是否确认收款',
-					content: '本次收款金额'+form.currentAmount,
+					content: '本次收款金额' + form.currentAmount,
 					success: function(rest) {
-						if (rest.confirm == true) {
-							uni.showLoading({
-								title: '加载中',
-								mask: true
-							});
-							collectPayment(form).then(res=>{
-								uni.showToast({
-									icon: "none",
-									title: '收款成功',
-									mask: true,
-									duration:2000
-								});
-								setTimeout(function() {
-									uni.hideLoading();
-									this_.refresh(res.data.id)
-								}, 1000);
-							})
+						if (rest.confirm == true) {
+							uni.showLoading({
+								title: '加载中',
+								mask: true
+							});
+							collectPayment(form).then(res => {
+								uni.showToast({
+									icon: "none",
+									title: '收款成功',
+									mask: true,
+									duration: 2000
+								});
+								setTimeout(function() {
+									uni.hideLoading();
+									this_.refresh(res.data.id)
+								}, 1000);
+							})
 						}
 					}
 				})
-			},
-			//保存附件
-			saveAttachment(){
-				let form = {
-					pid:this.form.id,
-					orderFilesList: this.fileList1
-				}
-				if (form.orderFilesList.length > 0) {
-					form.orderFilesList.forEach(item => delete item.status)
-				}
-				uni.showLoading({
-					title: '加载中',
-					mask: true
-				});
-				saveAtta(form).then(res => {
-					uni.showToast({
-						icon: "none",
-						title: '保存成功',
-						mask: true
-					});
-					let _this = this
-					setTimeout(function() {
-						uni.hideLoading();
-						_this.refresh(res.data.id)
-					}, 1000);
-				})
+			},
+			//保存附件
+			saveAttachment() {
+				let form = {
+					pid: this.form.id,
+					orderFilesList: this.fileList1
+				}
+				if (form.orderFilesList.length > 0) {
+					form.orderFilesList.forEach(item => delete item.status)
+				}
+				uni.showLoading({
+					title: '加载中',
+					mask: true
+				});
+				saveAtta(form).then(res => {
+					uni.showToast({
+						icon: "none",
+						title: '保存成功',
+						mask: true
+					});
+					let _this = this
+					setTimeout(function() {
+						uni.hideLoading();
+						_this.refresh(res.data.id)
+					}, 1000);
+				})
 			},
 			//保存
 			conserve() {
@@ -814,4 +840,19 @@
 	::v-deep .u-cell__body {
 		padding: 20rpx 10rpx;
 	}
+
+	.choice {
+		// position: fixed;
+		// top: calc(var(--status-bar-height) + 44px);
+		// right: 0;
+		// border: 1rpx solid #000;
+		// background-color: #fff;
+
+		width: 100%;
+		height: 100%;
+		position: fixed;
+		top: 0;
+		bottom: 0;
+		background-color: rgba(1, 1, 1, 0.3);
+	}
 </style>

+ 10 - 5
pages/views/salesSlip/selectProduct.vue

@@ -236,7 +236,8 @@
 					this.tabbarData = []
 					queryCommodity({
 						goodsTypeId: item.id,
-						storageId: this.mainForm.storageId, //仓库id
+						storageId: this.mainForm.storageId, //仓库id
+						billType:"XS",
 						...this.formTwo
 					}).then(resTwo => {
 						this.total = resTwo.data.total || []
@@ -262,7 +263,8 @@
 					});
 					queryCommodity({
 						goodsTypeId: this.tabbarData[0].id,
-						storageId: this.mainForm.storageId, //仓库id
+						storageId: this.mainForm.storageId, //仓库id
+						billType:"XS",
 						...this.formTwo
 					}).then(res => {
 						this.total = res.data.total || []
@@ -363,7 +365,8 @@
 						}
 						queryCommodity({
 							goodsTypeId: null,
-							storageId: this.mainForm.storageId, //仓库id
+							storageId: this.mainForm.storageId, //仓库id
+						billType:"XS",
 							...this.formTwo
 						}).then(resTwo => {
 							this.total = resTwo.data.total || []
@@ -394,7 +397,8 @@
 				});
 				queryCommodity({
 					goodsTypeId: this.tabbarTwo[index].id,
-					storageId: this.mainForm.storageId, //仓库id
+					storageId: this.mainForm.storageId, //仓库id
+					billType:"XS",
 					...this.formTwo
 				}).then(res => {
 					this.tabbarData = []
@@ -422,7 +426,8 @@
 				});
 				queryCommodity({
 					// goodsTypeId: this.tabbar[index].id,
-					storageId: this.mainForm.storageId, //仓库id
+					storageId: this.mainForm.storageId, //仓库id
+						billType:"XS",
 					...this.formTwo
 				}).then(res => {
 					this.tabbarData = []

+ 13 - 0
store/actionsType.js

@@ -0,0 +1,13 @@
+//bluetooth
+
+const SET_INFODATA = "SET_INFODATA";
+const SET_CONNECTBLEDATA = "SET_CONNECTBLEDATA";
+const SET_CONNECTPRINTBLE = "SET_CONNECTPRINTBLE"
+const SET_REQUEST_DATA = "SET_REQUEST_DATA"
+
+export {
+	SET_INFODATA,
+	SET_CONNECTBLEDATA,
+	SET_CONNECTPRINTBLE,
+	SET_REQUEST_DATA
+}

+ 15 - 0
store/gettersType.js

@@ -0,0 +1,15 @@
+
+
+//bluetooth
+const GET_CONNECTBLEDATA = "GET_CONNECTBLEDATA";
+const GET_INFODATA = "GET_INFODATA";
+const GET_CONNECTRINTDATA = "GET_CONNECTRINTDATA";
+const GET_REQUEST_DATA = "GET_REQUEST_DATA";
+
+
+export{
+	GET_CONNECTBLEDATA,
+	GET_INFODATA,
+	GET_CONNECTRINTDATA,
+	GET_REQUEST_DATA
+}

+ 19 - 1
store/index.js

@@ -1,6 +1,10 @@
 import Vue from 'vue'
 import Vuex from 'vuex'
-Vue.use(Vuex)
+
+//vuex模块引入
+import Bluetooth from './modules/bluetooth.js';  //存储蓝牙设备信息
+//vue使用vuex;
+Vue.use(Vuex);
 
 let lifeData = {};
 
@@ -28,6 +32,15 @@ const saveLifeData = function(key, value) {
 		uni.setStorageSync('lifeData', tmp);
 	}
 }
+
+// export default new Vuex.Store({
+// 	// 开启严格模式,仅开发模式下启用,发布环境下取消
+// 	strict: true,
+//     modules:{
+// 	   Bluetooth
+//     }
+// })
+
 const store = new Vuex.Store({
 	// 下面这些值仅为示例,使用过程中请删除
 	state: {
@@ -39,6 +52,7 @@ const store = new Vuex.Store({
 		},
 		accessToken: lifeData.accessToken ? lifeData.accessToken : '',
 		isLogin: lifeData.isLogin ? lifeData.isLogin : false,
+		connectedPrint:{}
 		// 如果version无需保存到本地永久存储,无需lifeData.version方式
 		// version: '1.0.0',
 	},
@@ -63,6 +77,10 @@ const store = new Vuex.Store({
 			// 保存变量到本地,见顶部函数定义
 			saveLifeData(saveKey, state[saveKey])
 		}
+	},
+	strict: true,
+	modules:{
+	   Bluetooth
 	}
 })
 

+ 70 - 0
store/modules/bluetooth.js

@@ -0,0 +1,70 @@
+import {SET_INFODATA,SET_CONNECTBLEDATA,SET_CONNECTPRINTBLE,SET_REQUEST_DATA} from '@/store/actionsType.js';
+import {GET_CONNECTBLEDATA,GET_INFODATA,GET_CONNECTRINTDATA,GET_REQUEST_DATA} from '@/store/gettersType.js';
+const state = {
+	BLEInfoData:[],  //存储蓝牙列表
+	connectBLEData:[], //存储已链接蓝牙列表
+	connectPrintBLE:{}   ,//存储已连接打印机蓝牙,存入缓存
+	ceshidata:{}
+}
+const mutations = {
+	[SET_INFODATA](state,value){
+		if(value instanceof Array){
+			state.BLEInfoData = value;
+		}else{
+			state.BLEInfoData.push(value);
+		}
+	},
+	[SET_CONNECTBLEDATA](state,value){
+		if(value instanceof Array){
+			state.connectBLEData = value;
+		}else{
+			state.connectBLEData.push(value);
+		}
+	},
+	[SET_CONNECTPRINTBLE](state,value){
+		state.connectPrintBLE = value;
+	},
+	[SET_REQUEST_DATA](state,value){
+		console.log(value)
+		// if(value instanceof Array){
+		// 	state.ceshidata = value;
+		// }else{
+			state.ceshidata = value;
+		// }
+	}
+}
+const actions = {
+	[SET_INFODATA]({commit},value){
+		commit(SET_INFODATA,value);
+	},
+	[SET_CONNECTBLEDATA]({commit},value){
+		commit(SET_CONNECTBLEDATA,value);
+	},
+	[SET_CONNECTPRINTBLE]({commit},value){
+		commit(SET_CONNECTPRINTBLE,value);
+	},
+	[SET_REQUEST_DATA]({commit},value){
+		commit(SET_REQUEST_DATA, value);
+	}
+	
+}
+const getters = {
+	[GET_CONNECTBLEDATA]:(state)=>{
+		return state.connectBLEData;
+	},
+	[GET_INFODATA]:(state)=>{
+		return state.BLEInfoData;
+	},
+	[GET_CONNECTRINTDATA]:(state)=>{
+		return state.connectPrintBLE
+	},
+	[GET_REQUEST_DATA]:(state)=>{
+		return state.ceshidata
+	}
+}
+export default{
+	state,
+	getters,
+	actions,
+	mutations
+};

Some files were not shown because too many files changed in this diff