Commit 34615b132562dc4a66199ff7e0e2a9f318a6fc9f

Authored by 杨泽宇
1 parent 3be06ee0

debug notify

src/router/index.ts
... ... @@ -10,6 +10,11 @@ import OwnerManagement from "./modules/ownerManagement"
10 10 import Housekeeper from "./modules/housekeeper"
11 11 import Layout from '@/layout/enter.vue'
12 12 const routes: Array<any> = [
  13 + {
  14 + path: '/login',
  15 + name: 'Login',
  16 + component: () => import(/* webpackChunkName: "About" */ '@/views/user/login.vue')
  17 + },
13 18 { path: '/', redirect: { path: '/dashboard' } },
14 19 {
15 20 path: '/',
... ... @@ -32,11 +37,6 @@ const routes: Array&lt;any&gt; = [
32 37 OwnerManagement,
33 38 Housekeeper,
34 39 {
35   - path: '/login',
36   - name: 'Login',
37   - component: () => import(/* webpackChunkName: "About" */ '@/views/user/login.vue')
38   - },
39   - {
40 40 path: '/404',
41 41 name: 'Error',
42 42 component: () => import(/* webpackChunkName: "Error" */ '@/views/error/404.vue'),
... ...
src/views/dashboard/index.vue
1 1 <script setup lang="ts">
2   -import {ref} from 'vue'
3   -import {propertyList } from '@/api/property'
4   -import router from '@/router'
  2 +import { ref } from "vue";
  3 +import { propertyList } from "@/api/property";
  4 +import router from "@/router";
5 5 import * as store from "@/pinia/index";
6   -const title = ref(import.meta.env.VITE_APP_TITLE).value
7   -// propertyList().then(res => {
8   -// console.log(res)
9   -// }).catch(error => {
10   -// console.log(error)
11   -// })
12   -console.log(router.getRoutes())
  6 +const title = ref(import.meta.env.VITE_APP_TITLE).value;
  7 +propertyList()
  8 + .then((res) => {
  9 + console.log(res);
  10 + })
  11 + .catch((error) => {
  12 + console.log(error);
  13 + });
  14 +console.log(router.getRoutes());
13 15 </script>
14 16  
15 17 <template>
16 18 <div class="dashboard-container">
17 19 <div class="dashboard-logo"></div>
18   - <h1>欢迎访问 -- {{title}}</h1>
  20 + <h1>欢迎访问 -- {{ title }}</h1>
  21 + <!-- {{ store.family }}
  22 + {{ store.family.menuStore() }}
  23 + {{ store.family.menuStore().menuList }} -->
19 24 </div>
20 25 </template>
21 26  
... ... @@ -28,11 +33,11 @@ console.log(router.getRoutes())
28 33 text-align: center;
29 34 }
30 35 &-logo {
31   - width: 200px;
32   - height: 200px;
  36 + width: 200px;
  37 + height: 200px;
33 38 margin: 0 auto;
34   - background-color: pink;
35   - background-image: url('@/assets/logo.png');
  39 + background-color: pink;
  40 + background-image: url("@/assets/logo.png");
36 41 background-repeat: no-repeat;
37 42 background-size: contain;
38 43 background-position: 0;
... ...
src/views/notify/edit.vue
... ... @@ -5,11 +5,12 @@ import { getTableList } from &quot;@/api/community/residence&quot;;
5 5 import { useRoute } from "vue-router";
6 6 import { back } from "@/utils/tool";
7 7 import * as store from "@/pinia/index";
  8 +import { ElMessageBox } from "element-plus";
8 9 import type { ElForm } from "element-plus";
9 10 let form = reactive({
10 11 data: {
11 12 title: "",
12   - status: "0",
  13 + status: null,
13 14 oId: store?.family?.loginStore()?.organizationId,
14 15 neighborHoodId: null,
15 16 neighborHoodName: "",
... ... @@ -40,13 +41,6 @@ const rules = reactive({
40 41 trigger: "change",
41 42 },
42 43 ],
43   - status: [
44   - {
45   - required: true,
46   - message: "请选择发布类型",
47   - trigger: "change",
48   - },
49   - ],
50 44 });
51 45 /**
52 46 * 表单重置
... ... @@ -58,20 +52,33 @@ const resetForm = (formEl: InstanceType&lt;typeof ElForm&gt; | undefined) =&gt; {
58 52 /**
59 53 * 表单提交
60 54 */
61   -const submitForm = (formEl: InstanceType<typeof ElForm> | undefined) => {
  55 +const submitForm = (
  56 + formEl: InstanceType<typeof ElForm> | undefined,
  57 + type: number
  58 +) => {
62 59 if (!formEl) return;
63 60 formEl.validate(async (valid) => {
64 61 if (valid) {
65   - notifyAdd(form.data)
66   - .then((res) => {
67   - if (res) {
68   - instance?.proxy?.$message.success("操作成功");
69   - history.go(-1);
  62 + form.data.status = type;
  63 + if (type) {
  64 + ElMessageBox.confirm(
  65 + "是否确定发布?(确认发布后将不可进行修改)",
  66 + "提示",
  67 + {
  68 + confirmButtonText: "确认",
  69 + cancelButtonText: "取消",
  70 + type: "warning",
70 71 }
71   - })
72   - .catch((error) => {
73   - console.log(error);
74   - });
  72 + )
  73 + .then((res) => {
  74 + postApi(type);
  75 + })
  76 + .catch((error) => {
  77 + console.log(error);
  78 + });
  79 + } else {
  80 + postApi(type);
  81 + }
75 82 } else {
76 83 instance?.proxy?.$message.error("请检查表单格式");
77 84 return false;
... ... @@ -79,6 +86,22 @@ const submitForm = (formEl: InstanceType&lt;typeof ElForm&gt; | undefined) =&gt; {
79 86 });
80 87 };
81 88 /**
  89 + * 表单提交接口
  90 + * @param {number} type 1发布 0存草稿
  91 + */
  92 +const postApi = async (type: number) => {
  93 + notifyAdd(form.data)
  94 + .then((res) => {
  95 + if (res) {
  96 + instance?.proxy?.$message.success(type ? "发布成功" : "已存为草稿");
  97 + history.go(-1);
  98 + }
  99 + })
  100 + .catch((error) => {
  101 + console.log(error);
  102 + });
  103 +};
  104 +/**
82 105 * 选小区,给小区名赋值
83 106 * @param {number | null} data 选中的小区id
84 107 */
... ... @@ -163,15 +186,12 @@ onMounted(() =&gt; {
163 186 show-word-limit
164 187 />
165 188 </el-form-item>
166   - <el-form-item label="发布类型" prop="status" style="width: 100%">
167   - <el-radio-group v-model="form.data.status">
168   - <el-radio label="0">存草稿</el-radio>
169   - <el-radio label="1">发布</el-radio>
170   - </el-radio-group>
171   - </el-form-item>
172 189 <el-form-item style="width: 100%" v-show="form.dataType !== 'detail'">
173   - <el-button type="primary" @click="submitForm(ruleFormRef)"
174   - >提交</el-button
  190 + <el-button type="primary" @click="submitForm(ruleFormRef, 1)"
  191 + >发布</el-button
  192 + >
  193 + <el-button type="primary" @click="submitForm(ruleFormRef, 0)"
  194 + >存为草稿</el-button
175 195 >
176 196 <el-button
177 197 type="info"
... ...
src/views/notify/index.vue
... ... @@ -93,6 +93,13 @@ const handleTimeChange = (value: array) =&gt; {
93 93 getList();
94 94 };
95 95 /**
  96 + * 表格每一行是否可选中
  97 + * @param {array} row 每一行数据对象
  98 + */
  99 +const isSelectable = (row: any) => {
  100 + return row.status === 0;
  101 +};
  102 +/**
96 103 * 删除
97 104 * @param {object} obj 要删除的数据对象
98 105 */
... ... @@ -176,7 +183,11 @@ onMounted(() =&gt; {
176 183 ref="multipleTableRef"
177 184 @selection-change="handleSelectionChange"
178 185 >
179   - <el-table-column type="selection" align="center" />
  186 + <el-table-column
  187 + type="selection"
  188 + align="center"
  189 + :selectable="isSelectable"
  190 + />
180 191 <el-table-column prop="id" label="ID" align="center"></el-table-column>
181 192 <el-table-column
182 193 prop="title"
... ... @@ -204,8 +215,9 @@ onMounted(() =&gt; {
204 215 </template>
205 216 </el-table-column>
206 217 <el-table-column label="操作" align="center">
  218 + <!-- 已发布状态的公告不可以被修改、删除 -->
207 219 <template #default="scope">
208   - <el-button type="text"
  220 + <el-button type="text" v-show="scope.row.status === 0"
209 221 ><router-link
210 222 :to="{
211 223 path: '/notify/edit',
... ... @@ -223,7 +235,10 @@ onMounted(() =&gt; {
223 235 >详情</router-link
224 236 ></el-button
225 237 >
226   - <el-button type="text" @click="handleDelete(scope.row)"
  238 + <el-button
  239 + type="text"
  240 + @click="handleDelete(scope.row)"
  241 + v-show="scope.row.status === 0"
227 242 >删除</el-button
228 243 >
229 244 </template>
... ...
src/views/property/index.vue
1 1 <script setup lang="ts">
2 2 import { reactive, ref, onMounted, getCurrentInstance } from "vue";
3 3 import { propertyList, propertyStatus } from "@/api/property";
4   -import { userProxy } from '@/api/user/user';
  4 +import { userProxy } from "@/api/user/user";
5 5 import { menuData } from "@/api/user/login";
6 6 import * as store from "@/pinia/index";
7 7 import { parseTime } from "@/utils/tool";
... ... @@ -68,7 +68,7 @@ const handleSearch = () =&gt; {
68 68 };
69 69 /**
70 70 * 切换状态
71   - * @param {object} 单条数据对象
  71 + * @param {object} 单条数据对象
72 72 */
73 73 const handleStatus = async (obj) => {
74 74 try {
... ... @@ -91,23 +91,23 @@ const handleStatus = async (obj) =&gt; {
91 91 * @param {object} 单条数据对象
92 92 */
93 93 const handleProxy = (obj) => {
94   - userProxy({oId: obj.id}).then(res => {
95   - if(res?.data) {
96   - console.log('代理成功的回调')
97   - console.log(res.data)
  94 + userProxy({ oId: obj.id }).then((res) => {
  95 + if (res?.data) {
  96 + console.log("代理成功的回调");
  97 + console.log(res.data);
98 98 globalProperties.$message.success("代理成功");
99 99 getMenu().then(() => {
100   - console.log('got menu data')
  100 + console.log("got menu data");
101 101 setTimeout(() => {
102   - location.href = '/'
103   - console.log('跳')
104   - }, 2000)
105   - })
  102 + // location.href = '/'
  103 + console.log("跳");
  104 + }, 2000);
  105 + });
106 106 } else {
107 107 globalProperties.$message.error("代理失败");
108 108 }
109   - })
110   -}
  109 + });
  110 +};
111 111 /**
112 112 * 获取权限菜单
113 113 */
... ... @@ -121,7 +121,7 @@ const getMenu = async () =&gt; {
121 121 };
122 122 /**
123 123 * 状态值
124   - * @enum {number}
  124 + * @enum {number}
125 125 */
126 126 enum statusEnum {
127 127 "禁用" = 0,
... ... @@ -205,7 +205,9 @@ onMounted(() =&gt; {
205 205 >编辑</router-link
206 206 ></el-button
207 207 >
208   - <el-button type="text" @click="handleProxy(scope.row)">代理登录</el-button>
  208 + <el-button type="text" @click="handleProxy(scope.row)"
  209 + >代理登录</el-button
  210 + >
209 211 <el-button type="text" @click="handleStatus(scope.row)">{{
210 212 scope.row.status ? "禁用" : "启用"
211 213 }}</el-button>
... ...