| | |
| | | placeholder="请输入申请人" |
| | | clearable |
| | | :prefix-icon="Search" |
| | | @keyup.enter="handleQuery" |
| | | @keyup.enter="onSearch" |
| | | /> |
| | | <span class="search_title" style="margin-left: 12px">申请日期:</span> |
| | | <el-date-picker |
| | |
| | | style="width: 260px" |
| | | clearable |
| | | /> |
| | | <el-button type="primary" style="margin-left: 10px" @click="handleQuery">搜索</el-button> |
| | | <el-button type="primary" style="margin-left: 10px" @click="onSearch">搜索</el-button> |
| | | <el-button @click="resetSearch">重置</el-button> |
| | | </div> |
| | | <div> |
| | |
| | | :page="page" |
| | | :isSelection="false" |
| | | :tableLoading="tableLoading" |
| | | @pagination="pagination" |
| | | @pagination="onPagination" |
| | | :total="page.total" |
| | | /> |
| | | </div> |
| | | |
| | | <!-- 新增 / 编辑 --> |
| | | <el-dialog |
| | | v-if="formDialog.visible" |
| | | v-model="formDialog.visible" |
| | | :title="formDialog.title" |
| | | width="960px" |
| | | append-to-body |
| | | destroy-on-close |
| | | class="regular-apply-form-dialog" |
| | | @closed="onFormClosed" |
| | | > |
| | | <el-form ref="formRef" :model="form" :rules="formRules" label-width="140px" class="regular-apply-form"> |
| | | <el-form-item v-if="form.templateSnapshot" label="审批模板"> |
| | | <span class="template-name">{{ form.templateSnapshot.label || form.templateName }}</span> |
| | | <el-button |
| | | v-if="formDialog.mode === 'add'" |
| | | type="primary" |
| | | link |
| | | class="ml12" |
| | | @click="reopenTemplateBind" |
| | | > |
| | | 更换模板 |
| | | </el-button> |
| | | </el-form-item> |
| | | <FormPayloadFields :fields="form.formFieldDefs" :form-payload="form.formPayload" /> |
| | | <ApprovalTemplateFormSection |
| | | :active-template="form.templateSnapshot" |
| | | :fields="form.formFieldDefs" |
| | | :form-payload="form.formPayload" |
| | | v-model:flow-nodes="form.flowNodes" |
| | | v-model:attachments="form.storageBlobDTOs" |
| | | :template-attachments="form.templateAttachments" |
| | | <ApprovalInstanceSubmitDialog |
| | | v-model="submitDialog.visible" |
| | | :title="submitDialogTitle" |
| | | :form="submitForm" |
| | | :rules="submitFormRules" |
| | | :fields="submitFormFields" |
| | | :active-template="activeTemplate" |
| | | :user-options="flowUserOptions" |
| | | flow-attachments-only |
| | | hide-template-name |
| | | :allow-change-template="false" |
| | | :is-edit="isSubmitEdit" |
| | | :saving="submitSaving" |
| | | :form-ref="submitFormRef" |
| | | @submit="onSubmit" |
| | | /> |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="submitForm">确 定</el-button> |
| | | <el-button @click="formDialog.visible = false">取 消</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | |
| | | <ApprovalTemplateBindDialog |
| | | v-model:visible="templateBindVisible" |
| | |
| | | @closed="onTemplateBindClosed" |
| | | /> |
| | | |
| | | <!-- 详情(只读) --> |
| | | <el-dialog v-model="detailDialog.visible" title="转正申请详情" width="640px" append-to-body> |
| | | <el-descriptions :column="1" border> |
| | | <el-descriptions-item label="申请人">{{ detailRow.applicantName }}</el-descriptions-item> |
| | | <el-descriptions-item label="申请日期">{{ detailRow.applyDate }}</el-descriptions-item> |
| | | <el-descriptions-item label="转正日期">{{ detailRow.regularizationDate }}</el-descriptions-item> |
| | | <el-descriptions-item label="试用期工作总结">{{ detailRow.probationSummary }}</el-descriptions-item> |
| | | <el-descriptions-item label="审批结果">{{ approvalResultLabel(detailRow.approvalResult) }}</el-descriptions-item> |
| | | <el-descriptions-item label="审批方式">{{ approvalModeLabel(detailRow.approvalMode) }}</el-descriptions-item> |
| | | <el-descriptions-item label="审批人">{{ detailRow.approverNames || "—" }}</el-descriptions-item> |
| | | <el-descriptions-item label="附件"> |
| | | <template v-if="detailRow.attachmentList?.length"> |
| | | <el-tag |
| | | v-for="(f, i) in detailRow.attachmentList" |
| | | :key="i" |
| | | class="mr6 mb6" |
| | | type="info" |
| | | > |
| | | {{ f.name }} |
| | | </el-tag> |
| | | </template> |
| | | <span v-else>无</span> |
| | | </el-descriptions-item> |
| | | </el-descriptions> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="detailDialog.visible = false">关 闭</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | |
| | | <!-- 附件列表 --> |
| | | <el-dialog v-model="filesDialog.visible" title="附件" width="520px" append-to-body> |
| | | <el-table v-if="filesDialog.row?.attachmentList?.length" :data="filesDialog.row.attachmentList" border> |
| | | <el-table-column type="index" label="序号" width="60" align="center" /> |
| | | <el-table-column prop="name" label="文件名" min-width="200" show-overflow-tooltip /> |
| | | <el-table-column label="操作" width="100" align="center"> |
| | | <template #default="{ row }"> |
| | | <el-button link type="primary" @click="mockDownload(row)">下载</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <el-empty v-else description="暂无附件" /> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="filesDialog.visible = false">关 闭</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | <ApprovalInstanceDetailDialog |
| | | v-model="detailDialog.visible" |
| | | title="转正申请详情" |
| | | :row="detailRow" |
| | | @edit="openEditFromDetail" |
| | | /> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { Search } from "@element-plus/icons-vue"; |
| | | import { computed, getCurrentInstance, nextTick, onMounted, reactive, ref, watch } from "vue"; |
| | | import { ElMessage } from "element-plus"; |
| | | import { onMounted, reactive } from "vue"; |
| | | import ApprovalInstanceDetailDialog from "../../ApproveManage/approve-shared/components/ApprovalInstanceDetailDialog.vue"; |
| | | import ApprovalInstanceSubmitDialog from "../../ApproveManage/approve-shared/components/ApprovalInstanceSubmitDialog.vue"; |
| | | import ApprovalTemplateBindDialog from "../../ApproveManage/approve-shared/components/ApprovalTemplateBindDialog.vue"; |
| | | import ApprovalTemplateFormSection from "../../ApproveManage/approve-shared/components/ApprovalTemplateFormSection.vue"; |
| | | import FormPayloadFields from "../../ApproveManage/approve-list/components/FormPayloadFields.vue"; |
| | | import { buildInstanceTableColumns } from "../../ApproveManage/approve-shared/approvalInstanceFormConfigTable.js"; |
| | | import { APPROVAL_MODULE_KEYS } from "../../ApproveManage/approve-shared/approvalModuleRegistry.js"; |
| | | import { |
| | | applyBindingToForm, |
| | | buildFormPayloadRules, |
| | | validateTemplateBinding, |
| | | } from "../../ApproveManage/approve-shared/approvalTemplateBindingUtils.js"; |
| | | import { useApprovalInstanceModule } from "../../ApproveManage/approve-shared/useApprovalInstanceModule.js"; |
| | | import { useFlowUserOptions } from "../../ApproveManage/approve-shared/useFlowUserOptions.js"; |
| | | |
| | | /** 与后端约定字段(占位) */ |
| | | const createEmptyForm = () => ({ |
| | | id: undefined, |
| | | applicantName: "", |
| | | applyDate: "", |
| | | regularizationDate: "", |
| | | probationSummary: "", |
| | | hasTemplateBinding: false, |
| | | templateId: "", |
| | | templateName: "", |
| | | templateSnapshot: null, |
| | | formFieldDefs: [], |
| | | formPayload: {}, |
| | | flowNodes: [], |
| | | templateAttachments: [], |
| | | storageBlobDTOs: [], |
| | | }); |
| | | |
| | | const { proxy } = getCurrentInstance(); |
| | | |
| | | function approvalModeLabel(mode) { |
| | | if (mode === "countersign") return "会签"; |
| | | return "与签"; |
| | | } |
| | | |
| | | function approvalResultLabel(v) { |
| | | if (v === "approved") return "已通过"; |
| | | if (v === "rejected") return "已驳回"; |
| | | if (v === "cancelled") return "已撤销"; |
| | | return "待审批"; |
| | | } |
| | | |
| | | const allRows = ref([]); |
| | | |
| | | const searchForm = reactive({ |
| | | applicantName: "", |
| | | applyDateRange: null, |
| | | }); |
| | | |
| | | const tableLoading = ref(false); |
| | | const page = reactive({ |
| | | current: 1, |
| | | size: 10, |
| | | total: 0, |
| | | }); |
| | | |
| | | const filteredList = computed(() => { |
| | | let list = [...allRows.value]; |
| | | const name = (searchForm.applicantName || "").trim(); |
| | | if (name) { |
| | | list = list.filter((r) => r.applicantName.includes(name)); |
| | | const mod = useApprovalInstanceModule({ |
| | | moduleKey: APPROVAL_MODULE_KEYS.REGULAR, |
| | | buildExtraListParams(sf) { |
| | | const range = sf?.applyDateRange; |
| | | if (Array.isArray(range) && range[0]) { |
| | | return { createTime: range[0], createTimeEnd: range[1] }; |
| | | } |
| | | const range = searchForm.applyDateRange; |
| | | if (range && range.length === 2) { |
| | | const [start, end] = range; |
| | | list = list.filter((r) => r.applyDate >= start && r.applyDate <= end); |
| | | } |
| | | return list.sort((a, b) => (a.applyDate < b.applyDate ? 1 : -1)); |
| | | return {}; |
| | | }, |
| | | }); |
| | | |
| | | watch( |
| | | filteredList, |
| | | (list) => { |
| | | page.total = list.length; |
| | | const maxPage = Math.max(1, Math.ceil(list.length / page.size) || 1); |
| | | if (page.current > maxPage) { |
| | | page.current = maxPage; |
| | | } |
| | | }, |
| | | { immediate: true } |
| | | ); |
| | | const { |
| | | tableData, |
| | | tableLoading, |
| | | page, |
| | | detailDialog, |
| | | detailRow, |
| | | submitDialog, |
| | | submitForm, |
| | | submitFormRef, |
| | | submitSaving, |
| | | isSubmitEdit, |
| | | activeTemplate, |
| | | submitFormFields, |
| | | submitFormRules, |
| | | submitDialogTitle, |
| | | templateBindVisible, |
| | | handleQuery, |
| | | initModuleList, |
| | | pagination, |
| | | openAddWithTemplate, |
| | | onTemplateBound, |
| | | onTemplateBindClosed, |
| | | openEditFromDetail, |
| | | submitInstanceForm, |
| | | buildTableActions, |
| | | } = mod; |
| | | |
| | | const tableData = computed(() => { |
| | | const list = filteredList.value; |
| | | const start = (page.current - 1) * page.size; |
| | | return list.slice(start, start + page.size); |
| | | }); |
| | | |
| | | const tableColumn = ref([ |
| | | { label: "申请人", prop: "applicantName", minWidth: 100 }, |
| | | { label: "申请日期", prop: "applyDate", width: 120 }, |
| | | { label: "转正日期", prop: "regularizationDate", width: 120 }, |
| | | { label: "试用期工作总结", prop: "probationSummary", minWidth: 200 }, |
| | | { |
| | | label: "审批结果", |
| | | prop: "approvalResult", |
| | | width: 110, |
| | | dataType: "tag", |
| | | formatData: (v) => approvalResultLabel(v), |
| | | formatType: (v) => { |
| | | if (v === "approved") return "success"; |
| | | if (v === "rejected") return "danger"; |
| | | if (v === "cancelled") return "info"; |
| | | return "warning"; |
| | | }, |
| | | }, |
| | | { |
| | | dataType: "action", |
| | | label: "操作", |
| | | align: "center", |
| | | fixed: "right", |
| | | width: 200, |
| | | operation: [ |
| | | { |
| | | name: "编辑", |
| | | type: "text", |
| | | clickFun: (row) => openFormDialog("edit", row), |
| | | }, |
| | | { |
| | | name: "查看详情", |
| | | type: "text", |
| | | clickFun: (row) => openDetail(row), |
| | | }, |
| | | { |
| | | name: "附件", |
| | | type: "text", |
| | | clickFun: (row) => openFiles(row), |
| | | }, |
| | | ], |
| | | }, |
| | | ]); |
| | | |
| | | const formDialog = reactive({ |
| | | visible: false, |
| | | title: "", |
| | | mode: "add", |
| | | }); |
| | | const formRef = ref(); |
| | | const form = reactive(createEmptyForm()); |
| | | const templateBindVisible = ref(false); |
| | | const pendingTemplateBinding = ref(null); |
| | | const { flowUserOptions, loadFlowUsers } = useFlowUserOptions(); |
| | | |
| | | const formRules = computed(() => buildFormPayloadRules(form.formFieldDefs)); |
| | | const tableColumn = buildInstanceTableColumns(tableData, buildTableActions); |
| | | |
| | | const detailDialog = reactive({ visible: false }); |
| | | const detailRow = ref({}); |
| | | |
| | | const filesDialog = reactive({ visible: false, row: null }); |
| | | |
| | | function handleQuery() { |
| | | page.current = 1; |
| | | tableLoading.value = true; |
| | | setTimeout(() => { |
| | | tableLoading.value = false; |
| | | }, 150); |
| | | function onSearch() { |
| | | handleQuery(searchForm); |
| | | } |
| | | |
| | | function resetSearch() { |
| | | searchForm.applicantName = ""; |
| | | searchForm.applyDateRange = null; |
| | | handleQuery(); |
| | | onSearch(); |
| | | } |
| | | |
| | | function pagination(obj) { |
| | | page.current = obj.page; |
| | | page.size = obj.limit; |
| | | function onPagination(obj) { |
| | | pagination(obj, searchForm); |
| | | } |
| | | |
| | | function openDetail(row) { |
| | | detailRow.value = { ...row }; |
| | | detailDialog.visible = true; |
| | | async function onSubmit() { |
| | | const ok = await submitInstanceForm({ skipValidate: true }); |
| | | if (ok) ElMessage.success(isSubmitEdit.value ? "修改成功" : "提交成功"); |
| | | } |
| | | |
| | | function openFiles(row) { |
| | | filesDialog.row = row; |
| | | filesDialog.visible = true; |
| | | } |
| | | |
| | | function mockDownload(row) { |
| | | const url = row.url || row.downloadURL || row.previewURL || row.previewUrl; |
| | | if (url) { |
| | | window.open(url, "_blank"); |
| | | return; |
| | | } |
| | | proxy?.$modal?.msgWarning?.("暂无下载地址"); |
| | | } |
| | | |
| | | function openAddWithTemplate() { |
| | | formDialog.visible = false; |
| | | pendingTemplateBinding.value = null; |
| | | templateBindVisible.value = true; |
| | | } |
| | | |
| | | function onTemplateBound(binding) { |
| | | pendingTemplateBinding.value = binding; |
| | | } |
| | | |
| | | function onTemplateBindClosed() { |
| | | const binding = pendingTemplateBinding.value; |
| | | if (!binding) return; |
| | | pendingTemplateBinding.value = null; |
| | | openFormWithBinding(binding); |
| | | } |
| | | |
| | | function openFormWithBinding(binding) { |
| | | Object.assign(form, createEmptyForm()); |
| | | applyBindingToForm(form, binding); |
| | | form.hasTemplateBinding = true; |
| | | formDialog.mode = "add"; |
| | | formDialog.title = "新增转正申请"; |
| | | onMounted(async () => { |
| | | loadFlowUsers(); |
| | | formDialog.visible = true; |
| | | nextTick(() => formRef.value?.clearValidate?.()); |
| | | } |
| | | |
| | | function reopenTemplateBind() { |
| | | formDialog.visible = false; |
| | | pendingTemplateBinding.value = null; |
| | | templateBindVisible.value = true; |
| | | } |
| | | |
| | | function openFormDialog(mode, row) { |
| | | if (mode === "edit" && row && !row.hasTemplateBinding) { |
| | | proxy?.$modal?.msgWarning?.("该记录为旧版数据,请重新通过模板发起申请"); |
| | | return; |
| | | } |
| | | formDialog.mode = mode; |
| | | formDialog.title = "编辑转正申请"; |
| | | Object.assign(form, createEmptyForm()); |
| | | if (mode === "edit" && row) { |
| | | Object.assign(form, { |
| | | id: row.id, |
| | | applicantName: row.applicantName, |
| | | applyDate: row.applyDate, |
| | | regularizationDate: row.regularizationDate, |
| | | probationSummary: row.probationSummary, |
| | | hasTemplateBinding: true, |
| | | templateId: row.templateId, |
| | | templateName: row.templateName, |
| | | templateSnapshot: row.templateSnapshot, |
| | | formFieldDefs: row.formFieldDefs || [], |
| | | formPayload: JSON.parse(JSON.stringify(row.formPayload || {})), |
| | | flowNodes: JSON.parse(JSON.stringify(row.flowNodes || [])), |
| | | templateAttachments: JSON.parse(JSON.stringify(row.templateAttachments || [])), |
| | | storageBlobDTOs: JSON.parse(JSON.stringify(row.storageBlobDTOs || [])), |
| | | }); |
| | | loadFlowUsers(); |
| | | } |
| | | formDialog.visible = true; |
| | | nextTick(() => formRef.value?.clearValidate?.()); |
| | | } |
| | | |
| | | function onFormClosed() { |
| | | formRef.value?.resetFields?.(); |
| | | } |
| | | |
| | | async function submitForm() { |
| | | try { |
| | | await formRef.value?.validate?.(); |
| | | } catch { |
| | | return; |
| | | } |
| | | const flowCheck = validateTemplateBinding({ flowNodes: form.flowNodes }); |
| | | if (!flowCheck.ok) { |
| | | proxy?.$modal?.msgWarning?.(flowCheck.message || "请完善审批流程"); |
| | | return; |
| | | } |
| | | form.flowNodes = flowCheck.nodes; |
| | | syncRegularFieldsFromPayload(); |
| | | const payload = { |
| | | applicantName: form.applicantName, |
| | | applyDate: form.applyDate, |
| | | regularizationDate: form.regularizationDate, |
| | | probationSummary: form.probationSummary, |
| | | hasTemplateBinding: true, |
| | | templateId: form.templateId, |
| | | templateName: form.templateName, |
| | | templateSnapshot: form.templateSnapshot, |
| | | formFieldDefs: form.formFieldDefs, |
| | | formPayload: JSON.parse(JSON.stringify(form.formPayload || {})), |
| | | flowNodes: JSON.parse(JSON.stringify(form.flowNodes || [])), |
| | | templateAttachments: JSON.parse(JSON.stringify(form.templateAttachments || [])), |
| | | storageBlobDTOs: JSON.parse(JSON.stringify(form.storageBlobDTOs || [])), |
| | | }; |
| | | if (formDialog.mode === "add") { |
| | | const id = `local_${Date.now()}`; |
| | | allRows.value.unshift({ id, ...payload, approvalResult: "pending" }); |
| | | proxy?.$modal?.msgSuccess?.("新增成功"); |
| | | } else { |
| | | const idx = allRows.value.findIndex((r) => r.id === form.id); |
| | | if (idx !== -1) { |
| | | const prev = allRows.value[idx]; |
| | | allRows.value[idx] = { |
| | | ...prev, |
| | | id: form.id, |
| | | ...payload, |
| | | approvalResult: prev.approvalResult ?? "pending", |
| | | }; |
| | | } |
| | | proxy?.$modal?.msgSuccess?.("保存成功"); |
| | | } |
| | | formDialog.visible = false; |
| | | handleQuery(); |
| | | } |
| | | |
| | | /** 从模板填报项同步列表展示字段 */ |
| | | function syncRegularFieldsFromPayload() { |
| | | const defs = form.formFieldDefs || []; |
| | | const payload = form.formPayload || {}; |
| | | for (const f of defs) { |
| | | const label = String(f.label || ""); |
| | | const val = payload[f.key]; |
| | | if (label.includes("申请人") && !label.includes("日期")) { |
| | | form.applicantName = val != null && val !== "" ? String(val) : form.applicantName; |
| | | } |
| | | if (label.includes("申请日期") && f.type === "date") { |
| | | form.applyDate = val || ""; |
| | | } |
| | | if (label.includes("转正") && (label.includes("日期") || label.includes("时间")) && f.type === "date") { |
| | | form.regularizationDate = val || ""; |
| | | } |
| | | if (label.includes("试用期") || label.includes("工作总结")) { |
| | | form.probationSummary = val != null ? String(val) : ""; |
| | | } |
| | | } |
| | | } |
| | | |
| | | onMounted(() => { |
| | | loadFlowUsers(); |
| | | await initModuleList(searchForm); |
| | | }); |
| | | </script> |
| | | |
| | |
| | | .search_title { |
| | | font-size: 14px; |
| | | color: var(--el-text-color-regular); |
| | | } |
| | | .mr6 { |
| | | margin-right: 6px; |
| | | } |
| | | .mb6 { |
| | | margin-bottom: 6px; |
| | | } |
| | | .regular-apply-form :deep(.el-row) { |
| | | margin-bottom: 0; |
| | | } |
| | | .regular-apply-form :deep(.el-form-item) { |
| | | margin-bottom: 18px; |
| | | } |
| | | .template-name { |
| | | font-weight: 600; |
| | | color: var(--el-text-color-primary); |
| | | } |
| | | .ml12 { |
| | | margin-left: 12px; |
| | | } |
| | | .regular-apply-form-dialog :deep(.el-dialog__body) { |
| | | padding-top: 12px; |
| | | } |
| | | </style> |