增加考勤机管理接口调试

This commit is contained in:
BianLzhaoMin 2025-12-01 18:20:58 +08:00
parent 8e141943e1
commit 0f4440dfeb
4 changed files with 382 additions and 286 deletions

View File

@ -3,7 +3,7 @@ import request from '@/utils/request'
// 获取工程和考勤机树形数据 // 获取工程和考勤机树形数据
export function getProjectAndMacTreeAPI() { export function getProjectAndMacTreeAPI() {
return request({ return request({
url: '/system/attMacManage/tree', url: '/bmw/kqManager/getProKqjTree',
method: 'get', method: 'get',
}) })
} }
@ -11,7 +11,7 @@ export function getProjectAndMacTreeAPI() {
// 根据考勤机编号获取人员列表 // 根据考勤机编号获取人员列表
export function getPersonListByMacNoAPI(params) { export function getPersonListByMacNoAPI(params) {
return request({ return request({
url: '/system/attMacManage/personList', url: '/bmw/kqManager/getWorkerByDeviceId',
method: 'get', method: 'get',
params, params,
}) })
@ -20,17 +20,18 @@ export function getPersonListByMacNoAPI(params) {
// 获取所有人员列表 // 获取所有人员列表
export function getAllPersonListAPI(params) { export function getAllPersonListAPI(params) {
return request({ return request({
url: '/system/attMacManage/allPersonList', url: '/bmw/kqManager/getProDeviceWorker',
method: 'get', method: 'get',
params, params,
}) })
} }
// 删除人员 // 删除人员
export function deletePersonAPI(id) { export function deletePersonAPI(data) {
return request({ return request({
url: '/system/attMacManage/deletePerson/' + id, url: '/bmw/kqManager/delWorkerByDevice/',
method: 'post', method: 'post',
data,
}) })
} }
@ -46,7 +47,7 @@ export function batchDeletePersonAPI(ids) {
// 下发 // 下发
export function sendDownAPI(data) { export function sendDownAPI(data) {
return request({ return request({
url: '/system/attMacManage/sendDown', url: '/bmw/kqManager/pushWorkerByDevice',
method: 'post', method: 'post',
data, data,
}) })
@ -64,17 +65,17 @@ export function configAPI(data) {
// 刷新 // 刷新
export function refreshAPI(macNo) { export function refreshAPI(macNo) {
return request({ return request({
url: '/system/attMacManage/refresh', url: '/bmw/kqManager/refreshDevice',
method: 'post', method: 'post',
data: { macNo }, data: { deviceCode: macNo },
}) })
} }
// 重启 // 重启
export function restartAPI(macNo) { export function restartAPI(macNo) {
return request({ return request({
url: '/system/attMacManage/restart', url: '/bmw/kqManager/restartDevice',
method: 'post', method: 'post',
data: { macNo }, data: { deviceCode: macNo },
}) })
} }

View File

@ -41,7 +41,7 @@ export default {
treeData: [], treeData: [],
defaultProps: { defaultProps: {
children: 'children', children: 'children',
label: 'label', label: 'name',
}, },
} }
}, },
@ -58,6 +58,7 @@ export default {
async getTreeData() { async getTreeData() {
try { try {
const res = await getProjectAndMacTreeAPI() const res = await getProjectAndMacTreeAPI()
if (res.code === 200) { if (res.code === 200) {
this.treeData = res.data || [] this.treeData = res.data || []
} }
@ -103,7 +104,7 @@ export default {
// //
filterNode(value, data) { filterNode(value, data) {
if (!value) return true if (!value) return true
return data.label.indexOf(value) !== -1 return data.name.indexOf(value) !== -1
}, },
// //
handleNodeClick(data) { handleNodeClick(data) {

View File

@ -1,75 +1,190 @@
<template> <template>
<el-card class="table-card" shadow="hover"> <div>
<div class="table-container"> <el-card class="table-card" shadow="hover">
<TableModel <div class="table-container">
:formLabel="formLabel" <TableModel
:columnsList="columnsList" :formLabel="formLabel"
:request-api="requestApi" :columnsList="columnsList"
:showOperation="true" :request-api="requestApi"
:isSelectShow="true" :showOperation="true"
:sendParams="sendParams" :isSelectShow="true"
ref="tableRef" :sendParams="sendParams"
> ref="tableRef"
<template slot="btn"> >
<el-button <template slot="btn">
size="mini" <el-button
type="danger" size="mini"
icon="el-icon-delete" type="danger"
:disabled="selectedData.length === 0" icon="el-icon-delete"
@click="handleBatchDelete" :disabled="selectedData.length === 0"
> @click="handleBatchDelete"
批量删除 >
批量删除
</el-button>
<el-button
size="mini"
type="primary"
icon="el-icon-download"
@click="handleSendDown"
>
下发
</el-button>
<el-button
size="mini"
type="primary"
icon="el-icon-setting"
@click="handleConfig"
>
配置
</el-button>
<el-button
size="mini"
type="success"
icon="el-icon-refresh"
@click="handleRefresh"
>
刷新
</el-button>
<el-button
size="mini"
type="warning"
icon="el-icon-switch-button"
@click="handleRestart"
>
重启
</el-button>
</template>
<template slot="handle" slot-scope="{ data }">
<el-button
size="mini"
type="danger"
icon="el-icon-delete"
@click="handleDelete(data)"
>
删除
</el-button>
</template>
</TableModel>
</div>
</el-card>
<!-- 下发弹框 -->
<DialogModel
:dialogConfig="sendDownDialogConfig"
@closeDialogOuter="handleCloseSendDownDialog"
>
<template slot="outerContent">
<el-form
ref="sendDownFormRef"
:model="sendDownFormData"
:rules="sendDownFormRules"
label-width="120px"
>
<el-form-item label="选择人员:" prop="personIds">
<el-select
v-model="sendDownFormData.personIds"
multiple
filterable
placeholder="请选择人员"
style="width: 100%"
:loading="personListLoading"
>
<el-option
v-for="item in personList"
:key="item.id"
:label="`${item.name}(${item.idNumber})`"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="下发内容:" prop="content">
<el-input
v-model="sendDownFormData.content"
type="textarea"
:autosize="{ minRows: 4, maxRows: 8 }"
placeholder="请输入下发内容"
clearable
maxlength="500"
show-word-limit
/>
</el-form-item>
</el-form>
<el-row class="dialog-footer-btn">
<el-button size="medium" @click="handleCloseSendDownDialog">
取消
</el-button> </el-button>
<el-button <el-button
size="mini" size="medium"
type="primary" type="primary"
icon="el-icon-download" @click="handleSendDownSubmit"
@click="handleSendDown"
> >
下发 确定
</el-button>
</el-row>
</template>
</DialogModel>
<!-- 配置弹框 -->
<DialogModel
:dialogConfig="configDialogConfig"
@closeDialogOuter="handleCloseConfigDialog"
>
<template slot="outerContent">
<el-form
ref="configFormRef"
:model="configFormData"
:rules="configFormRules"
label-width="120px"
>
<el-form-item label="选择人员:" prop="personIds">
<el-select
v-model="configFormData.personIds"
multiple
filterable
placeholder="请选择人员"
style="width: 100%"
:loading="personListLoading"
>
<el-option
v-for="item in personList"
:key="item.id"
:label="`${item.name}(${item.idNumber})`"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="配置项:" prop="configItem">
<el-input
v-model="configFormData.configItem"
type="textarea"
:autosize="{ minRows: 4, maxRows: 8 }"
placeholder="请输入配置项"
clearable
maxlength="500"
show-word-limit
/>
</el-form-item>
</el-form>
<el-row class="dialog-footer-btn">
<el-button size="medium" @click="handleCloseConfigDialog">
取消
</el-button> </el-button>
<el-button <el-button
size="mini" size="medium"
type="primary" type="primary"
icon="el-icon-setting" @click="handleConfigSubmit"
@click="handleConfig"
> >
配置 确定
</el-button> </el-button>
<el-button </el-row>
size="mini" </template>
type="success" </DialogModel>
icon="el-icon-refresh" </div>
@click="handleRefresh"
>
刷新
</el-button>
<el-button
size="mini"
type="warning"
icon="el-icon-switch-button"
@click="handleRestart"
>
重启
</el-button>
</template>
<template slot="handle" slot-scope="{ data }">
<el-button
size="mini"
type="danger"
icon="el-icon-delete"
@click="handleDelete(data)"
>
删除
</el-button>
</template>
</TableModel>
</div>
</el-card>
</template> </template>
<script> <script>
import TableModel from '@/components/TableModel' import TableModel from '@/components/TableModel'
import DialogModel from '@/components/DialogModel'
import { import {
getPersonListByMacNoAPI, getPersonListByMacNoAPI,
getAllPersonListAPI, getAllPersonListAPI,
@ -77,18 +192,25 @@ import {
batchDeletePersonAPI, batchDeletePersonAPI,
refreshAPI, refreshAPI,
restartAPI, restartAPI,
sendDownAPI,
configAPI,
} from '@/api/system/attMacManage.js' } from '@/api/system/attMacManage.js'
export default { export default {
name: 'RightTable', name: 'RightTable',
components: { components: {
TableModel, TableModel,
DialogModel,
}, },
props: { props: {
macNo: { macNo: {
type: String, type: String,
default: '', default: '',
}, },
proId: {
type: [String, Number],
default: '',
},
}, },
data() { data() {
return { return {
@ -135,17 +257,80 @@ export default {
t_width: '180', t_width: '180',
}, },
], ],
//
sendDownDialogConfig: {
outerVisible: false,
outerTitle: '下发',
outerWidth: '50%',
maxHeight: '80vh',
},
//
configDialogConfig: {
outerVisible: false,
outerTitle: '配置',
outerWidth: '50%',
maxHeight: '80vh',
},
//
sendDownFormData: {
personIds: [],
content: '',
},
//
configFormData: {
personIds: [],
configItem: '',
},
//
sendDownFormRules: {
personIds: [
{
required: true,
message: '请选择人员',
trigger: 'change',
},
],
content: [
{
required: true,
message: '请输入下发内容',
trigger: 'blur',
},
],
},
//
configFormRules: {
personIds: [
{
required: true,
message: '请选择人员',
trigger: 'change',
},
],
configItem: [
{
required: true,
message: '请输入配置项',
trigger: 'blur',
},
],
},
//
personList: [],
personListLoading: false,
} }
}, },
computed: { computed: {
// 使API // 使API
requestApi() { requestApi() {
return this.macNo ? getPersonListByMacNoAPI : getAllPersonListAPI return this.macNo
? getPersonListByMacNoAPI
: getPersonListByMacNoAPI
}, },
// //
sendParams() { sendParams() {
return { return {
macNo: this.macNo || '', deviceCode: this.macNo || '',
} }
}, },
// //
@ -218,11 +403,113 @@ export default {
}, },
// //
handleSendDown() { handleSendDown() {
this.$parent.openSendDownDialog() if (!this.macNo) {
this.$modal.msgWarning('请先选择考勤机')
return
}
this.sendDownDialogConfig.outerVisible = true
this.resetSendDownForm()
this.getPersonList()
}, },
// //
handleConfig() { handleConfig() {
this.$parent.openConfigDialog() if (!this.macNo) {
this.$modal.msgWarning('请先选择考勤机')
return
}
this.configDialogConfig.outerVisible = true
this.resetConfigForm()
this.getPersonList()
},
//
async getPersonList() {
this.personListLoading = true
try {
const res = await getAllPersonListAPI({
proId: this.proId,
})
if (res.code === 200) {
this.personList = res.rows || res.data || []
}
} catch (error) {
console.error('获取人员列表失败:', error)
} finally {
this.personListLoading = false
}
},
//
handleCloseSendDownDialog() {
this.sendDownDialogConfig.outerVisible = false
this.resetSendDownForm()
},
//
resetSendDownForm() {
this.sendDownFormData = {
personIds: [],
content: '',
}
if (this.$refs.sendDownFormRef) {
this.$refs.sendDownFormRef.resetFields()
}
},
//
handleSendDownSubmit() {
this.$refs.sendDownFormRef.validate((valid) => {
if (valid) {
const params = {
macNo: this.macNo,
personIds: this.sendDownFormData.personIds,
content: this.sendDownFormData.content,
}
sendDownAPI(params)
.then((res) => {
if (res.code === 200) {
this.$modal.msgSuccess('下发成功')
this.handleCloseSendDownDialog()
this.getTableList()
this.$emit('refresh-tree')
}
})
.catch(() => {})
}
})
},
//
handleCloseConfigDialog() {
this.configDialogConfig.outerVisible = false
this.resetConfigForm()
},
//
resetConfigForm() {
this.configFormData = {
personIds: [],
configItem: '',
}
if (this.$refs.configFormRef) {
this.$refs.configFormRef.resetFields()
}
},
//
handleConfigSubmit() {
this.$refs.configFormRef.validate((valid) => {
if (valid) {
const params = {
macNo: this.macNo,
personIds: this.configFormData.personIds,
configItem: this.configFormData.configItem,
}
configAPI(params)
.then((res) => {
if (res.code === 200) {
this.$modal.msgSuccess('配置成功')
this.handleCloseConfigDialog()
this.getTableList()
this.$emit('refresh-tree')
}
})
.catch(() => {})
}
})
}, },
// //
handleRefresh() { handleRefresh() {
@ -288,4 +575,9 @@ export default {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
.dialog-footer-btn {
text-align: right;
padding-top: 20px;
}
</style> </style>

View File

@ -10,161 +10,44 @@
<rightTable <rightTable
ref="rightTableRef" ref="rightTableRef"
:mac-no="selectedMacNo" :mac-no="selectedMacNo"
:pro-id="selectedProId"
@refresh-tree="handleRefreshTree" @refresh-tree="handleRefreshTree"
/> />
</el-col> </el-col>
</el-row> </el-row>
<!-- 下发弹框 -->
<DialogModel
:dialogConfig="sendDownDialogConfig"
@closeDialogOuter="handleCloseSendDownDialog"
>
<template slot="outerContent">
<el-form
ref="sendDownFormRef"
:model="sendDownFormData"
:rules="sendDownFormRules"
label-width="120px"
>
<el-form-item label="下发内容:" prop="content">
<el-input
v-model="sendDownFormData.content"
type="textarea"
:autosize="{ minRows: 4, maxRows: 8 }"
placeholder="请输入下发内容"
clearable
maxlength="500"
show-word-limit
/>
</el-form-item>
</el-form>
<el-row class="dialog-footer-btn">
<el-button size="medium" @click="handleCloseSendDownDialog">
取消
</el-button>
<el-button
size="medium"
type="primary"
@click="handleSendDownSubmit"
>
确定
</el-button>
</el-row>
</template>
</DialogModel>
<!-- 配置弹框 -->
<DialogModel
:dialogConfig="configDialogConfig"
@closeDialogOuter="handleCloseConfigDialog"
>
<template slot="outerContent">
<el-form
ref="configFormRef"
:model="configFormData"
:rules="configFormRules"
label-width="120px"
>
<el-form-item label="配置项:" prop="configItem">
<el-input
v-model="configFormData.configItem"
type="textarea"
:autosize="{ minRows: 4, maxRows: 8 }"
placeholder="请输入配置项"
clearable
maxlength="500"
show-word-limit
/>
</el-form-item>
</el-form>
<el-row class="dialog-footer-btn">
<el-button size="medium" @click="handleCloseConfigDialog">
取消
</el-button>
<el-button
size="medium"
type="primary"
@click="handleConfigSubmit"
>
确定
</el-button>
</el-row>
</template>
</DialogModel>
</div> </div>
</template> </template>
<script> <script>
import leftTree from './components/leftTree.vue' import leftTree from './components/leftTree.vue'
import rightTable from './components/rightTable.vue' import rightTable from './components/rightTable.vue'
import DialogModel from '@/components/DialogModel'
import { sendDownAPI, configAPI } from '@/api/system/attMacManage.js'
export default { export default {
name: 'AttMacManage', name: 'AttMacManage',
components: { components: {
leftTree, leftTree,
rightTable, rightTable,
DialogModel,
}, },
data() { data() {
return { return {
selectedMacNo: '', // selectedMacNo: '', //
// selectedProId: '', // id
sendDownDialogConfig: {
outerVisible: false,
outerTitle: '下发',
outerWidth: '50%',
maxHeight: '80vh',
},
//
configDialogConfig: {
outerVisible: false,
outerTitle: '配置',
outerWidth: '50%',
maxHeight: '80vh',
},
//
sendDownFormData: {
content: '',
},
//
configFormData: {
configItem: '',
},
//
sendDownFormRules: {
content: [
{
required: true,
message: '请输入下发内容',
trigger: 'blur',
},
],
},
//
configFormRules: {
configItem: [
{
required: true,
message: '请输入配置项',
trigger: 'blur',
},
],
},
} }
}, },
methods: { methods: {
// //
handleNodeClick(data) { handleNodeClick(data) {
if (data.level === 2) { console.log('data选择的节点', data)
//
this.selectedMacNo = data.macNo || data.id this.selectedMacNo = data.id
} else { this.selectedProId = data.proId
// // if (data.level === 2) {
this.selectedMacNo = '' // //
} // this.selectedMacNo = data.id
// } else {
// //
// this.selectedMacNo = ''
// }
// //
this.$nextTick(() => { this.$nextTick(() => {
if (this.$refs.rightTableRef) { if (this.$refs.rightTableRef) {
@ -178,89 +61,8 @@ export default {
this.$refs.leftTreeRef.getTreeData() this.$refs.leftTreeRef.getTreeData()
} }
}, },
//
openSendDownDialog() {
this.sendDownDialogConfig.outerVisible = true
this.resetSendDownForm()
},
//
handleCloseSendDownDialog() {
this.sendDownDialogConfig.outerVisible = false
this.resetSendDownForm()
},
//
resetSendDownForm() {
this.sendDownFormData = {
content: '',
}
if (this.$refs.sendDownFormRef) {
this.$refs.sendDownFormRef.resetFields()
}
},
//
handleSendDownSubmit() {
this.$refs.sendDownFormRef.validate((valid) => {
if (valid) {
const params = {
macNo: this.selectedMacNo,
content: this.sendDownFormData.content,
}
sendDownAPI(params)
.then((res) => {
if (res.code === 200) {
this.$modal.msgSuccess('下发成功')
this.handleCloseSendDownDialog()
}
})
.catch(() => {})
}
})
},
//
openConfigDialog() {
this.configDialogConfig.outerVisible = true
this.resetConfigForm()
},
//
handleCloseConfigDialog() {
this.configDialogConfig.outerVisible = false
this.resetConfigForm()
},
//
resetConfigForm() {
this.configFormData = {
configItem: '',
}
if (this.$refs.configFormRef) {
this.$refs.configFormRef.resetFields()
}
},
//
handleConfigSubmit() {
this.$refs.configFormRef.validate((valid) => {
if (valid) {
const params = {
macNo: this.selectedMacNo,
configItem: this.configFormData.configItem,
}
configAPI(params)
.then((res) => {
if (res.code === 200) {
this.$modal.msgSuccess('配置成功')
this.handleCloseConfigDialog()
}
})
.catch(() => {})
}
})
},
}, },
} }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss"></style>
.dialog-footer-btn {
text-align: right;
padding-top: 20px;
}
</style>