考勤数据增加工区管理

dev_xd
lj7788 2025-12-29 16:00:21 +08:00
parent bb90fd9add
commit ad5b939bf3
13 changed files with 622 additions and 152 deletions

View File

@ -0,0 +1,8 @@
增加表
sys_work_area
修改表
pro_mobile_attendance_data 增加 work_area_id 工区id
attendance_ubi_data 增加 work_area_id 工区id
attendance_ubi_device 增加 work_area_id 工区id
pro_video_monitor 增加 work_area_id 工区id

View File

@ -16,8 +16,7 @@
<script
type="text/javascript"
src="https://api.map.baidu.com/api?type=webgl&v=1.0&ak=eseRcUMFiUlnWA6miQLejNpvS70H8SRN"
></script>
src="https://api.map.baidu.com/api?v=1.0&&type=webgl&ak=nDcjhjtaNwnVrKNIDbjibTm6i4u0k0fk"></script>
<script src="/cdn/vue/dist/vue.js"></script>
<script src="/cdn/element-ui/lib/index.js"></script>
<script src="/cdn/jquery/3.5.1/jquery.min.js"></script>

View File

@ -12,7 +12,16 @@ const listVideoMonitor = (query) => {
method: 'get'
})
}
const workAreaTree = (projectId) => {
return request({
url: '/system/workAarea/workAreaTree?projectId=' + projectId,
method: 'get'
})
}
export default {
listVideoMonitor,
getYsToken
getYsToken,
workAreaTree
}

View File

