From 9d5b4d650e5b01081d3537c750e7469db4d161e3 Mon Sep 17 00:00:00 2001 From: 马宇豪 <978517621@qq.com> Date: 星期二, 29 四月 2025 08:53:20 +0800 Subject: [PATCH] 提交 --- pages/tabBar/firstPage/firstPage.vue | 107 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 91 insertions(+), 16 deletions(-) diff --git a/pages/tabBar/firstPage/firstPage.vue b/pages/tabBar/firstPage/firstPage.vue index 039b813..80a7434 100644 --- a/pages/tabBar/firstPage/firstPage.vue +++ b/pages/tabBar/firstPage/firstPage.vue @@ -13,7 +13,7 @@ </view> </view> <u-toast ref="uToast"></u-toast> - <view class="cardList"> + <view class="tabList" v-if="user.useProd == 1"> <view class="switchPanel"> <view class="switchBtns"> <view class="btnItem" @click="changeTab(1)"> @@ -59,7 +59,7 @@ <view> 入库时间:{{tabNum == 1?hazmat.createTime:product.createTime}} </view> - <view v-if="modalTitle == '取用' || modalTitle == '扫码作废'"> + <view v-if="modalTitle == '常规取用' || modalTitle == '用尽取用' || modalTitle == '扫码作废'"> <span v-if="tabNum == 1">当前包装存量:{{hazmat.remaining}}{{hazmat.hazmatBasic?hazmat.hazmatBasic.unit:''}}</span> <span v-else>当前包装存量:{{product.remaining}}{{product.productBasic?product.productBasic.unit:''}}</span> </view> @@ -82,7 +82,8 @@ </u-form-item> </u--form> </view> - <u-button v-if="modalTitle == '取用'" type="primary" style="margin-top: 20px" text="确认取用" @click="confirmTake()"></u-button> + <u-button v-if="modalTitle == '常规取用'" type="primary" style="margin-top: 20px" text="确认取用" @click="confirmTake1()"></u-button> + <u-button v-if="modalTitle == '用尽取用'" type="primary" style="margin-top: 20px" text="确认取用" @click="confirmTake2()"></u-button> <u-button v-if="modalTitle == '归还'" type="primary" style="margin-top: 20px" text="确认归还" @click="confirmBack()"></u-button> <u-button v-if="modalTitle == '用尽登记'" type="warning" style="margin-top: 20px" text="确认用尽登记" @click="confirmCheck()"></u-button> <u-button v-if="modalTitle == '销售'" type="primary" style="margin-top: 20px" text="确认销售" @click="confirmSell()"></u-button> @@ -100,10 +101,12 @@ postHazmatUse, postHazmatUsed, postHazmatDiscard, - postProductDiscard, getProductByCode, postProductSold + postProductDiscard, getProductByCode, postProductSold, + getUserInfo } from '../../../api/index.js' import VUE_APP_BASE_URL from 'common/constant.js' import take from '../../../static/take.png' + import takeAll from '../../../static/takeAll.png' import takeBack from '../../../static/return.png' import check from '../../../static/check.png' import del from '../../../static/delete.png' @@ -120,8 +123,13 @@ cardList1: [ { icon: take, - title: '取用', + title: '常规取用', type: 1 + }, + { + icon: takeAll, + title: '用尽取用', + type: 5 }, { icon: takeBack, @@ -159,6 +167,7 @@ id: null, remaining: '' }, + user: {}, rules: { remaining: { type: 'string', @@ -168,7 +177,7 @@ } }, tabNum: 1, - blockText: '原材料', + blockText: '危化品', blockStyle: { transform: 'translateX(0px)' } @@ -188,18 +197,39 @@ }, created(){ uni.hideTabBar() + this.getUserInfo() }, mounted() { }, methods: { + getUserInfo(){ + getUserInfo().then(res => { + if(res.code == 200) { + this.user = res.data + uni.setStorageSync('userSet', res.data) + }else{ + uni.$u.toast(res.message) + } + }) + }, + scanCode(title){ const t = this t.modalTitle = title uni.scanCode({ autoZoom: false, + scanType: ['qrCode'], success: function (res) { if(res && res.result){ + if(res.result.indexOf('SJ') == -1 && res.result.indexOf('CP') == -1){ + t.$refs.uToast.show({ + type: 'default', + message: '没有识别到正确的编码,请重新扫码', + duration: 2000 + }) + return + } if(t.tabNum == 1){ getHazmatByCode({code: res.result}).then((re)=>{ if(re.code == 200){ @@ -245,9 +275,9 @@ }) }, - confirmTake(){ + confirmTake1(){ const t = this - postHazmatUse(t.hazmat.id).then((r)=>{ + postHazmatUse(t.hazmat.id,0).then((r)=>{ if(r.code == 200){ t.$refs.uToast.show({ type: 'default', @@ -265,8 +295,31 @@ duration: 2000 }) }) - t.showModal = false + t.closeModal() }, + + confirmTake2(){ + const t = this + postHazmatUse(t.hazmat.id,1).then((r)=>{ + if(r.code == 200){ + t.$refs.uToast.show({ + type: 'default', + message: r.message + }) + }else{ + t.$refs.uToast.show({ + type: 'default', + message: r.message + }) + } + }).catch((err) => { + uni.showToast({ + title: err, + duration: 2000 + }) + }) + t.closeModal() + }, confirmBack() { const t = this @@ -291,8 +344,7 @@ duration: 2000 }) }) - t.showModal = false - t.hazmatBack.remaining = '' + t.closeModal() }).catch(errors => { uni.$u.toast('请完善必填信息') }) @@ -318,7 +370,7 @@ duration: 2000 }) }) - t.showModal = false + t.closeModal() }, confirmSell(){ @@ -341,7 +393,7 @@ duration: 2000 }) }) - t.showModal = false + t.closeModal() }, confirmCancle(){ @@ -385,7 +437,7 @@ }) }) } - t.showModal = false + t.closeModal() }, closeModal(){ @@ -444,7 +496,7 @@ left: 0; right: 0; width: 100%; - z-index: 1; + z-index: 9999; } .barText{ /* text-align: center; */ @@ -471,6 +523,23 @@ width: 100%; } } + +.tabList{ + width: 100%; + box-sizing: border-box; + padding: 0 15px; + margin-top: 15px; + display: flex; + flex-direction: column; + align-items: center; + position: -webkit-sticky; + position: sticky; + top: 50px; + left: 0; + right: 0; + z-index: 9998; +} + .switchPanel{ width: 100%; height: 84rpx; @@ -479,6 +548,7 @@ box-sizing: border-box; border-radius: 8px; box-shadow: 0px -6px 10px rgba(255, 255, 255, 1), 0px 4px 15px rgba(0, 0, 0, 0.1),0px 3px 6px rgba(0, 0, 0, 0.05) inset !important; + background: #f5f7fa; .switchBtns{ width: 100%; @@ -520,11 +590,12 @@ border: 2rpx solid #fff; } } + .cardList{ width: 100%; box-sizing: border-box; padding: 0 15px; - margin-top: 20px; + margin-top: 15px; display: flex; flex-direction: column; align-items: center; @@ -546,6 +617,10 @@ box-shadow: none; } + &:last-of-type{ + margin-bottom: 75px; + } + .cardTit{ font-size: 36rpx; font-weight: bold; -- Gitblit v1.9.2