fix
This commit is contained in:
parent
c47c8e48aa
commit
4972dcaf4d
|
@ -22,21 +22,6 @@
|
|||
/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="提案类型">
|
||||
<a-select
|
||||
v-model="searchForm.type"
|
||||
placeholder="请选择类型"
|
||||
allow-clear
|
||||
style="width: 150px"
|
||||
>
|
||||
<a-option value="">全部</a-option>
|
||||
<a-option value="管理规范">管理规范</a-option>
|
||||
<a-option value="操作流程">操作流程</a-option>
|
||||
<a-option value="安全制度">安全制度</a-option>
|
||||
<a-option value="其他">其他</a-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="状态">
|
||||
<a-select
|
||||
v-model="searchForm.status"
|
||||
|
@ -45,8 +30,8 @@
|
|||
style="width: 150px"
|
||||
>
|
||||
<a-option value="">全部</a-option>
|
||||
<a-option value="PUBLISHED">已公示</a-option>
|
||||
<a-option value="APPROVED">已通过</a-option>
|
||||
<a-option value="PUBLISHED">已公告</a-option>
|
||||
<a-option value="APPROVED">已公示</a-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
|
||||
|
@ -183,7 +168,6 @@ const columns = [
|
|||
const searchForm = reactive({
|
||||
title: '',
|
||||
proposer: '',
|
||||
type: '',
|
||||
status: ''
|
||||
})
|
||||
|
||||
|
@ -213,22 +197,19 @@ const regulationStore = useRegulationStore()
|
|||
// 获取状态颜色
|
||||
const getStatusColor = (status: RegulationStatus) => {
|
||||
const colors = {
|
||||
[RegulationStatus.DRAFT]: 'blue',
|
||||
[RegulationStatus.PUBLISHED]: 'purple',
|
||||
[RegulationStatus.APPROVED]: 'green',
|
||||
}
|
||||
return colors[status] || 'blue'
|
||||
return colors[status] || 'purple'
|
||||
}
|
||||
|
||||
// 获取状态文本
|
||||
const getStatusText = (status: RegulationStatus) => {
|
||||
const texts = {
|
||||
[RegulationStatus.DRAFT]: '草稿',
|
||||
[RegulationStatus.PUBLISHED]: '已公告',
|
||||
[RegulationStatus.APPROVED]: '已公示',
|
||||
|
||||
}
|
||||
return texts[status] || '草稿'
|
||||
return texts[status] || '已公告'
|
||||
}
|
||||
|
||||
// 格式化日期
|
||||
|
@ -268,14 +249,18 @@ const getLevelText = (level: RegulationLevel) => {
|
|||
const getTableData = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const response = await regulationApi.getRegulationList({
|
||||
// 构建请求参数
|
||||
const requestParams: any = {
|
||||
page: pagination.current,
|
||||
size: pagination.pageSize,
|
||||
title: searchForm.title || undefined,
|
||||
proposer: searchForm.proposer || undefined,
|
||||
type: searchForm.type || undefined,
|
||||
status: searchForm.status || undefined
|
||||
})
|
||||
proposer: searchForm.proposer || undefined
|
||||
}
|
||||
|
||||
if (searchForm.status) {
|
||||
// 用户选择了特定状态
|
||||
requestParams.status = searchForm.status
|
||||
const response = await regulationApi.getRegulationList(requestParams)
|
||||
|
||||
if (response.status === 200) {
|
||||
tableData.value = response.data.records
|
||||
|
@ -284,6 +269,37 @@ const getTableData = async () => {
|
|||
} else {
|
||||
Message.error('搜索失败')
|
||||
}
|
||||
} else {
|
||||
// 用户没有选择状态,默认显示已公示和已公告的提案
|
||||
// 分别查询已公告和已公示的提案
|
||||
const [publishedResponse, approvedResponse] = await Promise.all([
|
||||
regulationApi.getRegulationList({
|
||||
...requestParams,
|
||||
status: RegulationStatus.PUBLISHED
|
||||
}),
|
||||
regulationApi.getRegulationList({
|
||||
...requestParams,
|
||||
status: RegulationStatus.APPROVED
|
||||
})
|
||||
])
|
||||
|
||||
if (publishedResponse.status === 200 && approvedResponse.status === 200) {
|
||||
// 合并两个结果
|
||||
const allRecords = [
|
||||
...publishedResponse.data.records,
|
||||
...approvedResponse.data.records
|
||||
]
|
||||
|
||||
// 按创建时间排序
|
||||
allRecords.sort((a, b) => new Date(b.createTime).getTime() - new Date(a.createTime).getTime())
|
||||
|
||||
tableData.value = allRecords
|
||||
pagination.total = allRecords.length
|
||||
pagination.current = 1
|
||||
} else {
|
||||
Message.error('搜索失败')
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('搜索制度公示失败:', error)
|
||||
Message.error('搜索失败')
|
||||
|
@ -303,7 +319,6 @@ const reset = () => {
|
|||
Object.assign(searchForm, {
|
||||
title: '',
|
||||
proposer: '',
|
||||
type: '',
|
||||
status: ''
|
||||
})
|
||||
pagination.current = 1
|
||||
|
|
|
@ -31,21 +31,6 @@
|
|||
/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="提案类型">
|
||||
<a-select
|
||||
v-model="searchForm.type"
|
||||
placeholder="请选择类型"
|
||||
allow-clear
|
||||
style="width: 150px"
|
||||
>
|
||||
<a-option value="">全部</a-option>
|
||||
<a-option value="管理规范">管理规范</a-option>
|
||||
<a-option value="操作流程">操作流程</a-option>
|
||||
<a-option value="安全制度">安全制度</a-option>
|
||||
<a-option value="其他">其他</a-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="状态">
|
||||
<a-select
|
||||
v-model="searchForm.status"
|
||||
|
@ -352,7 +337,6 @@ const columns = [
|
|||
const searchForm = reactive({
|
||||
title: '',
|
||||
proposer: '',
|
||||
type: '',
|
||||
status: ''
|
||||
})
|
||||
|
||||
|
@ -484,7 +468,6 @@ const getTableData = async () => {
|
|||
size: pagination.pageSize,
|
||||
title: searchForm.title || undefined,
|
||||
proposer: searchForm.proposer || undefined,
|
||||
type: searchForm.type || undefined,
|
||||
status: searchForm.status || undefined
|
||||
})
|
||||
|
||||
|
@ -514,7 +497,6 @@ const reset = () => {
|
|||
Object.assign(searchForm, {
|
||||
title: '',
|
||||
proposer: '',
|
||||
type: '',
|
||||
status: ''
|
||||
})
|
||||
pagination.current = 1
|
||||
|
|
|
@ -30,8 +30,8 @@
|
|||
style="width: 150px"
|
||||
>
|
||||
<a-option value="">全部</a-option>
|
||||
<a-option value="confirmed">已确认</a-option>
|
||||
<a-option value="pending">待确认</a-option>
|
||||
<a-option value="CONFIRMED">已确认</a-option>
|
||||
<a-option value="PENDING">待确认</a-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
|
||||
|
@ -64,8 +64,8 @@
|
|||
</span>
|
||||
</template>
|
||||
<template #confirmStatus="{ record }">
|
||||
<a-tag :color="record.confirmStatus === 'confirmed' ? 'green' : 'orange'">
|
||||
{{ record.confirmStatus === 'confirmed' ? '已确认' : '待确认' }}
|
||||
<a-tag :color="record.confirmStatus === 'CONFIRMED' ? 'green' : 'orange'">
|
||||
{{ record.confirmStatus === 'CONFIRMED' ? '已确认' : '待确认' }}
|
||||
</a-tag>
|
||||
</template>
|
||||
|
||||
|
@ -96,6 +96,11 @@
|
|||
<span>公示人: {{ currentRegulation.createByName }}</span>
|
||||
<span>公示时间: {{ currentRegulation.publishTime }}</span>
|
||||
<span>生效日期: {{ currentRegulation.effectiveTime }}</span>
|
||||
<span>确认状态:
|
||||
<a-tag :color="currentRegulation.confirmStatus === 'CONFIRMED' ? 'green' : 'orange'">
|
||||
{{ currentRegulation.confirmStatus === 'CONFIRMED' ? '已确认' : '待确认' }}
|
||||
</a-tag>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -118,9 +123,20 @@
|
|||
<a-divider />
|
||||
|
||||
<div class="detail-footer">
|
||||
<a-button type="primary" @click="handleConfirm(currentRegulation)">
|
||||
<a-button
|
||||
v-if="currentRegulation.confirmStatus !== 'CONFIRMED'"
|
||||
type="primary"
|
||||
@click="handleConfirm(currentRegulation)"
|
||||
>
|
||||
确认知晓并遵守
|
||||
</a-button>
|
||||
<a-button
|
||||
v-else
|
||||
type="primary"
|
||||
disabled
|
||||
>
|
||||
已确认知晓
|
||||
</a-button>
|
||||
<a-button @click="handleDownload(currentRegulation)">
|
||||
下载制度文件
|
||||
</a-button>
|
||||
|
@ -216,10 +232,20 @@ const getTableData = async () => {
|
|||
})
|
||||
|
||||
if (response.status === 200) {
|
||||
tableData.value = response.data.records
|
||||
|
||||
|
||||
// 确保每个记录都有 confirmStatus 字段
|
||||
const records = response.data.records.map((record: any) => ({
|
||||
...record,
|
||||
confirmStatus: record.confirmStatus || 'PENDING'
|
||||
}))
|
||||
|
||||
tableData.value = records
|
||||
pagination.pageSize = response.data.size
|
||||
pagination.current = response.data.current
|
||||
pagination.total = response.data.total
|
||||
|
||||
|
||||
} else {
|
||||
Message.error('搜索失败')
|
||||
}
|
||||
|
@ -311,10 +337,15 @@ const submitConfirm = async () => {
|
|||
Message.success('确认成功,您已承诺遵守该制度')
|
||||
confirmModalVisible.value = false
|
||||
|
||||
// 更新本地数据状态
|
||||
const index = tableData.value.findIndex(item => item.regulationId === currentRegulation.value.regulationId)
|
||||
if (index !== -1) {
|
||||
tableData.value[index].confirmStatus = 'confirmed'
|
||||
// 立即刷新数据,确保状态同步
|
||||
await getTableData()
|
||||
|
||||
// 如果详情弹窗是打开的,也更新详情弹窗中的数据
|
||||
if (detailModalVisible.value && currentRegulation.value) {
|
||||
const updatedRecord = tableData.value.find(item => item.regulationId === currentRegulation.value.regulationId)
|
||||
if (updatedRecord) {
|
||||
currentRegulation.value = updatedRecord
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
|
|
Loading…
Reference in New Issue