Commit 031bdd9c1c96099cb927ad27bb69aa39488ffafb

Authored by 张红振
1 parent 55bc0c23

fix bug

src/api/ownerManagement/owner.ts 0 → 100644
  1 +import request from '../request'
  2 +
  3 +// 列表查询
  4 +export function getTableList(params:any) {
  5 + return request({
  6 + method: 'get',
  7 + url: '/resident/residentList',
  8 + params: params
  9 + })
  10 +}
  11 +
  12 +// 房屋信息
  13 +export function getHouse(params:any) {
  14 + return request({
  15 + method: 'post',
  16 + url: '/house/getHouse',
  17 + params: params
  18 + })
  19 +}
  20 +// 删除
  21 +export function deleteHouse(params:any) {
  22 + return request({
  23 + method: 'delete',
  24 + url: '/house/deleteHouse',
  25 + params: params
  26 + })
  27 +}
... ...
src/api/request.ts
1 1 import axios from 'axios'
2 2 import * as store from "@/pinia/index";
3 3 import router from '@/router'
  4 +import { ElMessage } from 'element-plus'
4 5  
5 6 // 不这样写报ts类型错误,import...有一个多余的boolean类型
6   -let url: any = import.meta.env
  7 +let url: any = import.meta.env
7 8 let instance = axios.create({
8 9 baseURL: url.VITE_BASE_URL,
9 10 withCredentials: true,
... ... @@ -25,16 +26,20 @@ instance.interceptors.request.use(
25 26  
26 27 instance.interceptors.response.use(
27 28 response => {
28   - if(response) {
  29 + if (response) {
29 30 console.log(response?.data?.errorCode)
30 31 }
31   - switch(~~response?.data?.errorCode) {
  32 + switch (~~response?.data?.errorCode) {
32 33 case 10002:
33 34 console.log('跳转')
34 35 router.push({
35 36 path: 'login'
36 37 })
37   - break;
  38 + break;
  39 + case 500:
  40 + ElMessage.error(`${response?.data?.errorMessage},请联系管理员`)
  41 + Promise.reject(response?.data)
  42 + break;
38 43 }
39 44 return response
40 45 },
... ...
src/main.ts
... ... @@ -5,7 +5,7 @@ import promise from 'es6-promise'
5 5 // import store from '@/store/index'
6 6  
7 7 import ElementPlus from 'element-plus'
8   -import { ElMessage } from 'element-plus'
  8 +import { ElMessage,ElMessageBox } from 'element-plus'
9 9 import 'element-plus/dist/index.css'
10 10 import zhCn from 'element-plus/es/locale/lang/zh-cn' // TIP elementUI配置中文环境
11 11  
... ... @@ -38,6 +38,7 @@ for(const i in globalVariable) {
38 38 // app.config.warnHandler = () => null;
39 39 // app.config.errorHandler = () => null;
40 40 app.provide("$message", ElMessage);
  41 +app.provide("$messageBox", ElMessageBox );
41 42  
42 43 app
43 44 // .use(store)
... ...
src/router/index.ts
... ... @@ -4,6 +4,7 @@ import User from "./modules/user"
4 4 import Resident from "./modules/resident"
5 5 import Property from "./modules/property"
6 6 import Community from "./modules/community"
  7 +import OwnerManagement from "./modules/ownerManagement"
7 8 import Layout from '@/layout/enter.vue'
8 9 const routes: Array<any> = [
9 10 { path: '/', redirect: { path: '/dashboard' } },
... ... @@ -42,7 +43,7 @@ const routes: Array&lt;any&gt; = [
42 43 Resident,
43 44 Property,
44 45 Community,
45   -
  46 + OwnerManagement,
46 47 {
47 48 path: '/login',
48 49 name: 'Login',
... ...
src/router/modules/ownerManagement.ts 0 → 100644
  1 +
  2 +import Layout from '@/layout/enter.vue'
  3 +const OwnerManagement = {
  4 + path: '/',
  5 + component: Layout,
  6 + name: 'Owner',
  7 + children: [{
  8 + path: 'owner',
  9 + name: 'owner',
  10 + component: () => import('@/views/ownerManagement/owner/index.vue'),
  11 + meta: { title: '业主管理' }
  12 + }
  13 + ]
  14 +}
  15 +
  16 +export default OwnerManagement
... ...
src/views/community/housekeeper/houseDetail.vue
1 1 <script setup lang="ts">
2 2 import { reactive, ref, onMounted, getCurrentInstance } from "vue";
3   -import type { ElForm } from "element-plus";
4 3 import { addOrUpdate } from "@/api/community/housekeeper.ts";
5 4 import { getTableList } from "@/api/community/residence.ts";
6 5  
7 6 const ruleFormRef = ref<InstanceType<typeof ElForm>>();
8 7 let instance: ComponentInternalInstance | null = getCurrentInstance(); //获取app实例
  8 +
  9 +
9 10 // 声明props
10 11 const props = defineProps({
11 12 formObj: {
... ... @@ -111,12 +112,14 @@ let submitForm = (formEl: InstanceType&lt;typeof ElForm&gt; | undefined) =&gt; {
111 112 if (valid) {
112 113 console.log("111");
113 114 addOrUpdate(props.formObj).then((res) => {
114   - console.log(res);
  115 + console.log(111)
  116 + loading.value = false;
115 117 emit("success");
116   - });
  118 + }).catch((err) => {
  119 + console.log(err)
  120 + })
117 121 } else {
118 122 instance?.proxy?.$message.error("请完善信息"); //调用
119   -
120 123 loading.value = false;
121 124 return false;
122 125 }
... ...
src/views/community/housekeeper/index.vue
1 1 <script setup lang="ts">
2   -import { reactive, onMounted } from "vue";
3   -import { getTableList, deleteBuilding,getCurrentInstance } from "@/api/community/housekeeper.ts";
  2 +import { reactive, onMounted, getCurrentInstance } from "vue";
  3 +import { getTableList, deleteBuilding } from "@/api/community/housekeeper.ts";
4 4 import { parseTime } from "@/utils/tool.ts";
5 5 import HouseDetail from "./houseDetail.vue";
6 6 import Pagination from "@/components/Pagination/index.vue";
  7 +import { useRoute } from "vue-router";
  8 +
  9 +let instance: ComponentInternalInstance | null = getCurrentInstance(); //获取app实例
  10 +
  11 +let route = useRoute(); // 路由
7 12  
8   -let instance: ComponentInternalInstance | null = getCurrentInstance();//获取app实例
9 13 // 数据筛选
10 14 const searchData = reactive({
11 15 neighborhoodId: null,
... ... @@ -55,10 +59,18 @@ const edit = (row: Object) =&gt; {
55 59 * @param { number } buildingId 楼宇ID
56 60 */
57 61 const remove = (buildingId: number) => {
58   - deleteBuilding({ buildingId: buildingId }).then((res) => {
59   - instance?.proxy?.$message.success('操作成功')//调用
60   - search();
61   - });
  62 + instance?.proxy?.$messageBox
  63 + .confirm("确认要进行此操作?", "提示", {
  64 + confirmButtonText: "确定",
  65 + cancelButtonText: "取消",
  66 + })
  67 + .then(() => {
  68 + deleteBuilding({ buildingId: buildingId }).then((res) => {
  69 + instance?.proxy?.$message.success("操作成功"); //调用
  70 + search();
  71 + });
  72 + })
  73 + .catch((err) => {});
62 74 };
63 75 /**
64 76 * 组件操作成功回调
... ... @@ -75,6 +87,9 @@ const dialogClose: void = () =&gt; {
75 87 data.formObj = {};
76 88 };
77 89 onMounted(() => {
  90 + searchData.neighborhoodId = route.query.neighborhoodId
  91 + ? route.query.neighborhoodId
  92 + : null;
78 93 search();
79 94 });
80 95 </script>
... ... @@ -97,8 +112,8 @@ onMounted(() =&gt; {
97 112 >
98 113 <el-row>
99 114 <el-form-item>
100   - <el-button type="primary">导入</el-button>
101   - <el-button type="primary">导出</el-button>
  115 + <!-- <el-button type="primary">导入</el-button>
  116 + <el-button type="primary">导出</el-button> -->
102 117 <el-button type="primary" @click="data.dialogVisible = true"
103 118 >新增</el-button
104 119 >
... ...
src/views/community/residence/communityDetail.vue
1 1 <script setup lang="ts">
2 2 import { reactive, ref, onMounted,getCurrentInstance } from "vue";
3 3 import type { ElForm } from "element-plus";
4   -import { ElMessage } from "element-plus";
5 4 import { addOrUpdate } from "@/api/community/residence.ts";
  5 +
6 6 const ruleFormRef = ref<InstanceType<typeof ElForm>>();
7 7 let instance: ComponentInternalInstance | null = getCurrentInstance();//获取app实例
8 8 // 声明props
... ... @@ -84,6 +84,7 @@ let submitForm = (formEl: InstanceType&lt;typeof ElForm&gt; | undefined) =&gt; {
84 84 if (valid) {
85 85 console.log("111")
86 86 addOrUpdate(props.formObj).then((res) => {
  87 + loading.value = false;
87 88 emit("success");
88 89 });
89 90 } else {
... ...
src/views/community/residence/index.vue
1 1 <script setup lang="ts">
2   -import { reactive, onMounted,getCurrentInstance } from "vue";
  2 +import { reactive, onMounted, getCurrentInstance } from "vue";
3 3 import { getTableList, deleteNeighborhood } from "@/api/community/residence.ts";
4 4 import CommunityDetail from "./communityDetail.vue";
5 5 import Pagination from "@/components/Pagination/index.vue";
6 6  
7   -let instance: ComponentInternalInstance | null = getCurrentInstance();//获取app实例
  7 +let instance: ComponentInternalInstance | null = getCurrentInstance(); //获取app实例
8 8 // 数据筛选
9 9 const searchData = reactive({
10   - propertyId: 1,
11 10 type: 0,
12 11 name: null,
13 12 pageNum: 1,
... ... @@ -45,6 +44,7 @@ const search = (): void =&gt; {
45 44 * @param { Object } 列表对象
46 45 */
47 46 const edit = (row: Object) => {
  47 + data.title = "编辑小区";
48 48 data.formObj = row;
49 49 data.dialogVisible = true;
50 50 };
... ... @@ -53,10 +53,18 @@ const edit = (row: Object) =&gt; {
53 53 * @param { number } neighborhoodId 小区ID
54 54 */
55 55 const remove = (neighborhoodId: number) => {
56   - deleteNeighborhood({ neighborhoodId: neighborhoodId }).then((res) => {
57   - instance?.proxy?.$message.success('操作成功')//调用
58   - search();
59   - });
  56 + instance?.proxy?.$messageBox
  57 + .confirm("确认要进行此操作?", "提示", {
  58 + confirmButtonText: "确定",
  59 + cancelButtonText: "取消",
  60 + })
  61 + .then(() => {
  62 + deleteNeighborhood({ neighborhoodId: neighborhoodId }).then((res) => {
  63 + instance?.proxy?.$message.success("操作成功"); //调用
  64 + search();
  65 + });
  66 + })
  67 + .catch((err) => {});
60 68 };
61 69 /**
62 70 * 组件操作成功回调
... ... @@ -70,6 +78,7 @@ const changeData: void = () =&gt; {
70 78 * 弹框关闭
71 79 */
72 80 const dialogClose: void = () => {
  81 + data.title = "新增小区";
73 82 data.formObj = {};
74 83 };
75 84 onMounted(() => {
... ... @@ -82,7 +91,7 @@ onMounted(() =&gt; {
82 91 <el-form :inline="true" :model="searchData" v-loading="data.loading">
83 92 <el-form-item>
84 93 <el-input
85   - placeholder="请输入社区名称"
  94 + placeholder="输入小区名称"
86 95 v-model="searchData.name"
87 96 clearable
88 97 ></el-input>
... ... @@ -94,8 +103,8 @@ onMounted(() =&gt; {
94 103 >
95 104 <el-row>
96 105 <el-form-item>
97   - <el-button type="primary">导入</el-button>
98   - <el-button type="primary">导出</el-button>
  106 + <!-- <el-button type="primary">导入</el-button>
  107 + <el-button type="primary">导出</el-button> -->
99 108 <el-button type="primary" @click="data.dialogVisible = true"
100 109 >新增</el-button
101 110 >
... ... @@ -119,7 +128,14 @@ onMounted(() =&gt; {
119 128 <el-button type="text" size="mini" @click="remove(scope.row.id)"
120 129 >删除</el-button
121 130 >
122   - <el-button type="text" size="mini">楼宇管理</el-button>
  131 + <router-link
  132 + :to="{
  133 + name: 'housekeeper',
  134 + query: { neighborhoodId: scope.row.id },
  135 + }"
  136 + >
  137 + <el-button type="text" size="mini">楼宇管理</el-button></router-link
  138 + >
123 139 </template>
124 140 </el-table-column>
125 141 </el-table>
... ...
src/views/ownerManagement/owner/index.vue 0 → 100644
  1 +<script setup lang="ts">
  2 +import { reactive, onMounted, getCurrentInstance } from "vue";
  3 +import { getTableList } from "@/api/ownerManagement/owner.ts";
  4 +// import CommunityDetail from "./communityDetail.vue";
  5 +import Pagination from "@/components/Pagination/index.vue";
  6 +
  7 +let instance: ComponentInternalInstance | null = getCurrentInstance(); //获取app实例
  8 +// 数据筛选
  9 +const searchData = reactive({
  10 + isOwner: null,
  11 + pageNum: 1,
  12 + pageSize: 10,
  13 +});
  14 +// 展示
  15 +const data = reactive({
  16 + total: 0,
  17 + tableList: [],
  18 + dialogVisible: false,
  19 + loading: false,
  20 + title: "新增小区",
  21 + formObj: {},
  22 +});
  23 +
  24 +/**
  25 + * 列表查询
  26 + */
  27 +const search = (): void => {
  28 + data.loading = true;
  29 + getTableList(searchData)
  30 + .then((res) => {
  31 + data.tableList = res.data.data.list;
  32 + data.total = res.data.data.total;
  33 + searchData.pageSize = res.data.data.pageSize;
  34 + data.loading = false;
  35 + })
  36 + .catch((err) => {
  37 + console.log(err);
  38 + data.loading = false;
  39 + });
  40 +};
  41 +/**
  42 + * 编辑
  43 + * @param { Object } 列表对象
  44 + */
  45 +const edit = (row: Object) => {
  46 + data.formObj = row;
  47 + data.dialogVisible = true;
  48 +};
  49 +/**
  50 + * 删除
  51 + * @param { number } neighborhoodId 小区ID
  52 + */
  53 +const remove = (neighborhoodId: number) => {
  54 + // deleteNeighborhood({ neighborhoodId: neighborhoodId }).then((res) => {
  55 + // instance?.proxy?.$message.success('操作成功')//调用
  56 + // search();
  57 + // });
  58 +};
  59 +/**
  60 + * 组件操作成功回调
  61 + */
  62 +const changeData: void = () => {
  63 + data.dialogVisible = false;
  64 + search();
  65 +};
  66 +
  67 +/**
  68 + * 弹框关闭
  69 + */
  70 +const dialogClose: void = () => {
  71 + data.formObj = {};
  72 +};
  73 +onMounted(() => {
  74 + console.log("11");
  75 + search();
  76 +});
  77 +</script>
  78 +<template>
  79 + <div class="app-container">
  80 + <!-- 搜索 -->
  81 + <el-form :inline="true" :model="searchData" v-loading="data.loading">
  82 + <el-form-item>
  83 + <el-input
  84 + placeholder="请输入社区名称"
  85 + v-model="searchData.name"
  86 + clearable
  87 + ></el-input>
  88 + </el-form-item>
  89 + <el-form-item
  90 + ><el-button type="primary" @click="search"
  91 + >查询</el-button
  92 + ></el-form-item
  93 + >
  94 + <el-row>
  95 + <el-form-item>
  96 + <el-button type="primary">导入</el-button>
  97 + <el-button type="primary">导出</el-button>
  98 + <el-button type="primary" @click="data.dialogVisible = true"
  99 + >新增</el-button
  100 + >
  101 + </el-form-item>
  102 + </el-row>
  103 + </el-form>
  104 +
  105 + <!-- 表格 -->
  106 + <el-table border :data="data.tableList">
  107 + <el-table-column label="小区名称" prop="name"></el-table-column>
  108 + <el-table-column label="楼座数" prop="buildingCount"></el-table-column>
  109 + <el-table-column label="储藏室数" prop="storeroomCount"></el-table-column>
  110 + <el-table-column label="车位数" prop="truckSpaceCount"></el-table-column>
  111 + <el-table-column label="所在地区" prop="locality"></el-table-column>
  112 + <el-table-column label="详细地址" prop="address"></el-table-column>
  113 + <el-table-column label="操作">
  114 + <template #default="scope">
  115 + <el-button type="text" size="mini" @click="edit(scope.row)"
  116 + >编辑</el-button
  117 + >
  118 + <el-button type="text" size="mini" @click="remove(scope.row.id)"
  119 + >删除</el-button
  120 + >
  121 + <el-button type="text" size="mini">楼宇管理</el-button>
  122 + </template>
  123 + </el-table-column>
  124 + </el-table>
  125 +
  126 + <!-- 分页 -->
  127 + <Pagination
  128 + v-if="data.total > 0"
  129 + :total="data.total"
  130 + :currentPage="searchData.pageNum"
  131 + :pageSize="searchData.pageSize"
  132 + @pageChange="search"
  133 + ></Pagination>
  134 +
  135 + <!-- 详情弹框 -->
  136 + <!-- <el-dialog
  137 + v-model="data.dialogVisible"
  138 + :title="data.title"
  139 + width="30%"
  140 + @close="dialogClose"
  141 + > -->
  142 + <!-- <CommunityDetail
  143 + @cancel="data.dialogVisible = false"
  144 + @success="changeData"
  145 + :formObj="data.formObj"
  146 + ></CommunityDetail> -->
  147 + <!-- </el-dialog> -->
  148 + </div>
  149 +</template>
  150 +
  151 +<style></style>
... ...