考勤机绑定接口调试
This commit is contained in:
parent
b75fbc37cd
commit
06c20c63e6
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue