提交 df3eb3b0 authored 作者: 刘旭's avatar 刘旭

提交最新代码

上级 7ffeb46d
import request from '@/utils/request' import request from '@/utils/request';
// 获取发布菜单 // 获取发布菜单
export const getMenuTree = () => request('/LowCodePlatform/center/permission/getMenuTree', 'GET') export const getMenuTree = () => request('/lowcodeplatform-system/center/permission/getMenuTree', 'GET');
export const getMenuList = () => request('/LowCodePlatform/user/getMenuList', 'POST') export const getMenuList = () => request('/lowcodeplatform-system/user/getMenuList', 'POST');
export const getBusinessList = (data: any) => request('/LowCodePlatform/center/business/list', 'GET', data) export const getBusinessList = (data: any) =>
request('/lowcodeplatform-system/center/business/list', 'POST', data);
export const getMetadataList = () => request('/LowCodePlatform/center/metadata/list', 'GET') export const getMetadataList = () => request('/lowcodeplatform-system/center/metadata/list', 'GET');
// 获取元数据 // 获取元数据
export const getMetadata = (formId: string) => request('/LowCodePlatform/center/metadata/detail', 'GET', { formId }) export const getMetadata = (formId: string) =>
request('/lowcodeplatform-system/center/metadata/detail', 'GET', { formId });
// 获取序列号扫描数据 // 获取序列号扫描数据
export const getDataBySerialNumber = (data: any) => request('/wms/serialNumber/getDataBySerialNumber', 'GET', data) export const getDataBySerialNumber = (data: any) =>
\ No newline at end of file request('/wms-system/serialNumber/getDataBySerialNumber', 'GET', data);
// 获取打印信息
export const getPrintData = (data: any) =>
request('/wms-system/labelRule/print/serial', 'POST', data);
// 获取打印信息
export const createBusiness = (data: any) =>
request('/lowcodeplatform-system/center/business/createBatch', 'POST', data);
import request from '@/utils/request' import request from '@/utils/request'
// 登录 // 登录
export const login = (data: any) => request('/LowCodePlatform/auth/login/app', 'POST', data) export const login = (data: any) => request('/lowcodeplatform-system/auth/login/app', 'POST', data)
...@@ -6,6 +6,9 @@ ...@@ -6,6 +6,9 @@
<textl>{{ item.value }}</textl> <textl>{{ item.value }}</textl>
</view> </view>
</block> </block>
<u-divider v-show="is_WMS_Receive" color="#fa3534">
<u-button type="primary" size="mini" @tap="handlePrint">打印</u-button>
</u-divider>
<!-- <u-row :gutter="12" class="box-list"> <!-- <u-row :gutter="12" class="box-list">
<u-col :span="10"> <u-col :span="10">
<u-row> <u-row>
...@@ -29,11 +32,21 @@ ...@@ -29,11 +32,21 @@
<!-- </u-col> <!-- </u-col>
</u-row> --> </u-row> -->
</view> </view>
<view style="margin-top:4%; display: flex; flex-direction: row;">
<canvas canvas-id="edit_area_canvas"
:style="{ width: state.canvasWidth + 'px', height: state.canvasHeight + 'px' }"></canvas>
</view>
</template> </template>
<script setup lang='ts'> <script setup lang="ts">
import { ref } from 'vue' import { ref, computed, reactive } from 'vue'
import { useBlueTooth } from '@/store/modules/bluetooth';
import { createNew } from '@/utils/ble/tsc'
import { data } from './demo'
import { getPrintData } from '@/api/apply'
// import { init, labelTest } from '@/utils/print'
const blueTooth = useBlueTooth()
const props = defineProps({ const props = defineProps({
businessList: { businessList: {
type: Array type: Array
...@@ -41,13 +54,242 @@ const props = defineProps({ ...@@ -41,13 +54,242 @@ const props = defineProps({
}) })
const checked = ref(false) const checked = ref(false)
const state: any = reactive({
looptime: 0,
currentTime: 1,
lastData: 0,
oneTimeData: 0,
canvasWidth: 1050,
canvasHeight: 750,
buffSize: [],
printNum: [],
printerNum: 1,
currentPrint: 1,
isReceiptSend: false,
isLabelSend: false
})
const is_WMS_Receive = computed(() => {
return JSON.parse(uni.getStorageSync('pageData')).permTag == 'WMS_Receive' ? true : false
}) // 是否收料通知单
const labelData = () => {
let obj: any
const config = data.config
const list = data.list
obj = {
x: config.x,
y: config.y,
list: []
}
list.map((item: any) => {
if (item.columns) {
item.columns.map((col: any) => {
col.list.map((list: any) => {
obj.list?.push({
label: list.label,
type: list.type,
value: list.options.defaultValue,
x: list.options.x,
y: list.options.y
})
})
})
} else obj.list?.push({
label: item.label,
type: item.type,
value: item.options.defaultValue,
x: item.options.x,
y: item.options.y
})
})
return obj
}
const checkboxChange = (val: boolean) => { const checkboxChange = (val: boolean) => {
console.log(val); console.log(val);
} }
const handlePrint = async () => {
const res: any = await getPrintData(['A021'])
console.log(res);
// const deviceId = blueTooth.BLEInformation.deviceId
// labelTest(labelData())
// if (!deviceId) {
// uni.navigateTo({ url: '/pages/blueTooth/index' })
// }
// uni.createBLEConnection({
// deviceId: blueTooth.BLEInformation.deviceId,
// success: (result) => {
// console.log(result, 'result');
// },
// fail: async (error) => {
// console.log(error, 'error');
// if (error.code == -1) {
// // await init()
// // await labelTest(blueTooth, demo)
// labelTest(labelData())
// }
// }
// })
}
const init = () => {
let list = [] as any[]
let numList = []
let j = 0
for (let i = 20; i < 200; i += 10) {
list[j] = i;
j++
}
for (let i = 1; i < 10; i++) {
numList[i - 1] = i
}
state.buffSize = list;
// state.oneTimeData = list[0];
state.oneTimeData = 20;
state.printNum = numList;
state.printerNum = numList[0];
}
const labelTest = (printData: any) => {
console.log(printData);
const { x, y, list } = printData
let canvasWidth = state.canvasWidth
let canvasHeight = state.canvasHeight
// x 和 y: 文字的起始位置坐标,以毫米为单位。
// font: 字体类型,可以是预装载的或者外部下载的字体。
// x_ 和 y_: 水平和垂直缩放比例,范围为 0 - 10,可调整字体大小。
// str: 要打印的文字内容。
// codetype: 条形码类型,支持 CODE128、CODE39、CODE93 等多种类型。
// height: 条码的高度,以毫米为单位。
// readable: 是否在条形码下方打印可读的文字标签。0 表示不打印,1 表示打印。
// narrow 和 wide: 条形码线条的宽度比例,范围为 1 - 10。
// content: 条形码所表示的内容。
let command = createNew()
command.setSize(x, y); // 设置页面大小
command.setGap(0); //传感器 command.setCls();
command.setCls(); //清除打印机缓存
list.map((item: any) => {
console.log(item);
switch (item.type) {
case 'qrcode':
console.log(item.value, 'value')
command.setQR(item.x, item.y, 'L', 7, 'A', item.value);
break;
case 'barcode':
console.log(item.value, 'barcode')
command.setBarCode(item.x, item.y, 'EAN8', 64, 1, 3, 3, item.value);
break;
default:
command.setText(item.x, item.y, 'TSS24.BF2', 1, 1, `${item.label}${item.value}`);
break;
}
})
console.log(command, 'canvasGetImageData');
setTimeout(() => {
uni.canvasGetImageData({
canvasId: 'edit_area_canvas',
x: 0,
y: 0,
width: canvasWidth,
height: canvasHeight,
success: function (res) {
command.setBitmap(60, 0, 1, res)
},
complete: function () {
command.setPagePrint()
state.isLabelSend = true;
prepareSend(command.getData())
}
})
}, 300);
}
//准备发送,根据每次发送字节数来处理分包数量
const prepareSend = (buff: any[]) => {
console.log(buff.length, 'buff.length');
let time = state.oneTimeData
let looptime = (Number(buff.length) / Number(time));
let lastData = (Number(buff.length) % Number(time));
console.log(looptime + "---" + lastData)
state.looptime = looptime + 1;
state.lastData = lastData;
state.currentTime = 1;
Send(buff)
}
//分包发送
const Send = (buff: any) => {
let {
currentTime,
looptime: loopTime,
lastData,
oneTimeData: onTimeData,
printerNum: printNum,
currentPrint } = state;
let buf;
let dataView;
if (currentTime < loopTime) {
buf = new ArrayBuffer(onTimeData)
dataView = new DataView(buf)
for (var i = 0; i < onTimeData; ++i) {
dataView.setUint8(i, buff[(currentTime - 1) * onTimeData + i])
}
} else {
buf = new ArrayBuffer(lastData)
dataView = new DataView(buf)
for (var i = 0; i < lastData; ++i) {
dataView.setUint8(i, buff[(currentTime - 1) * onTimeData + i])
}
}
console.log("第" + currentTime + "次发送数据大小为:" + buf.byteLength)
let BLEInformation = blueTooth.BLEInformation
plus.bluetooth.writeBLECharacteristicValue({
deviceId: BLEInformation.deviceId,
serviceId: BLEInformation.writeServiceId,
characteristicId: BLEInformation.writeCharaterId,
value: buf,
success: function (res) {
console.log(res)
},
fail: function (e) {
console.log(e)
},
complete: function () {
currentTime++
if (currentTime <= loopTime) {
state.currentTime = currentTime;
Send(buff)
} else {
uni.showToast({
title: '已打印第' + currentPrint + '张',
})
if (currentPrint == printNum) {
state.looptime = 0;
state.lastData = 0;
state.currentTime = 1;
state.isReceiptSend = false;
state.isLabelSend = false;
state.currentPrint = 1;
} else {
currentPrint++;
state.currentPrint = currentPrint;
state.currentTime = 1;
Send(buff)
}
}
}
})
}
defineExpose({
init
})
</script> </script>
<style lang = "scss" scoped> <style lang="scss" scoped>
.card { .card {
box-sizing: border-box; box-sizing: border-box;
margin: 16rpx; margin: 16rpx;
...@@ -57,9 +299,8 @@ const checkboxChange = (val: boolean) => { ...@@ -57,9 +299,8 @@ const checkboxChange = (val: boolean) => {
background-color: #ffffff; background-color: #ffffff;
overflow: hidden; overflow: hidden;
color: #303133; color: #303133;
transition: .3s; transition: 0.3s;
box-shadow: 0px 0px 12px rgba(0, 0, 0, .05); box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.05);
.box-list { .box-list {
display: flex; display: flex;
...@@ -80,7 +321,6 @@ const checkboxChange = (val: boolean) => { ...@@ -80,7 +321,6 @@ const checkboxChange = (val: boolean) => {
// } // }
// } // }
} }
} }
:deep(.u-checkbox__label) { :deep(.u-checkbox__label) {
......
export const data = {
"config": {
"size": "default",
"hideRequiredAsterisk": false,
"labelWidth": 100,
"labelPosition": "right",
"dbTableComment": "收料标签",
"dbTableName": "T_WMS_LableRule",
"formId": "WMS_LableRule",
"formTypes": "labelPrint",
"subSystem": "wms-system",
"microFrontEnd": false,
"supportSync": false,
"saveVisibility": "",
"savePlugin": "",
"pushVisibility": "",
"pushPlugin": "",
"printVisibility": "",
"printPlugin": "",
"dependencyForm": "WMS_Receive",
"x": 60,
"y": 42
},
"list": [
{
"label": "条码",
"type": "barcode",
"options": {
"defaultValue": "123456789",
"visibility": [
"list_visible",
"form_visible"
],
"x": "150",
"y": "25"
},
"key": "7a14224c207a47698fa0a8bd24a2a895",
"model": "FSerialId",
"rules": [],
"dbFieldName": "FSerialId",
"dbFieldComment": "条码",
"dbTableName": "T_WMS_LableRule"
},
{
"label": "栅格布局",
"type": "grid",
"columns": [
{
"span": 12,
"list": [
{
"label": "物料编码",
"type": "text",
"options": {
"defaultValue": "ZXCVBNM",
"visibility": [
"list_visible",
"form_visible"
],
"x": "20",
"y": "160"
},
"key": "ec2d553e50884d0ca10d0efb9b6c4593",
"model": "FMaterialId",
"rules": [],
"dbFieldName": "FMaterialId",
"dbFieldComment": "物料编码",
"dbTableName": "T_WMS_LableRule"
},
{
"label": "物料名称",
"type": "text",
"options": {
"defaultValue": "锂电池",
"visibility": [
"list_visible",
"form_visible"
],
"x": "20",
"y": "200"
},
"key": "1cd2df65b64d46dcbac6ae8f4316a730",
"model": "FMaterialName",
"rules": [],
"dbFieldName": "FMaterialName",
"dbFieldComment": "物料名称",
"dbTableName": "T_WMS_LableRule"
},
{
"label": "批号",
"type": "text",
"options": {
"defaultValue": "1008611",
"visibility": [
"list_visible",
"form_visible"
],
"x": "20",
"y": "240"
},
"key": "a0247174622b4935b36232232ef129c5",
"model": "FLot",
"rules": [],
"dbFieldName": "FLot",
"dbFieldComment": "批号",
"dbTableName": "T_WMS_LableRule"
},
{
"label": "数量",
"type": "text",
"options": {
"defaultValue": "10000",
"visibility": [
"list_visible",
"form_visible"
],
"x": "20",
"y": "280"
},
"key": "9dd73ddb99f3449f8be4cdadddc24fad",
"model": "FQty",
"rules": [],
"dbFieldName": "FQty",
"dbFieldComment": "数量",
"dbTableName": "T_WMS_LableRule"
}
]
},
{
"span": 12,
"list": [
{
"label": "二维码",
"type": "qrcode",
"options": {
"defaultValue": "ZXCVBNM,,,,123456",
"visibility": [
"list_visible",
"form_visible"
],
"x": "340",
"y": "160"
},
"key": "3d2c4d94491c4f269b93064f7362125b",
"model": "FDimensionalCode",
"rules": [],
"dbFieldName": "FDimensionalCode",
"dbFieldComment": "二维码",
"dbTableName": "T_WMS_LableRule"
}
]
}
],
"options": {
"gutter": 0,
"justify": "start",
"align": "top"
},
"key": "dae5e3e88230400d8d253b04239cb4ca",
"model": "grid_dae5e3e88230400d8d253b04239cb4ca",
"rules": [],
"dbTableName": "T_WMS_LableRule"
}
]
}
\ No newline at end of file
<template> <template>
<vk-header :title="title" back-icon-name="nav-back" /> <vk-header :title="title" back-icon-name="nav-back" />
<form-list-item :business-list="businessList" /> <form-list-item ref="formListRef" :business-list="businessList" />
</template> </template>
<script setup lang='ts'> <script setup lang='ts'>
...@@ -15,12 +15,14 @@ import FormListItem from './component/FormListItem.vue'; ...@@ -15,12 +15,14 @@ import FormListItem from './component/FormListItem.vue';
const title = ref('') const title = ref('')
const store = useFormData() const store = useFormData()
const pageData = ref() const pageData = ref()
const formListRef = ref()
const businessList = ref([] as any[]) const businessList = ref([] as any[])
onLoad(async () => { onLoad(async () => {
const { subSystem, permTag: formId } = JSON.parse(uni.getStorageSync('pageData')) const { subSystem, permTag: formId } = JSON.parse(uni.getStorageSync('pageData'))
const { data: res } = await getBusinessList({ formId, subSystem, mobile: true }) const { data: res } = await getBusinessList({ formId, subSystem, mobile: true })
sLoading() sLoading()
formListRef.value.init()
if (res.code === 200) handleLoadData(res.data) if (res.code === 200) handleLoadData(res.data)
}) })
......
...@@ -3,17 +3,9 @@ ...@@ -3,17 +3,9 @@
<view class="card" v-show="res.children?.length"> <view class="card" v-show="res.children?.length">
<h3 class="card-text">{{ res.title }}</h3> <h3 class="card-text">{{ res.title }}</h3>
<u-grid :col="4" :border="false"> <u-grid :col="4" :border="false">
<u-grid-item <u-grid-item v-for="item in res.children" :custom-style="{ 'text-align': 'center' }"
v-for="item in res.children" @tap="tapGridItem(item)">
:custom-style="{ 'text-align': 'center' }" <u-icon :name="item.icon" custom-prefix="custom-icon" size="44" :color="item.iconStyle" />
@tap="tapGridItem(item)"
>
<u-icon
:name="item.icon"
custom-prefix="custom-icon"
size="44"
:color="item.iconStyle"
/>
<view class="grid-text">{{ item.title }}</view> <view class="grid-text">{{ item.title }}</view>
</u-grid-item> </u-grid-item>
</u-grid> </u-grid>
...@@ -27,11 +19,9 @@ import { getMenuTree } from '@/api/apply'; ...@@ -27,11 +19,9 @@ import { getMenuTree } from '@/api/apply';
const menuList = ref(); const menuList = ref();
const tapGridItem = (row: any) => { const tapGridItem = (row: any) => {
uni.navigateTo({
url: '/pages/apply/formDetail',
success() {
uni.setStorageSync('pageData', JSON.stringify(row)); uni.setStorageSync('pageData', JSON.stringify(row));
}, uni.navigateTo({
url: '/pages/apply/formDetail'
}); });
}; };
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<view style="margin: 40rpx 0;"></view> <view style="margin: 40rpx 0;"></view>
<u-button type="error" @tap="stopSearch">停止搜索</u-button> <u-button type="error" @tap="stopSearch">停止搜索</u-button>
<view style="margin: 40rpx 0;"></view> <view style="margin: 40rpx 0;"></view>
<u-button type="warning" @tap="openControl">跳转页面</u-button> <u-button type="warning" @tap="navigateTo">跳转页面</u-button>
<view v-for="item in list" :data-title="item.deviceId" :data-name="item.name" <view v-for="item in list" :data-title="item.deviceId" :data-name="item.name"
:data-advertisData="item.advertisServiceUUIDs" :key="item.deviceId" @tap="bindViewTap"> :data-advertisData="item.advertisServiceUUIDs" :key="item.deviceId" @tap="bindViewTap">
...@@ -56,6 +56,12 @@ const errorCodeTip = (code: number) => { ...@@ -56,6 +56,12 @@ const errorCodeTip = (code: number) => {
} }
} }
const navigateTo = () => {
uni.navigateTo({
url: '/pages/blueTooth/printTest'
})
}
const stopSearch = () => { const stopSearch = () => {
uni.stopBluetoothDevicesDiscovery({ uni.stopBluetoothDevicesDiscovery({
success: (res: any) => { success: (res: any) => {
...@@ -161,15 +167,11 @@ const bindViewTap = (e: any) => { ...@@ -161,15 +167,11 @@ const bindViewTap = (e: any) => {
deviceId: title, deviceId: title,
success(res: any) { success(res: any) {
console.log('createBLEConnection success:', res); console.log('createBLEConnection success:', res);
console.log('before', BLEInformation.deviceId);
BLEInformation.deviceId = title; BLEInformation.deviceId = title;
console.log('before', BLEInformation.deviceId);
blueTooth.$patch({ blueTooth.$patch({
BLEInformation BLEInformation
}) })
uni.hideLoading() uni.hideLoading()
console.log('纳尼');
('纳尼')
setTimeout(() => { setTimeout(() => {
getSeviceId(); getSeviceId();
}); });
...@@ -228,7 +230,6 @@ const getCharacteristics = async () => { ...@@ -228,7 +230,6 @@ const getCharacteristics = async () => {
BLEInformation: blueTooth.BLEInformation BLEInformation: blueTooth.BLEInformation
}) })
notifyCharacter.value = true; notifyCharacter.value = true;
console.log('notify');
} }
if (!writeCharacter.value && properties.write) { if (!writeCharacter.value && properties.write) {
blueTooth.BLEInformation.writeCharaterId = uuid; blueTooth.BLEInformation.writeCharaterId = uuid;
...@@ -237,7 +238,6 @@ const getCharacteristics = async () => { ...@@ -237,7 +238,6 @@ const getCharacteristics = async () => {
BLEInformation: blueTooth.BLEInformation BLEInformation: blueTooth.BLEInformation
}) })
writeCharacter.value = true; writeCharacter.value = true;
console.log('write');
} }
if (!readCharacter.value && properties.read) { if (!readCharacter.value && properties.read) {
blueTooth.BLEInformation.readCharaterId = uuid; blueTooth.BLEInformation.readCharaterId = uuid;
...@@ -246,7 +246,6 @@ const getCharacteristics = async () => { ...@@ -246,7 +246,6 @@ const getCharacteristics = async () => {
BLEInformation: blueTooth.BLEInformation BLEInformation: blueTooth.BLEInformation
}) })
readCharacter.value = true; readCharacter.value = true;
console.log('read');
} }
} }
...@@ -268,9 +267,7 @@ const getCharacteristics = async () => { ...@@ -268,9 +267,7 @@ const getCharacteristics = async () => {
} }
const openControl = () => { const openControl = () => {
console.log('成功跳转'); console.log('成功跳转');
uni.navigateTo({ uni.navigateBack({ delta: 1 })
url: '/pages/blueTooth/printTest'
})
} }
</script> </script>
......
<template> <template>
<div class='app-container'></div>
</template>
<script setup lang='ts'>
import { ref } from 'vue'
</script>
<style lang = "scss" scoped>
</style>
<!-- <template>
<view class="content"> <view class="content">
<view class="body"> <view class="body">
<view> <view>
...@@ -11,7 +22,8 @@ ...@@ -11,7 +22,8 @@
标签测试 标签测试
</u-button> </u-button>
</view> </view>
<u-button type="warning" @tap="front">向前拉动</u-button>
<u-button type="warning" @tap="after">向后拉动</u-button>
<picker style='margin:20px' mode='selector' :range='state.buffSize' :value='state.buffIndex' <picker style='margin:20px' mode='selector' :range='state.buffSize' :value='state.buffIndex'
@change='buffBindChange'> @change='buffBindChange'>
当前每次发送字节数为(点击可更换):{{ state.buffSize[state.buffIndex] }} 当前每次发送字节数为(点击可更换):{{ state.buffSize[state.buffIndex] }}
...@@ -93,7 +105,15 @@ const state: any = reactive({ ...@@ -93,7 +105,15 @@ const state: any = reactive({
}) })
const blueTooth = useBlueTooth() const blueTooth = useBlueTooth()
const front = () => {
let command = createNew()
command.setFeed(1)
}
const after = () => {
let command = createNew()
command.setBackFeed(1)
}
const inputEvent = (e: any) => state.sendContent = e.detail.value; const inputEvent = (e: any) => state.sendContent = e.detail.value;
const labelTest = () => { const labelTest = () => {
let canvasWidth = state.canvasWidth let canvasWidth = state.canvasWidth
...@@ -302,4 +322,4 @@ input { ...@@ -302,4 +322,4 @@ input {
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
</style> </style> -->
\ No newline at end of file \ No newline at end of file
...@@ -3,52 +3,51 @@ ...@@ -3,52 +3,51 @@
</template> </template>
<script> <script>
import scaninput from './scanInput.js'; import scaninput from './scanInput.js'
scaninput.initScan(); scaninput.initScan()
scaninput.startScan(); scaninput.startScan()
export default { export default {
name: 'scan-listener', name: "scan-listener",
created() { created() {
scaninput.install(this.scanHandle); scaninput.install(this.scanHandle)
// uni.$on('scan_handle', this.scanHandle) // uni.$on('scan_handle', this.scanHandle)
}, },
beforeDestroy() { beforeDestroy() {
scaninput.uninstall(this.scanHandle); scaninput.uninstall(this.scanHandle)
}, },
methods: { methods: {
onEvent(event) { onEvent(event) {
// console.log(event.key) // console.log(event.key)
if (event.key != 'Enter' && event.key != 'PrintScreen') { if (event.key != 'Enter' && event.key != 'PrintScreen') { // 拼接输入的值,Enter与PrintScreen是物理按钮要排除
// 拼接输入的值,Enter与PrintScreen是物理按钮要排除 this.inputVal = this.inputVal + event.key
this.inputVal = this.inputVal + event.key;
} }
if (event.key == 'Enter') { if (event.key == 'Enter') {
let reg = new RegExp('Shift', 'g'); //g代表全部 let reg = new RegExp('Shift', 'g') //g代表全部
let reg2 = new RegExp('Unidentified', 'g'); //排除‘Unidentified’字符 let reg2 = new RegExp('Unidentified', 'g') //排除‘Unidentified’字符
let inputVal = this.inputVal; let inputVal = this.inputVal
inputVal = inputVal.replace(reg, ''); inputVal = inputVal.replace(reg, "")
inputVal = inputVal.replace(reg2, ''); inputVal = inputVal.replace(reg2, "")
inputVal = inputVal.replace(/\s/g, ''); inputVal = inputVal.replace(/\s/g, "")
inputVal = inputVal.replace(/\r\n/g, ''); inputVal = inputVal.replace(/\r\n/g, "")
inputVal = inputVal.replace(/\n/g, ''); inputVal = inputVal.replace(/\n/g, "")
if (this.inputVal) { if (this.inputVal) {
// console.log('键盘监听模式') // console.log('键盘监听模式')
this.$emit('scan', this.inputVal); this.$emit('scan', this.inputVal.replace(/Unidentified/g, "").replace(/Shift/g, ""))
} }
this.inputVal = ''; this.inputVal = ''
} }
}, },
scanHandle(code) { scanHandle(code) {
// console.log('广播模式') // console.log('广播模式')
this.$emit('scan', code); this.$emit('scan', code)
}, }
}, },
data() { data() {
return { return {
inputVal: '', inputVal: '',
}; };
}, }
}; }
</script> </script>
<script module="keyboard" lang="renderjs"> <script module="keyboard" lang="renderjs">
export default { export default {
...@@ -74,4 +73,5 @@ export default { ...@@ -74,4 +73,5 @@ export default {
} }
</script> </script>
<style></style> <style>
</style>
\ No newline at end of file
let main, receiver, filter, _codeQueryTag = false, let main, receiver, filter, _codeQueryTag = false, temp = [], init = false, start = false;
temp = [],
init = false,
start = false;
export default { export default {
initScan() { initScan() {
if (init) return if(init) return
let _this = this; let _this = this;
main = plus.android.runtimeMainActivity(); //获取activity main = plus.android.runtimeMainActivity(); //获取activity
var IntentFilter = plus.android.importClass('android.content.IntentFilter'); var IntentFilter = plus.android.importClass('android.content.IntentFilter');
...@@ -15,32 +12,31 @@ export default { ...@@ -15,32 +12,31 @@ export default {
onReceive: function(context, intent) { onReceive: function(context, intent) {
//barcode_string //barcode_string
plus.android.importClass(intent); plus.android.importClass(intent);
let code = intent.getStringExtra(uni._qs_scanlistener_label || let code = intent.getStringExtra(uni._qs_scanlistener_label || "barcode_string"); // 换你的广播标签,你的pda设备里面看
"barcode_string"); // 换你的广播标签,你的pda设备里面看
_this.queryCode(code); _this.queryCode(code);
} }
}); });
init = true init = true
}, },
startScan() { startScan() {
if (!start) { if(!start) {
start = true start = true
main.registerReceiver(receiver, filter); main.registerReceiver(receiver, filter);
} }
}, },
stopScan() { stopScan() {
if (start) { if(start) {
start = false start = false
main.unregisterReceiver(receiver); main.unregisterReceiver(receiver);
} }
}, },
install(fn) { install(fn) {
if (typeof fn == 'function' && !~temp.indexOf(fn)) temp.push(fn) if(typeof fn == 'function' && !~temp.indexOf(fn)) temp.push(fn)
}, },
uninstall(fn) { uninstall(fn) {
if (typeof fn == 'function') { if(typeof fn == 'function') {
const index = temp.find(i => i == fn) const index = temp.find(i=>i == fn)
if (~index) temp.splice(index, 1) if(~index) temp.splice(index, 1)
} }
}, },
queryCode: function(code) { queryCode: function(code) {
...@@ -50,7 +46,7 @@ export default { ...@@ -50,7 +46,7 @@ export default {
// setTimeout(function() { // setTimeout(function() {
// _codeQueryTag = false; // _codeQueryTag = false;
// }, 150); // }, 150);
if (temp && temp.length) { if(temp && temp.length) {
temp[temp.length - 1](code) temp[temp.length - 1](code)
} }
uni.vibrateShort() uni.vibrateShort()
......
...@@ -8,7 +8,7 @@ export const createNew = () => { ...@@ -8,7 +8,7 @@ export const createNew = () => {
jpPrinter.name = '蓝牙打印机' jpPrinter.name = '蓝牙打印机'
jpPrinter.init = function () { } jpPrinter.init = function () { }
jpPrinter.
jpPrinter.addCommand = function (content: any) { jpPrinter.addCommand = function (content: any) {
//将指令转成数组装起 //将指令转成数组装起
var code = new TextEncoder('gb18030', { var code = new TextEncoder('gb18030', {
......
...@@ -2,15 +2,15 @@ const CONFIG: any = { ...@@ -2,15 +2,15 @@ const CONFIG: any = {
// 开发环境配置 // 开发环境配置
development: { development: {
assetsPath: 'http://192.168.60:81', // 静态资源路径 assetsPath: 'http://192.168.60:81', // 静态资源路径
baseUrl: 'http://192.168.0.38:8089', // 后台接口请求地址 baseUrl: 'http://192.168.0.46', // 后台接口请求地址
// baseUrl: 'http://192.168.0.60:81', // 后台接口请求地址 // baseUrl: 'http://192.168.0.8', // 后台接口请求地址
hostUrl: 'http://192.168.0.60:81', // H5地址(前端运行地址) hostUrl: 'http://192.168.0.60:81', // H5地址(前端运行地址)
websocketUrl: '', // websocket服务端地址 websocketUrl: '', // websocket服务端地址
}, },
// 生产环境配置 // 生产环境配置
production: { production: {
assetsPath: '', // 静态资源路径 assetsPath: '', // 静态资源路径
baseUrl: 'http://192.168.0.38:8089', // 后台接口请求地址 baseUrl: '', // 后台接口请求地址
// baseUrl: 'https://api.test.siccat.com/api/graphql', // baseUrl: 'https://api.test.siccat.com/api/graphql',
hostUrl: '', // H5地址(前端运行地址) hostUrl: '', // H5地址(前端运行地址)
websocketUrl: '', // websocket服务端地址 websocketUrl: '', // websocket服务端地址
......
// import { reactive } from "vue";
// import { createNew } from './ble/tsc'
// let blueTooth: any;
// const state: any = reactive({
// looptime: 0,
// currentTime: 1,
// lastData: 0,
// oneTimeData: 0,
// canvasWidth: 1050,
// canvasHeight: 750,
// buffSize: [],
// printNum: [],
// printerNum: 1,
// currentPrint: 1,
// isReceiptSend: false,
// isLabelSend: false
// })
// export const init = () => {
// let list = [] as any[]
// let numList = []
// let j = 0
// for (let i = 20; i < 200; i += 10) {
// list[j] = i;
// j++
// }
// for (let i = 1; i < 10; i++) {
// numList[i - 1] = i
// }
// state.buffSize = list;
// state.oneTimeData = list[0];
// state.printNum = numList;
// state.printerNum = numList[0];
// }
// export const labelTest = (tooth: any, printData?: any) => {
// blueTooth = tooth
// let canvasWidth = state.canvasWidth
// let canvasHeight = state.canvasHeight
// let { qrcode, barcode, fields } = printData
// // x 和 y: 文字的起始位置坐标,以毫米为单位。
// // font: 字体类型,可以是预装载的或者外部下载的字体。
// // x_ 和 y_: 水平和垂直缩放比例,范围为 0 - 10,可调整字体大小。
// // str: 要打印的文字内容。
// // codetype: 条形码类型,支持 CODE128、CODE39、CODE93 等多种类型。
// // height: 条码的高度,以毫米为单位。
// // readable: 是否在条形码下方打印可读的文字标签。0 表示不打印,1 表示打印。
// // narrow 和 wide: 条形码线条的宽度比例,范围为 1 - 10。
// // content: 条形码所表示的内容。
// let command = createNew()
// command.setSize(70, 52); // 设置页面大小
// command.setGap(0); //传感器 command.setCls(); //清除打印机缓存
// // command.setText(40, 50, 'TSS24.BF2', 1, 1, 'WMS编码号');
// // command.setBarCode(200, 40, 'EAN8', 64, 1, 3, 3, '1234567');
// // command.setText(40, 100, 'TSS24.BF2', 1, 1, '佳博智汇');
// // command.setText(40, 140, 'TSS24.BF2', 1, 1, 'h测试数字12345678');
// // command.setText(40, 180, 'TSS24.BF2', 1, 1, 'g测试数字12345678');
// // command.setText(40, 220, 'TSS24.BF2', 1, 1, 'f测试数字12345678');
// // command.setText(40, 260, 'TSS24.BF2', 1, 1, 'e测试数字12345678');
// // command.setText(40, 300, 'TSS24.BF2', 1, 1, 'd测试数字12345678');
// // command.setText(40, 340, 'TSS24.BF2', 1, 1, 'c测试数字12345678');
// // command.setText(40, 380, 'TSS24.BF2', 1, 1, 'b测试数字12345678');
// // command.setQR(300, 180, 'L', 8, 'A', 'www.smarnet.cc佳博智汇');
// command.setText(40, 50, 'TSS24.BF2', 1, 1, 'WMS编码号');
// command.setBarCode(200, 40, 'EAN8', 64, 1, 3, 3, barcode);
// let num = 60
// for (const k in fields) {
// command.setText(40, num + 40, 'TSS24.BF2', 1, 1, JSON.stringify(fields[k]));
// }
// command.setQR(300, 180, 'L', 6, 'A', JSON.stringify(qrcode));
// setTimeout(() => {
// uni.canvasGetImageData({
// canvasId: 'edit_area_canvas',
// x: 0,
// y: 0,
// width: canvasWidth,
// height: canvasHeight,
// success: function (res) {
// command.setBitmap(60, 0, 1, res)
// },
// complete: function () {
// command.setPagePrint()
// state.isLabelSend = true;
// prepareSend(command.getData())
// }
// })
// }, 300);
// }
// //准备发送,根据每次发送字节数来处理分包数量
// const prepareSend = (buff: any[]) => {
// console.log(buff.length, 'buff.length');
// let time = state.oneTimeData
// let looptime = (Number(buff.length) / Number(time));
// let lastData = (Number(buff.length) % Number(time));
// console.log(looptime + "---" + lastData)
// state.looptime = looptime + 1;
// state.lastData = lastData;
// state.currentTime = 1;
// Send(buff)
// }
// //分包发送
// const Send = (buff: any) => {
// let {
// currentTime,
// looptime: loopTime,
// lastData,
// oneTimeData: onTimeData,
// printerNum: printNum,
// currentPrint } = state;
// let buf;
// let dataView;
// if (currentTime < loopTime) {
// buf = new ArrayBuffer(onTimeData)
// dataView = new DataView(buf)
// for (var i = 0; i < onTimeData; ++i) {
// dataView.setUint8(i, buff[(currentTime - 1) * onTimeData + i])
// }
// } else {
// buf = new ArrayBuffer(lastData)
// dataView = new DataView(buf)
// for (var i = 0; i < lastData; ++i) {
// dataView.setUint8(i, buff[(currentTime - 1) * onTimeData + i])
// }
// }
// console.log("第" + currentTime + "次发送数据大小为:" + buf.byteLength)
// let BLEInformation = blueTooth.BLEInformation
// plus.bluetooth.writeBLECharacteristicValue({
// deviceId: BLEInformation.deviceId,
// serviceId: BLEInformation.writeServiceId,
// characteristicId: BLEInformation.writeCharaterId,
// value: buf,
// success: function (res) {
// console.log(res)
// },
// fail: function (e) {
// console.log(e)
// },
// complete: function () {
// currentTime++
// if (currentTime <= loopTime) {
// state.currentTime = currentTime;
// Send(buff)
// } else {
// uni.showToast({
// title: '已打印第' + currentPrint + '张',
// })
// if (currentPrint == printNum) {
// state.looptime = 0;
// state.lastData = 0;
// state.currentTime = 1;
// state.isReceiptSend = false;
// state.isLabelSend = false;
// state.currentPrint = 1;
// } else {
// currentPrint++;
// state.currentPrint = currentPrint;
// state.currentTime = 1;
// Send(buff)
// }
// }
// }
// })
// }
\ No newline at end of file
...@@ -41,3 +41,21 @@ export const sLoading = (msg: string = '加载中...') => { ...@@ -41,3 +41,21 @@ export const sLoading = (msg: string = '加载中...') => {
export const hLoading = () => { export const hLoading = () => {
uni.hideLoading() uni.hideLoading()
} }
// 防抖
interface DebounceFunc<T extends (...args: any[]) => any> {
(this: ThisParameterType<T>, ...args: Parameters<T>): ReturnType<T>;
}
export function debounce<T extends (...args: any[]) => any>(
fn: T,
delay = 300,
): DebounceFunc<T> {
let timer: number | null;
return function (this: ThisParameterType<T>, ...args: Parameters<T>) {
if (timer) clearTimeout(timer);
timer = setTimeout(() => {
fn.call(this, ...args);
}, delay);
} as DebounceFunc<T>;
}
\ No newline at end of file
import { defineConfig } from 'vite' import { defineConfig } from 'vite';
// import pxtovw from 'postcss-px-to-viewport' // import pxtovw from 'postcss-px-to-viewport'
import { resolve } from 'path' import { resolve } from 'path';
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons' import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
import uni from '@dcloudio/vite-plugin-uni' import uni from '@dcloudio/vite-plugin-uni';
export default defineConfig({ export default defineConfig({
plugins: [ plugins: [
...@@ -44,10 +44,14 @@ export default defineConfig({ ...@@ -44,10 +44,14 @@ export default defineConfig({
strictPort: false, // 端口被占用直接退出 strictPort: false, // 端口被占用直接退出
https: false, // 默认用http方式 https: false, // 默认用http方式
proxy: { proxy: {
'/LowCodePlatform': { '/lowcodeplatform-system': {
target: 'http://192.168.0.38:8089', target: 'http://192.168.0.46',
// target: 'http://192.168.0.8',
},
'/wms-system': {
target: 'http://192.168.0.46',
// target: 'http://192.168.0.8',
}, },
}, },
}, },
}) });
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论