审批页面接口对接

This commit is contained in:
雷校云
2025-12-15 00:09:36 +08:00
parent ccc5a1f0f6
commit d57f6838a3
5 changed files with 180 additions and 51 deletions

View File

@@ -32,25 +32,47 @@ const getLabelAndTagByValue = async (dictCode: string, value: any) => {
// 按需加载字典数据
await dictStore.loadDictItems(dictCode)
// 从缓存中获取字典数据
const dictItems = dictStore.getDictItems(dictCode)
const response: any = dictStore.getDictItems(dictCode)
// 处理API响应格式
let dictItems = []
if (Array.isArray(response)) {
dictItems = response
} else if (response && typeof response === 'object' && Array.isArray(response.data)) {
dictItems = response.data
} else {
console.warn(`Dictionary items for code "${dictCode}" is not in expected format:`, response)
return {
label: '',
tagType: undefined
}
}
// 查找对应的字典项
const dictItem = dictItems.find((item) => item.value == value)
const dictItem = dictItems.find((item: any) => item.value == value)
return {
label: dictItem?.label || '',
tagType: dictItem?.tagType
}
}
/**
* 更新 label 和 tagType
*/
const updateLabelAndTag = async () => {
if (!props.code || props.modelValue === undefined) return
const { label: newLabel, tagType: newTagType } = await getLabelAndTagByValue(
props.code,
props.modelValue
)
label.value = newLabel
tagType.value = newTagType as typeof tagType.value
try {
const { label: newLabel, tagType: newTagType } = await getLabelAndTagByValue(
props.code,
props.modelValue
)
label.value = newLabel
tagType.value = newTagType as typeof tagType.value
} catch (error) {
console.error('Failed to update dict label:', error)
label.value = ''
tagType.value = undefined
}
}
// 初始化或code变化时更新标签和标签样式

View File

@@ -0,0 +1,59 @@
<template>
<div class="approval-form">
<div class="text-xs">
{{ content }}
</div>
<el-form
ref="fomrRef"
style="width: 200px"
:model="formInline"
label-width="auto"
:rules="rules"
>
<el-form-item label="审核" prop="state">
<el-select v-model="formInline.state" size="small" placeholder="请选择">
<el-option :label="'已通过'" :value="'已通过'" />
<el-option :label="'未通过'" :value="'未通过'" />
</el-select>
</el-form-item>
</el-form>
</div>
</template>
<script lang="ts" setup>
defineProps({
content: {
type: String,
default: ''
}
})
const fomrRef = ref()
const rules = ref({
state: [{ required: true, message: '请选择', trigger: 'change' }]
})
const formInline = reactive({
state: ''
})
const getForm = () => {
return formInline
}
const submit = () => {
return fomrRef.value?.validate()
}
defineExpose({
submit,
getForm
})
</script>
<style scoped lang="scss">
.approval-form {
display: flex;
flex-direction: column;
gap: 20px;
}
</style>

View File

