-f 项目优化
This commit is contained in:
parent
64fd0be30b
commit
7779beea9d
@ -35,8 +35,4 @@ VITE_APP_WEBSOCKET = false
|
|||||||
# sse 开关
|
# sse 开关
|
||||||
VITE_APP_SSE = true
|
VITE_APP_SSE = true
|
||||||
|
|
||||||
# 高德地图 Key(设备上图/地图选点/大屏使用,在高德开放平台申请 Web端(JS API))
|
|
||||||
VITE_AMAP_KEY = ''
|
|
||||||
# 高德地图安全密钥(JSAPI 2.0 配合 key 使用)
|
|
||||||
VITE_AMAP_SECURITYCODE = ''
|
|
||||||
VITE_DINGTALK_CORP_ID = 'dingac2932b8bc38a94735c2f4657eb6378f'
|
VITE_DINGTALK_CORP_ID = 'dingac2932b8bc38a94735c2f4657eb6378f'
|
||||||
|
|||||||
@ -38,8 +38,4 @@ VITE_APP_WEBSOCKET = false
|
|||||||
# sse 开关
|
# sse 开关
|
||||||
VITE_APP_SSE = true
|
VITE_APP_SSE = true
|
||||||
|
|
||||||
# 高德地图 Key(设备上图/地图选点/大屏使用,在高德开放平台申请 Web端(JS API))
|
|
||||||
VITE_AMAP_KEY = ''
|
|
||||||
# 高德地图安全密钥(JSAPI 2.0 配合 key 使用)
|
|
||||||
VITE_AMAP_SECURITYCODE = ''
|
|
||||||
VITE_DINGTALK_CORP_ID = 'dingac2932b8bc38a94735c2f4657eb6378f'
|
VITE_DINGTALK_CORP_ID = 'dingac2932b8bc38a94735c2f4657eb6378f'
|
||||||
|
|||||||
@ -38,3 +38,21 @@ export function getDeptUsers(deptId: string | number, nickName?: string): AxiosP
|
|||||||
params: { deptId, nickName: nickName || undefined }
|
params: { deptId, nickName: nickName || undefined }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 地址解析为经纬度(后端代理高德服务,登录即可) */
|
||||||
|
export function amapGeocode(address: string): AxiosPromise<{ lng: number; lat: number; address: string }> {
|
||||||
|
return request({
|
||||||
|
url: '/sbgl/common/geocode',
|
||||||
|
method: 'get',
|
||||||
|
params: { address }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 经纬度解析为地址(后端代理高德服务,登录即可) */
|
||||||
|
export function amapRegeo(lng: number, lat: number): AxiosPromise<{ address: string }> {
|
||||||
|
return request({
|
||||||
|
url: '/sbgl/common/regeo',
|
||||||
|
method: 'get',
|
||||||
|
params: { lng, lat }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import request from '@/utils/request';
|
import request from '@/utils/request';
|
||||||
import { download } from '@/utils/request';
|
import { download } from '@/utils/request';
|
||||||
import { AxiosPromise } from 'axios';
|
import { AxiosPromise } from 'axios';
|
||||||
import { DeviceVO, DeviceQuery, DeviceForm, ImportResultVO, LifecycleVO } from './types';
|
import { DeviceVO, DeviceQuery, DeviceForm, ImportResultVO, LifecycleVO, DeviceExportTaskVO } from './types';
|
||||||
|
|
||||||
// 设备分页列表
|
// 设备分页列表
|
||||||
export function listDevice(query: DeviceQuery): AxiosPromise<DeviceVO[]> {
|
export function listDevice(query: DeviceQuery): AxiosPromise<DeviceVO[]> {
|
||||||
@ -94,6 +94,32 @@ export function exportDevice(query: DeviceQuery) {
|
|||||||
return download('/sbgl/device/export', query, `设备台账_${new Date().getTime()}.xlsx`);
|
return download('/sbgl/device/export', query, `设备台账_${new Date().getTime()}.xlsx`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 启动异步导出(大数据量)
|
||||||
|
export function exportDeviceAsync(query: DeviceQuery): AxiosPromise<DeviceExportTaskVO> {
|
||||||
|
return request({
|
||||||
|
url: '/sbgl/device/exportAsync',
|
||||||
|
method: 'post',
|
||||||
|
data: query
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询异步导出任务
|
||||||
|
export function getDeviceExportTask(taskId: string): AxiosPromise<DeviceExportTaskVO> {
|
||||||
|
return request({
|
||||||
|
url: '/sbgl/device/exportTask/' + taskId,
|
||||||
|
method: 'get'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取异步导出文件(Blob,前端自行保存,不弹下载 loading)
|
||||||
|
export function getDeviceExportFile(taskId: string): Promise<Blob> {
|
||||||
|
return request({
|
||||||
|
url: `/sbgl/device/exportTask/${taskId}/download`,
|
||||||
|
method: 'get',
|
||||||
|
responseType: 'blob'
|
||||||
|
}) as unknown as Promise<Blob>;
|
||||||
|
}
|
||||||
|
|
||||||
// 设备全生命周期时间线
|
// 设备全生命周期时间线
|
||||||
export function getLifecycle(id: string | number): AxiosPromise<LifecycleVO> {
|
export function getLifecycle(id: string | number): AxiosPromise<LifecycleVO> {
|
||||||
return request({
|
return request({
|
||||||
|
|||||||
@ -25,6 +25,7 @@ export interface DeviceVO {
|
|||||||
export interface DeviceQuery extends PageQuery {
|
export interface DeviceQuery extends PageQuery {
|
||||||
deviceCode?: string;
|
deviceCode?: string;
|
||||||
deviceName?: string;
|
deviceName?: string;
|
||||||
|
keyword?: string;
|
||||||
typeId?: string | number;
|
typeId?: string | number;
|
||||||
deptId?: string | number;
|
deptId?: string | number;
|
||||||
status?: string;
|
status?: string;
|
||||||
@ -54,13 +55,23 @@ export interface ImportResultVO {
|
|||||||
errors: string[];
|
errors: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface DeviceExportTaskVO {
|
||||||
|
taskId: string;
|
||||||
|
status: 'PENDING' | 'RUNNING' | 'SUCCESS' | 'FAIL';
|
||||||
|
total: number;
|
||||||
|
fileName?: string;
|
||||||
|
url?: string;
|
||||||
|
message?: string;
|
||||||
|
createTime?: string;
|
||||||
|
finishTime?: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface LifecycleVO {
|
export interface LifecycleVO {
|
||||||
deviceId: string | number;
|
deviceId: string | number;
|
||||||
deviceCode: string;
|
deviceCode: string;
|
||||||
deviceName: string;
|
deviceName: string;
|
||||||
status: string;
|
status: string;
|
||||||
createTime: string;
|
createTime: string;
|
||||||
repairCount: number;
|
|
||||||
timeline: TimelineItem[];
|
timeline: TimelineItem[];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,5 +80,4 @@ export interface TimelineItem {
|
|||||||
nodeType: string;
|
nodeType: string;
|
||||||
content: string;
|
content: string;
|
||||||
operator?: string;
|
operator?: string;
|
||||||
orderId?: string | number;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,6 +11,9 @@ export interface WorkOrderVO {
|
|||||||
reportBy?: string | number;
|
reportBy?: string | number;
|
||||||
reportName?: string;
|
reportName?: string;
|
||||||
reportTime?: string;
|
reportTime?: string;
|
||||||
|
reportLng?: number;
|
||||||
|
reportLat?: number;
|
||||||
|
reportAddress?: string;
|
||||||
dispatchTime?: string;
|
dispatchTime?: string;
|
||||||
handlerId?: string | number;
|
handlerId?: string | number;
|
||||||
handlerName?: string;
|
handlerName?: string;
|
||||||
@ -73,6 +76,7 @@ export interface WorkOrderForm {
|
|||||||
deadline?: string;
|
deadline?: string;
|
||||||
reportLng?: number;
|
reportLng?: number;
|
||||||
reportLat?: number;
|
reportLat?: number;
|
||||||
|
reportAddress?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface HandleForm {
|
export interface HandleForm {
|
||||||
|
|||||||
262
src/components/SbLocationPicker/index.vue
Normal file
262
src/components/SbLocationPicker/index.vue
Normal file
@ -0,0 +1,262 @@
|
|||||||
|
<template>
|
||||||
|
<el-dialog v-model="visible" title="选择报修位置" width="min(760px, 94vw)" append-to-body
|
||||||
|
:close-on-click-modal="false" @opened="onOpened">
|
||||||
|
<div class="location-picker">
|
||||||
|
<div class="location-picker__search">
|
||||||
|
<el-input v-model="address" clearable placeholder="输入地址,例如:衢江区大洲镇××路"
|
||||||
|
@keyup.enter="locateAddress()">
|
||||||
|
<template #append>
|
||||||
|
<el-button :loading="locating" @click="locateAddress()">定位地址</el-button>
|
||||||
|
</template>
|
||||||
|
</el-input>
|
||||||
|
<el-button :loading="gpsLocating" icon="Aim" @click="useCurrentLocation(false)">使用当前位置</el-button>
|
||||||
|
</div>
|
||||||
|
<div class="location-picker__hint">
|
||||||
|
可直接点击地图或拖动标记选择位置;地址输入后点“定位地址”会自动定位到该地址。
|
||||||
|
<div v-if="!hasAmapKey()" class="location-picker__warn">
|
||||||
|
未配置高德地图 Key:地址会自动生成“区县 + 坐标”,可手动修改;精确门牌地址解析需配置 Key。
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<sb-map ref="mapRef" pick-mode height="min(400px, 42vh)" :center="initialCenter" :zoom="15"
|
||||||
|
:selected="selectedPoint" :geo-json="quzhouGeo" boundary-only restrict-geo
|
||||||
|
@pick="onPick" @pick-reject="onPickReject" />
|
||||||
|
<div class="location-picker__coords">
|
||||||
|
<span>当前坐标:{{ localLng ? `${localLng.toFixed(6)}, ${localLat?.toFixed(6)}` : '未选择' }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<template #footer>
|
||||||
|
<el-button @click="visible = false">取 消</el-button>
|
||||||
|
<el-button type="primary" @click="confirm">确 定</el-button>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup name="SbLocationPicker" lang="ts">
|
||||||
|
import { computed, nextTick, ref, watch } from 'vue';
|
||||||
|
import { ElMessage } from 'element-plus';
|
||||||
|
import quzhouGeo from '@/assets/geo/quzhou.json';
|
||||||
|
import { findDistrictCenter, isPointInGeoJson, locateDistrict, wgs84ToGcj02 } from '@/utils/geo';
|
||||||
|
import { geocodeAddress, hasAmapKey, reverseGeocode } from '@/utils/amap';
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
modelValue: boolean;
|
||||||
|
lng?: number;
|
||||||
|
lat?: number;
|
||||||
|
address?: string;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: 'update:modelValue', value: boolean): void;
|
||||||
|
(e: 'confirm', value: { lng?: number; lat?: number; address: string }): void;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const visible = computed({
|
||||||
|
get: () => props.modelValue,
|
||||||
|
set: (value: boolean) => emit('update:modelValue', value)
|
||||||
|
});
|
||||||
|
|
||||||
|
const mapRef = ref<any>();
|
||||||
|
const localLng = ref<number>();
|
||||||
|
const localLat = ref<number>();
|
||||||
|
const address = ref('');
|
||||||
|
const locating = ref(false);
|
||||||
|
const gpsLocating = ref(false);
|
||||||
|
const initialCenter = computed<[number, number]>(() => [
|
||||||
|
localLng.value ?? 118.87,
|
||||||
|
localLat.value ?? 28.97
|
||||||
|
]);
|
||||||
|
const selectedPoint = computed(() => (
|
||||||
|
localLng.value && localLat.value ? { lng: localLng.value, lat: localLat.value } : null
|
||||||
|
));
|
||||||
|
|
||||||
|
const fillAddress = async () => {
|
||||||
|
if (!localLng.value || !localLat.value || !hasAmapKey()) return;
|
||||||
|
try {
|
||||||
|
address.value = await reverseGeocode(localLng.value, localLat.value);
|
||||||
|
} catch {
|
||||||
|
// 地址解析失败时保留手动输入内容
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 未配置高德 Key 或反解析失败时,用区县 + 坐标生成可识别的地址 */
|
||||||
|
const fallbackAddressText = () => {
|
||||||
|
if (!localLng.value || !localLat.value) return '';
|
||||||
|
const district = locateDistrict(quzhouGeo, localLng.value, localLat.value) || '衢州市';
|
||||||
|
return `${district}(地图选点 ${localLng.value.toFixed(6)}, ${localLat.value.toFixed(6)})`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const applyFallbackAddress = async () => {
|
||||||
|
await fillAddress();
|
||||||
|
if (!address.value.trim() && localLng.value && localLat.value) {
|
||||||
|
address.value = fallbackAddressText();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const useCurrentLocation = (silent: boolean) => {
|
||||||
|
if (!navigator.geolocation) {
|
||||||
|
if (!silent) ElMessage.warning('当前浏览器不支持定位,请直接点击地图选择');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
gpsLocating.value = true;
|
||||||
|
navigator.geolocation.getCurrentPosition(
|
||||||
|
async (pos) => {
|
||||||
|
// 浏览器定位为 WGS84,转换为高德底图使用的 GCJ-02
|
||||||
|
const point = wgs84ToGcj02(pos.coords.longitude, pos.coords.latitude);
|
||||||
|
const lng = Number(point.lng.toFixed(6));
|
||||||
|
const lat = Number(point.lat.toFixed(6));
|
||||||
|
gpsLocating.value = false;
|
||||||
|
if (!isPointInGeoJson(quzhouGeo, lng, lat)) {
|
||||||
|
if (!silent) ElMessage.warning('当前位置不在衢州市范围内,请手动选择位置');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
localLng.value = lng;
|
||||||
|
localLat.value = lat;
|
||||||
|
mapRef.value?.flyTo(lng, lat, 16);
|
||||||
|
await applyFallbackAddress();
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
gpsLocating.value = false;
|
||||||
|
if (!silent) ElMessage.warning('获取定位失败,请直接点击地图选择');
|
||||||
|
},
|
||||||
|
{ enableHighAccuracy: true, timeout: 8000 }
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const onOpened = async () => {
|
||||||
|
await nextTick();
|
||||||
|
if (localLng.value && localLat.value) {
|
||||||
|
// 已有坐标:飞到点位,缺少地址时反向解析
|
||||||
|
mapRef.value?.flyTo(localLng.value, localLat.value, 16);
|
||||||
|
if (!address.value) {
|
||||||
|
await applyFallbackAddress();
|
||||||
|
}
|
||||||
|
} else if (address.value) {
|
||||||
|
// 设备只有地址没有坐标:有 Key 时解析到点;无 Key 时仅把地图移到对应区县,避免写入错误的中心点坐标
|
||||||
|
if (hasAmapKey()) {
|
||||||
|
await locateAddress(true);
|
||||||
|
} else {
|
||||||
|
const center = findDistrictCenter(quzhouGeo, address.value);
|
||||||
|
if (center) mapRef.value?.flyTo(center.lng, center.lat, 12);
|
||||||
|
}
|
||||||
|
} else if (!address.value) {
|
||||||
|
// 没有设备位置:获取浏览器当前位置作为默认定位
|
||||||
|
useCurrentLocation(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const onPick = async (point: { lng: number; lat: number }) => {
|
||||||
|
localLng.value = point.lng;
|
||||||
|
localLat.value = point.lat;
|
||||||
|
await applyFallbackAddress();
|
||||||
|
};
|
||||||
|
|
||||||
|
const onPickReject = () => {
|
||||||
|
ElMessage.warning('报修位置必须在衢州市范围内');
|
||||||
|
};
|
||||||
|
|
||||||
|
const locateAddress = async (silent = false) => {
|
||||||
|
if (!address.value.trim()) {
|
||||||
|
if (!silent) ElMessage.warning('请先输入地址');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!hasAmapKey()) {
|
||||||
|
// 未配置 Key:退化为按地址中的区县定位到区划中心,再由用户拖动标记精确选点
|
||||||
|
const center = findDistrictCenter(quzhouGeo, address.value.trim());
|
||||||
|
if (!center) {
|
||||||
|
if (!silent) ElMessage.warning('未配置高德地图 Key,无法精确解析地址,请直接点击地图选择位置');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
localLng.value = Number(center.lng.toFixed(6));
|
||||||
|
localLat.value = Number(center.lat.toFixed(6));
|
||||||
|
mapRef.value?.flyTo(center.lng, center.lat, 12);
|
||||||
|
if (!silent) ElMessage.info(`已定位到${center.name},请拖动地图标记到准确位置`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
locating.value = true;
|
||||||
|
try {
|
||||||
|
const result = await geocodeAddress(address.value.trim());
|
||||||
|
if (!isPointInGeoJson(quzhouGeo, result.lng, result.lat)) {
|
||||||
|
if (!silent) ElMessage.warning('该地址不在衢州市范围内');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
localLng.value = result.lng;
|
||||||
|
localLat.value = result.lat;
|
||||||
|
address.value = result.address;
|
||||||
|
mapRef.value?.flyTo(result.lng, result.lat, 16);
|
||||||
|
} catch (e: any) {
|
||||||
|
if (!silent) ElMessage.warning(e?.message || '地址定位失败');
|
||||||
|
} finally {
|
||||||
|
locating.value = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const confirm = () => {
|
||||||
|
if (!address.value.trim() && localLng.value && localLat.value) {
|
||||||
|
// 未配置地理编码时,用区县 + 坐标兜底,确保能带出位置
|
||||||
|
address.value = fallbackAddressText();
|
||||||
|
}
|
||||||
|
if (!address.value.trim()) {
|
||||||
|
ElMessage.warning('请在地图上选择位置或填写地址');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
emit('confirm', {
|
||||||
|
lng: localLng.value,
|
||||||
|
lat: localLat.value,
|
||||||
|
address: address.value.trim()
|
||||||
|
});
|
||||||
|
visible.value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.modelValue,
|
||||||
|
(open) => {
|
||||||
|
if (!open) return;
|
||||||
|
// 仅同步已有值;默认定位/地址解析在弹层打开后处理(此时地图已挂载)
|
||||||
|
localLng.value = props.lng;
|
||||||
|
localLat.value = props.lat;
|
||||||
|
address.value = props.address || '';
|
||||||
|
}
|
||||||
|
);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.location-picker {
|
||||||
|
&__search {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
|
||||||
|
:deep(.el-input) {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
&__search {
|
||||||
|
flex-wrap: wrap;
|
||||||
|
|
||||||
|
.el-button {
|
||||||
|
width: 100%;
|
||||||
|
margin-left: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&__hint {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
color: #909399;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__warn {
|
||||||
|
margin-top: 4px;
|
||||||
|
color: var(--el-color-warning);
|
||||||
|
}
|
||||||
|
|
||||||
|
&__coords {
|
||||||
|
margin-top: 8px;
|
||||||
|
color: #606266;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -111,6 +111,10 @@ function initMap() {
|
|||||||
emit('pick', point);
|
emit('pick', point);
|
||||||
});
|
});
|
||||||
renderPoints();
|
renderPoints();
|
||||||
|
// 组件挂载时已有选中点(如设备已有坐标),补画标记
|
||||||
|
if (props.pickMode && props.selected?.lng && props.selected?.lat) {
|
||||||
|
setPickMarker(props.selected);
|
||||||
|
}
|
||||||
|
|
||||||
// 容器尺寸变化(如侧栏收起、页面切换)后重算地图,避免点击偏移/瓦片错位
|
// 容器尺寸变化(如侧栏收起、页面切换)后重算地图,避免点击偏移/瓦片错位
|
||||||
resizeObserver = new ResizeObserver(() => {
|
resizeObserver = new ResizeObserver(() => {
|
||||||
@ -267,7 +271,13 @@ watch(
|
|||||||
watch(
|
watch(
|
||||||
() => props.selected,
|
() => props.selected,
|
||||||
(val) => {
|
(val) => {
|
||||||
if (val && val.lng) setPickMarker(val);
|
if (val && val.lng) {
|
||||||
|
setPickMarker(val);
|
||||||
|
} else if (pickMarker && map) {
|
||||||
|
map.removeLayer(pickMarker);
|
||||||
|
pickMarker = null;
|
||||||
|
lastValidPick = null;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{ deep: true }
|
{ deep: true }
|
||||||
);
|
);
|
||||||
|
|||||||
31
src/utils/amap.ts
Normal file
31
src/utils/amap.ts
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/**
|
||||||
|
* 高德地理编码工具。
|
||||||
|
* 地址解析/逆解析由后端代理高德 Web 服务完成,前端无需配置 JSAPI Key。
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { amapGeocode, amapRegeo } from '@/api/sbgl/common';
|
||||||
|
|
||||||
|
/** 后端已配置高德服务,地址解析可用 */
|
||||||
|
export const hasAmapKey = () => true;
|
||||||
|
|
||||||
|
/** 地址 → 经纬度 */
|
||||||
|
export async function geocodeAddress(address: string): Promise<{ lng: number; lat: number; address: string }> {
|
||||||
|
const res: any = await amapGeocode(address);
|
||||||
|
const data = res?.data;
|
||||||
|
const lng = Number(data?.lng);
|
||||||
|
const lat = Number(data?.lat);
|
||||||
|
if (!Number.isFinite(lng) || !Number.isFinite(lat)) {
|
||||||
|
throw new Error('未找到该地址,请换个地址或直接点击地图选点');
|
||||||
|
}
|
||||||
|
return { lng, lat, address: data?.address || address };
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 经纬度 → 地址 */
|
||||||
|
export async function reverseGeocode(lng: number, lat: number): Promise<string> {
|
||||||
|
const res: any = await amapRegeo(lng, lat);
|
||||||
|
const address = res?.data?.address;
|
||||||
|
if (!address) {
|
||||||
|
throw new Error('未获取到地址');
|
||||||
|
}
|
||||||
|
return address;
|
||||||
|
}
|
||||||
@ -48,3 +48,88 @@ export function locateDistrict(geoJson: any, lng: number, lat: number): string {
|
|||||||
export function isPointInGeoJson(geoJson: any, lng: number, lat: number): boolean {
|
export function isPointInGeoJson(geoJson: any, lng: number, lat: number): boolean {
|
||||||
return locateDistrict(geoJson, lng, lat) !== '';
|
return locateDistrict(geoJson, lng, lat) !== '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按地址中的区县名称查找区划中心点(无地理编码服务时的粗略定位兜底)。
|
||||||
|
* 返回点保证落在区划内。
|
||||||
|
*/
|
||||||
|
export function findDistrictCenter(geoJson: any, address: string): { lng: number; lat: number; name: string } | null {
|
||||||
|
const features = geoJson?.features ?? [];
|
||||||
|
const feature = features.find((f: any) => {
|
||||||
|
const name = f?.properties?.name;
|
||||||
|
return name && (address.includes(name) || address.includes(name.replace(/[市县区]$/, '')));
|
||||||
|
});
|
||||||
|
if (!feature?.geometry) return null;
|
||||||
|
const geometry = feature.geometry;
|
||||||
|
const polygons: number[][][][] = geometry.type === 'MultiPolygon'
|
||||||
|
? geometry.coordinates
|
||||||
|
: geometry.type === 'Polygon' ? [geometry.coordinates] : [];
|
||||||
|
const rings = polygons.flatMap((poly) => poly?.[0] ?? []).filter((ring) => ring?.length);
|
||||||
|
if (!rings.length) return null;
|
||||||
|
|
||||||
|
let minLng = Infinity;
|
||||||
|
let minLat = Infinity;
|
||||||
|
let maxLng = -Infinity;
|
||||||
|
let maxLat = -Infinity;
|
||||||
|
let sumLng = 0;
|
||||||
|
let sumLat = 0;
|
||||||
|
let count = 0;
|
||||||
|
for (const ring of rings) {
|
||||||
|
for (const [lng, lat] of ring) {
|
||||||
|
minLng = Math.min(minLng, lng);
|
||||||
|
maxLng = Math.max(maxLng, lng);
|
||||||
|
minLat = Math.min(minLat, lat);
|
||||||
|
maxLat = Math.max(maxLat, lat);
|
||||||
|
sumLng += lng;
|
||||||
|
sumLat += lat;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const name = feature.properties.name;
|
||||||
|
const bboxCenter = { lng: (minLng + maxLng) / 2, lat: (minLat + maxLat) / 2 };
|
||||||
|
if (isPointInGeoJson({ features: [feature] }, bboxCenter.lng, bboxCenter.lat)) {
|
||||||
|
return { ...bboxCenter, name };
|
||||||
|
}
|
||||||
|
const avg = { lng: sumLng / count, lat: sumLat / count };
|
||||||
|
if (isPointInGeoJson({ features: [feature] }, avg.lng, avg.lat)) {
|
||||||
|
return { ...avg, name };
|
||||||
|
}
|
||||||
|
const [lng, lat] = rings[0][0];
|
||||||
|
return { lng, lat, name };
|
||||||
|
}
|
||||||
|
|
||||||
|
const PI = Math.PI;
|
||||||
|
const A = 6378245.0;
|
||||||
|
const EE = 0.00669342162296594323;
|
||||||
|
|
||||||
|
function transformLat(lng: number, lat: number): number {
|
||||||
|
let ret = -100.0 + 2.0 * lng + 3.0 * lat + 0.2 * lat * lat + 0.1 * lng * lat + 0.2 * Math.sqrt(Math.abs(lng));
|
||||||
|
ret += ((20.0 * Math.sin(6.0 * lng * PI) + 20.0 * Math.sin(2.0 * lng * PI)) * 2.0) / 3.0;
|
||||||
|
ret += ((20.0 * Math.sin(lat * PI) + 40.0 * Math.sin((lat / 3.0) * PI)) * 2.0) / 3.0;
|
||||||
|
ret += ((160.0 * Math.sin((lat / 12.0) * PI) + 320 * Math.sin((lat * PI) / 30.0)) * 2.0) / 3.0;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
function transformLng(lng: number, lat: number): number {
|
||||||
|
let ret = 300.0 + lng + 2.0 * lat + 0.1 * lng * lng + 0.1 * lng * lat + 0.1 * Math.sqrt(Math.abs(lng));
|
||||||
|
ret += ((20.0 * Math.sin(6.0 * lng * PI) + 20.0 * Math.sin(2.0 * lng * PI)) * 2.0) / 3.0;
|
||||||
|
ret += ((20.0 * Math.sin(lng * PI) + 40.0 * Math.sin((lng / 3.0) * PI)) * 2.0) / 3.0;
|
||||||
|
ret += ((150.0 * Math.sin((lng / 12.0) * PI) + 300.0 * Math.sin((lng / 30.0) * PI)) * 2.0) / 3.0;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** WGS84(浏览器 GPS)→ GCJ-02(高德底图),避免定位偏移 */
|
||||||
|
export function wgs84ToGcj02(lng: number, lat: number): { lng: number; lat: number } {
|
||||||
|
if (lng < 72.004 || lng > 137.8347 || lat < 0.8293 || lat > 55.8271) {
|
||||||
|
return { lng, lat };
|
||||||
|
}
|
||||||
|
let dLat = transformLat(lng - 105.0, lat - 35.0);
|
||||||
|
let dLng = transformLng(lng - 105.0, lat - 35.0);
|
||||||
|
const radLat = (lat / 180.0) * PI;
|
||||||
|
let magic = Math.sin(radLat);
|
||||||
|
magic = 1 - EE * magic * magic;
|
||||||
|
const sqrtMagic = Math.sqrt(magic);
|
||||||
|
dLat = (dLat * 180.0) / (((A * (1 - EE)) / (magic * sqrtMagic)) * PI);
|
||||||
|
dLng = (dLng * 180.0) / ((A / sqrtMagic) * Math.cos(radLat) * PI);
|
||||||
|
return { lng: lng + dLng, lat: lat + dLat };
|
||||||
|
}
|
||||||
|
|||||||
@ -117,7 +117,6 @@
|
|||||||
<el-descriptions :column="1" border size="small">
|
<el-descriptions :column="1" border size="small">
|
||||||
<el-descriptions-item label="建档时间">{{ formatDate(device.createTime) }}</el-descriptions-item>
|
<el-descriptions-item label="建档时间">{{ formatDate(device.createTime) }}</el-descriptions-item>
|
||||||
<el-descriptions-item label="最近更新">{{ formatDate(device.updateTime) }}</el-descriptions-item>
|
<el-descriptions-item label="最近更新">{{ formatDate(device.updateTime) }}</el-descriptions-item>
|
||||||
<el-descriptions-item label="累计维修">{{ lifecycle?.repairCount ?? 0 }} 次</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="生命周期节点">{{ lifecycle?.timeline?.length ?? 0 }} 条</el-descriptions-item>
|
<el-descriptions-item label="生命周期节点">{{ lifecycle?.timeline?.length ?? 0 }} 条</el-descriptions-item>
|
||||||
</el-descriptions>
|
</el-descriptions>
|
||||||
</el-card>
|
</el-card>
|
||||||
@ -125,18 +124,53 @@
|
|||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<el-card shadow="hover">
|
<el-card shadow="hover">
|
||||||
<template #header><span class="card-title">生命周期</span></template>
|
<el-tabs v-model="activeTab">
|
||||||
<el-timeline v-if="lifecycle?.timeline?.length">
|
<el-tab-pane label="生命周期" name="lifecycle">
|
||||||
<el-timeline-item v-for="(item, idx) in lifecycle.timeline" :key="idx"
|
<el-timeline v-if="lifecycle?.timeline?.length">
|
||||||
:timestamp="formatDate(item.time)" placement="top">
|
<el-timeline-item v-for="(item, idx) in lifecycle.timeline" :key="idx"
|
||||||
<div class="timeline-content">{{ item.content }}</div>
|
:timestamp="formatDate(item.time)" placement="top">
|
||||||
<div v-if="item.operator || item.orderId" class="timeline-meta">
|
<div class="timeline-content">{{ item.content }}</div>
|
||||||
<span v-if="item.operator">操作人:{{ item.operator }}</span>
|
<div v-if="item.operator" class="timeline-meta">
|
||||||
<span v-if="item.orderId">关联工单:{{ item.orderId }}</span>
|
<span>操作人:{{ item.operator }}</span>
|
||||||
</div>
|
</div>
|
||||||
</el-timeline-item>
|
</el-timeline-item>
|
||||||
</el-timeline>
|
</el-timeline>
|
||||||
<el-empty v-else description="暂无生命周期记录" :image-size="70" />
|
<el-empty v-else description="暂无生命周期记录" :image-size="70" />
|
||||||
|
</el-tab-pane>
|
||||||
|
|
||||||
|
<el-tab-pane :label="`工单记录 (${orderTotal})`" name="orders">
|
||||||
|
<el-table v-loading="orderLoading" :data="orderRows" border size="small" max-height="520">
|
||||||
|
<el-table-column label="工单编号" prop="orderCode" width="180" />
|
||||||
|
<el-table-column label="标题" prop="title" min-width="160" show-overflow-tooltip />
|
||||||
|
<el-table-column label="类型" width="100" align="center">
|
||||||
|
<template #default="scope">
|
||||||
|
<dict-tag :options="sb_order_type" :value="scope.row.orderType" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="状态" width="110" align="center">
|
||||||
|
<template #default="scope">
|
||||||
|
<dict-tag :options="sb_order_status" :value="scope.row.status" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="当前环节" width="160" align="center">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-tooltip v-if="scope.row.currentNodeName" :content="scope.row.currentNodeName" placement="top">
|
||||||
|
<span>{{ orderPhaseLabel(scope.row.currentNodeType) || scope.row.currentNodeName }}</span>
|
||||||
|
</el-tooltip>
|
||||||
|
<span v-else>-</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="处理人" prop="handlerName" width="100" />
|
||||||
|
<el-table-column label="维护单位" prop="maintainer" min-width="120" show-overflow-tooltip />
|
||||||
|
<el-table-column label="费用" width="100" align="right">
|
||||||
|
<template #default="scope">{{ formatMoney(scope.row.amount) }}</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="发起时间" width="160">
|
||||||
|
<template #default="scope">{{ formatDate(scope.row.reportTime) }}</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</el-tab-pane>
|
||||||
|
</el-tabs>
|
||||||
</el-card>
|
</el-card>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -151,6 +185,7 @@ import { listDetailFields } from '@/api/sbgl/devicetype';
|
|||||||
import { DeviceFieldVO } from '@/api/sbgl/devicetype/types';
|
import { DeviceFieldVO } from '@/api/sbgl/devicetype/types';
|
||||||
import { getDevice, getLifecycle } from '@/api/sbgl/device';
|
import { getDevice, getLifecycle } from '@/api/sbgl/device';
|
||||||
import { DeviceVO, LifecycleVO } from '@/api/sbgl/device/types';
|
import { DeviceVO, LifecycleVO } from '@/api/sbgl/device/types';
|
||||||
|
import { listOrder } from '@/api/sbgl/workorder';
|
||||||
import { listBusinessOss } from '@/api/sbgl/common';
|
import { listBusinessOss } from '@/api/sbgl/common';
|
||||||
import { fieldValueArray, formatFieldValue } from '../devicetype/fieldTypes';
|
import { fieldValueArray, formatFieldValue } from '../devicetype/fieldTypes';
|
||||||
|
|
||||||
@ -162,13 +197,19 @@ interface OssEntry {
|
|||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||||
const { sb_device_status } = toRefs<any>(proxy?.useDict('sb_device_status'));
|
const { sb_device_status, sb_order_status, sb_order_type } = toRefs<any>(
|
||||||
|
proxy?.useDict('sb_device_status', 'sb_order_status', 'sb_order_type')
|
||||||
|
);
|
||||||
|
|
||||||
const loading = ref(true);
|
const loading = ref(true);
|
||||||
const device = ref<DeviceVO | null>(null);
|
const device = ref<DeviceVO | null>(null);
|
||||||
const fields = ref<DeviceFieldVO[]>([]);
|
const fields = ref<DeviceFieldVO[]>([]);
|
||||||
const lifecycle = ref<LifecycleVO | null>(null);
|
const lifecycle = ref<LifecycleVO | null>(null);
|
||||||
const ossMap = ref<Record<string, OssEntry>>({});
|
const ossMap = ref<Record<string, OssEntry>>({});
|
||||||
|
const activeTab = ref('lifecycle');
|
||||||
|
const orderRows = ref<any[]>([]);
|
||||||
|
const orderTotal = ref(0);
|
||||||
|
const orderLoading = ref(false);
|
||||||
|
|
||||||
const deviceId = computed(() => String(route.params.id ?? ''));
|
const deviceId = computed(() => String(route.params.id ?? ''));
|
||||||
const attrs = computed<Record<string, any>>(() => parseAttrs(device.value?.attrs));
|
const attrs = computed<Record<string, any>>(() => parseAttrs(device.value?.attrs));
|
||||||
@ -193,6 +234,29 @@ const formatDate = (value?: string | Date | null, pattern = '{y}-{m}-{d} {h}:{i}
|
|||||||
return proxy?.parseTime(value, pattern) ?? '-';
|
return proxy?.parseTime(value, pattern) ?? '-';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const formatMoney = (value: any): string =>
|
||||||
|
value === null || value === undefined || value === '' ? '-' : `¥${Number(value).toFixed(2)}`;
|
||||||
|
|
||||||
|
/** 工单当前环节用待办动作展示 */
|
||||||
|
const orderPhaseLabel = (type?: string) =>
|
||||||
|
({ APPROVAL: '待审批', ACCEPT: '待接单', DISPATCH: '待派单', FINISH: '待完工', VERIFY: '待验收', SUPERVISE: '待监理确认' }[type || ''] || '');
|
||||||
|
|
||||||
|
/** 设备关联工单 */
|
||||||
|
const loadOrders = async () => {
|
||||||
|
if (!deviceId.value) return;
|
||||||
|
orderLoading.value = true;
|
||||||
|
try {
|
||||||
|
const res: any = await listOrder({ deviceId: deviceId.value, pageNum: 1, pageSize: 100 } as any);
|
||||||
|
orderRows.value = res.rows ?? [];
|
||||||
|
orderTotal.value = Number(res.total ?? orderRows.value.length);
|
||||||
|
} catch {
|
||||||
|
orderRows.value = [];
|
||||||
|
orderTotal.value = 0;
|
||||||
|
} finally {
|
||||||
|
orderLoading.value = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/** 图片/附件字段存 OSS 文件ID,详情展示前批量换取访问地址 */
|
/** 图片/附件字段存 OSS 文件ID,详情展示前批量换取访问地址 */
|
||||||
const loadOssUrls = async () => {
|
const loadOssUrls = async () => {
|
||||||
const ids = new Set<string>();
|
const ids = new Set<string>();
|
||||||
@ -271,6 +335,7 @@ const loadDetail = async () => {
|
|||||||
} catch {
|
} catch {
|
||||||
lifecycle.value = null;
|
lifecycle.value = null;
|
||||||
}
|
}
|
||||||
|
await loadOrders();
|
||||||
await loadOssUrls();
|
await loadOssUrls();
|
||||||
} catch {
|
} catch {
|
||||||
device.value = null;
|
device.value = null;
|
||||||
|
|||||||
@ -5,7 +5,8 @@
|
|||||||
<el-card shadow="hover">
|
<el-card shadow="hover">
|
||||||
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
|
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
|
||||||
<el-form-item label="设备类型" prop="typeId">
|
<el-form-item label="设备类型" prop="typeId">
|
||||||
<el-select v-model="queryParams.typeId" placeholder="全部类型" clearable style="width: 180px" @change="handleTypeChanged">
|
<el-select v-model="queryParams.typeId" placeholder="全部类型" clearable style="width: 180px"
|
||||||
|
@change="handleTypeChanged" @visible-change="handleTypeDropdownVisible">
|
||||||
<el-option v-for="t in typeOptions" :key="t.id" :label="t.typeName" :value="t.id" />
|
<el-option v-for="t in typeOptions" :key="t.id" :label="t.typeName" :value="t.id" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@ -121,7 +122,8 @@
|
|||||||
<el-row :gutter="12">
|
<el-row :gutter="12">
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="设备类型" prop="typeId">
|
<el-form-item label="设备类型" prop="typeId">
|
||||||
<el-select v-model="form.typeId" placeholder="请选择类型" :disabled="!!form.id && !currentTypeDeleted" style="width: 100%" @change="onFormTypeChange">
|
<el-select v-model="form.typeId" placeholder="请选择类型" :disabled="!!form.id && !currentTypeDeleted"
|
||||||
|
style="width: 100%" @change="onFormTypeChange" @visible-change="handleTypeDropdownVisible">
|
||||||
<el-option v-for="t in formTypeOptions" :key="t.id" :label="t.typeName" :value="t.id" />
|
<el-option v-for="t in formTypeOptions" :key="t.id" :label="t.typeName" :value="t.id" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@ -323,7 +325,8 @@
|
|||||||
import { listType, listTypeOptions, listEnabledFields } from '@/api/sbgl/devicetype';
|
import { listType, listTypeOptions, listEnabledFields } from '@/api/sbgl/devicetype';
|
||||||
import { DeviceTypeVO, DeviceFieldVO } from '@/api/sbgl/devicetype/types';
|
import { DeviceTypeVO, DeviceFieldVO } from '@/api/sbgl/devicetype/types';
|
||||||
import { parseFieldOptions, fieldValueArray, formatFieldValue, normalizeFieldValue } from '../devicetype/fieldTypes';
|
import { parseFieldOptions, fieldValueArray, formatFieldValue, normalizeFieldValue } from '../devicetype/fieldTypes';
|
||||||
import { listDevice, getDevice, addDevice, updateDevice, delDevice, importTemplate, importData, exportDevice, listRecycleDevice, restoreDevice } from '@/api/sbgl/device';
|
import FileSaver from 'file-saver';
|
||||||
|
import { listDevice, getDevice, addDevice, updateDevice, delDevice, importTemplate, importData, exportDevice, exportDeviceAsync, getDeviceExportTask, getDeviceExportFile, listRecycleDevice, restoreDevice } from '@/api/sbgl/device';
|
||||||
import { DeviceVO, DeviceQuery, DeviceForm, ImportResultVO } from '@/api/sbgl/device/types';
|
import { DeviceVO, DeviceQuery, DeviceForm, ImportResultVO } from '@/api/sbgl/device/types';
|
||||||
import { getCommonDeptTree, listBusinessOss } from '@/api/sbgl/common';
|
import { getCommonDeptTree, listBusinessOss } from '@/api/sbgl/common';
|
||||||
import { isPointInGeoJson } from '@/utils/geo';
|
import { isPointInGeoJson } from '@/utils/geo';
|
||||||
@ -357,6 +360,17 @@ const importForm = reactive({ typeId: '' as any, mode: 'add' as 'add' | 'upsert'
|
|||||||
const importResult = ref<ImportResultVO | null>(null);
|
const importResult = ref<ImportResultVO | null>(null);
|
||||||
const fileInputRef = ref<HTMLInputElement>();
|
const fileInputRef = ref<HTMLInputElement>();
|
||||||
|
|
||||||
|
/** 数据量超过该值转后台导出(不展示任务窗口,完成后自动下载) */
|
||||||
|
const ASYNC_EXPORT_THRESHOLD = 1000;
|
||||||
|
let exportTaskTimer: ReturnType<typeof setInterval> | null = null;
|
||||||
|
|
||||||
|
const clearExportTimer = () => {
|
||||||
|
if (exportTaskTimer) {
|
||||||
|
clearInterval(exportTaskTimer);
|
||||||
|
exportTaskTimer = null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// ---------------- 回收站 ----------------
|
// ---------------- 回收站 ----------------
|
||||||
const recycleVisible = ref(false);
|
const recycleVisible = ref(false);
|
||||||
const recycleLoading = ref(false);
|
const recycleLoading = ref(false);
|
||||||
@ -486,7 +500,7 @@ const parseAttrsJson = (attrs: any): Record<string, any> => {
|
|||||||
|
|
||||||
const getList = async () => {
|
const getList = async () => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
queryParams.value.deviceCode = keyword.value;
|
queryParams.value.keyword = keyword.value || undefined;
|
||||||
const res = await listDevice(queryParams.value);
|
const res = await listDevice(queryParams.value);
|
||||||
deviceList.value = (res.rows ?? []).map((row) => ({ ...row, attrs: parseAttrsJson(row.attrs) }));
|
deviceList.value = (res.rows ?? []).map((row) => ({ ...row, attrs: parseAttrsJson(row.attrs) }));
|
||||||
total.value = res.total;
|
total.value = res.total;
|
||||||
@ -588,7 +602,7 @@ const handleUpdate = async (row: DeviceVO) => {
|
|||||||
deptId: data.deptId,
|
deptId: data.deptId,
|
||||||
lng: data.lng,
|
lng: data.lng,
|
||||||
lat: data.lat,
|
lat: data.lat,
|
||||||
status: data.status,
|
status: data.status || '0',
|
||||||
attrs: parseAttrsJson(data.attrs),
|
attrs: parseAttrsJson(data.attrs),
|
||||||
installDate: data.installDate,
|
installDate: data.installDate,
|
||||||
installLocation: data.installLocation,
|
installLocation: data.installLocation,
|
||||||
@ -605,13 +619,13 @@ const handleUpdate = async (row: DeviceVO) => {
|
|||||||
const submitForm = () => {
|
const submitForm = () => {
|
||||||
deviceFormRef.value?.validate(async (valid: boolean) => {
|
deviceFormRef.value?.validate(async (valid: boolean) => {
|
||||||
if (!valid) return;
|
if (!valid) return;
|
||||||
const needLocation = formTypeOptions.value.find((t) => String(t.id) === String(form.value.typeId))?.needLocation === 1;
|
const hasLng = form.value.lng !== undefined && form.value.lng !== null && String(form.value.lng).trim() !== '';
|
||||||
if (needLocation && (form.value.lng === undefined || form.value.lat === undefined)) {
|
const hasLat = form.value.lat !== undefined && form.value.lat !== null && String(form.value.lat).trim() !== '';
|
||||||
proxy?.$modal.msgWarning('该类型设备必须填写经纬度(可使用地图选点)');
|
if (hasLng !== hasLat) {
|
||||||
|
proxy?.$modal.msgWarning('经度和纬度需同时填写,或同时留空');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (form.value.lng !== undefined && form.value.lat !== undefined
|
if (hasLng && hasLat && !isPointInGeoJson(quzhouGeo, Number(form.value.lng), Number(form.value.lat))) {
|
||||||
&& !isPointInGeoJson(quzhouGeo, Number(form.value.lng), Number(form.value.lat))) {
|
|
||||||
proxy?.$modal.msgWarning('设备位置必须在衢州市行政区划范围内');
|
proxy?.$modal.msgWarning('设备位置必须在衢州市行政区划范围内');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -709,7 +723,52 @@ const handleImport = async () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const saveExportFile = async (taskId: string, fileName?: string) => {
|
||||||
|
try {
|
||||||
|
const blob = await getDeviceExportFile(taskId);
|
||||||
|
if (blob && blob.size > 0) {
|
||||||
|
FileSaver.saveAs(blob, fileName || '设备台账.xlsx');
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// 静默失败,不打扰当前操作
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const pollExportThenDownload = (taskId: string) => {
|
||||||
|
clearExportTimer();
|
||||||
|
const tick = async () => {
|
||||||
|
try {
|
||||||
|
const res = await getDeviceExportTask(taskId);
|
||||||
|
if (res.data.status === 'SUCCESS') {
|
||||||
|
clearExportTimer();
|
||||||
|
// 后台生成完成后自动保存文件,不弹窗
|
||||||
|
void saveExportFile(taskId, res.data.fileName);
|
||||||
|
} else if (res.data.status === 'FAIL') {
|
||||||
|
clearExportTimer();
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
clearExportTimer();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
void tick();
|
||||||
|
exportTaskTimer = setInterval(tick, 2000);
|
||||||
|
};
|
||||||
|
|
||||||
|
const startBackgroundExport = async () => {
|
||||||
|
try {
|
||||||
|
const res = await exportDeviceAsync(queryParams.value);
|
||||||
|
pollExportThenDownload(res.data.taskId);
|
||||||
|
} catch {
|
||||||
|
// 后台导出失败不打扰当前操作
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleExport = () => {
|
const handleExport = () => {
|
||||||
|
// 数据量较大时转后台导出:无窗口、无等待,完成后自动下载
|
||||||
|
if (total.value > ASYNC_EXPORT_THRESHOLD) {
|
||||||
|
void startBackgroundExport();
|
||||||
|
return;
|
||||||
|
}
|
||||||
proxy?.$modal.confirm('是否按当前筛选条件导出设备台账?').then(() => {
|
proxy?.$modal.confirm('是否按当前筛选条件导出设备台账?').then(() => {
|
||||||
return exportDevice(queryParams.value);
|
return exportDevice(queryParams.value);
|
||||||
});
|
});
|
||||||
@ -726,7 +785,18 @@ const loadTypeOptions = async () => {
|
|||||||
typeOptions.value = typeRes.data ?? [];
|
typeOptions.value = typeRes.data ?? [];
|
||||||
};
|
};
|
||||||
|
|
||||||
let typeOptionsActivated = false;
|
/** 打开类型下拉时刷新,保证刚新增的类型立即出现 */
|
||||||
|
const handleTypeDropdownVisible = (visible: boolean) => {
|
||||||
|
if (visible) {
|
||||||
|
void loadTypeOptions();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const refreshTypeOptionsIfVisible = () => {
|
||||||
|
if (!document.hidden) {
|
||||||
|
void loadTypeOptions();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await loadTypeOptions();
|
await loadTypeOptions();
|
||||||
@ -734,14 +804,19 @@ onMounted(async () => {
|
|||||||
const deptRes = await getCommonDeptTree();
|
const deptRes = await getCommonDeptTree();
|
||||||
deptOptions.value = (deptRes.data ?? []) as any[];
|
deptOptions.value = (deptRes.data ?? []) as any[];
|
||||||
getList();
|
getList();
|
||||||
|
document.addEventListener('visibilitychange', refreshTypeOptionsIfVisible);
|
||||||
|
window.addEventListener('focus', refreshTypeOptionsIfVisible);
|
||||||
});
|
});
|
||||||
|
|
||||||
onActivated(() => {
|
onActivated(() => {
|
||||||
// 首次激活由 onMounted 加载,之后每次从其他页签切回来都重新拉取类型
|
// 每次从其他菜单/页签切回设备台账都重新拉取类型
|
||||||
if (typeOptionsActivated) {
|
void loadTypeOptions();
|
||||||
loadTypeOptions();
|
});
|
||||||
}
|
|
||||||
typeOptionsActivated = true;
|
onBeforeUnmount(() => {
|
||||||
|
document.removeEventListener('visibilitychange', refreshTypeOptionsIfVisible);
|
||||||
|
window.removeEventListener('focus', refreshTypeOptionsIfVisible);
|
||||||
|
clearExportTimer();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@ -37,9 +37,13 @@
|
|||||||
<span class="order-card__status" :class="statusClass(o.status)">{{ statusLabel(o.status) }}</span>
|
<span class="order-card__status" :class="statusClass(o.status)">{{ statusLabel(o.status) }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="order-card__row" v-if="o.deviceName">设备:{{ o.deviceName }}<template v-if="o.deviceCode">({{ o.deviceCode }})</template></div>
|
<div class="order-card__row" v-if="o.deviceName">设备:{{ o.deviceName }}<template v-if="o.deviceCode">({{ o.deviceCode }})</template></div>
|
||||||
|
<div class="order-card__row" v-if="o.currentNodeName">
|
||||||
|
当前环节:{{ nodePhaseLabel(o.currentNodeType) || o.currentNodeName }}
|
||||||
|
<template v-if="nodePhaseLabel(o.currentNodeType)">({{ o.currentNodeName }})</template>
|
||||||
|
</div>
|
||||||
<div class="order-card__row" v-if="o.handlerName">处理人:{{ o.handlerName }}</div>
|
<div class="order-card__row" v-if="o.handlerName">处理人:{{ o.handlerName }}</div>
|
||||||
<div class="order-card__bottom">
|
<div class="order-card__bottom">
|
||||||
<span>{{ o.reportName }} 报修 · {{ formatTime(o.createTime) }}</span>
|
<span>{{ o.reportName }} 报修 · {{ formatTime(o.reportTime || o.createTime) }}</span>
|
||||||
<span v-if="o.timeoutFlag === 1" class="order-card__timeout">已超时</span>
|
<span v-if="o.timeoutFlag === 1" class="order-card__timeout">已超时</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -63,9 +67,10 @@
|
|||||||
<div class="detail-row"><label>工单号</label><span>{{ detail.orderCode }}</span></div>
|
<div class="detail-row"><label>工单号</label><span>{{ detail.orderCode }}</span></div>
|
||||||
<div class="detail-row"><label>标题</label><span>{{ detail.title || '-' }}</span></div>
|
<div class="detail-row"><label>标题</label><span>{{ detail.title || '-' }}</span></div>
|
||||||
<div class="detail-row" v-if="detail.deviceName"><label>设备</label><span>{{ detail.deviceName }}<template v-if="detail.deviceCode">({{ detail.deviceCode }})</template></span></div>
|
<div class="detail-row" v-if="detail.deviceName"><label>设备</label><span>{{ detail.deviceName }}<template v-if="detail.deviceCode">({{ detail.deviceCode }})</template></span></div>
|
||||||
|
<div class="detail-row" v-if="detail.reportAddress"><label>报修位置</label><span>{{ detail.reportAddress }}</span></div>
|
||||||
<div class="detail-row" v-if="detail.orderType"><label>类型</label><span>{{ typeLabel(detail.orderType) }}</span></div>
|
<div class="detail-row" v-if="detail.orderType"><label>类型</label><span>{{ typeLabel(detail.orderType) }}</span></div>
|
||||||
<div class="detail-row" v-if="detail.description"><label>问题描述</label><span>{{ detail.description }}</span></div>
|
<div class="detail-row" v-if="detail.description"><label>问题描述</label><span>{{ detail.description }}</span></div>
|
||||||
<div class="detail-row"><label>发起人</label><span>{{ detail.reportName }} · {{ formatTime(detail.createTime) }}</span></div>
|
<div class="detail-row"><label>发起人</label><span>{{ detail.reportName }} · {{ formatTime(detail.reportTime || detail.createTime) }}</span></div>
|
||||||
<div class="detail-row" v-if="detail.handlerName"><label>处理人</label><span>{{ detail.handlerName }}</span></div>
|
<div class="detail-row" v-if="detail.handlerName"><label>处理人</label><span>{{ detail.handlerName }}</span></div>
|
||||||
<div class="detail-row" v-if="detail.maintainer"><label>维护单位</label><span>{{ detail.maintainer }}</span></div>
|
<div class="detail-row" v-if="detail.maintainer"><label>维护单位</label><span>{{ detail.maintainer }}</span></div>
|
||||||
<div class="detail-row" v-if="detail.deadline"><label>处理期限</label><span>{{ formatTime(detail.deadline) }}</span></div>
|
<div class="detail-row" v-if="detail.deadline"><label>处理期限</label><span>{{ formatTime(detail.deadline) }}</span></div>
|
||||||
@ -122,8 +127,10 @@
|
|||||||
<el-button v-if="detail.canDispatch" type="warning" round @click="openInternalDispatch">派 单</el-button>
|
<el-button v-if="detail.canDispatch" type="warning" round @click="openInternalDispatch">派 单</el-button>
|
||||||
<!-- 处理人:完工提交 -->
|
<!-- 处理人:完工提交 -->
|
||||||
<el-button v-if="canFinish || detail.canFinish" type="success" round @click="openFinish">完工提交</el-button>
|
<el-button v-if="canFinish || detail.canFinish" type="success" round @click="openFinish">完工提交</el-button>
|
||||||
<!-- 审批人:审批当前流程节点 -->
|
<!-- 当前节点:审批 / 验收 / 监理确认 -->
|
||||||
<el-button v-if="canApproveNode" type="warning" round @click="openApproveNode">审 批</el-button>
|
<el-button v-if="canApproveNode" type="warning" round @click="openApproveNode">
|
||||||
|
{{ nodeActionName(detail.currentNodeType) }}
|
||||||
|
</el-button>
|
||||||
<!-- 监理:确认/退回完工费用(兼容旧流程) -->
|
<!-- 监理:确认/退回完工费用(兼容旧流程) -->
|
||||||
<template v-if="canSupervise">
|
<template v-if="canSupervise">
|
||||||
<el-button type="success" round @click="doSupervise(1)">监理确认</el-button>
|
<el-button type="success" round @click="doSupervise(1)">监理确认</el-button>
|
||||||
@ -131,7 +138,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<!-- 发起人:修改(未进入处理流程前) -->
|
<!-- 发起人:修改(未进入处理流程前) -->
|
||||||
<el-button v-if="canEdit" plain round @click="openEdit">修 改</el-button>
|
<el-button v-if="canEdit" plain round @click="openEdit">修 改</el-button>
|
||||||
<!-- 发起人/管理员:催办、关闭 -->
|
<!-- 发起人:催办;发起人/管理员:关闭 -->
|
||||||
<el-button v-if="canUrge" plain round @click="doUrge">催 办</el-button>
|
<el-button v-if="canUrge" plain round @click="doUrge">催 办</el-button>
|
||||||
<el-button v-if="canClose" type="danger" plain round @click="closeVisible = true">关 闭</el-button>
|
<el-button v-if="canClose" type="danger" plain round @click="closeVisible = true">关 闭</el-button>
|
||||||
<!-- 非处理人:验收 -->
|
<!-- 非处理人:验收 -->
|
||||||
@ -197,27 +204,64 @@
|
|||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
<!-- 审批流节点审批弹层 -->
|
<!-- 审批流节点审批弹层 -->
|
||||||
<el-dialog v-model="approveVisible" :title="`工单审批 - ${approveNode.nodeName}`" width="92%">
|
<el-dialog v-model="approveVisible"
|
||||||
|
:title="`工单${nodeActionName(approveNode.nodeType)} - ${approveNode.nodeName}`" width="92%">
|
||||||
<el-form label-position="top">
|
<el-form label-position="top">
|
||||||
<el-form-item label="当前节点">
|
<el-form-item label="当前节点">
|
||||||
<span>{{ approveNode.nodeName }}({{ approveNodeTypeLabel(approveNode.nodeType) }})</span>
|
<span>{{ approveNode.nodeName }}({{ approveNodeTypeLabel(approveNode.nodeType) }})</span>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item v-if="approveNode.nodeType === 'SUPERVISE'" label="完工费用">
|
<template v-if="['SUPERVISE', 'VERIFY'].includes(approveNode.nodeType)">
|
||||||
<span class="cost-amount">{{ formatMoney(approveNode.amount) }}</span>
|
<div class="approve-section-title">完工提交信息</div>
|
||||||
</el-form-item>
|
<el-form-item label="处理人">
|
||||||
<el-form-item label="审批结论">
|
<span>{{ detail.handlerName || '-' }}</span>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="完工时间">
|
||||||
|
<span>{{ formatTime(detail.finishTime) }}</span>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="处理说明">
|
||||||
|
<span style="white-space: pre-wrap">{{ detail.processDesc || '-' }}</span>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="完工照片">
|
||||||
|
<div v-if="detail.finishImageUrls && detail.finishImageUrls.length" class="finish-images">
|
||||||
|
<el-image v-for="(img, i) in detail.finishImageUrls" :key="i" :src="img"
|
||||||
|
:preview-src-list="detail.finishImageUrls" :initial-index="i" preview-teleported
|
||||||
|
fit="cover" class="finish-image" />
|
||||||
|
</div>
|
||||||
|
<span v-else>-</span>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="合同单价">
|
||||||
|
{{ detail.priceItem || '-' }}
|
||||||
|
<span v-if="detail.unitPrice">({{ formatMoney(detail.unitPrice) }} × {{ detail.workQty || 0 }})</span>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="完工工作量">
|
||||||
|
<span>{{ detail.workQty || 0 }}</span>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="完工费用">
|
||||||
|
<span class="cost-amount">{{ formatMoney(detail.amount) }}</span>
|
||||||
|
<span v-if="Number(detail.calcAmount) !== Number(detail.amount)" class="cost-tip">
|
||||||
|
(系统计算:{{ formatMoney(detail.calcAmount) }})
|
||||||
|
</span>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item v-if="detail.amountAdjustReason" label="手改原因">
|
||||||
|
<span class="cost-tip">{{ detail.amountAdjustReason }}</span>
|
||||||
|
</el-form-item>
|
||||||
|
</template>
|
||||||
|
<el-form-item :label="nodeActionName(approveNode.nodeType) + '结论'">
|
||||||
<el-radio-group v-model="approveForm.approveResult">
|
<el-radio-group v-model="approveForm.approveResult">
|
||||||
<el-radio :value="1">通过</el-radio>
|
<el-radio :value="1">通过</el-radio>
|
||||||
<el-radio :value="0">驳回</el-radio>
|
<el-radio :value="0">驳回</el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="审批意见">
|
<el-form-item :label="nodeActionName(approveNode.nodeType) + '意见'">
|
||||||
<el-input v-model="approveForm.approveOpinion" type="textarea" :rows="3" placeholder="驳回时必须填写审批意见" />
|
<el-input v-model="approveForm.approveOpinion" type="textarea" :rows="3"
|
||||||
|
:placeholder="'驳回时必须填写' + nodeActionName(approveNode.nodeType) + '意见'" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<el-button round @click="approveVisible = false">取消</el-button>
|
<el-button round @click="approveVisible = false">取消</el-button>
|
||||||
<el-button type="primary" round :loading="submitting" @click="doApproveNode">提 交</el-button>
|
<el-button type="primary" round :loading="submitting" @click="doApproveNode">
|
||||||
|
提交{{ nodeActionName(approveNode.nodeType) }}
|
||||||
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
@ -257,18 +301,27 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="设备类型(可空,先选类型缩小设备范围)">
|
<el-form-item label="设备类型(可空,先选类型缩小设备范围)">
|
||||||
<el-select v-model="formTypeId" clearable style="width: 100%" @change="createForm.deviceId = ''; loadDevices()">
|
<el-select v-model="formTypeId" clearable style="width: 100%" @change="onTypeChange">
|
||||||
<el-option v-for="t in typeOpts" :key="t.id" :label="t.typeName" :value="t.id" />
|
<el-option v-for="t in typeOpts" :key="t.id" :label="t.typeName" :value="t.id" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="关联设备(可空)">
|
<el-form-item label="关联设备(可空)">
|
||||||
<div class="device-picker">
|
<div class="device-picker">
|
||||||
<el-select v-model="createForm.deviceId" filterable remote clearable :remote-method="loadDevices" placeholder="输入名称搜索设备" style="flex: 1">
|
<el-select v-model="createForm.deviceId" filterable remote clearable :remote-method="loadDevices" placeholder="输入名称搜索设备" style="flex: 1"
|
||||||
<el-option v-for="d in deviceOpts" :key="d.id" :label="`${d.deviceName}(${d.deviceCode})`" :value="d.id" />
|
@change="onDeviceChange">
|
||||||
|
<el-option v-for="d in deviceOpts" :key="d.id"
|
||||||
|
:label="d.deviceCode ? `${d.deviceName}(${d.deviceCode})` : d.deviceName" :value="d.id" />
|
||||||
</el-select>
|
</el-select>
|
||||||
<el-button icon="Camera" @click="scanDevice">扫码</el-button>
|
<el-button icon="Camera" @click="scanDevice">扫码</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="报修位置" required>
|
||||||
|
<div class="device-picker">
|
||||||
|
<el-input v-model="createForm.reportAddress" readonly placeholder="选择设备后自动带出,或点击地图选择"
|
||||||
|
style="flex: 1" @click="openLocationPicker" />
|
||||||
|
<el-button icon="MapLocation" @click="openLocationPicker">地图</el-button>
|
||||||
|
</div>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item label="工单标题" required>
|
<el-form-item label="工单标题" required>
|
||||||
<el-input v-model="createForm.title" placeholder="请输入工单标题" />
|
<el-input v-model="createForm.title" placeholder="请输入工单标题" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@ -288,6 +341,9 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
|
<sb-location-picker v-model="locationPickerVisible" :lng="locationPickerLng" :lat="locationPickerLat"
|
||||||
|
:address="locationPickerAddress" @confirm="onLocationConfirm" />
|
||||||
|
|
||||||
<!-- 免登失败提示 -->
|
<!-- 免登失败提示 -->
|
||||||
<div v-if="loginError" class="h5-order__error">
|
<div v-if="loginError" class="h5-order__error">
|
||||||
<p>{{ loginError }}</p>
|
<p>{{ loginError }}</p>
|
||||||
@ -328,11 +384,11 @@ const perm = (p: string) => permissions.value.includes(p) || permissions.value.i
|
|||||||
/** 状态页签(与 Web 端状态口径一致;多状态用逗号分隔,后端 in 查询) */
|
/** 状态页签(与 Web 端状态口径一致;多状态用逗号分隔,后端 in 查询) */
|
||||||
const tabs = [
|
const tabs = [
|
||||||
{ label: '全部', value: '' },
|
{ label: '全部', value: '' },
|
||||||
|
{ label: '待审批', value: 'PENDING_APPROVAL' },
|
||||||
{ label: '待接单', value: 'TO_ACCEPT' },
|
{ label: '待接单', value: 'TO_ACCEPT' },
|
||||||
{ label: '待派单', value: 'PENDING_INTERNAL_DISPATCH' },
|
{ label: '待派单', value: 'PENDING_INTERNAL_DISPATCH' },
|
||||||
{ label: '处理中', value: 'ACCEPTED,PROCESSING' },
|
{ label: '处理中', value: 'ACCEPTED,PROCESSING' },
|
||||||
{ label: '待监理', value: 'PENDING_SUPERVISE' },
|
{ label: '待监理', value: 'PENDING_SUPERVISE' },
|
||||||
{ label: '待审批', value: 'PENDING_APPROVAL' },
|
|
||||||
{ label: '待验收', value: 'PENDING_VERIFY' },
|
{ label: '待验收', value: 'PENDING_VERIFY' },
|
||||||
{ label: '已完成', value: 'FINISHED' }
|
{ label: '已完成', value: 'FINISHED' }
|
||||||
];
|
];
|
||||||
@ -368,7 +424,7 @@ const verifyOpinion = ref('');
|
|||||||
const superviseRejectVisible = ref(false);
|
const superviseRejectVisible = ref(false);
|
||||||
const superviseOpinion = ref('');
|
const superviseOpinion = ref('');
|
||||||
const approveVisible = ref(false);
|
const approveVisible = ref(false);
|
||||||
const approveNode = reactive({ nodeName: '', nodeType: '', amount: 0 });
|
const approveNode = reactive({ nodeName: '', nodeType: '' });
|
||||||
const approveForm = reactive<{ approveResult: number; approveOpinion: string }>({ approveResult: 1, approveOpinion: '' });
|
const approveForm = reactive<{ approveResult: number; approveOpinion: string }>({ approveResult: 1, approveOpinion: '' });
|
||||||
const internalDispatchVisible = ref(false);
|
const internalDispatchVisible = ref(false);
|
||||||
const internalDispatchHandlerId = ref<any>('');
|
const internalDispatchHandlerId = ref<any>('');
|
||||||
@ -382,17 +438,60 @@ const editId = ref<string | number>('');
|
|||||||
const ORDER_TYPES: Record<string, string> = {
|
const ORDER_TYPES: Record<string, string> = {
|
||||||
bx: '故障报修', xj: '日常巡检', by: '维修保养', az: '设备安装', cc: '设备拆除'
|
bx: '故障报修', xj: '日常巡检', by: '维修保养', az: '设备安装', cc: '设备拆除'
|
||||||
};
|
};
|
||||||
const createForm = reactive<{ orderType: string; deviceId: any; title: string; description: string; images: string; deadline: string }>({
|
const createForm = reactive<{
|
||||||
orderType: 'bx', deviceId: '', title: '', description: '', images: '', deadline: ''
|
orderType: string; deviceId: any; title: string; description: string; images: string; deadline: string;
|
||||||
|
reportLng?: number; reportLat?: number; reportAddress: string;
|
||||||
|
}>({
|
||||||
|
orderType: 'bx', deviceId: '', title: '', description: '', images: '', deadline: '', reportAddress: ''
|
||||||
});
|
});
|
||||||
|
const locationPickerVisible = ref(false);
|
||||||
|
const locationPickerLng = ref<number>();
|
||||||
|
const locationPickerLat = ref<number>();
|
||||||
|
const locationPickerAddress = ref('');
|
||||||
|
const onTypeChange = () => {
|
||||||
|
createForm.deviceId = '';
|
||||||
|
createForm.reportLng = undefined;
|
||||||
|
createForm.reportLat = undefined;
|
||||||
|
createForm.reportAddress = '';
|
||||||
|
loadDevices();
|
||||||
|
};
|
||||||
|
const onDeviceChange = () => {
|
||||||
|
const device = deviceOpts.value.find((item) => String(item.id) === String(createForm.deviceId));
|
||||||
|
if (!device) {
|
||||||
|
createForm.reportLng = undefined;
|
||||||
|
createForm.reportLat = undefined;
|
||||||
|
createForm.reportAddress = '';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (device.lng != null && device.lat != null) {
|
||||||
|
createForm.reportLng = Number(device.lng);
|
||||||
|
createForm.reportLat = Number(device.lat);
|
||||||
|
}
|
||||||
|
if (device.installLocation) {
|
||||||
|
createForm.reportAddress = device.installLocation;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const openLocationPicker = () => {
|
||||||
|
locationPickerLng.value = createForm.reportLng;
|
||||||
|
locationPickerLat.value = createForm.reportLat;
|
||||||
|
locationPickerAddress.value = createForm.reportAddress || '';
|
||||||
|
locationPickerVisible.value = true;
|
||||||
|
};
|
||||||
|
const onLocationConfirm = (value: { lng?: number; lat?: number; address: string }) => {
|
||||||
|
createForm.reportLng = value.lng;
|
||||||
|
createForm.reportLat = value.lat;
|
||||||
|
createForm.reportAddress = value.address;
|
||||||
|
};
|
||||||
const formTypeId = ref<string | number>('');
|
const formTypeId = ref<string | number>('');
|
||||||
const typeOpts = ref<any[]>([]);
|
const typeOpts = ref<any[]>([]);
|
||||||
const deviceOpts = ref<any[]>([]);
|
const deviceOpts = ref<any[]>([]);
|
||||||
|
|
||||||
/* ---------- 状态字典(与后台字典键一致) ---------- */
|
/* ---------- 状态字典(与后台字典键一致) ---------- */
|
||||||
const STATUS_LABELS: Record<string, string> = {
|
const STATUS_LABELS: Record<string, string> = {
|
||||||
|
PENDING_DISPATCH: '待派单',
|
||||||
TO_ACCEPT: '待接单',
|
TO_ACCEPT: '待接单',
|
||||||
ACCEPTED: '已接单',
|
ACCEPTED: '已接单',
|
||||||
|
ARRIVED: '已到场',
|
||||||
PROCESSING: '处理中',
|
PROCESSING: '处理中',
|
||||||
PENDING_SUPERVISE: '待监理确认',
|
PENDING_SUPERVISE: '待监理确认',
|
||||||
PENDING_APPROVAL: '待审批',
|
PENDING_APPROVAL: '待审批',
|
||||||
@ -442,7 +541,7 @@ const canEdit = computed(
|
|||||||
() =>
|
() =>
|
||||||
perm('sbgl:order:edit') &&
|
perm('sbgl:order:edit') &&
|
||||||
(isReporter.value || isAdmin.value) &&
|
(isReporter.value || isAdmin.value) &&
|
||||||
['PENDING_DISPATCH', 'REJECTED', 'TO_ACCEPT'].includes(detail.value.status)
|
['PENDING_DISPATCH', 'REJECTED'].includes(detail.value.status)
|
||||||
);
|
);
|
||||||
/** 验收:验收权限 + 待验收状态 + 非处理人本人 */
|
/** 验收:验收权限 + 待验收状态 + 非处理人本人 */
|
||||||
const canVerify = computed(
|
const canVerify = computed(
|
||||||
@ -465,11 +564,15 @@ const canApproveNode = computed(() => perm('sbgl:order:query') && detail.value.c
|
|||||||
const canAcceptNode = computed(() => perm('sbgl:order:handle') && detail.value.canAccept === true);
|
const canAcceptNode = computed(() => perm('sbgl:order:handle') && detail.value.canAccept === true);
|
||||||
const approveNodeTypeLabel = (type: string) =>
|
const approveNodeTypeLabel = (type: string) =>
|
||||||
({ SUPERVISE: '监理确认', VERIFY: '验收', APPROVAL: '审批' }[type] || '审批');
|
({ SUPERVISE: '监理确认', VERIFY: '验收', APPROVAL: '审批' }[type] || '审批');
|
||||||
|
const nodeActionName = (type?: string) =>
|
||||||
|
(type === 'VERIFY' ? '验收' : type === 'SUPERVISE' ? '监理确认' : '审批');
|
||||||
const canUrge = computed(
|
const canUrge = computed(
|
||||||
() =>
|
() =>
|
||||||
|
perm('sbgl:order:query') &&
|
||||||
|
isReporter.value &&
|
||||||
|
!['FINISHED', 'CLOSED', 'REJECTED'].includes(detail.value.status) &&
|
||||||
(!!detail.value.currentNodeId ||
|
(!!detail.value.currentNodeId ||
|
||||||
['PENDING_DISPATCH', 'TO_ACCEPT', 'ACCEPTED', 'PROCESSING'].includes(detail.value.status)) &&
|
['TO_ACCEPT', 'ACCEPTED', 'ARRIVED', 'PROCESSING'].includes(detail.value.status))
|
||||||
isReporter.value
|
|
||||||
);
|
);
|
||||||
const canClose = computed(
|
const canClose = computed(
|
||||||
() =>
|
() =>
|
||||||
@ -555,9 +658,11 @@ const openDetail = async (o: any) => {
|
|||||||
detail.value = res.data;
|
detail.value = res.data;
|
||||||
const r = await listOrderRecords(o.id);
|
const r = await listOrderRecords(o.id);
|
||||||
records.value = (r as any).data ?? [];
|
records.value = (r as any).data ?? [];
|
||||||
// 流转记录里存的是 ossId(逗号分隔),需换算成访问 URL 才能展示
|
// 流转记录/完工照片存的是 ossId(逗号分隔),需换算成访问 URL 才能展示
|
||||||
try {
|
try {
|
||||||
const allIds = [...new Set(records.value.flatMap((rec: any) => (rec.images ? rec.images.split(',') : [])))].filter(Boolean).join(',');
|
const recordIds = records.value.flatMap((rec: any) => (rec.images ? rec.images.split(',') : []));
|
||||||
|
const finishIds = detail.value.finishImages ? detail.value.finishImages.split(',') : [];
|
||||||
|
const allIds = [...new Set([...recordIds, ...finishIds])].filter(Boolean).join(',');
|
||||||
if (allIds) {
|
if (allIds) {
|
||||||
const ossRes = await listBusinessOss(allIds);
|
const ossRes = await listBusinessOss(allIds);
|
||||||
const urlMap: Record<string, string> = {};
|
const urlMap: Record<string, string> = {};
|
||||||
@ -567,6 +672,7 @@ const openDetail = async (o: any) => {
|
|||||||
rec.imageUrls = rec.images.split(',').map((id: string) => urlMap[id]).filter(Boolean).join(',');
|
rec.imageUrls = rec.images.split(',').map((id: string) => urlMap[id]).filter(Boolean).join(',');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
detail.value.finishImageUrls = finishIds.map((id: string) => urlMap[id]).filter(Boolean);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// 换算失败不阻断详情展示
|
// 换算失败不阻断详情展示
|
||||||
@ -578,133 +684,6 @@ const openDetail = async (o: any) => {
|
|||||||
/** 是否钉钉容器内(钉钉 WebView 的 UA 带 DingTalk 标识) */
|
/** 是否钉钉容器内(钉钉 WebView 的 UA 带 DingTalk 标识) */
|
||||||
const isDingTalk = () => /DingTalk/i.test(navigator.userAgent);
|
const isDingTalk = () => /DingTalk/i.test(navigator.userAgent);
|
||||||
|
|
||||||
/** 浏览器定位(仅非钉钉环境使用),WGS84 坐标转为 GCJ-02 与高德底图一致;带硬超时防止个别环境卡死 */
|
|
||||||
const browserLocate = (): Promise<{ lng?: number; lat?: number }> =>
|
|
||||||
new Promise((resolve) => {
|
|
||||||
let settled = false;
|
|
||||||
const done = (v: { lng?: number; lat?: number }) => {
|
|
||||||
if (settled) return;
|
|
||||||
settled = true;
|
|
||||||
clearTimeout(hardTimer);
|
|
||||||
resolve(v);
|
|
||||||
};
|
|
||||||
// 硬超时:部分 WebView 的 getCurrentPosition 报了 timeout 也不回调,强制兜底
|
|
||||||
const hardTimer = setTimeout(() => done({}), 8000);
|
|
||||||
if (!navigator.geolocation) return done({});
|
|
||||||
navigator.geolocation.getCurrentPosition(
|
|
||||||
(pos) => {
|
|
||||||
const gcj = wgs84ToGcj02(pos.coords.longitude, pos.coords.latitude);
|
|
||||||
done({ lng: gcj.lng, lat: gcj.lat });
|
|
||||||
},
|
|
||||||
() => done({}),
|
|
||||||
{ enableHighAccuracy: true, timeout: 6000 }
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
/** WGS84 → GCJ-02(火星坐标)转换,偏移算法适用于中国境内 */
|
|
||||||
const wgs84ToGcj02 = (lng: number, lat: number): { lng: number; lat: number } => {
|
|
||||||
const a = 6378245.0;
|
|
||||||
const ee = 0.00669342162296594323;
|
|
||||||
const transformLat = (x: number, y: number) => {
|
|
||||||
let ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x));
|
|
||||||
ret += ((20.0 * Math.sin(6.0 * x * Math.PI) + 20.0 * Math.sin(2.0 * x * Math.PI)) * 2.0) / 3.0;
|
|
||||||
ret += ((20.0 * Math.sin(y * Math.PI) + 40.0 * Math.sin((y / 3.0) * Math.PI)) * 2.0) / 3.0;
|
|
||||||
ret += ((160.0 * Math.sin((y / 12.0) * Math.PI) + 320 * Math.sin((y * Math.PI) / 30.0)) * 2.0) / 3.0;
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
const transformLng = (x: number, y: number) => {
|
|
||||||
let ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt(Math.abs(x));
|
|
||||||
ret += ((20.0 * Math.sin(6.0 * x * Math.PI) + 20.0 * Math.sin(2.0 * x * Math.PI)) * 2.0) / 3.0;
|
|
||||||
ret += ((20.0 * Math.sin(x * Math.PI) + 40.0 * Math.sin((x / 3.0) * Math.PI)) * 2.0) / 3.0;
|
|
||||||
ret += ((150.0 * Math.sin((x / 12.0) * Math.PI) + 300.0 * Math.sin((x / 30.0) * Math.PI)) * 2.0) / 3.0;
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
if (lng < 72.004 || lng > 137.8347 || lat < 0.8293 || lat > 55.8271) return { lng, lat };
|
|
||||||
let dLat = transformLat(lng - 105.0, lat - 35.0);
|
|
||||||
let dLng = transformLng(lng - 105.0, lat - 35.0);
|
|
||||||
const radLat = (lat / 180.0) * Math.PI;
|
|
||||||
let magic = Math.sin(radLat);
|
|
||||||
magic = 1 - ee * magic * magic;
|
|
||||||
const sqrtMagic = Math.sqrt(magic);
|
|
||||||
dLat = (dLat * 180.0) / (((a * (1 - ee)) / (magic * sqrtMagic)) * Math.PI);
|
|
||||||
dLng = (dLng * 180.0) / ((a / sqrtMagic) * Math.cos(radLat) * Math.PI);
|
|
||||||
return { lng: lng + dLng, lat: lat + dLat };
|
|
||||||
};
|
|
||||||
|
|
||||||
const showLocateLoading = () => {
|
|
||||||
if (isDingTalk()) {
|
|
||||||
dd.device?.notification?.showPreloader?.({ text: '正在获取定位…', showIcon: true });
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const hideLocateLoading = () => {
|
|
||||||
if (isDingTalk()) {
|
|
||||||
dd.device?.notification?.hidePreloader?.();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/** 钉钉容器内定位:JSAPI device.geolocation.get(原生手机定位,需 dd.config 签名鉴权)
|
|
||||||
* 注意:该 JSAPI 仅移动端钉钉支持,PC 端钉钉不支持;钉钉内不降级浏览器定位(HTTP 页面会卡住),
|
|
||||||
* 任何环节失败都直接以空坐标继续签到流程,不阻断操作。 */
|
|
||||||
const dingLocate = (): Promise<{ lng?: number; lat?: number }> =>
|
|
||||||
new Promise((resolve) => {
|
|
||||||
// PC 端钉钉不支持定位 JSAPI(geolocation 壳子存在但调用永不回调),直接空坐标秒返回,不弹加载。
|
|
||||||
// platform 取值有 pc/gdtPc 等多种变体,用 UA 判断最可靠:非移动端 UA 一律视为 PC
|
|
||||||
const isMobileUA = /iPhone|iPad|iPod|Android|Mobile/i.test(navigator.userAgent || '');
|
|
||||||
if (!isMobileUA || !dd.device?.geolocation?.get) {
|
|
||||||
resolve({});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
showLocateLoading();
|
|
||||||
let settled = false;
|
|
||||||
const done = (v: { lng?: number; lat?: number }) => {
|
|
||||||
if (settled) return;
|
|
||||||
settled = true;
|
|
||||||
clearTimeout(guardTimer);
|
|
||||||
hideLocateLoading();
|
|
||||||
resolve(v);
|
|
||||||
};
|
|
||||||
// 超时保护:10 秒未拿到定位直接空坐标继续,避免流程卡死无反应
|
|
||||||
const fallback = () => done({});
|
|
||||||
const guardTimer = setTimeout(fallback, 10000);
|
|
||||||
|
|
||||||
// 签名 URL 必须与当前页面地址一致(不含 hash)
|
|
||||||
const signUrl = window.location.href.split('#')[0];
|
|
||||||
jsapiSign(signUrl)
|
|
||||||
.then((res: any) => {
|
|
||||||
const cfg = res?.data || {};
|
|
||||||
dd.config({
|
|
||||||
agentId: String(cfg.agentId ?? ''),
|
|
||||||
corpId,
|
|
||||||
timeStamp: String(cfg.timeStamp ?? ''),
|
|
||||||
nonceStr: cfg.nonceStr,
|
|
||||||
signature: cfg.signature,
|
|
||||||
jsApiList: ['device.geolocation.get', 'biz.util.scan']
|
|
||||||
});
|
|
||||||
dd.ready(() => {
|
|
||||||
try {
|
|
||||||
dd.device.geolocation.get({
|
|
||||||
targetAccuracy: 200,
|
|
||||||
coordinate: 1, // 高德坐标(GCJ-02),与系统地图底图一致
|
|
||||||
withReGeocode: false,
|
|
||||||
useCache: false,
|
|
||||||
onSuccess: (r: any) => done({ lng: r.longitude, lat: r.latitude }),
|
|
||||||
onFail: fallback
|
|
||||||
});
|
|
||||||
} catch {
|
|
||||||
fallback();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch(fallback);
|
|
||||||
});
|
|
||||||
|
|
||||||
/** 获取定位:钉钉内只走原生 JSAPI 定位(失败/超时则不带坐标继续,绝不降级浏览器定位防卡死);
|
|
||||||
* 非钉钉环境(普通浏览器)走浏览器定位。均不阻断完工提交流程。 */
|
|
||||||
const getLocation = (): Promise<{ lng?: number; lat?: number }> => {
|
|
||||||
if (isDingTalk()) return dingLocate();
|
|
||||||
return browserLocate();
|
|
||||||
};
|
|
||||||
|
|
||||||
const doHandle = async (action: 'ACCEPT') => {
|
const doHandle = async (action: 'ACCEPT') => {
|
||||||
submitting.value = true;
|
submitting.value = true;
|
||||||
try {
|
try {
|
||||||
@ -864,7 +843,6 @@ const doSupervise = async (result: number) => {
|
|||||||
const openApproveNode = () => {
|
const openApproveNode = () => {
|
||||||
approveNode.nodeName = detail.value.currentNodeName || '';
|
approveNode.nodeName = detail.value.currentNodeName || '';
|
||||||
approveNode.nodeType = detail.value.currentNodeType || '';
|
approveNode.nodeType = detail.value.currentNodeType || '';
|
||||||
approveNode.amount = Number(detail.value.amount ?? 0);
|
|
||||||
approveForm.approveResult = 1;
|
approveForm.approveResult = 1;
|
||||||
approveForm.approveOpinion = '';
|
approveForm.approveOpinion = '';
|
||||||
approveVisible.value = true;
|
approveVisible.value = true;
|
||||||
@ -872,7 +850,7 @@ const openApproveNode = () => {
|
|||||||
|
|
||||||
const doApproveNode = async () => {
|
const doApproveNode = async () => {
|
||||||
if (approveForm.approveResult === 0 && !approveForm.approveOpinion.trim()) {
|
if (approveForm.approveResult === 0 && !approveForm.approveOpinion.trim()) {
|
||||||
ElMessage.warning('驳回时请填写审批意见');
|
ElMessage.warning(`驳回时请填写${nodeActionName(approveNode.nodeType)}意见`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
submitting.value = true;
|
submitting.value = true;
|
||||||
@ -965,7 +943,14 @@ const scanDevice = async () => {
|
|||||||
formTypeId.value = device.typeId;
|
formTypeId.value = device.typeId;
|
||||||
await loadDevices(device.deviceName);
|
await loadDevices(device.deviceName);
|
||||||
createForm.deviceId = device.id;
|
createForm.deviceId = device.id;
|
||||||
ElMessage.success(`已匹配设备:${device.deviceName}(${device.deviceCode})`);
|
if (device.lng != null && device.lat != null) {
|
||||||
|
createForm.reportLng = Number(device.lng);
|
||||||
|
createForm.reportLat = Number(device.lat);
|
||||||
|
}
|
||||||
|
if (device.installLocation) {
|
||||||
|
createForm.reportAddress = device.installLocation;
|
||||||
|
}
|
||||||
|
ElMessage.success(`已匹配设备:${device.deviceName}${device.deviceCode ? '(' + device.deviceCode + ')' : ''}`);
|
||||||
} catch {
|
} catch {
|
||||||
// 错误提示由请求拦截器统一处理
|
// 错误提示由请求拦截器统一处理
|
||||||
}
|
}
|
||||||
@ -977,12 +962,11 @@ const scanDevice = async () => {
|
|||||||
|
|
||||||
const openCreate = async () => {
|
const openCreate = async () => {
|
||||||
editId.value = '';
|
editId.value = '';
|
||||||
Object.assign(createForm, { orderType: 'bx', deviceId: '', title: '', description: '', images: '', deadline: '' });
|
Object.assign(createForm, { orderType: 'bx', deviceId: '', title: '', description: '', images: '', deadline: '', reportLng: undefined, reportLat: undefined, reportAddress: '' });
|
||||||
formTypeId.value = '';
|
formTypeId.value = '';
|
||||||
if (typeOpts.value.length === 0) {
|
// 每次打开都刷新类型,避免后台新增类型后 H5 看不到
|
||||||
const res = await listTypeOptions();
|
const typeRes = await listTypeOptions();
|
||||||
typeOpts.value = (res as any).data ?? [];
|
typeOpts.value = (typeRes as any).data ?? [];
|
||||||
}
|
|
||||||
await loadDevices();
|
await loadDevices();
|
||||||
submitVisible.value = true;
|
submitVisible.value = true;
|
||||||
};
|
};
|
||||||
@ -995,19 +979,35 @@ const openEdit = async () => {
|
|||||||
title: detail.value.title,
|
title: detail.value.title,
|
||||||
description: detail.value.description,
|
description: detail.value.description,
|
||||||
images: detail.value.images || '',
|
images: detail.value.images || '',
|
||||||
deadline: detail.value.deadline || ''
|
deadline: detail.value.deadline || '',
|
||||||
|
reportLng: detail.value.reportLng,
|
||||||
|
reportLat: detail.value.reportLat,
|
||||||
|
reportAddress: detail.value.reportAddress || ''
|
||||||
});
|
});
|
||||||
formTypeId.value = '';
|
formTypeId.value = '';
|
||||||
if (typeOpts.value.length === 0) {
|
// 每次打开都刷新类型,避免后台新增类型后 H5 看不到
|
||||||
const res = await listTypeOptions();
|
const typeRes = await listTypeOptions();
|
||||||
typeOpts.value = (res as any).data ?? [];
|
typeOpts.value = (typeRes as any).data ?? [];
|
||||||
|
// 按设备名搜索候选项,避免原设备不在默认 20 条里导致下拉框显示为空
|
||||||
|
await loadDevices(detail.value.deviceName || undefined);
|
||||||
|
// 历史工单没有报修位置时,用关联设备的安装位置补齐
|
||||||
|
const currentDevice = deviceOpts.value.find((d) => String(d.id) === String(createForm.deviceId));
|
||||||
|
if (currentDevice) {
|
||||||
|
if (!createForm.reportAddress && currentDevice.installLocation) {
|
||||||
|
createForm.reportAddress = currentDevice.installLocation;
|
||||||
|
}
|
||||||
|
if (createForm.reportLng == null && createForm.reportLat == null
|
||||||
|
&& currentDevice.lng != null && currentDevice.lat != null) {
|
||||||
|
createForm.reportLng = Number(currentDevice.lng);
|
||||||
|
createForm.reportLat = Number(currentDevice.lat);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
await loadDevices();
|
|
||||||
submitVisible.value = true;
|
submitVisible.value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const doSubmitOrder = async () => {
|
const doSubmitOrder = async () => {
|
||||||
if (!createForm.orderType) return ElMessage.warning('请选择工单类型');
|
if (!createForm.orderType) return ElMessage.warning('请选择工单类型');
|
||||||
|
if (!createForm.reportAddress?.trim()) return ElMessage.warning('请选择报修位置');
|
||||||
if (!createForm.title?.trim()) return ElMessage.warning('请填写工单标题');
|
if (!createForm.title?.trim()) return ElMessage.warning('请填写工单标题');
|
||||||
submitting.value = true;
|
submitting.value = true;
|
||||||
try {
|
try {
|
||||||
@ -1056,6 +1056,32 @@ onMounted(async () => {
|
|||||||
color: #d9480f;
|
color: #d9480f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.cost-tip {
|
||||||
|
margin-left: 4px;
|
||||||
|
color: #909399;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.approve-section-title {
|
||||||
|
margin: 10px 0 6px;
|
||||||
|
padding-left: 8px;
|
||||||
|
border-left: 3px solid #409eff;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #303133;
|
||||||
|
}
|
||||||
|
|
||||||
|
.finish-images {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.finish-image {
|
||||||
|
width: 68px;
|
||||||
|
height: 68px;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
.finish-cost {
|
.finish-cost {
|
||||||
margin-bottom: 6px;
|
margin-bottom: 6px;
|
||||||
color: #d9480f;
|
color: #d9480f;
|
||||||
@ -1140,7 +1166,7 @@ onMounted(async () => {
|
|||||||
margin-left: 2px;
|
margin-left: 2px;
|
||||||
}
|
}
|
||||||
&__list {
|
&__list {
|
||||||
padding: 10px 12px 30px;
|
padding: 10px 12px 90px;
|
||||||
}
|
}
|
||||||
&__tip {
|
&__tip {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
@ -1179,11 +1205,17 @@ onMounted(async () => {
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
margin-bottom: 6px;
|
margin-bottom: 6px;
|
||||||
}
|
}
|
||||||
&__title {
|
&__title {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
overflow: hidden;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: #243244;
|
color: #243244;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
&__row {
|
&__row {
|
||||||
color: #667;
|
color: #667;
|
||||||
|
|||||||
@ -77,8 +77,8 @@
|
|||||||
<div class="detail-row"><span>类型:</span>{{ selected.typeName }}</div>
|
<div class="detail-row"><span>类型:</span>{{ selected.typeName }}</div>
|
||||||
<div class="detail-row">
|
<div class="detail-row">
|
||||||
<span>状态:</span>
|
<span>状态:</span>
|
||||||
<span :class="['status-tag', statusClass(selected.status)]">
|
<span :class="['status-tag', statusClass(selected)]">
|
||||||
{{ statusText(selected.status) }}
|
{{ statusText(selected) }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="detail-row"><span>经纬度:</span>{{ Number(selected.lng).toFixed(5) }}, {{ Number(selected.lat).toFixed(5) }}</div>
|
<div class="detail-row"><span>经纬度:</span>{{ Number(selected.lng).toFixed(5) }}, {{ Number(selected.lat).toFixed(5) }}</div>
|
||||||
@ -108,8 +108,6 @@ import { formatFieldValue } from '../devicetype/fieldTypes';
|
|||||||
import { locateDistrict } from '@/utils/geo';
|
import { locateDistrict } from '@/utils/geo';
|
||||||
import quzhouGeo from '@/assets/geo/quzhou.json';
|
import quzhouGeo from '@/assets/geo/quzhou.json';
|
||||||
|
|
||||||
const { proxy } = getCurrentInstance() as any;
|
|
||||||
const { sb_device_status } = toRefs<any>(proxy?.useDict('sb_device_status'));
|
|
||||||
|
|
||||||
const overview = ref<OverviewVO>({});
|
const overview = ref<OverviewVO>({});
|
||||||
const typeOptions = ref<DeviceTypeVO[]>([]);
|
const typeOptions = ref<DeviceTypeVO[]>([]);
|
||||||
@ -127,13 +125,16 @@ const activeDistrict = ref('');
|
|||||||
const mapRef = ref<any>();
|
const mapRef = ref<any>();
|
||||||
const geoFeatures = (quzhouGeo as any).features ?? [];
|
const geoFeatures = (quzhouGeo as any).features ?? [];
|
||||||
|
|
||||||
const statusText = (s?: string) => {
|
const statusText = (device?: any) => {
|
||||||
if (s === null || s === undefined || s === '') return '-';
|
const s = String(device?.status ?? '');
|
||||||
const hit = (sb_device_status?.value ?? []).find((d: any) => String(d.value) === String(s));
|
return ({ '0': '在用', '1': '停用', '2': '维修中', '3': '已报废' } as Record<string, string>)[s] || (s || '-');
|
||||||
return hit?.label ?? String(s);
|
};
|
||||||
|
const statusClass = (device?: any) => {
|
||||||
|
const s = String(device?.status ?? '');
|
||||||
|
if (s === '2') return 'warn';
|
||||||
|
if (s === '3' || s === '1') return 'bad';
|
||||||
|
return 'ok';
|
||||||
};
|
};
|
||||||
/** 状态标签颜色:0在用 1停用 2维修中 3已报废 */
|
|
||||||
const statusClass = (s?: string) => (String(s) === '2' ? 'warn' : String(s) === '3' || String(s) === '1' ? 'bad' : 'ok');
|
|
||||||
|
|
||||||
/** 右侧详情面板的动态属性行 */
|
/** 右侧详情面板的动态属性行 */
|
||||||
const attrRows = computed(() => {
|
const attrRows = computed(() => {
|
||||||
@ -229,7 +230,7 @@ const visiblePoints = computed(() =>
|
|||||||
.join('');
|
.join('');
|
||||||
const popupHtml = `
|
const popupHtml = `
|
||||||
<div style="font-weight:600;font-size:14px;margin-bottom:2px;">${esc(d.deviceName)}</div>
|
<div style="font-weight:600;font-size:14px;margin-bottom:2px;">${esc(d.deviceName)}</div>
|
||||||
<div style="color:#888;margin-bottom:4px;">${esc(d.typeName ?? '')} · ${statusText(d.status)}</div>
|
<div style="color:#888;margin-bottom:4px;">${esc(d.typeName ?? '')} · ${statusText(d)}</div>
|
||||||
${attrRows}
|
${attrRows}
|
||||||
<div style="color:#aaa;font-size:12px;margin-top:4px;">${Number(d.lng).toFixed(5)}, ${Number(d.lat).toFixed(5)}</div>`;
|
<div style="color:#aaa;font-size:12px;margin-top:4px;">${Number(d.lng).toFixed(5)}, ${Number(d.lat).toFixed(5)}</div>`;
|
||||||
return { id: d.id, lng: Number(d.lng), lat: Number(d.lat), name: d.deviceName, icon: resolveIconUrl(d.typeIcon), popupHtml };
|
return { id: d.id, lng: Number(d.lng), lat: Number(d.lat), name: d.deviceName, icon: resolveIconUrl(d.typeIcon), popupHtml };
|
||||||
@ -247,17 +248,16 @@ const onPointClick = (point: any) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(async () => {
|
/* ---------- 大屏数据静默刷新 ---------- */
|
||||||
const [ov, types, byType, devStatus] = await Promise.all([getOverview(), listTypeOptions(), countByType(), deviceStatus()]);
|
const SCREEN_REFRESH_MS = 30000;
|
||||||
overview.value = ov.data ?? {};
|
let refreshTimer: ReturnType<typeof setInterval> | null = null;
|
||||||
typeOptions.value = types.data ?? [];
|
let refreshing = false;
|
||||||
typeCountList.value = byType.data ?? [];
|
let typeSignature = '';
|
||||||
deviceStatusList.value = devStatus.data ?? [];
|
let deviceSignature = '';
|
||||||
visibleTypes.value = typeOptions.value.map((t) => String(t.id));
|
|
||||||
|
|
||||||
// 拉取各类型的属性字段配置,用于点位弹窗与详情面板显示中文标签
|
const loadFieldMeta = async (types: DeviceTypeVO[]) => {
|
||||||
const labelEntries = await Promise.all(
|
const labelEntries = await Promise.all(
|
||||||
typeOptions.value.map(async (t) => {
|
types.map(async (t) => {
|
||||||
try {
|
try {
|
||||||
const res = await listEnabledFields(t.id as string | number);
|
const res = await listEnabledFields(t.id as string | number);
|
||||||
const map: Record<string, { label: string; fieldType: string }> = {};
|
const map: Record<string, { label: string; fieldType: string }> = {};
|
||||||
@ -269,12 +269,86 @@ onMounted(async () => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
fieldMetaMap.value = Object.fromEntries(labelEntries);
|
fieldMetaMap.value = Object.fromEntries(labelEntries);
|
||||||
|
};
|
||||||
|
|
||||||
const res = await listMapDevice({});
|
const loadScreenData = async (silent = false) => {
|
||||||
deviceList.value = (res.data ?? []).map((d: any) => ({
|
if (refreshing) return;
|
||||||
...d,
|
refreshing = true;
|
||||||
attrs: typeof d.attrs === 'string' ? JSON.parse(d.attrs) : d.attrs
|
try {
|
||||||
}));
|
const [ov, typesRes, byType, devStatus] = await Promise.all([
|
||||||
|
getOverview(), listTypeOptions(), countByType(), deviceStatus()
|
||||||
|
]);
|
||||||
|
overview.value = ov.data ?? {};
|
||||||
|
typeCountList.value = byType.data ?? [];
|
||||||
|
deviceStatusList.value = devStatus.data ?? [];
|
||||||
|
|
||||||
|
const types = typesRes.data ?? [];
|
||||||
|
const newTypeIds = types.map((t) => String(t.id));
|
||||||
|
const nextTypeSignature = newTypeIds.join(',');
|
||||||
|
if (nextTypeSignature !== typeSignature) {
|
||||||
|
const oldTypeIds = typeOptions.value.map((t) => String(t.id));
|
||||||
|
const wasAllSelected = oldTypeIds.length === 0
|
||||||
|
|| oldTypeIds.every((id) => visibleTypes.value.includes(id));
|
||||||
|
typeOptions.value = types;
|
||||||
|
visibleTypes.value = wasAllSelected
|
||||||
|
? newTypeIds
|
||||||
|
: newTypeIds.filter((id) => visibleTypes.value.includes(id) || !oldTypeIds.includes(id));
|
||||||
|
typeSignature = nextTypeSignature;
|
||||||
|
// 类型变化时才重新拉取扩展字段配置,避免每轮刷新都发大量请求
|
||||||
|
await loadFieldMeta(types);
|
||||||
|
}
|
||||||
|
|
||||||
|
const res = await listMapDevice({});
|
||||||
|
const nextDevices = (res.data ?? []).map((d: any) => ({
|
||||||
|
...d,
|
||||||
|
attrs: typeof d.attrs === 'string' ? JSON.parse(d.attrs) : d.attrs
|
||||||
|
}));
|
||||||
|
const nextDeviceSignature = nextDevices
|
||||||
|
.map((d: any) => [d.id, d.typeId, d.status, d.lng, d.lat, d.deviceName, d.deviceCode, d.updateTime].join(':'))
|
||||||
|
.join('|');
|
||||||
|
if (nextDeviceSignature !== deviceSignature) {
|
||||||
|
deviceList.value = nextDevices;
|
||||||
|
deviceSignature = nextDeviceSignature;
|
||||||
|
if (selected.value) {
|
||||||
|
const current = nextDevices.find((d: any) => String(d.id) === String(selected.value?.id));
|
||||||
|
selected.value = current
|
||||||
|
? { ...current, attrs: typeof current.attrs === 'string' ? JSON.parse(current.attrs) : current.attrs }
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// 自动刷新失败保留上一次数据,不打扰大屏展示
|
||||||
|
if (!silent) {
|
||||||
|
console.warn('[大屏] 数据加载失败', e);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
refreshing = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const refreshWhenVisible = () => {
|
||||||
|
if (!document.hidden) {
|
||||||
|
void loadScreenData(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const stopRefreshTimer = () => {
|
||||||
|
if (refreshTimer) {
|
||||||
|
clearInterval(refreshTimer);
|
||||||
|
refreshTimer = null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
await loadScreenData();
|
||||||
|
stopRefreshTimer();
|
||||||
|
refreshTimer = setInterval(() => void loadScreenData(true), SCREEN_REFRESH_MS);
|
||||||
|
document.addEventListener('visibilitychange', refreshWhenVisible);
|
||||||
|
});
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
stopRefreshTimer();
|
||||||
|
document.removeEventListener('visibilitychange', refreshWhenVisible);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@ -92,7 +92,7 @@
|
|||||||
v-hasPermi="['sbgl:order:handle']">完工</el-button>
|
v-hasPermi="['sbgl:order:handle']">完工</el-button>
|
||||||
<el-button v-if="scope.row.canApprove"
|
<el-button v-if="scope.row.canApprove"
|
||||||
link type="warning" icon="Stamp" @click="openApprove(scope.row)"
|
link type="warning" icon="Stamp" @click="openApprove(scope.row)"
|
||||||
v-hasPermi="['sbgl:order:query']">审批</el-button>
|
v-hasPermi="['sbgl:order:query']">{{ nodeActionName(scope.row.currentNodeType) }}</el-button>
|
||||||
<el-button v-if="scope.row.status === 'PENDING_SUPERVISE' && !scope.row.currentNodeId"
|
<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']"
|
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>
|
v-show="String(scope.row.handlerId) !== String(userStore.userId) || Number(userStore.userId) === 1">监理</el-button>
|
||||||
@ -127,10 +127,18 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="关联设备" prop="deviceId">
|
<el-form-item label="关联设备" prop="deviceId">
|
||||||
<el-select v-model="submitForm.deviceId" filterable remote clearable :remote-method="searchDevice"
|
<el-select v-model="submitForm.deviceId" filterable remote clearable :remote-method="searchDevice"
|
||||||
placeholder="输入名称搜索设备(可空)" style="width: 100%">
|
placeholder="输入名称搜索设备(可空)" style="width: 100%" @change="onSubmitDeviceChange">
|
||||||
<el-option v-for="d in deviceOptions" :key="d.id" :label="`${d.deviceName}(${d.deviceCode})`" :value="d.id" />
|
<el-option v-for="d in deviceOptions" :key="d.id"
|
||||||
|
:label="d.deviceCode ? `${d.deviceName}(${d.deviceCode})` : d.deviceName" :value="d.id" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="报修位置" prop="reportAddress">
|
||||||
|
<div class="location-field">
|
||||||
|
<el-input v-model="submitForm.reportAddress" readonly
|
||||||
|
placeholder="选择设备后自动带出,或点击地图选择位置" />
|
||||||
|
<el-button icon="MapLocation" @click="openLocationPicker">地图选择</el-button>
|
||||||
|
</div>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item label="工单标题" prop="title">
|
<el-form-item label="工单标题" prop="title">
|
||||||
<el-input v-model="submitForm.title" />
|
<el-input v-model="submitForm.title" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@ -151,6 +159,10 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
|
<!-- 报修位置选择 -->
|
||||||
|
<sb-location-picker v-model="locationPickerVisible" :lng="locationPickerLng" :lat="locationPickerLat"
|
||||||
|
:address="locationPickerAddress" @confirm="onLocationConfirm" />
|
||||||
|
|
||||||
<!-- 验收 -->
|
<!-- 验收 -->
|
||||||
<el-dialog title="工单验收" v-model="verifyDialog.visible" width="520px" append-to-body>
|
<el-dialog title="工单验收" v-model="verifyDialog.visible" width="520px" append-to-body>
|
||||||
<el-form ref="verifyFormRef" :model="verifyForm" label-width="100px">
|
<el-form ref="verifyFormRef" :model="verifyForm" label-width="100px">
|
||||||
@ -203,15 +215,36 @@
|
|||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
<!-- 审批流当前节点审批 -->
|
<!-- 审批流当前节点审批 -->
|
||||||
<el-dialog :title="`工单审批 - ${approveDialog.nodeName || ''}`" v-model="approveDialog.visible"
|
<el-dialog :title="`工单${nodeActionName(approveDialog.nodeType)} - ${approveDialog.nodeName || ''}`"
|
||||||
width="560px" append-to-body>
|
v-model="approveDialog.visible" width="560px" append-to-body>
|
||||||
<el-form label-width="110px">
|
<el-form label-width="110px">
|
||||||
<el-form-item label="工单">{{ approveDialog.title }}</el-form-item>
|
<el-form-item label="工单">{{ approveDialog.title }}</el-form-item>
|
||||||
<el-form-item label="当前节点">
|
<el-form-item label="当前节点">
|
||||||
{{ approveDialog.nodeName }}
|
{{ approveDialog.nodeName }}
|
||||||
<el-tag class="ml-2" size="small" type="warning">{{ approveNodeTypeLabel(approveDialog.nodeType) }}</el-tag>
|
<el-tag class="ml-2" size="small" type="warning">{{ approveNodeTypeLabel(approveDialog.nodeType) }}</el-tag>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<template v-if="approveDialog.nodeType === 'SUPERVISE'">
|
<template v-if="['SUPERVISE', 'VERIFY'].includes(approveDialog.nodeType)">
|
||||||
|
<el-divider content-position="left">完工提交信息</el-divider>
|
||||||
|
<el-form-item label="处理人">{{ approveDialog.handlerName || '-' }}</el-form-item>
|
||||||
|
<el-form-item label="完工时间">{{ proxy?.parseTime(approveDialog.finishTime) || '-' }}</el-form-item>
|
||||||
|
<el-form-item label="处理说明">
|
||||||
|
<span style="white-space: pre-wrap">{{ approveDialog.processDesc || '-' }}</span>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="完工照片">
|
||||||
|
<div v-if="approveDialog.finishImageUrls.length" style="display: flex; gap: 8px; flex-wrap: wrap">
|
||||||
|
<el-image v-for="(url, i) in approveDialog.finishImageUrls" :key="i" :src="url"
|
||||||
|
:preview-src-list="approveDialog.finishImageUrls" :initial-index="i" preview-teleported
|
||||||
|
fit="cover" style="width: 72px; height: 72px; border-radius: 4px" />
|
||||||
|
</div>
|
||||||
|
<span v-else>-</span>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="合同单价">
|
||||||
|
{{ approveDialog.priceItem || '-' }}
|
||||||
|
<span v-if="approveDialog.unitPrice" class="cost-tip">
|
||||||
|
({{ formatMoney(approveDialog.unitPrice) }} × {{ approveDialog.workQty || 0 }})
|
||||||
|
</span>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="完工工作量">{{ approveDialog.workQty || 0 }}</el-form-item>
|
||||||
<el-form-item label="完工费用">
|
<el-form-item label="完工费用">
|
||||||
<span class="cost-strong">{{ formatMoney(approveDialog.amount) }}</span>
|
<span class="cost-strong">{{ formatMoney(approveDialog.amount) }}</span>
|
||||||
<span v-if="approveDialog.autoAmount !== approveDialog.amount" class="cost-tip">
|
<span v-if="approveDialog.autoAmount !== approveDialog.amount" class="cost-tip">
|
||||||
@ -222,19 +255,21 @@
|
|||||||
<span class="cost-tip">{{ approveDialog.adjustReason }}</span>
|
<span class="cost-tip">{{ approveDialog.adjustReason }}</span>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</template>
|
</template>
|
||||||
<el-form-item label="审批结论">
|
<el-form-item :label="nodeActionName(approveDialog.nodeType) + '结论'">
|
||||||
<el-radio-group v-model="approveForm.approveResult">
|
<el-radio-group v-model="approveForm.approveResult">
|
||||||
<el-radio :value="1">通过</el-radio>
|
<el-radio :value="1">通过</el-radio>
|
||||||
<el-radio :value="0">驳回</el-radio>
|
<el-radio :value="0">驳回</el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="审批意见">
|
<el-form-item :label="nodeActionName(approveDialog.nodeType) + '意见'">
|
||||||
<el-input v-model="approveForm.approveOpinion" type="textarea" :rows="3"
|
<el-input v-model="approveForm.approveOpinion" type="textarea" :rows="3"
|
||||||
placeholder="驳回时必须填写审批意见" />
|
:placeholder="'驳回时必须填写' + nodeActionName(approveDialog.nodeType) + '意见'" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<el-button type="primary" :loading="approveSubmitting" @click="doApprove">提交审批</el-button>
|
<el-button type="primary" :loading="approveSubmitting" @click="doApprove">
|
||||||
|
提交{{ nodeActionName(approveDialog.nodeType) }}
|
||||||
|
</el-button>
|
||||||
<el-button @click="approveDialog.visible = false">取 消</el-button>
|
<el-button @click="approveDialog.visible = false">取 消</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
@ -326,6 +361,12 @@
|
|||||||
<el-tag v-if="detail.timeoutFlag === 1" type="danger" size="small" class="ml-1">超时</el-tag>
|
<el-tag v-if="detail.timeoutFlag === 1" type="danger" size="small" class="ml-1">超时</el-tag>
|
||||||
</el-descriptions-item>
|
</el-descriptions-item>
|
||||||
<el-descriptions-item label="关联设备" :span="2">{{ detail.deviceName || '-' }}</el-descriptions-item>
|
<el-descriptions-item label="关联设备" :span="2">{{ detail.deviceName || '-' }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="报修位置" :span="2">
|
||||||
|
{{ detail.reportAddress || '-' }}
|
||||||
|
<span v-if="detail.reportLng && detail.reportLat" class="cost-tip">
|
||||||
|
({{ Number(detail.reportLng).toFixed(6) }}, {{ Number(detail.reportLat).toFixed(6) }})
|
||||||
|
</span>
|
||||||
|
</el-descriptions-item>
|
||||||
<el-descriptions-item label="发起人">{{ detail.reportName }}</el-descriptions-item>
|
<el-descriptions-item label="发起人">{{ detail.reportName }}</el-descriptions-item>
|
||||||
<el-descriptions-item label="发起时间">{{ proxy?.parseTime(detail.reportTime) }}</el-descriptions-item>
|
<el-descriptions-item label="发起时间">{{ proxy?.parseTime(detail.reportTime) }}</el-descriptions-item>
|
||||||
<el-descriptions-item label="处理时限">{{ proxy?.parseTime(detail.deadline) }}</el-descriptions-item>
|
<el-descriptions-item label="处理时限">{{ proxy?.parseTime(detail.deadline) }}</el-descriptions-item>
|
||||||
@ -416,7 +457,9 @@ const superviseForm = reactive<{ orderId: any; superviseResult: number; supervis
|
|||||||
orderId: '', superviseResult: 1, superviseOpinion: ''
|
orderId: '', superviseResult: 1, superviseOpinion: ''
|
||||||
});
|
});
|
||||||
const approveDialog = reactive({
|
const approveDialog = reactive({
|
||||||
visible: false, title: '', nodeName: '', nodeType: '', amount: 0, autoAmount: 0, adjustReason: ''
|
visible: false, title: '', nodeName: '', nodeType: '', amount: 0, autoAmount: 0, adjustReason: '',
|
||||||
|
handlerName: '', finishTime: '', processDesc: '', priceItem: '', unitPrice: 0, workQty: 0,
|
||||||
|
finishImageUrls: [] as string[]
|
||||||
});
|
});
|
||||||
const approveForm = reactive<{ orderId: any; approveResult: number; approveOpinion: string }>({
|
const approveForm = reactive<{ orderId: any; approveResult: number; approveOpinion: string }>({
|
||||||
orderId: '', approveResult: 1, approveOpinion: ''
|
orderId: '', approveResult: 1, approveOpinion: ''
|
||||||
@ -428,6 +471,10 @@ const dispatchHandlerOptions = ref<any[]>([]);
|
|||||||
const dispatchSubmitting = ref(false);
|
const dispatchSubmitting = ref(false);
|
||||||
|
|
||||||
let submitForm = ref<WorkOrderForm>({ orderType: 'bx', title: '' });
|
let submitForm = ref<WorkOrderForm>({ orderType: 'bx', title: '' });
|
||||||
|
const locationPickerVisible = ref(false);
|
||||||
|
const locationPickerLng = ref<number>();
|
||||||
|
const locationPickerLat = ref<number>();
|
||||||
|
const locationPickerAddress = ref('');
|
||||||
const verifyForm = reactive<{ orderId: any; verifyResult: number; verifyOpinion: string }>({ orderId: '', verifyResult: 1, verifyOpinion: '' });
|
const verifyForm = reactive<{ orderId: any; verifyResult: number; verifyOpinion: string }>({ orderId: '', verifyResult: 1, verifyOpinion: '' });
|
||||||
const handleDialog = reactive({ visible: false, title: '', status: '', orderType: '', finishOnly: false });
|
const handleDialog = reactive({ visible: false, title: '', status: '', orderType: '', finishOnly: false });
|
||||||
const handleForm = reactive<{
|
const handleForm = reactive<{
|
||||||
@ -457,6 +504,7 @@ const records = ref<OrderRecordVO[]>([]);
|
|||||||
|
|
||||||
const submitRules = {
|
const submitRules = {
|
||||||
orderType: [{ required: true, message: '请选择工单类型', trigger: 'change' }],
|
orderType: [{ required: true, message: '请选择工单类型', trigger: 'change' }],
|
||||||
|
reportAddress: [{ required: true, message: '请选择报修位置', trigger: 'change' }],
|
||||||
title: [{ required: true, message: '工单标题不能为空', trigger: 'blur' }]
|
title: [{ required: true, message: '工单标题不能为空', trigger: 'blur' }]
|
||||||
};
|
};
|
||||||
const actionLabel = (action: string) => {
|
const actionLabel = (action: string) => {
|
||||||
@ -495,6 +543,7 @@ const resetQuery = () => {
|
|||||||
// ---------------- 发起 / 修改 ----------------
|
// ---------------- 发起 / 修改 ----------------
|
||||||
const openSubmit = () => {
|
const openSubmit = () => {
|
||||||
submitForm.value = { orderType: 'bx', title: '' };
|
submitForm.value = { orderType: 'bx', title: '' };
|
||||||
|
submitTypeId.value = '';
|
||||||
submitDialog.editMode = false;
|
submitDialog.editMode = false;
|
||||||
submitDialog.visible = true;
|
submitDialog.visible = true;
|
||||||
// 预加载设备候选(打开即可直接下拉选择,无需先输入关键字)
|
// 预加载设备候选(打开即可直接下拉选择,无需先输入关键字)
|
||||||
@ -510,11 +559,59 @@ const openEdit = async (row: WorkOrderVO) => {
|
|||||||
title: row.title,
|
title: row.title,
|
||||||
description: row.description,
|
description: row.description,
|
||||||
images: row.images,
|
images: row.images,
|
||||||
deadline: row.deadline
|
deadline: row.deadline,
|
||||||
|
reportLng: row.reportLng,
|
||||||
|
reportLat: row.reportLat,
|
||||||
|
reportAddress: row.reportAddress
|
||||||
} as WorkOrderForm;
|
} as WorkOrderForm;
|
||||||
submitDialog.editMode = true;
|
submitDialog.editMode = true;
|
||||||
submitDialog.visible = true;
|
submitDialog.visible = true;
|
||||||
await loadDeviceOptions();
|
submitTypeId.value = '';
|
||||||
|
// 按设备名搜索候选项,避免原设备不在默认 20 条里导致下拉框显示为空
|
||||||
|
await loadDeviceOptions(row.deviceName || undefined);
|
||||||
|
// 历史工单没有报修位置时,用关联设备的安装位置补齐
|
||||||
|
const currentDevice = deviceOptions.value.find((d) => String(d.id) === String(submitForm.value.deviceId));
|
||||||
|
if (currentDevice) {
|
||||||
|
if (!submitForm.value.reportAddress && currentDevice.installLocation) {
|
||||||
|
submitForm.value.reportAddress = currentDevice.installLocation;
|
||||||
|
}
|
||||||
|
if (submitForm.value.reportLng == null && submitForm.value.reportLat == null
|
||||||
|
&& currentDevice.lng != null && currentDevice.lat != null) {
|
||||||
|
submitForm.value.reportLng = Number(currentDevice.lng);
|
||||||
|
submitForm.value.reportLat = Number(currentDevice.lat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 选择设备后自动带出设备安装位置;清空设备时清空位置 */
|
||||||
|
const onSubmitDeviceChange = () => {
|
||||||
|
const device = deviceOptions.value.find((item) => String(item.id) === String(submitForm.value.deviceId));
|
||||||
|
if (!device) {
|
||||||
|
submitForm.value.reportLng = undefined;
|
||||||
|
submitForm.value.reportLat = undefined;
|
||||||
|
submitForm.value.reportAddress = '';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (device.lng != null && device.lat != null) {
|
||||||
|
submitForm.value.reportLng = Number(device.lng);
|
||||||
|
submitForm.value.reportLat = Number(device.lat);
|
||||||
|
}
|
||||||
|
if (device.installLocation) {
|
||||||
|
submitForm.value.reportAddress = device.installLocation;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const openLocationPicker = () => {
|
||||||
|
locationPickerLng.value = submitForm.value.reportLng;
|
||||||
|
locationPickerLat.value = submitForm.value.reportLat;
|
||||||
|
locationPickerAddress.value = submitForm.value.reportAddress || '';
|
||||||
|
locationPickerVisible.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
const onLocationConfirm = (value: { lng?: number; lat?: number; address: string }) => {
|
||||||
|
submitForm.value.reportLng = value.lng;
|
||||||
|
submitForm.value.reportLat = value.lat;
|
||||||
|
submitForm.value.reportAddress = value.address;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 加载设备候选:有关键字按名称模糊搜,无关键字取前 20 台 */
|
/** 加载设备候选:有关键字按名称模糊搜,无关键字取前 20 台 */
|
||||||
@ -528,6 +625,9 @@ const submitTypeId = ref<string | number>('');
|
|||||||
const typeOptions = ref<any[]>([]);
|
const typeOptions = ref<any[]>([]);
|
||||||
const onSubmitTypeChange = async () => {
|
const onSubmitTypeChange = async () => {
|
||||||
submitForm.value.deviceId = '';
|
submitForm.value.deviceId = '';
|
||||||
|
submitForm.value.reportLng = undefined;
|
||||||
|
submitForm.value.reportLat = undefined;
|
||||||
|
submitForm.value.reportAddress = '';
|
||||||
await loadDeviceOptions();
|
await loadDeviceOptions();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -603,11 +703,14 @@ const doSupervise = async () => {
|
|||||||
|
|
||||||
const approveNodeTypeLabel = (type: string) =>
|
const approveNodeTypeLabel = (type: string) =>
|
||||||
({ SUPERVISE: '监理确认', VERIFY: '验收', APPROVAL: '审批' }[type] || '审批');
|
({ SUPERVISE: '监理确认', VERIFY: '验收', APPROVAL: '审批' }[type] || '审批');
|
||||||
|
/** 当前节点按钮/弹窗动作名称 */
|
||||||
|
const nodeActionName = (type?: string) =>
|
||||||
|
(type === 'VERIFY' ? '验收' : type === 'SUPERVISE' ? '监理确认' : '审批');
|
||||||
/** 当前节点用“待办动作”展示,避免“运维单位完成”被误读为已经完成 */
|
/** 当前节点用“待办动作”展示,避免“运维单位完成”被误读为已经完成 */
|
||||||
const currentNodePhaseLabel = (type?: string) =>
|
const currentNodePhaseLabel = (type?: string) =>
|
||||||
({ APPROVAL: '待审批', ACCEPT: '待接单', DISPATCH: '待派单', FINISH: '待完工', VERIFY: '待验收', SUPERVISE: '待监理确认' }[type || ''] || '');
|
({ APPROVAL: '待审批', ACCEPT: '待接单', DISPATCH: '待派单', FINISH: '待完工', VERIFY: '待验收', SUPERVISE: '待监理确认' }[type || ''] || '');
|
||||||
|
|
||||||
const openApprove = (row: WorkOrderVO) => {
|
const openApprove = async (row: WorkOrderVO) => {
|
||||||
approveForm.orderId = row.id;
|
approveForm.orderId = row.id;
|
||||||
approveForm.approveResult = 1;
|
approveForm.approveResult = 1;
|
||||||
approveForm.approveOpinion = '';
|
approveForm.approveOpinion = '';
|
||||||
@ -617,6 +720,26 @@ const openApprove = (row: WorkOrderVO) => {
|
|||||||
approveDialog.amount = Number(row.amount ?? 0);
|
approveDialog.amount = Number(row.amount ?? 0);
|
||||||
approveDialog.autoAmount = Number(row.calcAmount ?? 0);
|
approveDialog.autoAmount = Number(row.calcAmount ?? 0);
|
||||||
approveDialog.adjustReason = row.amountAdjustReason || '';
|
approveDialog.adjustReason = row.amountAdjustReason || '';
|
||||||
|
approveDialog.handlerName = row.handlerName || '';
|
||||||
|
approveDialog.finishTime = row.finishTime || '';
|
||||||
|
approveDialog.processDesc = row.processDesc || '';
|
||||||
|
approveDialog.priceItem = row.priceItem || '';
|
||||||
|
approveDialog.unitPrice = Number(row.unitPrice ?? 0);
|
||||||
|
approveDialog.workQty = Number(row.workQty ?? 0);
|
||||||
|
approveDialog.finishImageUrls = [];
|
||||||
|
if (row.finishImages) {
|
||||||
|
const ids = row.finishImages.split(',').filter(Boolean);
|
||||||
|
try {
|
||||||
|
if (ids.length) {
|
||||||
|
const res = await listBusinessOss(ids.join(','));
|
||||||
|
const urlMap: Record<string, string> = {};
|
||||||
|
(res.data ?? []).forEach((o: any) => (urlMap[o.ossId] = o.url));
|
||||||
|
approveDialog.finishImageUrls = ids.map((id) => urlMap[id]).filter(Boolean);
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// 图片地址换算失败不影响验收操作
|
||||||
|
}
|
||||||
|
}
|
||||||
approveDialog.visible = true;
|
approveDialog.visible = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -879,4 +1002,13 @@ onActivated(() => {
|
|||||||
gap: 6px;
|
gap: 6px;
|
||||||
margin-top: 8px;
|
margin-top: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.location-field {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
|
||||||
|
:deep(.el-input) {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user