This commit is contained in:
bb_pan 2025-06-21 17:36:59 +08:00
parent 18babde1f1
commit 3994c9acb9
7 changed files with 53 additions and 28 deletions

View File

@ -202,13 +202,15 @@ const getCodeDetailData = async (id, publishTask, typeId) => {
// //
const getCodeDeviceListData = async () => { const getCodeDeviceListData = async () => {
// ID
const checkedIds = codeDeviceList.value.filter(e => e.checked).map(e => e.maId)
const res = await getCodeDeviceListAPI(queryCodeParams.value) const res = await getCodeDeviceListAPI(queryCodeParams.value)
codeDeviceList.value.push(...res.rows) // checked
if (codeDeviceList.value.length > 0) { const newRows = res.rows.map(e => ({
codeDeviceList.value = codeDeviceList.value.map((e) => { ...e,
return { ...e, checked: false } checked: checkedIds.includes(e.maId)
}) }))
} codeDeviceList.value.push(...newRows)
total.value = res.total total.value = res.total
} }

View File

@ -27,7 +27,7 @@
style="background: #fff; padding: 10px; margin: 5px; border-radius: 5px" style="background: #fff; padding: 10px; margin: 5px; border-radius: 5px"
> >
<uni-col :span="6"> <uni-col :span="6">
<view class="btnBox complete" @click="saveCode"> 维修完成 </view> <view class="btnBox complete" @click="saveCode"> 提交 </view>
</uni-col> </uni-col>
</uni-row> </uni-row>
<scroll-view scroll-y style="padding-bottom: 20rpx"> <scroll-view scroll-y style="padding-bottom: 20rpx">
@ -393,17 +393,18 @@ const saveCode = () => {
let index2 = partItems.value.findIndex((v) => v.partNum == 0) let index2 = partItems.value.findIndex((v) => v.partNum == 0)
if (repairPerson.value == '') { if (repairPerson.value == '') {
uni.showToast({ title: '请先选择维修人员!', icon: 'none' }) uni.showToast({ title: '请先选择维修人员!', icon: 'none' })
} else if (index1 > -1) {
uni.showToast({ title: '请先选择配件类型!', icon: 'none' })
} else if (index2 > -1) {
uni.showToast({ title: '请填写配件数量!', icon: 'none' })
} else { } else {
saveCodeApi() saveCodeApi()
} }
} }
} }
const loading = ref(false)
// //
const saveCodeApi = async () => { const saveCodeApi = async () => {
if (loading.value) {
uni.showToast({ title: '请勿重复提交!', icon: 'none' })
}
loading.value = true
// //
rowData.value = queryParams.value rowData.value = queryParams.value
// //
@ -433,14 +434,19 @@ const saveCodeApi = async () => {
// 1 // 1
rowData.value.repairDeviceList[i].repairType = 1; rowData.value.repairDeviceList[i].repairType = 1;
} }
console.log(rowData.value.repairDeviceList) // console.log('🚀 ~ saveCodeApi ~ :', rowData.value.repairDeviceList)
saveRepairRow(rowData.value.repairDeviceList).then(async (response) => { const params = rowData.value.repairDeviceList.filter(item => queryParams.value.selectedCodes.includes(item.code))
console.log('🚀 ~ saveCodeApi ~ params:', params)
saveRepairRow(params).then(async (response) => {
if (response.code == 200) { if (response.code == 200) {
uni.showToast({ title: '保存成功', icon: 'none' }) uni.showToast({ title: '保存成功', icon: 'none' })
uni.navigateBack({ uni.navigateBack({
delta: 2, // delta: 2, //
}) })
} }
loading.value = false
}).catch(() => {
loading.value = false
}) })
} }
</script> </script>

View File

@ -36,7 +36,7 @@
<view class="btnBox scrap" @click="changeTab(3)"> 待报废 </view> <view class="btnBox scrap" @click="changeTab(3)"> 待报废 </view>
</uni-col> </uni-col>
<uni-col :span="6"> <uni-col :span="6">
<view class="btnBox complete" @click="saveCode"> 维修完成 </view> <view class="btnBox complete" @click="saveCode"> 提交 </view>
</uni-col> </uni-col>
</uni-row> </uni-row>
<scroll-view scroll-y style="padding-bottom: 20rpx"> <scroll-view scroll-y style="padding-bottom: 20rpx">

View File

