From 736b2dcb48735b65701030901ed01fc5f0aed8c2 Mon Sep 17 00:00:00 2001
From: skyouc
Date: 星期一, 13 一月 2025 20:36:44 +0800
Subject: [PATCH] # 1. 添加自定义toast组件 2. 上架商品不显示问题修复 3. 播种库位订单绑定功能
---
pages/home/home.vue | 4 -
pages/pakin/putOn.vue | 38 +++++++-----
common/utils/toast.js | 17 +++++
main.js | 8 ++
pages/stock/orderBindSeed.vue | 113 +++++++++++++++++++++++++++++--------
5 files changed, 134 insertions(+), 46 deletions(-)
diff --git a/common/utils/toast.js b/common/utils/toast.js
new file mode 100644
index 0000000..ce546fd
--- /dev/null
+++ b/common/utils/toast.js
@@ -0,0 +1,17 @@
+
+function loading(title) {
+ uni.showLoading({
+ mask: true,
+ title: title,
+ })
+}
+
+function hideLoading() {
+ uni.hideLoading()
+}
+
+
+module.exports = {
+ loading,
+ hideLoading
+};
\ No newline at end of file
diff --git a/main.js b/main.js
index de7e8cc..429db57 100644
--- a/main.js
+++ b/main.js
@@ -9,8 +9,12 @@
import store from '@/store/index.js';
Vue.prototype.$store = store;
//鍏ㄥ眬鍏敤闈欐�佹暟鎹�
-import Mock from '@/common/mock/index.js';
-Vue.prototype.$Mock = Mock;
+import Mock from '@/common/mock/index.js';
+import toast from "@/common/utils/toast.js"
+
+
+Vue.prototype.$Mock = Mock;
+Vue.prototype.$toast = toast
App.mpType = 'app'
diff --git a/pages/home/home.vue b/pages/home/home.vue
index 0170a72..81891f9 100644
--- a/pages/home/home.vue
+++ b/pages/home/home.vue
@@ -163,9 +163,7 @@
},
- methods: {
-
-
+ methods: {
selectLoc() {
this.$refs['showLeft'].open()
},
diff --git a/pages/pakin/putOn.vue b/pages/pakin/putOn.vue
index 05309ac..8e889cd 100644
--- a/pages/pakin/putOn.vue
+++ b/pages/pakin/putOn.vue
@@ -105,21 +105,21 @@
fetchGoods() {
let that = this
setTimeout(() => {
- if (that.barcode.length < 1) {
- return
- }else if (that.barcode.length != 8) {
- this.messageToggle('error', '鎷栫洏鐮佷负8浣嶉殢鏈烘暟瀛楋紒锛�')
- return
- }
- }, 500)
-
- this.getMatnrBybarcode()
+ that.getMatnrBybarcode()
+ }, 800)
},
/**
* 鏍规嵁鎷栫洏鐮佹媺鍙栧凡缁勬嫋鏁版嵁
*/
getMatnrBybarcode() {
+ if (this.barcode.length < 1) {
+ return
+ }
+ if (this.barcode.length != 8) {
+ this.messageToggle('error', '鎷栫洏鐮佷负8浣嶉殢鏈烘暟瀛楋紒锛�')
+ return
+ }
let that = this
uni.request({
url: that.baseUrl + '/pda/barcode/matnr/' + that.barcode,
@@ -131,7 +131,6 @@
if (result.code === 200) {
that.dataList = result.data
}
- console.log(result)
}
})
},
@@ -150,7 +149,8 @@
comb() {
uni.vibrateShort();
- let that = this;
+ let that = this;
+ this.$toast.loading('鍔犺浇涓�...')
uni.request({
url: that.baseUrl + '/pda/matnr/in/barcode',
data: JSON.stringify({
@@ -161,10 +161,10 @@
header: {
'token': uni.getStorageSync('token')
},
- success(result) {
+ success(result) {
+ that.$toast.hideLoading()
var res = result.data
- if (res.code === 200) {
- that.resst();
+ if (res.code === 200) {
that.messageToggle('success', '涓婃灦鎴愬姛锛侊紒')
} else if (res.code == 403) {
that.messageText = res.msg
@@ -177,7 +177,14 @@
} else {
that.messageText = res.msg
that.messageToggle('error')
- }
+ }
+
+ },
+ fail() {
+ that.$toast.hideLoading()
+ },
+ complete() {
+ that.resst()
}
});
},
@@ -187,6 +194,7 @@
},
resst() {
+ this.dataList = []
this.barcode = ''
this.locno = ''
},
diff --git a/pages/stock/orderBindSeed.vue b/pages/stock/orderBindSeed.vue
index 4606f9a..2ae32b2 100644
--- a/pages/stock/orderBindSeed.vue
+++ b/pages/stock/orderBindSeed.vue
@@ -2,22 +2,37 @@
<view>
<view class="view-bg">
<uni-section title="鎾浣�" type="line" />
- <uni-data-select v-model="value" :localdata="range" @change="change" style="padding: 20rpx; height: 100rpx;background-color: white;">
+ <uni-data-select v-model="siteNo" :localdata="range" @change="change" style="padding: 20rpx; height: 100rpx;background-color: white;">
</uni-data-select>
</view>
<view class="view-bg">
<uni-section title="璁㈠崟" type="line" />
- <input maxlength="10" placeholder="PDA鎵弿绔欑偣鏍囩" v-model="orderNo"/>
+ <input placeholder="PDA鎵弿绔欑偣鏍囩" v-model="orderNo"/>
</view>
<view class="view-bg">
<uni-section title="瀹瑰櫒" type="line" />
- <input maxlength="10" placeholder="PDA鎵弿鎵樼洏/鏂欑鏍囩" v-model="barcode"/>
+ <input maxlength="8" placeholder="PDA鎵弿鎵樼洏/鏂欑鏍囩" v-model="barcode"/>
</view>
<view class="button-sp-buttom">
- <button class="btn-span" type="primary" @click="bindOrder">缁戝畾</button>
+ <button class="btn-span" type="primary" @click="bindOrder('bind')">缁戝畾</button>
<button class="btn-span" type="default">瑙g粦</button>
- </view>
+ </view>
+ <template>
+ <!-- 纭鍑哄簱 -->
+ <view>
+ <uni-popup ref="combConfirm" type="dialog">
+ <uni-popup-dialog :type="msgType" cancelText="鍙栨秷" confirmText="纭" :title="title" :content="content"
+ @confirm="confirm" @close="combClose"></uni-popup-dialog>
+ </uni-popup>
+ </view>
+ <view>
+ <!-- 鎻愮ず淇℃伅寮圭獥 -->
+ <uni-popup ref="message" type="message">
+ <uni-popup-message :type="msgType1" :message="messageText" :duration="2000"></uni-popup-message>
+ </uni-popup>
+ </view>
+ </template>
</view>
</template>
@@ -25,10 +40,14 @@
export default {
data() {
return {
- value: 0,
range: [],
orderNo: '',
- barcode: ''
+ barcode: '',
+ msgType1: '',
+ messageText: '',
+ msgType: '',
+ title: '',
+ content: '',
}
},
@@ -41,6 +60,7 @@
methods: {
getSeedLocs() {
let that = this
+ toast.loading('鍔犺浇涓�')
uni.request({
url: this.baseUrl + '/pda/pick/seed/locs',
header: {
@@ -53,12 +73,16 @@
let array = result.data
console.log(array)
that.range = array.map((item, index) => {
- return {text: item.siteNo, value: item.id}
+ return {text: item.siteNo, value: item.siteNo}
})
console.log(that.range)
}
}
+ },
+ complete() {
+ toast.hideLoading()
}
+
})
},
@@ -66,39 +90,76 @@
console.log("e:", e);
},
//缁戝畾璁㈠崟鑷虫挱绉嶅
- bindOrder() {
+ bindOrder(type) {
let that = this
+ if (this.barcode == undefined || this.barcode == '') {
+ this.messageToggle('error', '鎷栫洏鐮佷笉鑳戒负绌猴紒锛�')
+ return
+ }
+
+ if (this.orderNo == undefined || this.orderNo == '') {
+ this.messageToggle('error', '璁㈠崟缂栫爜涓嶈兘涓虹┖锛侊紒')
+ return
+ }
+
+ if (this.siteNo == undefined || this.siteNo == '') {
+ this.messageToggle('error', '鎾绔欑偣涓嶈兘涓虹┖锛侊紒')
+ return
+ }
+
+ if (type == undefined || type == null || type == null) {
+ type = 'bind'
+ }
+ toast.loading('缁戝畾涓�..')
uni.request({
url: that.baseUrl + "/pda/pick/seed/bind",
- data: {barcode: that.barcode, orderNo: that.orderNo, siteNo: '', type: 'bind'},
+ data: {barcode: that.barcode, orderNo: that.orderNo, siteNo: that.siteNo, type: type},
+ method: 'POST',
header: {
'token': uni.getStorageSync('token')
},
success(res) {
let result = res.data;
if (result.code === 200) {
-
+ toast.hideLoading()
+ this.messageToggle('success', '缁戝畾鎴愬姛锛�')
+ } else {
+ toast.hideLoading()
+ this.messageToggle('error', result.msg)
}
+ },
+ fail(res) {
+ toast.hideLoading()
+ this.messageToggle('error', '鏈嶅姟鍣ㄩ敊璇�')
+
+ },
+ complete() {
+ that.barcode = ''
+ that.orderNo = ''
+ that.siteNo = ''
}
})
},
//瑙g粦
unbindOrder() {
- let that = this
- uni.request({
- url: that.baseUrl + "/pda/pick/seed/bind",
- data: {barcode: that.barcode, orderNo: that.orderNo, siteNo: '', type: 'unbind'},
- header: {
- 'token': uni.getStorageSync('token')
- },
- success(res) {
- let result = res.data;
- if (result.code === 200) {
-
- }
- }
- })
- }
+ this.bindOrder('unbind')
+ },
+ //dialog寮规淇℃伅
+ dialogToggle(type,title, msg) {
+ this.msgType = type
+ this.title = title
+ this.content = msg
+ this.$refs.combConfirm.open()
+ },
+
+ //娑堟伅寮规
+ messageToggle(type, msg) {
+ this.msgType1 = type
+ if (msg != undefined || msg != null) {
+ this.messageText = msg
+ }
+ this.$refs.message.open()
+ },
}
}
</script>
--
Gitblit v1.9.1