考勤机绑定接口调试

This commit is contained in:
BianLzhaoMin 2025-10-21 11:18:27 +08:00
parent b75fbc37cd
commit 06c20c63e6
3 changed files with 124 additions and 35 deletions

View File

@ -77,7 +77,12 @@
<script setup name="bindSetting">
import { ref, onMounted } from 'vue'
import { getSubcontractorListAPI, getSubTeamContractListAPI } from '@/services/machine-setting'
import {
getSubcontractorListAPI,
getSubTeamContractListAPI,
unBindPmAttDeviceAPI,
confirmBindPmAttDeviceAPI,
} from '@/services/machine-setting'
const subPickerShow = ref(false)
const teamPickerShow = ref(false)
const subPickerColumns = ref([[]])
@ -93,6 +98,7 @@ const machineInfo = ref({
subName: '',
teamId: '',
teamName: '',
serialNumber: '',
})
//
@ -137,43 +143,87 @@ const onUnbind = () => {
uni.showModal({
title: '提示',
content: '确定要解除绑定吗?',
success: (res) => {
success: async (res) => {
if (res.confirm) {
// TODO:
console.log('解除绑定')
uni.showToast({
title: '解除绑定成功',
icon: 'success',
const res = await unBindPmAttDeviceAPI({
deviceCode: machineInfo.value.deviceCode,
})
if (res.code === 200) {
uni.showToast({
title: '解绑成功',
icon: 'success',
})
setTimeout(() => {
uni.navigateBack()
//
uni.$emit('refreshMachineList', {})
}, 1000)
} else {
uni.showToast({
title: res?.msg || '解绑失败',
icon: 'none',
})
}
}
},
})
}
//
const onConfirmBind = () => {
if (!machineInfo.value.subcontractorName) {
uni.showToast({
title: '请选择分包商',
icon: 'none',
})
return
}
const onConfirmBind = async () => {
// if (!machineInfo.value.subcontractorName) {
// uni.showToast({
// title: '',
// icon: 'none',
// })
// return
// }
if (!machineInfo.value.teamName) {
uni.showToast({
title: '请选择班组',
icon: 'none',
})
return
}
// if (!machineInfo.value.teamName) {
// uni.showToast({
// title: '',
// icon: 'none',
// })
// return
// }
// TODO:
console.log('确认绑定', machineInfo.value)
uni.showToast({
title: '绑定成功',
icon: 'success',
})
const { proId, deviceCode, deviceName, serialNumber, subId, teamId } = machineInfo.value
const params = {
proId,
deviceCode,
deviceName,
serialNumber,
subId,
teamId,
}
const res = await confirmBindPmAttDeviceAPI(params)
if (res.code === 200) {
uni.showToast({
title: '绑定成功',
icon: 'success',
})
setTimeout(() => {
uni.navigateBack()
//
uni.$emit('refreshMachineList', {})
}, 1000)
} else {
uni.showToast({
title: res?.msg || '绑定失败',
icon: 'none',
})
}
}
const onCancelSub = () => {
@ -209,9 +259,12 @@ onMounted(() => {
if (options.params) {
// TODO: ID
console.log('考勤机ID:', JSON.parse(options.params))
machineInfo.value = JSON.parse(options.params)
getSubcontractorListFun()
if (machineInfo.value.proId && machineInfo.value.subId) {
getSubTeamContractListFun()
}
}
})
</script>

View File

@ -74,7 +74,7 @@
<script setup name="machineSetting">
import { debounce } from 'lodash-es'
import { ref, computed, onMounted, nextTick } from 'vue'
import { ref, computed, onMounted, onUnmounted, nextTick } from 'vue'
import { getMachineListAPI } from '@/services/machine-setting.js'
import { useCommonStore } from '@/stores'
@ -89,6 +89,7 @@ const queryParams = ref({
pageNum: 1,
pageSize: 10,
deviceName: '',
proName: '',
})
//
@ -100,10 +101,17 @@ const onSearchName = () => {
}
//
const getMachineListFun = async () => {
const getMachineListFun = async (isRefresh = false) => {
const res = await getMachineListAPI(queryParams.value)
total.value = res?.total
machineList.value = [...machineList.value, ...res?.rows]
if (isRefresh) {
//
machineList.value = res?.rows || []
} else {
//
machineList.value = [...machineList.value, ...res?.rows]
}
}
//
@ -121,7 +129,17 @@ const hasMore = computed(() => {
//
const onMachineSettingItem = (item) => {
const { deviceCode, deviceName, proId, proName, subId, subName, teamId, teamName } = item
const {
deviceCode,
deviceName,
proId,
proName,
subId,
subName,
teamId,
teamName,
serialNumber,
} = item
const params = {
deviceCode,
deviceName,
@ -131,15 +149,33 @@ const onMachineSettingItem = (item) => {
subName,
teamId,
teamName,
serialNumber,
}
uni.navigateTo({
url: `/pages/machine-setting/components/bindSetting?params=${JSON.stringify(params)}`,
})
}
//
const handleRefreshMachineList = (eventData) => {
console.log('收到刷新机器列表事件:', eventData)
//
queryParams.value.pageNum = 1
//
getMachineListFun(true)
}
onMounted(() => {
queryParams.value.proName = commonStore?.activeProjectName
getMachineListFun()
//
uni.$on('refreshMachineList', handleRefreshMachineList)
})
//
onUnmounted(() => {
uni.$off('refreshMachineList', handleRefreshMachineList)
})
</script>

View File

@ -9,18 +9,18 @@ export const getMachineListAPI = (data) => {
})
}
// 考勤机解除绑定
export const getMachineUnbindAPI = (data) => {
export const unBindPmAttDeviceAPI = (data) => {
return http({
method: 'GET',
url: `/bmw/worker/**`,
method: 'POST',
url: `/bmw/pmAttDevice/updatePmAttDevice`,
data,
})
}
// 考勤机确认绑定
export const getMachineConfirmBindAPI = (data) => {
export const confirmBindPmAttDeviceAPI = (data) => {
return http({
method: 'GET',
url: `/bmw/worker/**`,
method: 'POST',
url: `/bmw/pmAttDevice/updatePmAttDevice`,
data,
})
}