|
|
@@ -12,6 +12,7 @@
|
|
|
</el-form-item>
|
|
|
<el-form-item style="float: right">
|
|
|
<el-button type="success" @click="handleAdd">新增</el-button>
|
|
|
+ <el-button @click="openTemplateDrawer">模板库</el-button>
|
|
|
<el-button type="danger" @click="handleBatchDelete">批量删除</el-button>
|
|
|
<el-button type="primary" @click="handleExport">导出</el-button>
|
|
|
<el-button type="primary" @click="handleDownloadTemplate">下载模版</el-button>
|
|
|
@@ -183,6 +184,69 @@
|
|
|
</template>
|
|
|
</el-dialog>
|
|
|
|
|
|
+ <!-- 模板库管理抽屉 -->
|
|
|
+ <el-drawer v-model="templateDrawerVisible" title="预案模板库" size="760px" destroy-on-close>
|
|
|
+ <div style="margin-bottom:12px;display:flex;justify-content:space-between;align-items:center">
|
|
|
+ <span style="color:#909399;font-size:13px">模板用于「新建预案」时预填名称与章节正文</span>
|
|
|
+ <el-button type="primary" size="small" @click="handleTemplateAdd">新增模板</el-button>
|
|
|
+ </div>
|
|
|
+ <el-table :data="templateList" border stripe style="width:100%" v-loading="templateLoading">
|
|
|
+ <el-table-column prop="planName" label="模板名称" min-width="180" show-overflow-tooltip />
|
|
|
+ <el-table-column prop="eventType" label="类型" width="80" align="center" />
|
|
|
+ <el-table-column prop="eventLevel" label="等级" width="70" align="center" />
|
|
|
+ <el-table-column prop="responsibleUnit" label="责任单位" width="100">
|
|
|
+ <template #default="{ row }">{{ row.responsibleUnit || '-' }}</template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="planSummary" label="概要" min-width="200" show-overflow-tooltip>
|
|
|
+ <template #default="{ row }">{{ row.planSummary || '-' }}</template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="操作" width="130" align="center" fixed="right">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <el-button link type="primary" @click="handleTemplateEdit(row)">编辑</el-button>
|
|
|
+ <el-button link type="danger" @click="handleTemplateDelete(row)">删除</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+
|
|
|
+ <!-- 模板新增/编辑弹窗 -->
|
|
|
+ <el-dialog v-model="templateFormVisible" :title="templateForm.id ? '编辑模板' : '新增模板'" width="620px" append-to-body destroy-on-close>
|
|
|
+ <el-form ref="templateFormRef" :model="templateForm" :rules="templateRules" label-width="90px">
|
|
|
+ <el-form-item label="模板名称" prop="planName">
|
|
|
+ <el-input v-model="templateForm.planName" maxlength="60" placeholder="请输入模板名称" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-row :gutter="16">
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item label="类型">
|
|
|
+ <el-select v-model="templateForm.eventType" placeholder="请选择" style="width:100%">
|
|
|
+ <el-option v-for="t in ['综合', '供水', '燃气', '排水']" :key="t" :label="t" :value="t" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item label="等级">
|
|
|
+ <el-select v-model="templateForm.eventLevel" placeholder="请选择" style="width:100%">
|
|
|
+ <el-option v-for="l in ['Ⅰ级', 'Ⅱ级', 'Ⅲ级']" :key="l" :label="l" :value="l" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-form-item label="责任单位">
|
|
|
+ <el-input v-model="templateForm.responsibleUnit" maxlength="50" placeholder="请输入责任单位(选填)" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="模板概要">
|
|
|
+ <el-input v-model="templateForm.planSummary" type="textarea" :rows="2" maxlength="200" show-word-limit placeholder="一句话说明模板适用场景(新建预案选择时展示)" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="章节正文">
|
|
|
+ <el-input v-model="templateForm.planContent" type="textarea" :rows="8" placeholder="模板章节大纲/正文,新建预案套用后可在正文基础上编写" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <template #footer>
|
|
|
+ <el-button @click="templateFormVisible = false">取消</el-button>
|
|
|
+ <el-button type="primary" :loading="templateSaving" @click="handleTemplateSubmit">保存</el-button>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+ </el-drawer>
|
|
|
+
|
|
|
<!-- 版本管理弹窗 -->
|
|
|
<el-dialog v-model="versionVisible" title="版本管理" width="760px" destroy-on-close>
|
|
|
<div style="margin-bottom:12px;color:#606266;font-size:13px">
|
|
|
@@ -237,7 +301,8 @@ import { getToken } from '@/utils/auth'
|
|
|
import { useDict } from '@/utils/dict'
|
|
|
import {
|
|
|
getEventPlanPage, getEventPlanById, saveEventPlan, deleteEventPlan,
|
|
|
- submitEventPlan, getPlanVersions, getPlanVersion, getPlanLibraryList
|
|
|
+ submitEventPlan, getPlanVersions, getPlanVersion, getPlanLibraryList,
|
|
|
+ savePlanLibrary, deletePlanLibrary
|
|
|
} from '@/api/dispatch'
|
|
|
|
|
|
// ---------- 字典 ----------
|
|
|
@@ -333,10 +398,15 @@ const libraryList = ref([])
|
|
|
|
|
|
const handleAdd = () => {
|
|
|
createPickVisible.value = true
|
|
|
- if (!libraryList.value.length) {
|
|
|
- getPlanLibraryList()
|
|
|
- .then(res => { libraryList.value = res?.data ?? [] })
|
|
|
- .catch(() => { libraryList.value = [] })
|
|
|
+ loadTemplates()
|
|
|
+}
|
|
|
+
|
|
|
+async function loadTemplates() {
|
|
|
+ try {
|
|
|
+ const res = await getPlanLibraryList()
|
|
|
+ libraryList.value = res?.data ?? []
|
|
|
+ } catch {
|
|
|
+ libraryList.value = []
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -352,6 +422,77 @@ function pickCreate(tpl) {
|
|
|
dialogVisible.value = true
|
|
|
}
|
|
|
|
|
|
+// ---------- 模板库管理 ----------
|
|
|
+const templateDrawerVisible = ref(false)
|
|
|
+const templateList = ref([])
|
|
|
+const templateLoading = ref(false)
|
|
|
+const templateFormVisible = ref(false)
|
|
|
+const templateFormRef = ref(null)
|
|
|
+const templateSaving = ref(false)
|
|
|
+const templateForm = ref({})
|
|
|
+const templateRules = {
|
|
|
+ planName: [{ required: true, message: '请输入模板名称', trigger: 'blur' }]
|
|
|
+}
|
|
|
+
|
|
|
+// 打开抽屉时加载模板列表(此前按钮只开了抽屉没加载数据,导致首次打开“暂无数据”)
|
|
|
+function openTemplateDrawer() {
|
|
|
+ templateDrawerVisible.value = true
|
|
|
+ loadTemplatesForDrawer()
|
|
|
+}
|
|
|
+
|
|
|
+async function loadTemplatesForDrawer() {
|
|
|
+ templateLoading.value = true
|
|
|
+ try {
|
|
|
+ const res = await getPlanLibraryList()
|
|
|
+ templateList.value = res?.data ?? []
|
|
|
+ } catch {
|
|
|
+ ElMessage.error('模板列表加载失败')
|
|
|
+ } finally {
|
|
|
+ templateLoading.value = false
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const defaultTemplateForm = () => ({ id: null, planName: '', eventType: '', eventLevel: '', responsibleUnit: '', planSummary: '', planContent: '' })
|
|
|
+
|
|
|
+function handleTemplateAdd() {
|
|
|
+ templateForm.value = defaultTemplateForm()
|
|
|
+ templateFormVisible.value = true
|
|
|
+}
|
|
|
+
|
|
|
+function handleTemplateEdit(row) {
|
|
|
+ templateForm.value = { ...row }
|
|
|
+ templateFormVisible.value = true
|
|
|
+}
|
|
|
+
|
|
|
+function handleTemplateDelete(row) {
|
|
|
+ ElMessageBox.confirm(`确认删除模板【${row.planName}】?`, '提示', { type: 'warning' }).then(async () => {
|
|
|
+ try {
|
|
|
+ await deletePlanLibrary(row.id)
|
|
|
+ ElMessage.success('删除成功')
|
|
|
+ loadTemplatesForDrawer()
|
|
|
+ } catch {
|
|
|
+ ElMessage.error('删除失败')
|
|
|
+ }
|
|
|
+ }).catch(() => {})
|
|
|
+}
|
|
|
+
|
|
|
+function handleTemplateSubmit() {
|
|
|
+ templateFormRef.value?.validate(async (valid) => {
|
|
|
+ if (!valid) return
|
|
|
+ templateSaving.value = true
|
|
|
+ try {
|
|
|
+ await savePlanLibrary(templateForm.value)
|
|
|
+ ElMessage.success('保存成功')
|
|
|
+ templateFormVisible.value = false
|
|
|
+ loadTemplatesForDrawer()
|
|
|
+ } catch {
|
|
|
+ ElMessage.error('保存失败')
|
|
|
+ } finally {
|
|
|
+ templateSaving.value = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
// 已通过的预案走「修订」:保存后生成审核中的候选版本,必须填写修订说明
|
|
|
const isRevising = computed(() => !!form.value.id && form.value.status === 2)
|
|
|
|