Commit e979bb4e9acc16390351a92aa218bdffe84ca11b
Merge branch 'dev' of http://bj.gitlab.cnlive.com/cnlive_project/cnlive-community-web-vue into dev
Showing
13 changed files
with
613 additions
and
47 deletions
src/api/notify/index.ts
0 → 100644
| 1 | +import request from '../request' | ||
| 2 | +import { deleteEmptyParam } from '@/utils/tool' | ||
| 3 | + | ||
| 4 | +/** | ||
| 5 | + * @description 公告列表 | ||
| 6 | + * @function notifyList | ||
| 7 | + */ | ||
| 8 | +export const notifyList = async ( params: any ) => { | ||
| 9 | + let res: any = await request.get( '/notify/list', deleteEmptyParam(params) ) | ||
| 10 | + return res | ||
| 11 | +} | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * @description 公告详情 | ||
| 15 | + * @function notifyDetail | ||
| 16 | + */ | ||
| 17 | + export const notifyDetail = async ( params: any ) => { | ||
| 18 | + let res: any = await request.get( '/notify/getNotify', {params} ) | ||
| 19 | + return res | ||
| 20 | +} | ||
| 21 | + | ||
| 22 | +/** | ||
| 23 | + * @description 新增公告 | ||
| 24 | + * @function notifyAdd | ||
| 25 | + */ | ||
| 26 | +export function notifyAdd (data: any) { | ||
| 27 | + return request({ | ||
| 28 | + method: 'post', | ||
| 29 | + url: '/notify/add', | ||
| 30 | + data: data | ||
| 31 | + }) | ||
| 32 | +} | ||
| 33 | + | ||
| 34 | +/** | ||
| 35 | + * @description 删除公告 | ||
| 36 | + * @function notifyDelete | ||
| 37 | + */ | ||
| 38 | +export function notifyDelete (params: any) { | ||
| 39 | + return request({ | ||
| 40 | + method: 'delete', | ||
| 41 | + url: '/notify/deleteNotify', | ||
| 42 | + params: params | ||
| 43 | + }) | ||
| 44 | +} | ||
| 0 | \ No newline at end of file | 45 | \ No newline at end of file |
src/api/user/user/index.ts
| 1 | import request from '../../request' | 1 | import request from '../../request' |
| 2 | -import {formDataWrapper} from '@/utils/tool' | 2 | +import { formDataWrapper, deleteEmptyParam } from '@/utils/tool' |
| 3 | 3 | ||
| 4 | /** | 4 | /** |
| 5 | * @description 用户列表 | 5 | * @description 用户列表 |
| @@ -9,7 +9,7 @@ export const userList = async ( params: any ) => { | @@ -9,7 +9,7 @@ export const userList = async ( params: any ) => { | ||
| 9 | let res: any = await request({ | 9 | let res: any = await request({ |
| 10 | url: '/user/list', | 10 | url: '/user/list', |
| 11 | method: 'get', | 11 | method: 'get', |
| 12 | - params: params | 12 | + params: deleteEmptyParam(params) |
| 13 | }) | 13 | }) |
| 14 | return res | 14 | return res |
| 15 | } | 15 | } |
src/layout/header.vue
| @@ -70,11 +70,9 @@ onMounted(() => { | @@ -70,11 +70,9 @@ onMounted(() => { | ||
| 70 | <!-- TIP 控制菜单collapse的按钮结束 --> | 70 | <!-- TIP 控制菜单collapse的按钮结束 --> |
| 71 | <!-- TIP 功能键 --> | 71 | <!-- TIP 功能键 --> |
| 72 | <div class="right-buttons"> | 72 | <div class="right-buttons"> |
| 73 | - <el-button type="text">站内消息</el-button> | ||
| 74 | <el-button type="text"><router-link to="/">首页</router-link></el-button> | 73 | <el-button type="text"><router-link to="/">首页</router-link></el-button> |
| 75 | - <el-button type="text">帮助</el-button> | ||
| 76 | <el-button type="text" | 74 | <el-button type="text" |
| 77 | - >当前用户:<b>{{ asyncData.userInfo }}</b></el-button | 75 | + >当前用户:<b>{{ asyncData.userInfo? asyncData.userInfo: '超级管理员' }}</b></el-button |
| 78 | > | 76 | > |
| 79 | <el-button type="text" @click="handleLogout">退出</el-button> | 77 | <el-button type="text" @click="handleLogout">退出</el-button> |
| 80 | </div> | 78 | </div> |
src/pinia/modules/login.ts
| @@ -3,12 +3,15 @@ import { logout } from '@/api/user/login'; | @@ -3,12 +3,15 @@ import { logout } from '@/api/user/login'; | ||
| 3 | import { ElMessage } from "element-plus"; | 3 | import { ElMessage } from "element-plus"; |
| 4 | interface LoginUser { | 4 | interface LoginUser { |
| 5 | token: string, | 5 | token: string, |
| 6 | - organizationId: number, | ||
| 7 | - id: number, | 6 | + organizationId?: number, |
| 7 | + id?: number, | ||
| 8 | userName: string, | 8 | userName: string, |
| 9 | - organizationType: number | null, | 9 | + organizationType?: number | null, |
| 10 | organizationName: string, | 10 | organizationName: string, |
| 11 | - organizationLogo: string | 11 | + organizationLogo: string, |
| 12 | + oId?: number, | ||
| 13 | + userId?: number, | ||
| 14 | + oType?: number | ||
| 12 | } | 15 | } |
| 13 | const id: string = 'login' | 16 | const id: string = 'login' |
| 14 | const state: Function = () => ({ | 17 | const state: Function = () => ({ |
| @@ -53,11 +56,11 @@ const getters = { | @@ -53,11 +56,11 @@ const getters = { | ||
| 53 | const actions = { | 56 | const actions = { |
| 54 | setUserInfo(obj: LoginUser) { | 57 | setUserInfo(obj: LoginUser) { |
| 55 | this.token = obj.token | 58 | this.token = obj.token |
| 56 | - this.organizationId = obj.organizationId | ||
| 57 | - this.id = obj.id | 59 | + this.organizationId = obj.organizationId? obj.organizationId: obj.oId |
| 60 | + this.id = obj.id? obj.id: obj.userId | ||
| 58 | this.userName = obj.userName | 61 | this.userName = obj.userName |
| 59 | this.organizationName = obj.organizationName | 62 | this.organizationName = obj.organizationName |
| 60 | - this.organizationType = obj.organizationType | 63 | + this.organizationType = obj.organizationType? obj.organizationType: obj.oType |
| 61 | this.organizationLogo = obj.organizationLogo | 64 | this.organizationLogo = obj.organizationLogo |
| 62 | }, | 65 | }, |
| 63 | removeToken(msg: string | null) { | 66 | removeToken(msg: string | null) { |
src/router/index.ts
| 1 | import { createRouter, createWebHashHistory } from 'vue-router' | 1 | import { createRouter, createWebHashHistory } from 'vue-router' |
| 2 | +import Notify from './modules/notify' | ||
| 2 | import System from './modules/system' | 3 | import System from './modules/system' |
| 3 | import Permission from './modules/permission' | 4 | import Permission from './modules/permission' |
| 4 | import Role from "./modules/role" | 5 | import Role from "./modules/role" |
| @@ -9,6 +10,11 @@ import OwnerManagement from "./modules/ownerManagement" | @@ -9,6 +10,11 @@ import OwnerManagement from "./modules/ownerManagement" | ||
| 9 | import Housekeeper from "./modules/housekeeper" | 10 | import Housekeeper from "./modules/housekeeper" |
| 10 | import Layout from '@/layout/enter.vue' | 11 | import Layout from '@/layout/enter.vue' |
| 11 | const routes: Array<any> = [ | 12 | const routes: Array<any> = [ |
| 13 | + { | ||
| 14 | + path: '/login', | ||
| 15 | + name: 'Login', | ||
| 16 | + component: () => import(/* webpackChunkName: "About" */ '@/views/user/login.vue') | ||
| 17 | + }, | ||
| 12 | { path: '/', redirect: { path: '/dashboard' } }, | 18 | { path: '/', redirect: { path: '/dashboard' } }, |
| 13 | { | 19 | { |
| 14 | path: '/', | 20 | path: '/', |
| @@ -21,6 +27,7 @@ const routes: Array<any> = [ | @@ -21,6 +27,7 @@ const routes: Array<any> = [ | ||
| 21 | meta: { title: '欢迎访问' } | 27 | meta: { title: '欢迎访问' } |
| 22 | }] | 28 | }] |
| 23 | }, | 29 | }, |
| 30 | + Notify, | ||
| 24 | System, | 31 | System, |
| 25 | Permission, | 32 | Permission, |
| 26 | Role, | 33 | Role, |
| @@ -30,11 +37,6 @@ const routes: Array<any> = [ | @@ -30,11 +37,6 @@ const routes: Array<any> = [ | ||
| 30 | OwnerManagement, | 37 | OwnerManagement, |
| 31 | Housekeeper, | 38 | Housekeeper, |
| 32 | { | 39 | { |
| 33 | - path: '/login', | ||
| 34 | - name: 'Login', | ||
| 35 | - component: () => import(/* webpackChunkName: "About" */ '@/views/user/login.vue') | ||
| 36 | - }, | ||
| 37 | - { | ||
| 38 | path: '/404', | 40 | path: '/404', |
| 39 | name: 'Error', | 41 | name: 'Error', |
| 40 | component: () => import(/* webpackChunkName: "Error" */ '@/views/error/404.vue'), | 42 | component: () => import(/* webpackChunkName: "Error" */ '@/views/error/404.vue'), |
src/router/modules/notify.ts
0 → 100644
| 1 | +import Layout from '@/layout/enter.vue' | ||
| 2 | +const notify = { | ||
| 3 | + path: '/', | ||
| 4 | + component: Layout, | ||
| 5 | + name: 'Notify', | ||
| 6 | + children: [{ | ||
| 7 | + path: 'notify', | ||
| 8 | + name: 'notify', | ||
| 9 | + component: () => import('@/views/notify/index.vue'), | ||
| 10 | + meta: { title: '公告管理' } | ||
| 11 | + }, { | ||
| 12 | + path: '/notify/edit', | ||
| 13 | + name: 'notifyEdit', | ||
| 14 | + component: () => import('@/views/notify/edit.vue'), | ||
| 15 | + meta: { title: '公告编辑' } | ||
| 16 | + }] | ||
| 17 | +} | ||
| 18 | + | ||
| 19 | +export default notify |
src/views/dashboard/index.vue
| 1 | <script setup lang="ts"> | 1 | <script setup lang="ts"> |
| 2 | -import {ref} from 'vue' | ||
| 3 | -import {propertyList } from '@/api/property' | ||
| 4 | -import router from '@/router' | ||
| 5 | -const title = ref(import.meta.env.VITE_APP_TITLE).value | ||
| 6 | -// propertyList().then(res => { | ||
| 7 | -// console.log(res) | ||
| 8 | -// }).catch(error => { | ||
| 9 | -// console.log(error) | ||
| 10 | -// }) | ||
| 11 | -console.log(router.getRoutes()) | 2 | +import { ref } from "vue"; |
| 3 | +import { propertyList } from "@/api/property"; | ||
| 4 | +import router from "@/router"; | ||
| 5 | +import * as store from "@/pinia/index"; | ||
| 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()); | ||
| 12 | </script> | 15 | </script> |
| 13 | 16 | ||
| 14 | <template> | 17 | <template> |
| 15 | <div class="dashboard-container"> | 18 | <div class="dashboard-container"> |
| 16 | <div class="dashboard-logo"></div> | 19 | <div class="dashboard-logo"></div> |
| 17 | - <h1>欢迎访问 -- {{title}}</h1> | 20 | + <h1>欢迎访问 -- {{ title }}</h1> |
| 21 | + <!-- {{ store.family }} | ||
| 22 | + {{ store.family.menuStore() }} | ||
| 23 | + {{ store.family.menuStore().menuList }} --> | ||
| 18 | </div> | 24 | </div> |
| 19 | </template> | 25 | </template> |
| 20 | 26 | ||
| @@ -27,11 +33,11 @@ console.log(router.getRoutes()) | @@ -27,11 +33,11 @@ console.log(router.getRoutes()) | ||
| 27 | text-align: center; | 33 | text-align: center; |
| 28 | } | 34 | } |
| 29 | &-logo { | 35 | &-logo { |
| 30 | - width: 200px; | ||
| 31 | - height: 200px; | 36 | + width: 200px; |
| 37 | + height: 200px; | ||
| 32 | margin: 0 auto; | 38 | margin: 0 auto; |
| 33 | - background-color: pink; | ||
| 34 | - background-image: url('@/assets/logo.png'); | 39 | + background-color: pink; |
| 40 | + background-image: url("@/assets/logo.png"); | ||
| 35 | background-repeat: no-repeat; | 41 | background-repeat: no-repeat; |
| 36 | background-size: contain; | 42 | background-size: contain; |
| 37 | background-position: 0; | 43 | background-position: 0; |
src/views/notify/edit.vue
0 → 100644
| 1 | +<script setup lang="ts"> | ||
| 2 | +import { reactive, ref, getCurrentInstance, onMounted } from "vue"; | ||
| 3 | +import { notifyAdd, notifyDetail } from "@/api/notify"; | ||
| 4 | +import { getTableList } from "@/api/community/residence"; | ||
| 5 | +import { useRoute } from "vue-router"; | ||
| 6 | +import { back } from "@/utils/tool"; | ||
| 7 | +import * as store from "@/pinia/index"; | ||
| 8 | +import { ElMessageBox } from "element-plus"; | ||
| 9 | +import type { ElForm } from "element-plus"; | ||
| 10 | +let form = reactive({ | ||
| 11 | + data: { | ||
| 12 | + title: "", | ||
| 13 | + status: null, | ||
| 14 | + oId: store?.family?.loginStore()?.organizationId, | ||
| 15 | + neighborHoodId: null, | ||
| 16 | + neighborHoodName: "", | ||
| 17 | + id: null, | ||
| 18 | + content: "", | ||
| 19 | + buildingIds: "", | ||
| 20 | + }, | ||
| 21 | + dataType: "", | ||
| 22 | + neighborhoods: [], | ||
| 23 | +}); | ||
| 24 | +const ruleFormRef = ref<InstanceType<typeof ElForm>>(); | ||
| 25 | +let instance: ComponentInternalInstance | null = getCurrentInstance(); | ||
| 26 | +/** | ||
| 27 | + * 表单验证规则 | ||
| 28 | + */ | ||
| 29 | +const rules = reactive({ | ||
| 30 | + title: [ | ||
| 31 | + { | ||
| 32 | + required: true, | ||
| 33 | + message: "请填写公告标题", | ||
| 34 | + trigger: "change", | ||
| 35 | + }, | ||
| 36 | + ], | ||
| 37 | + content: [ | ||
| 38 | + { | ||
| 39 | + required: true, | ||
| 40 | + message: "请填写公告内容", | ||
| 41 | + trigger: "change", | ||
| 42 | + }, | ||
| 43 | + ], | ||
| 44 | +}); | ||
| 45 | +/** | ||
| 46 | + * 表单重置 | ||
| 47 | + */ | ||
| 48 | +const resetForm = (formEl: InstanceType<typeof ElForm> | undefined) => { | ||
| 49 | + if (!formEl) return; | ||
| 50 | + formEl.resetFields(); | ||
| 51 | +}; | ||
| 52 | +/** | ||
| 53 | + * 表单提交 | ||
| 54 | + */ | ||
| 55 | +const submitForm = ( | ||
| 56 | + formEl: InstanceType<typeof ElForm> | undefined, | ||
| 57 | + type: number | ||
| 58 | +) => { | ||
| 59 | + if (!formEl) return; | ||
| 60 | + formEl.validate(async (valid) => { | ||
| 61 | + if (valid) { | ||
| 62 | + form.data.status = type; | ||
| 63 | + if (type) { | ||
| 64 | + ElMessageBox.confirm( | ||
| 65 | + "是否确定发布?(确认发布后将不可进行修改)", | ||
| 66 | + "提示", | ||
| 67 | + { | ||
| 68 | + confirmButtonText: "确认", | ||
| 69 | + cancelButtonText: "取消", | ||
| 70 | + type: "warning", | ||
| 71 | + } | ||
| 72 | + ) | ||
| 73 | + .then((res) => { | ||
| 74 | + postApi(type); | ||
| 75 | + }) | ||
| 76 | + .catch((error) => { | ||
| 77 | + console.log(error); | ||
| 78 | + }); | ||
| 79 | + } else { | ||
| 80 | + postApi(type); | ||
| 81 | + } | ||
| 82 | + } else { | ||
| 83 | + instance?.proxy?.$message.error("请检查表单格式"); | ||
| 84 | + return false; | ||
| 85 | + } | ||
| 86 | + }); | ||
| 87 | +}; | ||
| 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 | +/** | ||
| 105 | + * 选小区,给小区名赋值 | ||
| 106 | + * @param {number | null} data 选中的小区id | ||
| 107 | + */ | ||
| 108 | +const handleNeighborhoodChange = async (data: number | null) => { | ||
| 109 | + form.data.neighborHoodName = form.neighborhoods.find((i) => i.id === data)[ | ||
| 110 | + "name" | ||
| 111 | + ]; | ||
| 112 | +}; | ||
| 113 | +/** | ||
| 114 | + * 小区列表 | ||
| 115 | + * @param {number | null} pageSize 一次请求多少条数据 | ||
| 116 | + */ | ||
| 117 | +const getNeighborhoods = async (pageSize: number = 20) => { | ||
| 118 | + try { | ||
| 119 | + const res = await getTableList({ | ||
| 120 | + page: 1, | ||
| 121 | + type: 0, | ||
| 122 | + pageSize: pageSize, | ||
| 123 | + }); | ||
| 124 | + form.neighborhoods = res?.data?.data?.list; | ||
| 125 | + if (res?.data?.data?.total > pageSize) { | ||
| 126 | + getNeighborhoods(res?.data?.data?.total); | ||
| 127 | + } | ||
| 128 | + } catch (e) { | ||
| 129 | + console.log(e); | ||
| 130 | + } | ||
| 131 | +}; | ||
| 132 | +onMounted(() => { | ||
| 133 | + getNeighborhoods(); | ||
| 134 | + if (JSON.stringify(useRoute().query) === "{}") { | ||
| 135 | + form.dataType = "add"; | ||
| 136 | + } else { | ||
| 137 | + form.dataType = useRoute().query.dataType; | ||
| 138 | + form.data = useRoute().query; | ||
| 139 | + form.data.neighborHoodId = ~~useRoute().query.neighborHoodId; | ||
| 140 | + } | ||
| 141 | +}); | ||
| 142 | +</script> | ||
| 143 | + | ||
| 144 | +<template> | ||
| 145 | + <div class="page-container"> | ||
| 146 | + <el-card class="form_card" style="max-width: 1303px"> | ||
| 147 | + <h1 v-show="form.dataType === 'add'">新增公告</h1> | ||
| 148 | + <h1 v-show="form.dataType === 'edit'">编辑公告</h1> | ||
| 149 | + <h1 v-show="form.dataType === 'detail'">公告详情</h1> | ||
| 150 | + <el-form | ||
| 151 | + :inline="true" | ||
| 152 | + :model="form.data" | ||
| 153 | + :rules="rules" | ||
| 154 | + ref="ruleFormRef" | ||
| 155 | + label-width="120px" | ||
| 156 | + class="card-form" | ||
| 157 | + :disabled="form.dataType === 'detail'" | ||
| 158 | + > | ||
| 159 | + <el-form-item label="小区" prop="neighborHoodId" style="width: 100%"> | ||
| 160 | + <el-select | ||
| 161 | + v-model="form.data.neighborHoodId" | ||
| 162 | + placeholder="请选择小区" | ||
| 163 | + @change="handleNeighborhoodChange" | ||
| 164 | + > | ||
| 165 | + <el-option | ||
| 166 | + :label="item.name" | ||
| 167 | + :value="item.id" | ||
| 168 | + v-for="(item, index) in form.neighborhoods" | ||
| 169 | + :key="index" | ||
| 170 | + ></el-option> | ||
| 171 | + </el-select> | ||
| 172 | + </el-form-item> | ||
| 173 | + <el-form-item label="公告标题" prop="title" style="width: 100%"> | ||
| 174 | + <el-input | ||
| 175 | + v-model.trim="form.data.title" | ||
| 176 | + placeholder="请填写公告标题" | ||
| 177 | + maxlength="32" | ||
| 178 | + /> | ||
| 179 | + </el-form-item> | ||
| 180 | + <el-form-item label="公告内容" prop="content" style="width: 100%"> | ||
| 181 | + <el-input | ||
| 182 | + type="textarea" | ||
| 183 | + v-model.trim="form.data.content" | ||
| 184 | + placeholder="富文本组件整理中,后续会替换,先用文本框走流程" | ||
| 185 | + maxlength="1500" | ||
| 186 | + show-word-limit | ||
| 187 | + /> | ||
| 188 | + </el-form-item> | ||
| 189 | + <el-form-item style="width: 100%" v-show="form.dataType !== 'detail'"> | ||
| 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 | ||
| 195 | + > | ||
| 196 | + <el-button | ||
| 197 | + type="info" | ||
| 198 | + @click="resetForm(ruleFormRef)" | ||
| 199 | + v-show="form.dataType === 'add'" | ||
| 200 | + >取消</el-button | ||
| 201 | + > | ||
| 202 | + <el-button type="info" @click="back">返回</el-button> | ||
| 203 | + </el-form-item> | ||
| 204 | + </el-form> | ||
| 205 | + <!-- 查看详情时表单不能编辑,禁用表单会把按钮也禁用掉,所以单列出来一个返回按钮 --> | ||
| 206 | + <el-button type="info" @click="back" v-if="form.dataType === 'detail'" | ||
| 207 | + >返回</el-button | ||
| 208 | + > | ||
| 209 | + </el-card> | ||
| 210 | + </div> | ||
| 211 | +</template> |
src/views/notify/index.vue
0 → 100644
| 1 | +<script setup lang="ts"> | ||
| 2 | +import { reactive, ref, onMounted } from "vue"; | ||
| 3 | +import { notifyList, notifyDelete } from "@/api/notify"; | ||
| 4 | +import { parseTime } from "@/utils/tool"; | ||
| 5 | +import Pagination from "@/components/Pagination/index.vue"; | ||
| 6 | +import { ElMessageBox, ElMessage } from "element-plus"; | ||
| 7 | +import type { ElTable } from "element-plus"; | ||
| 8 | +interface Form { | ||
| 9 | + page: number; | ||
| 10 | + pageSize: number; | ||
| 11 | + startTime: string; | ||
| 12 | + endTime: string; | ||
| 13 | +} | ||
| 14 | +interface Params { | ||
| 15 | + total: number; | ||
| 16 | + query: Form; | ||
| 17 | +} | ||
| 18 | +interface Data { | ||
| 19 | + loading: boolean; | ||
| 20 | + list: any[] | null; | ||
| 21 | + params: Params; | ||
| 22 | +} | ||
| 23 | +const multipleTableRef = ref<InstanceType<typeof ElTable>>(); | ||
| 24 | +let multipleSelection = ref<any[]>([]); | ||
| 25 | +const value1 = ref([]); | ||
| 26 | +let data = reactive({ | ||
| 27 | + list: [], | ||
| 28 | + loading: false, | ||
| 29 | + params: { | ||
| 30 | + total: 0, | ||
| 31 | + query: { | ||
| 32 | + page: 1, | ||
| 33 | + pageSize: 10, | ||
| 34 | + startTime: "", | ||
| 35 | + endTime: "", | ||
| 36 | + }, | ||
| 37 | + }, | ||
| 38 | +}); | ||
| 39 | +/** | ||
| 40 | + * 状态值 | ||
| 41 | + * @enum {number} | ||
| 42 | + */ | ||
| 43 | +enum statusEnum { | ||
| 44 | + "草稿" = 0, | ||
| 45 | + "已发布", | ||
| 46 | +} | ||
| 47 | +/** | ||
| 48 | + * 列表 | ||
| 49 | + */ | ||
| 50 | +const getList = async () => { | ||
| 51 | + data.loading = true; | ||
| 52 | + try { | ||
| 53 | + const res = await notifyList(data.params.query); | ||
| 54 | + data.list = res?.data?.data?.list; | ||
| 55 | + data.params.total = res?.data?.data?.total; | ||
| 56 | + } catch (e) { | ||
| 57 | + console.log(e); | ||
| 58 | + } finally { | ||
| 59 | + data.loading = false; | ||
| 60 | + } | ||
| 61 | +}; | ||
| 62 | +/** | ||
| 63 | + * 分页回调 | ||
| 64 | + * @param {number} page 当前页码 | ||
| 65 | + * @param {number} size 每页内容条数 | ||
| 66 | + */ | ||
| 67 | +const handlePageChange = (page, size) => { | ||
| 68 | + data.params.query.page = page; | ||
| 69 | + data.params.query.pageSize = size; | ||
| 70 | + getList(); | ||
| 71 | +}; | ||
| 72 | +/** | ||
| 73 | + * 查询 | ||
| 74 | + */ | ||
| 75 | +const handleSearch = () => { | ||
| 76 | + getList(); | ||
| 77 | +}; | ||
| 78 | +/** | ||
| 79 | + * 表格选中响应 | ||
| 80 | + * @param {array} data 选中的一条数据 | ||
| 81 | + */ | ||
| 82 | +const handleSelectionChange = (data: array) => { | ||
| 83 | + multipleSelection.value = data; | ||
| 84 | +}; | ||
| 85 | +/** | ||
| 86 | + * 时间组件回调 | ||
| 87 | + * @param {array} value [开始时间, 结束时间] | ||
| 88 | + */ | ||
| 89 | +const handleTimeChange = (value: array) => { | ||
| 90 | + console.log(value); | ||
| 91 | + data.params.query.startTime = value ? value[0] : ""; | ||
| 92 | + data.params.query.endTime = value ? value[1] : ""; | ||
| 93 | + getList(); | ||
| 94 | +}; | ||
| 95 | +/** | ||
| 96 | + * 表格每一行是否可选中 | ||
| 97 | + * @param {array} row 每一行数据对象 | ||
| 98 | + */ | ||
| 99 | +const isSelectable = (row: any) => { | ||
| 100 | + return row.status === 0; | ||
| 101 | +}; | ||
| 102 | +/** | ||
| 103 | + * 删除 | ||
| 104 | + * @param {object} obj 要删除的数据对象 | ||
| 105 | + */ | ||
| 106 | +const handleDelete = (obj: any) => { | ||
| 107 | + ElMessageBox.confirm("确认删除吗?", "警告", { | ||
| 108 | + confirmButtonText: "确认", | ||
| 109 | + cancelButtonText: "取消", | ||
| 110 | + type: "warning", | ||
| 111 | + }) | ||
| 112 | + .then(async () => { | ||
| 113 | + try { | ||
| 114 | + let res = await notifyDelete({ | ||
| 115 | + ids: obj.id, | ||
| 116 | + }); | ||
| 117 | + if (res?.data) { | ||
| 118 | + ElMessage({ | ||
| 119 | + type: "success", | ||
| 120 | + message: "操作成功", | ||
| 121 | + }); | ||
| 122 | + getList(); | ||
| 123 | + } else { | ||
| 124 | + ElMessage({ | ||
| 125 | + type: "error", | ||
| 126 | + message: "操作失败", | ||
| 127 | + }); | ||
| 128 | + } | ||
| 129 | + } catch (e) { | ||
| 130 | + console.log(e); | ||
| 131 | + } | ||
| 132 | + }) | ||
| 133 | + .catch(() => { | ||
| 134 | + console.log("取消"); | ||
| 135 | + }); | ||
| 136 | +}; | ||
| 137 | +onMounted(() => { | ||
| 138 | + getList(); | ||
| 139 | +}); | ||
| 140 | +</script> | ||
| 141 | + | ||
| 142 | +<template> | ||
| 143 | + <div class="page-container"> | ||
| 144 | + <h1>公告列表</h1> | ||
| 145 | + <el-row style="padding-bottom: 20px"> | ||
| 146 | + <el-form :inline="true" label-width="70px"> | ||
| 147 | + <el-form-item label="时间"> | ||
| 148 | + <el-date-picker | ||
| 149 | + v-model="value1" | ||
| 150 | + type="datetimerange" | ||
| 151 | + range-separator="至" | ||
| 152 | + format="YYYY-MM-DD HH:mm:ss" | ||
| 153 | + value-format="YYYY-MM-DD HH:mm:ss" | ||
| 154 | + start-placeholder="开始时间" | ||
| 155 | + end-placeholder="结束时间" | ||
| 156 | + @change="handleTimeChange" | ||
| 157 | + > | ||
| 158 | + </el-date-picker> | ||
| 159 | + </el-form-item> | ||
| 160 | + <el-form-item> | ||
| 161 | + <el-button type="primary" @click="handleSearch">查询</el-button> | ||
| 162 | + <el-button type="primary"> | ||
| 163 | + <router-link to="/notify/edit">添加公告</router-link> | ||
| 164 | + </el-button> | ||
| 165 | + <el-button | ||
| 166 | + type="danger" | ||
| 167 | + @click=" | ||
| 168 | + handleDelete({ id: multipleSelection.map((i) => i.id).join(',') }) | ||
| 169 | + " | ||
| 170 | + :disabled="!multipleSelection.length" | ||
| 171 | + >批量删除</el-button | ||
| 172 | + > | ||
| 173 | + </el-form-item> | ||
| 174 | + </el-form> | ||
| 175 | + </el-row> | ||
| 176 | + <el-table | ||
| 177 | + :data="data.list" | ||
| 178 | + style="width: 100%" | ||
| 179 | + border | ||
| 180 | + v-loading="data.loading" | ||
| 181 | + align="center" | ||
| 182 | + element-loading-text="拼命加载中" | ||
| 183 | + ref="multipleTableRef" | ||
| 184 | + @selection-change="handleSelectionChange" | ||
| 185 | + > | ||
| 186 | + <el-table-column | ||
| 187 | + type="selection" | ||
| 188 | + align="center" | ||
| 189 | + :selectable="isSelectable" | ||
| 190 | + /> | ||
| 191 | + <el-table-column prop="id" label="ID" align="center"></el-table-column> | ||
| 192 | + <el-table-column | ||
| 193 | + prop="title" | ||
| 194 | + label="标题" | ||
| 195 | + align="center" | ||
| 196 | + ></el-table-column> | ||
| 197 | + <el-table-column | ||
| 198 | + prop="content" | ||
| 199 | + label="内容" | ||
| 200 | + align="center" | ||
| 201 | + ></el-table-column> | ||
| 202 | + <el-table-column | ||
| 203 | + prop="neighborHoodName" | ||
| 204 | + label="小区" | ||
| 205 | + align="center" | ||
| 206 | + ></el-table-column> | ||
| 207 | + <el-table-column prop="status" label="状态" align="center"> | ||
| 208 | + <template #default="scope"> | ||
| 209 | + {{ statusEnum[scope.row.status] }} | ||
| 210 | + </template> | ||
| 211 | + </el-table-column> | ||
| 212 | + <el-table-column prop="createTime" label="发布时间" align="center"> | ||
| 213 | + <template #default="scope"> | ||
| 214 | + {{ parseTime(new Date(scope.row.createTime).getTime()) }} | ||
| 215 | + </template> | ||
| 216 | + </el-table-column> | ||
| 217 | + <el-table-column label="操作" align="center"> | ||
| 218 | + <!-- 已发布状态的公告不可以被修改、删除 --> | ||
| 219 | + <template #default="scope"> | ||
| 220 | + <el-button type="text" v-show="scope.row.status === 0" | ||
| 221 | + ><router-link | ||
| 222 | + :to="{ | ||
| 223 | + path: '/notify/edit', | ||
| 224 | + query: { ...scope.row, ...{ dataType: 'edit' } }, | ||
| 225 | + }" | ||
| 226 | + >编辑</router-link | ||
| 227 | + ></el-button | ||
| 228 | + > | ||
| 229 | + <el-button type="text" | ||
| 230 | + ><router-link | ||
| 231 | + :to="{ | ||
| 232 | + path: '/notify/edit', | ||
| 233 | + query: { ...scope.row, ...{ dataType: 'detail' } }, | ||
| 234 | + }" | ||
| 235 | + >详情</router-link | ||
| 236 | + ></el-button | ||
| 237 | + > | ||
| 238 | + <el-button | ||
| 239 | + type="text" | ||
| 240 | + @click="handleDelete(scope.row)" | ||
| 241 | + v-show="scope.row.status === 0" | ||
| 242 | + >删除</el-button | ||
| 243 | + > | ||
| 244 | + </template> | ||
| 245 | + </el-table-column> | ||
| 246 | + </el-table> | ||
| 247 | + <Pagination | ||
| 248 | + :total="data.params.total" | ||
| 249 | + :currentPage="data.params.query.page" | ||
| 250 | + :pageSize="data.params.query.pageSize" | ||
| 251 | + @pageChange="handlePageChange" | ||
| 252 | + ></Pagination> | ||
| 253 | + </div> | ||
| 254 | +</template> |
src/views/property/edit.vue
| @@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
| 2 | import { reactive, ref, getCurrentInstance, onMounted } from "vue"; | 2 | import { reactive, ref, getCurrentInstance, onMounted } from "vue"; |
| 3 | import { propertyAdd } from "@/api/property"; | 3 | import { propertyAdd } from "@/api/property"; |
| 4 | import { useRoute } from "vue-router"; | 4 | import { useRoute } from "vue-router"; |
| 5 | +import { back } from '@/utils/tool'; | ||
| 5 | import { validMobile } from "@/utils/validate"; | 6 | import { validMobile } from "@/utils/validate"; |
| 6 | import type { ElForm } from "element-plus"; | 7 | import type { ElForm } from "element-plus"; |
| 7 | const { | 8 | const { |
| @@ -233,7 +234,7 @@ onMounted(() => { | @@ -233,7 +234,7 @@ onMounted(() => { | ||
| 233 | /> | 234 | /> |
| 234 | </el-form-item> | 235 | </el-form-item> |
| 235 | <el-form-item label="类型" prop="type" style="width: 50%"> | 236 | <el-form-item label="类型" prop="type" style="width: 50%"> |
| 236 | - <el-select v-model="form.data.type"> | 237 | + <el-select v-model="form.data.type" :disabled="form.dataType === 'edit'"> |
| 237 | <el-option label="物业" value="1"></el-option> | 238 | <el-option label="物业" value="1"></el-option> |
| 238 | <el-option label="公益" value="2"></el-option> | 239 | <el-option label="公益" value="2"></el-option> |
| 239 | </el-select> | 240 | </el-select> |
| @@ -245,6 +246,9 @@ onMounted(() => { | @@ -245,6 +246,9 @@ onMounted(() => { | ||
| 245 | <el-button type="info" @click="resetForm(ruleFormRef)" | 246 | <el-button type="info" @click="resetForm(ruleFormRef)" |
| 246 | >取消</el-button | 247 | >取消</el-button |
| 247 | > | 248 | > |
| 249 | + <el-button type="info" @click="back" | ||
| 250 | + >返回</el-button | ||
| 251 | + > | ||
| 248 | </el-form-item> | 252 | </el-form-item> |
| 249 | </el-form> | 253 | </el-form> |
| 250 | </el-card> | 254 | </el-card> |
src/views/property/index.vue
| 1 | <script setup lang="ts"> | 1 | <script setup lang="ts"> |
| 2 | import { reactive, ref, onMounted, getCurrentInstance } from "vue"; | 2 | import { reactive, ref, onMounted, getCurrentInstance } from "vue"; |
| 3 | import { propertyList, propertyStatus } from "@/api/property"; | 3 | import { propertyList, propertyStatus } from "@/api/property"; |
| 4 | -import { userProxy } from '@/api/user/user'; | 4 | +import { userProxy } from "@/api/user/user"; |
| 5 | +import { menuData } from "@/api/user/login"; | ||
| 6 | +import * as store from "@/pinia/index"; | ||
| 5 | import { parseTime } from "@/utils/tool"; | 7 | import { parseTime } from "@/utils/tool"; |
| 6 | import Pagination from "@/components/Pagination/index.vue"; | 8 | import Pagination from "@/components/Pagination/index.vue"; |
| 7 | const { | 9 | const { |
| @@ -66,7 +68,7 @@ const handleSearch = () => { | @@ -66,7 +68,7 @@ const handleSearch = () => { | ||
| 66 | }; | 68 | }; |
| 67 | /** | 69 | /** |
| 68 | * 切换状态 | 70 | * 切换状态 |
| 69 | - * @param {object} 单条数据对象 | 71 | + * @param {object} 单条数据对象 |
| 70 | */ | 72 | */ |
| 71 | const handleStatus = async (obj) => { | 73 | const handleStatus = async (obj) => { |
| 72 | try { | 74 | try { |
| @@ -89,20 +91,37 @@ const handleStatus = async (obj) => { | @@ -89,20 +91,37 @@ const handleStatus = async (obj) => { | ||
| 89 | * @param {object} 单条数据对象 | 91 | * @param {object} 单条数据对象 |
| 90 | */ | 92 | */ |
| 91 | const handleProxy = (obj) => { | 93 | const handleProxy = (obj) => { |
| 92 | - userProxy({oId: obj.id}).then(res => { | ||
| 93 | - if(res?.data) { | 94 | + userProxy({ oId: obj.id }).then((res) => { |
| 95 | + if (res?.data) { | ||
| 96 | + console.log("代理成功的回调"); | ||
| 97 | + console.log(res.data); | ||
| 94 | globalProperties.$message.success("代理成功"); | 98 | globalProperties.$message.success("代理成功"); |
| 95 | - setTimeout(() => { | ||
| 96 | - location.href = '/' | ||
| 97 | - }, 500) | 99 | + getMenu().then(() => { |
| 100 | + console.log("got menu data"); | ||
| 101 | + setTimeout(() => { | ||
| 102 | + // location.href = '/' | ||
| 103 | + console.log("跳"); | ||
| 104 | + }, 2000); | ||
| 105 | + }); | ||
| 98 | } else { | 106 | } else { |
| 99 | globalProperties.$message.error("代理失败"); | 107 | globalProperties.$message.error("代理失败"); |
| 100 | } | 108 | } |
| 101 | - }) | ||
| 102 | -} | 109 | + }); |
| 110 | +}; | ||
| 111 | +/** | ||
| 112 | + * 获取权限菜单 | ||
| 113 | + */ | ||
| 114 | +const getMenu = async () => { | ||
| 115 | + try { | ||
| 116 | + let res = await menuData(); | ||
| 117 | + store.family.menuStore().setMenuList(res?.data?.data); | ||
| 118 | + } catch (e) { | ||
| 119 | + console.log(e); | ||
| 120 | + } | ||
| 121 | +}; | ||
| 103 | /** | 122 | /** |
| 104 | * 状态值 | 123 | * 状态值 |
| 105 | - * @enum {number} | 124 | + * @enum {number} |
| 106 | */ | 125 | */ |
| 107 | enum statusEnum { | 126 | enum statusEnum { |
| 108 | "禁用" = 0, | 127 | "禁用" = 0, |
| @@ -186,7 +205,9 @@ onMounted(() => { | @@ -186,7 +205,9 @@ onMounted(() => { | ||
| 186 | >编辑</router-link | 205 | >编辑</router-link |
| 187 | ></el-button | 206 | ></el-button |
| 188 | > | 207 | > |
| 189 | - <el-button type="text" @click="handleProxy(scope.row)">代理登录</el-button> | 208 | + <el-button type="text" @click="handleProxy(scope.row)" |
| 209 | + >代理登录</el-button | ||
| 210 | + > | ||
| 190 | <el-button type="text" @click="handleStatus(scope.row)">{{ | 211 | <el-button type="text" @click="handleStatus(scope.row)">{{ |
| 191 | scope.row.status ? "禁用" : "启用" | 212 | scope.row.status ? "禁用" : "启用" |
| 192 | }}</el-button> | 213 | }}</el-button> |
src/views/system/log.vue
| @@ -151,13 +151,16 @@ onMounted(() => { | @@ -151,13 +151,16 @@ onMounted(() => { | ||
| 151 | > | 151 | > |
| 152 | <el-table-column prop="id" label="ID" align="center"> </el-table-column> | 152 | <el-table-column prop="id" label="ID" align="center"> </el-table-column> |
| 153 | <el-table-column prop="ip" label="IP" align="center"> </el-table-column> | 153 | <el-table-column prop="ip" label="IP" align="center"> </el-table-column> |
| 154 | - <el-table-column prop="type" label="类型" align="center"> | ||
| 155 | - </el-table-column> | ||
| 156 | <el-table-column prop="model" label="模块" align="center"> | 154 | <el-table-column prop="model" label="模块" align="center"> |
| 157 | </el-table-column> | 155 | </el-table-column> |
| 156 | + <el-table-column prop="type" label="类型" align="center"> | ||
| 157 | + </el-table-column> | ||
| 158 | <el-table-column prop="themeName" label="内容" align="center"> | 158 | <el-table-column prop="themeName" label="内容" align="center"> |
| 159 | </el-table-column> | 159 | </el-table-column> |
| 160 | <el-table-column prop="time" label="操作时间" align="center"> | 160 | <el-table-column prop="time" label="操作时间" align="center"> |
| 161 | + <template #default="scope"> | ||
| 162 | + {{ parseTime(new Date(scope.row.time).getTime()) }} | ||
| 163 | + </template> | ||
| 161 | </el-table-column> | 164 | </el-table-column> |
| 162 | <el-table-column prop="userName" label="操作人" align="center"> | 165 | <el-table-column prop="userName" label="操作人" align="center"> |
| 163 | </el-table-column> | 166 | </el-table-column> |
src/views/user/edit.vue
| @@ -107,7 +107,8 @@ const submitForm = (formEl: InstanceType<typeof ElForm> | undefined) => { | @@ -107,7 +107,8 @@ const submitForm = (formEl: InstanceType<typeof ElForm> | undefined) => { | ||
| 107 | password: form.data.password, | 107 | password: form.data.password, |
| 108 | roleIds: form.data.roleIds, | 108 | roleIds: form.data.roleIds, |
| 109 | userId: form.data.id, | 109 | userId: form.data.id, |
| 110 | - userName: form.data.userName | 110 | + userName: form.data.userName, |
| 111 | + neighborhoodIds: form.data.neighborhoodIds | ||
| 111 | }); | 112 | }); |
| 112 | } | 113 | } |
| 113 | } catch (e) { | 114 | } catch (e) { |