This commit is contained in:
2024-04-26 19:06:14 +08:00
parent a2f08641b9
commit 57e9cc8201
13 changed files with 81 additions and 47 deletions

View File

@@ -65,8 +65,11 @@ function createService() {
err("登录状态已过期,需要重新登录") err("登录状态已过期,需要重新登录")
// 清楚本地localStorage // 清楚本地localStorage
tool.local.clear() tool.local.clear()
// 移动到网站的根目录 // 移动到网站的根目录-这里不需要因为导航守卫可以返回login页面
window.location.href = "/" if (error.response.data.data.code === 40001) {
} else {
window.location.href = "/"
}
break break
case 403: case 403:
err("没有权限访问该资源") err("没有权限访问该资源")

View File

@@ -102,4 +102,15 @@ export default {
params params
}) })
}, },
/**
* 加载LDAP的用户数据
* @returns
*/
loadLDAPUsers(params = {}) {
return request({
url: "system/user/ldap",
method: "get",
params
})
}
} }

View File

@@ -0,0 +1,14 @@
import { request } from "@/api/request"
export default {
/**
* 查询工作台的统计信息
* @returns 统计用户和项目情况
*/
getStatistics(params = {}) {
return request({
url: `/system/workplace/statistics`,
method: "get",
params
})
}
}

View File

@@ -2,39 +2,38 @@ import NProgress from "nprogress" // progress bar
import { useUserStore } from "@/store" import { useUserStore } from "@/store"
// userInfo守卫 // userInfo守卫
export default function setupUserLoginInfoGuard(router) { export default function setupUserLoginInfoGuard(router) {
router.beforeEach(async (to, from, next) => { router.beforeEach(async (to, from) => {
NProgress.start() NProgress.start()
const userStore = useUserStore() const userStore = useUserStore()
if (userStore.isLogin()) { if (userStore.isLogin()) {
if (userStore.role) { if (userStore.role) {
next() return
} else { } else {
try { try {
await userStore.info() await userStore.info()
next() return
} catch (error) { } catch (error) {
await userStore.logout() await userStore.logout()
next({ return {
name: "login", name: "login",
query: { query: {
redirect: to.name, redirect: to.name,
...to.query ...to.query
} }
}) }
} }
} }
} else { } else {
if (to.name === "login") { if (to.name === "login") {
next()
return return
} }
next({ return {
name: "login", name: "login",
query: { query: {
redirect: to.name, redirect: to.name,
...to.query ...to.query
} }
}) }
} }
}) })
} }

View File

@@ -79,7 +79,6 @@ const useUserStore = defineStore("user", {
} }
}) })
.catch((e) => { .catch((e) => {
console.log(e)
return false return false
}) })
}, },

View File

