-f 项目优化
This commit is contained in:
parent
52cfc5621a
commit
64fd0be30b
@ -1,24 +1,7 @@
|
||||
// 运维工单接口
|
||||
import request from '@/utils/request';
|
||||
import { AxiosPromise } from 'axios';
|
||||
import { WorkOrderVO, WorkOrderQuery, WorkOrderForm, HandleForm, VerifyForm, SuperviseForm, ApproveForm, InternalDispatchForm, OrderRecordVO, OrderConfigVO, OrderConfigForm } from './types';
|
||||
|
||||
// 查询固定受理部门
|
||||
export function getOrderConfig(): AxiosPromise<OrderConfigVO> {
|
||||
return request({
|
||||
url: '/sbgl/orderConfig',
|
||||
method: 'get'
|
||||
});
|
||||
}
|
||||
|
||||
// 保存固定受理部门
|
||||
export function saveOrderConfig(data: OrderConfigForm) {
|
||||
return request({
|
||||
url: '/sbgl/orderConfig',
|
||||
method: 'put',
|
||||
data
|
||||
});
|
||||
}
|
||||
import { WorkOrderVO, WorkOrderQuery, WorkOrderForm, HandleForm, VerifyForm, SuperviseForm, ApproveForm, InternalDispatchForm, OrderRecordVO } from './types';
|
||||
|
||||
// 工单分页列表
|
||||
export function listOrder(query: WorkOrderQuery): AxiosPromise<WorkOrderVO[]> {
|
||||
|
||||
@ -122,13 +122,3 @@ export interface OrderRecordVO {
|
||||
createTime: string;
|
||||
}
|
||||
|
||||
export interface OrderConfigVO {
|
||||
id?: string | number;
|
||||
maintainerDeptId: string | number;
|
||||
maintainerDeptName?: string;
|
||||
updateTime?: string;
|
||||
}
|
||||
|
||||
export interface OrderConfigForm {
|
||||
maintainerDeptId: string | number;
|
||||
}
|
||||
|
||||
1
src/assets/geo/quzhou.json
Normal file
1
src/assets/geo/quzhou.json
Normal file
File diff suppressed because one or more lines are too long
@ -9,6 +9,7 @@
|
||||
import { ref, watch, onMounted, onBeforeUnmount, nextTick } from 'vue';
|
||||
import L from 'leaflet';
|
||||
import 'leaflet/dist/leaflet.css';
|
||||
import { isPointInGeoJson } from '@/utils/geo';
|
||||
|
||||
export interface MapPoint {
|
||||
id?: string | number;
|
||||
@ -36,17 +37,36 @@ const props = defineProps<{
|
||||
zoom?: number;
|
||||
/** 底图类型:road 路网图 / sat 卫星影像 */
|
||||
base?: 'road' | 'sat';
|
||||
/** 行政区划 GeoJSON(FeatureCollection) */
|
||||
geoJson?: any;
|
||||
/** 各区划统计值:区划名称 -> 数量 */
|
||||
districtCounts?: Record<string, number>;
|
||||
/** 高亮区划名称 */
|
||||
highlightDistrict?: string;
|
||||
/** 首次渲染区划时自动缩放到区划范围 */
|
||||
fitGeo?: boolean;
|
||||
/** 只显示区划边界,不显示名称/统计(用于选点限制范围) */
|
||||
boundaryOnly?: boolean;
|
||||
/** 隐藏区划名称标签(默认显示) */
|
||||
hideDistrictLabels?: boolean;
|
||||
/** 选点限制:只允许落在 geoJson 范围内 */
|
||||
restrictGeo?: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'pick', point: MapPoint): void;
|
||||
(e: 'pick-reject', point: MapPoint): void;
|
||||
(e: 'point-click', point: MapPoint): void;
|
||||
(e: 'district-click', name: string): void;
|
||||
}>();
|
||||
|
||||
const mapRef = ref<HTMLDivElement>();
|
||||
let map: L.Map | null = null;
|
||||
let markerLayer: L.LayerGroup | null = null;
|
||||
let pickMarker: L.Marker | null = null;
|
||||
let lastValidPick: MapPoint | null = null;
|
||||
let districtLayer: L.GeoJSON | null = null;
|
||||
let districtLabelLayer: L.LayerGroup | null = null;
|
||||
let resizeObserver: ResizeObserver | null = null;
|
||||
|
||||
/** 高德瓦片(GCJ-02,与 ZHJTQY 一致,免 key) */
|
||||
@ -67,16 +87,26 @@ function initMap() {
|
||||
map = L.map(mapRef.value, {
|
||||
center: [center[1], center[0]], // Leaflet 是 [lat, lng]
|
||||
zoom: props.zoom ?? 12,
|
||||
zoomSnap: 0.5,
|
||||
zoomDelta: 0.5,
|
||||
zoomControl: false,
|
||||
attributionControl: false
|
||||
});
|
||||
// 缩放控件放右下角:左上角常被图层面板/标题栏遮挡
|
||||
L.control.zoom({ position: 'bottomright' }).addTo(map);
|
||||
L.tileLayer(TILE_URLS[props.base ?? 'road'], TILE_OPTS).addTo(map);
|
||||
// 区划名称层:位于区划面之上、设备点位之下
|
||||
const labelPane = map.createPane('districtLabels');
|
||||
labelPane.style.zIndex = '450';
|
||||
districtLabelLayer = L.layerGroup().addTo(map);
|
||||
markerLayer = L.layerGroup().addTo(map);
|
||||
map.on('click', (e: L.LeafletMouseEvent) => {
|
||||
if (!props.pickMode) return;
|
||||
const point: MapPoint = { lng: +e.latlng.lng.toFixed(6), lat: +e.latlng.lat.toFixed(6) };
|
||||
if (props.restrictGeo && props.geoJson && !isPointInGeoJson(props.geoJson, point.lng, point.lat)) {
|
||||
emit('pick-reject', point);
|
||||
return;
|
||||
}
|
||||
setPickMarker(point);
|
||||
emit('pick', point);
|
||||
});
|
||||
@ -91,13 +121,24 @@ function initMap() {
|
||||
|
||||
function setPickMarker(point: MapPoint) {
|
||||
if (!map) return;
|
||||
lastValidPick = point;
|
||||
if (pickMarker) {
|
||||
map.removeLayer(pickMarker);
|
||||
}
|
||||
pickMarker = L.marker([point.lat, point.lng], { draggable: true }).addTo(map);
|
||||
pickMarker.on('dragend', () => {
|
||||
const pos = pickMarker!.getLatLng();
|
||||
emit('pick', { lng: +pos.lng.toFixed(6), lat: +pos.lat.toFixed(6) });
|
||||
const next = { lng: +pos.lng.toFixed(6), lat: +pos.lat.toFixed(6) };
|
||||
if (props.restrictGeo && props.geoJson && !isPointInGeoJson(props.geoJson, next.lng, next.lat)) {
|
||||
// 拖出衢州范围:回到上一个有效位置
|
||||
if (lastValidPick) {
|
||||
pickMarker!.setLatLng([lastValidPick.lat, lastValidPick.lng]);
|
||||
}
|
||||
emit('pick-reject', next);
|
||||
return;
|
||||
}
|
||||
lastValidPick = next;
|
||||
emit('pick', next);
|
||||
});
|
||||
map.panTo([point.lat, point.lng]);
|
||||
}
|
||||
@ -123,17 +164,106 @@ function renderPoints() {
|
||||
marker.addTo(markerLayer!);
|
||||
});
|
||||
const list = (props.points ?? []).filter((p) => p.lng && p.lat);
|
||||
if (list.length === 1) {
|
||||
if (list.length === 1 && !props.geoJson) {
|
||||
map.setView([list[0].lat, list[0].lng], 15);
|
||||
}
|
||||
}
|
||||
|
||||
/** 行政区划底色 + 区划名称/统计标签 */
|
||||
function renderDistricts(fitGeo = false) {
|
||||
if (!map) return;
|
||||
if (districtLayer) {
|
||||
map.removeLayer(districtLayer);
|
||||
districtLayer = null;
|
||||
}
|
||||
districtLabelLayer?.clearLayers();
|
||||
if (!props.geoJson) return;
|
||||
|
||||
const active = props.highlightDistrict;
|
||||
const styleOf = (name: string, hover = false) => {
|
||||
if (props.boundaryOnly) {
|
||||
return {
|
||||
color: hover ? '#409EFF' : '#79a7e8',
|
||||
weight: hover ? 2 : 1.2,
|
||||
opacity: 0.9,
|
||||
fillColor: '#409EFF',
|
||||
fillOpacity: hover ? 0.08 : 0.03
|
||||
};
|
||||
}
|
||||
const isActive = !!active && name === active;
|
||||
return {
|
||||
color: isActive ? '#64dcff' : hover ? '#9fd2ff' : '#8fa8ef',
|
||||
weight: isActive ? 2.4 : hover ? 2 : 1.1,
|
||||
opacity: 0.95,
|
||||
fillColor: isActive ? '#16357f' : '#7486c8',
|
||||
fillOpacity: isActive ? 0.55 : hover ? 0.38 : 0.2
|
||||
};
|
||||
};
|
||||
|
||||
districtLayer = L.geoJSON(props.geoJson, {
|
||||
style: (feature: any) => styleOf(feature?.properties?.name ?? ''),
|
||||
onEachFeature: (feature: any, layer: L.Layer) => {
|
||||
const name = feature?.properties?.name ?? '';
|
||||
// 悬停高亮
|
||||
layer.on('mouseover', () => (layer as any).setStyle?.(styleOf(name, true)));
|
||||
layer.on('mouseout', () => (layer as any).setStyle?.(styleOf(name)));
|
||||
layer.on('click', () => emit('district-click', name));
|
||||
// 区域选点模式只画边界,不显示名称/数量
|
||||
if (props.boundaryOnly || props.hideDistrictLabels) return;
|
||||
// 区划中心放名称 + 设备数,仿参考系统
|
||||
const center = (layer as any).getBounds?.().getCenter?.();
|
||||
if (!center || !districtLabelLayer) return;
|
||||
const count = props.districtCounts?.[name] ?? 0;
|
||||
const isActive = !!active && name === active;
|
||||
// 区划中心点较近时做固定像素偏移,避免标签互相遮挡
|
||||
const offset: Record<string, [number, number]> = {
|
||||
柯城区: [0, -34],
|
||||
衢江区: [0, 34],
|
||||
常山县: [-38, 10],
|
||||
龙游县: [38, -16]
|
||||
};
|
||||
const [dx, dy] = offset[name] ?? [0, 0];
|
||||
const icon = L.divIcon({
|
||||
className: 'sb-district-label',
|
||||
html: `<div class="sb-district-card${isActive ? ' is-active' : ''}">
|
||||
<span class="sb-district-card__name">${escapeHtml(name)}</span>
|
||||
<span class="sb-district-card__count">${count} 台</span>
|
||||
</div>`,
|
||||
iconSize: [116, 32],
|
||||
iconAnchor: [58 - dx, 16 - dy]
|
||||
});
|
||||
L.marker(center, { icon, interactive: false, pane: 'districtLabels', keyboard: false })
|
||||
.addTo(districtLabelLayer);
|
||||
}
|
||||
}).addTo(map);
|
||||
districtLayer.bringToBack();
|
||||
|
||||
if (fitGeo && props.fitGeo !== false) {
|
||||
map.fitBounds(districtLayer.getBounds(), { padding: [36, 36], maxZoom: 10 });
|
||||
}
|
||||
}
|
||||
|
||||
function escapeHtml(value: string) {
|
||||
return value.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.points,
|
||||
() => renderPoints(),
|
||||
{ deep: true }
|
||||
);
|
||||
|
||||
watch(
|
||||
() => props.geoJson,
|
||||
() => renderDistricts(true)
|
||||
);
|
||||
|
||||
watch(
|
||||
[() => props.districtCounts, () => props.highlightDistrict],
|
||||
() => renderDistricts(false),
|
||||
{ deep: true }
|
||||
);
|
||||
|
||||
watch(
|
||||
() => props.selected,
|
||||
(val) => {
|
||||
@ -145,6 +275,7 @@ watch(
|
||||
onMounted(async () => {
|
||||
await nextTick();
|
||||
initMap();
|
||||
renderDistricts(true);
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
@ -162,7 +293,19 @@ function flyTo(lng: number, lat: number, zoom = 16) {
|
||||
map.setView([lat, lng], zoom);
|
||||
}
|
||||
|
||||
defineExpose({ flyTo });
|
||||
/** 缩放并居中到指定行政区划 */
|
||||
function fitDistrict(name: string) {
|
||||
if (!map || !props.geoJson) return;
|
||||
const feature = (props.geoJson.features ?? []).find(
|
||||
(f: any) => f?.properties?.name === name
|
||||
);
|
||||
if (!feature) return;
|
||||
const bounds = L.geoJSON(feature).getBounds();
|
||||
if (!bounds.isValid()) return;
|
||||
map.fitBounds(bounds, { padding: [48, 48], maxZoom: 12 });
|
||||
}
|
||||
|
||||
defineExpose({ flyTo, fitDistrict });
|
||||
</script>
|
||||
|
||||
<style>
|
||||
@ -181,6 +324,47 @@ defineExpose({ flyTo });
|
||||
font-size: 13px;
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
/* 行政区划名称/统计卡(divIcon,非 scoped) */
|
||||
.sb-district-label {
|
||||
background: transparent;
|
||||
border: none;
|
||||
pointer-events: none;
|
||||
}
|
||||
.sb-district-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 7px;
|
||||
width: 108px;
|
||||
height: 28px;
|
||||
padding: 0 8px;
|
||||
box-sizing: border-box;
|
||||
color: #dce9ff;
|
||||
background: linear-gradient(180deg, rgba(20, 55, 120, 0.9), rgba(9, 27, 62, 0.9));
|
||||
border: 1px solid rgba(98, 170, 255, 0.55);
|
||||
border-radius: 14px;
|
||||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
|
||||
white-space: nowrap;
|
||||
}
|
||||
.sb-district-card.is-active {
|
||||
color: #fff;
|
||||
border-color: #64dcff;
|
||||
background: linear-gradient(180deg, rgba(29, 74, 166, 0.96), rgba(11, 34, 86, 0.96));
|
||||
box-shadow: 0 0 14px rgba(70, 180, 255, 0.35);
|
||||
}
|
||||
.sb-district-card__name {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
.sb-district-card__count {
|
||||
font-size: 12px;
|
||||
color: #5ed8ff;
|
||||
}
|
||||
.sb-district-card.is-active .sb-district-card__count {
|
||||
color: #8ff0ff;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style scoped>
|
||||
|
||||
50
src/utils/geo.ts
Normal file
50
src/utils/geo.ts
Normal file
@ -0,0 +1,50 @@
|
||||
/**
|
||||
* 简单 GeoJSON 行政区划工具(无第三方依赖)。
|
||||
* 坐标顺序统一为 [lng, lat]。
|
||||
*/
|
||||
|
||||
/** 射线法判断点是否在环内 */
|
||||
function pointInRing(lng: number, lat: number, ring: number[][]): boolean {
|
||||
let inside = false;
|
||||
for (let i = 0, j = ring.length - 1; i < ring.length; j = i++) {
|
||||
const xi = ring[i][0];
|
||||
const yi = ring[i][1];
|
||||
const xj = ring[j][0];
|
||||
const yj = ring[j][1];
|
||||
if (yi > lat !== yj > lat && lng < ((xj - xi) * (lat - yi)) / (yj - yi) + xi) {
|
||||
inside = !inside;
|
||||
}
|
||||
}
|
||||
return inside;
|
||||
}
|
||||
|
||||
/** Polygon:第一个环为外环,其余为内环(洞) */
|
||||
function pointInPolygon(lng: number, lat: number, rings: number[][][]): boolean {
|
||||
if (!rings?.length || !pointInRing(lng, lat, rings[0])) return false;
|
||||
for (let i = 1; i < rings.length; i++) {
|
||||
if (pointInRing(lng, lat, rings[i])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** 返回坐标所在的区划名称;不在任何区划内返回空字符串 */
|
||||
export function locateDistrict(geoJson: any, lng: number, lat: number): string {
|
||||
const features = geoJson?.features ?? [];
|
||||
for (const feature of features) {
|
||||
const geometry = feature?.geometry;
|
||||
if (!geometry) continue;
|
||||
if (geometry.type === 'Polygon' && pointInPolygon(lng, lat, geometry.coordinates)) {
|
||||
return feature.properties?.name ?? '';
|
||||
}
|
||||
if (geometry.type === 'MultiPolygon'
|
||||
&& geometry.coordinates.some((poly: number[][][]) => pointInPolygon(lng, lat, poly))) {
|
||||
return feature.properties?.name ?? '';
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/** 点是否落在 GeoJSON 行政区划范围内 */
|
||||
export function isPointInGeoJson(geoJson: any, lng: number, lat: number): boolean {
|
||||
return locateDistrict(geoJson, lng, lat) !== '';
|
||||
}
|
||||
@ -128,7 +128,7 @@
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="设备编号" prop="deviceCode">
|
||||
<el-input v-model="form.deviceCode" placeholder="全局唯一编号" />
|
||||
<el-input v-model="form.deviceCode" placeholder="选填,全局唯一编号" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
@ -237,7 +237,9 @@
|
||||
|
||||
<!-- 地图选点 -->
|
||||
<el-dialog title="地图选点(点击地图拾取坐标,可拖动标记微调)" v-model="mapPickVisible" width="760px" append-to-body>
|
||||
<sb-map pick-mode height="460px" :center="form.lng && form.lat ? [form.lng, form.lat] : undefined" :selected="pickedPoint" @pick="onPick" />
|
||||
<sb-map pick-mode height="460px" :center="[118.87, 28.97]" :zoom="9"
|
||||
:selected="pickedPoint" :geo-json="quzhouGeo" boundary-only :restrict-geo="true"
|
||||
@pick="onPick" @pick-reject="onPickReject" />
|
||||
<div class="mt-2">当前坐标:{{ form.lng || '-' }},{{ form.lat || '-' }}</div>
|
||||
<template #footer>
|
||||
<el-button type="primary" @click="mapPickVisible = false">使用该坐标</el-button>
|
||||
@ -324,6 +326,8 @@ import { parseFieldOptions, fieldValueArray, formatFieldValue, normalizeFieldVal
|
||||
import { listDevice, getDevice, addDevice, updateDevice, delDevice, importTemplate, importData, exportDevice, listRecycleDevice, restoreDevice } from '@/api/sbgl/device';
|
||||
import { DeviceVO, DeviceQuery, DeviceForm, ImportResultVO } from '@/api/sbgl/device/types';
|
||||
import { getCommonDeptTree, listBusinessOss } from '@/api/sbgl/common';
|
||||
import { isPointInGeoJson } from '@/utils/geo';
|
||||
import quzhouGeo from '@/assets/geo/quzhou.json';
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const { sb_device_status } = toRefs<any>(proxy?.useDict('sb_device_status'));
|
||||
const router = useRouter();
|
||||
@ -383,7 +387,6 @@ let form = ref<DeviceForm>({
|
||||
|
||||
// 校验规则:经纬度按类型动态补
|
||||
const formRules = {
|
||||
deviceCode: [{ required: true, message: '设备编号不能为空', trigger: 'blur' }],
|
||||
deviceName: [{ required: true, message: '设备名称不能为空', trigger: 'blur' }],
|
||||
typeId: [{ required: true, message: '设备类型不能为空', trigger: 'change' }]
|
||||
};
|
||||
@ -607,6 +610,11 @@ const submitForm = () => {
|
||||
proxy?.$modal.msgWarning('该类型设备必须填写经纬度(可使用地图选点)');
|
||||
return;
|
||||
}
|
||||
if (form.value.lng !== undefined && form.value.lat !== undefined
|
||||
&& !isPointInGeoJson(quzhouGeo, Number(form.value.lng), Number(form.value.lat))) {
|
||||
proxy?.$modal.msgWarning('设备位置必须在衢州市行政区划范围内');
|
||||
return;
|
||||
}
|
||||
if (form.value.id) {
|
||||
await updateDevice(form.value);
|
||||
proxy?.$modal.msgSuccess('修改成功');
|
||||
@ -670,6 +678,11 @@ const onPick = (point: { lng: number; lat: number }) => {
|
||||
pickedPoint.value = point;
|
||||
};
|
||||
|
||||
/** 选点超出衢州市行政区划范围时拒绝 */
|
||||
const onPickReject = () => {
|
||||
proxy?.$modal.msgWarning('设备位置必须在衢州市行政区划范围内');
|
||||
};
|
||||
|
||||
// ---------------- 导入导出 ----------------
|
||||
const handleDownloadTemplate = () => {
|
||||
importTemplate(importForm.typeId);
|
||||
|
||||
@ -467,8 +467,9 @@ const approveNodeTypeLabel = (type: string) =>
|
||||
({ SUPERVISE: '监理确认', VERIFY: '验收', APPROVAL: '审批' }[type] || '审批');
|
||||
const canUrge = computed(
|
||||
() =>
|
||||
['PENDING_DISPATCH', 'TO_ACCEPT', 'ACCEPTED', 'PROCESSING'].includes(detail.value.status) &&
|
||||
(isReporter.value || isAdmin.value)
|
||||
(!!detail.value.currentNodeId ||
|
||||
['PENDING_DISPATCH', 'TO_ACCEPT', 'ACCEPTED', 'PROCESSING'].includes(detail.value.status)) &&
|
||||
isReporter.value
|
||||
);
|
||||
const canClose = computed(
|
||||
() =>
|
||||
@ -905,7 +906,9 @@ const doVerify = async (result: number) => {
|
||||
const doUrge = async () => {
|
||||
const waitingAccept = detail.value.status === 'TO_ACCEPT' && !detail.value.handlerId;
|
||||
await urgeOrder(detail.value.id);
|
||||
ElMessage.success(waitingAccept ? '已催办,已通知受理部门人员接单' : '已催办,已通知处理人');
|
||||
ElMessage.success(waitingAccept
|
||||
? '已催办,已通知运维单位人员接单'
|
||||
: `已催办,已通知当前环节处理人${detail.value.currentNodeName ? '(' + detail.value.currentNodeName + ')' : ''}`);
|
||||
detailVisible.value = false;
|
||||
};
|
||||
|
||||
@ -1013,7 +1016,7 @@ const doSubmitOrder = async () => {
|
||||
ElMessage.success('修改成功');
|
||||
} else {
|
||||
await submitOrder({ ...createForm, images: createForm.images || undefined } as any);
|
||||
ElMessage.success('发起成功,已通知受理部门接单');
|
||||
ElMessage.success('发起成功,已进入审批流程');
|
||||
}
|
||||
submitVisible.value = false;
|
||||
detailVisible.value = false;
|
||||
|
||||
@ -100,10 +100,12 @@
|
||||
<el-option label="仅按角色(全部同角色人员)" value="ROLE_ONLY" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.approverScope === 'FIXED_DEPT'" label="审批部门" prop="approverDeptId">
|
||||
<el-form-item v-if="['FIXED_DEPT', 'MAINTAINER_DEPT'].includes(form.approverScope)"
|
||||
:label="form.approverScope === 'MAINTAINER_DEPT' ? '运维单位' : '审批部门'" prop="approverDeptId">
|
||||
<el-tree-select v-model="form.approverDeptId" :data="deptOptions" node-key="id"
|
||||
:props="{ label: 'label', children: 'children' }" check-strictly filterable
|
||||
placeholder="请选择审批部门" style="width: 100%" />
|
||||
:placeholder="form.approverScope === 'MAINTAINER_DEPT' ? '请选择接单/派单的运维单位' : '请选择审批部门'"
|
||||
style="width: 100%" />
|
||||
</el-form-item>
|
||||
<el-form-item label="审批顺序" prop="sort">
|
||||
<el-input-number v-model="form.sort" :min="0" :precision="0" style="width: 180px" />
|
||||
@ -173,7 +175,7 @@ const nodeTypeTag = (type: string) => ({
|
||||
const scopeLabel = (scope: string, deptName?: string) => ({
|
||||
REPORTER_ANCESTOR: '提交人上级部门',
|
||||
FIXED_DEPT: `固定部门${deptName ? ':' + deptName : ''}`,
|
||||
MAINTAINER_DEPT: '固定运维单位',
|
||||
MAINTAINER_DEPT: `固定运维单位${deptName ? ':' + deptName : ''}`,
|
||||
ASSIGNEE: '当前处理人',
|
||||
ROLE_ONLY: '仅按角色'
|
||||
}[scope || 'ROLE_ONLY'] || scope);
|
||||
@ -233,8 +235,9 @@ const handleUpdate = async (row: OrderFlowNodeVO) => {
|
||||
const submitForm = () => {
|
||||
formRef.value?.validate(async (valid: boolean) => {
|
||||
if (!valid || submitting.value) return;
|
||||
if (form.value.approverScope === 'FIXED_DEPT' && !form.value.approverDeptId) {
|
||||
proxy?.$modal.msgWarning('固定部门审批必须选择审批部门');
|
||||
if (['FIXED_DEPT', 'MAINTAINER_DEPT'].includes(form.value.approverScope) && !form.value.approverDeptId) {
|
||||
proxy?.$modal.msgWarning(form.value.approverScope === 'MAINTAINER_DEPT'
|
||||
? '固定运维单位必须选择运维单位部门' : '固定部门审批必须选择审批部门');
|
||||
return;
|
||||
}
|
||||
submitting.value = true;
|
||||
|
||||
@ -36,6 +36,14 @@
|
||||
<span class="stat-num">{{ item.count }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel">
|
||||
<div class="panel__title">行政区划</div>
|
||||
<div v-for="item in districtList" :key="item.name" class="stat-row district-row"
|
||||
:class="{ 'is-active': highlightDistrict === item.name }" @click="onDistrictClick(item.name)">
|
||||
<span>{{ item.name }}</span>
|
||||
<span class="stat-num">{{ item.count }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel">
|
||||
<div class="panel__title">工单概况</div>
|
||||
<div class="stat-row"><span>待派单</span><span class="stat-num warn">{{ overview.orderPending ?? 0 }}</span></div>
|
||||
@ -46,7 +54,10 @@
|
||||
|
||||
<!-- 中央地图 -->
|
||||
<main class="sb-screen__map">
|
||||
<sb-map height="100%" :points="visiblePoints" @point-click="onPointClick" />
|
||||
<sb-map ref="mapRef" height="100%" :points="visiblePoints" :geo-json="quzhouGeo"
|
||||
:district-counts="districtCounts" :highlight-district="highlightDistrict"
|
||||
:center="[118.75, 28.78]" :zoom="9.5"
|
||||
@point-click="onPointClick" @district-click="onDistrictClick" />
|
||||
</main>
|
||||
|
||||
<!-- 右侧(透明悬浮于地图上) -->
|
||||
@ -94,6 +105,8 @@ import { DeviceVO } from '@/api/sbgl/device/types';
|
||||
import { DeviceTypeVO } from '@/api/sbgl/devicetype/types';
|
||||
import { StatItemVO, OverviewVO } from '@/api/sbgl/stats';
|
||||
import { formatFieldValue } from '../devicetype/fieldTypes';
|
||||
import { locateDistrict } from '@/utils/geo';
|
||||
import quzhouGeo from '@/assets/geo/quzhou.json';
|
||||
|
||||
const { proxy } = getCurrentInstance() as any;
|
||||
const { sb_device_status } = toRefs<any>(proxy?.useDict('sb_device_status'));
|
||||
@ -109,6 +122,10 @@ const layersCollapsed = ref(true);
|
||||
const selected = ref<DeviceVO | null>(null);
|
||||
/** 各类型启用的属性字段配置:typeId -> fieldKey -> { label, fieldType } */
|
||||
const fieldMetaMap = ref<Record<string, Record<string, { label: string; fieldType: string }>>>({});
|
||||
/** 当前选中的行政区划(空表示全部) */
|
||||
const activeDistrict = ref('');
|
||||
const mapRef = ref<any>();
|
||||
const geoFeatures = (quzhouGeo as any).features ?? [];
|
||||
|
||||
const statusText = (s?: string) => {
|
||||
if (s === null || s === undefined || s === '') return '-';
|
||||
@ -134,6 +151,68 @@ const attrRows = computed(() => {
|
||||
const esc = (s: unknown) =>
|
||||
String(s ?? '').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
||||
|
||||
/* ---------- 行政区划:点位归属与统计 ---------- */
|
||||
/** 没有经纬度时,按部门名称兜底归属 */
|
||||
const districtByDeptName = (deptName?: string) => {
|
||||
if (!deptName) return '';
|
||||
if (deptName.includes('柯城')) return '柯城区';
|
||||
if (deptName.includes('衢江') || deptName.includes('集聚区')) return '衢江区';
|
||||
if (deptName.includes('龙游')) return '龙游县';
|
||||
if (deptName.includes('江山')) return '江山市';
|
||||
if (deptName.includes('常山')) return '常山县';
|
||||
if (deptName.includes('开化')) return '开化县';
|
||||
return '';
|
||||
};
|
||||
|
||||
const deviceDistrict = (device: DeviceVO) => {
|
||||
const lng = Number(device.lng);
|
||||
const lat = Number(device.lat);
|
||||
if (Number.isFinite(lng) && Number.isFinite(lat)) {
|
||||
const name = locateDistrict(quzhouGeo, lng, lat);
|
||||
if (name) return name;
|
||||
}
|
||||
return districtByDeptName(device.deptName);
|
||||
};
|
||||
|
||||
const districtCounts = computed<Record<string, number>>(() => {
|
||||
const counts: Record<string, number> = {};
|
||||
geoFeatures.forEach((f: any) => {
|
||||
counts[f.properties?.name ?? ''] = 0;
|
||||
});
|
||||
deviceList.value.forEach((device) => {
|
||||
const name = deviceDistrict(device);
|
||||
if (name && name in counts) counts[name] += 1;
|
||||
});
|
||||
return counts;
|
||||
});
|
||||
|
||||
const districtList = computed(() =>
|
||||
geoFeatures.map((f: any) => ({
|
||||
name: f.properties?.name ?? '',
|
||||
count: districtCounts.value[f.properties?.name ?? ''] ?? 0
|
||||
}))
|
||||
);
|
||||
|
||||
/** 默认高亮设备最多的区划;点击后高亮并筛选该区划 */
|
||||
const maxDistrictName = computed(() => {
|
||||
let name = '';
|
||||
let max = -1;
|
||||
districtList.value.forEach((item) => {
|
||||
if (item.count > max) {
|
||||
max = item.count;
|
||||
name = item.name;
|
||||
}
|
||||
});
|
||||
return name;
|
||||
});
|
||||
const highlightDistrict = computed(() => activeDistrict.value || maxDistrictName.value);
|
||||
const onDistrictClick = (name: string) => {
|
||||
activeDistrict.value = name;
|
||||
selected.value = null;
|
||||
// 点击区划后居中并放大到该区划
|
||||
mapRef.value?.fitDistrict(name);
|
||||
};
|
||||
|
||||
const visiblePoints = computed(() =>
|
||||
deviceList.value
|
||||
.filter((d) => visibleTypes.value.includes(String(d.typeId)) && d.lng && d.lat)
|
||||
@ -360,34 +439,37 @@ onMounted(async () => {
|
||||
}
|
||||
/* 面板:白底深字(全局 aside 字色为深色,白底更清晰) */
|
||||
.panel {
|
||||
background: rgba(255, 255, 255, 0.82);
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
|
||||
background: linear-gradient(180deg, rgba(10, 34, 72, 0.9), rgba(6, 22, 48, 0.86));
|
||||
box-shadow: 0 2px 14px rgba(0, 0, 0, 0.35);
|
||||
transition: none;
|
||||
border: 1px solid #d9e4f3;
|
||||
border-radius: 6px;
|
||||
border: 1px solid rgba(58, 133, 224, 0.5);
|
||||
border-radius: 4px;
|
||||
padding: 12px;
|
||||
margin-bottom: 10px;
|
||||
color: #243244;
|
||||
color: #cfe3ff;
|
||||
backdrop-filter: blur(3px);
|
||||
&:hover {
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
|
||||
box-shadow: 0 2px 14px rgba(0, 0, 0, 0.35);
|
||||
}
|
||||
}
|
||||
.panel__title {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
margin-bottom: 8px;
|
||||
border-left: 3px solid #1d6fd0;
|
||||
border-left: 3px solid #2d9cff;
|
||||
padding-left: 8px;
|
||||
color: #1d3a66;
|
||||
color: #6fdcff;
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
.panel__sub {
|
||||
font-size: 12px;
|
||||
color: #64748b;
|
||||
color: #8ea8cc;
|
||||
}
|
||||
.big-num {
|
||||
font-size: 34px;
|
||||
font-weight: 700;
|
||||
color: #1d6fd0;
|
||||
color: #5ed8ff;
|
||||
text-shadow: 0 0 12px rgba(70, 190, 255, 0.4);
|
||||
}
|
||||
.stat-row {
|
||||
display: flex;
|
||||
@ -397,15 +479,29 @@ onMounted(async () => {
|
||||
}
|
||||
.stat-num {
|
||||
font-weight: 600;
|
||||
color: #e2efff;
|
||||
}
|
||||
.stat-num.warn { color: #ffb45c; }
|
||||
.stat-num.info { color: #5cc8ff; }
|
||||
.stat-num.ok { color: #48e0a0; }
|
||||
.district-row {
|
||||
cursor: pointer;
|
||||
padding: 5px 6px;
|
||||
margin: 0 -6px;
|
||||
border-radius: 3px;
|
||||
&:hover {
|
||||
background: rgba(0, 138, 255, 0.16);
|
||||
}
|
||||
&.is-active {
|
||||
background: rgba(0, 138, 255, 0.24);
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
.stat-num.warn { color: #d97a1f; }
|
||||
.stat-num.info { color: #1d6fd0; }
|
||||
.stat-num.ok { color: #2ca35e; }
|
||||
.detail-name {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
margin-bottom: 8px;
|
||||
color: #1d6fd0;
|
||||
color: #6fdcff;
|
||||
}
|
||||
.detail-row {
|
||||
font-size: 13px;
|
||||
@ -414,12 +510,12 @@ onMounted(async () => {
|
||||
.detail-attrs-title {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: #64748b;
|
||||
color: #8ea8cc;
|
||||
margin: 8px 0 2px;
|
||||
border-top: 1px dashed #d9e4f3;
|
||||
border-top: 1px dashed rgba(93, 145, 214, 0.4);
|
||||
padding-top: 8px;
|
||||
}
|
||||
.status-tag.ok { color: #2ca35e; }
|
||||
.status-tag.warn { color: #d97a1f; }
|
||||
.status-tag.bad { color: #d64545; }
|
||||
.status-tag.ok { color: #48e0a0; }
|
||||
.status-tag.warn { color: #ffb45c; }
|
||||
.status-tag.bad { color: #ff6b6b; }
|
||||
</style>
|
||||
|
||||
@ -32,10 +32,6 @@
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Plus" @click="openSubmit">发起工单</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="info" plain icon="Setting" @click="openOrderConfig"
|
||||
v-hasPermi="['sbgl:order:config']">受理部门设置</el-button>
|
||||
</el-col>
|
||||
<right-toolbar v-model:show-search="showSearch" @query-table="getList" />
|
||||
</el-row>
|
||||
</template>
|
||||
@ -100,9 +96,9 @@
|
||||
<el-button v-if="scope.row.status === 'PENDING_SUPERVISE' && !scope.row.currentNodeId"
|
||||
link type="warning" icon="Stamp" @click="openSupervise(scope.row)" v-hasPermi="['sbgl:order:supervise']"
|
||||
v-show="String(scope.row.handlerId) !== String(userStore.userId) || Number(userStore.userId) === 1">监理</el-button>
|
||||
<el-button v-if="IN_PROCESS.includes(scope.row.status)"
|
||||
<el-button v-if="scope.row.currentNodeId || IN_PROCESS.includes(scope.row.status)"
|
||||
link type="warning" icon="Bell" @click="handleUrge(scope.row)"
|
||||
v-show="String(scope.row.reportBy) === String(userStore.userId) || Number(userStore.userId) === 1">催办</el-button>
|
||||
v-show="String(scope.row.reportBy) === String(userStore.userId)">催办</el-button>
|
||||
<el-button v-if="scope.row.status === 'PENDING_VERIFY' && !scope.row.currentNodeId && String(scope.row.handlerId) !== String(userStore.userId)"
|
||||
link type="success" icon="CircleCheck" @click="openVerify(scope.row)" v-hasPermi="['sbgl:order:verify']">验收</el-button>
|
||||
<el-button link type="primary" icon="View" @click="openDetail(scope.row)">详情</el-button>
|
||||
@ -155,23 +151,6 @@
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 受理部门设置 -->
|
||||
<el-dialog v-model="orderConfigDialog.visible" title="受理部门设置" width="520px" append-to-body>
|
||||
<el-form ref="orderConfigFormRef" :model="orderConfigForm" :rules="orderConfigRules" label-width="110px">
|
||||
<el-form-item label="固定受理部门" prop="maintainerDeptId">
|
||||
<el-tree-select v-model="orderConfigForm.maintainerDeptId" :data="deptOptions" node-key="id"
|
||||
:props="{ label: 'label', children: 'children' }" check-strictly filterable
|
||||
placeholder="请选择受理部门" style="width: 100%" />
|
||||
</el-form-item>
|
||||
<el-alert type="info" :closable="false"
|
||||
title="新工单创建后自动分派到该部门(含下级部门),部门内人员均可接单,不再需要手动派单。" />
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button type="primary" :loading="configSubmitting" @click="saveOrderConfigForm">保 存</el-button>
|
||||
<el-button @click="orderConfigDialog.visible = false">取 消</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 验收 -->
|
||||
<el-dialog title="工单验收" v-model="verifyDialog.visible" width="520px" append-to-body>
|
||||
<el-form ref="verifyFormRef" :model="verifyForm" label-width="100px">
|
||||
@ -406,14 +385,13 @@
|
||||
<script setup name="WorkOrder" lang="ts">
|
||||
import ImagePreview from '@/components/ImagePreview/index.vue';
|
||||
import { listBusinessOss } from '@/api/sbgl/common';
|
||||
import { listOrder, getOrder, submitOrder, updateOrder, handleOrder, superviseOrder, approveOrder, dispatchInternal, listDispatchHandlers, verifyOrder, closeOrder, urgeOrder, listOrderRecords, getOrderConfig, saveOrderConfig } from '@/api/sbgl/workorder';
|
||||
import { listOrder, getOrder, submitOrder, updateOrder, handleOrder, superviseOrder, approveOrder, dispatchInternal, listDispatchHandlers, verifyOrder, closeOrder, urgeOrder, listOrderRecords } from '@/api/sbgl/workorder';
|
||||
import { WorkOrderVO, WorkOrderQuery, WorkOrderForm, OrderRecordVO } from '@/api/sbgl/workorder/types';
|
||||
import { listContractPriceOptions } from '@/api/sbgl/contractPrice';
|
||||
import { ContractPriceVO } from '@/api/sbgl/contractPrice/types';
|
||||
import { listDevice, getDeviceOptions } from '@/api/sbgl/device';
|
||||
import { listTypeOptions } from '@/api/sbgl/devicetype';
|
||||
import { DeviceVO } from '@/api/sbgl/device/types';
|
||||
import { getCommonDeptTree } from '@/api/sbgl/common';
|
||||
import { useUserStore } from '@/store/modules/user';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
@ -428,10 +406,6 @@ const queryFormRef = ref<ElFormInstance>();
|
||||
const queryParams = ref<WorkOrderQuery>({ pageNum: 1, pageSize: 10 });
|
||||
|
||||
const submitDialog = reactive({ visible: false, editMode: false });
|
||||
const orderConfigDialog = reactive({ visible: false });
|
||||
const orderConfigFormRef = ref<ElFormInstance>();
|
||||
const configSubmitting = ref(false);
|
||||
const orderConfigForm = reactive<{ maintainerDeptId: any }>({ maintainerDeptId: '' });
|
||||
const verifyDialog = reactive({ visible: false, title: '' });
|
||||
const superviseDialog = reactive({
|
||||
visible: false, title: '', amount: 0, autoAmount: 0, adjustReason: ''
|
||||
@ -454,7 +428,6 @@ const dispatchHandlerOptions = ref<any[]>([]);
|
||||
const dispatchSubmitting = ref(false);
|
||||
|
||||
let submitForm = ref<WorkOrderForm>({ orderType: 'bx', title: '' });
|
||||
const deptOptions = ref<any[]>([]);
|
||||
const verifyForm = reactive<{ orderId: any; verifyResult: number; verifyOpinion: string }>({ orderId: '', verifyResult: 1, verifyOpinion: '' });
|
||||
const handleDialog = reactive({ visible: false, title: '', status: '', orderType: '', finishOnly: false });
|
||||
const handleForm = reactive<{
|
||||
@ -486,10 +459,6 @@ const submitRules = {
|
||||
orderType: [{ required: true, message: '请选择工单类型', trigger: 'change' }],
|
||||
title: [{ required: true, message: '工单标题不能为空', trigger: 'blur' }]
|
||||
};
|
||||
const orderConfigRules = {
|
||||
maintainerDeptId: [{ required: true, message: '请选择固定受理部门', trigger: 'change' }]
|
||||
};
|
||||
|
||||
const actionLabel = (action: string) => {
|
||||
const map: Record<string, string> = {
|
||||
SUBMIT: '发起工单', UPDATE: '修改工单', DISPATCH: '派单', RE_DISPATCH: '改派', AUTO_DISPATCH: '自动分派',
|
||||
@ -578,7 +547,7 @@ const doSubmit = () => {
|
||||
proxy?.$modal.msgSuccess('工单已修改');
|
||||
} else {
|
||||
await submitOrder(submitForm.value);
|
||||
proxy?.$modal.msgSuccess('工单已发起,已通知受理部门接单');
|
||||
proxy?.$modal.msgSuccess('工单已发起,已进入审批流程');
|
||||
}
|
||||
submitDialog.visible = false;
|
||||
getList();
|
||||
@ -588,37 +557,6 @@ const doSubmit = () => {
|
||||
});
|
||||
};
|
||||
|
||||
// ---------------- 受理部门设置 ----------------
|
||||
const openOrderConfig = async () => {
|
||||
orderConfigForm.maintainerDeptId = '';
|
||||
orderConfigFormRef.value?.clearValidate();
|
||||
orderConfigDialog.visible = true;
|
||||
const tree = await getCommonDeptTree();
|
||||
deptOptions.value = (tree.data ?? []) as any[];
|
||||
try {
|
||||
const res = await getOrderConfig();
|
||||
if (res.data?.maintainerDeptId) {
|
||||
orderConfigForm.maintainerDeptId = res.data.maintainerDeptId;
|
||||
}
|
||||
} catch {
|
||||
// 未配置时保持为空
|
||||
}
|
||||
};
|
||||
|
||||
const saveOrderConfigForm = () => {
|
||||
orderConfigFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (!valid || configSubmitting.value) return;
|
||||
configSubmitting.value = true;
|
||||
try {
|
||||
await saveOrderConfig({ maintainerDeptId: orderConfigForm.maintainerDeptId });
|
||||
proxy?.$modal.msgSuccess('受理部门已保存');
|
||||
orderConfigDialog.visible = false;
|
||||
} finally {
|
||||
configSubmitting.value = false;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// ---------------- 验收 ----------------
|
||||
const openVerify = (row: WorkOrderVO) => {
|
||||
verifyForm.orderId = row.id;
|
||||
@ -856,7 +794,9 @@ const doHandle = async () => {
|
||||
const handleUrge = async (row: WorkOrderVO) => {
|
||||
await urgeOrder(row.id);
|
||||
const waitingAccept = row.status === 'TO_ACCEPT' && !row.handlerId;
|
||||
proxy?.$modal.msgSuccess(waitingAccept ? '已催办,已通知受理部门人员接单' : '已催办,钉钉消息已发送给处理人');
|
||||
proxy?.$modal.msgSuccess(waitingAccept
|
||||
? '已催办,已通知运维单位人员接单'
|
||||
: `已催办,已通知当前环节处理人${row.currentNodeName ? '(' + row.currentNodeName + ')' : ''}`);
|
||||
};
|
||||
|
||||
const handleClose = async (row: WorkOrderVO) => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user