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

View File

@@ -102,4 +102,15 @@ export default {
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"
// userInfo守卫
export default function setupUserLoginInfoGuard(router) {
router.beforeEach(async (to, from, next) => {
router.beforeEach(async (to, from) => {
NProgress.start()
const userStore = useUserStore()
if (userStore.isLogin()) {
if (userStore.role) {
next()
return
} else {
try {
await userStore.info()
next()
return
} catch (error) {
await userStore.logout()
next({
return {
name: "login",
query: {
redirect: to.name,
...to.query
}
})
}
}
}
} else {
if (to.name === "login") {
next()
return
}
next({
return {
name: "login",
query: {
redirect: to.name,
...to.query
}
})
}
}
})
}

View File

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

View File

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

View File

@@ -15,11 +15,7 @@
<a-space size="large" class="mr-3">
<div class="text-right">
<div>总数</div>
<div>2</div>
</div>
<div class="text-right">
<div>新增</div>
<div><icon-caret-up class="text-green-600" /> 15</div>
<div>{{ statistics.ucount }}</div>
</div>
</a-space>
</div>
@@ -39,11 +35,7 @@
<a-space size="large" class="mr-3">
<div class="text-right">
<div>总数</div>
<div>23</div>
</div>
<div class="text-right">
<div>减少</div>
<div><icon-caret-down class="text-red-600" /> 2</div>
<div>{{ statistics.ppcount }}</div>
</div>
</a-space>
</div>
@@ -63,11 +55,7 @@
<a-space size="large" class="mr-3">
<div class="text-right">
<div>总数</div>
<div>234</div>
</div>
<div class="text-right">
<div>新增</div>
<div><icon-caret-down class="text-red-600" /> 3</div>
<div>{{ statistics.pcount }}</div>
</div>
</a-space>
</div>
@@ -83,15 +71,11 @@
<div class="flex justify-between h-full">
<div class="en-title bg-green-600">OC</div>
<div class="w-full ml-3.5 flex justify-between items-center">
提交项目总数
完成项目总数
<a-space size="large" class="mr-3">
<div class="text-right">
<div>总数</div>
<div>45</div>
</div>
<div class="text-right">
<div>新增</div>
<div><icon-caret-up class="text-green-600" /> 2</div>
<div>{{ statistics.pdcount }}</div>
</div>
</a-space>
</div>
@@ -101,6 +85,21 @@
</div>
</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>
.en-title {
width: 75px;

View File

@@ -106,7 +106,7 @@ const loginChartOptions = ref({
formatter(params) {
return `<div class="login-chart">
<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
).toLocaleString()}</span></div>
</div>`

View File

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

View File

@@ -151,7 +151,7 @@ const showType = (record) => {
const crudOptions = ref({
api: testDemandApi.getTestDemandList,
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 },
beforeOpenAdd: function () {
let key_split = route.query.key.split("-")

View File

@@ -46,7 +46,7 @@ const showType = (record) => {
const crudOptions = ref({
api: designDemandApi.getDesignDemandList,
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 },
// 处理添加后函数
beforeOpenAdd: function () {

View File

@@ -43,7 +43,7 @@ const showType = (record) => {
const crudOptions = ref({
api: caseApi.getCaseList,
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 },
// 处理新增删除后树状图显示
beforeOpenAdd: function () {

View File

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