新增 报备进展记录
This commit is contained in:
1 parent
ac74fa9204
commit
1759de5af3
13 files changed
+639
-24
No files matched your search
@@ -58,9 +58,17 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="createdAt" label="创建时间" width="180" />
|
||||
<el-table-column label="操作" width="200" fixed="right">
|
||||
<el-table-column label="操作" width="250" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" @click="handleView(row)">查看</el-button>
|
||||
<el-button
|
||||
v-if="row.status === 1"
|
||||
link
|
||||
type="info"
|
||||
@click="handleShowProgress(row)"
|
||||
>
|
||||
进展
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="userStore.isAdmin && row.status === 0"
|
||||
link
|
||||
@@ -157,6 +165,51 @@
|
||||
<el-button type="primary" @click="handleAuditSubmit">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 进展记录对话框 -->
|
||||
<el-dialog v-model="progressDialogVisible" title="报备进展记录" width="1000px" @close="handleProgressDialogClose">
|
||||
<el-card>
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span>添加进展记录</span>
|
||||
</div>
|
||||
</template>
|
||||
<el-form ref="progressFormRef" :model="progressFormData" :rules="progressRules" label-width="100px">
|
||||
<el-form-item label="进展内容" prop="progressContent">
|
||||
<el-input
|
||||
v-model="progressFormData.progressContent"
|
||||
type="textarea"
|
||||
:rows="4"
|
||||
placeholder="请输入进展内容"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button v-if="editingProgressId" @click="handleCancelEdit">取消编辑</el-button>
|
||||
<el-button type="primary" @click="handleSaveProgress">{{ editingProgressId ? '保存修改' : '添加' }}</el-button>
|
||||
</template>
|
||||
</el-card>
|
||||
|
||||
<el-divider content-position="left">进展记录列表</el-divider>
|
||||
|
||||
<el-table :data="progressList" border stripe v-loading="progressLoading">
|
||||
<el-table-column prop="progressContent" label="进展内容" show-overflow-tooltip />
|
||||
<el-table-column prop="createdAt" label="创建时间" width="180" />
|
||||
<el-table-column prop="updatedAt" label="更新时间" width="180" />
|
||||
<el-table-column label="操作" width="150" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
v-if="!userStore.isAdmin"
|
||||
link
|
||||
type="primary"
|
||||
@click="handleEditProgress(row)"
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -166,9 +219,10 @@ import { ElMessage, ElMessageBox, type FormInstance, type FormRules } from 'elem
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
|
||||
import { getReportPage, createReport, auditReport, withdrawReport } from '@/api/report'
|
||||
import { getProgressByReportId, createProgress, updateProgress } from '@/api/report-progress'
|
||||
import { searchCustomerByName } from '@/api/customer'
|
||||
import { getConfigValue } from '@/api/system'
|
||||
import type { Report, ReportForm } from '@/types'
|
||||
import type { Report, ReportForm, ReportProgress, ReportProgressForm } from '@/types'
|
||||
|
||||
const userStore = useUserStore()
|
||||
|
||||
@@ -184,6 +238,21 @@ const formRef = ref<FormInstance>()
|
||||
const searchLoading = ref(false)
|
||||
const customerOptions = ref<Array<{ id: number; name: string }>>([])
|
||||
|
||||
// 进展记录相关
|
||||
const progressDialogVisible = ref(false)
|
||||
const progressFormRef = ref<FormInstance>()
|
||||
const progressFormData = reactive<ReportProgressForm>({
|
||||
reportId: 0,
|
||||
progressContent: ''
|
||||
})
|
||||
const progressList = ref<ReportProgress[]>([])
|
||||
const editingProgressId = ref<number | undefined>()
|
||||
const progressLoading = ref(false)
|
||||
|
||||
const progressRules: FormRules = {
|
||||
progressContent: [{ required: true, message: '请输入进展内容', trigger: 'blur' }]
|
||||
}
|
||||
|
||||
const queryForm = reactive({
|
||||
current: 1,
|
||||
size: 10,
|
||||
@@ -211,6 +280,77 @@ const formatDate = (dateStr: string | null | undefined) => {
|
||||
return dateStr.split(' ')[0] // 只保留日期部分,去掉时间
|
||||
}
|
||||
|
||||
// 显示进展记录对话框
|
||||
const handleShowProgress = async (row: Report) => {
|
||||
progressFormData.reportId = row.id
|
||||
progressFormData.progressContent = ''
|
||||
editingProgressId.value = undefined
|
||||
await fetchProgressList(row.id)
|
||||
progressDialogVisible.value = true
|
||||
}
|
||||
|
||||
// 获取进展记录列表
|
||||
const fetchProgressList = async (reportId: number) => {
|
||||
progressLoading.value = true
|
||||
try {
|
||||
const res = await getProgressByReportId(reportId)
|
||||
progressList.value = res
|
||||
} catch (error) {
|
||||
console.error('获取进展记录失败', error)
|
||||
progressList.value = []
|
||||
} finally {
|
||||
progressLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 保存进展记录
|
||||
const handleSaveProgress = async () => {
|
||||
if (!progressFormRef.value) return
|
||||
await progressFormRef.value.validate(async (valid) => {
|
||||
if (valid) {
|
||||
try {
|
||||
if (editingProgressId.value) {
|
||||
// 编辑模式
|
||||
await updateProgress(editingProgressId.value, progressFormData)
|
||||
ElMessage.success('更新成功')
|
||||
} else {
|
||||
// 新增模式
|
||||
await createProgress(progressFormData)
|
||||
ElMessage.success('添加成功')
|
||||
}
|
||||
// 重新获取进展记录列表
|
||||
await fetchProgressList(progressFormData.reportId)
|
||||
// 重置表单
|
||||
progressFormData.progressContent = ''
|
||||
editingProgressId.value = undefined
|
||||
} catch (error) {
|
||||
console.error('保存进展记录失败', error)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 编辑进展记录
|
||||
const handleEditProgress = (row: ReportProgress) => {
|
||||
editingProgressId.value = row.id
|
||||
progressFormData.progressContent = row.progressContent
|
||||
}
|
||||
|
||||
// 取消编辑
|
||||
const handleCancelEdit = () => {
|
||||
editingProgressId.value = undefined
|
||||
progressFormData.progressContent = ''
|
||||
}
|
||||
|
||||
// 关闭进展记录对话框
|
||||
const handleProgressDialogClose = () => {
|
||||
progressDialogVisible.value = false
|
||||
progressFormRef.value?.resetFields()
|
||||
progressFormData.progressContent = ''
|
||||
editingProgressId.value = undefined
|
||||
progressList.value = []
|
||||
}
|
||||
|
||||
// 查询数据
|
||||
const fetchData = async () => {
|
||||
loading.value = true
|
||||
|
||||
Reference in new issue
Block a user