<script setup name="stationManage">
|
import { ref, onMounted, reactive, computed, watchEffect, nextTick } from "vue";
|
import addEdit from './addEdit.vue';
|
import {
|
delStatiaon,
|
getStationList,
|
} from "@/api/station.js";
|
import useElement from "@/hooks/useElement.js";
|
const { $loading, $message, $confirm } = useElement();
|
|
import { checkSnId } from '@/api/user.js';
|
import useStation from "@/hooks/useStationList.js";
|
const { stationName1, stationName2, stationName3,
|
stationList1, stationList2, stationList3,
|
} = useStation();
|
|
const tableData = ref([]);
|
const pageNum = ref(1);
|
const pageSize = ref(10);
|
const total = ref(0);
|
const info = ref({});
|
|
const addEditVisible = ref(false);
|
const addEditTitle = ref('');
|
const isAdd = ref(false);
|
|
const filter = reactive({
|
name: "",
|
type: undefined,
|
});
|
|
function getList() {
|
let params = {
|
pageNum: pageNum.value,
|
pageSize: pageSize.value,
|
stationName1: stationName1.value || undefined,
|
stationName2: stationName2.value || undefined,
|
stationName3: stationName3.value || undefined,
|
};
|
|
getStationList(params).then((res) => {
|
let { code, data, data2 } = res;
|
let _total = 0;
|
let _list = [];
|
if (code && data) {
|
_list = data2.list;
|
_total = data2.total;
|
}
|
tableData.value = _list;
|
total.value = _total;
|
});
|
}
|
|
|
function add () {
|
console.log('add', '=============');
|
addEditTitle.value = '添加机房';
|
isAdd.value = true;
|
addEditVisible.value = true;
|
}
|
|
function edit (scope) {
|
console.log('scope', scope, '=============');
|
let {
|
row
|
} = scope;
|
addEditTitle.value = '修改机房';
|
isAdd.value = false;
|
info.value = row;
|
addEditVisible.value = true;
|
}
|
|
function del (scope) {
|
console.log('scope', scope, '=============');
|
let {
|
row
|
} = scope;
|
$confirm('删除该机房', () => {
|
let loading = $loading();
|
delStatiaon(row.stationId).then((res) => {
|
let { code, data } = res;
|
loading.close();
|
if (code && data) {
|
$message.success('删除成功');
|
getList();
|
} else {
|
$message.error('删除失败');
|
}
|
});
|
});
|
}
|
|
function handleSizeChange(val) {
|
pageSize.value = val;
|
getList();
|
}
|
|
function handleCurrentChange(val) {
|
pageNum.value = val;
|
getList();
|
}
|
|
function cancel (scope) {
|
console.log('row', scope.row, '=============');
|
|
}
|
|
function okHandle() {
|
addEditVisible.value = false;
|
getList();
|
}
|
|
onMounted(() => {
|
getList();
|
});
|
</script>
|
|
<template>
|
<div class="page-wrapper">
|
<div class="page-header">
|
<!-- <div class="hdw-card-container">
|
<yc-card title="区域列表" is-full>
|
<hdw-tree @item-click="itemClickHandler"></hdw-tree>
|
</yc-card>
|
</div> -->
|
</div>
|
<div class="page-content">
|
<yc-card is-full>
|
<div class="page-content-wrapper">
|
<div class="page-content-tools">
|
<el-button type="primary" size="small" @click="add"><svg-icon icon-class="add"></svg-icon>添加</el-button>
|
|
|
<div class="tools-filter">
|
<div class="tools-filter-item">
|
<div class="filter-label">省:</div>
|
<div class="filter-content">
|
<el-select
|
v-model="stationName1"
|
clearable
|
placeholder="请选择"
|
@change="() => nextTick(() => getList())"
|
size="small"
|
style="width: 180px"
|
>
|
<el-option
|
v-for="(item, idx) in stationList1"
|
:key="'province_' + idx"
|
:label="item"
|
:value="item"
|
/>
|
</el-select>
|
</div>
|
</div>
|
<div class="tools-filter-item">
|
<div class="filter-label">市:</div>
|
<div class="filter-content">
|
<el-select
|
v-model="stationName2"
|
clearable
|
placeholder="请选择"
|
@change="() => nextTick(() => getList())"
|
size="small"
|
style="width: 180px"
|
>
|
<el-option
|
v-for="(item, idx) in stationList2"
|
:key="'city_' + idx"
|
:label="item"
|
:value="item"
|
/>
|
</el-select>
|
</div>
|
</div>
|
<div class="tools-filter-item">
|
<div class="filter-label">区县:</div>
|
<div class="filter-content">
|
<el-select
|
v-model="stationName3"
|
clearable
|
placeholder="请选择"
|
@change="() => nextTick(() => getList())"
|
size="small"
|
style="width: 180px"
|
>
|
<el-option
|
v-for="(item, idx) in stationList3"
|
:key="'list2_' + idx"
|
:label="item"
|
:value="item"
|
/>
|
</el-select>
|
</div>
|
</div>
|
</div>
|
<el-button type="primary" size="small" @click="getList"><svg-icon icon-class="search"></svg-icon>查询</el-button>
|
</div>
|
<div class="page-content-table">
|
<div class="pos-rel">
|
<div class="pos-abs">
|
<el-table stripe :data="tableData" border style="width: 100%; height: 100%">
|
<el-table-column type="index" fixed="left" width="50" />
|
<el-table-column prop="stationName1" label="省" width="180" />
|
<el-table-column prop="stationName2" label="市" width="180" />
|
<el-table-column prop="stationName3" label="区县" />
|
<el-table-column prop="stationName4" label="机房名称" min-width="180" />
|
<el-table-column align="center" fixed="right" label="操作" width="200">
|
<template #default="scope">
|
<el-button type="primary" size="small"
|
@click="edit(scope)">编辑</el-button>
|
<el-button type="danger" size="small" @click="del(scope)">删除</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
</div>
|
</div>
|
</div>
|
<div class="page-content-page">
|
<div class="page-tool"></div>
|
<div class="el-page-container">
|
<el-pagination v-model:current-page="pageNum" v-model:page-size="pageSize"
|
:page-sizes="[10,20, 40, 60, 80, 100, 200, 300, 400]" size="small"
|
layout="total, sizes, prev, pager, next, jumper" :total="total" @size-change="handleSizeChange"
|
@current-change="handleCurrentChange" />
|
</div>
|
<div class="page-tool"></div>
|
</div>
|
</div>
|
</yc-card>
|
</div>
|
<div class="page-footer"></div>
|
<!-- 编辑 新建 -->
|
<el-dialog v-model="addEditVisible" :title="addEditTitle" width="640" align-center :close-on-click-modal="false">
|
<add-edit v-if="addEditVisible" :info="info" :isAdd="isAdd" @close="addEditVisible = false"
|
@ok="okHandle"></add-edit>
|
</el-dialog>
|
</div>
|
</template>
|
|
<style scoped lang="scss">
|
.page-wrapper {
|
display: flex;
|
flex-direction: row;
|
padding: 8px;
|
height: 100%;
|
|
.page-content {
|
flex: 1;
|
}
|
}
|
|
.page-content-wrapper {
|
display: flex;
|
flex-direction: column;
|
height: 100%;
|
|
.page-content-tools {
|
padding-bottom: 8px;
|
}
|
|
.page-content-table {
|
border-top: 1px solid var(--border-light-color);
|
box-sizing: border-box;
|
flex: 1;
|
margin-left: -8px;
|
margin-right: -8px;
|
}
|
|
.page-content-page {
|
padding: 8px 8px 0 8px;
|
text-align: center;
|
|
.el-page-container {
|
display: inline-block;
|
padding: 0 16px;
|
}
|
|
.page-tool {
|
display: inline-block;
|
}
|
}
|
}
|
|
.hdw-card-container {
|
width: 320px;
|
padding-right: 8px;
|
height: 100%;
|
}
|
|
.pos-rel {
|
position: relative;
|
width: 100%;
|
height: 100%;
|
|
.pos-abs {
|
position: absolute;
|
top: 0;
|
bottom: 0;
|
left: 0;
|
right: 0;
|
width: 100%;
|
height: 100%;
|
}
|
}
|
|
.tools-filter {
|
display: inline-block;
|
font-size: 14px;
|
|
.tools-filter-item {
|
display: inline-block;
|
margin-right: 8px;
|
|
.filter-label {
|
display: inline-block;
|
}
|
|
.filter-content {
|
display: inline-block;
|
}
|
}
|
}
|
|
.page-content-tools {
|
display: flex;
|
|
.item {
|
display: flex;
|
align-items: center;
|
|
&+.item {
|
margin-left: 20px;
|
}
|
|
.label {
|
&::after {
|
content: ":";
|
}
|
}
|
|
.value {
|
margin-left: 8px;
|
font-weight: bold;
|
color: #090;
|
font-size: 18px;
|
}
|
}
|
}
|
|
.dialog-title {
|
color: #000;
|
font-size: 16px;
|
padding-left: 0.8em;
|
}
|
|
:deep(.el-dialog__body) {
|
flex: 1;
|
}
|
</style>
|