@ -6,12 +6,23 @@
<img src="/cdn/bsimages/nodata.png" style="width: 240px;" />
<div style="text-align: center;">暂无数据</div>
</div>
<div class="video-list">
<div class="video-list" v-else-if="!showTree">
<div v-for="it in videoMonitors" :key="it.id" class="video-item command" :class="it.active ? 'is-active' : ''" @click="doSelectItem(it)">
<svg-icon class-name="video-icon" icon-class="video" />
{{ it.monitorName }}
</div>
</div>
<div v-else class="video-tree">
<el-tree ref="treeRef" :data="treeData" :props="{ label: 'label', children: 'children' }"
highlight-current node-key="id" @node-click="handleTreeNodeClick">
<template #default="{ node, data }">
<span v-if="data.vdata" class="tree-node-content">
<svg-icon class-name="video-icon" icon-class="video" />{{ node.label }}
</span>
<span v-else class="tree-node-content">{{ node.label }}</span>
</template>
</el-tree>
</div>
</module-one-1-3>
</el-col>
<el-col :span="20" class="h100">
@ -62,6 +73,9 @@ export default {
showIndex: 1,
showList: [],
elKey: 0,
showTree: false,
treeData: [],
workAreaOptions: []
}
},
mounted() {
@ -106,8 +120,173 @@ export default {
return it
})
this.showAllVideo()
this.getWorkAreaTree()
})
},
/** 查询工区树结构 */
getWorkAreaTree() {
this.$api.videoMonitor.workAreaTree(this.selProject.id).then(response => {
// el-tree-select
this.workAreaOptions = response.data || [];
if (this.videoMonitors.filter(d => d.workAreaId).length > 0) {
// makeTreevideoMonitors
this.treeData = this.makeTree();
if (this.treeData.length > 0) {
this.showTree = true;
setTimeout(() => {
this.handleTreeNodeClick(this.treeData[0]);
// 使ref使
this.$nextTick(() => {
if (this.$refs.treeRef) {
this.$refs.treeRef.setCurrentKey(this.treeData[0].id);
}
});
}, 400);
} else {
this.showTree = false;
}
} else {
this.treeData = [];
this.showTree = false;
}
});
},
makeTree() {
const videoMonitorMap = {};
let defNode = {
id: '',
label: '默认工区',
type: 'workArea',
children: []
}
this.videoMonitors.forEach(video => {
if (video.workAreaId) {
if (!videoMonitorMap[video.workAreaId]) {
videoMonitorMap[video.workAreaId] = [];
}
videoMonitorMap[video.workAreaId].push(video);
} else {
defNode.children.push({
id: video.id,
label: video.monitorName,
vdata: video,
type: 'workArea',
children: []
});
}
});
// videoMonitors
function attachVideoMonitors(nodes) {
if (!nodes || !Array.isArray(nodes)) return [];
return nodes.map(node => {
//
const newNode = JSON.parse(JSON.stringify(node));
// videoMonitors
if (videoMonitorMap[node.id] && videoMonitorMap[node.id].length > 0) {
if (!newNode.children) {
newNode.children = [];
}
// videoMonitors
videoMonitorMap[node.id].forEach(video => {
newNode.children.push({
id: video.id,
label: video.monitorName,
type: 'workArea',
vdata: video,
children: []
});
});
}
//
if (newNode.children && newNode.children.length > 0) {
newNode.children = attachVideoMonitors(newNode.children);
}
return newNode;
});
}
// videoMonitors(treeNodetypeworkArea)
function pruneEmptyNodes(nodes) {
if (!nodes || !Array.isArray(nodes)) return [];
const result = [];
for (const node of nodes) {
//
const newNode = { ...node };
// videoMonitorsvdata
const hasDirectVideoMonitors = node.children && node.children.some(child => child.vdata && child.type === 'workArea');
//
if (node.children && node.children.length > 0) {
newNode.children = pruneEmptyNodes(node.children);
}
//
// 1. videoMonitors
// 2. videoMonitors
if (hasDirectVideoMonitors || (newNode.children && newNode.children.length > 0) || newNode.type === 'workArea') {
result.push(newNode);
}
}
return result;
}
//
const workAreaOptionsCopy = JSON.parse(JSON.stringify(this.workAreaOptions));
const treeWithVideos = attachVideoMonitors(workAreaOptionsCopy);
const prunedTree = pruneEmptyNodes(treeWithVideos);
//
if (defNode.children && defNode.children.length > 0) {
return [defNode, ...prunedTree];
}
return prunedTree;
},
handleTreeNodeClick(node) {
// vdata
if (node.vdata) {
this.doSelectItem(node.vdata, true);
} else {
//
let videoNodes = [];
function getVideoNodes(nodes) {
if (!nodes || !Array.isArray(nodes)) return [];
nodes.forEach(node => {
if (node.vdata) {
videoNodes.push(node);
}
if (node.children && node.children.length > 0) {
getVideoNodes(node.children);
}
});
}
getVideoNodes(node.children);
let videoList = videoNodes.map(d => d.vdata);
this.videoMonitors = videoList;
if (videoList.length > 1) {
this.showMode = 'all';
this.showAllData();
} else {
this.showMode = 'sigle';
this.doSelectItem(videoList[0], true);
}
}
},
loadVideo(it) {
this.$api.videoMonitor.getYsToken(it.id).then((d) => {
it.accessToken = d.msg
@ -120,8 +299,8 @@ export default {
this.showIndex = 1
this.showAllData()
},
doSelectItem(it) {
if (it.active) {
doSelectItem(it, reLoad = false) {
if (it.active && !reLoad) {
return
}
this.showMode = 'sigle'
@ -174,6 +353,147 @@ export default {
}
}
.video-tree {
width: 100%;
height: 100%;
font-size: 16px; /* 增大字体大小 */
.el-tree{
background: transparent;
color:#fff;
}
.tree-node-content {
display: inline-block;
width: 100%;
padding: 4px 4px; /* 增大内边距 */
cursor: pointer;
border-radius: 4px;
transition: background-color 0.2s;
line-height: 20px; /* 增大行高 */
&:hover {
background-color: transparent;
}
}
.el-tree-node__content{
&:hover{
background-color: rgba(255, 255, 255, 0.2);
}
}
.el-tree-node:focus > .el-tree-node__content {
background-color: rgba(255, 255, 255, 0.2);
}
.el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content {
background-color: rgba(4, 148, 238, 0.787);
color: white;
font-size: 16px; /* 保持选中状态的字体大小 */
padding: 4px 4px; /* 保持选中状态的内边距 */
.el-tree-node__expand-icon,
.el-icon-arrow-right,
.el-icon-arrow-down {
color: white;
font-size: 16px; /* 增大箭头图标大小 */
}
}
/* 覆盖默认的el-tree样式以适应大屏 */
.el-tree-node__content {
padding: 4px 4px; /* 增大节点内容的内边距 */
height: auto; /* 允许内容高度自适应 */
}
.el-tree-node__expand-icon {
font-size: 16px; /* 增大展开/折叠图标大小 */
width: 24px; /* 增大图标容器宽度 */
height: 24px; /* 增大图标容器高度 */
line-height: 20px; /* 调整图标行高 */
}
.el-tree-node__label {
font-size: 16px; /* 确保标签字体大小一致 */
}
}
/* 针对大屏分辨率的额外调整 */
@media (min-width: 1921px) and (max-width: 2560px) {
.video-tree {
font-size: 18px; /* 更大屏显时的字体 */
.tree-node-content {
padding: 8px 4px; /* 更大的内边距 */
line-height: 32px; /* 更大的行高 */
}
.el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content {
font-size: 18px;
padding: 8px 4px;
.el-tree-node__expand-icon,
.el-icon-arrow-right,
.el-icon-arrow-down {
font-size: 18px;
}
}
.el-tree-node__content {
padding: 8px 4px;
line-height: 24px;
}
.el-tree-node__expand-icon {
font-size: 18px;
width: 24px;
height: 24px;
line-height: 24px;
}
.el-tree-node__label {
font-size: 18px;
}
}
}
/* 针对大屏分辨率的额外调整 */
@media (min-width: 2561px) {
.video-tree {
font-size: 24px; /* 更大屏显时的字体 */
.tree-node-content {
padding: 8px 4px; /* 更大的内边距 */
line-height: 32px; /* 更大的行高 */
}
.el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content {
font-size: 24px;
padding: 8px 4px;
.el-tree-node__expand-icon,
.el-icon-arrow-right,
.el-icon-arrow-down {
font-size: 18px;
}
}
.el-tree-node__content {
padding: 8px 4px;
line-height: 24px;
}
.el-tree-node__expand-icon {
font-size: 24px;
width: 24px;
height: 24px;
line-height: 24px;
}
.el-tree-node__label {
font-size: 24px;
}
}
}
.all-mode {
.all-header {
text-align: right;

View File

@ -76,6 +76,16 @@ public class AttendanceUbiData extends BaseEntity
@Excel(name = "设备NO")
private String deviceNo;
private Long workAreaId;
public Long getWorkAreaId() {
return workAreaId;
}
public void setWorkAreaId(Long workAreaId) {
this.workAreaId = workAreaId;
}
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private Long isDel;

View File

@ -100,6 +100,10 @@ public class AttendanceUbiDevice extends BaseEntity
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private Long isDel;
/** 工区ID */
@Excel(name = "工区ID")
private Long workAreaId;
private String compName;
private String projectName;
@ -148,6 +152,7 @@ public class AttendanceUbiDevice extends BaseEntity
private String souceName;
private String workAreaName; // 工区名称,用于显示
public void setId(Long id)
{
this.id = id;
@ -338,6 +343,24 @@ public class AttendanceUbiDevice extends BaseEntity
return isDel;
}
public void setWorkAreaId(Long workAreaId)
{
this.workAreaId = workAreaId;
}
public Long getWorkAreaId()
{
return workAreaId;
}
public String getWorkAreaName() {
return workAreaName;
}
public void setWorkAreaName(String workAreaName) {
this.workAreaName = workAreaName;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@ -91,6 +91,16 @@ public class ProMobileAttendanceData extends BaseEntity
@Excel(name = "考勤设备")
private String attDevice;
private Long workAreaId;
public Long getWorkAreaId() {
return workAreaId;
}
public void setWorkAreaId(Long workAreaId) {
this.workAreaId = workAreaId;
}
public String getAttDevice() {
return attDevice;
}

View File

@ -33,17 +33,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="eventGuid" column="eventGuid"/>
<result property="inPhoto" column="inPhoto"/>
<result property="outPhoto" column="outPhoto"/>
<result property="workAreaId" column="work_area_id"/>
</resultMap>
<sql id="selectAttendanceUbiDataVo">
select id, comId, projectId, userId, userName, sub_dept_group, sub_dept_group_name, craft_type, craft_post,admitGuid,
eventGuid,inPhoto,outPhoto,comName,projectName,sub_dept_id,sub_dept_name,
eventGuid,inPhoto,outPhoto,comName,projectName,sub_dept_id,sub_dept_name,work_area_id,
inTime, outTime, deviceNo, is_del, state, remark, create_by, create_time, update_by, update_time from attendance_ubi_data
</sql>
<sql id="selectAttendanceUbiDataAllVo">
select id, comId, projectId, userId, userName, sub_dept_group, sub_dept_group_name, craft_type, craft_post,admitGuid,
eventGuid,inPhoto,outPhoto,inData,outData,comName,projectName,sub_dept_id,sub_dept_name,
eventGuid,inPhoto,outPhoto,inData,outData,comName,projectName,sub_dept_id,sub_dept_name,work_area_id,
inTime, outTime, deviceNo, is_del, state, remark, create_by, create_time, update_by, update_time from attendance_ubi_data
</sql>
@ -133,6 +134,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="inData != null">inData,</if>
<if test="outTime != null">outTime,</if>
<if test="outData != null">outData,</if>
<if test="workAreaId!=null">work_area_id,</if>
<if test="deviceNo != null">deviceNo,</if>
<if test="isDel != null">is_del,</if>
<if test="subDeptId != null">sub_dept_id,</if>
@ -163,6 +165,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="inData != null">#{inData},</if>
<if test="outTime != null">#{outTime},</if>
<if test="outData != null">#{outData},</if>
<if test="workAreaId!=null">#{workAreaId},</if>
<if test="deviceNo != null">#{deviceNo},</if>
<if test="isDel != null">#{isDel},</if>
<if test="subDeptId != null">#{subDeptId},</if>

View File

@ -36,17 +36,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="compName" column="comp_name"/>
<result property="projectName" column="project_name"/>
<result property="souceName" column="souce_name"/>
<result property="workAreaId" column="work_area_id"/>
<result property="workAreaName" column="work_area_name"/>
</resultMap>
<sql id="selectAttendanceUbiDeviceVo">
select ud.id, ud.com_id, ud.project_id, ud.name, ud.tag, ud.scene_guid, ud.source, ud.device_no, ud.addition, ud.bind_default_scene, ud.force_empty_device,
ud.direction,ud.channel,
ud.work_area_id,
ud.device_model, ud.device_state, ud.rec_type, ud.online_state, ud.version_no, ud.last_active_time, ud.has_register, ud.state, ud.remark, ud.is_del,
ud.create_by, ud.create_time, ud.update_by, ud.update_time ,dp.`dept_name` comp_name,pp.`project_name`,dic.`dict_label` souce_name
ud.create_by, ud.create_time, ud.update_by, ud.update_time ,dp.`dept_name` comp_name,pp.`project_name`,dic.`dict_label` souce_name,wa.`title` work_area_name
from attendance_ubi_device ud
left join sys_dept dp on ud.`com_id`=dp.`dept_id`
left join pro_project_info pp on ud.`project_id`=pp.`id`
left join sys_dict_data dic on ud.`source`=dic.`dict_value` and dic.`dict_type`='ubi_device_source'
left join sys_work_area wa on ud.`work_area_id`=wa.`id`
</sql>
<select id="selectAttendanceUbiDeviceList" parameterType="AttendanceUbiDevice" resultMap="AttendanceUbiDeviceResult">
@ -107,6 +111,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="hasRegister != null">has_register,</if>
<if test="state != null">state,</if>
<if test="remark != null">remark,</if>
<if test="workAreaId != null">work_area_id,</if>
<if test="isDel != null">is_del,</if>
<if test="direction != null">direction,</if>
<if test="channel != null">channel,</if>
@ -137,6 +142,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="hasRegister != null">#{hasRegister},</if>
<if test="state != null">#{state},</if>
<if test="remark != null">#{remark},</if>
<if test="workAreaId != null">#{workAreaId},</if>
<if test="isDel != null">#{isDel},</if>
<if test="direction != null">#{direction},</if>
<if test="channel != null">#{channel},</if>
@ -170,6 +176,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="hasRegister != null">has_register = #{hasRegister},</if>
<if test="state != null">state = #{state},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="workAreaId != null">work_area_id = #{workAreaId},</if>
<if test="isDel != null">is_del = #{isDel},</if>
<if test="direction != null">direction = #{direction},</if>
<if test="channel != null">channel = #{channel},</if>

View File

@ -30,6 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="userPost" column="user_post" />
<result property="userSex" column="user_sex" />
<result property="attDevice" column="att_device" />
<result property="workAreaId" column="wa.work_area_id"/>
</resultMap>
<sql id="selectProMobileAttendanceDataVo">
@ -87,6 +88,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="attDate != null">att_date,</if>
<if test="attImg != null">att_img,</if>
<if test="attDevice != null">att_device,</if>
<if test="workAreaId != null">work_area_id,</if>
<if test="isDel != null">is_del,</if>
<if test="remark != null">remark,</if>
<if test="state != null">state,</if>
@ -106,6 +108,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="attImg != null">#{attImg},</if>
<if test="attDevice != null">#{attDevice},</if>
<if test="isDel != null">#{isDel},</if>
<if test="workAreaId != null">#{workAreaId},</if>
<if test="remark != null">#{remark},</if>
<if test="state != null">#{state},</if>
<if test="createBy != null">#{createBy},</if>

View File

@ -147,10 +147,12 @@ public class UniCallBackController {
addData.setSubDeptGroupName(proUser.getSubDeptGroupName());
addData.setCraftPost(proUser.getCraftPost());
addData.setCraftType(proUser.getCraftType());
addData.setWorkAreaId(device.getWorkAreaId());
attendanceData.setUserId(proUser.getUserId());
attendanceData.setProjectId(projectId);
attendanceData.setAttDate(showTime);
attendanceData.setAttImg(filePath);
attendanceData.setWorkAreaId(device.getWorkAreaId());
if(device.getDirection()==0) {
addData.setInTime(showTime);
addData.setInData(data);
@ -171,12 +173,14 @@ public class UniCallBackController {
}else{
//修改操作
AttendanceUbiData upData= list.get(0);
upData.setWorkAreaId(device.getWorkAreaId());
if(upData.getEventGuid().equals(eventGuid)){
return AjaxResult.error("此记录已入库!");
}
Date dt1=upData.getInTime();
Date dt2=upData.getOutTime();
attendanceData.setUserId(upData.getUserId());
attendanceData.setWorkAreaId(device.getWorkAreaId());
attendanceData.setProjectId(projectId);
attendanceData.setAttDate(showTime);
attendanceData.setAttImg(filePath);

View File

@ -2,8 +2,10 @@
<div class="app-container">
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="90px">
<el-form-item label="项目" prop="projectId">
<el-select :disabled="data.currentPrjId != ''" v-model="queryParams.projectId" placeholder="请选择项目" clearable @change="handleQuery">
<el-option v-for="prj in data.projects" :key="prj.id" :label="prj.projectName" :value="prj.id"></el-option>
<el-select :disabled="data.currentPrjId != ''" v-model="queryParams.projectId" placeholder="请选择项目"
clearable @change="handleQuery">
<el-option v-for="prj in data.projects" :key="prj.id" :label="prj.projectName"
:value="prj.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="设备名称" prop="name">
@ -23,16 +25,20 @@
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['manage:attendance_ubi_device:add']"></el-button>
<el-button type="primary" plain icon="Plus" @click="handleAdd"
v-hasPermi="['manage:attendance_ubi_device:add']">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate" v-hasPermi="['manage:attendance_ubi_device:edit']"></el-button>
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate"
v-hasPermi="['manage:attendance_ubi_device:edit']">修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete" v-hasPermi="['manage:attendance_ubi_device:remove']"></el-button>
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete"
v-hasPermi="['manage:attendance_ubi_device:remove']">删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['manage:attendance_ubi_device:export']"></el-button>
<el-button type="warning" plain icon="Download" @click="handleExport"
v-hasPermi="['manage:attendance_ubi_device:export']">导出</el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
@ -40,6 +46,7 @@
<el-table v-loading="loading" :data="attendance_ubi_deviceList" @selection-change="handleSelectionChange">
<el-table-column label="公司" align="center" prop="compName" />
<el-table-column label="所属项目" align="center" prop="projectName" />
<el-table-column label="所属工区" align="center" prop="workAreaName" />
<el-table-column label="设备名称" align="center" prop="name" />
<el-table-column label="设备标签" align="center" prop="tag" />
<el-table-column label="设备来源" align="center" prop="souceName" />
@ -78,17 +85,22 @@
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="150">
<template #default="scope">
<el-button link type="primary" icon="ChromeFilled" @click="handleAuth(scope.row)" v-hasPermi="['manage:attendance_ubi_device:edit']"></el-button>
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['manage:attendance_ubi_device:edit']"></el-button>
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['manage:attendance_ubi_device:remove']"></el-button>
<el-button link type="primary" icon="ChromeFilled" @click="handleAuth(scope.row)"
v-hasPermi="['manage:attendance_ubi_device:edit']">同步</el-button>
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)"
v-hasPermi="['manage:attendance_ubi_device:edit']">修改</el-button>
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)"
v-hasPermi="['manage:attendance_ubi_device:remove']">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
v-model:limit="queryParams.pageSize" @pagination="getList" />
<!-- 添加或修改宇泛的设备信息对话框 -->
<el-dialog :title="title" v-model="open" width="600px" append-to-body :close-on-click-modal="false" :close-on-press-escape="false">
<el-dialog :title="title" v-model="open" width="600px" append-to-body :close-on-click-modal="false"
:close-on-press-escape="false" class="dlg-hide-form-hidden-scroll">
<el-form ref="attendance_ubi_deviceRef" :model="form" :rules="rules" label-width="100px">
<el-form-item label="所属项目">
<el-tag effect="plain">{{ form.projectName }}</el-tag>
@ -101,19 +113,25 @@
</el-form-item>
<el-form-item label="设备来源" prop="source">
<el-select v-model="form.source" placeholder="请选择设备来源" clearable>
<el-option v-for="dict in ubi_device_source" :key="dict.value" :label="dict.label" :value="dict.value" />
<el-option v-for="dict in ubi_device_source" :key="dict.value" :label="dict.label"
:value="dict.value" />
</el-select>
</el-form-item>
<el-form-item label="设备序列号" prop="deviceNo">
<el-input v-model="form.deviceNo" placeholder="请输入设备序列号" />
</el-form-item>
<el-form-item label="所属工区" prop="workAreaId">
<el-tree-select v-model="form.workAreaId" :data="data.workAreaOptions"
:props="{ value: 'id', label: 'title', children: 'children' }" value-key="id"
placeholder="请选择工区" clearable style="width:300px;" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" />
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button type="primary" @click="submitForm" :loading="data.submitLoading"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</template>
@ -132,10 +150,12 @@ import {
} from '@/api/manage/attendanceubidevice'
import useUserStore from '@/store/modules/user'
import { findMyProjectList } from '@/api/publics'
import { workAreaTree } from '@/api/system/workAarea'
const { proxy } = getCurrentInstance()
const userStore = useUserStore()
const { ubi_device_source } = proxy.useDict('ubi_device_source')
const attendance_ubi_deviceList = ref([])
const workAreaList = ref([])
const open = ref(false)
const loading = ref(true)
const showSearch = ref(true)
@ -176,10 +196,13 @@ const data = reactive({
tag: [{ required: true, trigger: ['blur', 'change'], message: '请输入设备标签' }],
source: [{ required: true, trigger: ['blur', 'change'], message: '请选择设备来源' }],
deviceNo: [{ required: true, trigger: ['blur', 'change'], message: '请输入设备序列号' }],
workAreaId: [{ required: false, trigger: 'blur', message: '请选择所属工区' }],
},
projects: [],
currentPrjId: '',
mode: '',
workAreaOptions: [],
submitLoading: false,
})
const { queryParams, form, rules } = toRefs(data)
@ -248,6 +271,7 @@ function reset() {
state: null,
remark: null,
isDel: null,
workAreaId: null,
createBy: null,
createTime: null,
updateBy: null,
@ -309,17 +333,22 @@ function submitForm() {
proxy.$refs['attendance_ubi_deviceRef'].validate((valid) => {
if (valid) {
form.value.comId = userStore.currentComId
data.submitLoading = true
if (form.value.id != null) {
updateAttendance_ubi_device(form.value).then((response) => {
proxy.$modal.msgSuccess('修改成功')
open.value = false
getList()
}).finally(() => {
data.submitLoading = false
})
} else {
addAttendance_ubi_device(form.value).then((response) => {
proxy.$modal.msgSuccess('新增成功')
open.value = false
getList()
}).finally(() => {
data.submitLoading = false
})
}
}
@ -351,7 +380,37 @@ function handleExport() {
`attendance_ubi_device_${new Date().getTime()}.xlsx`
)
}
/** 查询工区树结构 */
function getWorkAreaTree() {
workAreaTree(userStore.currentPrjId).then(response => {
// el-tree-select
data.workAreaOptions = transformTreeData(response.data);
});
}
/** 转换树形数据格式 */
function transformTreeData(apiData) {
if (!apiData || !Array.isArray(apiData)) {
return [];
}
return apiData.map(item => {
// item.datachildren
const transformedItem = {
id: item.id,
title: item.label, // 使label
ancestors: item.data?.ancestors, // dataancestors
//
...item.data
};
// children使
transformedItem.children = item.children ? transformTreeData(item.children) : [];
return transformedItem;
});
}
getList()
getProjectList()
getWorkAreaTree()
</script>

View File

@ -11,8 +11,10 @@
<el-table-column type="index" width="50" label="序号" />
<el-table-column label="公司" align="center" prop="compName" v-if="1 == 2" />
<el-table-column label="所属项目" align="center" prop="projectName" />
<el-table-column label="所属工区" align="center" prop="workAreaName" />
<el-table-column label="设备序列号" align="center" prop="deviceNo">
<template #default="scope"><span style="color: var(--el-color-warning);">{{scope.row.deviceNo}}</span></template>
<template #default="scope"><span style="color: var(--el-color-warning);">{{ scope.row.deviceNo
}}</span></template>
</el-table-column>
<el-table-column label="通道编号" align="center" prop="channel" />
<el-table-column label="方向" align="center" prop="direction">
@ -38,10 +40,14 @@
<el-table-column label="在线状态" align="center" prop="onlineState">
<template #default="scope">
<span v-if="scope.row.onlineState == 1" style="color:green;">
<el-icon style="vertical-align: middle;"><SuccessFilled /></el-icon>
<el-icon style="vertical-align: middle;">
<SuccessFilled />
</el-icon>
在线</span>
<span v-if="scope.row.onlineState == 2" style="color: red;">
<el-icon style="vertical-align: middle;"><CircleCloseFilled /></el-icon>线</span>
<el-icon style="vertical-align: middle;">
<CircleCloseFilled />
</el-icon>线</span>
</template>
</el-table-column>
<el-table-column label="版本号" align="center" prop="versionNo" v-if="false" />
@ -86,8 +92,7 @@
</el-form-item>
<el-form-item label="设备用途" prop="tag">
<el-select v-model="form.tag" placeholder="请选择设备用途" clearable>
<el-option v-for="(dict,idx) in ['','']" :key="idx" :label="dict"
:value="dict" />
<el-option v-for="(dict, idx) in ['', '']" :key="idx" :label="dict" :value="dict" />
</el-select>
</el-form-item>
@ -105,6 +110,12 @@
</el-select>
</el-form-item>
<el-form-item label="所属工区" prop="workAreaId" v-if="false">
<el-select v-model="form.workAreaId" placeholder="请选择工区" clearable>
<el-option v-for="workArea in workAreaList" :key="workArea.workAreaId"
:label="workArea.workAreaName" :value="workArea.workAreaId" />
</el-select>
</el-form-item>
<el-form-item label="备注" prop="remark" v-if="false">
<el-input v-model="form.remark" placeholder="请输入备注" />
</el-form-item>
@ -128,6 +139,7 @@ const { proxy } = getCurrentInstance();
const { ubi_device_source } = proxy.useDict('ubi_device_source');
const attendance_ubi_deviceList = ref([]);
const workAreaList = ref([]);
const open = ref(false);
const loading = ref(true);
const ids = ref([]);
@ -221,7 +233,8 @@ function reset() {
createBy: null,
createTime: null,
updateBy: null,
updateTime: null
updateTime: null,
workAreaId: null
};
proxy.resetForm("attendance_ubi_deviceRef");
}
@ -311,6 +324,7 @@ function showDrawer(row) {
defineExpose({
showDrawer
})
</script>
<style lang="scss">
@ -318,4 +332,5 @@ defineExpose({
.el-drawer__header {
margin-bottom: 0px;
}
}</style>
}
</style>