Files
sgxt_web/src/views/backOfficeSystem/JudgmentHome/tsypHome/components/ypHome.vue

371 lines
9.0 KiB
Vue
Raw Normal View History

2025-09-03 18:12:19 +08:00
<template>
2025-09-16 15:50:24 +08:00
<!-- 研判类型 -->
<div class="content">
2026-01-23 15:43:22 +08:00
<div ref="searchBox" class="mt10">
<Search :searchArr="searchConfiger" @submit="onSearch"> </Search>
</div>
<PageTitle :malginLeft="10" :height="35" backgroundColor="#ffff" :marginBottom="5" :marginTop="5">
<template #left>
<el-button size="small" type="primary" @click="openAddModel('add')" :icon="CirclePlus">
2025-09-16 15:50:24 +08:00
新增模型
</el-button>
2026-01-23 15:43:22 +08:00
</template>
2025-09-16 15:50:24 +08:00
</PageTitle>
2025-09-24 18:10:41 +08:00
<ul class="cntlsit mb10" v-if="show" v-infinite-scroll="load" :style="{ height: listHeight + 'px' }"
v-loading="loading">
<li class="model-card" v-for="(it, idx) in list" :key="idx">
<div class="model-info">
<div class="model-name">
<strong>模型名称</strong>{{ it.mxmc }}
</div>
<div class="model-type flex">
2025-09-29 18:11:07 +08:00
<strong>模型类型</strong>
<DictTag :tag="false" :value="it.mxlx" :options="D_MXGL_MXLX" />
2025-09-24 18:10:41 +08:00
</div>
</div>
<div class="model-image-container" @click="openYjList(it)">
2025-09-29 18:11:07 +08:00
<img class="model-image" src="@/assets/images/mxbg.jpg" alt="">
2025-09-24 18:10:41 +08:00
</div>
<div class="model-actions">
<span class="action-btn action-btn-view" @click.stop="openAddRule('', it)">
2025-09-29 18:11:07 +08:00
<el-icon class="action-icon">
<Document />
</el-icon>查看规则
2025-09-24 18:10:41 +08:00
</span>
<span class="action-btn action-btn-edit" @click.stop="openAddModel('edit', it)">
2025-09-29 18:11:07 +08:00
<el-icon class="action-icon">
<ChatDotSquare />
</el-icon>编辑
2025-09-24 18:10:41 +08:00
</span>
2025-09-29 18:11:07 +08:00
<span class="action-btn action-btn-edit" @click.stop="operationRule(it)">
<el-icon class="action-icon">
<Edit />
</el-icon>执行
2025-09-24 18:10:41 +08:00
</span>
<span class="action-btn action-btn-delete" @click.stop="delDictItem(it.id)">
2025-09-29 18:11:07 +08:00
<el-icon class="action-icon">
<Files />
</el-icon>删除
2025-09-24 18:10:41 +08:00
</span>
2025-09-16 15:50:24 +08:00
</div>
</li>
2025-09-24 18:10:41 +08:00
<div class="empty-container">
2025-09-16 15:50:24 +08:00
<MOSTY.Empty :show="!loading && list.length <= 0"></MOSTY.Empty>
</div>
2025-09-24 18:10:41 +08:00
<div class="no-more-data" v-if="total == list.length && total > 0">暂时没有数据了</div>
2025-09-16 15:50:24 +08:00
</ul>
</div>
2025-09-24 18:10:41 +08:00
<AddModel ref="addModel" :dict="{ D_MXGL_MXLX }" @getLits="getLits" />
2025-09-03 18:12:19 +08:00
</template>
<script setup>
2025-09-16 15:50:24 +08:00
import PageTitle from "@/components/aboutTable/PageTitle.vue";
2025-09-29 18:11:07 +08:00
import { getPageList, deleteEntity, getSsyjpzMxgzxl, SsyjselectList, getYjgzpzSelectList, getYjgzpzMxgzxl } from '@/api/model.js'
2025-09-24 18:10:41 +08:00
import emitter from "@/utils/eventBus.js";
2025-09-16 15:50:24 +08:00
import { CirclePlus } from '@element-plus/icons-vue'
2025-09-03 18:12:19 +08:00
import * as MOSTY from "@/components/MyComponents/index";
import Search from "@/components/aboutTable/Search.vue";
import { reactive, ref, onMounted, getCurrentInstance, watch, defineEmits } from "vue";
2025-09-24 18:10:41 +08:00
import AddModel from "../components/AddModel/addModel";
2025-09-03 18:12:19 +08:00
const emit = defineEmits(['change'])
2025-09-24 18:10:41 +08:00
const { proxy } = getCurrentInstance();
2025-09-29 18:11:07 +08:00
const { D_MXGL_MXLX, D_BZ_RYBQ } = proxy.$dict("D_MXGL_MXLX", "D_BZ_RYBQ")
2025-09-03 18:12:19 +08:00
const searchBox = ref(); //搜索框
const show = ref(false)
const listHeight = ref()
2025-09-24 18:10:41 +08:00
const SSYJ = '02'
2025-09-29 18:11:07 +08:00
const YJGZ = '01'
2025-09-03 18:12:19 +08:00
const searchConfiger = ref([
2025-09-24 18:10:41 +08:00
{ label: "模型名称", prop: "mxmc", placeholder: "请输入模型名称", showType: "input" },
{
label: "模型类型",
prop: "mxlx",
placeholder: "请选择模型类型",
showType: "select",
options: D_MXGL_MXLX
},
2025-09-03 18:12:19 +08:00
]);
2025-09-16 15:50:24 +08:00
const PaginationConfig = reactive({
pageCurrent: 1,
pageSize: 8,
2025-09-03 18:12:19 +08:00
});
const total = ref(0)
const list = ref([])
const loading = ref(false);
const formData = ref({})
onMounted(() => {
show.value = true;
tabHeightFn();
2025-09-03 19:58:23 +08:00
getLits()
2025-09-03 18:12:19 +08:00
})
const onSearch = (val) => {
formData.value = { ...formData.value, ...val, };
2025-09-16 15:50:24 +08:00
PaginationConfig.pageCurrent = 1;
2025-09-03 18:12:19 +08:00
getLits();
}
const load = () => {
if (total.value == list.value.length) return;
2025-09-16 15:50:24 +08:00
PaginationConfig.pageCurrent++;
2025-09-20 17:29:35 +08:00
// getLits();
2025-09-03 18:12:19 +08:00
}
const getLits = () => {
let params = {
2025-09-16 15:50:24 +08:00
...PaginationConfig,
2025-09-04 11:41:51 +08:00
...formData.value
2025-09-03 18:12:19 +08:00
}
loading.value = true;
2025-09-24 18:10:41 +08:00
getPageList(params).then(res => {
2025-09-03 18:12:19 +08:00
let arr = res.records || [];
2025-09-16 15:50:24 +08:00
list.value = PaginationConfig.pageCurrent == 1 ? arr : list.value.concat(arr);
2025-09-03 18:12:19 +08:00
total.value = res.total;
loading.value = false;
}).catch(() => {
loading.value = false;
})
}
// 表格高度计算
const tabHeightFn = () => {
2025-09-16 15:50:24 +08:00
listHeight.value = window.innerHeight - searchBox.value.offsetHeight - 230;
2025-09-03 18:12:19 +08:00
window.onresize = function () {
tabHeightFn();
};
};
2025-09-24 18:10:41 +08:00
const delDictItem = (id) => {
proxy.$confirm('是否删除该模型, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
deleteEntity({ ids: [id] }).then(res => {
proxy.$message.success("删除成功!")
getLits()
})
}).catch(() => {
proxy.$message({
type: 'info',
message: '已取消删除'
});
});
2025-09-03 18:12:19 +08:00
2025-09-24 18:10:41 +08:00
}
2025-09-16 15:50:24 +08:00
// 打开弹窗
const addModel = ref(null)
const openAddModel = (type, row) => {
addModel.value.init(type, row)
2025-09-03 18:12:19 +08:00
}
2025-09-16 15:50:24 +08:00
// 打开规则弹窗
const openAddRule = (type, row) => {
2025-09-24 18:10:41 +08:00
switch (row.mxlx) {
case SSYJ:
2025-09-29 18:11:07 +08:00
emitter.emit('changeModel', { row, name: '四色预警规则' })
2025-09-24 18:10:41 +08:00
break;
2025-09-29 18:11:07 +08:00
case YJGZ:
emitter.emit('changeModel', { row, name: '预警规则' })
2025-09-24 18:10:41 +08:00
break;
default:
break;
}
}
const openYjList = (row) => {
2025-09-29 18:11:07 +08:00
emitter.emit('changeModel', { row, name: '预警列表' })
2025-09-03 18:12:19 +08:00
}
2025-09-29 18:11:07 +08:00
const operationRule = async (row) => {
if (row.mxlx == SSYJ) {
try {
const data = await SsyjselectList({ mxid: row.id })
if (data.length > 0) {
await getSsyjpzMxgzxl({ id: data[0].id })
proxy.$message.success('运行成功')
} else {
proxy.$message.warning('未配置预警规则')
}
} catch (error) {
console.log(error);
proxy.$message.error('运行失败')
}
}
if (row.mxlx == YJGZ) {
try {
const data = await getYjgzpzSelectList({ mxid: row.id })
if (data.length > 0) {
await getYjgzpzMxgzxl({ id: data[0].id })
proxy.$message.success('运行成功')
} else {
proxy.$message.warning('未配置预警规则')
}
} catch (error) {
console.log(error);
proxy.$message.error('运行失败')
}
}
}
2025-09-03 18:12:19 +08:00
</script>
<style lang="scss" scoped>
.content {
2025-09-16 15:50:24 +08:00
width: 100%;
height: 100%;
margin-top: 20px;
margin-left: 10px;
2025-09-24 18:10:41 +08:00
border-radius: 8px;
2025-09-16 15:50:24 +08:00
box-sizing: border-box;
.btnsBox {
background: #fff;
padding: 10px 5px;
2025-09-03 18:12:19 +08:00
border-radius: 4px;
2025-09-16 15:50:24 +08:00
margin-bottom: 10px;
}
.cntlsit {
display: flex;
flex-wrap: wrap;
align-content: start;
2025-09-24 18:10:41 +08:00
gap: 20px;
2025-09-16 15:50:24 +08:00
overflow: hidden;
overflow-y: auto;
background: #fff;
2025-09-24 18:10:41 +08:00
padding: 16px;
2025-09-03 18:12:19 +08:00
box-sizing: border-box;
2025-09-24 18:10:41 +08:00
border-radius: 8px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
2025-09-03 18:12:19 +08:00
2025-09-24 18:10:41 +08:00
// 模型卡片样式
.model-card {
width: 300px;
border: 1px solid #e4e7ed;
border-radius: 8px;
overflow: hidden;
background: #fff;
transition: all 0.3s ease;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
&:hover {
transform: translateY(-4px);
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
border-color: #409eff;
}
// 模型信息区域
.model-info {
padding: 16px;
background-color: #fafafa;
border-bottom: 1px solid #f0f0f0;
.model-name,
.model-type {
margin-bottom: 8px;
font-size: 14px;
color: #606266;
strong {
color: #303133;
font-weight: 500;
}
}
.model-type {
margin-bottom: 0;
}
}
// 模型图片区域
.model-image-container {
cursor: pointer;
2025-09-03 18:12:19 +08:00
overflow: hidden;
2025-09-24 18:10:41 +08:00
transition: all 0.3s ease;
.model-image {
width: 100%;
height: 168px;
object-fit: cover;
transition: transform 0.3s ease;
&:hover {
transform: scale(1.05);
}
}
}
// 操作按钮区域
.model-actions {
text-align: right;
padding: 12px 0px;
border-top: 1px solid #f0f0f0;
background-color: #fafafa;
.action-btn {
// margin-left: 12px;
justify-content: space-between;
font-size: 13px;
cursor: pointer;
transition: all 0.3s ease;
display: inline-flex;
align-items: center;
padding: 4px 8px;
border-radius: 4px;
.action-icon {
margin-right: 4px;
font-size: 14px;
}
&:hover {
opacity: 0.8;
}
}
.action-btn-view,
.action-btn-edit {
color: #409eff;
&:hover {
background-color: #ecf5ff;
}
}
.action-btn-delete {
color: #f4ac47;
2025-09-03 18:12:19 +08:00
2025-09-24 18:10:41 +08:00
&:hover {
background-color: #fff7e6;
}
2025-09-03 18:12:19 +08:00
}
}
2025-09-24 18:10:41 +08:00
}
// 空状态和无更多数据样式
.empty-container {
width: 100%;
display: flex;
justify-content: center;
padding: 40px 0;
}
2025-09-16 15:50:24 +08:00
2025-09-24 18:10:41 +08:00
.no-more-data {
width: 100%;
text-align: center;
margin-bottom: 16px;
color: #a29f9f;
font-size: 13px;
2025-09-03 18:12:19 +08:00
}
2025-09-16 15:50:24 +08:00
}
2025-09-03 18:12:19 +08:00
</style>