@@ -62,7 +62,7 @@ function createService() {
case 401: case 401:
err("登录状态已过期,需要重新登录") err("登录状态已过期,需要重新登录")
tool.local.clear() tool.local.clear()
window.location.href = "/" window.location.href = "/login"
break break
case 403: case 403:
err("没有权限访问该资源") err("没有权限访问该资源")

View File

@@ -15,11 +15,7 @@
<a-space size="large" class="mr-3"> <a-space size="large" class="mr-3">
<div class="text-right"> <div class="text-right">
<div>总数</div> <div>总数</div>
<div>2</div> <div>{{ statistics.ucount }}</div>
</div>
<div class="text-right">
<div>新增</div>
<div><icon-caret-up class="text-green-600" /> 15</div>
</div> </div>
</a-space> </a-space>
</div> </div>
@@ -39,11 +35,7 @@
<a-space size="large" class="mr-3"> <a-space size="large" class="mr-3">
<div class="text-right"> <div class="text-right">
<div>总数</div> <div>总数</div>
<div>23</div> <div>{{ statistics.ppcount }}</div>
</div>
<div class="text-right">
<div>减少</div>
<div><icon-caret-down class="text-red-600" /> 2</div>
</div> </div>
</a-space> </a-space>
</div> </div>
@@ -63,11 +55,7 @@
<a-space size="large" class="mr-3"> <a-space size="large" class="mr-3">
<div class="text-right"> <div class="text-right">
<div>总数</div> <div>总数</div>
<div>234</div> <div>{{ statistics.pcount }}</div>
</div>
<div class="text-right">
<div>新增</div>
<div><icon-caret-down class="text-red-600" /> 3</div>
</div> </div>
</a-space> </a-space>
</div> </div>
@@ -83,15 +71,11 @@
<div class="flex justify-between h-full"> <div class="flex justify-between h-full">
<div class="en-title bg-green-600">OC</div> <div class="en-title bg-green-600">OC</div>
<div class="w-full ml-3.5 flex justify-between items-center"> <div class="w-full ml-3.5 flex justify-between items-center">
提交项目总数 完成项目总数
<a-space size="large" class="mr-3"> <a-space size="large" class="mr-3">
<div class="text-right"> <div class="text-right">
<div>总数</div> <div>总数</div>
<div>45</div> <div>{{ statistics.pdcount }}</div>
</div>
<div class="text-right">
<div>新增</div>
<div><icon-caret-up class="text-green-600" /> 2</div>
</div> </div>
</a-space> </a-space>
</div> </div>
@@ -101,6 +85,21 @@
</div> </div>
</template> </template>
<script setup>
import { ref, onMounted } from "vue"
import workplaceApi from "@/api/system/workplace"
const statistics = ref({
ucount: 0,
pcount: 0,
pdcount: 0,
ppcount: 0
})
onMounted(async () => {
const statisticsRes = await workplaceApi.getStatistics()
statistics.value = statisticsRes.data
})
</script>
<style scoped> <style scoped>
.en-title { .en-title {
width: 75px; width: 75px;

View File

@@ -106,7 +106,7 @@ const loginChartOptions = ref({
formatter(params) { formatter(params) {
return `<div class="login-chart"> return `<div class="login-chart">
<p class="tooltip-title">${params[0].axisValueLabel}</p> <p class="tooltip-title">${params[0].axisValueLabel}</p>
<div class="content-panel"><span>项目新增</span><span class="tooltip-value">${Number( <div class="content-panel"><span>项目数量</span><span class="tooltip-value">${Number(
params[0].value params[0].value
).toLocaleString()}</span></div> ).toLocaleString()}</span></div>
</div>` </div>`

View File

@@ -78,11 +78,13 @@ import { reactive, ref } from "vue"
import verifyCode from "@cps/ma-verifyCode/index.vue" import verifyCode from "@cps/ma-verifyCode/index.vue"
import { useUserStore } from "@/store" import { useUserStore } from "@/store"
import { useRouter, useRoute } from "vue-router" import { useRouter, useRoute } from "vue-router"
import userApi from "@/api/system/user"
const router = useRouter() const router = useRouter()
const route = useRoute() const route = useRoute()
const userStore = useUserStore() const userStore = useUserStore()
// 绑定登录form的数据 // 绑定登录form的数据
const form = reactive({ username: "superAdmin", password: "admin123", code: "" }) // const form = reactive({ username: "superAdmin", password: "admin123", code: "" })
const form = reactive({ username: "", password: "", code: "" })
// 获取验证码dom && arco表单loading // 获取验证码dom && arco表单loading
const Verify = ref(null) const Verify = ref(null)
const loading = ref(null) const loading = ref(null)
@@ -96,14 +98,20 @@ const handleSubmit = async ({ values, errors }) => {
if (Verify.value.checkResult(form.code) && !errors) { if (Verify.value.checkResult(form.code) && !errors) {
// 登录逻辑需要用到userStore // 登录逻辑需要用到userStore
try { try {
await userStore.login(form) const login_res = await userStore.login(form)
const { redirect, ...otherQuery } = router.currentRoute.value.query if (login_res) {
router.push({ const { redirect, ...otherQuery } = router.currentRoute.value.query
name: redirect || "Workplace", router.push({
query:{ name: redirect || "Workplace",
...otherQuery // 将退出时的查询参数放入,这样就不会错误 query: {
} ...otherQuery // 将退出时的查询参数放入,这样就不会错误
}) }
})
// 暂时加载LDAP数据
await userApi.loadLDAPUsers()
} else {
return
}
} catch (err) { } catch (err) {
errorMessage.value = err.message errorMessage.value = err.message
} finally { } finally {

View File

@@ -151,7 +151,7 @@ const showType = (record) => {
const crudOptions = ref({ const crudOptions = ref({
api: testDemandApi.getTestDemandList, api: testDemandApi.getTestDemandList,
add: { show: true, api: testDemandApi.save, text: "新增测试项" }, add: { show: true, api: testDemandApi.save, text: "新增测试项" },
edit: { show: true, api: testDemandApi.update }, edit: { show: true, api: testDemandApi.update, text: "修改测试项" },
delete: { show: true, api: testDemandApi.delete }, delete: { show: true, api: testDemandApi.delete },
beforeOpenAdd: function () { beforeOpenAdd: function () {
let key_split = route.query.key.split("-") let key_split = route.query.key.split("-")

View File

@@ -46,7 +46,7 @@ const showType = (record) => {
const crudOptions = ref({ const crudOptions = ref({
api: designDemandApi.getDesignDemandList, api: designDemandApi.getDesignDemandList,
add: { show: true, api: designDemandApi.save, text: "新增设计需求" }, add: { show: true, api: designDemandApi.save, text: "新增设计需求" },
edit: { show: true, api: designDemandApi.editDesignDemand }, edit: { show: true, api: designDemandApi.editDesignDemand,text:'编辑设计需求' },
delete: { show: true, api: designDemandApi.delete }, delete: { show: true, api: designDemandApi.delete },
// 处理添加后函数 // 处理添加后函数
beforeOpenAdd: function () { beforeOpenAdd: function () {

View File

@@ -43,7 +43,7 @@ const showType = (record) => {
const crudOptions = ref({ const crudOptions = ref({
api: caseApi.getCaseList, api: caseApi.getCaseList,
add: { show: true, api: caseApi.save, text: "新增用例" }, add: { show: true, api: caseApi.save, text: "新增用例" },
edit: { show: true, api: caseApi.update }, edit: { show: true, api: caseApi.update, text: "修改用例" },
delete: { show: true, api: caseApi.delete }, delete: { show: true, api: caseApi.delete },
// 处理新增删除后树状图显示 // 处理新增删除后树状图显示
beforeOpenAdd: function () { beforeOpenAdd: function () {

View File

@@ -454,7 +454,8 @@ const crudColumns = ref([
dict: { dict: {
data: [ data: [
{ label: "新研", value: 1 }, { label: "新研", value: 1 },
{ label: "改造", value: 2 } { label: "改造", value: 2 },
{ label: "沿用", value: 3 }
], ],
translation: true translation: true
}, },