@ -99,6 +99,7 @@ const queryParams = ref({})
const allChecked = ref(false) const allChecked = ref(false)
const repairDeviceList = ref([]) const repairDeviceList = ref([])
const selectedItems = ref([]) const selectedItems = ref([])
const ids = ref([])
const selectableItems = computed(() => { const selectableItems = computed(() => {
return repairDeviceList.value.filter(item => item.status === '0').map(item => item.code) return repairDeviceList.value.filter(item => item.status === '0').map(item => item.code)
@ -106,32 +107,42 @@ const selectableItems = computed(() => {
onLoad((options) => { onLoad((options) => {
queryParams.value = JSON.parse(options.queryParams) queryParams.value = JSON.parse(options.queryParams)
console.log(queryParams.value) console.log('🚀 ~ onLoad ~ queryParams.value:', queryParams.value)
repairDeviceList.value = queryParams.value.repairDeviceList; repairDeviceList.value = queryParams.value.repairDeviceList;
console.log(repairDeviceList.value) console.log(repairDeviceList.value)
}) })
const handleSelectAll = (e) => { const handleSelectAll = (e) => {
console.log('🚀 ~ handleSelectAll ~ e:', e)
const checked = e.detail.value.length > 0 const checked = e.detail.value.length > 0
allChecked.value = checked allChecked.value = checked
if (checked) { if (checked) {
selectedItems.value = [...selectableItems.value] selectedItems.value = [...selectableItems.value]
ids.value = repairDeviceList.value.filter(item => selectedItems.value.includes(item.code)).map(item => item.id)
console.log('🚀 ~ handleSelectAll ~ ids.value:', ids.value)
} else { } else {
selectedItems.value = [] selectedItems.value = []
ids.value = []
} }
} }
const handleItemCheck = (code) => { const handleItemCheck = (code) => {
console.log('🚀 ~ handleItemCheck ~ code:', code)
// Only allow selection if item is status '0' // Only allow selection if item is status '0'
const item = repairDeviceList.value.find(i => i.code === code) const item = repairDeviceList.value.find(i => i.code === code)
console.log('🚀 ~ handleItemCheck ~ item:', item)
if (item && item.status !== '0') return if (item && item.status !== '0') return
const index = selectedItems.value.indexOf(code) const index = selectedItems.value.indexOf(code)
console.log('🚀 ~ handleItemCheck ~ index:', index)
if (index === -1) { if (index === -1) {
selectedItems.value.push(code) selectedItems.value.push(code)
ids.value.push(item.id)
} else { } else {
selectedItems.value.splice(index, 1) selectedItems.value.splice(index, 1)
ids.value.splice(index, 1)
} }
console.log('🚀 ~ handleItemCheck ~ ids.value:', ids.value)
allChecked.value = selectedItems.value.length === selectableItems.value.length allChecked.value = selectedItems.value.length === selectableItems.value.length
} }
@ -148,7 +159,7 @@ const goOperate = (item,index) => {
const onQualified = async () => { const onQualified = async () => {
console.log(queryParams.value.ids[1]) console.log(queryParams.value.ids[1])
let id = [queryParams.value.ids[1]] let id = [queryParams.value.ids[1]]
const res = await auditRepairPass(id) const res = await auditRepairPass(ids.value)
if (res.code === 200) { if (res.code === 200) {
uni.showToast({ uni.showToast({
title: '操作成功!', title: '操作成功!',

View File

@ -227,7 +227,7 @@ onShow(() => {
// //
onLoad((options) => { onLoad((options) => {
taskId.value = options.taskId taskId.value = options.taskId
getRepairDetailsData() // getRepairDetailsData()
// //
uni.$on('onUpdate', () => { uni.$on('onUpdate', () => {
// //

View File

@ -193,7 +193,7 @@ const getTableList = async (isTap = false) => {
if (res.data.rows.length == 0) { if (res.data.rows.length == 0) {
tableList.value = [] tableList.value = []
} else { } else {
tableList.value.push(...res.data.rows) tableList.value = res.data.rows
} }
} }
} }
@ -213,7 +213,7 @@ onShow(() => {
const onScrollTolower = debounce(() => { const onScrollTolower = debounce(() => {
console.log('触底事件') console.log('触底事件')
if (total.value > tableList.value.length) { if (total.value > tableList.value.length) {
queryParams.value.pageNum++ queryParams.value.pageSize += 5
getTableList() getTableList()
} }
}, 500) }, 500)

View File

@ -4,7 +4,7 @@
<uni-row :gutter="24" class="search-form"> <uni-row :gutter="24" class="search-form">
<uni-col :span="6"> <uni-col :span="6">
<view class="search" @click="saveNumAll"> <view class="search" @click="saveNumAll">
维修完成 提交
</view> </view>
</uni-col> </uni-col>
</uni-row> </uni-row>
@ -223,6 +223,7 @@ import treeSelect from '../tree-select/tselectTwo.vue';
import {onLoad, onShow} from '@dcloudio/uni-app' import {onLoad, onShow} from '@dcloudio/uni-app'
// const query = defineProps() // // const query = defineProps() //
// const queryParams = JSON.parse(query.queryParams) // const queryParams = JSON.parse(query.queryParams)
const loading = ref(false)
const queryParams = ref({}) const queryParams = ref({})
const rowData = ref({}) const rowData = ref({})
onLoad((options) => { onLoad((options) => {
@ -521,19 +522,17 @@ const saveNumAll = async () => {
uni.showToast({ title: '请先选择维修人员!', icon: 'none' }) uni.showToast({ title: '请先选择维修人员!', icon: 'none' })
}else if((formLeft.value.repairNum + formMiddle.value.repairNum + formRight.value.scrapNum)==0){ }else if((formLeft.value.repairNum + formMiddle.value.repairNum + formRight.value.scrapNum)==0){
uni.showToast({ title: '请选择维修类型并填写维修数量!', icon: 'none' }) uni.showToast({ title: '请选择维修类型并填写维修数量!', icon: 'none' })
}else if(formLeft.value.repairNum>0&&partItems.value.findIndex(v => v.partId == '')>-1){
uni.showToast({ title: '内部维修请选择配件!', icon: 'none' })
}else if(formLeft.value.repairNum>0&&partItems.value.findIndex(v => v.partNum == 0)>-1){
uni.showToast({ title: '内部维修请填写配件数量!', icon: 'none' })
}else if(formMiddle.value.repairNum>0&&(formMiddle.value.supplierId==undefined||formMiddle.value.supplierId=='')){ }else if(formMiddle.value.repairNum>0&&(formMiddle.value.supplierId==undefined||formMiddle.value.supplierId=='')){
uni.showToast({ title: '返厂维修请选择厂家!', icon: 'none' }) uni.showToast({ title: '返厂维修请选择厂家!', icon: 'none' })
}else if(formMiddle.value.repairNum>0&&partItemsMiddle.value.findIndex(v => v.partName == '')>-1){
uni.showToast({ title: '返厂维修请填写配件名称!', icon: 'none' })
}else if(formMiddle.value.repairNum>0&&partItemsMiddle.value.findIndex(v => v.partNum == 0)>-1){
uni.showToast({ title: '返厂维修请填写配件数量!', icon: 'none' }) //partPrice == 0 uni.showToast({ title: '', icon: 'none' })
}else if(formRight.value.scrapNum>0&&formRight.value.scrapReason==''){ }else if(formRight.value.scrapNum>0&&formRight.value.scrapReason==''){
uni.showToast({ title: '维修报废请填写报废原因!', icon: 'none' }) uni.showToast({ title: '维修报废请填写报废原因!', icon: 'none' })
}else { }else {
if (loading.value) {
uni.showToast({ title: '请勿重复提交!', icon: 'none' })
return
}
loading.value = true
uni.showLoading({ title: '提交中...' })
// //
rowData.value.repairDeviceList[0].repairList=[ rowData.value.repairDeviceList[0].repairList=[
{ {
@ -568,12 +567,19 @@ const saveNumAll = async () => {
rowData.value.repairDeviceList[0].repairType = 1 rowData.value.repairDeviceList[0].repairType = 1
console.log(rowData.value.repairDeviceList) console.log(rowData.value.repairDeviceList)
saveRepairRow(rowData.value.repairDeviceList).then(async (response) => { saveRepairRow(rowData.value.repairDeviceList).then(async (response) => {
loading.value = false
uni.hideLoading()
if (response.code == 200) { if (response.code == 200) {
uni.showToast({ title: '保存成功', icon: 'none' }) uni.showToast({ title: '保存成功', icon: 'none' })
uni.navigateBack({ uni.navigateBack({
delta: 1, // delta: 1, //
}) })
} }
}).catch(() => {
loading.value = false
uni.hideLoading()
}) })
} }
} }