巡检任务编辑完成

This commit is contained in:
Zy
2026-04-22 17:44:05 +08:00
parent 04eb40d0e4
commit d0767d8a71
8 changed files with 142 additions and 90 deletions

View File

@@ -9,9 +9,9 @@ VITE_APP_ENV = 'development'
# 开发环境
VITE_APP_BASE_API = '/dev-api'
# # 开发环境 接口代理地址
# VITE_APP_PROXY_API = 'http://192.168.1.222:8080'
VITE_APP_PROXY_API = 'http://192.168.1.222:8080'
# 开发环境 接口代理地址
VITE_APP_PROXY_API = 'http://192.168.1.215:8080'
# VITE_APP_PROXY_API = 'http://192.168.1.215:8080'
# 图片基础地址
VITE_IMG_URL = 'http://192.168.1.222:8080'

View File

@@ -12,17 +12,17 @@ export interface TaskVO {
/**
* 关联巡检计划ID
*/
planId: string | number;
planId: string;
/**
* 巡检人员ID
*/
inspectorId: string | number;
inspectorId: string;
/**
* 巡检路线ID
*/
routeId: string | number;
routeId: string;
/**
* 起止日期
@@ -34,6 +34,15 @@ export interface TaskVO {
*/
status: string;
/** 巡检人员信息 */
inspectorInfo: {
'userId': string;
'userName': string;
'nickName': string;
'phonenumber': '';
'avatar': string;
}[];
/**
* 备注
*/
@@ -59,17 +68,17 @@ export interface TaskForm extends BaseEntity {
/**
* 关联巡检计划ID
*/
planId?: string | number;
planId?: string;
/**
* 巡检人员ID
*/
inspectorId?: string | number;
inspectorId?: string;
/**
* 巡检路线ID
*/
routeId?: string | number;
routeId?: string;
/**
* 起止日期
@@ -101,17 +110,17 @@ export interface TaskQuery extends PageQuery {
/**
* 关联巡检计划ID
*/
planId?: string | number;
planId?: string;
/**
* 巡检人员ID
*/
inspectorId?: string | number;
inspectorId?: string;
/**
* 巡检路线ID
*/
routeId?: string | number;
routeId?: string;
/**
* 起止日期

View File

@@ -27,12 +27,10 @@
</div>
</div>
<div class="overviewBox">
<el-card v-for="(item, index) in list" :key="index">
<div class="overviewitem">
<div class="overviewitem" v-for="(item, index) in list" :key="index">
<div class="overviewitem_name">{{ item.name }}</div>
<div class="overviewitem_value">{{ item.value }}</div>
</div>
</el-card>
</div>
</div>
</el-card>
@@ -41,10 +39,10 @@
<el-card class="flex-1" shadow="never">
<template #header>
<span style="font-size: 1.2rem">数据统计 </span>
<span style="font-size: 1.1rem">数据统计 </span>
</template>
<el-row :gutter="10" class="h-full">
<el-col :span="10">
<el-row :gutter="40" class="h-full">
<el-col :span="11">
<div class="echartsbox flex h-full flex-col">
<div class="echartsactions">
<div
@@ -62,19 +60,26 @@
</div>
</div>
</el-col>
<el-col :span="14">
<el-col :span="1"></el-col>
<el-col :span="12">
<el-table v-loading="loading" border :data="itemList">
<el-table-column label="日期" width="100" align="center" prop="statDate" />
<el-table-column label="计划巡检任务" width="120" align="center" prop="totalPlans" />
<el-table-column label="按时完成" align="center" prop="completedTasks" />
<el-table-column fixed="left" label="日期" width="100" align="center" prop="statDate" />
<el-table-column label="计划巡检任务" width="110" align="center" prop="totalPlans" />
<el-table-column label="按时完成" align="center" prop="completedTasks">
<template #default="scope">
{{ scope.row.completedTasks - scope.row.outCompletedTasks }}
</template>
</el-table-column>
<el-table-column label="超时完成" align="center" prop="outCompletedTasks" />
<el-table-column label="超时未完成" align="center" prop="outUncompletedTasks" />
<el-table-column label="超时未完成" width="110" align="center" prop="outUncompletedTasks" />
<el-table-column label="进行中" align="center" prop="activeTask" />
<el-table-column label="未开始" align="center" prop="pendingTask" />
</el-table>
<pagination
:pagerCount="pagerCount"
v-show="total > 0"
:total="total"
:layout="layout"
v-model:page="queryParams.pageNum"
v-model:limit="queryParams.pageSize"
@pagination="getList"
@@ -95,9 +100,12 @@ const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const itemList = ref<any[]>([]);
const loading = ref(true);
const showSearch = ref(true);
const total = ref(0);
const total = ref(100);
const queryFormRef = ref<ElFormInstance>();
const pagerCount = document.body.clientWidth <= 1500 ? 1 : 7;
const layout = document.body.clientWidth <= 1500 ? 'total, sizes, prev, pager, next' : 'total, sizes, prev, pager, next,';
const disabledDate = (time: Date) => {
return time.getTime() > Date.now();
};
@@ -117,17 +125,17 @@ const list = ref([
{
name: '计划数量',
key: 'totalPlans',
value: 20
value: 0
},
{
name: '任务数量',
key: 'totalPlans',
value: 200
key: 'totalTasks',
value: 0
},
{
name: '任务完成数量',
key: 'UncompletedTasks',
value: 40
key: 'completedTasks',
value: 0
},
{
name: ' 完成率',
@@ -137,13 +145,13 @@ const list = ref([
{
name: '未完成数量',
key: 'outUncompletedTasks',
value: 40
value: 0
}
]);
// ! echarts =================================================================
const activeEchartsindex = ref('totalTasks');
// echarts tabs
const ecartslist = ref([
{
name: '全部任务',
@@ -176,6 +184,8 @@ const ecartslist = ref([
offsetbottomColor: 'rgb(233, 233, 235)'
}
]);
// echarts options
const options = computed<EChartsOption>(() => ({
grid: {
left: '1%',
@@ -186,14 +196,26 @@ const options = computed<EChartsOption>(() => ({
},
xAxis: { data: xAxislist.value },
yAxis: { type: 'value' as const },
tooltip: { trigger: 'axis' as const },
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow',
shadowStyle: {
color: '#f6f8fc',
opacity: 0.3
}
}
},
series: activeSeries.value // 动态系列
}));
//
const diffday = ref(0);
const activeSeries = ref();
const xAxislist = ref([]);
// join Echarts Options object
function handleEcartsOptions(data, name, colorlist = ['#1a75ff', '#f2f9ff']) {
activeSeries.value = null;
const obj = {
data: data,
type: 'line' as const,
@@ -229,12 +251,13 @@ function handleEcartsOptions(data, name, colorlist = ['#1a75ff', '#f2f9ff']) {
activeSeries.value = obj;
}
// echarts tabs switch
function handleEcartsData(row: (typeof ecartslist.value)[number]) {
activeEchartsindex.value = row.key;
if (row) {
xAxislist.value = [];
// 避免修改原数组,创建副本排序
const sortedList = [...itemList.value].sort((a, b) => new Date(a.statDate).getTime() - new Date(b.statDate).getTime());
console.log(sortedList);
// 创建日期到值的映射,标准化日期格式(假设 statDate 为 '2024-04-16 00:00:00'截取前10位
const dataMap = new Map<string, number>();
sortedList.forEach((item) => {
@@ -243,22 +266,16 @@ function handleEcartsData(row: (typeof ecartslist.value)[number]) {
});
// 根据 x 轴日期生成数据数组
console.log(diffday.value);
const xAxisDates = getLastNDays(diffday.value, undefined, 'YYYY.MM.DD'); // 确保格式为 ['2024-04-16', ...]
const xAxisDates = getLastNDays(diffday.value, undefined, 'YYYY/MM/DD'); // 确保格式为 ['2024-04-16', ...]
const arr = xAxisDates.map((date) => dataMap.get(date) || 0);
console.log(xAxisDates, dataMap);
xAxislist.value = xAxisDates;
console.log('xAxisDates:', xAxisDates); // 调试
console.log('dataMap:', dataMap); // 调试
console.log('arr:', arr); // 调试
activeSeries.value = null;
handleEcartsOptions(arr, row.name, [row.color, row.offsetbottomColor]);
handleEcartsOptions(arr, row.name, [row.color]);
}
}
// 选择日期
function handleStateDate(val) {
console.log(diffDays(val));
diffday.value = diffDays(val);
queryParams.value.statDate = `${formatDate(new Date(val), 'YYYY/MM/DD')}-${formatDate(new Date(), 'YYYY/MM/DD')}`;
getList();
@@ -266,10 +283,10 @@ function handleStateDate(val) {
// ! echarts =================================================================
const day = 1000 * 60 * 60 * 24;
// search options
function handleQueryDay(val: number) {
const newday = new Date(); // 当前日期
const time = new Date(newday.getTime() - val * day); // 指定日期
console.log(time, newday);
diffday.value = val; // 差值
diffday.value = getNaturalDayDiff(time, newday);
queryParams.value.statDate = formatDate(time, 'YYYY/MM/DD');
@@ -283,7 +300,22 @@ const getList = async () => {
loading.value = true;
const res = await listItem(queryParams.value);
itemList.value = res.rows;
handleEcartsData(ecartslist.value[0]);
list.value.forEach((item) => {
item.value = 0;
});
itemList.value.forEach((item) => {
list.value[0].value += item.totalPlans ?? 0;
list.value[1].value += item.totalTasks ?? 0;
list.value[2].value += item.completedTasks ?? 0;
list.value[4].value += item.outUncompletedTasks ?? 0;
});
if (!Number.isNaN(+list.value[2].value) && !Number.isNaN(+list.value[1].value)) {
list.value[3].value = Math.min((Number(list.value[2].value) / Number(list.value[1].value)) * 100, 100) + '%';
}
handleEcartsData(ecartslist.value.find((item) => item.key === activeEchartsindex.value));
total.value = res.total;
loading.value = false;
};
@@ -300,14 +332,17 @@ onMounted(() => {
}
.rightSearch {
font-size: 0.85rem;
div {
width: 60px;
min-width: 60px;
margin-right: 10px;
}
i {
margin: 0 10px;
display: block;
padding: 5px 5px;
font-style: normal;
cursor: pointer;
&:hover {
color: #409eff;
}
@@ -315,13 +350,20 @@ onMounted(() => {
}
.overviewBox {
display: flex;
flex-wrap: nowrap;
align-items: center;
justify-content: space-between;
margin-top: 40px;
gap: 20px;
.overviewitem {
flex: 1;
min-width: 150px;
padding: 5px -5px;
padding: 25px 15px;
width: 240px;
height: 112px;
border-radius: 10px;
background-color: rgba(255, 255, 255, 1);
box-shadow: 0px 2px 6px 0px rgba(26, 117, 255, 0.2);
border: 1px solid rgba(26, 117, 255, 0.2);
.overviewitem_name {
color: rgba(102, 102, 102, 1);
@@ -346,9 +388,11 @@ onMounted(() => {
line-height: 40px;
width: 100px;
text-align: center;
font-size: 0.75rem;
border: 1px solid rgba(220, 223, 230, 1);
color: rgba(16, 16, 16, 1);
border-left: none;
cursor: pointer;
&:first-of-type {
border-radius: 4px 0px 0px 0px;
border-left: 1px solid rgba(220, 223, 230, 1);
@@ -363,5 +407,8 @@ onMounted(() => {
}
}
}
.echartsbody {
max-height: 500px;
}
}
</style>

View File

@@ -45,7 +45,7 @@
</el-form-item>
<el-form-item label="提醒时间">
<el-select v-model="form.remindTime" placeholder="请选择" style="width: 100%">
<el-option v-for="item in remindTimeoptions" :key="item.value" :label="item.label" :value="item.value" />
<el-option v-for="item in com_inspection_remind_tiime" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="巡检设置">
@@ -80,6 +80,10 @@ import { ref } from 'vue';
import AMapLoader from '@amap/amap-jsapi-loader';
import { addPlan, getPlan, updatePlan } from '@/api/system/InspectionPlan';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { com_inspection_remind_tiime } = toRefs<any>(proxy?.useDict('com_inspection_remind_tiime'));
com_inspection_remind_tiime;
const route = useRoute();
const router = useRouter();
@@ -127,6 +131,7 @@ const options = ref([
}
]);
// 提醒时间
const remindTimeoptions = ref([
{
value: 10,

View File

@@ -29,11 +29,9 @@
</div>
<div class="infobox">
<div class="label">执行状态 :</div>
<div class="value">{{ form.statusLabel }}</div>
<div class="value">
<DictTag :options="com_inspection_task_status" :value="form.status"></DictTag>
</div>
<div class="infobox">
<div class="label">创建人 :</div>
<div class="value">{{ form.createByName }}</div>
</div>
<div class="infobox">
<div class="label">创建时间 :</div>
@@ -68,7 +66,7 @@ import { getRecord } from '@/api/system/InspectionRecord';
import { RecordVO } from '@/api/system/InspectionRecord/type';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { com_pay_method } = toRefs<any>(proxy?.useDict('com_pay_method'));
const { com_inspection_task_status } = toRefs<any>(proxy?.useDict('com_inspection_task_status'));
const router = useRouter();
const route = useRoute();

View File

@@ -6,7 +6,9 @@
<el-card shadow="hover">
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
<el-form-item label="执行状态" prop="status">
<el-input v-model="queryParams.status" placeholder="请输入执行状态" clearable @keyup.enter="handleQuery" />
<el-select>
<el-option v-for="item in com_inspection_task_status" :key="item.value" :value="item.value" :label="item.label"></el-option>
</el-select>
</el-form-item>
<el-form-item label="巡检日期" prop="taskTime">
<el-date-picker
@@ -33,14 +35,6 @@
<el-card class="flex-1" shadow="never">
<template #header>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['system:record:add']">临时跳转详情页</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['system:record:remove']"
>删除</el-button
>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
</template>
@@ -59,7 +53,11 @@
<span>{{ parseTime(scope.row.actualEndTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="执行状态" align="center" prop="status" />
<el-table-column label="执行状态" align="center" prop="status">
<template #default="scope">
<DictTag :options="com_inspection_task_status" :value="scope.row.status"></DictTag>
</template>
</el-table-column>
<el-table-column label="关联计划" align="center" prop="planName" />
<el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
<template #default="scope">
@@ -78,6 +76,7 @@ import { listRecord, getRecord, delRecord, addRecord, updateRecord } from '@/api
import { RecordVO, RecordQuery, RecordForm } from '@/api/system/InspectionRecord/type';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { com_inspection_task_status } = toRefs<any>(proxy?.useDict('com_inspection_task_status'));
const recordList = ref<RecordVO[]>([]);
const buttonLoading = ref(false);
@@ -167,21 +166,15 @@ const handleSelectionChange = (selection: RecordVO[]) => {
};
const router = useRouter();
/** 新增按钮操作 */
const handleAdd = () => {
router.push({
path: '/Inspection/RecordMain'
});
};
/** 修改按钮操作 */
const handleUpdate = async (row?: RecordVO) => {
reset();
const _id = row?.id || ids.value[0];
const res = await getRecord(_id);
Object.assign(form.value, res.data);
dialog.visible = true;
dialog.title = '修改巡检记录主';
router.push({
path: '/Inspection/RecordMain',
query: {
id: row.id
}
});
};
/** 提交按钮 */

View File

@@ -10,11 +10,11 @@
<el-form-item label="任务名称" prop="taskName">
<el-input v-model="form.taskName" placeholder="请输入"></el-input>
</el-form-item>
<el-form-item label="巡检人员" prop="inspectorIds">
<el-form-item label="巡检人员" prop="inspectorId">
<div class="inspectorIdsBox">
<div v-for="(item, index) in checkoutUserlist" :key="index" class="inspector_items">
<div class="name">{{ item.nickName }}</div>
<i @click="handleDelete" class="deleteaction">
<i @click="handleDelete(item.userId)" class="deleteaction">
<el-icon><Delete /></el-icon>
</i>
</div>
@@ -33,7 +33,7 @@
</el-form-item>
<el-form-item label="提醒时间" prop="remindTime">
<el-select v-model="form.remindTime" placeholder="请选择" style="width: 100%">
<el-option v-for="item in remindTimeoptions" :key="item.value" :label="item.label" :value="item.value" />
<el-option v-for="item in com_inspection_remind_tiime" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<!-- <el-form-item label="巡检设置">
@@ -73,8 +73,7 @@ import { getRoute, listRoute } from '@/api/system/InspectionRoute';
import { RouteVO } from '@/api/system/InspectionRoute/type';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { com_inspection_plan_setting } = toRefs<any>(proxy?.useDict('com_inspection_plan_setting'));
const { com_inspection_remind_tiime } = toRefs<any>(proxy?.useDict('com_inspection_remind_tiime'));
const route = useRoute();
const router = useRouter();
@@ -90,7 +89,7 @@ const rules = ref({
taskName: [{ required: true, message: '请输入巡检任务名称', trigger: 'blur' }],
taskTime: [{ required: true, message: '请选择巡检任务时间', trigger: 'blur' }],
remindTime: [{ required: true, message: '请选择巡检任务提醒时间', trigger: 'blur' }],
inspectorIds: [{ required: true, message: '请选择巡检人员', trigger: 'blur' }],
inspectorId: [{ required: true, message: '请选择巡检人员', trigger: 'blur' }],
planId: [{ required: true, message: '请选择巡检计划', trigger: 'blur' }]
});
@@ -126,11 +125,13 @@ async function init() {
form.value = {
id: res.data.id,
taskName: res.data.taskName, // 巡检计划名称
inspectorIds: res.data.inspectorIds, // 巡检人员
inspectorId: res.data.inspectorId, // 巡检人员
taskTime: res.data.taskTime, // 巡检人员
remindTime: res.data.remindTime, // 提醒时间
routeIds: res.data.routeIds // 计划路线id
planId: res.data.planId // 计划路线id
};
handlChangeMap(res.data.routeIds);
checkoutUserlist.value = Array.isArray(res.data.inspectorInfo) ? res.data.inspectorInfo : [res.data.inspectorInfo];
handlChangeMap(res.data.planId);
});
}
}
@@ -147,6 +148,7 @@ function handleUserChange(val) {
checkoutUserlist.value = val;
}
function handleDelete(id) {
console.log(id, checkoutUserlist.value);
checkoutUserlist.value = checkoutUserlist.value.filter((item) => item.userId !== id);
}

View File

@@ -115,7 +115,6 @@ const initFormData: TaskForm = {
inspectorId: undefined,
routeId: undefined,
taskTime: undefined,
inspectSetting: undefined,
costUnit: undefined,
status: undefined,
actualStartTime: undefined,
@@ -133,7 +132,6 @@ const data = reactive<PageData<TaskForm, TaskQuery>>({
inspectorId: undefined,
routeId: undefined,
taskTime: undefined,
inspectSetting: undefined,
costUnit: undefined,
status: undefined,
actualStartTime: undefined,