From cfa236b5b63c351ed0f846cbc511fa64d88f4993 Mon Sep 17 00:00:00 2001
From: chenhaozhe <cgz@hz-kingdee.com>
Date: 星期五, 01 八月 2025 07:53:08 +0800
Subject: [PATCH] Merge branch 'Dev' of http://101.37.171.70:10101/r/~jhz/STUWMS into Dev
---
utils/common.js | 440 +++++++-------
pages/index/login.vue | 61 +
pages/tiaomadaying/tiaomadaying.vue | 1279 +++++++++++++++++++++--------------------
3 files changed, 905 insertions(+), 875 deletions(-)
diff --git a/pages/index/login.vue b/pages/index/login.vue
index db495cd..0b9c90f 100644
--- a/pages/index/login.vue
+++ b/pages/index/login.vue
@@ -63,29 +63,33 @@
</view>
</uni-popup-dialog>
</uni-popup>
-
+
<view class="btn" @tap="submit">鐧� 褰�</view>
<!-- <view class="btn apibtn" @tap="changeApi=true">鏈嶅姟鍣ㄨ缃�</view> -->
<view class="btn apibtn" @click="openServerSettingHandler">鏈嶅姟鍣ㄨ缃�</view>
</view>
</view>
</template>
-
+
<script>
import {
setLoginData,
setUserInfo
} from "@/utils/auth.js";
import hFormAlert from '@/components/h-form-alert/h-form-alert.vue';
+ import {
+ CommonUtils
+ } from "../../utils/common";
export default {
components: {
hFormAlert
},
data() {
return {
+ CommonUtils,
arrayDataBases: [],
DataBases: '',
-
+
arrayServerOrganization: ["娴欐睙鏅轰簯杩堟��", "娓╁窞娴疯瘹"],
arrayServerOrganizationValues: [
'http://47.96.97.237/API/',
@@ -95,7 +99,7 @@
arrayOrganization: [],
Organization: '',
HOrgNameList: [],
-
+
HOrgName: '',
UserName: '', //admin 001
PassWord: '', //123456
@@ -104,7 +108,7 @@
serverUrlCache: '',
}
},
- onLoad() {
+ onShow() {
var logindata = uni.getStorageSync('loginData') || ''
// console.log(logindata)
if (logindata) {
@@ -114,9 +118,9 @@
this.UserName = logindata.UserName
this.PassWord = logindata.PassWord
}
-
+
this.serverUrlCache = this.serverUrl
- console.log('this.serverUrlCache: ',this.serverUrlCache);
+ console.log('this.serverUrlCache: ', this.serverUrlCache);
let index = this.arrayServerOrganizationValues.findIndex((e) => {
return e == this.serverUrlCache
})
@@ -133,11 +137,11 @@
await this.$nextTick(() => {
this.Organization = this.arrayOrganization[0]
this.HOrgName = this.HOrgNameList[0]
-
+
let org = uni.getStorageSync('Organization')
let orgName = uni.getStorageSync('OrganizationID')
let orgHas = Array.from(this.arrayOrganization).findIndex((e) => e == org)
- if(org && (orgHas != -1)) {
+ if (org && (orgHas != -1)) {
this.Organization = org
this.HOrgName = orgName
}
@@ -185,7 +189,7 @@
this.DataBases = this.arrayDataBases[e.detail.value]
uni.setStorageSync('DataBases', this.DataBases);
},
-
+
getOrganization() {
uni.request({
url: this.serverUrl + '/Web/GetOrganizations',
@@ -268,7 +272,8 @@
uni.setStorageSync('login', "login");
uni.setStorageSync('Organization', this.Organization);
uni.setStorageSync('OrganizationID', this.HOrgName);
-
+ console.log('this.serverUrl: ', this.serverUrl);
+ this.CommonUtils.setServerUrl(this.serverUrl)
uni.reLaunch({
url: '/pages/index/index'
})
@@ -288,7 +293,7 @@
}
}
</script>
-
+
<style lang="scss" scoped>
.bg-img {
position: fixed;
@@ -298,7 +303,7 @@
left: 0;
z-index: -1;
}
-
+
.container {
width: 100%;
height: 100%;
@@ -306,21 +311,21 @@
flex-direction: column;
align-items: center;
justify-content: center;
-
+
.title {
margin-top: 174rpx;
font-size: 47rpx;
font-weight: bold;
color: #FFFFFF;
}
-
+
.box {
width: 682rpx;
position: relative;
top: 120rpx;
display: flex;
justify-content: center;
-
+
.logo {
width: 155rpx;
height: 155rpx;
@@ -329,7 +334,7 @@
z-index: 9;
background-color: rgba(255, 255, 255, 0.5);
border-radius: 100%;
-
+
image {
width: 100%;
height: 100%;
@@ -337,7 +342,7 @@
background-color: #f0f3f7;
}
}
-
+
.login {
width: 100%;
height: 480rpx;
@@ -348,26 +353,26 @@
border-radius: 25rpx 0 25rpx 0;
box-shadow: 0 6rpx 24rpx 8rpx rgba(21, 99, 210, 0.14);
padding-top: 160rpx;
-
+
.item {
display: flex;
align-items: center;
justify-content: flex-end;
margin-right: 38rpx;
margin-bottom: 70rpx;
-
+
.left {
font-size: 34rpx;
font-weight: 400;
color: #3C3C3C;
}
-
+
.right {
width: 441rpx;
height: 68rpx;
background: #EBEBEB;
border-radius: 10rpx;
-
+
input {
height: 100%;
padding: 0 30rpx;
@@ -375,7 +380,7 @@
}
}
}
-
+
// .api{
// margin-left: 30rpx;
// font-size: 27rpx;
@@ -391,7 +396,7 @@
// }
}
}
-
+
.btn {
width: 540rpx;
height: 92rpx;
@@ -405,26 +410,26 @@
text-align: center;
font-size: 36rpx;
}
-
+
.apibtn {
margin-top: 50rpx;
background: #eec18e;
box-shadow: 0rpx 0rpx 44rpx 7rpx rgba(253, 186, 118, 0.3);
}
}
-
+
.popup-content {
box-sizing: border-box;
display: flex;
flex-direction: column;
gap: 30rpx;
-
+
.pop-item {
border: #EBEBEB 2rpx solid;
border-radius: 10rpx;
padding: 14rpx 8rpx;
}
-
+
>picker {
background-color: #EBEBEB;
}
diff --git a/pages/tiaomadaying/tiaomadaying.vue b/pages/tiaomadaying/tiaomadaying.vue
index d0858f9..98775da 100644
--- a/pages/tiaomadaying/tiaomadaying.vue
+++ b/pages/tiaomadaying/tiaomadaying.vue
@@ -1,680 +1,701 @@
<template>
- <view class="container">
- <view class="content">
- <view class="header">鍩烘湰淇℃伅</view>
- <view class="items">
- <view class="item">
- <view class="left">鏉$爜缂栧彿锛�</view>
- <view class="right barcode">
- <input :focus="HBarCodeFocus" name="HBarCode" v-model="lailiaoInfo.barCodeNo"
- @focus="lailiaoInfo.barCodeNo = ''" @confirm="barCodeEntryHandler(lailiaoInfo.barCodeNo)"
- placeholder="璇锋壂鎻忓晢鍝佹潯鐮�" />
- </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 name="HBillNo" disabled v-model="lailiaoInfo.HBillNo" />
- </view>
- </view>
- <view class="item">
- <view class="left">婧愬崟琛屽彿锛�</view>
- <view class="right">
- <input name="HBillLineNo" disabled v-model="lailiaoInfo.HBillLineNo" />
- </view>
- </view>
- <view class="item">
- <view class="left">鐗╂枡缂栫爜锛�</view>
- <view class="right">
- <input name="HMaterNo" disabled v-model="lailiaoInfo.HMaterNumber" />
- </view>
- </view>
- <view class="item">
- <view class="left">鐗╂枡鍚嶇О锛�</view>
- <view class="right">
- <input name="HMaterName" disabled v-model="lailiaoInfo.HMaterName" />
- </view>
- </view>
- <view class="item">
- <view class="left">瑙勬牸鍨嬪彿锛�</view>
- <view class="right">
- <input name="HMaterType" disabled v-model="lailiaoInfo.HMaterModel" />
- </view>
- </view>
- <view class="item">
- <view class="left">鎵规锛�</view>
- <view class="right">
- <input name="HBatchNo" disabled v-model="lailiaoInfo.HBatchNo" />
- </view>
- </view>
- <view class="item">
- <view class="left">鏁伴噺锛�</view>
- <view class="right">
- <input name="HQty" disabled v-model="lailiaoInfo.HQty" />
- </view>
- </view>
- <view class="item">
- <view class="left">MTO鍙凤細</view>
- <view class="right">
- <input name="HMTONo" disabled v-model="lailiaoInfo.HMTONo" />
- </view>
- </view>
- <view class="item">
- <view class="left">渚涘簲鍟嗭細</view>
- <view class="right">
- <input name="HSupName" disabled v-model="lailiaoInfo.HSupName" />
- </view>
- </view>
- <view class="item">
- <view class="left">渚涘簲鍟嗙畝绉帮細</view>
- <view class="right">
- <input name="HSupNameShort" disabled v-model="lailiaoInfo.HSupNameShort" />
- </view>
- </view>
- </view>
- </view>
- <view class="operation-zone">
- <button class="btn-c" @click="GenereateBarCode">鐢熸垚</button>
- <button class="btn-c" :disabled="buttonStatus.btn2 == false" @click="print">鎵撳嵃</button>
- <view></view>
- <button class="btn-c" @click="setClearLailiaoInfo">鏂板</button>
- <button class="btn-c" @click="exit">閫�鍑�</button>
- </view>
- <labelPrinterComponentVue ref="labelPrinter" :printInfo="printInfo" :printMode="'cpcl'">
- </labelPrinterComponentVue>
- </view>
+ <view class="container">
+ <view class="content">
+ <view class="header">鍩烘湰淇℃伅</view>
+ <view class="items">
+ <view class="item">
+ <view class="left">鏉$爜缂栧彿锛�</view>
+ <view class="right barcode">
+ <input :focus="HBarCodeFocus" name="HBarCode" v-model="lailiaoInfo.barCodeNo"
+ @focus="lailiaoInfo.barCodeNo = ''" @confirm="barCodeEntryHandler(lailiaoInfo.barCodeNo)"
+ placeholder="璇锋壂鎻忓晢鍝佹潯鐮�" />
+ </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 name="HBillNo" disabled v-model="lailiaoInfo.HBillNo" />
+ </view>
+ </view>
+ <view class="item">
+ <view class="left">婧愬崟琛屽彿锛�</view>
+ <view class="right">
+ <input name="HBillLineNo" disabled v-model="lailiaoInfo.HBillLineNo" />
+ </view>
+ </view>
+ <view class="item">
+ <view class="left">鐗╂枡缂栫爜锛�</view>
+ <view class="right">
+ <input name="HMaterNo" disabled v-model="lailiaoInfo.HMaterNumber" />
+ </view>
+ </view>
+ <view class="item">
+ <view class="left">鐗╂枡鍚嶇О锛�</view>
+ <view class="right">
+ <input name="HMaterName" disabled v-model="lailiaoInfo.HMaterName" />
+ </view>
+ </view>
+ <view class="item">
+ <view class="left">瑙勬牸鍨嬪彿锛�</view>
+ <view class="right">
+ <input name="HMaterType" disabled v-model="lailiaoInfo.HMaterModel" />
+ </view>
+ </view>
+ <view class="item">
+ <view class="left">鎵规锛�</view>
+ <view class="right">
+ <input name="HBatchNo" disabled v-model="lailiaoInfo.HBatchNo" />
+ </view>
+ </view>
+ <view class="item">
+ <view class="left">鏁伴噺锛�</view>
+ <view class="right">
+ <input name="HQty" disabled v-model="lailiaoInfo.HQty" />
+ </view>
+ </view>
+ <view class="item">
+ <view class="left">MTO鍙凤細</view>
+ <view class="right">
+ <input name="HMTONo" disabled v-model="lailiaoInfo.HMTONo" />
+ </view>
+ </view>
+ <view class="item">
+ <view class="left">渚涘簲鍟嗭細</view>
+ <view class="right">
+ <input name="HSupName" disabled v-model="lailiaoInfo.HSupName" />
+ </view>
+ </view>
+ <view class="item">
+ <view class="left">渚涘簲鍟嗙畝绉帮細</view>
+ <view class="right">
+ <input name="HSupNameShort" disabled v-model="lailiaoInfo.HSupNameShort" />
+ </view>
+ </view>
+ </view>
+ </view>
+ <view class="operation-zone">
+ <button class="btn-c" :disabled="buttonStatus.btn1" @click="GenereateBarCode">鐢熸垚</button>
+ <button class="btn-c" :disabled="buttonStatus.btn2" @click="print">鎵撳嵃</button>
+ <view></view>
+ <button class="btn-c" @click="setClearLailiaoInfo">鏂板</button>
+ <button class="btn-c" @click="exit">閫�鍑�</button>
+ </view>
+ <labelPrinterComponentVue ref="labelPrinter" :printInfo="printInfo" :printMode="'cpcl'">
+ </labelPrinterComponentVue>
+ </view>
</template>
<script>
- import labelPrinterComponentVue from '../../components/labelPrinterComponent/labelPrinterComponent.vue';
- import {
- CBar,
- CBox,
- CForm,
- CImage,
- CLine,
- CCodeRotation,
- CCodeType,
- CPage,
- CText,
- CFont,
- CBold,
- CRotation,
- CInverse,
- CMag,
- CQRCode,
- CCorrectLevel,
- CSN,
- CStatus,
- CPCL,
- } from "@psdk/cpcl";
- import {
- CommonUtils
- } from '../../utils/common';
- import {
- getUserInfo
- } from "@/utils/auth.js";
- export default {
- data() {
- return {
- HBarCodeFocus: false,
+ import labelPrinterComponentVue from '../../components/labelPrinterComponent/labelPrinterComponent.vue';
+ import {
+ CBar,
+ CBox,
+ CForm,
+ CImage,
+ CLine,
+ CCodeRotation,
+ CCodeType,
+ CPage,
+ CText,
+ CFont,
+ CBold,
+ CRotation,
+ CInverse,
+ CMag,
+ CQRCode,
+ CCorrectLevel,
+ CSN,
+ CStatus,
+ CPCL,
+ } from "@psdk/cpcl";
+ import {
+ CommonUtils
+ } from '../../utils/common';
+ import {
+ getUserInfo
+ } from "@/utils/auth.js";
+ export default {
+ data() {
+ return {
+ HBarCodeFocus: false,
- printInfo: "",
- userInfo: getUserInfo(),
- buttonStatus: {
- btn1: true,
- btn2: false
- },
- barCodeMeta: '',
- generatedBarCode: '',
- lailiaoInfo: {
- HMainID: '',
- HSubID: '',
- HOrderBillNo: '',
- HMaterID: '',
- barCodeNo: '',
- HBillNo: '',
- HBillLineNo: '',
- HMaterNumber: '',
- HMaterName: '',
- HMaterModel: '',
- HBatchNo: '',
- HQty: '',
- HMTONo: '',
- HSupName: '',
- HSupNameShort: '',
- HMinQty: '',
- HBQty: '',
- HSupID: '',
- HUnitID: '',
- }
- };
- },
- components: {
- labelPrinterComponentVue
- },
- onLoad() {
- this.HBarCodeFocus = true
- },
- methods: {
- async refreshBarcodeState() {
- this.HBarCodeFocus = false
- await this.$nextTick(() => {
- this.HBarCodeFocus = true
- this.lailiaoInfo.barCodeNo = ""
- })
- },
- async print() {
- if (this.$printer.isConnected() === false) {
- this.$refs.labelPrinter.openPopup()
- } else {
- // this.printInfo = async () => {
- // let cpcl = await this.$printer.cpcl().clear()
- // .page(new CPage({
- // width: 608,
- // height: 400
- // }))
- // .qrcode(new CQRCode({
- // x: 500,
- // y: 30,
- // width: 3,
- // content: this.generatedBarCode,
- // codeRotation: CCodeRotation.ROTATION_0,
- // level: CCorrectLevel.L
- // }))
- // .text(new CText({
- // x: 30,
- // y: 30,
- // content: "渚涘簲鍟�: ",
- // font: CFont.TSS24
- // }))
- // .text(new CText({
- // x: 30,
- // y: 80,
- // content: "渚涘簲鍟嗘枡鍙�: ",
- // font: CFont.TSS24
- // }))
- // .text(new CText({
- // x: 30,
- // y: 130,
- // content: "鐗╂枡缂栫爜: ",
- // font: CFont.TSS24
- // }))
- // .text(new CText({
- // x: 30,
- // y: 180,
- // content: "鐗╂枡鍒嗙粍: ",
- // font: CFont.TSS24
- // }))
- // .text(new CText({
- // x: 300,
- // y: 180,
- // content: "瑙勬牸鍨嬪彿: ",
- // font: CFont.TSS24
- // }))
- // .text(new CText({
- // x: 30,
- // y: 230,
- // content: "鏁伴噺: ",
- // font: CFont.TSS24
- // }))
- // .text(new CText({
- // x: 300,
- // y: 230,
- // content: "鏃ユ湡: ",
- // font: CFont.TSS24
- // }))
- // .text(new CText({
- // x: 30,
- // y: 280,
- // content: "妫�楠屽憳: ",
- // font: CFont.TSS24
- // }))
- // .text(new CText({
- // x: 300,
- // y: 280,
- // content: "璁″垝璺熻釜鍙�: ",
- // font: CFont.TSS24
- // }))
- // .text(new CText({
- // x: 30,
- // y: 330,
- // content: "妫�楠岀粨鏋�: ",
- // font: CFont.TSS24
- // }))
- // .box(new CBox({
- // topLeftX: 260,
- // topLeftY: 320,
- // bottomRightX: 280,
- // bottomRightY: 340,
- // lineWidth: 4,
- // }))
- // .text(new CText({
- // x: 290,
- // y: 320,
- // content: "鍚堟牸",
- // font: CFont.TSS24
- // }))
- // .box(new CBox({
- // topLeftX: 360,
- // topLeftY: 320,
- // bottomRightX: 380,
- // bottomRightY: 340,
- // lineWidth: 4,
- // }))
- // .text(new CText({
- // x: 390,
- // y: 320,
- // content: "涓嶅悎鏍�",
- // font: CFont.TSS24
- // }))
- // .box(new CBox({
- // topLeftX: 480,
- // topLeftY: 320,
- // bottomRightX: 500,
- // bottomRightY: 340,
- // lineWidth: 4,
- // }))
- // .text(new CText({
- // x: 510,
- // y: 320,
- // content: "鐗归噰",
- // font: CFont.TSS24
- // }))
- // .form(new CForm())
- // .print();
- // console.log(cpcl.command().string())
- // return cpcl.command().binary()
- // }
- // await this.$nextTick(() => {
- // this.$refs.labelPrinter.execPrint()
- // })
- // T 24 0 300 280 璁″垝璺熻釜鍙�: ${this.lailiaoInfo.HMTONo || ''}
- this.printInfo = `! 0 200 200 400 1
+ printInfo: "",
+ userInfo: getUserInfo(),
+ buttonStatus: {
+ btn1: true,
+ btn2: true
+ },
+ barCodeMeta: '',
+ generatedBarCode: '',
+ lailiaoInfo: {
+ HMainID: '',
+ HSubID: '',
+ HOrderBillNo: '',
+ HMaterID: '',
+ barCodeNo: '',
+ HBillNo: '',
+ HBillLineNo: '',
+ HMaterNumber: '',
+ HMaterName: '',
+ HMaterModel: '',
+ HBatchNo: '',
+ HQty: '',
+ HMTONo: '',
+ HSupName: '',
+ HSupNameShort: '',
+ HMinQty: '',
+ HBQty: '',
+ HSupID: '',
+ HUnitID: '',
+ }
+ };
+ },
+ components: {
+ labelPrinterComponentVue
+ },
+ onLoad() {
+ this.HBarCodeFocus = true
+ },
+ methods: {
+ async refreshBarcodeState() {
+ this.HBarCodeFocus = false
+ await this.$nextTick(() => {
+ this.HBarCodeFocus = true
+ this.lailiaoInfo.barCodeNo = ""
+ })
+ },
+ async print() {
+ if (this.$printer.isConnected() === false) {
+ this.$refs.labelPrinter.openPopup()
+ } else {
+ // this.printInfo = async () => {
+ // let cpcl = await this.$printer.cpcl().clear()
+ // .page(new CPage({
+ // width: 608,
+ // height: 400
+ // }))
+ // .qrcode(new CQRCode({
+ // x: 500,
+ // y: 30,
+ // width: 3,
+ // content: this.generatedBarCode,
+ // codeRotation: CCodeRotation.ROTATION_0,
+ // level: CCorrectLevel.L
+ // }))
+ // .text(new CText({
+ // x: 30,
+ // y: 30,
+ // content: "渚涘簲鍟�: ",
+ // font: CFont.TSS24
+ // }))
+ // .text(new CText({
+ // x: 30,
+ // y: 80,
+ // content: "渚涘簲鍟嗘枡鍙�: ",
+ // font: CFont.TSS24
+ // }))
+ // .text(new CText({
+ // x: 30,
+ // y: 130,
+ // content: "鐗╂枡缂栫爜: ",
+ // font: CFont.TSS24
+ // }))
+ // .text(new CText({
+ // x: 30,
+ // y: 180,
+ // content: "鐗╂枡鍒嗙粍: ",
+ // font: CFont.TSS24
+ // }))
+ // .text(new CText({
+ // x: 300,
+ // y: 180,
+ // content: "瑙勬牸鍨嬪彿: ",
+ // font: CFont.TSS24
+ // }))
+ // .text(new CText({
+ // x: 30,
+ // y: 230,
+ // content: "鏁伴噺: ",
+ // font: CFont.TSS24
+ // }))
+ // .text(new CText({
+ // x: 300,
+ // y: 230,
+ // content: "鏃ユ湡: ",
+ // font: CFont.TSS24
+ // }))
+ // .text(new CText({
+ // x: 30,
+ // y: 280,
+ // content: "妫�楠屽憳: ",
+ // font: CFont.TSS24
+ // }))
+ // .text(new CText({
+ // x: 300,
+ // y: 280,
+ // content: "璁″垝璺熻釜鍙�: ",
+ // font: CFont.TSS24
+ // }))
+ // .text(new CText({
+ // x: 30,
+ // y: 330,
+ // content: "妫�楠岀粨鏋�: ",
+ // font: CFont.TSS24
+ // }))
+ // .box(new CBox({
+ // topLeftX: 260,
+ // topLeftY: 320,
+ // bottomRightX: 280,
+ // bottomRightY: 340,
+ // lineWidth: 4,
+ // }))
+ // .text(new CText({
+ // x: 290,
+ // y: 320,
+ // content: "鍚堟牸",
+ // font: CFont.TSS24
+ // }))
+ // .box(new CBox({
+ // topLeftX: 360,
+ // topLeftY: 320,
+ // bottomRightX: 380,
+ // bottomRightY: 340,
+ // lineWidth: 4,
+ // }))
+ // .text(new CText({
+ // x: 390,
+ // y: 320,
+ // content: "涓嶅悎鏍�",
+ // font: CFont.TSS24
+ // }))
+ // .box(new CBox({
+ // topLeftX: 480,
+ // topLeftY: 320,
+ // bottomRightX: 500,
+ // bottomRightY: 340,
+ // lineWidth: 4,
+ // }))
+ // .text(new CText({
+ // x: 510,
+ // y: 320,
+ // content: "鐗归噰",
+ // font: CFont.TSS24
+ // }))
+ // .form(new CForm())
+ // .print();
+ // console.log(cpcl.command().string())
+ // return cpcl.command().binary()
+ // }
+ // await this.$nextTick(() => {
+ // this.$refs.labelPrinter.execPrint()
+ // })
+ // T 24 0 300 280 璁″垝璺熻釜鍙�: ${this.lailiaoInfo.HMTONo || ''}
+
+ this.printInfo = `! 0 200 200 400 1
PAGE-WIDTH 608
SETQRVER 3
-B QR 470 30 M 5 U 5
+B QR 480 30 M 4 U 4
LA,${this.lailiaoInfo.barCodeNo}
ENDQR
T 24 0 10 30 渚涘簲鍟�: ${this.lailiaoInfo.HSupName}
T 55 0 10 55 (Supplier)
-T 24 0 10 80 渚涘簲鍟嗘枡鍙�: ${this.lailiaoInfo.HMaterNumber}
-T 55 0 10 105 (Supplier Sku No.)
-T 24 0 10 130 鐗╂枡鍚嶇О: ${this.lailiaoInfo.HMaterName}
-T 55 0 5 155 (Material Code)
-T 24 0 300 130 娆惧彿:
-T 55 0 300 155 (eng)
-T 24 0 5 180 鍒嗙粍: ${this.lailiaoInfo.HBatchNo}
-T 55 0 5 205 (Group)
-T 24 0 300 180 瑙勬牸: ${this.lailiaoInfo.HMaterModel}
-T 55 0 300 205 (SKU NO.)
-T 24 0 10 230 鏁伴噺: ${this.lailiaoInfo.HQty} (${this.lailiaoInfo.HPcsName})
-T 55 0 5 255 (Quantity)
+
+T 24 0 10 70 渚涘簲鍟嗘枡鍙�: ${this.lailiaoInfo.HMaterNumber}
+T 55 0 10 95 (Supplier Sku No.)
+T 24 0 10 110 鐗╂枡鍚嶇О: ${this.lailiaoInfo.HMaterName}
+T 55 0 10 135 (Material Code)
+T 24 0 10 150 娆惧彿:
+T 55 0 10 175 (eng)
+T 24 0 300 150 瀹㈡埛缂栧彿:
+T 55 0 300 175 (eng)
+T 24 0 10 190 鍒嗙粍: ${this.lailiaoInfo.HBatchNo}
+T 55 0 10 215 (Group)
+T 24 0 300 190 瑙勬牸: ${this.lailiaoInfo.HMaterModel}
+T 55 0 300 215 (SKU NO.)
+T 24 0 10 230 鏁伴噺: ${this.lailiaoInfo.HQty} (${this.lailiaoInfo.HPcsName})
+T 55 0 10 255 (Quantity)
T 24 0 300 230 鏃ユ湡: ${this.lailiaoInfo.HDate}
T 55 0 300 255 (Date)
-T 24 0 5 280 妫�楠屽憳:
-T 55 0 5 305 (QC)
-T 24 0 300 280 閲囪喘鍗曞彿: ${this.lailiaoInfo.HBillNo || ''}
-T 55 0 300 305 (Purchase Order No.)
-T 24 0 5 330 妫�楠岀粨鏋�:
-T 55 0 5 355 (Inspection status)
-BOX 240 330 260 350 4
-T 24 0 270 330 鍚堟牸
-T 55 0 250 355 (Pass)
-BOX 340 330 360 350 4
-T 24 0 370 330 涓嶅悎鏍�
-T 55 0 370 355 (Fail)
-BOX 460 330 480 350 4
-T 24 0 490 330 鐗归噰
-T 55 0 440 355 (Spec. accepted)
+
+T 24 0 10 270 妫�楠屽憳:
+T 55 0 10 295 (QC)
+T 24 0 300 270 閲囪喘鍗曞彿: ${this.lailiaoInfo.HBillNo || ''}
+T 55 0 300 295 (Purchase Order No.)
+T 24 0 10 310 妫�楠岀粨鏋�:
+T 55 0 10 335 (Inspection status)
+BOX 240 310 260 330 4
+T 24 0 270 310 鍚堟牸
+T 55 0 250 335 (Pass)
+BOX 340 310 360 330 4
+T 24 0 370 310 涓嶅悎鏍�
+T 55 0 370 335 (Fail)
+BOX 460 310 480 330 4
+T 24 0 490 310 鐗归噰
+T 55 0 440 335 (Spec. accepted)
FORM
PRINT`
- await this.$nextTick(() => {
- this.$refs.labelPrinter.execPrint()
- })
- }
- },
- setLailiaoInfo(data, row) {
- if (row > data.length) {
- CommonUtils.playSound(0)
- return uni.showToast({
- icon: 'none',
- title: '鏌ヨ鐨勫崟鎹彿涓嶅瓨鍦�...'
- })
+ await this.$nextTick(() => {
+ this.$refs.labelPrinter.execPrint()
+ })
+ }
+ },
+ setLailiaoInfo(data, row) {
+ if (row > data.length) {
+ CommonUtils.playSound(0)
+ return uni.showToast({
+ icon: 'none',
+ title: '鏌ヨ鐨勫崟鎹彿涓嶅瓨鍦�...'
+ })
- }
- let d = data[row - 1]
- this.lailiaoInfo = Object.assign(this.lailiaoInfo, {
- HMaterNumber: d['鐗╂枡缂栫爜'],
- HMaterName: d['鐗╂枡鍚嶇О'],
- HMaterModel: d['瑙勬牸鍨嬪彿'],
- HBatchNo: d['鎵瑰彿'],
- HQty: d['鏁伴噺'],
- HMinQty: d['鏁伴噺'],
- HBQty: d['鏁伴噺'],
- HSupID: d['HSupID'],
- HSupName: d['渚涘簲鍟�'],
- HUnitID: d['HUnitID'],
- HSupNameShort: d['渚涘簲鍟�'],
- HMTONo: d['璁㈠崟璺熻釜鍙�'],
- HMainID: d['linterid'],
- HSubID: d['HEntryID'],
- HMaterID: d['HMaterID'],
- })
- CommonUtils.playSound(1)
- this.buttonStatus.btn2 = true
- },
- setClearLailiaoInfo() {
- this.lailiaoInfo = {
- HMainID: '',
- HSubID: '',
- HOrderBillNo: '',
- HMaterID: '',
- barCodeNo: '',
- HBillNo: '',
- HBillLineNo: '',
- HMaterNumber: '',
- HMaterName: '',
- HMaterModel: '',
- HBatchNo: '',
- HQty: '',
- HMTONo: '',
- HSupName: '',
- HSupNameShort: '',
- HMinQty: '',
- HBQty: '',
- }
+ }
+ let d = data[row - 1]
+ this.lailiaoInfo = Object.assign(this.lailiaoInfo, {
+ HMaterNumber: d['鐗╂枡缂栫爜'],
+ HMaterName: d['鐗╂枡鍚嶇О'],
+ HMaterModel: d['瑙勬牸鍨嬪彿'],
+ HBatchNo: d['鎵瑰彿'],
+ HQty: d['鏁伴噺'],
+ HMinQty: d['鏁伴噺'],
+ HBQty: d['鏁伴噺'],
+ HSupID: d['HSupID'],
+ HSupName: d['渚涘簲鍟�'],
+ HUnitID: d['HUnitID'],
+ HSupNameShort: d['渚涘簲鍟�'],
+ HMTONo: d['璁″垝璺熻釜鍙�'],
+ HMainID: d['linterid'],
+ HSubID: d['HEntryID'],
+ HMaterID: d['HMaterID'],
+ })
+ CommonUtils.playSound(1)
+ this.buttonStatus.btn2 = true
+ },
+ setClearLailiaoInfo() {
+ this.lailiaoInfo = {
+ HMainID: '',
+ HSubID: '',
+ HOrderBillNo: '',
+ HMaterID: '',
+ barCodeNo: '',
+ HBillNo: '',
+ HBillLineNo: '',
+ HMaterNumber: '',
+ HMaterName: '',
+ HMaterModel: '',
+ HBatchNo: '',
+ HQty: '',
+ HMTONo: '',
+ HSupName: '',
+ HSupNameShort: '',
+ HMinQty: '',
+ HBQty: '',
+ }
- this.buttonStatus = {
- btn1: true,
- btn2: false
- }
- },
- barCodeEntryHandler(barCode) {
- if (CommonUtils.isEmpty(barCode) === false) {
- console.log('鏉$爜鍐呭锛�' + barCode);
- this.lailiaoInfo.barCodeNo = barCode;
- if (barCode.includes("@") === false) {
- this.buttonStatus.btn2 = false
- CommonUtils.playSound(0)
- this.refreshBarcodeState()
- return uni.showToast({
- icon: 'none',
- title: '鏉$爜鏍煎紡閿欒锛岃閲嶆柊鎵弿...'
- })
- }
- let barCodeInfo = barCode.split("@")
- let [PurchaseBillNo, Row] = barCodeInfo
- this.lailiaoInfo.HBillNo = PurchaseBillNo,
- this.lailiaoInfo.HBillLineNo = Row
- console.log({
- sWhere: ` and 鍗曟嵁鍙� = '${PurchaseBillNo}'`,
- user: this.userInfo.Czymc,
- })
- CommonUtils.doRequest(
- "/Cg_POOrderBill/list", {
- sWhere: ` and 鍗曟嵁鍙� = '${PurchaseBillNo}'`,
- user: this.userInfo.Czymc,
- },
- (res) => {
- console.log('閲囪喘璁㈠崟: ', res)
- let {
- data,
- count
- } = res.data
- if (count > 0) {
+ this.buttonStatus = {
+ btn1: true,
+ btn2: false
+ }
+ },
+ barCodeEntryHandler(barCode) {
+ if (CommonUtils.isEmpty(barCode) === false) {
+ console.log('鏉$爜鍐呭锛�' + barCode);
+ this.lailiaoInfo.barCodeNo = barCode;
+ if (barCode.includes("@") === false) {
+ this.buttonStatus.btn2 = false
+ CommonUtils.playSound(0)
+ this.refreshBarcodeState()
+ return uni.showToast({
+ icon: 'none',
+ title: '鏉$爜鏍煎紡閿欒锛岃閲嶆柊鎵弿...'
+ })
+ }
+ let barCodeInfo = barCode.split("@")
+ let [PurchaseBillNo, Row] = barCodeInfo
+ this.lailiaoInfo.HBillNo = PurchaseBillNo,
+ this.lailiaoInfo.HBillLineNo = Row
+ console.log({
+ sWhere: ` and 鍗曟嵁鍙� = '${PurchaseBillNo}'`,
+ user: this.userInfo.Czymc,
+ })
+ CommonUtils.doRequest(
+ "/Cg_POOrderBill/list", {
+ sWhere: ` and 鍗曟嵁鍙� = '${PurchaseBillNo}'`,
+ user: this.userInfo.Czymc,
+ },
+ (res) => {
+ console.log('閲囪喘璁㈠崟: ', res)
+ let {
+ data,
+ count,
+ Message
+ } = res.data
+ if (count > 0) {
- this.setLailiaoInfo(data, Row)
+ this.setLailiaoInfo(data, Row)
+ // uni.showToast({
+ // icon: 'none',
+ // title: Message
+ // })
+ this.buttonStatus.btn1 = false
- } else {
- CommonUtils.playSound(0)
- this.refreshBarcodeState()
- }
- },
- (error) => {
- CommonUtils.playSound(0)
- this.refreshBarcodeState()
- this.buttonStatus.btn2 = false
- }
- )
+ } else {
+ CommonUtils.playSound(0)
+ this.refreshBarcodeState()
+ // uni.showToast({
+ // icon: 'none',
+ // title: Message
+ // })
+ this.buttonStatus.btn1 = true
+ this.buttonStatus.btn2 = true
+ }
+ },
+ (error) => {
+ CommonUtils.playSound(0)
+ this.refreshBarcodeState()
+ this.buttonStatus.btn1 = true
+ this.buttonStatus.btn2 = true
+ }
+ )
- }
- },
- toScanCode() {
- var mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module")
- mpaasScanModule.mpaasScan({
- 'hideAlbum': true,
- 'timeoutInterval':'10', //瓒呮椂鏃堕棿
- 'timeoutText':'鏈瘑鍒埌浜岀淮鐮�' //瓒呮椂鎻愰啋
- },(ret) => {
- console.log(ret.resp_result)
- if (CommonUtils.isEmpty(ret.resp_result) === false) {
- console.log('鏉$爜鍐呭锛�' + ret.resp_result);
- this.lailiaoInfo.barCodeNo = ret.resp_result;
- if (ret.resp_result.includes("@") === false) {
- return uni.showToast({
- icon: 'none',
- title: '鏉$爜鏍煎紡閿欒锛岃閲嶆柊鎵弿...'
- })
- }
- let barCodeInfo = ret.resp_result.split("@")
- let [PurchaseBillNo, Row] = barCodeInfo
- this.lailiaoInfo.HBillNo = PurchaseBillNo,
- this.lailiaoInfo.HBillLineNo = Row
- console.log({
- sWhere: ` and 鍗曟嵁鍙� = '${PurchaseBillNo}'`,
- user: this.userInfo.Czymc,
- })
- CommonUtils.doRequest(
- "/Cg_POOrderBill/list", {
- sWhere: ` and 鍗曟嵁鍙� = '${PurchaseBillNo}'`,
- user: this.userInfo.Czymc,
- },
- (res) => {
- console.log('閲囪喘璁㈠崟: ', res)
- let {
- data,
- count
- } = res.data
- if (count > 0) {
- this.setLailiaoInfo(data, Row)
- }
- },
- (error) => {
-
- }
- )
-
- }
-
- })
- },
- GenereateBarCode() {
- let HBarCodeNoStr =
- `${this.lailiaoInfo.HBillNo}@${this.lailiaoInfo.HBillLineNo}@${this.lailiaoInfo.HMaterNumber}@${this.lailiaoInfo.HMTONo}@${this.lailiaoInfo.HQty}@${this.lailiaoInfo.HSupID}`
- let sMain = []
- sMain[0] = this.lailiaoInfo
- let sMainStr = JSON.stringify(sMain);
- //鑾峰彇閫夋嫨鐨勭粍缁�
- let HOrgType = uni.getStorageSync('Organization');
- //鑾峰彇閫夋嫨鐨勫伐鍘備唬鐮�
- let CampanyName = "xxx";
- //鑾峰彇閫夋嫨鐨勬簮鍗曠被鍨�
- let HSourceBillType = "鏉ユ枡閫氱煡鍗�";
- //鑾峰彇閫夋嫨鐨勬潯鐮佺被鍨�
- let HSelectBarCodeType = "鍞竴鏉$爜";
- //鑾峰彇褰撳墠鐧诲綍浜哄憳
- let UserName = uni.getStorageSync('HUserName');
- let sMainSub = sMainStr + ';' + HOrgType + ';' + HSourceBillType + ';' + HSelectBarCodeType + ';' +
- CampanyName + ';' + UserName + ';' + HBarCodeNoStr;
+ }
+ },
+ toScanCode() {
+ var mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module")
+ mpaasScanModule.mpaasScan({
+ 'hideAlbum': true,
+ 'timeoutInterval': '10', //瓒呮椂鏃堕棿
+ 'timeoutText': '鏈瘑鍒埌浜岀淮鐮�' //瓒呮椂鎻愰啋
+ }, (ret) => {
+ console.log(ret.resp_result)
+ if (CommonUtils.isEmpty(ret.resp_result) === false) {
+ console.log('鏉$爜鍐呭锛�' + ret.resp_result);
+ this.lailiaoInfo.barCodeNo = ret.resp_result;
+ if (ret.resp_result.includes("@") === false) {
+ return uni.showToast({
+ icon: 'none',
+ title: '鏉$爜鏍煎紡閿欒锛岃閲嶆柊鎵弿...'
+ })
+ }
+ // let barCodeInfo = ret.resp_result.split("@")
+ // let [PurchaseBillNo, Row] = barCodeInfo
+ // this.lailiaoInfo.HBillNo = PurchaseBillNo,
+ // this.lailiaoInfo.HBillLineNo = Row
+ // console.log({
+ // sWhere: ` and 鍗曟嵁鍙� = '${PurchaseBillNo}'`,
+ // user: this.userInfo.Czymc,
+ // })
+ // CommonUtils.doRequest(
+ // "/Cg_POOrderBill/list", {
+ // sWhere: ` and 鍗曟嵁鍙� = '${PurchaseBillNo}'`,
+ // user: this.userInfo.Czymc,
+ // },
+ // (res) => {
+ // console.log('閲囪喘璁㈠崟: ', res)
+ // let {
+ // data,
+ // count
+ // } = res.data
+ // if (count > 0) {
+ // this.setLailiaoInfo(data, Row)
+ // }
+ // },
+ // (error) => {
- CommonUtils.doRequest(
- "/Sc_BarCode/SaveBarCode_NoGenerate", {
- msg: sMainSub,
- CampanyName: CampanyName
- },
- (res) => {
- console.log(res)
- let {
- data,
- count,
- Message
- } = res.data
- if (count > 0) {
- this.buttonStatus = {
- btn1: false,
- btn2: true
- }
- this.generatedBarCode = data[0]['鏉$爜缂栧彿']
- console.log(this.generatedBarCode)
- uni.showToast({
- icon: 'none',
- title: Message
- })
- } else {
- uni.showToast({
- icon: 'none',
- title: Message
- })
- }
- },
- (err) => {
+ // }
+ // )
+ this.barCodeEntryHandler(ret.resp_result)
+ }
- },
- "POST"
- )
- },
- exit() {
- uni.navigateBack()
- }
- }
- }
+ })
+ },
+ GenereateBarCode() {
+ let HBarCodeNoStr =
+ `${this.lailiaoInfo.HBillNo}@${this.lailiaoInfo.HBillLineNo}@${this.lailiaoInfo.HMaterNumber || ''}@${this.lailiaoInfo.HMTONo || ''}@${this.lailiaoInfo.HQty || ''}@${this.lailiaoInfo.HSupID || ''}`
+ let sMain = []
+ sMain[0] = this.lailiaoInfo
+ let sMainStr = JSON.stringify(sMain);
+ //鑾峰彇閫夋嫨鐨勭粍缁�
+ let HOrgType = uni.getStorageSync('Organization');
+ //鑾峰彇閫夋嫨鐨勫伐鍘備唬鐮�
+ let CampanyName = "xxx";
+ //鑾峰彇閫夋嫨鐨勬簮鍗曠被鍨�
+ let HSourceBillType = "閲囪喘璁㈠崟";
+ //鑾峰彇閫夋嫨鐨勬潯鐮佺被鍨�
+ let HSelectBarCodeType = "鍝佺鏉$爜";
+ //鑾峰彇褰撳墠鐧诲綍浜哄憳
+ let UserName = uni.getStorageSync('HUserName');
+ let sMainSub = sMainStr + ';' + HOrgType + ';' + HSourceBillType + ';' + HSelectBarCodeType + ';' +
+ CampanyName + ';' + UserName + ';' + HBarCodeNoStr;
+
+ CommonUtils.doRequest(
+ "/Sc_BarCode/SaveBarCode_NoGenerate", {
+ msg: sMainSub,
+ CampanyName: CampanyName
+ },
+ (res) => {
+ console.log(res)
+ let {
+ data,
+ count,
+ Message
+ } = res.data
+ if (count > 0) {
+ // this.generatedBarCode = data[0]['鏉$爜缂栧彿']/
+ // console.log(this.generatedBarCode)
+ uni.showToast({
+ icon: 'none',
+ title: Message
+ })
+ this.buttonStatus = {
+ btn1: true,
+ btn2: true
+ }
+ } else {
+ uni.showToast({
+ icon: 'none',
+ title: Message
+ })
+ }
+ },
+ (err) => {
+ uni.showToast({
+ icon: 'none',
+ title: err
+ })
+ },
+ "POST"
+ )
+ },
+ exit() {
+ uni.navigateBack()
+ }
+ }
+ }
</script>
<style lang="scss" scoped>
- * {
- box-sizing: border-box;
- }
+ * {
+ box-sizing: border-box;
+ }
- input {
- padding: 8rpx 20rpx;
- font-size: 30rpx;
- line-height: 30rpx;
- }
+ input {
+ padding: 8rpx 20rpx;
+ font-size: 30rpx;
+ line-height: 30rpx;
+ }
- .uni-input-input[disabled] {
- background-color: #e4e4e4;
- }
+ .uni-input-input[disabled] {
+ background-color: #e4e4e4;
+ }
- .container {
- display: flex;
- flex-direction: column;
- height: 100vh;
- padding: 20rpx 0;
+ .container {
+ display: flex;
+ flex-direction: column;
+ height: 100vh;
+ padding: 20rpx 0;
- .content {
- flex: 1;
- background-image: url('/static/svgs/folder_bg.svg');
- background-size: cover;
- padding: 20rpx;
+ .content {
+ flex: 1;
+ background-image: url('/static/svgs/folder_bg.svg');
+ background-size: cover;
+ padding: 20rpx;
- .header {
- font-size: 30rpx;
- }
+ .header {
+ font-size: 30rpx;
+ }
- .items {
- display: flex;
- flex-direction: column;
- gap: 10rpx;
- padding: 40rpx 0rpx;
+ .items {
+ display: flex;
+ flex-direction: column;
+ gap: 10rpx;
+ padding: 40rpx 0rpx;
- .item {
- display: flex;
- flex-direction: row;
- padding: 0 10rpx;
- gap: 20rpx;
- font-size: 30rpx;
- // height: 1.5rem;
- // justify-content: center;
- align-items: center;
+ .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: left;
- width: 6rem;
- }
+ .left {
+ text-align: left;
+ width: 6rem;
+ }
- .right {
- flex: 1;
- height: 100%;
- padding: 6rpx 0;
- border-radius: 22rpx;
- border: 1px solid #e4e4e4;
- background-color: #e4e4e4;
+ .right {
+ flex: 1;
+ height: 100%;
+ padding: 6rpx 0;
+ border-radius: 22rpx;
+ border: 1px solid #e4e4e4;
+ background-color: #e4e4e4;
- >input {
- height: auto;
- }
+ >input {
+ height: auto;
+ }
- }
+ }
- .barcode {
- background-color: #fff !important;
- }
+ .barcode {
+ background-color: #fff !important;
+ }
- }
- }
- }
+ }
+ }
+ }
- .operation-zone {
- height: 3rem;
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: 30rpx;
- padding: 20rpx;
+ .operation-zone {
+ height: 3rem;
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 30rpx;
+ padding: 20rpx;
- >view {
- flex: 1;
- }
+ >view {
+ flex: 1;
+ }
- >button {
- width: 4rem;
- padding: 0;
- font-size: 25rpx;
- border-radius: 50rpx;
- line-height: 66rpx;
- font-size: 28rpx;
- }
+ >button {
+ width: 4rem;
+ padding: 0;
+ font-size: 25rpx;
+ border-radius: 50rpx;
+ line-height: 66rpx;
+ font-size: 28rpx;
+ }
- >button[disabled] {
- background-color: #acacac;
- color: #fff;
- }
+ >button[disabled] {
+ background-color: #acacac;
+ color: #fff;
+ }
- .btn-a {
- background-color: #acacac;
- color: #fff;
- }
+ .btn-a {
+ background-color: #acacac;
+ color: #fff;
+ }
- .btn-b {
- background-color: #41a863;
- color: #fff;
- }
+ .btn-b {
+ background-color: #41a863;
+ color: #fff;
+ }
- .btn-c {
- background-color: #3a78ff;
- color: #fff;
- }
- }
- }
+ .btn-c {
+ background-color: #3a78ff;
+ color: #fff;
+ }
+ }
+ }
</style>
\ No newline at end of file
diff --git a/utils/common.js b/utils/common.js
index d3dd163..2ba726f 100644
--- a/utils/common.js
+++ b/utils/common.js
@@ -1,251 +1,255 @@
class commonUtils {
- serverUrl
+ serverUrl
- constructor() {
- this.serverUrl = uni.getStorageSync('serverUrl') || 'http://47.96.97.237/API';
- }
+ constructor() {
+ this.serverUrl = uni.getStorageSync('serverUrl') || 'http://47.96.97.237/API/';
+ }
- // 闃叉姈鍑芥暟
- debounce(func, delay, immediate = false) {
- let timer = null;
- return function() {
- const context = this;
- const args = arguments;
+ setServerUrl(url) {
+ this.serverUrl = url
+ }
- const callNow = immediate && !timer;
- // 濡傛灉瀹氭椂鍣ㄥ凡缁忓瓨鍦紝娓呴櫎瀹�
- if (timer) {
- clearTimeout(timer);
- }
+ // 闃叉姈鍑芥暟
+ debounce(func, delay, immediate = false) {
+ let timer = null;
+ return function() {
+ const context = this;
+ const args = arguments;
- // 璁剧疆涓�涓柊鐨勫畾鏃跺櫒
- timer = setTimeout(() => {
- if (!immediate) {
- func.apply(context, args);
- }
- timer = null;
- }, delay);
+ const callNow = immediate && !timer;
+ // 濡傛灉瀹氭椂鍣ㄥ凡缁忓瓨鍦紝娓呴櫎瀹�
+ if (timer) {
+ clearTimeout(timer);
+ }
- // 閰嶇疆绔嬪嵆鎵ц
- if (callNow == true) {
- func.apply(context, args)
- }
- };
- }
+ // 璁剧疆涓�涓柊鐨勫畾鏃跺櫒
+ timer = setTimeout(() => {
+ if (!immediate) {
+ func.apply(context, args);
+ }
+ timer = null;
+ }, delay);
- // 鍒ょ┖鍑芥暟
- isEmpty(value, zeroIsEmpty = false, falseIsEmpty = false) {
- let val = value
- // 妫�鏌ユ槸鍚︿负null 鎴栬�� undefind
- if (val === null || val === undefined) {
- return true;
- }
- //濡傛灉瀛楃涓插叏閮ㄦ槸鐢辨暟瀛楁瀯鎴愮殑锛屽垯杞寲涓烘暟瀛楀瀷
- if (this.isAllDigits(val) === true) {
- val = Number(val)
- }
+ // 閰嶇疆绔嬪嵆鎵ц
+ if (callNow == true) {
+ func.apply(context, args)
+ }
+ };
+ }
- // 鏄惁鏄瓧绗︿覆绫诲瀷
- if (typeof val === 'string') {
- return val.trim().length === 0;
- }
+ // 鍒ょ┖鍑芥暟
+ isEmpty(value, zeroIsEmpty = false, falseIsEmpty = false) {
+ let val = value
+ // 妫�鏌ユ槸鍚︿负null 鎴栬�� undefind
+ if (val === null || val === undefined) {
+ return true;
+ }
+ //濡傛灉瀛楃涓插叏閮ㄦ槸鐢辨暟瀛楁瀯鎴愮殑锛屽垯杞寲涓烘暟瀛楀瀷
+ if (this.isAllDigits(val) === true) {
+ val = Number(val)
+ }
- // 鏄惁鏄暟缁�
- if (Array.isArray(val)) {
- return val.length === 0;
- }
+ // 鏄惁鏄瓧绗︿覆绫诲瀷
+ if (typeof val === 'string') {
+ return val.trim().length === 0;
+ }
- //鏄惁鏄璞�
- if (typeof val === 'object') {
- return Object.keys(val).length === 0;
- }
+ // 鏄惁鏄暟缁�
+ if (Array.isArray(val)) {
+ return val.length === 0;
+ }
- // 鏁板瓧绫诲瀷榛樿涓嶄负绌�
- if (typeof val === 'number') {
- // 鏁板瓧涓�0瑙嗕负绌�
- if (zeroIsEmpty == true) {
- if (val === 0) {
- return true
- }
- }
- return false
- }
+ //鏄惁鏄璞�
+ if (typeof val === 'object') {
+ return Object.keys(val).length === 0;
+ }
- // 甯冨皵绫诲瀷榛樿涓嶄负绌�
- if (typeof val === 'boolean') {
- // false鍊艰涓虹┖
- if (falseIsEmpty == true) {
- if (val === 0) {
- return true
- }
- }
- return false;
- }
- }
+ // 鏁板瓧绫诲瀷榛樿涓嶄负绌�
+ if (typeof val === 'number') {
+ // 鏁板瓧涓�0瑙嗕负绌�
+ if (zeroIsEmpty == true) {
+ if (val === 0) {
+ return true
+ }
+ }
+ return false
+ }
- // 鍒ゆ柇鏄惁鍏ㄦ槸鏁板瓧
- isAllDigits(str) {
- return /^\d+$/.test(str);
- }
+ // 甯冨皵绫诲瀷榛樿涓嶄负绌�
+ if (typeof val === 'boolean') {
+ // false鍊艰涓虹┖
+ if (falseIsEmpty == true) {
+ if (val === 0) {
+ return true
+ }
+ }
+ return false;
+ }
+ }
- isJson(str) {
- try {
- JSON.parse(str)
- return true
- } catch {
- return false
- }
- }
+ // 鍒ゆ柇鏄惁鍏ㄦ槸鏁板瓧
+ isAllDigits(str) {
+ return /^\d+$/.test(str);
+ }
- timeClock(callback, delay) {
- let timeoutId;
- let isRunning = false;
+ isJson(str) {
+ try {
+ JSON.parse(str)
+ return true
+ } catch {
+ return false
+ }
+ }
- function interval() {
- timeoutId = setTimeout(() => {
- callback();
- clearTimeout(timeoutId); // 绔嬪嵆娓呴櫎褰撳墠瀹氭椂鍣↖D
- if (isRunning) {
- interval();
- }
- }, delay);
- }
+ timeClock(callback, delay) {
+ let timeoutId;
+ let isRunning = false;
- return {
- start() {
- if (!isRunning) {
- isRunning = true;
- interval();
- }
- },
- stop() {
- if (isRunning) {
- isRunning = false;
- clearTimeout(timeoutId);
- }
- }
- };
- }
+ function interval() {
+ timeoutId = setTimeout(() => {
+ callback();
+ clearTimeout(timeoutId); // 绔嬪嵆娓呴櫎褰撳墠瀹氭椂鍣↖D
+ if (isRunning) {
+ interval();
+ }
+ }, delay);
+ }
- deepClone(target, map = new WeakMap()) {
- // 澶勭悊鍘熷鍊煎拰鍑芥暟(typeof 鏁扮粍浼氳繑鍥瀘bject)
- if (typeof target !== 'object' || target === null) {
- return target;
- }
+ return {
+ start() {
+ if (!isRunning) {
+ isRunning = true;
+ interval();
+ }
+ },
+ stop() {
+ if (isRunning) {
+ isRunning = false;
+ clearTimeout(timeoutId);
+ }
+ }
+ };
+ }
- // 澶勭悊寰幆寮曠敤
- if (map.has(target)) {
- return map.get(target);
- }
+ deepClone(target, map = new WeakMap()) {
+ // 澶勭悊鍘熷鍊煎拰鍑芥暟(typeof 鏁扮粍浼氳繑鍥瀘bject)
+ if (typeof target !== 'object' || target === null) {
+ return target;
+ }
- let clone;
+ // 澶勭悊寰幆寮曠敤
+ if (map.has(target)) {
+ return map.get(target);
+ }
- // 澶勭悊鏁扮粍
- if (Array.isArray(target)) {
- clone = [];
- map.set(target, clone);
- target.forEach((item, index) => {
- clone[index] = deepClone(item, map);
- });
- return clone;
- }
+ let clone;
- // 澶勭悊鏃ユ湡瀵硅薄
- if (target instanceof Date) {
- clone = new Date(target.getTime());
- map.set(target, clone);
- return clone;
- }
+ // 澶勭悊鏁扮粍
+ if (Array.isArray(target)) {
+ clone = [];
+ map.set(target, clone);
+ target.forEach((item, index) => {
+ clone[index] = deepClone(item, map);
+ });
+ return clone;
+ }
- // 澶勭悊姝e垯琛ㄨ揪寮�
- if (target instanceof RegExp) {
- clone = new RegExp(target);
- map.set(target, clone);
- return clone;
- }
+ // 澶勭悊鏃ユ湡瀵硅薄
+ if (target instanceof Date) {
+ clone = new Date(target.getTime());
+ map.set(target, clone);
+ return clone;
+ }
- // 澶勭悊鍑芥暟 (鐩存帴浣跨敤鍑芥暟鐨勫紩鐢�)
- if (typeof target === 'function') {
- return target;
- }
+ // 澶勭悊姝e垯琛ㄨ揪寮�
+ if (target instanceof RegExp) {
+ clone = new RegExp(target);
+ map.set(target, clone);
+ return clone;
+ }
- // 澶勭悊鍏朵粬瀵硅薄锛堟櫘閫氬璞°�佺被瀹炰緥绛夛級
- clone = Object.create(Object.getPrototypeOf(target));
- map.set(target, clone);
+ // 澶勭悊鍑芥暟 (鐩存帴浣跨敤鍑芥暟鐨勫紩鐢�)
+ if (typeof target === 'function') {
+ return target;
+ }
- // 鑾峰彇鎵�鏈夊睘鎬э紙鍖呮嫭 Symbol 绫诲瀷锛�
- const allKeys = [...Object.getOwnPropertyNames(target), ...Object.getOwnPropertySymbols(target)];
+ // 澶勭悊鍏朵粬瀵硅薄锛堟櫘閫氬璞°�佺被瀹炰緥绛夛級
+ clone = Object.create(Object.getPrototypeOf(target));
+ map.set(target, clone);
- allKeys.forEach(key => {
- const descriptor = Object.getOwnPropertyDescriptor(target, key);
- if (descriptor && descriptor.enumerable) {
- // 閫掑綊澶嶅埗灞炴�у��
- clone[key] = deepClone(target[key], map);
- }
- });
+ // 鑾峰彇鎵�鏈夊睘鎬э紙鍖呮嫭 Symbol 绫诲瀷锛�
+ const allKeys = [...Object.getOwnPropertyNames(target), ...Object.getOwnPropertySymbols(target)];
- return clone;
- }
+ allKeys.forEach(key => {
+ const descriptor = Object.getOwnPropertyDescriptor(target, key);
+ if (descriptor && descriptor.enumerable) {
+ // 閫掑綊澶嶅埗灞炴�у��
+ clone[key] = deepClone(target[key], map);
+ }
+ });
- // uni-app 浣跨敤 灏佽璇锋眰鍑芥暟 浣跨敤浼犵粺鍑芥暟褰撲綔鍥炶皟闇�瑕佷紶that锛岀澶村嚱鏁颁笉闇�瑕�
- doRequest(url, data, resFunction, errFunction, method, that) {
- that = that || this;
- let errorTip = null;
- uni.showLoading({
- title: '鍔犺浇涓�...'
- })
- uni.request({
- method: method || "GET",
- url: this.serverUrl + url,
- data: data || "",
- success: (res) => {
- if (typeof resFunction === 'function') {
- resFunction.call(that, res)
- } else if (typeof errFunction === 'undefined' || errFunction === null) {
- return
- } else {
- throw new TypeError("璁块棶鎴愬姛鍥炶皟鍑芥暟绫诲瀷涓嶄负鍑芥暟鎴栬�呯┖!")
- }
- },
- fail: (err) => {
- console.error(err)
- errorTip = () => {
- uni.showToast({
- icon: "none",
- title: err.errMsg || err.data.message || "鎺ュ彛寮傚父!",
- duration: 2000
- })
- }
- if (typeof errFunction === 'function') {
- errFunction.call(that, err)
- } else if (typeof errFunction === 'undefined' || errFunction === null) {
- return
- } else {
- throw new TypeError("璁块棶澶辫触鍥炶皟鍑芥暟绫诲瀷涓嶄负鍑芥暟鎴栬�呯┖!")
- }
+ return clone;
+ }
- },
- complete() {
- setTimeout(() => {
- uni.hideLoading()
- if (errorTip != null) {
- errorTip()
- }
- }, 1000)
- }
- })
- }
+ // uni-app 浣跨敤 灏佽璇锋眰鍑芥暟 浣跨敤浼犵粺鍑芥暟褰撲綔鍥炶皟闇�瑕佷紶that锛岀澶村嚱鏁颁笉闇�瑕�
+ doRequest(url, data, resFunction, errFunction, method, that) {
+ that = that || this;
+ let errorTip = null;
+ uni.showLoading({
+ title: '鍔犺浇涓�...'
+ })
+ uni.request({
+ method: method || "GET",
+ url: this.serverUrl + url,
+ data: data || "",
+ success: (res) => {
+ if (typeof resFunction === 'function') {
+ resFunction.call(that, res)
+ } else if (typeof errFunction === 'undefined' || errFunction === null) {
+ return
+ } else {
+ throw new TypeError("璁块棶鎴愬姛鍥炶皟鍑芥暟绫诲瀷涓嶄负鍑芥暟鎴栬�呯┖!")
+ }
+ },
+ fail: (err) => {
+ console.error(err)
+ errorTip = () => {
+ uni.showToast({
+ icon: "none",
+ title: err.errMsg || err.data.message || "鎺ュ彛寮傚父!",
+ duration: 2000
+ })
+ }
+ if (typeof errFunction === 'function') {
+ errFunction.call(that, err)
+ } else if (typeof errFunction === 'undefined' || errFunction === null) {
+ return
+ } else {
+ throw new TypeError("璁块棶澶辫触鍥炶皟鍑芥暟绫诲瀷涓嶄负鍑芥暟鎴栬�呯┖!")
+ }
- // uni-app 鎾斁闊抽灏佽
- playSound(e) {
- const innerAudioContext = uni.createInnerAudioContext();
- if (e == 1) {
- innerAudioContext.src = '/static/success.wav';
- } else {
- innerAudioContext.src = '/static/jingbao.wav';
- }
- innerAudioContext.play(); // 鎾斁闊抽
- }
+ },
+ complete() {
+ setTimeout(() => {
+ uni.hideLoading()
+ if (errorTip != null) {
+ errorTip()
+ }
+ }, 1000)
+ }
+ })
+ }
+
+ // uni-app 鎾斁闊抽灏佽
+ playSound(e) {
+ const innerAudioContext = uni.createInnerAudioContext();
+ if (e == 1) {
+ innerAudioContext.src = '/static/success.wav';
+ } else {
+ innerAudioContext.src = '/static/jingbao.wav';
+ }
+ innerAudioContext.play(); // 鎾斁闊抽
+ }
}
-export const CommonUtils = Object.freeze(new commonUtils());
\ No newline at end of file
+export const CommonUtils = new commonUtils()
\ No newline at end of file
--
Gitblit v1.9.1