|
@@ -0,0 +1,147 @@
|
|
|
+<template>
|
|
|
+ <div class="app-container">
|
|
|
+ <div v-show="!rescueStationAddState.show && !rescueStationEditState.show && !rescueStationViewState.show">
|
|
|
+ <h1>救助站管理</h1>
|
|
|
+ <el-row :gutter="10" class="mb8">
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button type="primary" icon="Plus" @click="handleAdd">录入</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button type="primary" icon="Plus" @click="handleAdds">批量导入</el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <!-- 表格组件 -->
|
|
|
+ <el-table ref="multipleTable" v-loading="loading" :data="tableData" style="width: 100%" :max-height="400">
|
|
|
+ <el-table-column label="id" align="center" prop="id" fixed="left" />
|
|
|
+ <el-table-column label="名称" align="center" prop="name" fixed="left" />
|
|
|
+ <el-table-column label="类型" align="center" prop="type" />
|
|
|
+ <el-table-column label="所属区县" align="center" prop="county" />
|
|
|
+ <el-table-column label="所属镇街" align="center" prop="town" />
|
|
|
+ <el-table-column label="地址" align="center" prop="address" />
|
|
|
+ <el-table-column label="联系人" align="center" prop="contacts" />
|
|
|
+ <el-table-column label="联系电话" align="center" prop="phone" />
|
|
|
+ <el-table-column label="开放时间" align="center" prop="open_time" />
|
|
|
+ <el-table-column label="更新时间" align="center" prop="update_time" />
|
|
|
+ <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="200">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-text class="common-btn-text-primary" @click="handleView(scope.row)">查看</el-text>
|
|
|
+ <el-text class="common-btn-text-primary" @click="handleUpdate(scope.row)">修改</el-text>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ <pagination
|
|
|
+ v-show="total > 0"
|
|
|
+ v-model:page="queryParams.page"
|
|
|
+ v-model:limit="queryParams.pageSize"
|
|
|
+ :total="total"
|
|
|
+ @pagination="fetchUnitData"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <RescueStationAdd v-if="rescueStationAddState.show" @close="handleCancel" @refresh="fetchStationData" />
|
|
|
+ <RescueStationEdit v-if="rescueStationEditState.show" :event-id="rescueStationEditState.eventId" @close="handleCancel" @refresh="fetchStationData" />
|
|
|
+ <RescueStationView v-if="rescueStationViewState.show" :event-id="rescueStationViewState.eventId" @close="handleCancel" />
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup lang="ts">
|
|
|
+import { onMounted, reactive, ref, toRefs } from 'vue';
|
|
|
+import { ElTable, ElTableColumn, ElButton, ElText } from 'element-plus';
|
|
|
+import { ComponentInternalInstance, getCurrentInstance } from 'vue';
|
|
|
+import { getStations } from '@/api/comprehensiveGuarantee/reliefResourceManagement/rescueStation';
|
|
|
+import Pagination from '@/components/Pagination/index.vue';
|
|
|
+import RescueStationAdd from './rescueStationAdd.vue';
|
|
|
+import RescueStationEdit from './rescueStationEdit.vue';
|
|
|
+import RescueStationView from './rescueStationView.vue';
|
|
|
+const loading = ref(true);
|
|
|
+const showSearch = ref(true);
|
|
|
+const multiple = ref(true);
|
|
|
+const ids = ref<Array<number | string>>([]);
|
|
|
+const single = ref(true);
|
|
|
+const total = ref(0);
|
|
|
+const tableData = ref<any[]>([]);
|
|
|
+const selectedRow = ref<any | null>(null);
|
|
|
+
|
|
|
+const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
|
|
+
|
|
|
+const initFormData = reactive({
|
|
|
+ name: '',
|
|
|
+ type: '',
|
|
|
+ county: '',
|
|
|
+ town: '',
|
|
|
+ address: '',
|
|
|
+ contacts: '',
|
|
|
+ phone: '',
|
|
|
+ open_time: '',
|
|
|
+ update_time: '',
|
|
|
+ id: ''
|
|
|
+});
|
|
|
+
|
|
|
+const data = reactive({
|
|
|
+ form: { ...initFormData },
|
|
|
+ queryParams: {
|
|
|
+ page: 1,
|
|
|
+ pageSize: 10
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
+const { queryParams, form } = toRefs(data);
|
|
|
+
|
|
|
+const fetchStationData = async () => {
|
|
|
+ try {
|
|
|
+ loading.value = true;
|
|
|
+ const response = await getStations(queryParams.value);
|
|
|
+ if (response.code === 200) {
|
|
|
+ tableData.value = response.data;
|
|
|
+ total.value = response.data.length;
|
|
|
+ } else {
|
|
|
+ console.error('获取数据失败:', response.msg);
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('请求数据时发生错误:', error);
|
|
|
+ } finally {
|
|
|
+ loading.value = false;
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+let rescueStationViewState = reactive({
|
|
|
+ show: false,
|
|
|
+ eventId: ''
|
|
|
+});
|
|
|
+
|
|
|
+let rescueStationEditState = reactive({
|
|
|
+ show: false,
|
|
|
+ eventId: ''
|
|
|
+});
|
|
|
+let rescueStationAddState = reactive({
|
|
|
+ show: false
|
|
|
+});
|
|
|
+const handleAdd = () => {
|
|
|
+ rescueStationAddState.show = true;
|
|
|
+};
|
|
|
+
|
|
|
+const handleView = (row: any) => {
|
|
|
+ rescueStationViewState.eventId = row.id;
|
|
|
+ rescueStationViewState.show = true;
|
|
|
+};
|
|
|
+
|
|
|
+const handleUpdate = (row: any) => {
|
|
|
+ rescueStationEditState.eventId = row.id;
|
|
|
+ rescueStationEditState.show = true;
|
|
|
+};
|
|
|
+
|
|
|
+const handleCancel = () => {
|
|
|
+ rescueStationViewState.show = false;
|
|
|
+ rescueStationEditState.show = false;
|
|
|
+ rescueStationAddState.show = false;
|
|
|
+};
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ fetchStationData();
|
|
|
+});
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+.app-container {
|
|
|
+ overflow-x: auto; /* 当内容溢出时允许水平滚动 */
|
|
|
+}
|
|
|
+</style>
|