Compare commits
61 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 228d39a76e | |||
| 5999214032 | |||
| bf7754af8a | |||
| 00605c5eae | |||
| 0fe8c3247c | |||
| e9a4b61d4e | |||
| af7444da5f | |||
| d7279e3f2d | |||
| e8a0f5f13f | |||
| b4eb747b52 | |||
| b2543dc524 | |||
| 65a880db47 | |||
| 4edc0d242c | |||
| 4dc09d2983 | |||
| d77a0f458d | |||
| cfbb897cf0 | |||
| 0598216ecc | |||
| 55e468ce79 | |||
| 541b092691 | |||
| 7a11813958 | |||
| 2fb294878f | |||
| ef704a17f5 | |||
| d814ee2aef | |||
| 0d27ec1139 | |||
| 2069626a05 | |||
| acd9cad23f | |||
| bb6dc0999f | |||
| 5a52a58c0c | |||
| a5ee34e6fb | |||
| 2179458f24 | |||
| 351806d05f | |||
| ca5ca2bb95 | |||
| ad6743656b | |||
| 1df7f49df1 | |||
| 75d1dc1c35 | |||
| 56006d3376 | |||
| aafee5564b | |||
| d087dc171f | |||
| cc404e0ec4 | |||
| d92732dfe6 | |||
| 6d9c25f3ce | |||
| 0aa703b529 | |||
| e0c0a10a43 | |||
| 4762408c99 | |||
| 0293c09ebd | |||
| 37bc08761d | |||
| 2a21170ba3 | |||
| c9ab7e221a | |||
| 34efcf19ee | |||
| 4f33e9c8ca | |||
| e4a21e1c6c | |||
| 4b0c7ec534 | |||
| b00e35c31c | |||
| e9c59574c5 | |||
| 46237d6283 | |||
| 1c2ded6dcd | |||
| f369e99292 | |||
| b613331464 | |||
| 1452208822 | |||
| d5611562e6 | |||
| b9c8842a85 |
@ -4,7 +4,7 @@
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Vite + Vue</title>
|
||||
<title>测盟汇管理系统</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
||||
105
package-lock.json
generated
105
package-lock.json
generated
@ -13,10 +13,12 @@
|
||||
"axios": "^1.7.2",
|
||||
"ckeditor5": "^42.0.0",
|
||||
"element-plus": "^2.7.6",
|
||||
"file-saver": "^2.0.5",
|
||||
"vue": "^3.4.29",
|
||||
"vue-router": "^4.4.0",
|
||||
"vuex": "^4.1.0",
|
||||
"vuex-persistedstate": "^4.1.0"
|
||||
"vuex-persistedstate": "^4.1.0",
|
||||
"xlsx": "^0.18.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^5.0.5",
|
||||
@ -1414,6 +1416,14 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/adler-32": {
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmmirror.com/adler-32/-/adler-32-1.3.1.tgz",
|
||||
"integrity": "sha512-ynZ4w/nUUv5rrsR8UUGoe1VC9hZj6V5hU9Qw1HlMDJGEJw5S7TfTErWTjMys6M7vr0YWcPqs3qAr4ss0nDfP+A==",
|
||||
"engines": {
|
||||
"node": ">=0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/async-validator": {
|
||||
"version": "4.2.5",
|
||||
"resolved": "https://registry.npmmirror.com/async-validator/-/async-validator-4.2.5.tgz",
|
||||
@ -1439,6 +1449,18 @@
|
||||
"resolved": "https://registry.npmmirror.com/blurhash/-/blurhash-2.0.5.tgz",
|
||||
"integrity": "sha512-cRygWd7kGBQO3VEhPiTgq4Wc43ctsM+o46urrmPOiuAe+07fzlSB9OJVdpgDL0jPqXUVQ9ht7aq7kxOeJHRK+w=="
|
||||
},
|
||||
"node_modules/cfb": {
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://registry.npmmirror.com/cfb/-/cfb-1.2.2.tgz",
|
||||
"integrity": "sha512-KfdUZsSOw19/ObEWasvBP/Ac4reZvAGauZhs6S/gqNhXhI7cKwvlH7ulj+dOEYnca4bm4SGo8C1bTAQvnTjgQA==",
|
||||
"dependencies": {
|
||||
"adler-32": "~1.3.0",
|
||||
"crc-32": "~1.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/ckeditor5": {
|
||||
"version": "42.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/ckeditor5/-/ckeditor5-42.0.0.tgz",
|
||||
@ -1503,6 +1525,14 @@
|
||||
"@ckeditor/ckeditor5-word-count": "42.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/codepage": {
|
||||
"version": "1.15.0",
|
||||
"resolved": "https://registry.npmmirror.com/codepage/-/codepage-1.15.0.tgz",
|
||||
"integrity": "sha512-3g6NUTPd/YtuuGrhMnOMRjFc+LJw/bnMp3+0r/Wcz3IXUuCosKRJvMphm5+Q+bvTVGcJJuRvVLuYba+WojaFaA==",
|
||||
"engines": {
|
||||
"node": ">=0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/color-convert": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/color-convert/-/color-convert-2.0.1.tgz",
|
||||
@ -1538,6 +1568,17 @@
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/crc-32": {
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://registry.npmmirror.com/crc-32/-/crc-32-1.2.2.tgz",
|
||||
"integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==",
|
||||
"bin": {
|
||||
"crc32": "bin/crc32.njs"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/csstype": {
|
||||
"version": "3.1.3",
|
||||
"resolved": "https://registry.npmmirror.com/csstype/-/csstype-3.1.3.tgz",
|
||||
@ -1648,6 +1689,11 @@
|
||||
"resolved": "https://registry.npmmirror.com/estree-walker/-/estree-walker-2.0.2.tgz",
|
||||
"integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w=="
|
||||
},
|
||||
"node_modules/file-saver": {
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://registry.npmmirror.com/file-saver/-/file-saver-2.0.5.tgz",
|
||||
"integrity": "sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA=="
|
||||
},
|
||||
"node_modules/follow-redirects": {
|
||||
"version": "1.15.6",
|
||||
"resolved": "https://registry.npmmirror.com/follow-redirects/-/follow-redirects-1.15.6.tgz",
|
||||
@ -1680,6 +1726,14 @@
|
||||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/frac": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmmirror.com/frac/-/frac-1.1.2.tgz",
|
||||
"integrity": "sha512-w/XBfkibaTl3YDqASwfDUqkna4Z2p9cFSr1aHDt0WoMTECnRfBOv2WArlZILlqgWlmdIlALXGpM2AOhEk5W3IA==",
|
||||
"engines": {
|
||||
"node": ">=0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/fsevents": {
|
||||
"version": "2.3.3",
|
||||
"resolved": "https://registry.npmmirror.com/fsevents/-/fsevents-2.3.3.tgz",
|
||||
@ -1865,6 +1919,17 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/ssf": {
|
||||
"version": "0.11.2",
|
||||
"resolved": "https://registry.npmmirror.com/ssf/-/ssf-0.11.2.tgz",
|
||||
"integrity": "sha512-+idbmIXoYET47hH+d7dfm2epdOMUDjqcB4648sTZ+t2JwoyBFL/insLfB/racrDmsKB3diwsDA696pZMieAC5g==",
|
||||
"dependencies": {
|
||||
"frac": "~1.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/turndown": {
|
||||
"version": "7.2.0",
|
||||
"resolved": "https://registry.npmmirror.com/turndown/-/turndown-7.2.0.tgz",
|
||||
@ -1960,7 +2025,7 @@
|
||||
},
|
||||
"node_modules/vue-router": {
|
||||
"version": "4.4.0",
|
||||
"resolved": "https://registry.npmmirror.com/vue-router/-/vue-router-4.4.0.tgz",
|
||||
"resolved": "https://registry.npmjs.org/vue-router/-/vue-router-4.4.0.tgz",
|
||||
"integrity": "sha512-HB+t2p611aIZraV2aPSRNXf0Z/oLZFrlygJm+sZbdJaW6lcFqEDQwnzUBXn+DApw+/QzDU/I9TeWx9izEjTmsA==",
|
||||
"dependencies": {
|
||||
"@vue/devtools-api": "^6.5.1"
|
||||
@ -1995,6 +2060,42 @@
|
||||
"peerDependencies": {
|
||||
"vuex": "^3.0 || ^4.0.0-rc"
|
||||
}
|
||||
},
|
||||
"node_modules/wmf": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmmirror.com/wmf/-/wmf-1.0.2.tgz",
|
||||
"integrity": "sha512-/p9K7bEh0Dj6WbXg4JG0xvLQmIadrner1bi45VMJTfnbVHsc7yIajZyoSoK60/dtVBs12Fm6WkUI5/3WAVsNMw==",
|
||||
"engines": {
|
||||
"node": ">=0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/word": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmmirror.com/word/-/word-0.3.0.tgz",
|
||||
"integrity": "sha512-OELeY0Q61OXpdUfTp+oweA/vtLVg5VDOXh+3he3PNzLGG/y0oylSOC1xRVj0+l4vQ3tj/bB1HVHv1ocXkQceFA==",
|
||||
"engines": {
|
||||
"node": ">=0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/xlsx": {
|
||||
"version": "0.18.5",
|
||||
"resolved": "https://registry.npmmirror.com/xlsx/-/xlsx-0.18.5.tgz",
|
||||
"integrity": "sha512-dmg3LCjBPHZnQp5/F/+nnTa+miPJxUXB6vtk42YjBBKayDNagxGEeIdWApkYPOf3Z3pm3k62Knjzp7lMeTEtFQ==",
|
||||
"dependencies": {
|
||||
"adler-32": "~1.3.0",
|
||||
"cfb": "~1.2.1",
|
||||
"codepage": "~1.15.0",
|
||||
"crc-32": "~1.2.1",
|
||||
"ssf": "~0.11.2",
|
||||
"wmf": "~1.0.1",
|
||||
"word": "~0.3.0"
|
||||
},
|
||||
"bin": {
|
||||
"xlsx": "bin/xlsx.njs"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.8"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,7 +17,9 @@
|
||||
"vue": "^3.4.29",
|
||||
"vue-router": "^4.4.0",
|
||||
"vuex": "^4.1.0",
|
||||
"vuex-persistedstate": "^4.1.0"
|
||||
"vuex-persistedstate": "^4.1.0",
|
||||
"xlsx": "^0.18.5",
|
||||
"file-saver": "^2.0.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^5.0.5",
|
||||
|
||||
BIN
public/background1.jpg
Normal file
BIN
public/background1.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 300 KiB |
BIN
public/background2.jpg
Normal file
BIN
public/background2.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 MiB |
47
src/App.vue
47
src/App.vue
@ -1,10 +1,43 @@
|
||||
<template>
|
||||
<router-view></router-view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import 'element-plus/dist/index.css'
|
||||
import {ref} from "vue";
|
||||
|
||||
const activeIndex = ref('1')
|
||||
const handleSelect = (key, keyPath) => {
|
||||
console.log(key, keyPath)
|
||||
}
|
||||
</script>
|
||||
|
||||
<!--请不要对App.vue进行修改,请采用在views的对应目录下新建自己需要的文件
|
||||
并通过在/router下的对应模块名称的js中引入路由的方式来显示自己的页面-->
|
||||
<template>
|
||||
<el-menu
|
||||
:default-active="activeIndex"
|
||||
class="el-menu-demo"
|
||||
mode="horizontal"
|
||||
@select="handleSelect"
|
||||
>
|
||||
<el-menu-item index="1">
|
||||
<router-link to="/" class="no-underline">首页</router-link>
|
||||
</el-menu-item>
|
||||
</el-menu>
|
||||
<div>
|
||||
<router-view></router-view>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.el-menu-demo {
|
||||
width: 100%;
|
||||
top: 0;
|
||||
z-index: 1000;
|
||||
display: flex;
|
||||
justify-content: center; /* 中心对齐 */
|
||||
}
|
||||
|
||||
.no-underline {
|
||||
text-decoration: none;
|
||||
color: inherit; /* 保持文字颜色与父元素一致 */
|
||||
}
|
||||
|
||||
.el-menu-item .no-underline:hover {
|
||||
color: #409EFF; /* 鼠标悬停时的颜色,可以根据需要调整 */
|
||||
}
|
||||
</style>
|
||||
|
||||
17
src/assets/global.css
Normal file
17
src/assets/global.css
Normal file
@ -0,0 +1,17 @@
|
||||
body {
|
||||
background-image: url('/public/background.jpg');
|
||||
background-size: contain;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
background-attachment: fixed;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
body {
|
||||
background-size: cover;
|
||||
}
|
||||
}
|
||||
@ -1,7 +1,7 @@
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { ref } from 'vue';
|
||||
|
||||
const count = ref(0)
|
||||
const count = ref(0);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@ -13,7 +13,7 @@ const count = ref(0)
|
||||
<img src="../assets/vue.svg" class="logo vue" alt="Vue logo" />
|
||||
</a>
|
||||
</div>
|
||||
<h1>{{ this.$route.meta.msg }}</h1>
|
||||
<h1>{{ $route.meta.msg }}</h1>
|
||||
|
||||
<div class="card">
|
||||
<el-button type="success" @click="count++">count is {{ count }}</el-button>
|
||||
@ -25,19 +25,24 @@ const count = ref(0)
|
||||
|
||||
<p>
|
||||
Check out
|
||||
<a href="https://vuejs.org/guide/quick-start.html#local" target="_blank"
|
||||
>create-vue</a
|
||||
>, the official Vue + Vite starter
|
||||
<a href="https://vuejs.org/guide/quick-start.html#local" target="_blank">create-vue</a>, the official Vue + Vite starter
|
||||
</p>
|
||||
<p>
|
||||
Learn more about IDE Support for Vue in the
|
||||
<a
|
||||
href="https://vuejs.org/guide/scaling-up/tooling.html#ide-support"
|
||||
target="_blank"
|
||||
>Vue Docs Scaling up Guide</a
|
||||
>.
|
||||
<a href="https://vuejs.org/guide/scaling-up/tooling.html#ide-support" target="_blank">Vue Docs Scaling up Guide</a>.
|
||||
</p>
|
||||
<p class="read-the-docs">Click on the Vite and Vue logos to learn more</p>
|
||||
|
||||
<!-- 添加导航链接 -->
|
||||
<ul>
|
||||
<li><router-link to="/login">Login</router-link></li>
|
||||
<li><router-link to="/register">Register</router-link></li>
|
||||
<li><router-link to="/courseList">Courses</router-link></li>
|
||||
<li><router-link to="/meetings">Meetings</router-link></li>
|
||||
<li><router-link to="/news">News</router-link></li>
|
||||
<li><router-link to="/organizations">Organizations</router-link></li>
|
||||
<li><router-link to="/users">Users</router-link></li>
|
||||
</ul>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
@ -56,4 +61,4 @@ const count = ref(0)
|
||||
.read-the-docs {
|
||||
color: #888;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
123
src/components/Home.vue
Normal file
123
src/components/Home.vue
Normal file
@ -0,0 +1,123 @@
|
||||
<template>
|
||||
<el-container>
|
||||
<el-header>
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<h1>欢迎使用测盟汇管理系统</h1>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-header>
|
||||
<el-main>
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="8">
|
||||
<el-card shadow="hover">
|
||||
<h2>认证管理</h2>
|
||||
<el-menu :default-active="activeMenu" router>
|
||||
<el-menu-item index="/login">登录</el-menu-item>
|
||||
<el-menu-item index="/register">注册</el-menu-item>
|
||||
<el-menu-item index="/manageProfile">管理个人资料</el-menu-item>
|
||||
<el-menu-item index="/profile">个人资料</el-menu-item>
|
||||
</el-menu>
|
||||
</el-card>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-card shadow="hover">
|
||||
<h2>新闻管理</h2>
|
||||
<el-menu :default-active="activeMenu" router>
|
||||
<el-menu-item index="/news">新闻管理</el-menu-item>
|
||||
<el-menu-item index="/news/edit?mode=create">添加新闻(独立页面)</el-menu-item>
|
||||
</el-menu>
|
||||
</el-card>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-card shadow="hover">
|
||||
<h2>课程管理</h2>
|
||||
<el-menu :default-active="activeMenu" router>
|
||||
<el-menu-item index="/course">课程</el-menu-item>
|
||||
<el-menu-item index="/courseList">课程列表</el-menu-item>
|
||||
</el-menu>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="20" style="margin-top: 20px;">
|
||||
<el-col :span="8">
|
||||
<el-card shadow="hover">
|
||||
<h2>组织管理</h2>
|
||||
<el-menu :default-active="activeMenu" router>
|
||||
<el-menu-item index="/organizations">组织机构</el-menu-item>
|
||||
</el-menu>
|
||||
</el-card>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-card shadow="hover">
|
||||
<h2>会议管理</h2>
|
||||
<el-menu :default-active="activeMenu" router>
|
||||
<el-menu-item index="/Meeting">会议管理</el-menu-item>
|
||||
<el-menu-item index="/Meeting/add">添加会议</el-menu-item>
|
||||
</el-menu>
|
||||
</el-card>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-card shadow="hover">
|
||||
<h2>用户管理</h2>
|
||||
<el-menu :default-active="activeMenu" router>
|
||||
<el-menu-item index="/tenantManagement">租户管理</el-menu-item>
|
||||
<el-menu-item index="/addUser">添加用户</el-menu-item>
|
||||
<el-menu-item index="/addTenant">添加租户</el-menu-item>
|
||||
<el-menu-item index="/userManagement">用户管理</el-menu-item>
|
||||
</el-menu>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-main>
|
||||
</el-container>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {ref} from 'vue'
|
||||
import {useRouter} from 'vue-router'
|
||||
import 'element-plus/dist/index.css'
|
||||
import {useStore} from 'vuex'
|
||||
|
||||
const router = useRouter()
|
||||
const store = useStore()
|
||||
const activeMenu = ref(router.currentRoute.value.path)
|
||||
|
||||
if (store.getters['authentication/token'] == null) {
|
||||
router.push('/login')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
h1 {
|
||||
text-align: center;
|
||||
margin: 20px 0;
|
||||
color: #3a3a3a;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
h2 {
|
||||
margin-bottom: 10px;
|
||||
color: #2c3e50;
|
||||
}
|
||||
|
||||
.el-card {
|
||||
padding: 20px;
|
||||
border-radius: 8px;
|
||||
border: 1px solid #ebeef5;
|
||||
}
|
||||
|
||||
.el-menu-item {
|
||||
font-size: 14px;
|
||||
color: #606266;
|
||||
}
|
||||
|
||||
.el-menu-item:hover {
|
||||
color: #409eff;
|
||||
}
|
||||
|
||||
.el-container {
|
||||
background-color: #f5f7fa;
|
||||
padding: 30px;
|
||||
}
|
||||
</style>
|
||||
@ -1,9 +1,23 @@
|
||||
// import CourseList from '../views/course-management/CourseList.vue'
|
||||
// import CourseDetail from '../views/course-management/CourseDetail.vue'
|
||||
// import CourseEdit from '../views/course-management/CourseEdit.vue'
|
||||
import Course from '../views/course-management/Course.vue';
|
||||
import CourseList from '../views/course-management/CourseList.vue';
|
||||
import BackgroundWrapper from "@views/course-management/BackgroundWrapper.vue";
|
||||
|
||||
export default [
|
||||
// { path: '/courses', component: CourseList },
|
||||
// { path: '/courses/:id', component: CourseDetail },
|
||||
// { path: '/courses/:id/edit', component: CourseEdit }
|
||||
]
|
||||
{
|
||||
path: '/course',
|
||||
name: 'Course',
|
||||
component: Course
|
||||
},
|
||||
|
||||
{
|
||||
path: '/courseList',
|
||||
name: 'CourseList',
|
||||
component: CourseList
|
||||
},
|
||||
|
||||
{
|
||||
path: '/backgroundWrapper',
|
||||
name: 'BackgroundWrapper',
|
||||
component: BackgroundWrapper
|
||||
}
|
||||
];
|
||||
@ -1,4 +1,5 @@
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
import store from '../store' // 确保正确引入你的 Vuex store
|
||||
import HelloWorld from "../components/HelloWorld.vue";
|
||||
import authenticationRoutes from './authentication'
|
||||
import courseManagementRoutes from './courseManagement'
|
||||
@ -6,11 +7,13 @@ import meetingManagementRoutes from './meetingManagement'
|
||||
import newsManagementRoutes from './newsManagement'
|
||||
import organizationManagementRoutes from './organizationManagement'
|
||||
import userManagementRoutes from './userManagement'
|
||||
import Home from "../components/Home.vue"
|
||||
|
||||
// 请不要直接修改本文件,使用在router下的对应模块名称的js中引入路由的方式来代替->
|
||||
|
||||
const routes = [
|
||||
{ path: '/', component: HelloWorld, meta: {"msg": "HeIl⚪ W0rId!"}},
|
||||
// { path: '/', component: HelloWorld, meta: {"msg": "HeIl⚪ W0rId!"}},
|
||||
{ path: '/', component: Home},
|
||||
...authenticationRoutes,
|
||||
...courseManagementRoutes,
|
||||
...meetingManagementRoutes,
|
||||
@ -24,4 +27,16 @@ const router = createRouter({
|
||||
routes
|
||||
})
|
||||
|
||||
// 添加全局导航守卫
|
||||
router.beforeEach((to, from, next) => {
|
||||
const token = store.getters['authentication/token'];
|
||||
|
||||
// 如果token不存在且访问的页面不是/login或/register,则跳转到/login
|
||||
if (!token && to.path !== '/login' && to.path !== '/register') {
|
||||
next('/login');
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
});
|
||||
|
||||
export default router
|
||||
|
||||
@ -1,9 +1,24 @@
|
||||
// import MeetingList from '../views/meeting-management/MeetingList.vue'
|
||||
// import MeetingDetail from '../views/meeting-management/MeetingDetail.vue'
|
||||
// import MeetingEdit from '../views/meeting-management/MeetingEdit.vue'
|
||||
// meetingManagementRoutes.js
|
||||
import MeetingManagement from "/src/views/meeting-management/MeetingManagement.vue";
|
||||
import AddMeeting from "/src/views/meeting-management/AddMeeting.vue";
|
||||
import EditMeeting from "/src/views/meeting-management/EditMeeting.vue";
|
||||
|
||||
export default [
|
||||
// { path: '/meetings', component: MeetingList },
|
||||
// { path: '/meetings/:id', component: MeetingDetail },
|
||||
// { path: '/meetings/:id/edit', component: MeetingEdit }
|
||||
]
|
||||
const routes = [
|
||||
{
|
||||
path: '/Meeting',
|
||||
name: 'MeetingManagement',
|
||||
component: MeetingManagement
|
||||
},
|
||||
{
|
||||
path: '/Meeting/add',
|
||||
name: 'AddMeeting',
|
||||
component: AddMeeting
|
||||
},
|
||||
{
|
||||
path: '/Meeting/edit/:id',
|
||||
name: 'EditMeeting',
|
||||
component: EditMeeting
|
||||
}
|
||||
];
|
||||
|
||||
export default routes;
|
||||
@ -1,9 +1,7 @@
|
||||
// import OrganizationList from '../views/organization-management/OrganizationList.vue'
|
||||
// import OrganizationDetail from '../views/organization-management/OrganizationDetail.vue'
|
||||
// import OrganizationEdit from '../views/organization-management/OrganizationEdit.vue'
|
||||
import Organization_main from '../views/organization-management/Organization_main.vue'
|
||||
|
||||
export default [
|
||||
// { path: '/organizations', component: OrganizationList },
|
||||
{ path: '/organizations', component: Organization_main},
|
||||
// { path: '/organizations/:id', component: OrganizationDetail },
|
||||
// { path: '/organizations/:id/edit', component: OrganizationEdit }
|
||||
]
|
||||
|
||||
@ -2,8 +2,23 @@
|
||||
// import UserDetail from '../views/user-management/UserDetail.vue'
|
||||
// import UserEdit from '../views/user-management/UserEdit.vue'
|
||||
|
||||
import TenantManagement from "../views/user-management/TenantManagement.vue";
|
||||
import AddUser from "../views/user-management/AddUser.vue";
|
||||
import AddTenant from "../views/user-management/AddTenant.vue";
|
||||
import UserManagement from "../views/user-management/UserManagement.vue";
|
||||
|
||||
export default [
|
||||
// { path: '/users', component: UserList },
|
||||
// { path: '/users/:id', component: UserDetail },
|
||||
// { path: '/users/:id/edit', component: UserEdit }
|
||||
{ path: '/tenantManagement',
|
||||
name: 'TenantManagement',
|
||||
component: TenantManagement
|
||||
},
|
||||
{ path: '/addUser',
|
||||
name: 'AddUser',
|
||||
component: AddUser
|
||||
},
|
||||
{ path: '/addTenant',
|
||||
name: 'AddTenant',
|
||||
component: AddTenant
|
||||
},
|
||||
{ path: '/userManagement', name: 'UM', component:UserManagement }
|
||||
]
|
||||
|
||||
@ -0,0 +1,43 @@
|
||||
import axios from "axios";
|
||||
import { useRouter } from 'vue-router';
|
||||
import {ref} from "vue";
|
||||
|
||||
|
||||
export default {
|
||||
login(account, password){
|
||||
const url='http://localhost:8080/checkLogin'
|
||||
const data={
|
||||
account:account,
|
||||
password:password
|
||||
}
|
||||
return axios.post(url, data)
|
||||
.then(response => {
|
||||
const user=ref(null);
|
||||
const router=useRouter();
|
||||
user.value=response.data;
|
||||
if(user.value.account!=null) {
|
||||
alert("登录成功");
|
||||
if (user.value.account === "123" && user.value.password === "123") {
|
||||
alert("进入管理员界面");
|
||||
location.href="/userManagement";
|
||||
} else {
|
||||
alert("进入用户界面");
|
||||
location.href="/tenantManagement";
|
||||
}
|
||||
}else{
|
||||
alert("登录失败");
|
||||
}
|
||||
// 处理登录成功的逻辑
|
||||
return response.data;
|
||||
});
|
||||
|
||||
},
|
||||
register(user){
|
||||
const url='http://localhost:8080/checkRegister'
|
||||
return axios.post(url, user)
|
||||
.then(response=>{
|
||||
return response.data;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
import axios from 'axios';
|
||||
|
||||
class MeetingService {
|
||||
getAllMeetings() {
|
||||
return axios.get(`/api/meetings/listAll`);
|
||||
}
|
||||
|
||||
getMeetingById(id) {
|
||||
// 使用 POST 方法并传递请求体
|
||||
return axios.post(`/api/meetings/getMeetingById`, { id });
|
||||
}
|
||||
|
||||
createMeeting(meeting) {
|
||||
return axios.post(`/api/meetings/addMeeting`, meeting);
|
||||
}
|
||||
|
||||
updateMeeting(id, meeting) {
|
||||
// Convert meeting object to a map
|
||||
const meetingMap = {
|
||||
id: id,
|
||||
name: meeting.name,
|
||||
organizer: meeting.organizer,
|
||||
startTime: meeting.startTime,
|
||||
endTime: meeting.endTime,
|
||||
content: meeting.content,
|
||||
status: meeting.status
|
||||
};
|
||||
return axios.post(`/api/meetings/updateMeeting`, meetingMap);
|
||||
}
|
||||
|
||||
deleteMeeting(id) {
|
||||
// 使用 POST 方法并传递请求体
|
||||
return axios.post(`/api/meetings/deleteMeeting`, { id });
|
||||
}
|
||||
|
||||
searchMeetings(params) {
|
||||
// 使用 POST 方法并传递请求体
|
||||
return axios.post(`/api/meetings/searchMeetings`, params);
|
||||
}
|
||||
}
|
||||
|
||||
export default new MeetingService();
|
||||
@ -0,0 +1,24 @@
|
||||
import axios from "axios";
|
||||
|
||||
export default {
|
||||
getAllOrganizations() {
|
||||
return axios.get('api/organizations/listAll').then(response => {
|
||||
return response.data;
|
||||
});
|
||||
},
|
||||
addOrganization(organization) {
|
||||
return axios.post('api/organizations/addOrganization', organization).then(response => {
|
||||
return response.data;
|
||||
});
|
||||
},
|
||||
deleteOrganization(organizationId) {
|
||||
return axios.post('api/organizations/deleteOrganization' , {organizationId:organizationId},{headers: {
|
||||
'Content-Type': 'application/json' // 设置 Content-Type 为 application/json
|
||||
}}).then(response => {
|
||||
return response.data;
|
||||
});
|
||||
},
|
||||
getOrganizationByName(organizationName){
|
||||
return axios.get('api/organizations/getByOrganizationName?')
|
||||
}
|
||||
}
|
||||
50
src/services/tenantService.js
Normal file
50
src/services/tenantService.js
Normal file
@ -0,0 +1,50 @@
|
||||
import axios from "axios";
|
||||
import store from "@store/index.js"
|
||||
|
||||
export default {
|
||||
addTenant(tenant) {
|
||||
const token = store.getters['authentication/token']
|
||||
const url = `/api/tenant/addTenant?token=${token}`
|
||||
const data = {
|
||||
symbol: tenant.symbol,
|
||||
contact: tenant.contact,
|
||||
phone: tenant.phone,
|
||||
manager: tenant.manager,
|
||||
name: tenant.name,
|
||||
}
|
||||
return axios.post(url, data)
|
||||
.then(response => {
|
||||
if (response.data != null) {
|
||||
alert("新增成功");
|
||||
} else
|
||||
alert("新增失败");
|
||||
location.href = "/tenantManagement";
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
|
||||
async getAll() {
|
||||
const token = store.getters['authentication/token']
|
||||
const url = `/api/tenant/getAllTenant?token=${token}`
|
||||
const response = await axios.get(url)
|
||||
return response.data;
|
||||
},
|
||||
|
||||
update(tenant) {
|
||||
const token = store.getters['authentication/token']
|
||||
const url = `/api/tenant/updateTenant?token=${token}`;
|
||||
return axios.post(url, tenant)
|
||||
.then(response => {
|
||||
});
|
||||
},
|
||||
|
||||
delete(tenant) {
|
||||
const token = store.getters['authentication/token']
|
||||
const url = `/api/tenant/deleteTenant?token=${token}`;
|
||||
return axios.post(url, tenant)
|
||||
.then(response => {
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
import axios from "axios";
|
||||
import {useStore} from 'vuex';
|
||||
import store from '@store/index.js'
|
||||
|
||||
export default {
|
||||
addUser(user){
|
||||
const token = store.getters['authentication/token']
|
||||
const url=`/api/user/addUser?token=${token}`
|
||||
const data={
|
||||
account: user.account,
|
||||
name: user.name,
|
||||
organization: user.organization,
|
||||
email: user.email,
|
||||
gender: user.gender,
|
||||
phone: user.phone,
|
||||
password:user.password
|
||||
}
|
||||
return axios.post(url, data)
|
||||
.then(response => {
|
||||
if(response.data!=null){
|
||||
alert("新增成功");
|
||||
}else
|
||||
alert("新增失败");
|
||||
location.href="/userManagement";
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
|
||||
async getAll() {
|
||||
const token = store.getters['authentication/token']
|
||||
const url = `/api/user/getAll?token=${token}`
|
||||
const response = await axios.get(url)
|
||||
return response.data;
|
||||
},
|
||||
|
||||
update(user){
|
||||
const token = store.getters['authentication/token']
|
||||
const url=`/api/user/update?token=${token}`
|
||||
return axios.post(url,user)
|
||||
.then(() => {
|
||||
location.href="/userManagement";
|
||||
});
|
||||
},
|
||||
|
||||
async delete(user){
|
||||
const token = store.getters['authentication/token']
|
||||
const url=`/api/user/delete?token=${token}`
|
||||
return await axios.post(url, user)
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,27 +1,96 @@
|
||||
import MeetingService from '../services/meetingService';
|
||||
|
||||
const state = {
|
||||
meetings: []
|
||||
}
|
||||
meetings: [],
|
||||
currentMeeting: null
|
||||
};
|
||||
|
||||
const mutations = {
|
||||
setMeetings(state, meetings) {
|
||||
state.meetings = meetings
|
||||
state.meetings = meetings;
|
||||
},
|
||||
setCurrentMeeting(state, meeting) {
|
||||
state.currentMeeting = meeting;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const actions = {
|
||||
fetchMeetings({ commit }) {
|
||||
// 模拟API调用
|
||||
const meetings = [
|
||||
{ id: 1, title: 'Meeting 1' },
|
||||
{ id: 2, title: 'Meeting 2' }
|
||||
]
|
||||
commit('setMeetings', meetings)
|
||||
async fetchMeetings({ commit }) {
|
||||
try {
|
||||
const response = await MeetingService.getAllMeetings();
|
||||
commit('setMeetings', response.data);
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch meetings:', error);
|
||||
}
|
||||
},
|
||||
async searchMeetings({ commit }, params) {
|
||||
try {
|
||||
const formattedparams = {
|
||||
name: params.name,
|
||||
organizer: params.organizer,
|
||||
startTime: params.startTime,
|
||||
|
||||
};
|
||||
const response = await MeetingService.searchMeetings(formattedparams);
|
||||
commit('setMeetings', response.data);
|
||||
} catch (error) {
|
||||
console.error('Failed to search meetings:', error);
|
||||
}
|
||||
},
|
||||
async fetchMeetingById({ commit }, id) {
|
||||
try {
|
||||
const response = await MeetingService.getMeetingById(id);
|
||||
commit('setCurrentMeeting', response.data);
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch meeting:', error);
|
||||
}
|
||||
},
|
||||
async createMeeting({ dispatch }, meeting) {
|
||||
try {
|
||||
const formattedMeeting = {
|
||||
name: meeting.name,
|
||||
organizer: meeting.organizer,
|
||||
startTime: meeting.startTime,
|
||||
endTime: meeting.endTime,
|
||||
content: meeting.content,
|
||||
status: 'Scheduled' // 确保状态为 'Scheduled'
|
||||
};
|
||||
await MeetingService.createMeeting(formattedMeeting);
|
||||
dispatch('fetchMeetings');
|
||||
} catch (error) {
|
||||
console.error('Failed to create meeting:', error);
|
||||
}
|
||||
},
|
||||
async editMeeting({ dispatch }, meeting) {
|
||||
try {
|
||||
const formattedMeeting = {
|
||||
name: meeting.name,
|
||||
organizer: meeting.organizer,
|
||||
startTime: meeting.startTime,
|
||||
endTime: meeting.endTime,
|
||||
content: meeting.content,
|
||||
status: 'Scheduled' // 确保状态为 'Scheduled'
|
||||
};
|
||||
await MeetingService.updateMeeting(meeting.id, formattedMeeting);
|
||||
dispatch('fetchMeetings');
|
||||
} catch (error) {
|
||||
console.error('Failed to update meeting:', error);
|
||||
}
|
||||
},
|
||||
async deleteMeeting({ dispatch }, id) {
|
||||
try {
|
||||
await MeetingService.deleteMeeting(id);
|
||||
dispatch('fetchMeetings');
|
||||
} catch (error) {
|
||||
console.error('Failed to delete meeting:', error);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const getters = {
|
||||
allMeetings: state => state.meetings
|
||||
}
|
||||
allMeetings: state => state.meetings,
|
||||
currentMeeting: state => state.currentMeeting
|
||||
};
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
@ -29,4 +98,4 @@ export default {
|
||||
mutations,
|
||||
actions,
|
||||
getters
|
||||
}
|
||||
};
|
||||
@ -23,7 +23,7 @@ const handleLogin = async () => {
|
||||
|
||||
if (response.status === 200) {
|
||||
ElMessage.success('登录成功');
|
||||
router.push('/profile');
|
||||
router.push('/');
|
||||
} else {
|
||||
ElMessage.error('登录失败,请稍后再试');
|
||||
}
|
||||
|
||||
17
src/views/course-management/BackgroundWrapper.vue
Normal file
17
src/views/course-management/BackgroundWrapper.vue
Normal file
@ -0,0 +1,17 @@
|
||||
<template>
|
||||
<div class="background-wrapper">
|
||||
<slot></slot>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.background-wrapper {
|
||||
background: url('@public/background2.jpg') no-repeat center center fixed;
|
||||
background-size: cover;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
||||
425
src/views/course-management/Course.vue
Normal file
425
src/views/course-management/Course.vue
Normal file
@ -0,0 +1,425 @@
|
||||
<script setup>
|
||||
import {onMounted, ref, computed} from 'vue';
|
||||
import {
|
||||
ElButton,
|
||||
ElForm,
|
||||
ElFormItem,
|
||||
ElInput,
|
||||
ElMessage,
|
||||
ElMessageBox,
|
||||
ElUpload
|
||||
} from 'element-plus';
|
||||
|
||||
import {Delete, Plus, Refresh, ZoomIn} from "@element-plus/icons-vue";
|
||||
import {useRoute, useRouter} from "vue-router";
|
||||
import {useStore} from "vuex";
|
||||
import axios from "axios";
|
||||
import BackgroundWrapper from './BackgroundWrapper.vue'; // 导入 BackgroundWrapper
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const store = useStore();
|
||||
const token = ref('')
|
||||
const form = ref({
|
||||
token: '',
|
||||
title: '',
|
||||
description: '',
|
||||
orderNo: '',
|
||||
author: '',
|
||||
videoPath: '',
|
||||
imagePath: ''
|
||||
});
|
||||
const createMode = ref(false);
|
||||
const modeTitle = ref('');
|
||||
|
||||
const videoFileList = ref([]); // 用于存储上传视频文件的列表
|
||||
const imageFileList = ref([]); // 用于存储上传图片文件的列表
|
||||
const basePath = '/api/courses'
|
||||
const videoUploadUrl = basePath + '/upload'; // 上传视频的后端地址
|
||||
const imageUploadUrl = videoUploadUrl; // 上传图片的后端地址
|
||||
const dialogImageUrl = ref('');
|
||||
const dialogVisible = ref(false); // 用于图片放大预览
|
||||
|
||||
//下面是编辑模式需要的一些变量
|
||||
const id = ref('');
|
||||
|
||||
const beforeVideoUpload = (file) => {
|
||||
const isMp4 = file.type === 'video/mp4';
|
||||
if (!isMp4) {
|
||||
ElMessage.error('只能上传 mp4 格式的视频文件!');
|
||||
return false;
|
||||
}
|
||||
|
||||
const isLt500M = file.size / 1024 / 1024 < 500;
|
||||
if (!isLt500M) {
|
||||
ElMessage.error('上传视频大小不能超过 500MB!');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
const beforeImageUpload = (file) => {
|
||||
const isImage = file.type === 'image/png' || file.type === 'image/jpg' || file.type === 'image/jpeg';
|
||||
if (!isImage) {
|
||||
ElMessage.error('只能上传 png/jpg/jpeg 格式的图片文件!');
|
||||
return false;
|
||||
}
|
||||
|
||||
const isLt5M = file.size / 1024 / 1024 < 5;
|
||||
if (!isLt5M) {
|
||||
ElMessage.error('上传文件大小不能超过 5MB!');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
const handleVideoSuccess = (response, file, fileList) => {
|
||||
file.url = response.url;
|
||||
form.value.videoPath = response.url; // 确保设置到表单中
|
||||
};
|
||||
|
||||
const handleImageSuccess = (response, file, fileList) => {
|
||||
file.url = response.url;
|
||||
form.value.imagePath = response.url; // 确保设置到表单中
|
||||
};
|
||||
|
||||
const handleVideoError = (error, file, fileList) => {
|
||||
ElMessage.error('视频上传失败,请重试!');
|
||||
};
|
||||
|
||||
const handleImageError = (error, file, fileList) => {
|
||||
ElMessage.error('图片上传失败,请重试!');
|
||||
};
|
||||
|
||||
const handleVideoChange = (file, fileList) => {
|
||||
if (fileList.length > 1) {
|
||||
fileList.splice(0, fileList.length - 1)
|
||||
}
|
||||
};
|
||||
|
||||
const handleImageChange = (file, fileList) => {
|
||||
if (fileList.length > 1) {
|
||||
fileList.splice(0, fileList.length - 1)
|
||||
}
|
||||
};
|
||||
|
||||
const handlePictureCardPreview = (file) => {
|
||||
dialogImageUrl.value = file.url
|
||||
dialogVisible.value = true
|
||||
}
|
||||
const handleRemoveImage = (file) => {
|
||||
imageFileList.value = imageFileList.value.filter((item) => item.uid !== file.uid);
|
||||
}
|
||||
|
||||
const handleRemoveVideo = (file) => {
|
||||
videoFileList.value = videoFileList.value.filter((item) => item.uid !== file.uid);
|
||||
}
|
||||
|
||||
const handleCommit = async () => {
|
||||
if (form.value.title === '' || form.value.description === '' || form.value.orderNo === '' || form.value.author === '') {
|
||||
await ElMessageBox.alert('请填写完整信息!');
|
||||
return;
|
||||
}
|
||||
if (isNaN(form.value.orderNo)) {
|
||||
await ElMessageBox.alert('排序必须是一个数字!');
|
||||
return;
|
||||
}
|
||||
if (imageFileList.value.length === 0 || videoFileList.value.length === 0) {
|
||||
await ElMessageBox.alert('请选择封面图片和课程视频!');
|
||||
return;
|
||||
}
|
||||
form.value.imagePath = imageFileList.value[0].url;
|
||||
form.value.videoPath = videoFileList.value[0].url;
|
||||
if (createMode.value) {
|
||||
try {
|
||||
const response = await axios.post(basePath, form.value);
|
||||
ElMessage.success('添加成功!');
|
||||
router.push('/courseList');
|
||||
} catch (e) {
|
||||
await ElMessageBox.alert(e.response.data.message);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
const response = await axios.put(`${basePath}/${id.value}`, form.value);
|
||||
ElMessage.success('修改成功!');
|
||||
router.push('/courseList');
|
||||
} catch (e) {
|
||||
await ElMessageBox.alert(e.response.data.message);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
const isLayoutReady = ref(false);
|
||||
|
||||
const fetchCourseDetail = async () => {
|
||||
let params = {
|
||||
token: token.value,
|
||||
}
|
||||
const res = await axios.get(basePath + '/' + id.value, {params});
|
||||
form.value.title = res.data.title;
|
||||
form.value.description = res.data.description;
|
||||
form.value.orderNo = res.data.orderNo;
|
||||
form.value.author = res.data.author;
|
||||
form.value.videoPath = res.data.videoPath;
|
||||
form.value.imagePath = res.data.imagePath;
|
||||
imageFileList.value.push({url: res.data.imagePath});
|
||||
videoFileList.value.push({url: res.data.videoPath});
|
||||
}
|
||||
|
||||
const orderNo = computed({
|
||||
get() {
|
||||
return form.value.orderNo;
|
||||
},
|
||||
set(value) {
|
||||
form.value.orderNo = value.replace(/\D/g, ''); // 只保留数字
|
||||
}
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
token.value = store.getters['authentication/token'];
|
||||
form.value.token = token.value;
|
||||
if (route.query.mode === 'create' || route.params.mode === 'create') {
|
||||
createMode.value = true;
|
||||
modeTitle.value = '添加课程';
|
||||
}
|
||||
if (route.query.mode === 'edit' || route.params.mode === 'edit') {
|
||||
id.value = route.params.id === undefined ? route.query.id : route.params.id;
|
||||
createMode.value = false;
|
||||
modeTitle.value = '修改课程';
|
||||
fetchCourseDetail();
|
||||
}
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<BackgroundWrapper class="background-wrapper">
|
||||
<div class="form-container">
|
||||
<ElForm :model="form" label-width="120px" @submit.prevent="handleCommit">
|
||||
<h2>{{ modeTitle }}</h2>
|
||||
<ElFormItem label="课程名称" required>
|
||||
<ElInput v-model="form.title" placeholder="请输入课程名称" required></ElInput>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="课程封面" required>
|
||||
<el-upload
|
||||
:action="imageUploadUrl"
|
||||
:limit="2"
|
||||
:before-upload="beforeImageUpload"
|
||||
:on-success="handleImageSuccess"
|
||||
:on-error="handleImageError"
|
||||
:on-change="handleImageChange"
|
||||
:file-list="imageFileList"
|
||||
list-type="picture-card"
|
||||
auto-upload
|
||||
v-model:file-list="imageFileList"
|
||||
>
|
||||
<template #file="{ file }">
|
||||
<div>
|
||||
<img class="el-upload-list__item-thumbnail" :src="file.url" alt=""/>
|
||||
<span class="el-upload-list__item-actions">
|
||||
<span
|
||||
class="el-upload-list__item-preview"
|
||||
@click="handlePictureCardPreview(file)"
|
||||
>
|
||||
<el-icon><zoom-in/></el-icon>
|
||||
</span>
|
||||
<span
|
||||
class="el-upload-list__item-delete"
|
||||
@click="handleRemoveImage(file)"
|
||||
>
|
||||
<el-icon><Delete/></el-icon>
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
<el-icon v-if="imageFileList.length === 0">
|
||||
<Plus/>
|
||||
</el-icon>
|
||||
<el-icon v-else>
|
||||
<Refresh/>
|
||||
</el-icon>
|
||||
</el-upload>
|
||||
<div class="tip">
|
||||
请上传大小不超过 <span style="color: red;">5MB</span> 格式为 <span style="color: red;">png/jpg/jpeg</span> 的文件
|
||||
</div>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="课程视频" required>
|
||||
<el-upload
|
||||
:action="videoUploadUrl"
|
||||
:limit="2"
|
||||
:before-upload="beforeVideoUpload"
|
||||
:on-success="handleVideoSuccess"
|
||||
:on-error="handleVideoError"
|
||||
:on-change="handleVideoChange"
|
||||
:file-list="videoFileList"
|
||||
list-type="picture-card"
|
||||
auto-upload
|
||||
v-model:file-list="videoFileList"
|
||||
>
|
||||
<template #file="{ file }">
|
||||
<div>
|
||||
<video class="el-upload-list__item-thumbnail" :src="file.url" controls></video>
|
||||
<span class="el-upload-list__item-actions">
|
||||
<span
|
||||
class="el-upload-list__item-delete"
|
||||
@click="handleRemoveVideo(file)"
|
||||
>
|
||||
<el-icon><Delete/></el-icon>
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
<el-icon v-if="videoFileList.length === 0">
|
||||
<Plus/>
|
||||
</el-icon>
|
||||
<el-icon v-else>
|
||||
<Refresh/>
|
||||
</el-icon>
|
||||
</el-upload>
|
||||
<div class="tip">
|
||||
请上传大小不超过 <span style="color: red;">500MB</span> 格式为 <span style="color: red;">mp4</span> 的文件
|
||||
</div>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="课程简介" required>
|
||||
<ElInput v-model="form.description" placeholder="请输入课程简介" required></ElInput>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="课程排序" required>
|
||||
<ElInput v-model="orderNo" placeholder="请输入课程排序(数字)" required></ElInput>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="作者" required>
|
||||
<ElInput v-model="form.author" placeholder="请输入作者" required></ElInput>
|
||||
</ElFormItem>
|
||||
<ElFormItem>
|
||||
<ElButton type="primary" native-type="submit">确定</ElButton>
|
||||
<ElButton @click="router.push('/courseList')">取消</ElButton>
|
||||
</ElFormItem>
|
||||
</ElForm>
|
||||
</div>
|
||||
|
||||
<el-dialog v-model="dialogVisible" class="image-preview">
|
||||
<img w-full :src="dialogImageUrl" alt="Preview Image"/>
|
||||
</el-dialog>
|
||||
</BackgroundWrapper>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
html, body {
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.background-wrapper {
|
||||
position: fixed; /* 确保背景覆盖整个视口 */
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: auto; /* 只在内容溢出时允许滚动 */
|
||||
/* 自定义滚动条样式 */
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: #007bff #f0f0f0;
|
||||
}
|
||||
|
||||
/* 针对 Webkit 浏览器的自定义滚动条 */
|
||||
.background-wrapper::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
}
|
||||
|
||||
.background-wrapper::-webkit-scrollbar-track {
|
||||
background: #f0f0f0;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.background-wrapper::-webkit-scrollbar-thumb {
|
||||
background-color: #007bff;
|
||||
border-radius: 10px;
|
||||
border: 3px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.form-container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100%;
|
||||
overflow-y: auto; /* 使容器在内容溢出时出现滚动条 */
|
||||
}
|
||||
|
||||
.image-preview {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.image-preview img {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.tip {
|
||||
margin-top: 8px;
|
||||
color: #727272;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.el-form {
|
||||
background: white;
|
||||
padding: 2rem;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
||||
width: 65%; /* 增加宽度 */
|
||||
max-height: 90vh; /* 确保表单不会超过视口高度 */
|
||||
overflow-y: auto; /* 使表单在内容溢出时出现滚动条 */
|
||||
/* 自定义滚动条样式 */
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: #007bff #f0f0f0;
|
||||
}
|
||||
|
||||
/* 针对 Webkit 浏览器的自定义滚动条 */
|
||||
.el-form::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
}
|
||||
|
||||
.el-form::-webkit-scrollbar-track {
|
||||
background: #f0f0f0;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.el-form::-webkit-scrollbar-thumb {
|
||||
background-color: #007bff;
|
||||
border-radius: 10px;
|
||||
border: 3px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.el-form-item {
|
||||
margin-bottom: 1rem;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.el-form-item label {
|
||||
display: block;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.el-input,
|
||||
.el-select {
|
||||
width: calc(100% - 12px); /* 设置文本框宽度,使其与滚动条保持一定距离 */
|
||||
}
|
||||
|
||||
.el-button--primary {
|
||||
background-color: #007bff;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.el-button--primary:hover {
|
||||
background-color: #0056b3;
|
||||
}
|
||||
|
||||
.dynamic-width-select {
|
||||
min-width: 30%;
|
||||
max-width: 100%;
|
||||
width: auto; /* 使宽度根据内容调整 */
|
||||
}
|
||||
</style>
|
||||
333
src/views/course-management/CourseList.vue
Normal file
333
src/views/course-management/CourseList.vue
Normal file
@ -0,0 +1,333 @@
|
||||
<script setup>
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { ElButton, ElForm, ElFormItem, ElInput, ElMessage, ElMessageBox, ElPagination, ElTable, ElTableColumn } from 'element-plus';
|
||||
import axios from "axios";
|
||||
import { useStore } from "vuex";
|
||||
import { useRouter } from "vue-router";
|
||||
import Course from "@views/course-management/Course.vue";
|
||||
import BackgroundWrapper from './BackgroundWrapper.vue';
|
||||
import _ from 'lodash';
|
||||
import { write, utils } from 'xlsx';
|
||||
import { saveAs } from 'file-saver';
|
||||
|
||||
const router = useRouter();
|
||||
const store = useStore();
|
||||
const token = store.getters['authentication/token'];
|
||||
|
||||
const searchTitle = ref('');
|
||||
const searchAuthor = ref('');
|
||||
const searchDescription = ref('');
|
||||
const sortOrder = ref('');
|
||||
|
||||
const allCoursesData = ref([]);
|
||||
const coursesData = ref([]);
|
||||
|
||||
const currentPage = ref(1);
|
||||
const pageSize = ref(10);
|
||||
const coursesCount = ref(0);
|
||||
const firstTimeLoad = ref(true);
|
||||
|
||||
const selections = ref([]);
|
||||
|
||||
const loadCourses = async (forceReload = false) => {
|
||||
if (forceReload) {
|
||||
firstTimeLoad.value = true;
|
||||
allCoursesData.value = [];
|
||||
}
|
||||
|
||||
if (firstTimeLoad.value || allCoursesData.value.length < (currentPage.value * pageSize.value) && (currentPage.value * pageSize.value) <= coursesCount.value) {
|
||||
let params = {
|
||||
token: token,
|
||||
start: allCoursesData.value.length,
|
||||
end: allCoursesData.value.length + pageSize.value * 2
|
||||
};
|
||||
try {
|
||||
const response = await axios.get('/api/courses', { params });
|
||||
const data = response.data;
|
||||
coursesCount.value = data.courseCount;
|
||||
allCoursesData.value.push(...data.courseList);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
firstTimeLoad.value = false;
|
||||
}
|
||||
coursesData.value = allCoursesData.value.slice((currentPage.value - 1) * pageSize.value, currentPage.value * pageSize.value);
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
loadCourses();
|
||||
});
|
||||
|
||||
const handleSearch = async () => {
|
||||
try {
|
||||
const response = await axios.get('/api/courses/search', {
|
||||
params: {
|
||||
token: token,
|
||||
title: searchTitle.value || '',
|
||||
author: searchAuthor.value || '',
|
||||
description: searchDescription.value || '',
|
||||
sortOrder: sortOrder.value || '',
|
||||
start: 0,
|
||||
end: pageSize.value
|
||||
}
|
||||
});
|
||||
const data = response.data;
|
||||
coursesCount.value = data.courseCount;
|
||||
allCoursesData.value = data.courseList;
|
||||
coursesData.value = allCoursesData.value.slice(0, pageSize.value);
|
||||
currentPage.value = 1;
|
||||
firstTimeLoad.value = false;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
};
|
||||
|
||||
const handleReset = async () => {
|
||||
searchTitle.value = '';
|
||||
searchAuthor.value = '';
|
||||
searchDescription.value = '';
|
||||
sortOrder.value = '';
|
||||
await loadCourses(true); // 强制重新加载课程数据
|
||||
};
|
||||
|
||||
const handleSort = async () => {
|
||||
// 将所有课程的排序字段转换成数值
|
||||
const sortedCourses = _.cloneDeep(allCoursesData.value).map(course => ({
|
||||
...course,
|
||||
orderNo: Number(course.orderNo)
|
||||
})).sort((a, b) => a.orderNo - b.orderNo);
|
||||
|
||||
// 更新所有课程的数据
|
||||
allCoursesData.value = sortedCourses;
|
||||
|
||||
// 计算当前分页的数据
|
||||
const start = (currentPage.value - 1) * pageSize.value;
|
||||
const end = start + pageSize.value;
|
||||
coursesData.value = allCoursesData.value.slice(start, end);
|
||||
};
|
||||
|
||||
const handleExport = () => {
|
||||
// 创建一个新的工作簿
|
||||
const workbook = utils.book_new();
|
||||
|
||||
// 创建工作表数据,提取 allCoursesData
|
||||
const sheetData = allCoursesData.value.map(course => ({
|
||||
'课程名称': course.title,
|
||||
'作者': course.author,
|
||||
'课程简介': course.description,
|
||||
'排序': course.orderNo
|
||||
}));
|
||||
|
||||
// 将数据放入工作表
|
||||
const worksheet = utils.json_to_sheet(sheetData);
|
||||
|
||||
// 将工作表添加到工作簿中
|
||||
utils.book_append_sheet(workbook, worksheet, 'Courses');
|
||||
|
||||
// 生成 Excel 文件
|
||||
const wbout = write(workbook, { bookType: 'xlsx', type: 'array' });
|
||||
|
||||
// 使用 file-saver 保存文件
|
||||
saveAs(new Blob([wbout], { type: 'application/octet-stream' }), '课程信息.xlsx');
|
||||
};
|
||||
|
||||
const handleEditButton = () => {
|
||||
if (selections.value.length === 1) {
|
||||
// 只有一个课程被选中,导航到编辑页面
|
||||
const selectedCourse = selections.value[0];
|
||||
router.push({ name: 'Course', query: { mode: 'edit', id: selectedCourse.id } });
|
||||
} else if (selections.value.length > 1) {
|
||||
// 选中了多个课程,弹出提示
|
||||
ElMessage.warning('无法同时修改多个目标');
|
||||
} else {
|
||||
// 没有选中任何课程,弹出提示
|
||||
ElMessage.warning('请先选择要修改的课程');
|
||||
}
|
||||
};
|
||||
|
||||
const handleDeleteButton = async () => {
|
||||
if (selections.value.length === 0) {
|
||||
ElMessage.warning('请先选择要删除的课程');
|
||||
return;
|
||||
}
|
||||
|
||||
ElMessageBox.confirm(
|
||||
'是否确认删除选中的课程?此操作不可撤销。',
|
||||
'确认删除',
|
||||
{
|
||||
confirmButtonText: '确认',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}
|
||||
).then(async () => {
|
||||
try {
|
||||
const deletePromises = selections.value.map(selection =>
|
||||
axios.delete(`/api/courses/${selection.id}`, { params: { token: token } })
|
||||
);
|
||||
await Promise.all(deletePromises);
|
||||
ElMessage.success('删除成功');
|
||||
selections.value = []; // 清空选中项
|
||||
await loadCourses(true); // 强制重新加载课程数据
|
||||
} catch (e) {
|
||||
ElMessage.error('删除失败');
|
||||
console.error(e);
|
||||
}
|
||||
}).catch(() => {
|
||||
ElMessage.info('已取消删除操作');
|
||||
});
|
||||
};
|
||||
|
||||
const handleSelectionChange = (newSelections) => {
|
||||
selections.value = newSelections;
|
||||
};
|
||||
|
||||
const handleEditInTable = (index) => {
|
||||
router.push({ name: 'Course', query: { mode: 'edit', id: coursesData.value[index].id } });
|
||||
};
|
||||
|
||||
const handleDeleteInTable = async (index) => {
|
||||
ElMessageBox.confirm(
|
||||
'是否确认删除该课程?此操作不可撤销。',
|
||||
'确认删除',
|
||||
{
|
||||
confirmButtonText: '确认',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}
|
||||
).then(async () => {
|
||||
try {
|
||||
await axios.delete(`/api/courses/${coursesData.value[index].id}`, { params: { token: token } });
|
||||
coursesData.value.splice(index, 1);
|
||||
allCoursesData.value.splice(index, 1);
|
||||
coursesCount.value--;
|
||||
await loadCourses(true); // 强制重新加载课程数据
|
||||
} catch (e) {
|
||||
ElMessage.error('删除失败');
|
||||
console.error(e);
|
||||
}
|
||||
}).catch(() => {
|
||||
ElMessage.info('已取消删除操作');
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<BackgroundWrapper class="background-wrapper">
|
||||
<div class="center-wrapper">
|
||||
<div class="container">
|
||||
<div class="search-container">
|
||||
<el-form inline>
|
||||
<el-form-item label="课程名称">
|
||||
<el-input v-model="searchTitle" placeholder="请输入课程名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="排序">
|
||||
<el-input v-model="sortOrder" placeholder="请输入排序" />
|
||||
</el-form-item>
|
||||
<el-form-item label="作者">
|
||||
<el-input v-model="searchAuthor" placeholder="请输入作者" />
|
||||
</el-form-item>
|
||||
<el-form-item label="课程简介">
|
||||
<el-input v-model="searchDescription" placeholder="请输入简介" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="handleSearch">搜索</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="handleReset">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div class="button-container">
|
||||
<el-button type="success" @click="router.push('/course?mode=create')">新增</el-button>
|
||||
<el-button type="warning" @click="handleEditButton">修改</el-button>
|
||||
<el-button type="danger" @click="handleDeleteButton">删除</el-button>
|
||||
<el-button type="info" @click="handleSort">排序</el-button>
|
||||
<el-button type="primary" @click="handleExport">导出</el-button>
|
||||
</div>
|
||||
|
||||
<el-table :data="coursesData" style="width: 100%;" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55"></el-table-column>
|
||||
<el-table-column prop="orderNo" label="排序" align="center"></el-table-column>
|
||||
<el-table-column prop="title" label="课程名称" align="center"></el-table-column>
|
||||
<el-table-column prop="author" label="作者" align="center"></el-table-column>
|
||||
<el-table-column prop="description" label="课程简介" align="center"></el-table-column>
|
||||
<el-table-column label="操作" align="center">
|
||||
<template #default="scope">
|
||||
<el-button @click="handleEditInTable(scope.$index)" type="text">修改</el-button>
|
||||
<el-button @click="handleDeleteInTable(scope.$index)" type="text">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<div class="pagination-container">
|
||||
<el-pagination
|
||||
@size-change="pageSize = $event; loadCourses(true)"
|
||||
@current-change="currentPage = $event; loadCourses(true)"
|
||||
:current-page="currentPage"
|
||||
:page-size="pageSize"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
:total="coursesCount"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
>
|
||||
</el-pagination>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</BackgroundWrapper>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
html, body {
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.background-wrapper {
|
||||
position: fixed; /* 确保背景覆盖整个视口 */
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: auto; /* 只在内容溢出时允许滚动 */
|
||||
}
|
||||
|
||||
.center-wrapper {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.container {
|
||||
padding: 20px;
|
||||
background: rgba(255, 255, 255, 0.8); /* 为了让内容清晰,可加上一层半透明白色背景 */
|
||||
border-radius: 15px;
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
||||
max-width: 800px; /* 控制页面内容宽度 */
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.search-container {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.button-container {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.el-table {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.pagination-container {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-bottom: -10px;
|
||||
}
|
||||
</style>
|
||||
57
src/views/meeting-management/AddMeeting.vue
Normal file
57
src/views/meeting-management/AddMeeting.vue
Normal file
@ -0,0 +1,57 @@
|
||||
<template>
|
||||
<el-form :model="meeting" label-width="120px" @submit.native.prevent="submitForm">
|
||||
<el-form-item label="会议名称">
|
||||
<el-input v-model="meeting.name"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="创建人">
|
||||
<el-input v-model="meeting.organizer"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="开始时间">
|
||||
<el-date-picker v-model="meeting.startTime" type="datetime" placeholder="选择时间"></el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="结束时间">
|
||||
<el-date-picker v-model="meeting.endTime" type="datetime" placeholder="选择时间"></el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="会议内容">
|
||||
<el-input type="textarea" v-model="meeting.content"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="submitForm">确定</el-button>
|
||||
<el-button @click="cancel">取消</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapActions } from 'vuex';
|
||||
|
||||
export default {
|
||||
name: 'AddMeeting',
|
||||
data() {
|
||||
return {
|
||||
meeting: {
|
||||
name: '',
|
||||
organizer: '',
|
||||
startTime: '',
|
||||
endTime: '',
|
||||
content: '',
|
||||
status: 'Scheduled' // 确保状态为 'Scheduled'
|
||||
}
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
...mapActions('meetingManagement', ['createMeeting']),
|
||||
async submitForm() {
|
||||
try {
|
||||
await this.createMeeting(this.meeting);
|
||||
this.$router.push({ name: 'MeetingManagement' });
|
||||
} catch (error) {
|
||||
console.error('Failed to create meeting:', error);
|
||||
}
|
||||
},
|
||||
cancel() {
|
||||
this.$router.push({ name: 'MeetingManagement' });
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
61
src/views/meeting-management/EditMeeting.vue
Normal file
61
src/views/meeting-management/EditMeeting.vue
Normal file
@ -0,0 +1,61 @@
|
||||
<template>
|
||||
<el-form :model="meeting" label-width="120px" @submit.native.prevent="submitForm">
|
||||
<el-form-item label="会议名称">
|
||||
<el-input v-model="meeting.name"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="创建人">
|
||||
<el-input v-model="meeting.organizer"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="开始时间">
|
||||
<el-date-picker v-model="meeting.startTime" type="datetime" placeholder="选择时间"></el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="结束时间">
|
||||
<el-date-picker v-model="meeting.endTime" type="datetime" placeholder="选择时间"></el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="会议内容">
|
||||
<el-input type="textarea" v-model="meeting.content"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="submitForm">确定</el-button>
|
||||
<el-button @click="cancel">取消</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapActions, mapGetters } from 'vuex';
|
||||
|
||||
export default {
|
||||
name: 'EditMeeting',
|
||||
data() {
|
||||
return {
|
||||
meeting: {
|
||||
id: '',
|
||||
name: '',
|
||||
organizer: '',
|
||||
startTime: '',
|
||||
endTime: '',
|
||||
content: '',
|
||||
status: 'Active'
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapGetters('meetingManagement', ['currentMeeting'])
|
||||
},
|
||||
methods: {
|
||||
...mapActions('meetingManagement', ['fetchMeetingById', 'editMeeting']),
|
||||
async submitForm() {
|
||||
await this.editMeeting(this.meeting);
|
||||
this.$router.push({ name: 'MeetingManagement' });
|
||||
},
|
||||
cancel() {
|
||||
this.$router.push({ name: 'MeetingManagement' });
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
await this.fetchMeetingById(this.$route.params.id);
|
||||
Object.assign(this.meeting, this.currentMeeting);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
162
src/views/meeting-management/MeetingManagement.vue
Normal file
162
src/views/meeting-management/MeetingManagement.vue
Normal file
@ -0,0 +1,162 @@
|
||||
<template>
|
||||
<div class="meeting-management">
|
||||
<div class="header">
|
||||
<el-input v-model="searchName" placeholder="会议名称" class="search-input"></el-input>
|
||||
<el-input v-model="searchOrganizer" placeholder="创建人" class="search-input"></el-input>
|
||||
<el-date-picker v-model="searchStartTime" type="datetime" placeholder="开始时间" class="search-input"></el-date-picker>
|
||||
<el-button type="primary" @click="search">搜索</el-button>
|
||||
<el-button type="primary" @click="goToAddMeeting">添加会议</el-button>
|
||||
</div>
|
||||
<el-table :data="allMeetings" style="width: 100%">
|
||||
<el-table-column prop="id" label="会议ID" width="80"></el-table-column>
|
||||
<el-table-column prop="name" label="会议名称"></el-table-column>
|
||||
<el-table-column prop="organizer" label="组织者"></el-table-column>
|
||||
<el-table-column prop="startTime" label="开始时间"></el-table-column>
|
||||
<el-table-column prop="endTime" label="结束时间"></el-table-column>
|
||||
<el-table-column prop="status" label="状态"></el-table-column>
|
||||
<el-table-column label="操作" width="180">
|
||||
<template #default="scope">
|
||||
<el-button @click="editMeeting(scope.row.id)" type="text">修改</el-button>
|
||||
<el-button @click="confirmDelete(scope.row.id)" type="text" class="delete-button">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
:current-page="currentPage"
|
||||
:page-sizes="[10, 20, 30, 40]"
|
||||
:page-size="pageSize"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
:total="total"
|
||||
></el-pagination>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapActions, mapGetters } from 'vuex';
|
||||
import axios from 'axios';
|
||||
import MeetingService from "@services/meetingService.js";
|
||||
import MeetingManagement from "@store/meetingManagement.js";
|
||||
import meetingManagement from "@store/meetingManagement.js";
|
||||
|
||||
export default {
|
||||
name: 'MeetingManagement',
|
||||
data() {
|
||||
return {
|
||||
currentPage: 1,
|
||||
pageSize: 10,
|
||||
total: 0,
|
||||
searchName: '',
|
||||
searchOrganizer: '',
|
||||
searchStartTime: null,
|
||||
allMeeting:''
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapGetters('meetingManagement', ['allMeetings'])
|
||||
},
|
||||
methods: {
|
||||
...mapActions('meetingManagement', ['fetchMeetings', 'searchMeetings', 'deleteMeeting']),
|
||||
goToAddMeeting() {
|
||||
this.$router.push({ name: 'AddMeeting' });
|
||||
},
|
||||
editMeeting(id) {
|
||||
this.$router.push({ name: 'EditMeeting', params: { id } });
|
||||
},
|
||||
confirmDelete(id) {
|
||||
this.$confirm(
|
||||
'是否确认删除会议管理编号为 "' + id + '" 的数据项?',
|
||||
'系统提示',
|
||||
{
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}
|
||||
)
|
||||
.then(() => {
|
||||
this.deleteMeeting(id).then(() => {
|
||||
this.fetchMeetings();
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
},
|
||||
handleSizeChange(val) {
|
||||
this.pageSize = val;
|
||||
this.fetchMeetings();
|
||||
},
|
||||
handleCurrentChange(val) {
|
||||
this.currentPage = val;
|
||||
this.fetchMeetings();
|
||||
},
|
||||
search() {
|
||||
const params = {
|
||||
name: this.searchName,
|
||||
organizer: this.searchOrganizer,
|
||||
startTime: this.searchStartTime ? this.searchStartTime.toISOString() : null
|
||||
};
|
||||
this.allMeeting = this.searchMeetings(params)
|
||||
},
|
||||
exportMeetings() {
|
||||
axios
|
||||
.post(
|
||||
'/api/meetings/export',
|
||||
{
|
||||
name: this.searchName,
|
||||
organizer: this.searchOrganizer,
|
||||
startTime: this.searchStartTime ? this.searchStartTime.toISOString() : null
|
||||
},
|
||||
{ responseType: 'blob' }
|
||||
)
|
||||
.then(response => {
|
||||
const url = window.URL.createObjectURL(new Blob([response.data]));
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.setAttribute('download', 'meetings.xlsx');
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('导出失败', error);
|
||||
});
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.fetchMeetings();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.meeting-management {
|
||||
padding: 20px;
|
||||
background-color: #f5f5f5;
|
||||
border-radius: 8px;
|
||||
}
|
||||
.header {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.search-input {
|
||||
margin-right: 10px;
|
||||
}
|
||||
.el-button {
|
||||
margin-right: 10px;
|
||||
}
|
||||
.el-table {
|
||||
background-color: #fff;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
}
|
||||
.el-pagination {
|
||||
margin-top: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
.delete-button {
|
||||
color: #f56c6c;
|
||||
}
|
||||
.delete-button:hover {
|
||||
color: #ff7875;
|
||||
}
|
||||
</style>
|
||||
@ -87,6 +87,8 @@ const props = defineProps({
|
||||
const containerStyle = ref('form-container')
|
||||
|
||||
const emit = defineEmits(['setNewsDialogInvisible']);
|
||||
|
||||
const options = ref([])
|
||||
const setNewsDialogInvisible = (changed) => {
|
||||
emit('setNewsDialogInvisible', changed);
|
||||
};
|
||||
@ -204,6 +206,18 @@ const fetchNewsDetail = async () => {
|
||||
fileList.value.push({url: res.data.imagePath});
|
||||
}
|
||||
|
||||
const fetchOptions = async () => {
|
||||
const params = {
|
||||
token: token.value,
|
||||
}
|
||||
try{
|
||||
const res = await axios.get('/api/tenant/getTenantOptions',{params});
|
||||
options.value = res.data.options;
|
||||
} catch (e) {
|
||||
await ElMessageBox.alert(e.response.data.message);
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
token.value = store.getters['authentication/token'];
|
||||
form.value.token = token.value;
|
||||
@ -220,6 +234,12 @@ onMounted(() => {
|
||||
modeTitle.value = '修改资讯';
|
||||
fetchNewsDetail();
|
||||
}
|
||||
else if (props.mode === 'show'){
|
||||
createMode.value = false;
|
||||
id.value = props.id;
|
||||
modeTitle.value = '资讯详情';
|
||||
fetchNewsDetail();
|
||||
}
|
||||
}
|
||||
else if (route.query.mode === 'create' || route.params.mode === 'create') {
|
||||
createMode.value = true;
|
||||
@ -231,6 +251,8 @@ onMounted(() => {
|
||||
fetchNewsDetail();
|
||||
}
|
||||
|
||||
fetchOptions()
|
||||
|
||||
config.value = {
|
||||
toolbar: {
|
||||
items: [
|
||||
@ -425,7 +447,7 @@ onMounted(() => {
|
||||
<ElForm :model="form" label-width="120px" @submit.prevent="handleCommit">
|
||||
<h2>{{ modeTitle }}</h2>
|
||||
<ElFormItem label="新闻标题" required>
|
||||
<ElInput v-model="form.title" placeholder="请输入新闻标题" required></ElInput>
|
||||
<ElInput v-model="form.title" placeholder="请输入新闻标题" :disabled="props.mode === 'show'" required></ElInput>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="新闻图片路径" required>
|
||||
<el-upload
|
||||
@ -439,6 +461,7 @@ onMounted(() => {
|
||||
list-type="picture-card"
|
||||
auto-upload
|
||||
v-model:file-list="fileList"
|
||||
:disabled="props.mode === 'show'"
|
||||
required
|
||||
>
|
||||
<template #file="{ file }">
|
||||
@ -454,6 +477,7 @@ onMounted(() => {
|
||||
<span
|
||||
class="el-upload-list__item-delete"
|
||||
@click="handleRemove(file)"
|
||||
v-if="props.mode !== 'show'"
|
||||
>
|
||||
<el-icon><Delete/></el-icon>
|
||||
</span>
|
||||
@ -476,27 +500,30 @@ onMounted(() => {
|
||||
ref="editorContainerElement">
|
||||
<div class="editor-container__editor">
|
||||
<div ref="editorElement">
|
||||
<ckeditor v-if="isLayoutReady" v-model="form.content" :editor="editor" :config="config"/>
|
||||
<ckeditor v-if="isLayoutReady" v-model="form.content" :editor="editor" :config="config" :disabled="props.mode === 'show'"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="作者" required>
|
||||
<ElInput v-model="form.author" placeholder="请输入作者" required></ElInput>
|
||||
<ElInput v-model="form.author" placeholder="请输入作者" :disabled="props.mode === 'show'" required></ElInput>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="新闻简介" required>
|
||||
<ElInput v-model="form.summary" placeholder="请输入新闻简介" required></ElInput>
|
||||
<ElInput v-model="form.summary" placeholder="请输入新闻简介" :disabled="props.mode === 'show'" required></ElInput>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="选择租户" required>
|
||||
<ElSelect v-model="form.tenant" placeholder="请选择" class="dynamic-width-select">
|
||||
<ElOption label="Option 1" value="option1"></ElOption>
|
||||
<ElOption label="Option 2" value="option2"></ElOption>
|
||||
<ElOption label="Option 3" value="option3"></ElOption>
|
||||
<ElSelect v-model="form.tenant" placeholder="请选择" class="dynamic-width-select" :disabled="props.mode === 'show'">
|
||||
<ElOption
|
||||
v-for="option in options"
|
||||
:key="option"
|
||||
:label="option"
|
||||
:value="option"
|
||||
></ElOption>
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem>
|
||||
<ElFormItem v-if="props.mode !== 'show'">
|
||||
<ElButton type="primary" native-type="submit">确定</ElButton>
|
||||
<ElButton @click="handleCancel">取消</ElButton>
|
||||
<ElButton @click="handleCancel">{{ props.mode === 'show' ? '返回' : '取消' }}</ElButton>
|
||||
</ElFormItem>
|
||||
</ElForm>
|
||||
</div>
|
||||
|
||||
@ -168,9 +168,9 @@ const handleSelectionChange = (newSelections) => {
|
||||
|
||||
const handleEditInTable = async (index) => {
|
||||
// router.push({name: 'editNews', query: {mode: 'edit', id: newsData.value[index].id}})
|
||||
editNewsDialogMode.value = 'edit'
|
||||
editId.value = newsData.value[index].id
|
||||
openEditNewsDialog()
|
||||
editNewsDialogMode.value = 'edit'
|
||||
editId.value = newsData.value[index].id
|
||||
openEditNewsDialog()
|
||||
};
|
||||
|
||||
const handleDeleteInTable = async (index) => {
|
||||
@ -199,10 +199,16 @@ const openEditNewsDialog = () => {
|
||||
|
||||
const setNewsDialogInvisible = (changed) => {
|
||||
editNewsDialogVisible.value = false;
|
||||
if (changed){
|
||||
if (changed) {
|
||||
refreshNewsList();
|
||||
}
|
||||
}
|
||||
|
||||
const handleShowDetail = (index) => {
|
||||
editNewsDialogMode.value = 'show'
|
||||
editId.value = newsData.value[index].id
|
||||
openEditNewsDialog()
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@ -215,9 +221,6 @@ const setNewsDialogInvisible = (changed) => {
|
||||
<el-form-item label="新闻图片路径">
|
||||
<el-input v-model="searchPath" placeholder="请输入路径"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="排序">
|
||||
<el-input v-model="sortOrder" placeholder="请输入排序"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="作者">
|
||||
<el-input v-model="searchAuthor" placeholder="请输入作者"/>
|
||||
</el-form-item>
|
||||
@ -239,10 +242,15 @@ const setNewsDialogInvisible = (changed) => {
|
||||
<el-button type="danger" @click="handleDeleteButton">删除</el-button>
|
||||
</div>
|
||||
|
||||
<el-table :data="newsData" style="width: 100%;"
|
||||
@selection-change="handleSelectionChange">
|
||||
<el-table :data="newsData" style="width: 100%;" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55"></el-table-column>
|
||||
<el-table-column prop="title" label="新闻标题" align="center"></el-table-column>
|
||||
<el-table-column prop="title" label="新闻标题" align="center">
|
||||
<template #default="scope">
|
||||
<div @click="handleShowDetail(scope.$index)" style="cursor: pointer;">
|
||||
{{ scope.row.title }}
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="author" label="作者" align="center"></el-table-column>
|
||||
<el-table-column prop="summary" label="新闻简介" align="center"></el-table-column>
|
||||
<el-table-column label="操作" align="center">
|
||||
|
||||
354
src/views/organization-management/Organization_main.vue
Normal file
354
src/views/organization-management/Organization_main.vue
Normal file
@ -0,0 +1,354 @@
|
||||
<template>
|
||||
<div class="department-management" v-if="showTable">
|
||||
<el-row :gutter="20" class="toolbar">
|
||||
<el-col :span="4">
|
||||
<el-input v-model="search.name" placeholder="请输入部门名称"></el-input>
|
||||
</el-col>
|
||||
<el-col :span="4">
|
||||
<el-select v-model="search.status" placeholder="部门状态">
|
||||
<el-option label="正常" value=true></el-option>
|
||||
<el-option label="停用" value=false></el-option>
|
||||
<el-option label="全部" value=""></el-option>
|
||||
</el-select>
|
||||
</el-col>
|
||||
<el-col :span="4">
|
||||
<el-button type="primary" @click="handleSearch">搜索</el-button>
|
||||
<el-button @click="handleReset">重置</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-button type="primary" @click="showDialogAdd = true">添加部门</el-button>
|
||||
<el-table
|
||||
:data="tableData"
|
||||
style="width: 100%; margin-bottom: 20px"
|
||||
row-key="organizationId"
|
||||
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
|
||||
border
|
||||
default-expand-all
|
||||
>
|
||||
<el-table-column prop="organizationId" label="部门ID" width="180" />
|
||||
<el-table-column prop="parentOrganization.organizationName" label="上级部门" width="180">
|
||||
<template #default="{ row }">
|
||||
{{ row.parentOrganization ? row.parentOrganization.organizationName : '无' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="organizationName" label="部门名称" width="180" />
|
||||
<el-table-column prop="leader" label="负责人" width="180" />
|
||||
<el-table-column prop="contactPhone" label="负责人联系电话" width="180" />
|
||||
<el-table-column prop="email" label="负责人邮箱" width="180" />
|
||||
<el-table-column prop="organizationStatus" label="部门状态" width="180">
|
||||
<template #default="{ row }">
|
||||
<span v-if="row.organizationStatus">
|
||||
<el-text type="success">正常</el-text>
|
||||
</span>
|
||||
<span v-else>
|
||||
<el-text type="danger">停用</el-text>
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="180">
|
||||
<template #default="scope" >
|
||||
<el-button type="danger" text @click="deleteOrganization(scope.row.organizationId)">删除</el-button>
|
||||
<el-button type="danger" text @click="handleUpdate(scope.row.organizationId)">修改</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<!-- 添加表单-->
|
||||
<el-dialog v-model="showDialogAdd" title="填写信息" width="80%">
|
||||
<el-form :model="dialogFormAdd" :rules="rules">
|
||||
<el-form-item label="上级部门" :label-width="formLabelWidth">
|
||||
<el-select v-model="dialogFormAdd.parentOrganization">
|
||||
<el-option
|
||||
v-for="item in originTableData"
|
||||
:key="item.organizationId"
|
||||
:label="item.organizationName"
|
||||
:value="item.organizationId"
|
||||
>
|
||||
{{item.organizationName}}
|
||||
</el-option>
|
||||
<el-option label="无" value=0></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item prop="organizationName" label="部门名称" :label-width="formLabelWidth">
|
||||
<el-input v-model="dialogFormAdd.organizationName"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="displayOrder" label="显示排列" :label-width="formLabelWidth">
|
||||
<el-input-number v-model="dialogFormAdd.displayOrder" :min=1 :max="100"></el-input-number>
|
||||
</el-form-item>
|
||||
<el-form-item prop="leader" label="负责人" :label-width="formLabelWidth">
|
||||
<el-input v-model="dialogFormAdd.leader"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="contactPhone" label="联系电话" :label-width="formLabelWidth">
|
||||
<el-input v-model="dialogFormAdd.contactPhone"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="email" label="邮箱" :label-width="formLabelWidth">
|
||||
<el-input v-model="dialogFormAdd.email"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="部门状态" :label-width="formLabelWidth">
|
||||
<el-switch v-model="dialogFormAdd.organizationStatus" active-value="true" active-text="启用" inactive-value="false" inactive-text="禁用"></el-switch>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="dialog-footer">
|
||||
<span slot="footer">
|
||||
<el-button @click="showDialogAdd = false">取消</el-button>
|
||||
<el-button type="primary" @click="submitForm">提交</el-button>
|
||||
</span>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import {ref, onMounted, defineComponent} from 'vue';
|
||||
import organizationService from '../../services/organizationService';
|
||||
import {useStore} from 'vuex';
|
||||
import {ElMessage, ElMessageBox} from "element-plus";
|
||||
|
||||
|
||||
interface Organization {
|
||||
organizationId: number;
|
||||
parentOrganization: Organization | null;
|
||||
organizationName: string;
|
||||
leader: string;
|
||||
contactPhone: string;
|
||||
email: string;
|
||||
displayOrder: number;
|
||||
organizationStatus: boolean;
|
||||
children?: Organization[]; // 子组织数组
|
||||
hasChildren: boolean; // 是否有子组织
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
setup() {
|
||||
const store = useStore();
|
||||
const showTable = ref(true);
|
||||
const show = ref(false);
|
||||
const showDialogAdd = ref(false);
|
||||
const formLabelWidth = ref('120px');
|
||||
|
||||
const dialogFormAdd = ref(
|
||||
{
|
||||
organizationId:0,
|
||||
parentOrganization: 0,
|
||||
organizationName: '',
|
||||
displayOrder: 0,
|
||||
leader: '',
|
||||
contactPhone: '',
|
||||
email: '',
|
||||
organizationStatus: true,
|
||||
}
|
||||
);
|
||||
const dialogFormPerson = ref({
|
||||
|
||||
});
|
||||
|
||||
const originTableData = ref<Organization[]>([]);
|
||||
const tableData = ref<Organization[]>([]);
|
||||
const treeData = ref();
|
||||
const noChildrenData = ref();
|
||||
const fetchData = async () => {
|
||||
try {
|
||||
tableData.value=[];
|
||||
const data = await organizationService.getAllOrganizations();
|
||||
if(data.lenth===1){
|
||||
|
||||
}
|
||||
console.log('获取到的部门信息', data);
|
||||
originTableData.value = data;
|
||||
console.log(originTableData.value);
|
||||
//buildTree 负责构建树形结构
|
||||
treeData.value = buildTree(originTableData.value);
|
||||
console.log('树形结构数据', treeData);
|
||||
noChildrenData.value = originTableData.value.map(item => ({
|
||||
...item,
|
||||
children: [] // 将 children 设置为空数组
|
||||
}));
|
||||
console.log('无子组织数据', noChildrenData);
|
||||
tableData.value = treeData.value;
|
||||
} catch (error) {
|
||||
console.error('Error fetching organization:', error);
|
||||
}
|
||||
};
|
||||
|
||||
const buildTree = (flatData: Organization[]): Organization[] => {
|
||||
const map: Record<number, Organization> = {};
|
||||
const roots: Organization[] = [];
|
||||
|
||||
flatData.forEach(org => {
|
||||
map[org.organizationId] = org;
|
||||
org.children = [];
|
||||
});
|
||||
|
||||
flatData.forEach(org => {
|
||||
if (org.parentOrganization?.organizationId && map[org.parentOrganization.organizationId]) {
|
||||
map[org.parentOrganization.organizationId].children.push(org);
|
||||
map[org.parentOrganization.organizationId].hasChildren = false;
|
||||
// map[org.organizationId].hasChildren = true; // 标记是否有子组织
|
||||
} else {
|
||||
roots.push(org);
|
||||
}
|
||||
});
|
||||
|
||||
const sortTree = (nodes: Organization[]) => {
|
||||
nodes.sort((a, b) => a.displayOrder - b.displayOrder);
|
||||
nodes.forEach(node => {
|
||||
if (node.children && node.children.length > 0) {
|
||||
sortTree(node.children);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
sortTree(roots);
|
||||
|
||||
console.log('roots:', roots);
|
||||
return roots;
|
||||
};
|
||||
|
||||
|
||||
|
||||
const submitForm = () => {
|
||||
console.log('提交表单' , dialogFormAdd.value);
|
||||
organizationService.addOrganization(dialogFormAdd.value);
|
||||
ElMessage({
|
||||
type: 'success',
|
||||
message: `成功`,
|
||||
})
|
||||
showDialogAdd.value = false;
|
||||
|
||||
dialogFormAdd.value = {
|
||||
organizationId:0,
|
||||
parentOrganization: 0,
|
||||
organizationName: '',
|
||||
displayOrder: 0,
|
||||
leader: '',
|
||||
contactPhone: '',
|
||||
email: '',
|
||||
organizationStatus: true,
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
const deleteOrganization = (organizationId:number) => {
|
||||
ElMessageBox.confirm(
|
||||
'将删除该部门,确定?',
|
||||
'注意!!!',
|
||||
{
|
||||
confirmButtonText: '确认',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
center: true,
|
||||
}
|
||||
)
|
||||
.then(() => {
|
||||
organizationService.deleteOrganization(organizationId);
|
||||
fetchData();
|
||||
ElMessage({
|
||||
type: 'success',
|
||||
message: '删除成功',
|
||||
|
||||
})
|
||||
})
|
||||
.catch(() => {
|
||||
ElMessage({
|
||||
type: 'info',
|
||||
message: '取消删除',
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
const handleUpdate = (organizationId:number) => {
|
||||
console.log('编辑部门', organizationId);
|
||||
const organization = originTableData.value.find((item) => item.organizationId === organizationId);
|
||||
console.log('organization', organization);
|
||||
dialogFormAdd.value = {
|
||||
organizationId:organization?.organizationId,
|
||||
parentOrganization: organization?.parentOrganization?.organizationId || 0,
|
||||
organizationName: organization?.organizationName,
|
||||
displayOrder: organization?.displayOrder,
|
||||
leader: organization?.leader,
|
||||
contactPhone: organization?.contactPhone,
|
||||
email: organization?.email,
|
||||
organizationStatus: organization?.organizationStatus,
|
||||
}
|
||||
console.log('dialogFormAdd', dialogFormAdd.value);
|
||||
showDialogAdd.value = true;
|
||||
|
||||
}
|
||||
|
||||
const search = ref({
|
||||
name:'',
|
||||
status:''
|
||||
})
|
||||
const handleSearch = () => {
|
||||
console.log('搜索', search.value);
|
||||
// if(search.value.name != ''){
|
||||
tableData.value = noChildrenData.value.filter(
|
||||
(data) => {
|
||||
const isNameValid = search.value && search.value.name;
|
||||
const isStatusValid = search.value && search.value.status;
|
||||
|
||||
return (!isNameValid || data.organizationName.toLowerCase().includes(search.value.name.toLowerCase())) &&
|
||||
(!isStatusValid || data.organizationStatus === JSON.parse(search.value.status));
|
||||
}
|
||||
);
|
||||
}
|
||||
const handleReset = () => {
|
||||
search.value.name = '';
|
||||
search.value.status = '';
|
||||
fetchData();
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchData();
|
||||
});
|
||||
|
||||
return {
|
||||
originTableData,
|
||||
tableData,
|
||||
showDialogAdd,
|
||||
showTable,
|
||||
show,
|
||||
dialogFormAdd,
|
||||
submitForm,
|
||||
formLabelWidth,
|
||||
deleteOrganization,
|
||||
handleUpdate,
|
||||
search,
|
||||
handleSearch,
|
||||
handleReset,
|
||||
};
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
rules: {
|
||||
organizationName:[{
|
||||
required: true, message: '请输入部门名称', trigger: 'blur'
|
||||
}],
|
||||
leader:[{
|
||||
required: true, message: '请输入负责人名称', trigger: 'blur'
|
||||
}],
|
||||
contactPhone:[{
|
||||
type:'text',required:true,message:'请输入联系电话',trigger:'blur'
|
||||
}],
|
||||
email: [{
|
||||
pattern:/^([a-zA-Z0-9]+[-_\.]?)+@[a-zA-Z0-9]+\.[a-z]+$/ ,required: true ,message: '输入邮箱', trigger: 'blur'
|
||||
}],
|
||||
}
|
||||
};
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.department-management {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.toolbar {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.dialog-footer{
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
107
src/views/user-management/AddTenant.vue
Normal file
107
src/views/user-management/AddTenant.vue
Normal file
@ -0,0 +1,107 @@
|
||||
<template>
|
||||
<div class="container">
|
||||
<el-card class="form-container" shadow="hover">
|
||||
|
||||
<el-row>
|
||||
<el-col :span="6">
|
||||
<el-text class="mx-1" type="primary">租户名称</el-text>
|
||||
</el-col>
|
||||
<el-col :span="18">
|
||||
<el-input v-model="name" placeholder="请输入名称" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row style="margin-top: 20px;">
|
||||
<el-col :span="6">
|
||||
<el-text class="mx-1" type="primary">租户标识</el-text>
|
||||
</el-col>
|
||||
<el-col :span="18">
|
||||
<el-input v-model="symbol" placeholder="请输入标识" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row style="margin-top: 20px;">
|
||||
<el-col :span="6">
|
||||
<el-text class="mx-1" type="primary">联系人</el-text>
|
||||
</el-col>
|
||||
<el-col :span="18">
|
||||
<el-input v-model="contact" placeholder="请输入联系人" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row style="margin-top: 20px;">
|
||||
<el-col :span="6">
|
||||
<el-text class="mx-1" type="primary">手机号码</el-text>
|
||||
</el-col>
|
||||
<el-col :span="18">
|
||||
<el-input v-model="phone" placeholder="请输入手机号码" />
|
||||
</el-col>
|
||||
|
||||
</el-row>
|
||||
<el-row style="margin-top: 20px;">
|
||||
<el-col :span="6">
|
||||
<el-text class="mx-1" type="primary">管理员</el-text>
|
||||
</el-col>
|
||||
<el-col :span="18">
|
||||
<el-input v-model="manager" placeholder="请输入管理员" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row style="margin-top: 20px;">
|
||||
<el-col :offset="6" :span="18">
|
||||
<el-button type="primary" @click="addFinished">确认新增</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import tenantService from "../../services/tenantService.js";
|
||||
|
||||
const manager = ref<String>('');
|
||||
const phone = ref<String>('');
|
||||
const contact = ref<String>('');
|
||||
const name = ref<String>('');
|
||||
const symbol = ref<String>('');
|
||||
|
||||
|
||||
const addFinished = () => {
|
||||
const tenant = {
|
||||
symbol: symbol.value,
|
||||
name: name.value,
|
||||
contact: contact.value,
|
||||
manager: manager.value,
|
||||
phone: phone.value,
|
||||
};
|
||||
tenantService.addTenant(tenant);
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
background-color: #f0f2f5; /* 设置背景色为浅色 */
|
||||
}
|
||||
|
||||
.form-container {
|
||||
background-color: #333; /* 深色背景 */
|
||||
color: white; /* 确保文本颜色与深色背景有对比 */
|
||||
padding: 20px;
|
||||
border-radius: 10px;
|
||||
width: 400px;
|
||||
}
|
||||
|
||||
.el-text {
|
||||
color: white; /* 确保文本颜色与深色背景有对比 */
|
||||
}
|
||||
|
||||
.el-input {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
119
src/views/user-management/AddUser.vue
Normal file
119
src/views/user-management/AddUser.vue
Normal file
@ -0,0 +1,119 @@
|
||||
<template>
|
||||
<div class="container">
|
||||
<el-card class="form-container" shadow="hover">
|
||||
<el-row>
|
||||
<el-col :span="6">
|
||||
<el-text class="mx-1" type="primary">用户昵称</el-text>
|
||||
</el-col>
|
||||
<el-col :span="18">
|
||||
<el-input v-model="name" placeholder="请输入昵称" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row style="margin-top: 20px;">
|
||||
<el-col :span="6">
|
||||
<el-text class="mx-1" type="primary">用户账号</el-text>
|
||||
</el-col>
|
||||
<el-col :span="18">
|
||||
<el-input v-model="account" placeholder="请输入账号" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row style="margin-top: 20px;">
|
||||
<el-col :span="6">
|
||||
<el-text class="mx-1" type="primary">用户密码</el-text>
|
||||
</el-col>
|
||||
<el-col :span="18">
|
||||
<el-input v-model="password" placeholder="请输入密码" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row style="margin-top: 20px;">
|
||||
<el-col :span="6">
|
||||
<el-text class="mx-1" type="primary">手机号码</el-text>
|
||||
</el-col>
|
||||
<el-col :span="18">
|
||||
<el-input v-model="phone" placeholder="请输入手机号码" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row style="margin-top: 20px;">
|
||||
<el-col :span="6">
|
||||
<el-text class="mx-1" type="primary">邮箱</el-text>
|
||||
</el-col>
|
||||
<el-col :span="18">
|
||||
<el-input v-model="email" placeholder="请输入邮箱" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row style="margin-top: 20px;">
|
||||
<el-col :span="6">
|
||||
<el-text class="mx-1" type="primary">用户性别</el-text>
|
||||
</el-col>
|
||||
<el-col :span="18">
|
||||
<el-input v-model="gender" placeholder="请输入性别" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row style="margin-top: 20px;">
|
||||
<el-col :span="6">
|
||||
<el-text class="mx-1" type="primary">部门</el-text>
|
||||
</el-col>
|
||||
<el-col :span="18">
|
||||
<el-input v-model="organization" placeholder="请输入部门" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row style="margin-top: 20px;">
|
||||
<el-col :offset="6" :span="18">
|
||||
<el-button type="primary" @click="addFinished">确认新增</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import userService from "../../services/userService.js";
|
||||
|
||||
const account = ref<String>('');
|
||||
const phone = ref<String>('');
|
||||
const email = ref<String>('');
|
||||
const name = ref<String>('');
|
||||
const gender = ref<String>('');
|
||||
const organization = ref<String>('');
|
||||
const password = ref<String>('');
|
||||
|
||||
const addFinished = () => {
|
||||
const user = {
|
||||
account: account.value,
|
||||
name: name.value,
|
||||
organization: organization.value,
|
||||
password: password.value,
|
||||
email: email.value,
|
||||
gender: gender.value,
|
||||
phone: phone.value,
|
||||
};
|
||||
userService.addUser(user);
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
background-color: #f0f2f5; /* 设置背景色为浅色 */
|
||||
}
|
||||
|
||||
.form-container {
|
||||
background-color: #333; /* 深色背景 */
|
||||
color: white; /* 确保文本颜色与深色背景有对比 */
|
||||
padding: 20px;
|
||||
border-radius: 10px;
|
||||
width: 400px;
|
||||
}
|
||||
|
||||
.el-text {
|
||||
color: white; /* 确保文本颜色与深色背景有对比 */
|
||||
}
|
||||
|
||||
.el-input {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
56
src/views/user-management/Profile.vue
Normal file
56
src/views/user-management/Profile.vue
Normal file
@ -0,0 +1,56 @@
|
||||
<template>
|
||||
<div>
|
||||
<h2>Profile</h2>
|
||||
<form @submit.prevent="updateProfile">
|
||||
<div>
|
||||
<label for="nickname">Nickname:</label>
|
||||
<input type="text" v-model="user.nickname">
|
||||
</div>
|
||||
<div>
|
||||
<label for="phoneNumber">Phone Number:</label>
|
||||
<input type="text" v-model="user.phoneNumber">
|
||||
</div>
|
||||
<div>
|
||||
<label for="gender">Gender:</label>
|
||||
<input type="text" v-model="user.gender">
|
||||
</div>
|
||||
<button type="submit">Update Profile</button>
|
||||
</form>
|
||||
<form @submit.prevent="changePassword">
|
||||
<div>
|
||||
<label for="oldPassword">Old Password:</label>
|
||||
<input type="password" v-model="oldPassword" required>
|
||||
</div>
|
||||
<div>
|
||||
<label for="newPassword">New Password:</label>
|
||||
<input type="password" v-model="newPassword" required>
|
||||
</div>
|
||||
<button type="submit">Change Password</button>
|
||||
</form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapActions, mapState } from 'vuex';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
oldPassword: '',
|
||||
newPassword: ''
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapState(['user'])
|
||||
},
|
||||
methods: {
|
||||
...mapActions(['updateProfile', 'changePassword']),
|
||||
async updateProfile() {
|
||||
await this.updateProfile(this.user);
|
||||
},
|
||||
async changePassword() {
|
||||
await this.changePassword({ oldPassword: this.oldPassword, newPassword: this.newPassword });
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
228
src/views/user-management/TenantManagement.vue
Normal file
228
src/views/user-management/TenantManagement.vue
Normal file
@ -0,0 +1,228 @@
|
||||
<template>
|
||||
<div>
|
||||
<router-view></router-view>
|
||||
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="6">
|
||||
<el-input v-model="searchSymbol" placeholder="请输入标识"></el-input>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-input v-model="searchContact" placeholder="请输入联系人"></el-input>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-input v-model="searchPhone" placeholder="请输入手机号"></el-input>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-input v-model="searchName" placeholder="请输入名称"></el-input>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row :gutter="20" class="mt-2">
|
||||
<el-col :span="24">
|
||||
<el-button type="primary" @click="handleAdd">新增</el-button>
|
||||
<el-button plain @click="dialogVisible=true">修改</el-button>
|
||||
<el-button type="danger" @click="handleDelete">删除</el-button>
|
||||
<el-button type="primary" @click="handleSearch">查询</el-button>
|
||||
<el-button type="primary" @click="handleReset">重置</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-table :data="tableData" style="width: 100%" class="mt-2" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55"></el-table-column>
|
||||
<el-table-column prop="symbol" label="租户标识" width="120"></el-table-column>
|
||||
<el-table-column prop="contact" label="联系人" width="120"></el-table-column>
|
||||
<el-table-column prop="phone" label="电话" width="120"></el-table-column>
|
||||
<el-table-column prop="name" label="租户名称" width="120"></el-table-column>
|
||||
<el-table-column prop="manager" label="管理员" width="120"></el-table-column>
|
||||
</el-table>
|
||||
|
||||
<el-dialog v-model="dialogVisible" title="Tips" width="500" :before-close="handleClose">
|
||||
<span>修改租户信息</span>
|
||||
<template #footer>
|
||||
<div>
|
||||
<el-form :model="formData">
|
||||
<el-form-item label="姓名">
|
||||
<el-input v-model="formData.name"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="联系人">
|
||||
<el-input v-model="formData.contact"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="电话">
|
||||
<el-input v-model="formData.phone"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="管理员">
|
||||
<el-input v-model="formData.manager"></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">关闭</el-button>
|
||||
<el-button type="primary" @click="editFinished">确认修改</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import tenantService from "../../services/tenantService.js";
|
||||
import {defineComponent, onMounted, ref} from 'vue';
|
||||
import {ElMessage, ElMessageBox} from 'element-plus'
|
||||
|
||||
interface Tenant {
|
||||
symbol: string;
|
||||
contact: string;
|
||||
phone: string;
|
||||
name: string;
|
||||
manager: string;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
setup() {
|
||||
const searchSymbol = ref('');
|
||||
const searchContact = ref('');
|
||||
const searchPhone = ref('');
|
||||
const searchName = ref('');
|
||||
const tableData = ref<Tenant[]>([]);
|
||||
|
||||
const selectedRows = ref<Tenant[]>([]);
|
||||
const formData = ref({
|
||||
symbol: '',
|
||||
contact: '',
|
||||
phone: '',
|
||||
name: '',
|
||||
manager: '',
|
||||
});
|
||||
|
||||
const dialogVisible = ref(false);
|
||||
|
||||
const handleClose = (done: () => void) => {
|
||||
done();
|
||||
};
|
||||
|
||||
const fetchData = async () => {
|
||||
try {
|
||||
tableData.value = await tenantService.getAll();
|
||||
} catch (error) {
|
||||
console.error("Error fetching organization:", error);
|
||||
}
|
||||
};
|
||||
|
||||
const handleSelectionChange = (rows) => {
|
||||
selectedRows.value = rows;
|
||||
if (rows.length === 1) {
|
||||
formData.value = { ...rows[0] };
|
||||
} else {
|
||||
formData.value = {
|
||||
symbol: '',
|
||||
contact: '',
|
||||
phone: '',
|
||||
name: '',
|
||||
manager: '',
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
const editFinished = async () => {
|
||||
try {
|
||||
await tenantService.update(formData.value);
|
||||
await ElMessageBox.alert('修改成功', '提示', {
|
||||
// if you want to disable its autofocus
|
||||
// autofocus: false,
|
||||
confirmButtonText: 'OK',
|
||||
callback: (action) => {
|
||||
ElMessage({
|
||||
type: 'info',
|
||||
message: `action: ${action}`,
|
||||
})
|
||||
},
|
||||
})
|
||||
dialogVisible.value = false;
|
||||
location.href="/tenantManagement";
|
||||
fetchData();
|
||||
} catch (error) {
|
||||
console.error("Error updating user:", error);
|
||||
}
|
||||
};
|
||||
|
||||
const handleAdd = () => {
|
||||
location.href = '/addTenant';
|
||||
};
|
||||
|
||||
|
||||
const handleDelete = async () => {
|
||||
try{
|
||||
await tenantService.delete(formData.value);
|
||||
await ElMessageBox.alert('删除成功', '提示', {
|
||||
// if you want to disable its autofocus
|
||||
// autofocus: false,
|
||||
confirmButtonText: 'OK',
|
||||
callback: (action) => {
|
||||
ElMessage({
|
||||
type: 'info',
|
||||
message: `action: ${action}`,
|
||||
})
|
||||
},
|
||||
})
|
||||
await fetchData();
|
||||
}catch(error){
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
const handleSearch = async () => {
|
||||
tableData.value =tableData.value.filter(
|
||||
(data) => {
|
||||
const isNameValid = searchName.value;
|
||||
const isSymbolValid =searchSymbol.value;
|
||||
const isPhoneValid = searchPhone.value;
|
||||
const isContactValid = searchContact.value;
|
||||
// search.value && search.value.
|
||||
|
||||
return (!isNameValid || data.name.toLowerCase().includes(searchName.value.toLowerCase())) &&
|
||||
(!isPhoneValid || data.phone.toLowerCase().includes(searchPhone.value.toLowerCase()) )&&
|
||||
(!isSymbolValid || data.symbol.toLowerCase().includes(searchSymbol.value.toLowerCase()))&&
|
||||
(!isContactValid || data.contact.toLowerCase().includes(searchContact.value.toLowerCase()))
|
||||
}
|
||||
)
|
||||
};
|
||||
|
||||
|
||||
const handleReset=()=>{
|
||||
location.href = '/tenantManagement';
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
fetchData();
|
||||
});
|
||||
|
||||
return {
|
||||
tableData,
|
||||
handleAdd,
|
||||
formData,
|
||||
dialogVisible,
|
||||
handleClose,
|
||||
selectedRows,
|
||||
handleSelectionChange,
|
||||
editFinished,
|
||||
handleDelete,
|
||||
searchPhone,
|
||||
searchSymbol,
|
||||
searchName,
|
||||
searchContact,
|
||||
handleSearch,
|
||||
handleReset
|
||||
|
||||
};
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.mt-2 {
|
||||
margin-top: 20px;
|
||||
}
|
||||
</style>
|
||||
220
src/views/user-management/UserManagement.vue
Normal file
220
src/views/user-management/UserManagement.vue
Normal file
@ -0,0 +1,220 @@
|
||||
<template>
|
||||
<div>
|
||||
<router-view></router-view>
|
||||
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="6">
|
||||
<el-input v-model="searchOrganization" placeholder="请输入组织"></el-input>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-input v-model="searchName" placeholder="请输入用户名"></el-input>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-input v-model="searchPhone" placeholder="请输入手机号"></el-input>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row :gutter="20" class="mt-2">
|
||||
<el-col :span="24">
|
||||
<el-button type="primary" @click="handleAdd">新增</el-button>
|
||||
<el-button plain @click="dialogVisible=true">修改</el-button>
|
||||
<el-button type="danger" @click="handleDelete">删除</el-button>
|
||||
<el-button type="primary" @click="handleSearch">查询</el-button>
|
||||
<el-button type="primary" @click="handleReset">重置</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-table :data="tableData" style="width: 100%" class="mt-2" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55"></el-table-column>
|
||||
<el-table-column prop="id" label="用户编号" width="120"></el-table-column>
|
||||
<el-table-column prop="account" label="账号" width="120"></el-table-column>
|
||||
<el-table-column prop="name" label="名称" width="120"></el-table-column>
|
||||
<el-table-column prop="organization" label="组织" width="120"></el-table-column>
|
||||
<el-table-column prop="phone" label="手机号" width="150"></el-table-column>
|
||||
<el-table-column prop="email" label="邮箱" width="180"></el-table-column>
|
||||
<el-table-column prop="gender" label="性别" width="180"></el-table-column>
|
||||
</el-table>
|
||||
|
||||
<el-dialog v-model="dialogVisible" title="Tips" width="500" :before-close="handleClose">
|
||||
<span>修改用户</span>
|
||||
<template #footer>
|
||||
<div>
|
||||
<el-form :model="formData">
|
||||
<el-form-item label="姓名">
|
||||
<el-input v-model="formData.name"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="账号">
|
||||
<el-input v-model="formData.account"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="组织">
|
||||
<el-input v-model="formData.organization"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="邮箱">
|
||||
<el-input v-model="formData.email"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="性别">
|
||||
<el-input v-model="formData.gender"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="电话">
|
||||
<el-input v-model="formData.phone"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="密码">
|
||||
<el-input type="password" v-model="formData.password"></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">关闭</el-button>
|
||||
<el-button type="primary" @click="editFinished">确认修改</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import userService from "../../services/userService.js";
|
||||
import {defineComponent, onMounted, ref} from 'vue';
|
||||
import {ElMessage} from "element-plus";
|
||||
|
||||
interface User {
|
||||
id: number;
|
||||
account: string;
|
||||
name: string;
|
||||
organization: string;
|
||||
phone: string;
|
||||
email: string;
|
||||
gender: string;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
setup() {
|
||||
|
||||
const searchOrganization = ref('');
|
||||
const searchName = ref('');
|
||||
const searchPhone = ref('');
|
||||
|
||||
|
||||
const tableData = ref<User[]>([]);
|
||||
|
||||
const selectedRows = ref<User[]>([]);
|
||||
|
||||
|
||||
const formData = ref({
|
||||
id: null,
|
||||
account: '',
|
||||
name: '',
|
||||
organization: '',
|
||||
email: '',
|
||||
gender: '',
|
||||
phone: '',
|
||||
password: '',
|
||||
});
|
||||
|
||||
const dialogVisible = ref(false);
|
||||
|
||||
const handleClose = (done: () => void) => {
|
||||
done();
|
||||
};
|
||||
|
||||
const fetchData = async () => {
|
||||
try {
|
||||
tableData.value = await userService.getAll();
|
||||
} catch (error) {
|
||||
console.error("Error fetching organization:", error);
|
||||
}
|
||||
};
|
||||
|
||||
const handleSelectionChange = (rows) => {
|
||||
selectedRows.value = rows;
|
||||
if (rows.length === 1) {
|
||||
formData.value = {...rows[0]};
|
||||
} else {
|
||||
formData.value = {
|
||||
id: null,
|
||||
account: '',
|
||||
name: '',
|
||||
organization: '',
|
||||
email: '',
|
||||
gender: '',
|
||||
phone: '',
|
||||
password: '',
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
const editFinished = async () => {
|
||||
try {
|
||||
await userService.update(formData.value);
|
||||
dialogVisible.value = false;
|
||||
fetchData();
|
||||
} catch (error) {
|
||||
console.error("Error updating user:", error);
|
||||
}
|
||||
};
|
||||
|
||||
const handleAdd = () => {
|
||||
location.href = '/addUser';
|
||||
};
|
||||
|
||||
const handleDelete = async () => {
|
||||
try {
|
||||
await userService.delete(formData.value);
|
||||
ElMessage.success("删除成功")
|
||||
await fetchData();
|
||||
} catch (error) {
|
||||
ElMessage.error("删除失败")
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const handleSearch = async () => {
|
||||
tableData.value = tableData.value.filter(
|
||||
(data) => {
|
||||
const isNameValid = searchName.value;
|
||||
const isOrganizationValid = searchOrganization.value;
|
||||
const isPhoneValid = searchPhone.value;
|
||||
// search.value && search.value.
|
||||
|
||||
return (!isNameValid || data.name.toLowerCase().includes(searchName.value.toLowerCase())) &&
|
||||
(!isPhoneValid || data.phone.toLowerCase().includes(searchPhone.value.toLowerCase())) &&
|
||||
(!isOrganizationValid || data.organization.toLowerCase().includes(searchOrganization.value.toLowerCase()))
|
||||
}
|
||||
)
|
||||
};
|
||||
|
||||
|
||||
const handleReset = () => {
|
||||
location.href = '/userManagement';
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchData();
|
||||
});
|
||||
|
||||
return {
|
||||
tableData,
|
||||
handleAdd,
|
||||
formData,
|
||||
dialogVisible,
|
||||
handleClose,
|
||||
selectedRows,
|
||||
handleSelectionChange,
|
||||
editFinished,
|
||||
handleDelete,
|
||||
searchPhone,
|
||||
searchOrganization,
|
||||
searchName,
|
||||
handleSearch,
|
||||
handleReset
|
||||
};
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.mt-2 {
|
||||
margin-top: 20px;
|
||||
}
|
||||
</style>
|
||||
Loading…
Reference in New Issue
Block a user