zhouwenxuan
2023-08-31 21d10974b1f1e19162b690c313c6f4014f182963
预警管理
已修改8个文件
已添加3个文件
610 ■■■■ 文件已修改
src/api/basicDataManage/gasManage/index.ts 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/warningManage/warningInfo/index.ts 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/warningManage/warningPeople/index.ts 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/warningManage/warningSet/index.ts 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/types/warning.d.ts 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/warningManage/warningInfo/component/infoDialog.vue 75 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/warningManage/warningInfo/index.vue 134 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/warningManage/warningPeople/component/peopleDialog.vue 124 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/warningManage/warningPeople/index.vue 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/warningManage/warningSet/component/setDialog.vue 46 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/warningManage/warningSet/index.vue 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/basicDataManage/gasManage/index.ts
@@ -12,6 +12,15 @@
            });
        },
        //气体不分页
        getGas: (data: object) => {
            return request({
                url: import.meta.env.VITE_API_URL + `/gasCategory/list`,
                method: 'post',
                data: data
            });
        },
        //气体新增
        addGas: (data: object) => {
            return request({
src/api/warningManage/warningInfo/index.ts
对比新文件
@@ -0,0 +1,25 @@
import request from '/@/utils/request';
export function warningInfoApi() {
    return {
        //预警信息分页
        getWarnLogPage: (data: object) => {
            return request({
                url: import.meta.env.VITE_API_URL + `/gasWarnLog/page`,
                method: 'post',
                data: data
            });
        },
        //预警信息处理
        handleWarnLog: (data: object) => {
            return request({
                url: import.meta.env.VITE_API_URL + `/gasWarnLog/handleById`,
                method: 'post',
                data: data
            });
        },
    };
}
src/api/warningManage/warningPeople/index.ts
对比新文件
@@ -0,0 +1,41 @@
import request from '/@/utils/request';
export function warningPeopleApi() {
    return {
        //预警通知人员分页
        getWarnUserPage: (data: object) => {
            return request({
                url: import.meta.env.VITE_API_URL + `/gasWarnUser/page`,
                method: 'post',
                data: data
            });
        },
        //预警通知人员新增
        addWarnUser: (data: object) => {
            return request({
                url: import.meta.env.VITE_API_URL + `/gasWarnUser/add`,
                method: 'post',
                data: data
            });
        },
        //预警通知人员修改
        handelWarnUser: (data: object) => {
            return request({
                url: import.meta.env.VITE_API_URL + `/gasWarnUser/update`,
                method: 'post',
                data: data
            });
        },
        //预警通知人员删除
        delWarnUser: (data: object) => {
            return request({
                url: import.meta.env.VITE_API_URL + `/gasWarnUser/del`,
                method: 'post',
                data: data
            });
        },
    };
}
src/api/warningManage/warningSet/index.ts
对比新文件
@@ -0,0 +1,24 @@
import request from '/@/utils/request';
export function warningSetApi() {
    return {
        //预警设置查询
        getWarnSetPage: (data: object) => {
            return request({
                url: import.meta.env.VITE_API_URL + `/gasThreshold/list`,
                method: 'post',
                data: data
            });
        },
        //预警设置修改
        handelWarnSet: (data: object) => {
            return request({
                url: import.meta.env.VITE_API_URL + `/gasThreshold/update`,
                method: 'post',
                data: data
            });
        },
    };
}
src/types/warning.d.ts
@@ -1,6 +1,7 @@
interface TableDataRow {
    id: string;
    name: string;
    points: number;
    threshold: number;
}
export interface TableDataState {
    tableData: {
@@ -12,8 +13,9 @@
    isShowUserDialog: boolean;
    disabled: boolean;
    setForm: {
        id: string;
        name: string;
        points: number;
        threshold: number;
    };
    setFormRules:{},
}
@@ -22,6 +24,8 @@
    id: string;
    name: string;
    phone: string;
    realName: string;
    userId: string;
}
export interface PeopleDataState {
    tableData: {
@@ -32,7 +36,7 @@
            pageIndex: number;
            pageSize: number;
            searchParams:{
                name: string
                realName: string
            }
        };
    }
@@ -43,8 +47,10 @@
    isShowUserDialog: boolean;
    disabled: boolean;
    peopleForm: {
        id: string;
        name: string;
        phone: string;
        realName: string;
    };
    setFormRules:{},
    peopleList: Array<TableDataPeople>
@@ -53,15 +59,16 @@
export interface TableDataInfo {
    id: string;
    content: string;
    warningTime: string;
    name: string;
    ppm: string;
    level: string;
    notifier: string;
    managePeople: string;
    manageTime: string;
    warnTime: string;
    gasName: string;
    gasConcentration: string;
    gasThresholdId: string;
    handlerName: string;
    handlerRealName: string;
    handlerTime: string;
    status: string;
    method?: string;
    gasWarnLogSmsUsers: []
}
export interface InfoDataState {
    tableData: {
@@ -72,7 +79,7 @@
            pageIndex: number;
            pageSize: number;
            searchParams:{
                time: [];
                time: string[];
                level: string;
                status: string;
                gas: string;
@@ -87,12 +94,14 @@
export interface people {
    id: string;
    name: string;
    realName: string;
}
export interface InfoState {
    title: string;
    isShowUserDialog: boolean;
    disabled: boolean;
    infoForm: {
        id: string;
        name: string;
        method: string;
    };
src/views/warningManage/warningInfo/component/infoDialog.vue
@@ -15,7 +15,7 @@
                        size="default"
                        :disabled="state.disabled"
                    >
                        <el-option v-for="item in state.peopleList" :key="item.id" :label="item.name" :value="item.id"></el-option>
                        <el-option v-for="item in state.peopleList" :key="item.id" :label="item.realName" :value="item.id"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="处理方式:" prop="points">
@@ -35,6 +35,9 @@
<script setup lang="ts">
import {reactive, ref} from "vue";
import {InfoState} from "/@/types/warning";
import {userApi} from "/@/api/systemManage/user";
import {ElMessage} from "element-plus";
import {warningInfoApi} from "/@/api/warningManage/warningInfo";
const gasRef = ref();
const emit = defineEmits(["getInfoData"]);
@@ -43,42 +46,74 @@
    isShowUserDialog: false,
    disabled: false,
    infoForm: {
        id: '',
        name: '',
        method: ''
    },
    setFormRules:{
        name: [{ required: true, message: '请选择预警人员', trigger: 'blur' }],
    },
    peopleList: [
        // {
        //     id: '1',
        //     name: '张三',
        // },
        // {
        //     id: '2',
        //     name: '李四',
        // }
    ]
    peopleList: []
});
const openDialog = (type: string, value: any) => {
    getUserList();
    state.isShowUserDialog = true;
    if (type === '查看') {
        state.disabled = true;
        state.infoForm = JSON.parse(JSON.stringify(value));
        state.infoForm.name = state.infoForm.managePeople;
        console.log("info",state.infoForm)
        let data = JSON.parse(JSON.stringify(value));
        state.infoForm.id = data.id;
        state.infoForm.name = data.handlerId;
        state.infoForm.method = data.handlerDesc;
    } else if (type === '处理'){
        state.disabled = false;
        state.infoForm = {
            name: '',
            method: ''
        }
        state.infoForm = JSON.parse(JSON.stringify(value));
    }
    state.title = type;
};
const onSubmit = () => {
    gasRef.value.clearValidate();
const getUserList = async () => {
    const param = {
        pageIndex: 1,
        pageSize: 9999,
        searchParams: {
            roleId: null,
            name: "",
            realName: "",
            userIndentityId: null
        }
    }
    let res = await userApi().getUserList(param);
    if(res.data.code == 100) {
        state.peopleList = res.data.data;
    }else {
        ElMessage({
            type: 'error',
            message: res.data.msg
        });
    }
}
const onSubmit = async () => {
    if(state.title == '处理') {
        const param = {
            id: state.infoForm.id,
            userId: state.infoForm.name,
            handlerDesc: state.infoForm.method
        }
        let res = await warningInfoApi().handleWarnLog(param);
        if(res.data.code == 100) {
            ElMessage({
                type: 'success',
                message: '处理成功'
            });
        }else {
            ElMessage({
                type: 'error',
                message: res.data.msg
            });
        }
        gasRef.value.clearValidate();
    }
    state.isShowUserDialog = false;
    emit('getInfoData');
};
src/views/warningManage/warningInfo/index.vue
@@ -40,8 +40,9 @@
                            class="w100"
                            style="max-width: 180px"
                            size="default"
                            filterable
                        >
                            <el-option v-for="item in state.tableData.gasList" :key="item.label" :label="item.value" :value="item.label"></el-option>
                            <el-option v-for="item in state.tableData.gasList" :key="item.id" :label="item.name" :value="item.id"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-button size="default" type="primary" class="ml10" @click="search()">
@@ -60,28 +61,34 @@
            </div>
            <el-table :data="state.tableData.data" style="width: 100%">
                <el-table-column align="center" prop="content" label="预警内容"/>
                <el-table-column align="center" prop="warningTime" label="预警时间"/>
                <el-table-column align="center" prop="name" label="气体名称"/>
                <el-table-column align="center" prop="ppm" label="气体浓度"/>
                <el-table-column align="center" prop="level" label="预警级别" height="100">
                <el-table-column align="center" prop="warnTime" label="预警时间"/>
                <el-table-column align="center" prop="gasName" label="气体名称"/>
                <el-table-column align="center" prop="gasConcentration" label="气体浓度"/>
                <el-table-column align="center" prop="gasThresholdId" label="预警级别" height="100">
                    <template #default="scope">
                        <span class="yellow" v-if="scope.row.level == '1'">黄色预警</span>
                        <span class="red" v-if="scope.row.level == '2'">红色预警</span>
                        <span class="yellow" v-if="scope.row.gasThresholdId == '1'">黄色预警</span>
                        <span class="red" v-else-if="scope.row.gasThresholdId == '2'">红色预警</span>
                    </template>
                </el-table-column>
                <el-table-column align="center" prop="notifier" label="通知人员"/>
                <el-table-column align="center" prop="managePeople" label="处理人"/>
                <el-table-column align="center" prop="manageTime" label="处理时间"/>
                <el-table-column align="center" prop="gasWarnLogSmsUsers" label="通知人员">
                    <template #default="scope">
                        <div v-for="(item, index) in scope.row.gasWarnLogSmsUsers" :key="index">
                            {{item.realname}}
                        </div>
                    </template>
                </el-table-column>
                <el-table-column align="center" prop="handlerRealName" label="处理人"/>
                <el-table-column align="center" prop="handlerTime" label="处理时间"/>
                <el-table-column align="center" prop="status" label="处理状态">
                    <template #default="scope">
                        <span v-if="scope.row.status == '1'">未处理</span>
                        <span v-if="scope.row.status == '2'">已处理</span>
                        <span v-if="scope.row.status == '0'">未处理</span>
                        <span v-if="scope.row.status == '1'">已处理</span>
                    </template>
                </el-table-column>
                <el-table-column label="操作" show-overflow-tooltip width="140">
                    <template #default="scope">
                        <el-button size="small" text type="primary" v-if="scope.row.status == '2'" @click="openDialog('查看', scope.row)">查看</el-button>
                        <el-button size="small" text type="primary" v-if="scope.row.status == '1'" @click="openDialog('处理', scope.row)">处理</el-button>
                        <el-button size="small" text type="primary" v-if="scope.row.status == '1'" @click="openDialog('查看', scope.row)">查看</el-button>
                        <el-button size="small" text type="primary" v-if="scope.row.status == '0'" @click="openDialog('处理', scope.row)">处理</el-button>
                    </template>
                </el-table-column>
            </el-table>
@@ -106,42 +113,17 @@
</template>
<script setup lang="ts">
import {reactive, ref} from "vue";
import {reactive, ref, onMounted} from "vue";
import { ElMessage, ElMessageBox } from 'element-plus'
import {InfoDataState, PeopleDataState} from "/@/types/warning";
import infoDialog from "./component/infoDialog.vue";
import { gasManageApi } from "/@/api/basicDataManage/gasManage";
import {warningInfoApi} from "/@/api/warningManage/warningInfo";
const infoRef = ref();
const state = reactive<InfoDataState>({
    tableData: {
        data: [
            // {
            //     id: '1',
            //     content: '【气体监测预警提示】2023年10月20日8:30 甲烷气体浓度连续超标系统判断为黄色预警,请相关负责人及时检查处置。',
            //     warningTime: '2023年10月20日 8:30',
            //     name: '甲烷',
            //     ppm: '5ppm',
            //     level: '1',
            //     notifier: '老娄、老程',
            //     managePeople: '张三',
            //     manageTime: '2023年10月20日  11:30',
            //     status: '1',
            // },
            // {
            //     id: '1',
            //     content: '【气体监测预警提示】2023年10月20日8:30 甲烷气体浓度连续超标系统判断为黄色预警,请相关负责人及时检查处置。',
            //     warningTime: '2023年10月20日 8:30',
            //     name: '甲烷',
            //     ppm: '5ppm',
            //     level: '2',
            //     notifier: '老娄、老程',
            //     managePeople: '张三',
            //     manageTime: '2023年10月20日  11:30',
            //     status: '2',
            //     method:'xxx'
            // },
        ],
        data: [],
        total: 0,
        loading: false,
        listQuery: {
@@ -166,29 +148,64 @@
        ],
        statusList: [
            {
                label: '1',
                label: '0',
                value: '未处理'
            },
            {
                label: '2',
                label: '1',
                value: '已处理'
            }
        ],
        gasList: [
            {
                label: '1',
                value: '甲醛'
            },
            {
                label: '2',
                value: '甲烷'
            }
        ]
        gasList: []
    }
});
const initInfoData = () => {
    console.log("数据列表")
//页面加载
onMounted(() => {
    getGas();
    initInfoData();
});
//气体列表
const getGas = async () => {
    let res = await gasManageApi().getGas({});
    if(res.data.code == 100){
        state.tableData.gasList = res.data.data;
    }else {
        ElMessage({
            type: 'warning',
            message: res.data.msg
        });
    }
};
//预警信息列表
const initInfoData = async () => {
    const param = {
        pageIndex: state.tableData.listQuery.pageIndex,
        pageSize: state.tableData.listQuery.pageSize,
        searchParams: {
            startTime: state.tableData.listQuery.searchParams.time[0],
            endTime: state.tableData.listQuery.searchParams.time[1],
            gasCategoryId: state.tableData.listQuery.searchParams.gas,
            status: state.tableData.listQuery.searchParams.status,
            gasThresholdId: state.tableData.listQuery.searchParams.level,
        }
    };
    let res = await warningInfoApi().getWarnLogPage(param);
    console.log("res",res)
    if(res.data.code == 100) {
        state.tableData.data = res.data.data;
        state.tableData.total = res.data.total;
        state.tableData.listQuery.pageIndex = res.data.pageIndex;
        state.tableData.listQuery.pageSize = res.data.pageSize;
    }else {
        ElMessage({
            type: 'warning',
            message: res.data.msg
        });
    }
};
const onHandleSizeChange = (val: number) => {
    state.tableData.listQuery.pageSize = val;
@@ -221,9 +238,12 @@
};
const search = () => {
    state.tableData.listQuery.pageIndex = 1;
    initInfoData();
    console.log("vla",state.tableData.listQuery.searchParams)
}
const reset = () => {
    state.tableData.listQuery.pageIndex = 1;
    state.tableData.listQuery.searchParams.time = [];
    state.tableData.listQuery.searchParams.level = '';
    state.tableData.listQuery.searchParams.status = '';
src/views/warningManage/warningPeople/component/peopleDialog.vue
@@ -8,7 +8,7 @@
            <el-form :model="state.peopleForm" size="default" ref="gasRef" :rules="state.setFormRules" label-width="150px">
                <el-form-item label="预警人员:" prop="name">
                    <el-select
                        v-model="state.peopleForm.name"
                        v-model="state.peopleForm.realName"
                        filterable
                        class="w100"
                        style="max-width: 180px"
@@ -16,9 +16,9 @@
                        @change="changePeople"
                        :disabled="state.disabled"
                    >
                        <el-option v-for="item in state.peopleList" :key="item.id" :label="item.name" :value="item.id">
                        <el-option v-for="item in state.peopleList" :key="item.id" :label="item.realName" :value="item.id">
                            <div class="valueTable">
                                <div><div>姓名:</div><span>{{item.name}}</span></div>
                                <div><div>姓名:</div><span>{{item.realName}}</span></div>
                                <div><div>手机号:</div><span>{{item.phone}}</span></div>
                            </div>
                        </el-option>
@@ -41,6 +41,9 @@
<script setup lang="ts">
import {reactive, ref} from "vue";
import {PeopleState} from "/@/types/warning";
import { userApi } from "/@/api/systemManage/user";
import { warningPeopleApi } from "/@/api/warningManage/warningPeople";
import {ElMessage} from "element-plus";
const gasRef = ref();
const emit = defineEmits(["getPeopleData"]);
@@ -49,27 +52,22 @@
    isShowUserDialog: false,
    disabled: false,
    peopleForm: {
        id: '',
        name: '',
        phone: ''
        phone: '',
        realName: ''
    },
    setFormRules:{
        name: [{ required: true, message: '请选择预警人员', trigger: 'blur' }],
        phone: [{ required: true, message: '请输入手机号', trigger: 'blur' }],
    },
    peopleList: [
        // {
        //     id: '1',
        //     name: '张三',
        //     phone: '112554566666'
        // },
        // {
        //     id: '2',
        //     name: '李四',
        //     phone: '11254212321'
        // }
    ]
    peopleList: []
});
let chooseObj = reactive<any>({});
const openDialog = (type: string, value: any) => {
    getUserList();
    state.isShowUserDialog = true;
    if (type === '查看') {
        state.disabled = true;
@@ -79,26 +77,100 @@
        state.disabled = false;
        state.title = '修改预警人员';
        state.peopleForm = JSON.parse(JSON.stringify(value));
        chooseObj = state.peopleForm;
    }else {
        state.disabled = false;
        state.title = '新增预警人员';
        state.peopleForm = {
            id: '',
            name: '',
            phone: ''
            phone: '',
            realName: ''
        }
    }
};
const changePeople = (val:any) => {
    const obj = state.peopleList.find(item => item.id === val);
    if(obj){
        state.peopleForm.phone = obj.phone;
const getUserList = async () => {
    const param = {
        pageIndex: 1,
        pageSize: 9999,
        searchParams: {
            roleId: null,
            name: "",
            realName: "",
            userIndentityId: null
        }
    }
    let res = await userApi().getUserList(param);
    if(res.data.code == 100) {
        state.peopleList = res.data.data;
    }else {
        ElMessage({
            type: 'error',
            message: res.data.msg
        });
    }
}
const onSubmit = () => {
    gasRef.value.clearValidate();
    state.isShowUserDialog = false;
    emit('getPeopleData');
const changePeople = (val:any) => {
    chooseObj = state.peopleList.find(item => item.id === val);
    console.log("obj",chooseObj)
    if(chooseObj){
        state.peopleForm.phone = chooseObj.phone;
    }
}
const onSubmit = async () => {
    if(state.title == '新增预警人员' || state.title == '修改预警人员'){
        const valid = gasRef.value.validate();
        if(valid) {
            if(state.title == '新增预警人员'){
                const param = {
                    userId: chooseObj.id,
                    name: chooseObj.name,
                    realName: chooseObj.realName,
                    phone: chooseObj.phone
                }
                let res = await warningPeopleApi().addWarnUser(param);
                if(res.data.code == 100) {
                    ElMessage({
                        type: 'success',
                        message: '新增成功'
                    });
                }else{
                    ElMessage({
                        type: 'error',
                        message: res.data.msg
                    });
                }
            }else if(state.title == '修改预警人员'){
                const param = {
                    id: state.peopleForm.id,
                    userId: chooseObj.id,
                    name: chooseObj.name,
                    realName: chooseObj.realName,
                    phone: chooseObj.phone
                }
                console.log("res",param)
                let res = await warningPeopleApi().handelWarnUser(param);
                if(res.data.code == 100) {
                    ElMessage({
                        type: 'success',
                        message: '修改成功'
                    });
                }else{
                    ElMessage({
                        type: 'error',
                        message: res.data.msg
                    });
                }
            }
        }
        gasRef.value.clearValidate();
        state.isShowUserDialog = false;
        emit('getPeopleData');
    }else {
        state.isShowUserDialog = false;
        emit('getPeopleData');
    }
};
const handleClose = () => {
src/views/warningManage/warningPeople/index.vue
@@ -4,9 +4,9 @@
            <div class="system-menu-search mb15">
                <el-form :inline="true" >
                    <el-form-item label="姓名:">
                        <el-input  v-model="state.tableData.listQuery.searchParams.name"  placeholder="姓名" ></el-input>
                        <el-input  v-model="state.tableData.listQuery.searchParams.realName"  placeholder="请输入姓名" ></el-input>
                    </el-form-item>
                    <el-button size="default" type="primary" class="ml10">
                    <el-button size="default" type="primary" class="ml10" @click="search()">
                        <el-icon>
                            <ele-Search />
                        </el-icon>
@@ -28,9 +28,9 @@
            </el-button>
            <el-table :data="state.tableData.data" style="width: 100%">
                <el-table-column align="center" prop="name" label="预警人员"/>
                <el-table-column align="center" prop="realName"  label="预警人员"/>
                <el-table-column align="center" prop="phone" label="手机号"/>
                <el-table-column label="操作" show-overflow-tooltip width="140">
                <el-table-column label="操作" show-overflow-tooltip align="center" width="240">
                    <template #default="scope">
                        <el-button size="small" text type="primary" @click="openDialog('查看', scope.row)">查看</el-button>
                        <el-button size="small" text type="primary" @click="openDialog('修改', scope.row)">修改</el-button>
@@ -59,40 +59,46 @@
</template>
<script setup lang="ts">
import {reactive, ref} from "vue";
import {reactive, ref, onMounted} from "vue";
import { ElMessage, ElMessageBox } from 'element-plus'
import { PeopleDataState } from "/@/types/warning";
import peopleDialog from "./component/peopleDialog.vue";
import { warningPeopleApi } from "/@/api/warningManage/warningPeople";
const peopleRef = ref();
const state = reactive<PeopleDataState>({
    tableData: {
        data: [
            // {
            //     id: '1',
            //     name: '张三',
            //     phone: '112554566666'
            // },
            // {
            //     id: '2',
            //     name: '李四',
            //     phone: '11254212321'
            // }
        ],
        data: [],
        total: 0,
        loading: false,
        listQuery: {
            pageIndex: 1,
            pageSize: 10,
            searchParams:{
                name: ''
                realName: ''
            }
        }
    }
});
const initPeopleData = () => {
    console.log("数据列表")
//页面加载
onMounted(() => {
    initPeopleData();
});
const initPeopleData = async () => {
    let res = await warningPeopleApi().getWarnUserPage(state.tableData.listQuery);
    if(res.data.code == 100) {
        state.tableData.listQuery.pageIndex = res.data.pageIndex;
        state.tableData.listQuery.pageSize = res.data.pageSize;
        state.tableData.total = res.data.total;
        state.tableData.data = res.data.data;
    }else {
        ElMessage({
            type: 'error',
            message: res.data.msg
        });
    }
};
const onHandleSizeChange = (val: number) => {
    state.tableData.listQuery.pageSize = val;
@@ -116,15 +122,31 @@
            type: 'warning',
        }
    )
        .then(() => {
    .then(async () => {
        let res = await warningPeopleApi().delWarnUser({id: val.id})
        if(res.data.code == 100) {
            ElMessage({
                type: 'success',
                message: '删除成功',
            })
        })
            state.tableData.listQuery.pageIndex = 1;
            initPeopleData();
        }else {
            ElMessage({
                type: 'error',
                message: res.data.msg
            });
        }
    })
};
const search = () => {
    state.tableData.listQuery.pageIndex = 1;
    initPeopleData();
};
const reset = () => {
    state.tableData.listQuery.searchParams.name = '';
    state.tableData.listQuery.pageIndex = 1;
    state.tableData.listQuery.searchParams.realName = '';
    initPeopleData();
}
</script>
<style scoped lang="scss">
src/views/warningManage/warningSet/component/setDialog.vue
@@ -5,12 +5,12 @@
            v-model="state.isShowUserDialog"
            width="550px"
        >
            <el-form :model="state.setForm" size="default" ref="gasRef" :rules="state.setFormRules" label-width="150px">
            <el-form :model="state.setForm" size="default" ref="gasRef" :rules=" state.title == '修改' ?state.setFormRules:''" label-width="150px">
                <el-form-item label="预警名称:" prop="name">
                    <span>{{state.setForm.name}}</span>
                </el-form-item>
                <el-form-item label="连续超过阈值点数:" prop="points">
                    <el-input v-model.trim="state.setForm.points" :disabled="state.disabled"></el-input>
                <el-form-item label="连续超过阈值点数:" prop="threshold">
                    <el-input v-model.trim="state.setForm.threshold" :disabled="state.disabled"></el-input>
                </el-form-item>
            </el-form>
            <template #footer>
@@ -26,6 +26,8 @@
<script setup lang="ts">
import {reactive, ref} from "vue";
import {SetState} from "/@/types/warning";
import { warningSetApi } from "/@/api/warningManage/warningSet";
import {ElMessage} from "element-plus/es";
const gasRef = ref();
const emit = defineEmits(["getSetData"]);
@@ -34,11 +36,12 @@
    isShowUserDialog: false,
    disabled: false,
    setForm: {
        id: '',
        name: '',
        points: 0
        threshold: 0
    },
    setFormRules:{
        points: [{ required: true, message: '请填写连续超过阈值点数', trigger: 'blur' }],
        threshold: [{ required: true, message: '请填写连续超过阈值点数', trigger: 'blur' }],
    }
});
const openDialog = (type: string, value: any) => {
@@ -53,10 +56,35 @@
        state.setForm = JSON.parse(JSON.stringify(value));
    }
};
const onSubmit = () => {
    gasRef.value.clearValidate();
    state.isShowUserDialog = false;
    emit('getSetData');
const onSubmit = async () => {
    if(state.title == '修改'){
        const valid = gasRef.value.validate();
        if(valid){
            const param = {
                id: state.setForm.id,
                threshold: state.setForm.threshold
            }
            let res = await warningSetApi().handelWarnSet(param);
            if(res.data.code == 100){
                ElMessage({
                    type: 'success',
                    message: '修改成功'
                });
            }else {
                ElMessage({
                    type: 'error',
                    message: res.data.msg
                });
            }
        }
        gasRef.value.clearValidate();
        state.isShowUserDialog = false;
        emit('getSetData');
    }else {
        state.isShowUserDialog = false;
        emit('getSetData');
    }
};
const handleClose = () => {
src/views/warningManage/warningSet/index.vue
@@ -3,7 +3,7 @@
        <el-card shadow="hover">
            <el-table :data="state.tableData.data" style="width: 100%">
                <el-table-column align="center" prop="name" label="预警名称"/>
                <el-table-column align="center" prop="points" label="连续超过阈值点数"/>
                <el-table-column align="center" prop="threshold" label="连续超过阈值点数"/>
                <el-table-column label="操作" show-overflow-tooltip width="140">
                    <template #default="scope">
                        <el-button size="small" text type="primary" @click="openDialog('查看', scope.row)">查看</el-button>
@@ -17,28 +17,33 @@
</template>
<script setup lang="ts">
import {reactive, ref} from "vue";
import {reactive, ref, onMounted} from "vue";
import { TableDataState } from "/@/types/warning";
import setDialog from "./component/setDialog.vue";
import { warningSetApi } from "/@/api/warningManage/warningSet";
import {ElMessage} from "element-plus/es";
const setRef = ref();
const state = reactive<TableDataState>({
    tableData: {
        data: [
            {
                name: '黄色预警',
                points: 1
            },
            {
                name: '红色预警',
                points: 2
            },
        ]
        data: []
    }
});
//页面加载
onMounted(() => {
    initSetData();
});
const initSetData = () => {
    console.log("数据列表")
const initSetData = async () => {
    let res = await warningSetApi().getWarnSetPage({});
    if(res.data.code == 100) {
        state.tableData.data = res.data.data;
    }else {
        ElMessage({
            type: 'error',
            message: res.data.msg
        });
    }
};
const openDialog = (type: string, value: any) => {
    setRef.value.openDialog(type, value);