From 1234fa93988e8462cebc36aefa33511298cf93e6 Mon Sep 17 00:00:00 2001 From: yangan <yangan0921@163.com> Date: 星期一, 13 五月 2024 10:08:42 +0800 Subject: [PATCH] fix:冀中无人值守统计页面不显示数据bug --- pages/public-page/forward/forward.vue | 338 +++++++++++++++++++++++++++++++++++--------------------- 1 files changed, 212 insertions(+), 126 deletions(-) diff --git a/pages/public-page/forward/forward.vue b/pages/public-page/forward/forward.vue index 040efbe..d3a0cb2 100644 --- a/pages/public-page/forward/forward.vue +++ b/pages/public-page/forward/forward.vue @@ -15,7 +15,7 @@ <u-notice-bar :text="text" :fontSize="30"></u-notice-bar> <view class="notice-icon" - style="background: url('https://mx.jzeg.cn:9095/appimg/image/banner/notice.png') no-repeat;background-size: cover; width: 42rpx;height: 42rpx;"> + style="background: url('https://mx.jzeg.cn:9096/appimg/image/banner/notice.png') no-repeat;background-size: cover; width: 42rpx;height: 42rpx;"> </view> </view> <view v-else-if="roleType == 2" @@ -28,46 +28,53 @@ v-for="(val, index) in jhOrderPlanForwardList" :key="val.vid" :name="val.vid" - @click="deleteGroup(index, val)"> - <view class="forward-card"> - <view class="card-content"> - <u--form labelPosition="left" - :model="forwardForm" - ref="form1"> - <u-form-item label="杞彂瀵硅薄" - labelWidth="21%" - ref="item1" - @click="forwardObjectClick(index,val.name)"> - <u--input v-model="val.name" - placeholder="鐐瑰嚮閫夋嫨杞彂瀵硅薄" - :readonly="true" - border="bottom"></u--input> - </u-form-item> - <u-form-item label="杈撳叆鏁伴噺" - ref="item2" - labelWidth="21%"> - <view class="forward-card-amount"> - <view class="forward-card-amount-input"> - <u--input v-model="val.carNum" - placeholder="璇疯緭鍏ヨ浆鍙戞暟閲�" - @input="debouncecarNumInput(index, val.carNum)" - @blur="blurInput(index, val.carNum)" - border="bottom"></u--input> + @click="deleteGroup(index, val,val.xsUserId)"> + <view> + <view class="forward-card"> + <view :style="{ 'color': errorDataList.includes(index) ? '#f56c6c' : '' }" + class="error-tip" + v-show="errorDataList.includes(index)"> + * 姝ら」鏁版嵁閿欒,璇锋洿鏀瑰悗鍐嶆鎻愪氦 + </view> + <view class="card-content"> + <u--form labelPosition="left" + :model="forwardForm" + ref="form1"> + <u-form-item label="杞彂瀵硅薄" + labelWidth="21%" + ref="item1" + @click="forwardObjectClick(index,val.name,val.id)"> + <u--input v-model="val.name" + placeholder="鐐瑰嚮閫夋嫨杞彂瀵硅薄" + :readonly="true" + border="bottom"></u--input> + </u-form-item> + <u-form-item label="杈撳叆鏁伴噺" + ref="item2" + labelWidth="21%"> + <view class="forward-card-amount"> + <view class="forward-card-amount-input"> + <u--input v-model="val.carNum" + placeholder="璇疯緭鍏ヨ浆鍙戞暟閲�" + @input="debouncecarNumInput(index, val.carNum,val.xsUserId)" + @blur="blurInput(index, val.carNum,val.xsUserId)" + border="bottom"></u--input> + </view> + <u-checkbox-group v-model="val.checkboxValue1" + placement="column" + @change="v => checkboxChange(v, index, val,val.xsUserId)"> + <u-checkbox size="30" + shape="circle" + labelSize="30" + label="鍏ㄩ儴杞彂" + name="鍏ㄩ儴杞彂" + :disabled="val.ischecked" + :checked="val.isSelected"></u-checkbox> + </u-checkbox-group> </view> - <u-checkbox-group v-model="val.checkboxValue1" - placement="column" - @change="v => checkboxChange(v, index, val)"> - <u-checkbox size="30" - shape="circle" - labelSize="30" - label="鍏ㄩ儴杞彂" - name="鍏ㄩ儴杞彂" - :disabled="val.ischecked" - :checked="val.isSelected"></u-checkbox> - </u-checkbox-group> - </view> - </u-form-item> - </u--form> + </u-form-item> + </u--form> + </view> </view> </view> </u-swipe-action-item> @@ -147,50 +154,18 @@ console.log(params, '杞彂椤甸潰鐨勫弬鏁�'); // 瀹㈡埛 this.cars2 = Number(params.cars2); - this.tempcarNumSurplus1 = this.carNumSurplus1 = Number(params.carNumSurplus1); + this.tempcarNumSurplus1 = this.carNumSurplus1 = Number(params.carNumSurplus1 || 0); // 璐т唬 this.carNum = Number(params.carNum); - this.carNumSurplusHuodai = this.forwardSurplus = Number(params.carNumSurplusHuodai); + this.carNumSurplusHuodai = this.forwardSurplus = Number(params.carNumSurplusHuodai || 0); this.orderPlanId = params.orderPlanId; - this.$reqGet('forwardList', { OrderPlanId: params.orderPlanId }).then(res => { - if (res.data.length !== 0 && this.roleType == 1) { - this.jhOrderPlanForwardList = res.data.map((item, index) => { - return { - id: item.id, - orderPlanId: item.orderPlanId, - name: item.xsUserName === '' ? item.fleetName : item.xsUserName, - carNum: item.carNum, - xsUserId: item.xsUserId === '' ? 0 : item.xsUserId, - fleetId: item.fleetId === '' ? 0 : item.fleetId, - checkboxValue1: '', - vid: `${new Date().getTime()}${index}${item.id}` - }; - }); - } else if (res.data.length !== 0 && this.roleType == 2) { - this.jhOrderPlanForwardList = res.data.map((item, index) => { - return { - id: item.id, - orderPlanId: item.orderPlanId, - name: item.fleetName, - carNum: item.carNum, - xsUserId: item.xsUserId === '' ? 0 : item.xsUserId, - fleetId: item.fleetId === '' ? 0 : item.fleetId, - checkboxValue1: '', - vid: `${new Date().getTime()}${index}${item.id}` - }; - }); - } else { - this.jhOrderPlanForwardList = this.jhOrderPlanForwardList.map((item, index) => { - if (!item.orderPlanId) { - return { - ...item, - orderPlanId: params.orderPlanId, - vid: `${new Date().getTime()}${index}${item.id}` - }; - } - }); - } - }); + // 鍒ゆ柇鏄惁杞彂瀹屾垚 瀹屾垚鍒欎笉鍙啀娣诲姞 + if (this.roleType === 1) { + this.whetherClick = this.carNumSurplus1 === 0 + } else if (this.roleType === 2) { + this.whetherClick = this.forwardSurplus === 0 + } + this.getOrderPlan() }, data() { return { @@ -206,7 +181,7 @@ carNum: null, xsUserId: 0, fleetId: 0, - checkboxValue1: '', + checkboxValue1: '', //鍏ㄩ儴杞彂 isSelected: false }], // 绱㈠紩锛屽埄鐢ㄧ储寮曟纭樉绀� @@ -223,7 +198,7 @@ formNum: 1, // 涓汉杞彂鏁版嵁 personalForward: {}, - whetherClick: false, + whetherClick: false, //娣诲姞鎸夐挳 whetherClick1: false, // 婊戝姩鍗曞厓鏍奸厤缃� options1: [{ @@ -234,7 +209,10 @@ }], loading: false, //鎻愪氦loading originForwardName: '', //鍘熻浆鍙戝璞� - laterForwardName: '', //鍚庤浆鍙戝璞� + laterForwardName: '', //鍚庤浆鍙戝璞� + errorDataList: [], // 閿欒鏁版嵁 + isDirectAdd: false, // 鏄惁鏄湪鍘熸潵鏈夊璞$殑item淇敼 鏄殑涓簍rue + forwardId: '' //鍘熸潵鏈夊璞� 鐐瑰嚮璧嬪�� }; }, onShow() { @@ -256,6 +234,54 @@ } }, methods: { + getOrderPlan() { + uni.showLoading({ + title: '鍔犺浇涓�' + }) + this.$reqGet('forwardList', { OrderPlanId: this.orderPlanId }).then(res => { + uni.hideLoading() + if (res.data.length !== 0 && this.roleType == 1) { + this.jhOrderPlanForwardList = res.data.map((item, index) => { + return { + id: item.id, + orderPlanId: item.orderPlanId, + name: item.xsUserName === '' ? item.fleetName : item.xsUserName, + carNum: item.carNum, + xsUserId: item.xsUserId === '' ? 0 : item.xsUserId, + fleetId: item.fleetId === '' ? 0 : item.fleetId, + checkboxValue1: '', + vid: `${new Date().getTime()}${index}${item.id}`, + forWardType: item.xsUserId === '' ? 2 : 1 + }; + }); + } else if (res.data.length !== 0 && this.roleType == 2) { + this.jhOrderPlanForwardList = res.data.map((item, index) => { + return { + id: item.id, + orderPlanId: item.orderPlanId, + name: item.fleetName, + carNum: item.carNum, + xsUserId: item.xsUserId === '' ? 0 : item.xsUserId, + fleetId: item.fleetId === '' ? 0 : item.fleetId, + checkboxValue1: '', + vid: `${new Date().getTime()}${index}${item.id}`, + }; + }); + } else { + this.jhOrderPlanForwardList = this.jhOrderPlanForwardList.map((item, index) => { + if (!item.orderPlanId) { + return { + ...item, + orderPlanId: this.orderPlanId, + vid: `${new Date().getTime()}${index}${item.id}`, + }; + } + }); + } + }).catch(e => { + uni.hideLoading() + }) + }, // 杩斿洖涓婁竴椤� back() { uni.navigateBack({ @@ -293,7 +319,8 @@ return Number(x); } }, - checkboxChange(value, index, v) { + checkboxChange(value, index, v, xsUserId) { + this.$set(this.jhOrderPlanForwardList[index], 'forWardType', xsUserId ? 1 : 2); this.jhOrderPlanForwardList = this.jhOrderPlanForwardList.map(v => { return { ...v, @@ -336,10 +363,12 @@ }); }, // 杞彂 - forwardObjectClick(index, name) { + forwardObjectClick(index, name, id) { this.selectPopupShow = true; this.index = index; this.originForwardName = name || '' + this.isDirectAdd = this.originForwardName !== '' + this.forwardId = id }, selectPopupClose() { this.selectPopupShow = false; @@ -348,6 +377,30 @@ // 杞彂閫夋嫨璐т唬 forwardHuoDaiObjectSelect(item, index) { this.$nextTick(() => { + // let isableAdd = this.jhOrderPlanForwardList.filter(v => item.name === v.name); + // if (isableAdd.length > 0) { + // this.$u.toast('瀛樺湪閲嶅娣诲姞'); + // this.selectPopupShow = true; + // return + // } + // if (this.isDirectAdd) { + // if (this.originForwardName && this.originForwardName !== item.name && (this + // .carNumSurplus1 !== 0 || this.carNumSurplusHuodai !== 0)) { + // this.addForm(item.name) + // this.jhOrderPlanForwardList.forEach(v => { + // if (v.id === this.forwardId) { + // v.xsUserId = item.userId; + // v.name = item.name; + // v.fleetId = 0; + // v.forWardType = 1; + // } + // }) + // this.selectPopupShow = false; + // } else { + // this.$u.toast('鎻愮叅鍗曞墿浣欐暟涓�0鎴栧凡娣诲姞'); + // this.selectPopupShow = true; + // } + // } else { let isableAdd = this.jhOrderPlanForwardList.filter(v => item.name === v.name); if (isableAdd.length > 0) { this.$u.toast('瀛樺湪閲嶅娣诲姞'); @@ -357,15 +410,38 @@ this.jhOrderPlanForwardList[this.index].xsUserId = item.userId; this.jhOrderPlanForwardList[this.index].name = item.name; this.jhOrderPlanForwardList[this.index].fleetId = 0; - if (this.originForwardName) { - this.addForm(item.name) - } + this.jhOrderPlanForwardList[this.index].forWardType = 1; } + // } }); }, // 杞彂閫夋嫨杞﹂槦 forwardFleetObjectSelect(item, index) { this.$nextTick(() => { + // let isableAdd = this.jhOrderPlanForwardList.filter(v => item.name === v.name); + // if (isableAdd.length > 0) { + // this.$u.toast('瀛樺湪閲嶅娣诲姞'); + // this.selectPopupShow = true; + // return + // } + // if (this.isDirectAdd) { + // if (this.originForwardName && this.originForwardName !== item.name && (this + // .carNumSurplus1 !== 0 || this.carNumSurplusHuodai !== 0)) { + // this.addForm(item.name) + // this.jhOrderPlanForwardList.forEach(v => { + // if (v.id === this.forwardId) { + // v.xsUserId = item.userId; + // v.name = item.name; + // v.fleetId = 0; + // v.forWardType = 1; + // } + // }) + // this.selectPopupShow = false; + // } else { + // this.$u.toast('鎻愮叅鍗曞墿浣欐暟涓�0鎴栧凡娣诲姞'); + // this.selectPopupShow = true; + // } + // } else { let isableAdd = this.jhOrderPlanForwardList.filter(v => item.name === v.name); if (isableAdd.length > 0) { this.$u.toast('瀛樺湪閲嶅娣诲姞'); @@ -375,10 +451,9 @@ this.jhOrderPlanForwardList[this.index].fleetId = item.id; this.jhOrderPlanForwardList[this.index].name = item.name; this.jhOrderPlanForwardList[this.index].xsUserId = 0; - if (this.originForwardName) { - this.addForm(item.name) - } + this.jhOrderPlanForwardList[this.index].forWardType = 2; } + // } }); }, // 璁$畻鎻愮叅鍗曟暟閲忥紝娣诲姞鎴栧垹闄ゆ椂璋冪敤 @@ -387,11 +462,16 @@ return cur.carNum + prev; }, 0); console.log(total, '鎻愮叅鍗曚竴鍏辩殑鏁版嵁'); + //roleType 1瀹㈡埛 2 璐т唬 3鍙告満 5瑁呭嵏鍛� if (this.roleType == 1) { - if (Number(this.cars2) >= total) { + if (Number(this.cars2) > total) { this.carNumSurplus1 = Number(this.cars2) - total; this.whetherClick = false; this.whetherClick1 = false; + } else if (Number(this.cars2) == total) { //鍓╀綑鐨勬彁鐓ゅ崟涓�0锛堟坊鍔犮�佹彁浜ゆ寜閽笉鑳界偣鍑伙級 + this.whetherClick = true; + this.whetherClick1 = false; + this.carNumSurplus1 = Number(this.cars2) - total; } else { this.carNumSurplus1 = 0; this.$u.toast('鍓╀綑鎻愮叅鍗曟暟閲忎笉瓒�'); @@ -400,10 +480,14 @@ } } if (this.roleType == 2) { - if (Number(this.carNum) >= total) { + if (Number(this.carNum) > total) { this.carNumSurplusHuodai = Number(this.carNum) - total; this.whetherClick = false; this.whetherClick1 = false; + } else if (Number(this.carNum) == total) { + this.whetherClick = true; + this.whetherClick1 = false; + this.carNumSurplusHuodai = Number(this.carNum) - total; } else { this.carNumSurplusHuodai = 0; this.$u.toast('鍓╀綑鎻愮叅鍗曟暟閲忎笉瓒�'); @@ -412,10 +496,12 @@ } } }, - debouncecarNumInput(index, value) { + debouncecarNumInput(index, value, xsUserId) { let time; let that = this; that.$set(that.jhOrderPlanForwardList[index], 'carNum', Number(value)); + //forWardType 杞彂绫诲瀷 1璐т唬 2杞﹂槦 + that.$set(that.jhOrderPlanForwardList[index], 'forWardType', xsUserId ? 1 : 2); return (function() { if (!time) { time = setTimeout(() => { @@ -448,44 +534,32 @@ } })(); }, - blurInput(index, value) { + blurInput(index, value, xsUserId) { this.$set(this.jhOrderPlanForwardList[index], 'carNum', Number(value)); + this.$set(this.jhOrderPlanForwardList[index], 'forWardType', xsUserId ? 1 : 2); this.calculate(this.jhOrderPlanForwardList); }, // 娣诲姞涓�缁勮〃鍗� addForm(name) { // 鍒ゆ柇鏄惁鏈変竴涓閫夛紝濡傛灉鏈夊垯绂佹鏂板姞鐨勫閫夛紝娌℃湁鍒欎笉绂佹 let ischeck = this.jhOrderPlanForwardList.some(v => v.ischecked == true); - if (!ischeck) { - this.jhOrderPlanForwardList.push({ - orderPlanId: this.orderPlanId, - name: name || '', - carNum: null, - xsUserId: 0, - fleetId: 0, - checkboxValue1: '', - ischecked: false, - vid: new Date().getTime(), - isSelected: false - }); - } else { - this.jhOrderPlanForwardList.push({ - orderPlanId: this.orderPlanId, - name: name || '', - carNum: null, - xsUserId: 0, - fleetId: 0, - checkboxValue1: '', - ischecked: true, - vid: new Date().getTime(), - isSelected: false - }); - } + this.jhOrderPlanForwardList.push({ + orderPlanId: this.orderPlanId, + name: name || '', + carNum: null, + xsUserId: 0, + fleetId: 0, + checkboxValue1: '', + ischecked: ischeck, + vid: Math.random() * 100, + isSelected: false + }); this.calculate(this.jhOrderPlanForwardList); }, // 鍒犻櫎涓�缁勮〃鍗� - deleteGroup(index, v) { + deleteGroup(index, v, xsUserId) { let tempcarNum = v.carNum; + this.$set(this.jhOrderPlanForwardList[index], 'forWardType', xsUserId ? 1 : 2); if (v.id) { this.$reqPost('deleteForward', { id: v.id }, 'params').then(res => { if (res.code === 0) { @@ -523,7 +597,8 @@ this.loading = true; this.$reqPost('forward', this.jhOrderPlanForwardList, 'json').then(res => { console.log(res, 'zh'); - if (res.code == 0) { + // res.data.length == 0 鎻愪氦鎴愬姛 鍚﹀垯鎻愪氦澶辫触 + if (res.data.length == 0) { this.loading = false this.$u.toast('鎻愪氦鎴愬姛'); setTimeout(() => { @@ -531,9 +606,12 @@ }, 1000); } else { this.loading = false - this.$u.toast(res.msg); + this.errorDataList = res.data + this.$u.toast(res.msg ? res.msg : '鏁版嵁鏈夎,璇锋鏌�'); } - }); + }).catch(e => { + this.loading = false + }) } }, tabClick(item) { @@ -640,6 +718,14 @@ background: #ffffff; box-shadow: 4rpx 6rpx 25rpx 0rpx rgba(73, 120, 240, 0.15); border-radius: 20rpx; + position: relative; + + .error-tip { + position: absolute; + bottom: vww(5); + left: vww(22); + font-size: vww(14); + } .card-content { width: 612rpx; @@ -748,4 +834,4 @@ } } } -</style> \ No newline at end of file +</style> -- Gitblit v1.9.1