123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251 |
- <template>
- <div class="layout-pd">
- <el-row>
- <!--操作-->
- <el-col :xs="24" >
- <el-card class="mt8" shadow="hover" >
- <el-form :model="state.filter" :inline="true" @submit.stop.prevent style="margin-bottom:-20px;">
- <el-form-item prop="name" style="width: 100%">
- <el-col :xs="24" :sm="12" :md="8" :lg="8" :xl="6" class="mb20">
- <el-form-item label="推送用户">
- <el-input v-model="state.filter.pushUser" placeholder="请输入推送用户" clearable></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :md="8" :lg="8" :xl="6" class="mb20">
- <el-form-item label="是否推送">
- <el-select v-model="state.filter.ispushed" placeholder="请选择推送状态">
- <el-option label="所有" :value="undefined"></el-option>
- <el-option v-for="(value, key) in FuelDispenserEnum" :key="key" :label="value" :value="key" />
- </el-select>
- <!-- <el-input v-model="state.filter.isPushed" placeholder="单行输入" clearable></el-input> -->
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :md="8" :lg="8" :xl="6" class="mb20">
- <el-form-item label="推送时间">
- <el-date-picker
- v-model="state.filter.pushTime"
- type="datetimerange"
- value-format="YYYY-MM-DD HH:mm:ss"
- range-separator="To"
- start-placeholder="开始日期"
- end-placeholder="结束日期"
- />
- </el-form-item>
- </el-col>
- </el-form-item>
- </el-form>
- <hr>
- <el-row justify="space-between" class="submit-button" style="margin-bottom:-6px;">
- <el-row>
- <el-button type="primary" icon="ele-Search" @click="onQuery"> 查询 </el-button>
- <el-button type="primary" icon="ele-RefreshRight" @click="onReset"> 重置 </el-button>
- <el-button v-auth="'api:admin:file:upload-file'" type="primary" icon="ele-Upload"> 立即推送
- </el-button>
- </el-row>
- </el-row>
- </el-card>
- </el-col>
- <!--表格-->
- <el-col :xs="24" >
- <el-card style="height: 70vh" class="my-fill mt8" shadow="hover">
- <el-table v-loading="state.loading" stripe :data="state.tableModel" row-key="id" style="width: 100%">
- <el-table-column type="selection" width="55" fixed="left"></el-table-column>
- <el-table-column v-for="column in state.dynamicColumns" :key="column.prop" :prop="column.prop" :label="column.label" >
- </el-table-column>
- <!-- <el-table-column label="操作" fixed="right" header-align="center" align="center" class="right-operation" width="140">
- <template #default="{ row }" >
- <el-link v-if="row.isPushed === '未推送'"
- class="my-el-link mr12 ml12"
- type="primary"
- icon="ele-Upload"
- @click="onDateUpdate(row)"
- :underline="false"
- target="_blank"
- >立即推送</el-link>
- </template>
- </el-table-column> -->
- </el-table>
- <div class="my-flex my-flex-end" style="margin-top: 20px">
- <el-pagination v-model:currentPage="state.pageInput.currentPage"
- v-model:page-size="state.pageInput.pageSize" :total="state.total" :page-sizes="[10, 15, 20, 50, 100]"
- small background @size-change="onSizeChange" @current-change="onCurrentChange"
- layout="total, sizes, prev, pager, next, jumper" />
- </div>
- </el-card>
- </el-col>
- </el-row>
- </div>
- </template>
- <script setup lang="ts">
- import {onBeforeMount, onMounted, reactive, ref, watch} from "vue";
- import eventBus from "/@/utils/mitt";
- import {Api} from "/@/api/admin/AlarmService/alarmQueryApi";
- import { PushDto } from "/@/api/admin/AlarmService/alarmQueryDto";
- import { PageInputAlarmFilterModel } from "/@/api/admin/reportManagement/alarm/alarmDto";
- import { useDynamicPageSize } from "/@/composables/useDynamicPageSize";
- import { ElMessage } from "element-plus";
- import { all } from "axios";
- // 使用组合式函数获取分页状态
- // const pageState = useDynamicPageSize(10, 15);
- /**数据对象*/
- const state = reactive({
- /**加载显示 */
- loading: false,
- /**条件查询模块 */
- filter: {
- /**推送用户 */
- pushUser: "",
- /**是否推送 */
- pushed: "",
- /**推送时间 */
- pushTime: "",
- ispushed:undefined
- },
- /**表格信息 */
- tableModel: [] as PushDto[],
- /**动态表头 */
- dynamicColumns: [
- { prop: 'ruleName', label: '规则名称' },
- // { prop: 'pushUserid', label: '推送用户id' },
- { prop: 'pushUser', label: '推送用户' },
- { prop: 'content', label: '推送内容' },
- { prop: 'pushed', label: '是否推送' },
- { prop: 'pushTime', label: '推送时间' },
- // { prop: 'alarmhistoryID', label: '报警ID' },
- // { prop: 'taskPriority', label: '优先级' },
- ],
- /**分页标识 */
- pageInput: {
- currentPage: 1,
- pageSize: 15,
- } as PageInputAlarmFilterModel,
- /**分页总数 */
- total: 0,
- })
- /**设备状态*/
- enum FuelDispenserEnum {
- true = "已推送",
- false = "未推送",
- }
- onMounted(async () => {
- await onQuery()
- init()
- eventBus.off('refreshView')
- eventBus.on('refreshView', async () => {
- await init()
- })
- console.log()
- })
- onBeforeMount(() => {
- eventBus.off('refreshView')
- })
- /**
- * 页条变化
- * @param val
- */
- const onSizeChange = (val: number) => {
- state.pageInput.pageSize = val
- init()
- }
- /**
- * 页数 变化
- * @param val
- */
- const onCurrentChange = (val: number) => {
- state.pageInput.currentPage = val
- init()
- }
- /**
- * 监听变换
- */
- watch(() => {})
- /**条件查询 */
- const onQuery = () => {
- init()
- }
- /**初始化 */
- const init = async () => {
- state.loading = true;
- try {
- // 处理时间范围
- let sdate = '';
- let edate = '';
- if (state.filter.pushTime && Array.isArray(state.filter.pushTime) && state.filter.pushTime.length === 2) {
- sdate = state.filter.pushTime[0]; // 开始时间
- edate = state.filter.pushTime[1]; // 结束时间
- }
- const params = {
- ...state.pageInput,
- filter: {
- ...state.filter,
- sdate,
- edate,
- pushTime: undefined, // 避免传到后端去
- },
- };
- const res = await new Api().getList(params);
- state.tableModel = res?.data?.list ?? [];
- state.total = res?.data?.total ?? 0;
- } catch (error) {
- console.error('获取数据失败:', error);
- ElMessage.error('获取数据失败,请重试');
- } finally {
- state.loading = false;
- }
- };
- /**重置 */
- const onReset=()=>{
- // 重置查询条件
- state.filter = {
- pushUser: "",
- pushed: "",
- pushTime: "",
- ispushed:undefined
- };
- // 重新加载数据
- init();
- }
- /**编辑 */
- const onDateUpdate=(row: any)=>{
- console.log("编辑行数据:", row);
- }
- </script>
- <style scoped lang="scss">
- .el-input,
- .el-select {
- width: 240px;
- }
- /* 输入框标签固定四个字符宽度 */
- ::v-deep .el-form-item__label {
- // 字体大小14,4个字符,12px右间距
- width: 14*4px+12px;
- justify-content: start;
- }
- /* 数据表头 设置灰色样式 */
- ::v-deep .el-table th.el-table__cell {
- background-color: #F6F6F6;
- }
- </style>
|