123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217 |
- <template>
- <div class="table_item">
- <a-page-header sub-title="监测点配置" @back="goBack" style="padding: 0 0 20px">
- <template #title>
- <span style="font-size: 18px; cursor: pointer" @click="goBack">返回</span>
- </template>
- </a-page-header>
- <s-table
- ref="tableRef"
- :columns="columns"
- :data="loadData"
- :row-key="(record) => record.id"
- bordered
- @resizeColumn="handleResizeColumn"
- >
- <template #operator>
- <!-- 搜索区域 -->
- <div class="table-search">
- <div class="table-search-form">
- <a-row :gutter="10">
- <a-form
- ref="searchFormRef"
- name="advanced_search"
- layout="inline"
- :label-col="{ style: { width: '70px', justifyContent: 'end' } }"
- :model="searchFormState"
- class="ant-advanced-search-form"
- >
- <a-col :xs="24" :sm="24" :md="12" :lg="8" :xl="8"
- ><a-form-item label="点位名称" name="name">
- <a-input v-model:value="searchFormState.name" placeholder="请输入点位名称" /> </a-form-item
- ></a-col>
- </a-form>
- </a-row>
- </div>
- <div class="table-search-buttons">
- <a-button type="primary" @click="tableRef.refresh(true)">查询</a-button>
- <a-button class="xn-mg08" @click="reset">重置</a-button>
- </div>
- </div>
- <!-- 其他操作区域 -->
- <div class="table-head-btn">
- <div class="btn-left">
- <a-button type="primary" @click="formRef.onOpen('add', { monitorTargetId: queryId })">
- <template #icon><plus-outlined /></template>新增
- </a-button>
- </div>
- </div>
- </template>
- <template #bodyCell="{ column, record, index }">
- <!-- 序号 -->
- <template v-if="column.dataIndex === 'index'">{{ index + 1 }} </template>
- <template v-if="column.dataIndex === 'name'">
- <a-button type="link" @click="leaveFor('/biz/monitor/trendchart', record)">{{ record.name }}</a-button>
- </template>
- <template v-if="column.dataIndex === 'sensorType'">
- {{ $TOOL.dictTypeData('SENSORTYPE', record.sensorType) }}
- </template>
- <template v-if="column.dataIndex === 'action'">
- <a-button type="link" size="small" @click="formRef.onOpen('edit', record)">编辑</a-button>
- <a-popconfirm title="确定要删除吗?" @confirm="deleteData(record)">
- <a-button type="link" danger size="small">删除</a-button>
- </a-popconfirm>
- </template>
- </template>
- </s-table>
- <Form ref="formRef" @successful="tableRef.refresh(true)" />
- </div>
- </template>
- <script setup>
- import locationApi from '@/api/basicset/locationApi.js'
- import { useRoute } from 'vue-router'
- import router from '@/router'
- import Form from './form.vue'
- const formRef = ref()
- const searchFormRef = ref()
- const searchFormState = ref({})
- const tableRef = ref()
- const Route = useRoute()
- const columns = [
- {
- title: '序号',
- dataIndex: 'index',
- align: 'center',
- width: 50
- },
- {
- title: '区域名称',
- dataIndex: 'name',
- align: 'center',
- ellipsis: true,
- resizable: true
- },
- {
- title: '监控对象',
- dataIndex: 'targetName',
- align: 'center',
- ellipsis: true,
- resizable: true
- },
- {
- title: '监测设备',
- dataIndex: 'deviceName',
- align: 'center',
- ellipsis: true,
- resizable: true
- },
- {
- title: '传感器编号',
- dataIndex: 'sensorCode',
- align: 'center',
- ellipsis: true,
- resizable: true
- },
- {
- title: '传感器类型',
- dataIndex: 'sensorType',
- align: 'center',
- ellipsis: true,
- resizable: true
- },
- {
- title: '传感器路数',
- dataIndex: 'sensorRoute',
- align: 'center',
- ellipsis: true,
- resizable: true
- },
- {
- title: '创建时间',
- dataIndex: 'createTime',
- align: 'center',
- ellipsis: true,
- resizable: true
- },
- {
- title: '操作',
- dataIndex: 'action',
- align: 'center',
- width: 150
- }
- ]
- // 可伸缩列
- const handleResizeColumn = (w, col) => {
- col.width = w
- }
- const queryId = ref() //监控对象的id
- onBeforeMount(() => {
- if (Route.query.id) {
- queryId.value = Route.query.id
- }
- })
- // 返回上一页
- const goBack = () => {
- router.go(-1)
- }
- const loadData = (parameter) => {
- if (queryId.value) {
- parameter.monitorTargetId = queryId.value
- return locationApi.locationPage(Object.assign(parameter, searchFormState.value)).then((res) => {
- return res
- })
- }
- }
- // 重置
- const reset = () => {
- searchFormRef.value.resetFields()
- tableRef.value.refresh(true)
- }
- // 删除
- const deleteData = (record) => {
- let params = [
- {
- id: record.id
- }
- ]
- locationApi.locationDelete(params).then(() => {
- tableRef.value.refresh(true)
- reset()
- })
- }
- // 跳转到趋势图界面
- const leaveFor = (url, record) => {
- router.push({
- path: url,
- query: {
- id: record.id
- }
- })
- }
- </script>
- <style lang="less" scoped>
- .table_item {
- padding: 15px 20px;
- background-color: #ffffff;
- :deep(.ant-table-pagination-right) {
- justify-content: center !important;
- }
- :deep .ant-page-header-back {
- margin-right: 8px;
- }
- }
- </style>
|