bug修复和添加防抖

This commit is contained in:
xiaofajia 2024-11-21 15:30:42 +08:00
parent 27375030c1
commit b00333d103
2 changed files with 88 additions and 76 deletions

View File

@ -199,6 +199,7 @@ export default {
}, },
// //
canClick:true, canClick:true,
subLoading: false
}; };
}, },
onLoad(data) { onLoad(data) {
@ -356,54 +357,60 @@ export default {
}) })
}, },
confirmOpe(type) { confirmOpe(type) {
if(this.selectWares.length==0){ if (!this.subLoading){
uni.showToast({ this.subLoading = true
title: '请选中要审核的配件!', if(this.selectWares.length==0){
icon: 'none' uni.showToast({
}) title: '请选中要审核的配件!',
return icon: 'none'
}
if (this.canClick) {
this.canClick = false
let url = '/admin-api/repair/tw/audit'
let dataObj = {
id: this.id,
type: "01",
status: "yes" == type ? "01" : "02"
}
try {
if (this.selectWares && this.selectWares.length > 0) {
dataObj.items = [...this.selectWares.map(item => {
return {
id: item.id
}
})]
} else {
dataObj.items = []
this.repairList.map((groupItem) => {
groupItem.twItemList.map((item) => {
dataObj.items.push({id: item.id})
})
})
}
request({
url: url,
method: 'POST',
data: dataObj
}).then((res) => {
this.canClick = true
if (res.code == 200) {
uni.showToast({
title: '审批成功!',
icon: 'none'
})
setTimeout(() => {
uni.navigateBack()
}, 700)
}
}) })
} catch (e) { this.subLoading = false
this.canClick = true return
}
if (this.canClick) {
this.canClick = false
let url = '/admin-api/repair/tw/audit'
let dataObj = {
id: this.id,
type: "01",
status: "yes" == type ? "01" : "02"
}
try {
if (this.selectWares && this.selectWares.length > 0) {
dataObj.items = [...this.selectWares.map(item => {
return {
id: item.id
}
})]
} else {
dataObj.items = []
this.repairList.map((groupItem) => {
groupItem.twItemList.map((item) => {
dataObj.items.push({id: item.id})
})
})
}
request({
url: url,
method: 'POST',
data: dataObj
}).then((res) => {
this.canClick = true
if (res.code == 200) {
uni.showToast({
title: '审批成功!',
icon: 'none'
})
setTimeout(() => {
uni.navigateBack()
}, 700)
}
this.subLoading = false
})
} catch (e) {
this.subLoading = false
this.canClick = true
}
} }
} }
}, },

View File

@ -96,7 +96,7 @@
<text class="label"></text> <text class="label"></text>
<text class="repairNum"></text> <text class="repairNum"></text>
<view class="submit" @click="submit" v-if="!isInput">保存</view> <view class="submit" @click="submit" v-if="!isInput">保存</view>
<view class="submit" @click="inWare" v-else>入库</view> <view class="submit" @click="inWare" v-else :disabled="subLoading">入库</view>
</view> </view>
</view> </view>
</template> </template>
@ -143,6 +143,7 @@ export default {
unitList: [], unitList: [],
query: null, query: null,
selectRows: [], selectRows: [],
subLoading: false
}; };
}, },
onLoad(data) { onLoad(data) {
@ -424,35 +425,39 @@ export default {
* 入库 * 入库
*/ */
inWare() { inWare() {
const data = { if (!this.subLoading){
id: this.soId, this.subLoading = true
soNo: createUniqueCodeByHead("RK") const data = {
} id: this.soId,
const values = this.partList.map(([key, value]) => value).reduce((acc, item) => acc.concat(item)) soNo: createUniqueCodeByHead("RK")
if (this.selectRows && this.selectRows.length > 0){
const ids = this.selectRows.map(item => item.id)
const newSelect = values.filter(item => ids.includes(item.id))
data.soiList = [...newSelect]
data.waresList = [...newSelect.map(item => item.wares)]
}else {
data.soiList = [...values]
data.waresList = [...values.map(item => item.wares)]
}
request({
url: '/admin-api/repair/so/inWare',
method: 'post',
data: data
}).then((res) => {
if (res.code == 200) {
uni.showToast({
title: '入库成功!',
icon: 'none'
})
setTimeout(() => {
uni.navigateBack()
}, 700)
} }
}) const values = this.partList.map(([key, value]) => value).reduce((acc, item) => acc.concat(item))
if (this.selectRows && this.selectRows.length > 0){
const ids = this.selectRows.map(item => item.id)
const newSelect = values.filter(item => ids.includes(item.id))
data.soiList = [...newSelect]
data.waresList = [...newSelect.map(item => item.wares)]
}else {
data.soiList = [...values]
data.waresList = [...values.map(item => item.wares)]
}
request({
url: '/admin-api/repair/so/inWare',
method: 'post',
data: data
}).then((res) => {
if (res.code == 200) {
uni.showToast({
title: '入库成功!',
icon: 'none'
})
setTimeout(() => {
uni.navigateBack()
}, 700)
}
this.subLoading = false
})
}
// this.partList.forEach(item => { // this.partList.forEach(item => {
// item.inCount = item.count // item.inCount = item.count
// item.goodsId = item.id // item.goodsId = item.id