@@ -10,19 +10,20 @@
<div class="p-5">
<template v-if="noticeList?.length > 0">
<div v-for="(item, index) in noticeList" :key="index" class="w-500px py-3">
<div class="flex-y-center">
<DictLabel v-model="item.type" code="notice_type" size="small" />
<div class="flex-y-center noticeList-box">
<!-- <DictLabel v-model="item.type" code="notice_type" size="small" />-->
<el-tag type="primary">{{ item.type }}</el-tag>
<el-text
size="small"
class="w-200px cursor-pointer !ml-2 !flex-1"
truncated
@click="handleReadNotice(item.id)"
@click="handleReadNotice(item)"
>
{{ item.title }}
</el-text>
<div class="text-xs text-gray">
{{ item.publishTime }}
{{ item.content }}
</div>
</div>
</div>
@@ -87,6 +88,9 @@ const noticeDialogVisible = ref(false)
const noticeDetail = ref<NoticeDetailVO | null>(null)
import { useStomp } from '@/composables/websocket/useStomp'
import { UserApprovalProcessing, UserRoxyexhibition } from '@/api/calibration/approval'
import { functionDialogBox } from '@/utils/functionDialogBox'
import ApprovalForm from '@/components/Notification/ApprovalForm.vue'
const { subscribe, unsubscribe, isConnected } = useStomp()
watch(
@@ -104,7 +108,6 @@ watch(
type: data.type,
publishTime: data.publishTime
})
ElNotification({
title: '您收到一条新的通知消息!',
message: data.title,
@@ -116,26 +119,52 @@ watch(
}
}
)
/**
* 获取我的通知公告
*/
function featchMyNotice() {
NoticeAPI.getMyNoticePage({ pageNum: 1, pageSize: 5, isRead: 0 }).then((data) => {
noticeList.value = data.list
UserRoxyexhibition({ pageNum: 1, pageSize: 5 }).then((res: any) => {
noticeList.value = res.data
console.log(noticeList.value)
})
}
// 阅读通知公告
function handleReadNotice(id: string) {
NoticeAPI.getDetail(id).then((data) => {
noticeDialogVisible.value = true
noticeDetail.value = data
// 标记为已读
const index = noticeList.value.findIndex((notice) => notice.id === id)
if (index >= 0) {
noticeList.value.splice(index, 1)
function handleReadNotice(data: any) {
// NoticeAPI.getDetail(id).then((res: any) => {
// noticeDialogVisible.value = true
// noticeDetail.value = res.data
// // 标记为已读
// const index = noticeList.value.findIndex((notice) => notice.id === id)
// if (index >= 0) {
// noticeList.value.splice(index, 1)
// }
// })
functionDialogBox(
ApprovalForm,
{
content: data.content
},
{
title: data.type,
width: '500',
ok(value: any) {
onUserApprovalProcessing({ id: data.id, type: data.type, state: value.state })
}
// cancel() {
// console.log("value");
// },
}
)
}
const onUserApprovalProcessing = (data: any) => {
UserApprovalProcessing(data).then((res: any) => {
ElMessage({
type: 'success',
message: res.message
})
featchMyNotice()
})
}
@@ -160,4 +189,10 @@ onBeforeUnmount(() => {
})
</script>
<style lang="scss" scoped></style>
<style lang="scss" scoped>
.noticeList-box {
.text-xs {
flex: 1;
}
}
</style>

View File

@@ -59,10 +59,8 @@ import { SidebarColor, ThemeMode } from '@/enums/settings/theme-enum'
import { LayoutMode } from '@/enums'
// 导入子组件
import MenuSearch from '@/components/MenuSearch/index.vue'
import Fullscreen from '@/components/Fullscreen/index.vue'
import SizeSelect from '@/components/SizeSelect/index.vue'
import LangSelect from '@/components/LangSelect/index.vue'
import Notification from '@/components/Notification/index.vue'
const { t } = useI18n()

View File

@@ -38,37 +38,29 @@
class="data-table__content"
>
<el-table-column type="index" label="序号" width="60" />
<el-table-column label="通知标题" prop="title" min-width="200" />
<el-table-column label="通知标题" prop="title" />
<el-table-column align="center" label="通知类型" width="150">
<template #default="scope">
<DictLabel v-model="scope.row.type" code="notice_type" />
</template>
</el-table-column>
<el-table-column align="center" label="发布人" prop="publisherName" width="100" />
<el-table-column align="center" label="通知等级" width="100">
<template #default="scope">
<DictLabel v-model="scope.row.level" code="notice_level" />
<el-tag type="primary">{{ scope.row.type }}</el-tag>
</template>
</el-table-column>
<el-table-column align="center" label="报销内容" prop="content" min-width="100" />
<el-table-column
key="releaseTime"
align="center"
label="发布时间"
prop="publishTime"
prop="times"
width="150"
/>
<el-table-column align="center" label="发布人" prop="publisherName" width="150" />
<el-table-column align="center" label="状态" width="100">
<template #default="scope">
<el-tag v-if="scope.row.isRead == 1" type="success">已读</el-tag>
<el-tag v-else type="info">未读</el-tag>
<el-tag type="info">{{ scope.row.state }}</el-tag>
</template>
</el-table-column>
<el-table-column align="center" fixed="right" label="操作" width="80">
<template #default="scope">
<el-button type="primary" size="small" link @click="handleReadNotice(scope.row.id)">
查看
<el-button type="primary" size="small" link @click="handleReadNotice(scope.row)">
审批
</el-button>
</template>
</el-table-column>
@@ -110,12 +102,16 @@
</template>
<script setup lang="ts">
import { UserApprovalProcessing, UserRoxyexhibition } from '@/api/calibration/approval'
defineOptions({
name: 'MyNotice',
inheritAttrs: false
})
import NoticeAPI, { NoticePageVO, NoticePageQuery, NoticeDetailVO } from '@/api/system/notice-api'
import { NoticePageVO, NoticePageQuery, NoticeDetailVO } from '@/api/system/notice-api'
import { functionDialogBox } from '@/utils/functionDialogBox'
import ApprovalForm from '@/components/Notification/ApprovalForm.vue'
const queryFormRef = ref()
const pageData = ref<NoticePageVO[]>([])
@@ -134,10 +130,10 @@ const noticeDetail = ref<NoticeDetailVO | null>(null)
// 查询通知公告
function handleQuery() {
loading.value = true
NoticeAPI.getMyNoticePage(queryParams)
.then((data) => {
pageData.value = data.list
total.value = data.total
UserRoxyexhibition(queryParams)
.then((res: any) => {
pageData.value = res.data
total.value = res.total
})
.finally(() => {
loading.value = false
@@ -152,10 +148,29 @@ function handleResetQuery() {
}
// 阅读通知公告
function handleReadNotice(id: string) {
NoticeAPI.getDetail(id).then((data) => {
noticeDialogVisible.value = true
noticeDetail.value = data
function handleReadNotice(data: any) {
functionDialogBox(
ApprovalForm,
{
content: data.content
},
{
title: data.type,
width: '500',
ok(value: any) {
onUserApprovalProcessing({ id: data.id, type: data.type, state: value.state })
}
}
)
}
const onUserApprovalProcessing = (data: any) => {
UserApprovalProcessing(data).then((res: any) => {
ElMessage({
type: 'success',
message: res.message
})
handleQuery()
})
}