修改现场反馈问题

This commit is contained in:
guanj
2026-06-30 08:36:33 +08:00
parent 5c766684f9
commit 37eef06a3b
4 changed files with 203 additions and 89 deletions

1
components.d.ts vendored
View File

@@ -35,7 +35,6 @@ declare module '@vue/runtime-core' {
ElOption: typeof import('element-plus/es')['ElOption'] ElOption: typeof import('element-plus/es')['ElOption']
ElPagination: typeof import('element-plus/es')['ElPagination'] ElPagination: typeof import('element-plus/es')['ElPagination']
ElPopover: typeof import('element-plus/es')['ElPopover'] ElPopover: typeof import('element-plus/es')['ElPopover']
ElRadio: typeof import('element-plus/es')['ElRadio']
ElRadioButton: typeof import('element-plus/es')['ElRadioButton'] ElRadioButton: typeof import('element-plus/es')['ElRadioButton']
ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup'] ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
ElRow: typeof import('element-plus/es')['ElRow'] ElRow: typeof import('element-plus/es')['ElRow']

View File

@@ -215,7 +215,8 @@ export function eventPage(data: object) {
// 获取短信模版 // 获取短信模版
export function messageGenerate(data: object) { export function messageGenerate(data: object) {
return service({ return service({
url: "/accept/messageGenerate", // url: "/accept/messageGenerate",
url: "/accept/messageGenerateByIds",
method: "post", method: "post",
params: data, params: data,
}); });

View File

@@ -61,6 +61,7 @@ interface Props {
theCurrentTime?: boolean; theCurrentTime?: boolean;
setWatch?: boolean; setWatch?: boolean;
showTime?: boolean; showTime?: boolean;
defaultInterval?: number;
} }
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
@@ -68,6 +69,7 @@ const props = withDefaults(defineProps<Props>(), {
theCurrentTime: true, theCurrentTime: true,
setWatch: true, setWatch: true,
showTime: false, showTime: false,
defaultInterval: 3,
}); });
const START_TIME_SUFFIX = " 00:00:00"; const START_TIME_SUFFIX = " 00:00:00";
@@ -92,7 +94,7 @@ const setRangeValue = (start: string, end: string) => {
timeValue.value = formatRangeValue(start, end); timeValue.value = formatRangeValue(start, end);
}; };
const interval = ref(3); const interval = ref(props.defaultInterval);
const timeFlag = ref(1); const timeFlag = ref(1);
const count = ref(0); const count = ref(0);
const disabledPicker = ref(true); const disabledPicker = ref(true);
@@ -139,7 +141,8 @@ const isFutureDate = (time: any) => {
return time && time > Date.now(); return time && time > Date.now();
}; };
onMounted(() => { onMounted(() => {
timeChange(3); interval.value = props.defaultInterval;
timeChange(props.defaultInterval);
}); });
// 选择时间范围 // 选择时间范围
const timeChange = (e: number) => { const timeChange = (e: number) => {
@@ -565,6 +568,16 @@ const setTheDate = (value: any) => {
timeChange(value); timeChange(value);
}; };
const applyCustomRange = (start: string, end: string) => {
interval.value = 5;
disabledPicker.value = false;
backDisabled.value = true;
preDisabled.value = props.nextFlag ? false : true;
count.value = 0;
timeFlag.value = 1;
setRangeValue(start, end);
};
// 获取时间范围的同比 // 获取时间范围的同比
function getYearOnYear(startDate: string, endDate: string): [string, string] { function getYearOnYear(startDate: string, endDate: string): [string, string] {
const startYearAgo = new Date(startDate); const startYearAgo = new Date(startDate);
@@ -612,6 +625,7 @@ defineExpose({
timeFlag, timeFlag,
setTimeOptions, setTimeOptions,
setTheDate, setTheDate,
applyCustomRange,
getYearOnYear, getYearOnYear,
getMonthOnMonth, getMonthOnMonth,
timeChange, timeChange,

View File

@@ -1,9 +1,9 @@
<template> <template>
<el-dialog :close-on-click-modal="false" draggable v-model="machineVisible" :title="title" width="1200px" <el-dialog :close-on-click-modal="false" draggable v-model="machineVisible" :title="title" width="1300px"
:before-close="handleClose"> :before-close="handleClose" @opened="handleDialogOpened">
<el-form inline="true" class="formLeft"> <el-form inline="true" class="formLeft">
<el-form-item> <el-form-item>
<datePicker :setWatch="false" :showTime="true" ref="datePickerRef" style="width: 560px" /> <datePicker :setWatch="false" :showTime="true" ref="datePickerRef" :defaultInterval="5" style="width: 560px" />
</el-form-item> </el-form-item>
<el-form-item label="关键字筛选" style="margin-right: 10px"> <el-form-item label="关键字筛选" style="margin-right: 10px">
@@ -35,6 +35,13 @@
:key="item.value"></el-option> :key="item.value"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="过滤敏感用户">
<el-select clearable size="small" :teleported="false" v-model="eventForm.fiterSensitiveUser"
placeholder="请选择过滤敏感用户" style="width: 150px">
<el-option label="是" value="1"></el-option>
<el-option label="否" value="0"></el-option>
</el-select>
</el-form-item>
<el-form-item label="残余电压百分比"> <el-form-item label="残余电压百分比">
<el-input-number v-model="eventForm.eventValueMin" :min="0" style="width: 150px" <el-input-number v-model="eventForm.eventValueMin" :min="0" style="width: 150px"
size="small" :max="100" :precision="1" :step="1" size="small" :max="100" :precision="1" :step="1"
@@ -71,20 +78,19 @@
<el-form-item style="margin-right: 0;"> <el-form-item style="margin-right: 0;">
<el-button size="small" :icon="Search" type="primary" @click="inquire(true)">查询</el-button> <el-button size="small" :icon="Search" type="primary" @click="inquire(true)">查询</el-button>
<el-button size="small" type="warn" :icon="RefreshLeft" @click="clearInit()">重置</el-button> <el-button size="small" type="warn" :icon="RefreshLeft" @click="clearInit()">重置</el-button>
<el-button size="small" type="primary" :icon="Comment" @click="getMessage"
:loading="templateLoading">生成短信</el-button>
<el-button type="primary" :icon="Download" @click="exportTable" size="small" :loading="exportLoading">导出 <el-button type="primary" :icon="Download" @click="exportTable" size="small" :loading="exportLoading">导出
</el-button> </el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<div class="tableBox" v-loading="loading" element-loading-background="#343849c7"> <div class="tableBox" v-loading="loading" element-loading-background="#343849c7">
<el-table :scrollbar-always-on="true" :data="tableData" height="300px" size="small" stripe <el-table ref="tableRef" :scrollbar-always-on="true" :data="tableData" height="280px" size="small" stripe
highlight-current-row :header-cell-style="{ textAlign: 'center' }" border @row-click="handleRowClick"> row-key="eventdetail_index" highlight-current-row :header-cell-style="{ textAlign: 'center' }" border
<el-table-column align="center" width="50"> @row-click="handleRowClick" @selection-change="handleSelectionChange">
<template #default="scope"> <el-table-column type="selection" align="center" :selectable="selectable" reserve-selection
<el-radio v-model="selectedRowId" :label="scope.row.eventdetail_index" width="55" />
@change="handleRowSelect(scope.row)" @click.stop>&nbsp;</el-radio>
</template>
</el-table-column>
<el-table-column label="序号" align="center" width="60"> <el-table-column label="序号" align="center" width="60">
<template #default="scope"> <template #default="scope">
{{ (pageNum - 1) * pageSize + scope.$index + 1 }} {{ (pageNum - 1) * pageSize + scope.$index + 1 }}
@@ -130,20 +136,29 @@
@current-change="onTableCurrentChange"></el-pagination> @current-change="onTableCurrentChange"></el-pagination>
</div> </div>
<el-divider /> <el-divider />
<div class="sendBox" style="min-height: 37px;"> <div class="sendBox">
<div>发送用户</div> <div style="min-height: 37px;">
<div style="flex: 1;"> <div class="mb10">发送用户</div>
<el-tag v-for="(item, index) in messageList.pqsUsers" :key="index" class="mr5 mb10"> <div class="userGroups">
{{ item.name }} <div v-for="group in pqsUserGroups" :key="group.deptName" class="userGroup">
</el-tag> <span class="deptName">{{ group.deptName }}</span>
<el-checkbox-group v-model="selectedUserIds">
<el-checkbox v-for="user in group.users" class="mb7" :key="user.userIndex" :label="user.userIndex"
border size="small">
{{ user.name }}
</el-checkbox>
</el-checkbox-group>
</div>
</div>
</div>
<div>
<div class="mb10">短信模板 </div>
<el-input v-model="messageList.message" style="flex: 1;" :rows="5" type="textarea"
:value="messageList && messageList.message" />
</div> </div>
</div> </div>
<div class="sendBox"> <div class=" mt10" style="display: flex;justify-content: flex-end;">
<div>短信模板 </div>
<el-input v-model="messageList.message" style="flex: 1;" :rows="2" type="textarea"
:value="messageList && messageList.message" />
</div>
<div class="sendBox mt10" style="justify-content: flex-end;">
<el-button size="small" :icon="Message" type="primary" @click="sendMessage" <el-button size="small" :icon="Message" type="primary" @click="sendMessage"
:loading="sendLoading">发送</el-button> :loading="sendLoading">发送</el-button>
</div> </div>
@@ -163,7 +178,7 @@ import {
DArrowRight, DArrowRight,
Search, Search,
RefreshLeft, RefreshLeft,
Download, Message Download, Message, Comment
} from "@element-plus/icons-vue"; } from "@element-plus/icons-vue";
import * as XLSX from "xlsx"; import * as XLSX from "xlsx";
import waveForm from "@/components/BX/waveForm.vue"; import waveForm from "@/components/BX/waveForm.vue";
@@ -175,7 +190,7 @@ const machineVisible = ref(false);
const title = ref("暂降事件列表"); const title = ref("暂降事件列表");
const datePickerRef = ref(); const datePickerRef = ref();
const pageNum = ref(1); const pageNum = ref(1);
const pageSize = ref(20); const pageSize = ref(100);
const loading = ref(false); const loading = ref(false);
const exportLoading = ref(false); const exportLoading = ref(false);
const total = ref(0); const total = ref(0);
@@ -185,21 +200,29 @@ const deptsIndex = ref(null);
const deptsList = ref([]); const deptsList = ref([]);
const trendVisible = ref(false); const trendVisible = ref(false);
const waveFormRef = ref(); const waveFormRef = ref();
const selectedRowId = ref(""); const tableRef = ref();
const pqsUsers = ref([]); const selectedRowIds = ref<string[]>([]);
const selectedRow = ref<any>(null); const selectedRows = ref<any[]>([]);
const textarea = ref(""); const templateLoading = ref(false);
const messageList = ref({ const isAutoSelecting = ref(false);
const messageList = ref<{
message: string;
eventId: string;
pqsUsers: Record<string, any[]>;
}>({
message: "", message: "",
eventId: "", eventId: "",
pqsUsers: [] pqsUsers: {},
}); });
const selectedUserIds = ref<string[]>([]);
const selectable = (row: any) => !!row.eventdetail_index;
const eventForm: any = reactive({ const eventForm: any = reactive({
eventValueMin: null, eventValueMin: null,
eventValueMax: null, eventValueMax: null,
eventDurationMin: null, eventDurationMin: null,
eventDurationMax: null, eventDurationMax: null,
eventtype: null, eventtype: null,
fiterSensitiveUser: '1',
}); });
const sendLoading = ref(false); const sendLoading = ref(false);
const typeMap: Record<string, string> = { const typeMap: Record<string, string> = {
@@ -223,19 +246,45 @@ const eventTypeList = computed(() => {
})); }));
}); });
const pqsUserGroups = computed(() => {
const pqsUsers = messageList.value.pqsUsers;
if (!pqsUsers || Array.isArray(pqsUsers)) return [];
return Object.entries(pqsUsers).map(([deptName, users]) => ({
deptName,
users: users || [],
}));
});
const initSelectedUsers = (pqsUsers: Record<string, any[]>) => {
const ids: string[] = [];
Object.values(pqsUsers || {}).forEach((users) => {
users.forEach((user) => {
if (user.userIndex) ids.push(user.userIndex);
});
});
selectedUserIds.value = ids;
};
const getFilteredPqsUsers = () => {
const result: Record<string, any[]> = {};
const pqsUsers = messageList.value.pqsUsers;
if (!pqsUsers || Array.isArray(pqsUsers)) return result;
Object.entries(pqsUsers).forEach(([deptName, users]) => {
const filtered = users.filter((user) => selectedUserIds.value.includes(user.userIndex));
if (filtered.length > 0) {
result[deptName] = filtered;
}
});
return result;
};
const getTimeRange = () => { const getTimeRange = () => {
const picker = datePickerRef.value; const picker = datePickerRef.value;
if (picker?.timeValue?.length === 2) { const timeValue = picker?.timeValue || [];
return {
type: picker.interval ?? store.state.timeType,
startDateTime: picker.timeValue[0],
endTDateime: picker.timeValue[1],
};
}
return { return {
type: store.state.timeType, type: picker?.interval ?? 5,
startDateTime: store.state.timeValue[0], startDateTime: timeValue[0] || "",
endTDateime: store.state.timeValue[1], endTDateime: timeValue[1] || "",
}; };
}; };
@@ -264,37 +313,77 @@ const filteWavetype = (wavetype: string) => {
}; };
const clearSelection = () => { const clearSelection = () => {
selectedRowId.value = ""; selectedRowIds.value = [];
selectedRow.value = null; selectedRows.value = [];
tableRef.value?.clearSelection();
};
const handleSelectionChange = (rows: any[]) => {
if (isAutoSelecting.value) return;
selectedRows.value = rows;
selectedRowIds.value = rows.map((row) => row.eventdetail_index);
}; };
const handleRowClick = (row: any) => { const handleRowClick = (row: any) => {
selectedRowId.value = row.eventdetail_index; if (!selectable(row)) return;
selectedRow.value = row; tableRef.value?.toggleRowSelection(row);
getMessage(row.eventdetail_index);
}; };
const handleRowSelect = (row: any) => { const selectAllAndGenerateMessage = async () => {
selectedRow.value = row; await nextTick();
getMessage(row.eventdetail_index); if (total.value === 0) {
clearSelection();
return;
}
let allRecords = tableData.value;
if (total.value > tableData.value.length) {
const allRes = await eventPage(getQueryParams({ pageNum: 1, pageSize: total.value }));
allRecords = allRes.data.records || [];
}
const selectableRecords = allRecords.filter(selectable);
isAutoSelecting.value = true;
try {
selectedRows.value = selectableRecords;
selectedRowIds.value = selectableRecords.map((row) => row.eventdetail_index);
tableRef.value?.clearSelection();
await nextTick();
tableData.value.forEach((row: any) => {
if (selectedRowIds.value.includes(row.eventdetail_index)) {
tableRef.value?.toggleRowSelection(row, true);
}
});
getMessage(true);
} finally {
isAutoSelecting.value = false;
}
}; };
const getMessage = (eventId: string) => { const getMessage = (silent = false) => {
if (selectedRowIds.value.length === 0) {
messageGenerate({ eventId: eventId }).then((res: any) => { if (!silent) {
ElMessage.warning("请选择暂降事件!");
}
return;
}
templateLoading.value = true;
messageGenerate({ eventIds: selectedRowIds.value.join(',') }).then((res: any) => {
if (res.code == 'A0000') { if (res.code == 'A0000') {
messageList.value = res.data; messageList.value = res.data;
initSelectedUsers(res.data.pqsUsers || {});
} else { } else {
ElMessage.warning(res.message); ElMessage.warning(res.message);
messageList.value = { messageList.value = {
message: "", message: "",
eventId: "", eventId: "",
pqsUsers: [ pqsUsers: {}
};
] selectedUserIds.value = [];
}
} }
}) }).finally(() => {
templateLoading.value = false;
});
}; };
const initDept = () => { const initDept = () => {
const { type, startDateTime, endTDateime } = getTimeRange(); const { type, startDateTime, endTDateime } = getTimeRange();
@@ -308,33 +397,34 @@ const initDept = () => {
}); });
}; };
const syncDatePicker = () => { const handleDialogOpened = () => {
if (!datePickerRef.value) return; if (datePickerRef.value?.interval !== 5) {
datePickerRef.value.interval = store.state.timeType; datePickerRef.value?.setTheDate(5);
datePickerRef.value.setRangeValue( }
store.state.timeValue[0], initDept();
store.state.timeValue[1] inquire(true);
);
}; };
const inquire = (resetPage = false) => { const inquire = (resetPage = false) => {
messageList.value = { messageList.value = {
message: "", message: "",
eventId: "", eventId: "",
pqsUsers: [ pqsUsers: {}
};
] selectedUserIds.value = [];
}
if (resetPage) { if (resetPage) {
pageNum.value = 1; pageNum.value = 1;
pageSize.value = 20; pageSize.value = 100;
clearSelection(); clearSelection();
} }
loading.value = true; loading.value = true;
eventPage(getQueryParams()).then((res) => { eventPage(getQueryParams()).then(async (res) => {
total.value = res.data.total; total.value = res.data.total;
tableData.value = res.data.records; tableData.value = res.data.records;
loading.value = false; loading.value = false;
if (resetPage) {
await selectAllAndGenerateMessage();
}
}); });
}; };
@@ -346,6 +436,7 @@ const clearInit = async () => {
eventForm.eventDurationMin = null; eventForm.eventDurationMin = null;
eventForm.eventDurationMax = null; eventForm.eventDurationMax = null;
eventForm.eventtype = null; eventForm.eventtype = null;
eventForm.fiterSensitiveUser = 1;
deptsIndex.value = null; deptsIndex.value = null;
await inquire(true); await inquire(true);
}; };
@@ -361,17 +452,13 @@ const open = (text: string) => {
title.value = text || "暂降事件列表"; title.value = text || "暂降事件列表";
clearSelection(); clearSelection();
machineVisible.value = true; machineVisible.value = true;
nextTick(() => {
syncDatePicker();
initDept();
inquire(true);
});
}; };
const sendMessage = () => { const sendMessage = () => {
const pqsUsers = messageList.value.pqsUsers; const filteredPqsUsers = getFilteredPqsUsers();
if (pqsUsers.length == 0) { const userCount = Object.values(filteredPqsUsers).reduce((sum, users) => sum + users.length, 0);
ElMessage.warning("发送用户不能为空,请选择有用户的暂降事件!"); if (userCount === 0) {
ElMessage.warning("发送用户不能为空!");
return; return;
} }
if (!messageList.value.message?.trim()) { if (!messageList.value.message?.trim()) {
@@ -382,7 +469,7 @@ const sendMessage = () => {
sendLoading.value = true; sendLoading.value = true;
messageSend({ messageSend({
...messageList.value, ...messageList.value,
pqsUsers: filteredPqsUsers,
}) })
.then((res: any) => { .then((res: any) => {
if (res.code == 'A0000') { if (res.code == 'A0000') {
@@ -447,7 +534,7 @@ const handleClose = () => {
machineVisible.value = false; machineVisible.value = false;
}; };
defineExpose({ open, selectedRow, selectedRowId }); defineExpose({ open, selectedRows, selectedRowIds });
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@@ -465,13 +552,26 @@ defineExpose({ open, selectedRow, selectedRowId });
padding: 0; padding: 0;
} }
:deep(.el-radio__label) { .sendBox {
display: none; display: grid;
grid-template-columns: 2fr 1.3fr;
gap: 10px;
} }
.sendBox { .userGroups {
display: flex; flex: 1;
}
justify-content: space-between; .userGroup {
display: flex;
align-items: flex-start;
margin-bottom: 5px;
line-height: 24px;
}
.deptName {
flex-shrink: 0;
margin-right: 8px;
white-space: nowrap;
} }
</style> </style>