| | |
| | | nodeSignModeLabel, |
| | | } from "../approve-template/approveTemplateConstants.js"; |
| | | import { buildFormPayloadFromFields, parseFormConfigToData } from "../approve-template/formConfigUtils.js"; |
| | | import { isDynamicOptionSource, selectOptionSourceLabel } from "../approve-template/selectOptionSource.js"; |
| | | import { |
| | | isDynamicOptionSource, |
| | | resolveSelectDisplayLabel, |
| | | } from "../approve-template/selectOptionSource.js"; |
| | | |
| | | /** 审æ¹ç±»åï¼ä¸åç«¯åæ®µ approvalType 对é½ï¼åæå¯åæ¥ï¼ */ |
| | | export const APPROVAL_TYPE_OPTIONS = [ |
| | |
| | | { value: "procurement", label: "éè´å®¡æ¹", cellBg: "#f4f4f5", cellColor: "#909399" }, |
| | | { value: "quotation", label: "æ¥ä»·å®¡æ¹", cellBg: "#f4ecfc", cellColor: "#9b59b6" }, |
| | | { value: "shipment", label: "å货审æ¹", cellBg: "#e8faf6", cellColor: "#1abc9c" }, |
| | | { value: "enterprise_news", label: "ä¼ä¸æ°é»", cellBg: "#ecf5ff", cellColor: "#409eff" }, |
| | | ]; |
| | | |
| | | /** 审æ¹ç¶æ approvalStatus */ |
| | | export const APPROVAL_STATUS_OPTIONS = [ |
| | | { value: "pending", label: "å®¡æ ¸ä¸" }, |
| | | { value: "approved", label: "å·²éè¿" }, |
| | | { value: "rejected", label: "已驳å" }, |
| | | { value: "cancelled", label: "å·²æ¤é" }, |
| | | /** å表æ¥è¯¢ï¼å®¡æ¹ç¶æï¼ä¸å端 status æä¸¾ä¸è´ï¼ */ |
| | | export const APPROVAL_STATUS_SEARCH_OPTIONS = [ |
| | | { value: "PENDING", label: "å¾
审æ¹" }, |
| | | { value: "APPROVED", label: "å·²éè¿" }, |
| | | { value: "REJECTED", label: "已驳å" }, |
| | | ]; |
| | | |
| | | /** |
| | | * 审æ¹ç¶æå±ç¤ºï¼ä¸å端 status æä¸¾ä¸è´ï¼ |
| | | * PENDING â å¾
审æ¹/è¿è¡ä¸ APPROVED â å·²éè¿/已宿 REJECTED â 已驳å |
| | | */ |
| | | export const APPROVAL_STATUS_OPTIONS = [ |
| | | { value: "pending", api: "PENDING", label: "å¾
审æ¹" }, |
| | | { value: "approved", api: "APPROVED", label: "å·²éè¿" }, |
| | | { value: "rejected", api: "REJECTED", label: "已驳å" }, |
| | | { value: "cancelled", api: "CANCELLED", label: "å·²æ¤é" }, |
| | | ]; |
| | | |
| | | /** å端 status / é¡µé¢ approvalStatus â ç»ä¸é¡µé¢ keyï¼pending | approved | rejected | cancelledï¼ */ |
| | | export function normalizeApprovalStatusKey(v) { |
| | | const s = String(v ?? "").trim(); |
| | | if (!s) return "pending"; |
| | | const upper = s.toUpperCase(); |
| | | if (upper === "APPROVED" || upper === "APPROVE" || upper === "PASS") return "approved"; |
| | | if (upper === "REJECTED" || upper === "REJECT" || upper === "REFUSE") return "rejected"; |
| | | if (upper === "CANCELLED" || upper === "CANCEL") return "cancelled"; |
| | | if ( |
| | | upper === "PENDING" || |
| | | upper === "IN_PROGRESS" || |
| | | upper === "PROCESSING" || |
| | | upper === "RUNNING" |
| | | ) { |
| | | return "pending"; |
| | | } |
| | | const lower = s.toLowerCase(); |
| | | if (["pending", "approved", "rejected", "cancelled"].includes(lower)) return lower; |
| | | return "pending"; |
| | | } |
| | | |
| | | /** æäº¤å¼¹çªï¼æ¨¡æ¿å¡çï¼æ¥èªå端åè¡¨ï¼ */ |
| | | export function mapSubmitTemplateCard(row) { |
| | |
| | | } |
| | | |
| | | export function mapTaskStatusLabel(status) { |
| | | const s = String(status || "").toUpperCase(); |
| | | if (s === "APPROVED") return "å·²éè¿"; |
| | | if (s === "REJECTED") return "已驳å"; |
| | | if (s === "PENDING") return "å¾
审æ¹"; |
| | | if (s === "CANCELLED") return "å·²æ¤é"; |
| | | return status || "â"; |
| | | return approvalStatusLabel(status); |
| | | } |
| | | |
| | | export function mapTaskStatusTagType(status) { |
| | | const s = String(status || "").toUpperCase(); |
| | | if (s === "APPROVED") return "success"; |
| | | if (s === "REJECTED") return "danger"; |
| | | if (s === "CANCELLED") return "info"; |
| | | return "warning"; |
| | | return approvalStatusTagType(status); |
| | | } |
| | | |
| | | /** å端 tasks â é¡µé¢ flowNodesï¼æ levelNo åç»ï¼ä¾æµç¨ç¼è¾/å±ç¤ºï¼ */ |
| | |
| | | return "text"; |
| | | } |
| | | |
| | | /** ååæ®µå±ç¤ºå¼ï¼è¯¦æ
åªè¯»ï¼ */ |
| | | export function formatFieldDisplayValue(field, val) { |
| | | /** |
| | | * ååæ®µå±ç¤ºå¼ï¼è¯¦æ
åªè¯»ãåè¡¨ä¸»è¡¨ï¼ |
| | | * @param {object} [caches] 人å/é¨é¨ä¸æç¼åï¼ç¨äºè§£æã人åå表ãç±»åæ®µä¸ºå§å |
| | | */ |
| | | export function formatFieldDisplayValue(field, val, caches) { |
| | | if (val == null || val === "" || (Array.isArray(val) && !val.length)) return "â"; |
| | | if (field?.type === "select" && isDynamicOptionSource(field.optionSource)) { |
| | | return `${selectOptionSourceLabel(field.optionSource)}ï¼${String(val)}`; |
| | | const label = resolveSelectDisplayLabel(field, val, caches || {}); |
| | | if (label && label !== "â") return label; |
| | | return String(val); |
| | | } |
| | | if (field?.type === "select" && field.options?.length) { |
| | | const hit = field.options.find((o) => String(o.value) === String(val)); |
| | |
| | | |
| | | /** å端 status â é¡µé¢ approvalStatus */ |
| | | export function mapInstanceStatusFromApi(status) { |
| | | const s = String(status || "").toUpperCase(); |
| | | if (s === "APPROVED") return "approved"; |
| | | if (s === "REJECTED") return "rejected"; |
| | | if (s === "CANCELLED") return "cancelled"; |
| | | return "pending"; |
| | | return normalizeApprovalStatusKey(status); |
| | | } |
| | | |
| | | /** é¡µé¢ approvalStatus â å端 status */ |
| | | export function mapInstanceStatusToApi(approvalStatus) { |
| | | const s = String(approvalStatus || "").toLowerCase(); |
| | | if (s === "approved") return "APPROVED"; |
| | | if (s === "rejected") return "REJECTED"; |
| | | if (s === "cancelled") return "CANCELLED"; |
| | | return "PENDING"; |
| | | const key = normalizeApprovalStatusKey(approvalStatus); |
| | | const hit = APPROVAL_STATUS_OPTIONS.find((x) => x.value === key); |
| | | return hit?.api || "PENDING"; |
| | | } |
| | | |
| | | export function unwrapInstancePage(res) { |
| | |
| | | }; |
| | | } |
| | | |
| | | export function buildApprovalInstanceListParams({ page, searchForm }) { |
| | | export function buildApprovalInstanceListParams({ page, searchForm, businessType, extraParams }) { |
| | | const params = { |
| | | current: page.current, |
| | | size: page.size, |
| | | ...(extraParams && typeof extraParams === "object" ? extraParams : {}), |
| | | }; |
| | | const dto = {}; |
| | | const kw = (searchForm?.applicantKeyword || "").trim(); |
| | | if (kw) dto.applicantName = kw; |
| | | if (searchForm?.approvalType) { |
| | | const opt = APPROVAL_TYPE_OPTIONS.find((x) => x.value === searchForm.approvalType); |
| | | if (opt?.label) dto.templateName = opt.label; |
| | | const bizType = businessType ?? searchForm?.businessType; |
| | | if (bizType != null && bizType !== "") { |
| | | params.businessType = bizType; |
| | | } |
| | | if (Object.keys(dto).length) params.approvalInstanceDto = dto; |
| | | if (searchForm?.status) { |
| | | params.status = searchForm.status; |
| | | } |
| | | const range = searchForm?.createTimeRange; |
| | | if (Array.isArray(range) && range[0]) { |
| | | params.createTime = range[0]; |
| | | } |
| | | if (Array.isArray(range) && range[1]) { |
| | | params.createTimeEnd = range[1]; |
| | | } |
| | | return params; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | export function approvalStatusLabel(v) { |
| | | return APPROVAL_STATUS_OPTIONS.find((x) => x.value === v)?.label || "â"; |
| | | const key = normalizeApprovalStatusKey(v); |
| | | return APPROVAL_STATUS_OPTIONS.find((x) => x.value === key)?.label || "â"; |
| | | } |
| | | |
| | | /** ä¸å¡ç³è¯·é¡µç¶æææ¡ï¼PENDINGâè¿è¡ä¸ APPROVEDâ已宿 REJECTEDâ已驳å */ |
| | | export function businessApprovalStatusLabel(v) { |
| | | const key = normalizeApprovalStatusKey(v); |
| | | if (key === "pending") return "è¿è¡ä¸"; |
| | | if (key === "approved") return "已宿"; |
| | | if (key === "rejected") return "已驳å"; |
| | | if (key === "cancelled") return "å·²æ¤é"; |
| | | return "â"; |
| | | } |
| | | |
| | | /** |
| | | * ä¸å¡ç³è¯·é¡µæ¯å¦å
许修æ¹ï¼äºä¸ªç³è¯·é¡µï¼ |
| | | * è¿è¡ä¸(PENDING)ã已宿(APPROVED) ä¸å¯ä¿®æ¹ï¼å·²é©³åãå·²æ¤éçå¯ä¿®æ¹ |
| | | */ |
| | | export function canEditBusinessInstanceRow(row) { |
| | | const key = normalizeApprovalStatusKey( |
| | | row?.approvalStatus ?? row?.statusRaw ?? row?.status |
| | | ); |
| | | return key !== "pending" && key !== "approved"; |
| | | } |
| | | |
| | | export function businessApprovalStatusTagType(v) { |
| | | const key = normalizeApprovalStatusKey(v); |
| | | if (key === "approved") return "success"; |
| | | if (key === "rejected") return "danger"; |
| | | if (key === "cancelled") return "info"; |
| | | return "warning"; |
| | | } |
| | | |
| | | export function approvalStatusTagType(v) { |
| | | if (v === "approved") return "success"; |
| | | if (v === "rejected") return "danger"; |
| | | if (v === "cancelled") return "info"; |
| | | return "primary"; |
| | | const key = normalizeApprovalStatusKey(v); |
| | | if (key === "approved") return "success"; |
| | | if (key === "rejected") return "danger"; |
| | | if (key === "cancelled") return "info"; |
| | | return "warning"; |
| | | } |
| | | |
| | | export function unreadLabel(v) { |
| | |
| | | <div class="app-container"> |
| | | <div class="search_form mb20"> |
| | | <div class="search_fields"> |
| | | <span class="search_title">审æ¹ç±»åï¼</span> |
| | | <span class="search_title">模æ¿ç±»åï¼</span> |
| | | <el-select |
| | | v-model="searchForm.approvalType" |
| | | placeholder="è¯·éæ©å®¡æ¹ç±»å" |
| | | v-model="searchForm.businessType" |
| | | placeholder="è¯·éæ©æ¨¡æ¿ç±»å" |
| | | clearable |
| | | filterable |
| | | style="width: 200px" |
| | | > |
| | | <el-option |
| | | v-for="opt in APPROVAL_TYPE_OPTIONS" |
| | | v-for="opt in searchBusinessTypeOptions" |
| | | :key="`search-biz-type-${opt.value}`" |
| | | :label="opt.label" |
| | | :value="opt.value" |
| | | /> |
| | | </el-select> |
| | | <span class="search_title" style="margin-left: 12px">审æ¹ç¶æï¼</span> |
| | | <el-select |
| | | v-model="searchForm.status" |
| | | placeholder="è¯·éæ©å®¡æ¹ç¶æ" |
| | | clearable |
| | | style="width: 140px" |
| | | > |
| | | <el-option |
| | | v-for="opt in APPROVAL_STATUS_SEARCH_OPTIONS" |
| | | :key="opt.value" |
| | | :label="opt.label" |
| | | :value="opt.value" |
| | | /> |
| | | </el-select> |
| | | <span class="search_title" style="margin-left: 12px">ç³è¯·äººåç§°ï¼</span> |
| | | <el-input |
| | | v-model="searchForm.applicantKeyword" |
| | | style="width: 200px" |
| | | placeholder="请è¾å
¥ç³è¯·äººåç§°" |
| | | clearable |
| | | :prefix-icon="Search" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | <span class="search_title" style="margin-left: 12px">å建æ¶é´ï¼</span> |
| | | <el-date-picker |
| | | v-model="searchForm.createTimeRange" |
| | |
| | | const al = useApproveList(); |
| | | const { |
| | | Search, |
| | | APPROVAL_TYPE_OPTIONS, |
| | | APPROVAL_STATUS_SEARCH_OPTIONS, |
| | | searchBusinessTypeOptions, |
| | | loadSearchBusinessTypeOptions, |
| | | submitBusinessTypeOptions, |
| | | submitTemplateCards, |
| | | selectedBusinessTypeLabel, |
| | |
| | | |
| | | onMounted(() => { |
| | | loadFlowUsers(); |
| | | loadSearchBusinessTypeOptions(); |
| | | handleQuery(); |
| | | }); |
| | | </script> |
| | |
| | | validateTemplateBinding, |
| | | } from "../approve-shared/approvalTemplateBindingUtils.js"; |
| | | import { |
| | | APPROVAL_STATUS_SEARCH_OPTIONS, |
| | | APPROVAL_TYPE_OPTIONS, |
| | | approvalStatusLabel, |
| | | approvalStatusTagType, |
| | |
| | | const userStore = useUserStore(); |
| | | |
| | | const tableData = ref([]); |
| | | const searchBusinessTypeOptions = ref([]); |
| | | const submitBusinessTypeOptions = ref([]); |
| | | const allSubmitTemplates = ref([]); |
| | | const selectedBusinessType = ref(""); |
| | |
| | | }); |
| | | |
| | | const searchForm = reactive({ |
| | | approvalType: "", |
| | | applicantKeyword: "", |
| | | businessType: "", |
| | | status: "", |
| | | createTimeRange: [], |
| | | }); |
| | | |
| | |
| | | const tableColumn = ref([ |
| | | { label: "ç³è¯·äººç¼å·", prop: "applicantNo", width: 110 }, |
| | | { label: "ç³è¯·äººåç§°", prop: "applicantName", minWidth: 100 }, |
| | | { label: "ä¸å¡ç±»å", prop: "businessName", minWidth: 120 }, |
| | | { label: "模æ¿ç±»å", prop: "businessName", minWidth: 120 }, |
| | | { |
| | | label: "审æ¹ç±»å", |
| | | prop: "approvalType", |
| | |
| | | } |
| | | |
| | | function resetSearch() { |
| | | searchForm.approvalType = ""; |
| | | searchForm.applicantKeyword = ""; |
| | | searchForm.businessType = ""; |
| | | searchForm.status = ""; |
| | | searchForm.createTimeRange = []; |
| | | handleQuery(); |
| | | } |
| | | |
| | | async function loadSearchBusinessTypeOptions() { |
| | | try { |
| | | searchBusinessTypeOptions.value = await fetchBusinessTypeOptions(); |
| | | } catch { |
| | | searchBusinessTypeOptions.value = []; |
| | | } |
| | | } |
| | | |
| | | function pagination({ page: p, limit }) { |
| | |
| | | return { |
| | | Search, |
| | | APPROVAL_TYPE_OPTIONS, |
| | | APPROVAL_STATUS_SEARCH_OPTIONS, |
| | | searchBusinessTypeOptions, |
| | | loadSearchBusinessTypeOptions, |
| | | approvalTypeLabel, |
| | | approvalStatusLabel, |
| | | approvalStatusTagType, |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | import { computed } from "vue"; |
| | | import { |
| | | businessApprovalStatusLabel, |
| | | businessApprovalStatusTagType, |
| | | formatFieldDisplayValue, |
| | | resolveInstanceFormFields, |
| | | } from "../approve-list/approveListConstants.js"; |
| | | |
| | | /** å表/详æ
ä¸åæ¾ä¸ºç¬ç«åçå¡«æ¥é¡¹ key */ |
| | | const DEFAULT_EXCLUDE_KEYS = new Set(["summary"]); |
| | | |
| | | /** |
| | | * ä»è¡æ°æ® formConfig è§£æå段å®ä¹ä¸å¡«æ¥å¼ï¼å¹¶éºå¹³å°è¡ä¸ä¾ä¸»è¡¨ prop ç»å®ï¼å±ç¤ºç¨æ ¼å¼åå¼ï¼ |
| | | */ |
| | | export function enrichInstanceRowFromFormConfig(row, caches) { |
| | | const { fields, formPayload, templateSnapshot } = resolveInstanceFormFields(row); |
| | | const formDisplay = {}; |
| | | const displayRow = { |
| | | ...row, |
| | | formFieldDefs: fields, |
| | | formPayload, |
| | | templateSnapshot: row.templateSnapshot || templateSnapshot, |
| | | formDisplay, |
| | | }; |
| | | |
| | | for (const f of fields) { |
| | | if (!f?.key || DEFAULT_EXCLUDE_KEYS.has(f.key)) continue; |
| | | const val = formPayload[f.key]; |
| | | let text = formatFieldDisplayValue(f, val, caches); |
| | | if ( |
| | | text === String(val) && |
| | | row?.applicantName && |
| | | (f.label === "ç³è¯·äºº" || f.key === "applicant" || f.key === "applicantName") |
| | | ) { |
| | | const idMatch = |
| | | String(val) === String(row.applicantId) || |
| | | String(val) === String(row.applicantNo); |
| | | if (idMatch) text = row.applicantName; |
| | | } |
| | | formDisplay[f.key] = text; |
| | | displayRow[f.key] = text; |
| | | } |
| | | |
| | | return displayRow; |
| | | } |
| | | |
| | | /** |
| | | * ä»å表é¦è¡ formConfig çæä¸»è¡¨å¨æåï¼label åèªæ¨¡æ¿å段 labelï¼ |
| | | */ |
| | | export function getFormConfigFieldColumns(firstRow, { excludeKeys = DEFAULT_EXCLUDE_KEYS } = {}) { |
| | | const fields = (firstRow?.formFieldDefs || []).filter( |
| | | (f) => f?.key && !excludeKeys.has(f.key) |
| | | ); |
| | | return fields.map((f) => ({ |
| | | label: f.label || f.key, |
| | | prop: f.key, |
| | | minWidth: f.type === "textarea" ? 200 : f.type === "datetimerange" ? 160 : 120, |
| | | showOverflowTooltip: true, |
| | | })); |
| | | } |
| | | |
| | | /** |
| | | * ä¸å¡ç³è¯·ä¸»è¡¨åï¼åºå®å + formConfig 卿å + 审æ¹ç¶æ + æä½ |
| | | */ |
| | | export function buildInstanceTableColumns(tableDataRef, buildTableActions, options = {}) { |
| | | const { |
| | | excludeKeys = DEFAULT_EXCLUDE_KEYS, |
| | | beforeFormColumns = [], |
| | | extraColumns = [], |
| | | afterFormColumns = [], |
| | | actionWidth = 260, |
| | | } = options; |
| | | |
| | | return computed(() => { |
| | | const formCols = getFormConfigFieldColumns(tableDataRef.value?.[0], { excludeKeys }); |
| | | return [ |
| | | ...beforeFormColumns, |
| | | ...formCols, |
| | | ...extraColumns, |
| | | ...afterFormColumns, |
| | | { label: "å建æ¶é´", prop: "createTime", width: 170 }, |
| | | { |
| | | label: "审æ¹ç¶æ", |
| | | prop: "approvalStatus", |
| | | width: 110, |
| | | dataType: "tag", |
| | | formatData: (v) => businessApprovalStatusLabel(v), |
| | | formatType: (v) => businessApprovalStatusTagType(v), |
| | | }, |
| | | { |
| | | dataType: "action", |
| | | label: "æä½", |
| | | align: "center", |
| | | fixed: "right", |
| | | width: actionWidth, |
| | | operation: buildTableActions(), |
| | | }, |
| | | ]; |
| | | }); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | import { enrichInstanceRowFromFormConfig } from "./approvalInstanceFormConfigTable.js"; |
| | | |
| | | /** @deprecated ç»ä¸ä½¿ç¨ enrichInstanceRowFromFormConfig */ |
| | | export const enrichLeaveListRow = enrichInstanceRowFromFormConfig; |
| | | export const enrichOvertimeListRow = enrichInstanceRowFromFormConfig; |
| | | export const enrichRegularListRow = enrichInstanceRowFromFormConfig; |
| | | export const enrichTransferListRow = enrichInstanceRowFromFormConfig; |
| | | export const enrichWorkHandoverListRow = enrichInstanceRowFromFormConfig; |
| | | |
| | | export { enrichInstanceRowFromFormConfig }; |
| | |
| | | import { matchBusinessTypeValue } from "../approve-list/approveListConstants.js"; |
| | | |
| | | /** |
| | | * åä¸å¡æ¨¡åä¸å®¡æ¹æ¨¡æ¿ç±»åçæ å°ï¼é
ç½®åå
¥å£ï¼ |
| | | * |
| | | * åä¸å¡æ¨¡åä¸å®¡æ¹æ¨¡æ¿ç±»åçæ å°ï¼é
ç½®åå
¥å£ï¼ * |
| | | * ä½¿ç¨æ¹å¼ï¼ |
| | | * 1. å¨ä¸å¡é¡µå¼å
¥ ApprovalTemplateBindDialogï¼ä¼ å
¥ moduleKey |
| | | * 2. æå¨è¡¨åå
åµ ApprovalTemplateFormSection + useApprovalTemplateBinding({ moduleKey }) |
| | |
| | | OVERTIME: "overtime", |
| | | TRAVEL_REIMBURSE: "travel_reimburse", |
| | | COST_REIMBURSE: "cost_reimburse", |
| | | ENTERPRISE_NEWS: "enterprise_news", |
| | | }; |
| | | |
| | | /** @type {Record<string, import('./approvalModuleRegistry.js').ApprovalModuleConfig>} */ |
| | |
| | | approvalType: "cost_reimburse", |
| | | typeLabels: ["è´¹ç¨", "è´¹ç¨æ¥é"], |
| | | }, |
| | | [APPROVAL_MODULE_KEYS.ENTERPRISE_NEWS]: { |
| | | label: "ä¼ä¸æ°é»", |
| | | approvalType: "enterprise_news", |
| | | typeLabels: ["ä¼ä¸æ°é»", "æ°é»", "æ°é»åå¸"], |
| | | }, |
| | | }; |
| | | |
| | | /** |
| | |
| | | return APPROVAL_MODULE_REGISTRY[moduleKey] || null; |
| | | } |
| | | |
| | | /** å表æ¥è¯¢é»è®¤ businessTypeï¼ä¸å®¡æ¹å表 listPage 约å®ä¸è´ï¼ */ |
| | | export function getModuleListBusinessType(moduleKey) { |
| | | const cfg = getApprovalModuleConfig(moduleKey); |
| | | if (!cfg) return ""; |
| | | if (cfg.businessType != null && cfg.businessType !== "") return cfg.businessType; |
| | | return cfg.approvalType || ""; |
| | | } |
| | | |
| | | export function listApprovalModuleEntries() { |
| | | return Object.entries(APPROVAL_MODULE_REGISTRY).map(([moduleKey, cfg]) => ({ |
| | | moduleKey, |
| | |
| | | })); |
| | | } |
| | | |
| | | /** ä» TypeEnums é项ä¸è§£ææ¬æ¨¡åç businessType */ |
| | | /** ä» TypeEnums é项ä¸è§£ææ¬æ¨¡åç businessTypeï¼ä¸å®¡æ¹åè¡¨ä¸æä¸è´ï¼ */ |
| | | export function resolveModuleBusinessType(moduleKey, typeOptions = []) { |
| | | const cfg = getApprovalModuleConfig(moduleKey); |
| | | if (!cfg) return null; |
| | | if (cfg.businessType != null && cfg.businessType !== "") return cfg.businessType; |
| | | |
| | | const labels = [cfg.label, ...(cfg.typeLabels || [])].filter(Boolean); |
| | | const hit = (typeOptions || []).find((opt) => { |
| | | const hitByLabel = (typeOptions || []).find((opt) => { |
| | | const optLabel = String(opt?.label || "").trim(); |
| | | if (!optLabel) return false; |
| | | return labels.some( |
| | | (l) => optLabel === l || optLabel.includes(l) || l.includes(optLabel) |
| | | ); |
| | | }); |
| | | if (hit?.value != null && hit.value !== "") return hit.value; |
| | | if (hitByLabel?.value != null && hitByLabel.value !== "") return hitByLabel.value; |
| | | |
| | | if (cfg.approvalType) { |
| | | const hitByValue = (typeOptions || []).find( |
| | | (opt) => |
| | | matchBusinessTypeValue(opt?.value, cfg.approvalType) || |
| | | matchBusinessTypeValue(opt?.code, cfg.approvalType) |
| | | ); |
| | | if (hitByValue?.value != null && hitByValue.value !== "") return hitByValue.value; |
| | | } |
| | | |
| | | return cfg.approvalType || null; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <!-- ä¸å®¡æ¹å表详æ
å¼¹çªä¸è´ --> |
| | | <template> |
| | | <el-dialog |
| | | v-model="visible" |
| | | :title="title" |
| | | width="920px" |
| | | append-to-body |
| | | destroy-on-close |
| | | class="approve-detail-dialog" |
| | | @closed="emit('closed')" |
| | | > |
| | | <div class="approve-detail-body"> |
| | | <ApproveDetailPanel :row="row" /> |
| | | <div class="detail-block"> |
| | | <div class="detail-block-title"> |
| | | å®¡æ¹æµç¨ï¼{{ row?.tasks?.length || row?.flowNodes?.length || 0 }} é¡¹ï¼ |
| | | </div> |
| | | <InstanceFlowDisplay :tasks="row?.tasks" :nodes="row?.flowNodes" /> |
| | | </div> |
| | | <div class="detail-block"> |
| | | <div class="detail-block-title">审æ¹è®°å½</div> |
| | | <el-timeline v-if="row?.approvalRecords?.length" class="approve-record-timeline"> |
| | | <el-timeline-item |
| | | v-for="(rec, i) in row.approvalRecords" |
| | | :key="rec.id ?? i" |
| | | :type="rec.result === 'approved' ? 'success' : rec.result === 'rejected' ? 'danger' : 'primary'" |
| | | :timestamp="formatRecordTime(rec.time)" |
| | | placement="top" |
| | | > |
| | | <div class="record-item"> |
| | | <span class="record-operator">{{ rec.operatorName || "â" }}</span> |
| | | <el-tag |
| | | size="small" |
| | | :type="rec.result === 'approved' ? 'success' : rec.result === 'rejected' ? 'danger' : 'info'" |
| | | effect="plain" |
| | | > |
| | | {{ approvalActionLabel(rec.result) }} |
| | | </el-tag> |
| | | <p class="record-opinion">{{ rec.opinion || "æ æè§" }}</p> |
| | | </div> |
| | | </el-timeline-item> |
| | | </el-timeline> |
| | | <el-empty v-else description="ææ å®¡æ¹è®°å½" :image-size="48" /> |
| | | </div> |
| | | </div> |
| | | <template #footer> |
| | | <el-button v-if="canEditRow(row)" @click="emit('edit', row)">ä¿® æ¹</el-button> |
| | | <el-button @click="visible = false">å
³ é</el-button> |
| | | </template> |
| | | </el-dialog> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { computed } from "vue"; |
| | | import { canEditBusinessInstanceRow } from "../../approve-list/approveListConstants.js"; |
| | | import { formatDisplayTime } from "../../approve-template/approveTemplateConstants.js"; |
| | | import ApproveDetailPanel from "../../approve-list/components/ApproveDetailPanel.vue"; |
| | | import InstanceFlowDisplay from "../../approve-list/components/InstanceFlowDisplay.vue"; |
| | | |
| | | function canEditRow(row) { |
| | | return canEditBusinessInstanceRow(row); |
| | | } |
| | | |
| | | const props = defineProps({ |
| | | modelValue: { type: Boolean, default: false }, |
| | | row: { type: Object, default: () => ({}) }, |
| | | title: { type: String, default: "审æ¹è¯¦æ
" }, |
| | | }); |
| | | |
| | | const emit = defineEmits(["update:modelValue", "edit", "closed"]); |
| | | |
| | | const visible = computed({ |
| | | get: () => props.modelValue, |
| | | set: (v) => emit("update:modelValue", v), |
| | | }); |
| | | |
| | | function approvalActionLabel(result) { |
| | | if (result === "approved") return "éè¿"; |
| | | if (result === "rejected") return "驳å"; |
| | | return "å¾
å¤ç"; |
| | | } |
| | | |
| | | function formatRecordTime(time) { |
| | | return formatDisplayTime(time) || "â"; |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | .approve-detail-dialog :deep(.el-dialog__body) { |
| | | padding-top: 16px; |
| | | max-height: 70vh; |
| | | overflow-y: auto; |
| | | } |
| | | .approve-detail-body .detail-block { |
| | | margin-top: 20px; |
| | | } |
| | | .detail-block-title { |
| | | font-size: 14px; |
| | | font-weight: 600; |
| | | color: var(--el-text-color-primary); |
| | | margin: 0 0 12px; |
| | | padding-left: 10px; |
| | | border-left: 3px solid var(--el-color-primary); |
| | | line-height: 1.4; |
| | | } |
| | | .approve-record-timeline { |
| | | padding-left: 4px; |
| | | } |
| | | .record-item { |
| | | padding: 4px 0 2px; |
| | | } |
| | | .record-operator { |
| | | font-weight: 600; |
| | | margin-right: 8px; |
| | | color: var(--el-text-color-primary); |
| | | } |
| | | .record-opinion { |
| | | margin: 8px 0 0; |
| | | font-size: 13px; |
| | | color: var(--el-text-color-regular); |
| | | line-height: 1.5; |
| | | } |
| | | </style> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <!-- ä¸å®¡æ¹å表æäº¤/ä¿®æ¹å¼¹çªï¼ç¬¬ä¸æ¥ï¼ä¸è´ --> |
| | | <template> |
| | | <el-dialog |
| | | v-model="visible" |
| | | :title="title" |
| | | width="720px" |
| | | append-to-body |
| | | destroy-on-close |
| | | class="approve-submit-dialog" |
| | | @closed="emit('closed')" |
| | | > |
| | | <el-form ref="innerFormRef" :model="form" :rules="rules" label-width="120px"> |
| | | <el-form-item v-if="isEdit" label="审æ¹ç±»å"> |
| | | <span class="approve-type-cell" :style="approvalTypeStyle(activeTemplate?.approvalType)"> |
| | | {{ activeTemplate?.label || form.templateName || "â" }} |
| | | </span> |
| | | </el-form-item> |
| | | <slot name="before" :form="form" :fields="fields" /> |
| | | <ApprovalTemplateFormSection |
| | | :active-template="activeTemplate" |
| | | :fields="fields" |
| | | :form-payload="form.formPayload" |
| | | v-model:flow-nodes="form.flowNodes" |
| | | v-model:attachments="form.storageBlobDTOs" |
| | | :template-attachments="form.templateAttachments" |
| | | :user-options="userOptions" |
| | | :show-template-name="!isEdit" |
| | | :allow-change-template="false" |
| | | :flow-attachments-only="flowAttachmentsOnly" |
| | | :flow-only="flowOnly" |
| | | /> |
| | | <slot name="after" :form="form" :fields="fields" /> |
| | | </el-form> |
| | | <template #footer> |
| | | <el-button type="primary" :loading="saving" @click="handleSubmitClick"> |
| | | {{ isEdit ? "ä¿ å" : "æ 交" }} |
| | | </el-button> |
| | | <el-button @click="visible = false">å æ¶</el-button> |
| | | </template> |
| | | </el-dialog> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { computed, ref, watch } from "vue"; |
| | | import { ElMessage } from "element-plus"; |
| | | import { approvalTypeStyle } from "../../approve-list/approveListConstants.js"; |
| | | import ApprovalTemplateFormSection from "./ApprovalTemplateFormSection.vue"; |
| | | |
| | | const innerFormRef = ref(null); |
| | | |
| | | const props = defineProps({ |
| | | modelValue: { type: Boolean, default: false }, |
| | | title: { type: String, default: "" }, |
| | | form: { type: Object, required: true }, |
| | | rules: { type: Object, default: () => ({}) }, |
| | | fields: { type: Array, default: () => [] }, |
| | | activeTemplate: { type: Object, default: null }, |
| | | userOptions: { type: Array, default: () => [] }, |
| | | isEdit: { type: Boolean, default: false }, |
| | | saving: { type: Boolean, default: false }, |
| | | formRef: { type: Object, default: null }, |
| | | /** å¡«æ¥é¡¹ç± before ææ§½åç¬æ¸²ææ¶è®¾ä¸º true */ |
| | | flowAttachmentsOnly: { type: Boolean, default: false }, |
| | | flowOnly: { type: Boolean, default: false }, |
| | | }); |
| | | |
| | | const emit = defineEmits(["update:modelValue", "submit", "closed"]); |
| | | |
| | | const visible = computed({ |
| | | get: () => props.modelValue, |
| | | set: (v) => emit("update:modelValue", v), |
| | | }); |
| | | |
| | | watch( |
| | | innerFormRef, |
| | | (el) => { |
| | | if (props.formRef) props.formRef.value = el; |
| | | }, |
| | | { flush: "post" } |
| | | ); |
| | | |
| | | watch(visible, (v) => { |
| | | if (!v && props.formRef) props.formRef.value = null; |
| | | }); |
| | | |
| | | async function handleSubmitClick() { |
| | | if (!innerFormRef.value) { |
| | | ElMessage.warning("è¡¨åæªå°±ç»ªï¼è¯·ç¨ååè¯"); |
| | | return; |
| | | } |
| | | try { |
| | | await innerFormRef.value.validate(); |
| | | } catch { |
| | | ElMessage.warning("请å®å表åå¿
填项ååä¿å"); |
| | | return; |
| | | } |
| | | emit("submit"); |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | .approve-type-cell { |
| | | display: inline-block; |
| | | padding: 2px 10px; |
| | | border-radius: 4px; |
| | | font-size: 13px; |
| | | line-height: 1.5; |
| | | } |
| | | .approve-submit-dialog :deep(.el-dialog__body) { |
| | | padding-top: 12px; |
| | | } |
| | | </style> |
| | |
| | | <!-- 模æ¿ç»å®è¡¨ååºï¼å¡«æ¥é¡¹ + å®¡æ¹æµç¨ + éä»¶ï¼é¡»æå¨å¤å± el-form ä¸ï¼ --> |
| | | <template> |
| | | <template v-if="activeTemplate"> |
| | | <el-form-item v-if="showTemplateName && !hideTemplateName && !flowAttachmentsOnly" label="å®¡æ¹æ¨¡æ¿"> |
| | | <el-form-item |
| | | v-if="showTemplateName && !hideTemplateName && !flowAttachmentsOnly && !flowOnly" |
| | | label="å®¡æ¹æ¨¡æ¿" |
| | | > |
| | | <span class="template-name">{{ activeTemplate.label }}</span> |
| | | <el-button v-if="allowChangeTemplate" type="primary" link class="ml12" @click="emit('change-template')"> |
| | | æ´æ¢æ¨¡æ¿ |
| | | </el-button> |
| | | </el-form-item> |
| | | |
| | | <FormPayloadFields v-if="!hideFormFields && !flowAttachmentsOnly" :fields="fields" :form-payload="formPayload" /> |
| | | <FormPayloadFields |
| | | v-if="!hideFormFields && !flowAttachmentsOnly && !flowOnly" |
| | | :fields="fields" |
| | | :form-payload="formPayload" |
| | | /> |
| | | |
| | | <el-form-item label="å®¡æ¹æµç¨" required> |
| | | <TemplateFlowEditor v-model="flowNodesModel" :user-options="userOptions" /> |
| | | <p class="section-tip">æµç¨ä¸å®¡æ¹äººç±æ¨¡æ¿é¢ç½®ï¼å¯æéå¾®è°èç¹å®¡æ¹äººã</p> |
| | | </el-form-item> |
| | | |
| | | <el-form-item v-if="templateAttachments.length" label="模æ¿åè"> |
| | | <el-form-item v-if="!flowOnly && templateAttachments.length" label="模æ¿åè"> |
| | | <el-tag |
| | | v-for="(f, i) in templateAttachments" |
| | | :key="`tpl-${i}`" |
| | |
| | | <p class="section-tip">以ä¸ä¸ºæ¨¡æ¿é带æä»¶ï¼ä»
ä¾åèï¼æäº¤é件请å¨ä¸æ¹ä¸ä¼ ã</p> |
| | | </el-form-item> |
| | | |
| | | <el-form-item label="éä»¶"> |
| | | <el-form-item v-if="!flowOnly" label="éä»¶"> |
| | | <FileUpload |
| | | v-model:file-list="attachmentsModel" |
| | | :limit="uploadLimit" |
| | |
| | | hideTemplateName: { type: Boolean, default: false }, |
| | | /** 为 true æ¶ä»
å±ç¤ºå®¡æ¹æµç¨ä¸éä»¶ï¼å¡«æ¥é¡¹ç±ç¶çº§åç¬æ¸²æï¼ */ |
| | | flowAttachmentsOnly: { type: Boolean, default: false }, |
| | | /** 为 true æ¶ä»
å±ç¤ºå®¡æ¹æµç¨ï¼ä¸å±ç¤ºæ¨¡æ¿å¡«æ¥é¡¹ãéä»¶çï¼ */ |
| | | flowOnly: { type: Boolean, default: false }, |
| | | uploadLimit: { type: Number, default: 10 }, |
| | | }); |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | import { |
| | | deleteApprovalInstance, |
| | | listApprovalInstancePage, |
| | | saveApprovalInstance, |
| | | updateApprovalInstance, |
| | | } from "@/api/officeProcessAutomation/approvalInstance.js"; |
| | | import useUserStore from "@/store/modules/user"; |
| | | import { ElMessage, ElMessageBox } from "element-plus"; |
| | | import { computed, reactive, ref } from "vue"; |
| | | import { |
| | | applyBindingToForm, |
| | | buildFormPayloadRules, |
| | | validateTemplateBinding, |
| | | } from "./approvalTemplateBindingUtils.js"; |
| | | import { |
| | | buildApprovalInstanceListParams, |
| | | buildEditFormFromInstanceRow, |
| | | buildInstanceDto, |
| | | canEditBusinessInstanceRow, |
| | | createEmptySubmitForm, |
| | | mapInstanceFromApi, |
| | | resolveInstanceFormFields, |
| | | unwrapInstancePage, |
| | | } from "../approve-list/approveListConstants.js"; |
| | | import { fetchBusinessTypeOptions } from "../approve-template/approveTemplateConstants.js"; |
| | | import { |
| | | collectOptionSourcesFromFields, |
| | | fetchSelectOptionCaches, |
| | | } from "../approve-template/selectOptionSource.js"; |
| | | import { enrichInstanceRowFromFormConfig } from "./approvalInstanceFormConfigTable.js"; |
| | | import { |
| | | getApprovalModuleConfig, |
| | | getModuleListBusinessType, |
| | | resolveModuleBusinessType, |
| | | } from "./approvalModuleRegistry.js"; |
| | | |
| | | /** |
| | | * ä¸å¡ç³è¯·é¡µå
±ç¨ï¼å®¡æ¹å®ä¾å表æ¥è¯¢ãæ°å¢/ä¿®æ¹ä¿åã详æ
/ç¼è¾å¼¹çªï¼ä¸å®¡æ¹å表ä¸è´ï¼ |
| | | * |
| | | * @param {object} options |
| | | * @param {string} options.moduleKey approvalModuleRegistry ä¸ç key |
| | | * @param {(row: object) => object} [options.enrichListRow] å表è¡å¢å¼ºï¼ä» formPayload è§£æå±ç¤ºåæ®µï¼ |
| | | * @param {(base: object) => object} [options.buildExtraListParams] è¿½å æ¥è¯¢åæ° |
| | | * @param {() => void} [options.beforeSave] ä¿ååé©åï¼å¦åæ¥ä¸å¡åæ®µå° formPayloadï¼ |
| | | * @param {import('vue').ComputedRef|object} [options.extraFormRules] é¢å¤è¡¨åæ ¡éª |
| | | */ |
| | | export function useApprovalInstanceModule(options = {}) { |
| | | const { |
| | | moduleKey, |
| | | enrichListRow, |
| | | buildExtraListParams, |
| | | beforeSave, |
| | | extraFormRules, |
| | | } = options; |
| | | |
| | | const userStore = useUserStore(); |
| | | const moduleConfig = computed(() => getApprovalModuleConfig(moduleKey)); |
| | | const businessTypeOptions = ref([]); |
| | | |
| | | /** ä¸å®¡æ¹å表ä¸è´ï¼ä¼å
ç¨ TypeEnums ç valueï¼å¹é
ä¸å°ååé approvalType */ |
| | | const defaultListBusinessType = computed(() => { |
| | | const resolved = resolveModuleBusinessType(moduleKey, businessTypeOptions.value); |
| | | if (resolved != null && resolved !== "") return resolved; |
| | | return getModuleListBusinessType(moduleKey); |
| | | }); |
| | | |
| | | async function loadBusinessTypeOptions() { |
| | | if (businessTypeOptions.value.length) return; |
| | | try { |
| | | businessTypeOptions.value = await fetchBusinessTypeOptions(); |
| | | } catch { |
| | | businessTypeOptions.value = []; |
| | | } |
| | | } |
| | | |
| | | const tableData = ref([]); |
| | | const tableLoading = ref(false); |
| | | const page = reactive({ current: 1, size: 10, total: 0 }); |
| | | |
| | | const detailDialog = reactive({ visible: false }); |
| | | const detailRow = ref({}); |
| | | |
| | | const submitDialog = reactive({ visible: false, mode: "add" }); |
| | | const submitEditRow = ref(null); |
| | | const submitForm = reactive(createEmptySubmitForm("")); |
| | | const submitFormRef = ref(); |
| | | const submitSaving = ref(false); |
| | | |
| | | const templateBindVisible = ref(false); |
| | | const pendingTemplateBinding = ref(null); |
| | | /** æè¿ä¸æ¬¡å表æ¥è¯¢æ¡ä»¶ï¼ä¿ååå·æ°åè¡¨æ¶æ²¿ç¨ï¼ */ |
| | | let lastListSearchForm = null; |
| | | |
| | | const isSubmitEdit = computed(() => submitDialog.mode === "edit"); |
| | | const activeTemplate = computed(() => submitForm.templateSnapshot || null); |
| | | const submitFormFields = computed(() => { |
| | | const tplFields = activeTemplate.value?.fields; |
| | | if (tplFields?.length) return tplFields; |
| | | return submitForm.formFieldDefs || []; |
| | | }); |
| | | |
| | | const submitFormRules = computed(() => ({ |
| | | ...buildFormPayloadRules(submitFormFields.value), |
| | | ...(extraFormRules?.value ?? extraFormRules ?? {}), |
| | | })); |
| | | |
| | | const submitDialogTitle = computed(() => { |
| | | const label = moduleConfig.value?.label || "ç³è¯·"; |
| | | if (submitDialog.mode === "edit") { |
| | | return `ä¿®æ¹${activeTemplate.value?.label || submitForm.templateName || label}`; |
| | | } |
| | | return `æ°å¢${label}`; |
| | | }); |
| | | |
| | | function mapListRow(row, caches) { |
| | | const mapped = mapInstanceFromApi(row); |
| | | const fromFormConfig = enrichInstanceRowFromFormConfig(mapped, caches); |
| | | return enrichListRow ? enrichListRow(fromFormConfig) : fromFormConfig; |
| | | } |
| | | |
| | | async function fetchList(searchForm = {}) { |
| | | await loadBusinessTypeOptions(); |
| | | tableLoading.value = true; |
| | | try { |
| | | let extraParams = {}; |
| | | if (buildExtraListParams) { |
| | | extraParams = buildExtraListParams(searchForm) || {}; |
| | | } |
| | | const res = await listApprovalInstancePage( |
| | | buildApprovalInstanceListParams({ |
| | | page, |
| | | searchForm, |
| | | businessType: defaultListBusinessType.value, |
| | | extraParams, |
| | | }) |
| | | ); |
| | | const { records, total } = unwrapInstancePage(res); |
| | | const mapped = records.map(mapInstanceFromApi); |
| | | const allFields = []; |
| | | for (const row of mapped) { |
| | | const { fields } = resolveInstanceFormFields(row); |
| | | allFields.push(...fields); |
| | | } |
| | | const caches = await fetchSelectOptionCaches( |
| | | collectOptionSourcesFromFields(allFields) |
| | | ); |
| | | tableData.value = mapped.map((row) => mapListRow(row, caches)); |
| | | page.total = total; |
| | | } catch { |
| | | tableData.value = []; |
| | | page.total = 0; |
| | | ElMessage.error(`${moduleConfig.value?.label || "ç³è¯·"}å表å 载失败`); |
| | | } finally { |
| | | tableLoading.value = false; |
| | | } |
| | | } |
| | | |
| | | function handleQuery(searchForm) { |
| | | lastListSearchForm = searchForm; |
| | | page.current = 1; |
| | | return fetchList(searchForm); |
| | | } |
| | | |
| | | /** è¿å
¥é¡µé¢ï¼å
æ TypeEnums è§£æ businessTypeï¼åæ¥å表 */ |
| | | async function initModuleList(searchForm) { |
| | | await loadBusinessTypeOptions(); |
| | | return handleQuery(searchForm); |
| | | } |
| | | |
| | | function pagination({ page: p, limit }, searchForm) { |
| | | page.current = p; |
| | | page.size = limit; |
| | | return fetchList(searchForm); |
| | | } |
| | | |
| | | function openDetail(row) { |
| | | detailRow.value = { ...row }; |
| | | detailDialog.visible = true; |
| | | } |
| | | |
| | | function openEdit(row) { |
| | | if (!canEditBusinessInstanceRow(row)) { |
| | | ElMessage.warning("è¿è¡ä¸æå·²å®æç审æ¹ä¸å¯ä¿®æ¹"); |
| | | return; |
| | | } |
| | | if (!row?.id) { |
| | | ElMessage.warning("æ æ³ä¿®æ¹ï¼ç¼ºå°å®¡æ¹å®ä¾ ID"); |
| | | return; |
| | | } |
| | | submitDialog.mode = "edit"; |
| | | submitEditRow.value = { ...row }; |
| | | Object.assign(submitForm, buildEditFormFromInstanceRow(row)); |
| | | submitDialog.visible = true; |
| | | } |
| | | |
| | | function openEditFromDetail() { |
| | | const row = detailRow.value; |
| | | detailDialog.visible = false; |
| | | openEdit(row); |
| | | } |
| | | |
| | | function resetSubmitForm() { |
| | | Object.assign(submitForm, createEmptySubmitForm("")); |
| | | submitEditRow.value = null; |
| | | } |
| | | |
| | | function openAddWithTemplate() { |
| | | submitDialog.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; |
| | | openAddFromBinding(binding); |
| | | } |
| | | |
| | | function openAddFromBinding(binding) { |
| | | resetSubmitForm(); |
| | | applyBindingToForm(submitForm, binding); |
| | | submitDialog.mode = "add"; |
| | | submitEditRow.value = null; |
| | | submitDialog.visible = true; |
| | | } |
| | | |
| | | function closeSubmitDialog() { |
| | | submitDialog.visible = false; |
| | | } |
| | | |
| | | async function submitInstanceForm(options = {}) { |
| | | const { skipValidate = false } = options; |
| | | if (!skipValidate) { |
| | | if (!submitFormRef.value?.validate) { |
| | | ElMessage.warning("è¡¨åæªå°±ç»ªï¼è¯·å
³éå¼¹çªåéè¯"); |
| | | return false; |
| | | } |
| | | try { |
| | | await submitFormRef.value.validate(); |
| | | } catch { |
| | | ElMessage.warning("请å®å表åå¿
填项ååä¿å"); |
| | | return false; |
| | | } |
| | | } |
| | | if (!activeTemplate.value) { |
| | | ElMessage.warning("æªå è½½å®¡æ¹æ¨¡æ¿ï¼æ æ³ä¿å"); |
| | | return false; |
| | | } |
| | | const bindingCheck = validateTemplateBinding({ flowNodes: submitForm.flowNodes }); |
| | | if (!bindingCheck.ok) { |
| | | ElMessage.warning(bindingCheck.message); |
| | | return false; |
| | | } |
| | | if (!submitForm.templateId) { |
| | | ElMessage.warning("ç¼ºå°æ¨¡æ¿ IDï¼æ æ³æäº¤"); |
| | | return false; |
| | | } |
| | | if (beforeSave) { |
| | | try { |
| | | await beforeSave(submitForm, { isEdit: isSubmitEdit.value, editRow: submitEditRow.value }); |
| | | } catch { |
| | | return false; |
| | | } |
| | | } |
| | | if (submitSaving.value) return false; |
| | | submitSaving.value = true; |
| | | try { |
| | | const dto = buildInstanceDto({ |
| | | submitForm, |
| | | activeTemplate: activeTemplate.value, |
| | | userStore, |
| | | flowNodes: bindingCheck.nodes, |
| | | existingRow: isSubmitEdit.value ? submitEditRow.value : null, |
| | | }); |
| | | if (isSubmitEdit.value) { |
| | | await updateApprovalInstance(dto); |
| | | } else { |
| | | await saveApprovalInstance(dto); |
| | | } |
| | | submitDialog.visible = false; |
| | | if (!isSubmitEdit.value) page.current = 1; |
| | | await fetchList(lastListSearchForm ?? {}); |
| | | if (detailDialog.visible && detailRow.value?.id === submitForm.instanceId) { |
| | | const hit = tableData.value.find((r) => r.id === submitForm.instanceId); |
| | | if (hit) detailRow.value = { ...hit }; |
| | | else detailDialog.visible = false; |
| | | } |
| | | return true; |
| | | } catch { |
| | | ElMessage.error(isSubmitEdit.value ? "ä¿å失败" : "æäº¤å¤±è´¥"); |
| | | return false; |
| | | } finally { |
| | | submitSaving.value = false; |
| | | } |
| | | } |
| | | |
| | | async function removeInstance(row) { |
| | | if (row?.id == null || row.id === "") { |
| | | ElMessage.warning("æ æ³å é¤ï¼ç¼ºå°å®¡æ¹å®ä¾ ID"); |
| | | return; |
| | | } |
| | | const title = row.title || row.templateName || row.instanceNo || "该审æ¹"; |
| | | try { |
| | | await ElMessageBox.confirm( |
| | | `ç¡®å®è¦å é¤å®¡æ¹ã${title}ãåï¼å é¤åä¸å¯æ¢å¤ã`, |
| | | "å é¤ç¡®è®¤", |
| | | { |
| | | type: "warning", |
| | | confirmButtonText: "ç¡®å®å é¤", |
| | | cancelButtonText: "åæ¶", |
| | | distinguishCancelAndClose: true, |
| | | autofocus: false, |
| | | } |
| | | ); |
| | | } catch { |
| | | return; |
| | | } |
| | | try { |
| | | await deleteApprovalInstance([row.id]); |
| | | ElMessage.success("å 餿å"); |
| | | if (detailDialog.visible && detailRow.value?.id === row.id) { |
| | | detailDialog.visible = false; |
| | | } |
| | | if (submitDialog.visible && submitEditRow.value?.id === row.id) { |
| | | submitDialog.visible = false; |
| | | } |
| | | await fetchList(lastListSearchForm ?? {}); |
| | | } catch { |
| | | /* éè¯¯ç±æ¦æªå¨æç¤º */ |
| | | } |
| | | } |
| | | |
| | | /** æå»ºæ åæä½åï¼è¯¦æ
ãä¿®æ¹ãå é¤ï¼ä¸å®¡æ¹å表ä¸è´ï¼ */ |
| | | function buildTableActions(extraOperations = []) { |
| | | return [ |
| | | { name: "详æ
", type: "text", clickFun: (row) => openDetail(row) }, |
| | | { |
| | | name: "ä¿®æ¹", |
| | | type: "text", |
| | | disabled: (row) => !canEditBusinessInstanceRow(row), |
| | | clickFun: (row) => openEdit(row), |
| | | }, |
| | | { |
| | | name: "å é¤", |
| | | type: "danger", |
| | | clickFun: (row) => removeInstance(row), |
| | | }, |
| | | ...extraOperations, |
| | | ]; |
| | | } |
| | | |
| | | return { |
| | | moduleConfig, |
| | | defaultListBusinessType, |
| | | tableData, |
| | | tableLoading, |
| | | page, |
| | | detailDialog, |
| | | detailRow, |
| | | submitDialog, |
| | | submitEditRow, |
| | | submitForm, |
| | | submitFormRef, |
| | | submitSaving, |
| | | isSubmitEdit, |
| | | activeTemplate, |
| | | submitFormFields, |
| | | submitFormRules, |
| | | submitDialogTitle, |
| | | templateBindVisible, |
| | | pendingTemplateBinding, |
| | | fetchList, |
| | | handleQuery, |
| | | initModuleList, |
| | | pagination, |
| | | openDetail, |
| | | openEdit, |
| | | openEditFromDetail, |
| | | openAddWithTemplate, |
| | | onTemplateBound, |
| | | onTemplateBindClosed, |
| | | openAddFromBinding, |
| | | closeSubmitDialog, |
| | | resetSubmitForm, |
| | | submitInstanceForm, |
| | | removeInstance, |
| | | buildTableActions, |
| | | loadBusinessTypeOptions, |
| | | canEditBusinessInstanceRow, |
| | | }; |
| | | } |
| | |
| | | placeholder="å§åæç¼å·" |
| | | clearable |
| | | :prefix-icon="Search" |
| | | @keyup.enter="handleQuery" |
| | | @keyup.enter="onSearch" |
| | | /> |
| | | <span class="search_title" style="margin-left: 12px">请åç±»åï¼</span> |
| | | <el-select v-model="searchForm.leaveType" placeholder="å
¨é¨" clearable style="width: 180px"> |
| | | <el-option v-for="opt in LEAVE_TYPE_OPTIONS" :key="opt.value" :label="opt.label" :value="opt.value" /> |
| | | </el-select> |
| | | <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="leave-apply-form-dialog" |
| | | @closed="onFormClosed" |
| | | <ApprovalInstanceSubmitDialog |
| | | v-model="submitDialog.visible" |
| | | :title="submitDialogTitle" |
| | | :form="submitForm" |
| | | :rules="submitFormRules" |
| | | :fields="submitFormFields" |
| | | :active-template="activeTemplate" |
| | | :user-options="flowUserOptions" |
| | | :is-edit="isSubmitEdit" |
| | | :saving="submitSaving" |
| | | :form-ref="submitFormRef" |
| | | flow-attachments-only |
| | | @submit="onSubmit" |
| | | > |
| | | <el-form ref="formRef" :model="form" :rules="formRules" label-width="140px" class="leave-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="templateDisplayFields" :form-payload="form.formPayload" /> |
| | | <template #before="{ form, fields }"> |
| | | <FormPayloadFields :fields="displayTemplateFields(fields)" :form-payload="form.formPayload" /> |
| | | <el-row :gutter="24"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="åæä½é¢" prop="leaveBalanceDays"> |
| | |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="è¯·åæ¶é¿"> |
| | | <el-input :model-value="leaveDurationDisplay" readonly placeholder="æ ¹æ®æ¨¡æ¿ä¸è¯·åæ¶é´èªå¨è®¡ç®"> |
| | | <el-input :model-value="leaveDurationDisplay(form)" readonly placeholder="æ ¹æ®æ¨¡æ¿ä¸è¯·åæ¶é´èªå¨è®¡ç®"> |
| | | <template #append>天</template> |
| | | </el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <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" |
| | | :user-options="flowUserOptions" |
| | | flow-attachments-only |
| | | hide-template-name |
| | | :allow-change-template="false" |
| | | /> |
| | | </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> |
| | | </ApprovalInstanceSubmitDialog> |
| | | |
| | | <ApprovalTemplateBindDialog |
| | | v-model:visible="templateBindVisible" |
| | |
| | | @closed="onTemplateBindClosed" |
| | | /> |
| | | |
| | | <!-- 详æ
--> |
| | | <el-dialog v-model="detailDialog.visible" title="请åç³è¯·è¯¦æ
" width="720px" append-to-body> |
| | | <el-descriptions :column="1" border> |
| | | <el-descriptions-item label="ç³è¯·äººç¼å·">{{ detailRow.applicantNo || "â" }}</el-descriptions-item> |
| | | <el-descriptions-item label="ç³è¯·äºº">{{ detailRow.applicantName }}</el-descriptions-item> |
| | | <el-descriptions-item label="请åç±»å">{{ leaveTypeLabel(detailRow.leaveType) }}</el-descriptions-item> |
| | | <el-descriptions-item label="åæä½é¢">{{ formatBalance(detailRow.leaveBalanceDays) }}</el-descriptions-item> |
| | | <el-descriptions-item label="请åå¼å§æ¶é´">{{ detailRow.leaveStartTime || "â" }}</el-descriptions-item> |
| | | <el-descriptions-item label="请åç»ææ¶é´">{{ detailRow.leaveEndTime || "â" }}</el-descriptions-item> |
| | | <el-descriptions-item label="è¯·åæ¶é¿">{{ formatDuration(detailRow.leaveDurationDays) }}</el-descriptions-item> |
| | | <el-descriptions-item label="请åäºç±">{{ detailRow.leaveReason }}</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="å建æ¶é´">{{ detailRow.createTime || "â" }}</el-descriptions-item> |
| | | <el-descriptions-item label="éä»¶"> |
| | | <template v-if="rowAttachmentList(detailRow).length"> |
| | | <el-tag v-for="(f, i) in rowAttachmentList(detailRow)" :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="rowAttachmentList(filesDialog.row).length" :data="rowAttachmentList(filesDialog.row)" 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> |
| | | |
| | |
| | | import { Search } from "@element-plus/icons-vue"; |
| | | import dayjs from "dayjs"; |
| | | import { userListNoPageByTenantId } from "@/api/system/user.js"; |
| | | import { computed, getCurrentInstance, nextTick, onMounted, reactive, ref, watch } from "vue"; |
| | | import ApprovalTemplateBindDialog from "../../ApproveManage/approve-shared/components/ApprovalTemplateBindDialog.vue"; |
| | | import ApprovalTemplateFormSection from "../../ApproveManage/approve-shared/components/ApprovalTemplateFormSection.vue"; |
| | | import { ElMessage } from "element-plus"; |
| | | import { computed, onMounted, reactive, ref, watch } from "vue"; |
| | | import FormPayloadFields from "../../ApproveManage/approve-list/components/FormPayloadFields.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 { buildInstanceTableColumns } from "../../ApproveManage/approve-shared/approvalInstanceFormConfigTable.js"; |
| | | import { APPROVAL_MODULE_KEYS } from "../../ApproveManage/approve-shared/approvalModuleRegistry.js"; |
| | | import { |
| | | applyBindingToForm, |
| | | attachmentDisplayName, |
| | | buildFormPayloadRules, |
| | | validateTemplateBinding, |
| | | } from "../../ApproveManage/approve-shared/approvalTemplateBindingUtils.js"; |
| | | import { useApprovalInstanceModule } from "../../ApproveManage/approve-shared/useApprovalInstanceModule.js"; |
| | | import { useFlowUserOptions } from "../../ApproveManage/approve-shared/useFlowUserOptions.js"; |
| | | import { SELECT_OPTION_SOURCE } from "../../ApproveManage/approve-template/selectOptionSource.js"; |
| | | |
| | | /** 请åç±»åï¼value ä¸å端对é½å ä½ï¼ */ |
| | | const LEAVE_TYPE_OPTIONS = [ |
| | | { label: "å¹´å", value: "annual" }, |
| | | { label: "ç
å", value: "sick" }, |
| | |
| | | { label: "è°ä¼", value: "compensatory" }, |
| | | ]; |
| | | |
| | | function leaveTypeLabel(v) { |
| | | const hit = LEAVE_TYPE_OPTIONS.find((x) => x.value === v); |
| | | return hit?.label || "â"; |
| | | } |
| | | |
| | | /** ä¸å端约å®å段ï¼å ä½ï¼ */ |
| | | const createEmptyForm = () => ({ |
| | | id: undefined, |
| | | applicantId: "", |
| | | applicantNo: "", |
| | | applicantName: "", |
| | | leaveType: "", |
| | | leaveBalanceDays: undefined, |
| | | leaveStartTime: "", |
| | | leaveEndTime: "", |
| | | leaveDurationDays: null, |
| | | leaveReason: "", |
| | | hasTemplateBinding: false, |
| | | templateId: "", |
| | | templateName: "", |
| | | templateSnapshot: null, |
| | | formFieldDefs: [], |
| | | formPayload: {}, |
| | | flowNodes: [], |
| | | templateAttachments: [], |
| | | storageBlobDTOs: [], |
| | | }); |
| | | |
| | | const { proxy } = getCurrentInstance(); |
| | | |
| | | function unwrapArray(payload) { |
| | | if (Array.isArray(payload)) return payload; |
| | | if (payload && Array.isArray(payload.data)) return payload.data; |
| | | if (payload && Array.isArray(payload.rows)) return payload.rows; |
| | | return []; |
| | | } |
| | | |
| | | function isActiveUser(u) { |
| | | if (u.delFlag === "2" || u.delFlag === 2) return false; |
| | | if (u.status == null) return true; |
| | | return String(u.status) === "0"; |
| | | } |
| | | |
| | | function userById(id) { |
| | | if (id == null || id === "") return undefined; |
| | | return allUsersCache.value.find((u) => String(u.userId ?? u.id) === String(id)); |
| | | } |
| | | |
| | | function applicantNoFromUser(u) { |
| | | if (!u) return ""; |
| | | return ( |
| | | u.userName ?? |
| | | u.userCode ?? |
| | | u.jobNumber ?? |
| | | u.workNo ?? |
| | | (u.userId != null ? String(u.userId) : "") |
| | | ); |
| | | } |
| | | |
| | | /** åæä½é¢ï¼å¯¹æ¥èå¤ API åä¸å±ç¤ºåæ°æ®ï¼ */ |
| | | function mockLeaveBalance() { |
| | | return undefined; |
| | | } |
| | | |
| | | function isLeaveBalanceField(field) { |
| | | const label = String(field?.label || ""); |
| | | return label.includes("åæä½é¢") || field?.key === "leaveBalanceDays"; |
| | |
| | | function isLeaveDurationField(field) { |
| | | const label = String(field?.label || ""); |
| | | return label.includes("è¯·åæ¶é¿") || field?.key === "leaveDurationDays"; |
| | | } |
| | | |
| | | function displayTemplateFields(fields = []) { |
| | | return (fields || []).filter((f) => !isLeaveBalanceField(f) && !isLeaveDurationField(f)); |
| | | } |
| | | |
| | | function findLeaveTimeTemplateField(fields = []) { |
| | |
| | | ); |
| | | } |
| | | |
| | | /** 仿¨¡æ¿å¡«æ¥é¡¹è§£æè¯·åèµ·æ¢æ¶é´ */ |
| | | function resolveLeaveTimeRange(payload, leaveTimeField) { |
| | | if (!leaveTimeField?.key) return { start: "", end: "" }; |
| | | const val = payload?.[leaveTimeField.key]; |
| | |
| | | return { start: val[0] || "", end: val[1] || "" }; |
| | | } |
| | | |
| | | /** æèµ·æ¢æ¶é´è®¡ç®è¯·å天æ°ï¼å«æ¶åç§ï¼ç»æä¿ç两ä½å°æ°ï¼ */ |
| | | function computeLeaveDays(startStr, endStr) { |
| | | if (!startStr || !endStr) return null; |
| | | const t0 = dayjs(startStr); |
| | |
| | | return Math.round(days * 100) / 100; |
| | | } |
| | | |
| | | function formatDuration(v) { |
| | | if (v == null || v === "") return "â"; |
| | | return `${v} 天`; |
| | | function leaveDurationDisplay(form) { |
| | | const leaveTimeField = findLeaveTimeTemplateField(form.formFieldDefs); |
| | | const { start, end } = resolveLeaveTimeRange(form.formPayload, leaveTimeField); |
| | | const d = computeLeaveDays(start, end); |
| | | return d == null ? "" : String(d); |
| | | } |
| | | |
| | | function formatBalance(v) { |
| | | if (v == null || v === "") return "â"; |
| | | return `${v} 天`; |
| | | } |
| | | const searchForm = reactive({ |
| | | applicantKeyword: "", |
| | | leaveType: "", |
| | | }); |
| | | |
| | | function mapStorageBlobsToAttachmentList(blobs) { |
| | | return (blobs || []).map((f) => ({ |
| | | name: attachmentDisplayName(f), |
| | | url: f.url || f.downloadURL || f.previewURL || f.previewUrl, |
| | | })); |
| | | } |
| | | |
| | | function rowAttachmentList(row) { |
| | | if (!row) return []; |
| | | if (row.attachmentList?.length) return row.attachmentList; |
| | | return mapStorageBlobsToAttachmentList(row.storageBlobDTOs); |
| | | } |
| | | |
| | | function approvalModeLabel(mode) { |
| | | if (mode === "countersign") return "ä¼ç¾"; |
| | | if (mode === "or_sign") return "æç¾"; |
| | | return "ä¸ç¾"; |
| | | } |
| | | |
| | | function approvalResultLabel(v) { |
| | | if (v === "approved") return "å·²éè¿"; |
| | | if (v === "rejected") return "已驳å"; |
| | | if (v === "cancelled") return "å·²æ¤é"; |
| | | return "å¾
审æ¹"; |
| | | } |
| | | |
| | | function syncApplicantFromUser(uid) { |
| | | const u = userById(uid); |
| | | if (u) { |
| | | form.applicantId = uid != null && uid !== "" ? uid : ""; |
| | | form.applicantName = u.nickName || u.userName || ""; |
| | | form.applicantNo = applicantNoFromUser(u); |
| | | form.leaveBalanceDays = mockLeaveBalance(u); |
| | | } else { |
| | | form.applicantId = ""; |
| | | form.applicantName = ""; |
| | | form.applicantNo = ""; |
| | | if (uid == null || uid === "") { |
| | | form.leaveBalanceDays = undefined; |
| | | } |
| | | function validateLeaveBeforeSave() { |
| | | const leaveTimeField = findLeaveTimeTemplateField(submitForm.formFieldDefs); |
| | | const { start, end } = resolveLeaveTimeRange(submitForm.formPayload, leaveTimeField); |
| | | if (computeLeaveDays(start, end) == null) { |
| | | ElMessage.warning("è¯·æ£æ¥æ¨¡æ¿ä¸çè¯·åæ¶é´ï¼ç»ææ¶é´é¡»æäºå¼å§æ¶é´"); |
| | | throw new Error("invalid leave time"); |
| | | } |
| | | } |
| | | |
| | | /** ç³»ç»ç¨æ·ç¼å */ |
| | | const mod = useApprovalInstanceModule({ |
| | | moduleKey: APPROVAL_MODULE_KEYS.LEAVE, |
| | | beforeSave: validateLeaveBeforeSave, |
| | | extraFormRules: { |
| | | leaveBalanceDays: [{ required: true, message: "请填ååæä½é¢", trigger: "blur" }], |
| | | }, |
| | | }); |
| | | |
| | | const { |
| | | tableData, |
| | | tableLoading, |
| | | page, |
| | | detailDialog, |
| | | detailRow, |
| | | submitDialog, |
| | | submitEditRow, |
| | | submitForm, |
| | | submitFormRef, |
| | | submitSaving, |
| | | isSubmitEdit, |
| | | activeTemplate, |
| | | submitFormFields, |
| | | submitFormRules, |
| | | submitDialogTitle, |
| | | templateBindVisible, |
| | | handleQuery, |
| | | initModuleList, |
| | | pagination, |
| | | openAddWithTemplate, |
| | | onTemplateBound, |
| | | onTemplateBindClosed, |
| | | openEditFromDetail, |
| | | submitInstanceForm, |
| | | buildTableActions, |
| | | } = mod; |
| | | |
| | | const { flowUserOptions, loadFlowUsers } = useFlowUserOptions(); |
| | | const allUsersCache = ref([]); |
| | | |
| | | const applicantTemplateField = computed(() => |
| | | findApplicantTemplateField(submitForm.formFieldDefs) |
| | | ); |
| | | |
| | | function unwrapArray(payload) { |
| | | if (Array.isArray(payload)) return payload; |
| | | if (payload && Array.isArray(payload.data)) return payload.data; |
| | | return []; |
| | | } |
| | | |
| | | async function loadUserPool() { |
| | | try { |
| | |
| | | } |
| | | } |
| | | |
| | | const allRows = ref([]); |
| | | |
| | | const searchForm = reactive({ |
| | | applicantKeyword: "", |
| | | leaveType: "", |
| | | }); |
| | | |
| | | const tableLoading = ref(false); |
| | | const page = reactive({ |
| | | current: 1, |
| | | size: 10, |
| | | total: 0, |
| | | }); |
| | | |
| | | const filteredList = computed(() => { |
| | | let list = [...allRows.value]; |
| | | const kw = (searchForm.applicantKeyword || "").trim().toLowerCase(); |
| | | if (kw) { |
| | | list = list.filter((r) => { |
| | | const name = (r.applicantName || "").toLowerCase(); |
| | | const no = (r.applicantNo || "").toLowerCase(); |
| | | return name.includes(kw) || no.includes(kw); |
| | | }); |
| | | } |
| | | if (searchForm.leaveType) { |
| | | list = list.filter((r) => r.leaveType === searchForm.leaveType); |
| | | } |
| | | return list.sort((a, b) => (String(a.createTime) < String(b.createTime) ? 1 : -1)); |
| | | }); |
| | | |
| | | 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; |
| | | () => submitDialog.visible, |
| | | (v) => { |
| | | if (!v) return; |
| | | if (submitForm.leaveBalanceDays == null && isSubmitEdit.value) { |
| | | submitForm.leaveBalanceDays = |
| | | submitEditRow.value?.formPayload?.leaveBalanceDays ?? |
| | | submitEditRow.value?.leaveBalanceDays; |
| | | } |
| | | }, |
| | | { immediate: true } |
| | | if (submitForm.leaveBalanceDays == null && !isSubmitEdit.value) { |
| | | submitForm.leaveBalanceDays = undefined; |
| | | } |
| | | } |
| | | ); |
| | | |
| | | 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: "applicantNo", width: 120 }, |
| | | { label: "ç³è¯·äºº", prop: "applicantName", minWidth: 100 }, |
| | | { |
| | | label: "请åç±»å", |
| | | prop: "leaveType", |
| | | width: 100, |
| | | formatData: (v) => leaveTypeLabel(v), |
| | | }, |
| | | { |
| | | label: "è¯·åæ¶é¿", |
| | | prop: "leaveDurationDays", |
| | | width: 120, |
| | | formatData: (v) => (v == null || v === "" ? "â" : `${v} 天`), |
| | | }, |
| | | { label: "请åäºç±", prop: "leaveReason", minWidth: 180 }, |
| | | { label: "å建æ¶é´", prop: "createTime", width: 170 }, |
| | | { |
| | | 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: 220, |
| | | 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 leaveTimeTemplateField = computed(() => findLeaveTimeTemplateField(form.formFieldDefs)); |
| | | const applicantTemplateField = computed(() => findApplicantTemplateField(form.formFieldDefs)); |
| | | |
| | | const templateDisplayFields = computed(() => |
| | | (form.formFieldDefs || []).filter((f) => !isLeaveBalanceField(f) && !isLeaveDurationField(f)) |
| | | ); |
| | | |
| | | const leaveDurationDisplay = computed(() => { |
| | | const { start, end } = resolveLeaveTimeRange(form.formPayload, leaveTimeTemplateField.value); |
| | | const d = computeLeaveDays(start, end); |
| | | return d == null ? "" : String(d); |
| | | }); |
| | | |
| | | const formRules = computed(() => ({ |
| | | ...buildFormPayloadRules(templateDisplayFields.value), |
| | | leaveBalanceDays: [ |
| | | { |
| | | required: true, |
| | | message: "请填ååæä½é¢", |
| | | trigger: "blur", |
| | | }, |
| | | ], |
| | | })); |
| | | |
| | | watch( |
| | | () => { |
| | | const key = applicantTemplateField.value?.key; |
| | | return key ? form.formPayload[key] : undefined; |
| | | return key ? submitForm.formPayload[key] : undefined; |
| | | }, |
| | | async (uid) => { |
| | | if (!applicantTemplateField.value) return; |
| | | if (!allUsersCache.value.length) { |
| | | await loadUserPool(); |
| | | } |
| | | syncApplicantFromUser(uid); |
| | | if (!applicantTemplateField.value || !uid) return; |
| | | if (!allUsersCache.value.length) await loadUserPool(); |
| | | } |
| | | ); |
| | | |
| | | watch( |
| | | () => { |
| | | const key = leaveTimeTemplateField.value?.key; |
| | | return key ? form.formPayload[key] : undefined; |
| | | }, |
| | | () => { |
| | | const { start, end } = resolveLeaveTimeRange(form.formPayload, leaveTimeTemplateField.value); |
| | | form.leaveStartTime = start; |
| | | form.leaveEndTime = end; |
| | | form.leaveDurationDays = computeLeaveDays(start, end); |
| | | }, |
| | | { deep: true } |
| | | ); |
| | | 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.applicantKeyword = ""; |
| | | searchForm.leaveType = ""; |
| | | 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; |
| | | } |
| | | |
| | | async function onTemplateBindClosed() { |
| | | const binding = pendingTemplateBinding.value; |
| | | if (!binding) return; |
| | | pendingTemplateBinding.value = null; |
| | | await openFormWithBinding(binding); |
| | | } |
| | | |
| | | async function openFormWithBinding(binding) { |
| | | Object.assign(form, createEmptyForm()); |
| | | applyBindingToForm(form, binding); |
| | | form.hasTemplateBinding = true; |
| | | formDialog.mode = "add"; |
| | | formDialog.title = "æ°å¢è¯·åç³è¯·"; |
| | | await Promise.all([loadUserPool(), loadFlowUsers()]); |
| | | const applicantKey = applicantTemplateField.value?.key; |
| | | if (applicantKey && form.formPayload[applicantKey]) { |
| | | syncApplicantFromUser(form.formPayload[applicantKey]); |
| | | } |
| | | const { start, end } = resolveLeaveTimeRange(form.formPayload, leaveTimeTemplateField.value); |
| | | form.leaveStartTime = start; |
| | | form.leaveEndTime = end; |
| | | form.leaveDurationDays = computeLeaveDays(start, end); |
| | | formDialog.visible = true; |
| | | nextTick(() => formRef.value?.clearValidate?.()); |
| | | } |
| | | |
| | | function reopenTemplateBind() { |
| | | formDialog.visible = false; |
| | | pendingTemplateBinding.value = null; |
| | | templateBindVisible.value = true; |
| | | } |
| | | |
| | | async 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, |
| | | applicantId: row.applicantId, |
| | | applicantNo: row.applicantNo, |
| | | applicantName: row.applicantName, |
| | | leaveType: row.leaveType, |
| | | leaveBalanceDays: row.leaveBalanceDays, |
| | | leaveStartTime: row.leaveStartTime, |
| | | leaveEndTime: row.leaveEndTime, |
| | | leaveDurationDays: row.leaveDurationDays, |
| | | leaveReason: row.leaveReason, |
| | | 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 || [])), |
| | | }); |
| | | await loadUserPool(); |
| | | const applicantKey = applicantTemplateField.value?.key; |
| | | if (applicantKey) { |
| | | syncApplicantFromUser(form.formPayload[applicantKey]); |
| | | } |
| | | onMounted(async () => { |
| | | loadFlowUsers(); |
| | | } |
| | | formDialog.visible = true; |
| | | nextTick(() => formRef.value?.clearValidate?.()); |
| | | } |
| | | |
| | | function onFormClosed() { |
| | | formRef.value?.resetFields?.(); |
| | | } |
| | | |
| | | /** 仿¨¡æ¿å¡«æ¥é¡¹åæ¥å表å±ç¤ºå段 */ |
| | | function syncLeaveFieldsFromPayload() { |
| | | const defs = form.formFieldDefs || []; |
| | | const payload = form.formPayload || {}; |
| | | const leaveTimeField = findLeaveTimeTemplateField(defs); |
| | | |
| | | for (const f of defs) { |
| | | const label = String(f.label || ""); |
| | | const val = payload[f.key]; |
| | | |
| | | if (label.includes("ç³è¯·äºº") && !label.includes("æ¥æ") && !label.includes("æ¶é´")) { |
| | | if (val != null && val !== "") { |
| | | form.applicantId = val; |
| | | const u = userById(val); |
| | | if (u) { |
| | | form.applicantName = u.nickName || u.userName || ""; |
| | | form.applicantNo = applicantNoFromUser(u); |
| | | } |
| | | } |
| | | } |
| | | if ((label.includes("请åç±»å") || f.key === "leaveType") && f.type === "select") { |
| | | form.leaveType = val != null && val !== "" ? val : ""; |
| | | } |
| | | if (label.includes("äºç±") || f.key === "summary" || label.includes("请åäºç±")) { |
| | | form.leaveReason = val != null ? String(val) : ""; |
| | | } |
| | | } |
| | | |
| | | const { start, end } = resolveLeaveTimeRange(payload, leaveTimeField); |
| | | form.leaveStartTime = start; |
| | | form.leaveEndTime = end; |
| | | form.leaveDurationDays = computeLeaveDays(start, end); |
| | | } |
| | | |
| | | 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; |
| | | |
| | | const applicantKey = applicantTemplateField.value?.key; |
| | | if (applicantKey) { |
| | | syncApplicantFromUser(form.formPayload[applicantKey]); |
| | | } |
| | | syncLeaveFieldsFromPayload(); |
| | | |
| | | if (form.leaveDurationDays == null) { |
| | | proxy?.$modal?.msgWarning?.("è¯·æ£æ¥æ¨¡æ¿ä¸çè¯·åæ¶é´ï¼ç»ææ¶é´é¡»æäºå¼å§æ¶é´"); |
| | | return; |
| | | } |
| | | |
| | | const attachmentList = mapStorageBlobsToAttachmentList(form.storageBlobDTOs); |
| | | const payload = { |
| | | applicantId: form.applicantId, |
| | | applicantNo: form.applicantNo, |
| | | applicantName: form.applicantName, |
| | | leaveType: form.leaveType, |
| | | leaveBalanceDays: form.leaveBalanceDays, |
| | | leaveStartTime: form.leaveStartTime, |
| | | leaveEndTime: form.leaveEndTime, |
| | | leaveDurationDays: form.leaveDurationDays, |
| | | leaveReason: form.leaveReason, |
| | | 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 || [])), |
| | | attachmentList, |
| | | }; |
| | | if (formDialog.mode === "add") { |
| | | const id = `local_${Date.now()}`; |
| | | allRows.value.unshift({ |
| | | id, |
| | | ...payload, |
| | | approvalResult: "pending", |
| | | createTime: dayjs().format("YYYY-MM-DD HH:mm:ss"), |
| | | }); |
| | | 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", |
| | | createTime: prev.createTime ?? dayjs().format("YYYY-MM-DD HH:mm:ss"), |
| | | }; |
| | | } |
| | | proxy?.$modal?.msgSuccess?.("ä¿åæå"); |
| | | } |
| | | formDialog.visible = false; |
| | | handleQuery(); |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | .leave-apply-form :deep(.el-row) { |
| | | margin-bottom: 0; |
| | | } |
| | | .leave-apply-form :deep(.el-form-item) { |
| | | margin-bottom: 18px; |
| | | } |
| | | .template-name { |
| | | font-weight: 600; |
| | | color: var(--el-text-color-primary); |
| | | } |
| | | .ml12 { |
| | | margin-left: 12px; |
| | | } |
| | | .leave-apply-form-dialog :deep(.el-dialog__body) { |
| | | padding-top: 12px; |
| | | } |
| | | </style> |
| | |
| | | placeholder="å§åæç¼å·" |
| | | clearable |
| | | :prefix-icon="Search" |
| | | @keyup.enter="handleQuery" |
| | | @keyup.enter="onSearch" |
| | | /> |
| | | <span class="search_title" style="margin-left: 12px">å çç±»åï¼</span> |
| | | <el-select v-model="searchForm.overtimeType" placeholder="å
¨é¨" clearable style="width: 180px"> |
| | | <el-option v-for="opt in OVERTIME_TYPE_OPTIONS" :key="opt.value" :label="opt.label" :value="opt.value" /> |
| | | </el-select> |
| | | <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 class="search_actions"> |
| | | <el-button type="success" plain @click="handleImportClick">导å
¥</el-button> |
| | | <el-button type="warning" plain @click="handleExport">导åº</el-button> |
| | | <el-button type="primary" @click="openAddWithTemplate">æ°å¢å çç³è¯·</el-button> |
| | | </div> |
| | | </div> |
| | | <input ref="importInputRef" type="file" accept="application/json,.json" class="sr-only-input" @change="onImportFile" /> |
| | | |
| | | <div class="table_list"> |
| | | <PIMTable |
| | |
| | | :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="overtime-apply-form-dialog" |
| | | @closed="onFormClosed" |
| | | <ApprovalInstanceSubmitDialog |
| | | v-model="submitDialog.visible" |
| | | :title="submitDialogTitle" |
| | | :form="submitForm" |
| | | :rules="submitFormRules" |
| | | :fields="submitFormFields" |
| | | :active-template="activeTemplate" |
| | | :user-options="flowUserOptions" |
| | | :is-edit="isSubmitEdit" |
| | | :saving="submitSaving" |
| | | :form-ref="submitFormRef" |
| | | flow-attachments-only |
| | | @submit="onSubmit" |
| | | > |
| | | <el-form ref="formRef" :model="form" :rules="formRules" label-width="140px" class="overtime-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="templateDisplayFields" :form-payload="form.formPayload" /> |
| | | <template #before="{ form, fields }"> |
| | | <FormPayloadFields :fields="displayTemplateFields(fields)" :form-payload="form.formPayload" /> |
| | | <el-row :gutter="24"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="å çæ¶é¿"> |
| | | <el-input :model-value="overtimeHoursDisplay" readonly placeholder="æ ¹æ®æ¨¡æ¿ä¸å çæ¶é´èªå¨è®¡ç®"> |
| | | <el-input :model-value="overtimeHoursDisplay(form)" readonly placeholder="æ ¹æ®æ¨¡æ¿ä¸å çæ¶é´èªå¨è®¡ç®"> |
| | | <template #append>å°æ¶</template> |
| | | </el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <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" |
| | | :user-options="flowUserOptions" |
| | | flow-attachments-only |
| | | hide-template-name |
| | | :allow-change-template="false" |
| | | /> |
| | | </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> |
| | | </ApprovalInstanceSubmitDialog> |
| | | |
| | | <ApprovalTemplateBindDialog |
| | | v-model:visible="templateBindVisible" |
| | |
| | | @closed="onTemplateBindClosed" |
| | | /> |
| | | |
| | | <!-- 详æ
--> |
| | | <el-dialog v-model="detailDialog.visible" title="å çç³è¯·è¯¦æ
" width="720px" append-to-body> |
| | | <el-descriptions :column="1" border> |
| | | <el-descriptions-item label="ç³è¯·äººç¼å·">{{ detailRow.applicantNo || "â" }}</el-descriptions-item> |
| | | <el-descriptions-item label="ç³è¯·äºº">{{ detailRow.applicantName }}</el-descriptions-item> |
| | | <el-descriptions-item label="å çç±»å">{{ overtimeTypeLabel(detailRow.overtimeType) }}</el-descriptions-item> |
| | | <el-descriptions-item label="å çæ¥æ">{{ detailRow.overtimeDate || "â" }}</el-descriptions-item> |
| | | <el-descriptions-item label="å çå¼å§æ¥æ">{{ detailRow.overtimeStartTime || "â" }}</el-descriptions-item> |
| | | <el-descriptions-item label="å çç»ææ¥æ">{{ detailRow.overtimeEndTime || "â" }}</el-descriptions-item> |
| | | <el-descriptions-item label="å çæ¶é¿">{{ formatHours(detailRow.overtimeHours) }}</el-descriptions-item> |
| | | <el-descriptions-item label="å çäºç±">{{ detailRow.overtimeReason }}</el-descriptions-item> |
| | | <el-descriptions-item label="å®¡æ¹æµç¨"> |
| | | <template v-if="detailFlowSteps(detailRow).length"> |
| | | <div class="detail-flow-chain"> |
| | | <template v-for="(step, i) in detailFlowSteps(detailRow)" :key="i"> |
| | | <span class="detail-flow-step">{{ step }}</span> |
| | | <span v-if="i < detailFlowSteps(detailRow).length - 1" class="detail-flow-sep">â</span> |
| | | </template> |
| | | </div> |
| | | </template> |
| | | <span v-else>â</span> |
| | | </el-descriptions-item> |
| | | <el-descriptions-item label="审æ¹ç»æ">{{ approvalResultLabel(detailRow.approvalResult) }}</el-descriptions-item> |
| | | <el-descriptions-item label="å建æ¶é´">{{ detailRow.createTime || "â" }}</el-descriptions-item> |
| | | <el-descriptions-item label="éä»¶"> |
| | | <template v-if="rowAttachmentList(detailRow).length"> |
| | | <el-tag v-for="(f, i) in rowAttachmentList(detailRow)" :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="rowAttachmentList(filesDialog.row).length" :data="rowAttachmentList(filesDialog.row)" 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 dayjs from "dayjs"; |
| | | import { userListNoPageByTenantId } from "@/api/system/user.js"; |
| | | import { computed, getCurrentInstance, nextTick, onMounted, reactive, ref, watch } from "vue"; |
| | | import ApprovalTemplateBindDialog from "../../ApproveManage/approve-shared/components/ApprovalTemplateBindDialog.vue"; |
| | | import ApprovalTemplateFormSection from "../../ApproveManage/approve-shared/components/ApprovalTemplateFormSection.vue"; |
| | | import { ElMessage } from "element-plus"; |
| | | import { getCurrentInstance, onMounted, reactive, ref } from "vue"; |
| | | import FormPayloadFields from "../../ApproveManage/approve-list/components/FormPayloadFields.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 { buildInstanceTableColumns } from "../../ApproveManage/approve-shared/approvalInstanceFormConfigTable.js"; |
| | | import { APPROVAL_MODULE_KEYS } from "../../ApproveManage/approve-shared/approvalModuleRegistry.js"; |
| | | import { |
| | | applyBindingToForm, |
| | | attachmentDisplayName, |
| | | buildFormPayloadRules, |
| | | validateTemplateBinding, |
| | | } from "../../ApproveManage/approve-shared/approvalTemplateBindingUtils.js"; |
| | | import { useApprovalInstanceModule } from "../../ApproveManage/approve-shared/useApprovalInstanceModule.js"; |
| | | import { useFlowUserOptions } from "../../ApproveManage/approve-shared/useFlowUserOptions.js"; |
| | | import { SELECT_OPTION_SOURCE } from "../../ApproveManage/approve-template/selectOptionSource.js"; |
| | | |
| | | /** å çç±»åï¼value ä¸å端对é½å ä½ï¼ */ |
| | | const OVERTIME_TYPE_OPTIONS = [ |
| | | { label: "工使¥å ç", value: "weekday" }, |
| | | { label: "伿¯æ¥å ç", value: "weekend" }, |
| | | { label: "æ³å®è忥å ç", value: "holiday" }, |
| | | ]; |
| | | |
| | | function overtimeTypeLabel(v) { |
| | | const hit = OVERTIME_TYPE_OPTIONS.find((x) => x.value === v); |
| | | return hit?.label || "â"; |
| | | } |
| | | |
| | | const createEmptyForm = () => ({ |
| | | id: undefined, |
| | | applicantId: "", |
| | | applicantNo: "", |
| | | applicantName: "", |
| | | overtimeType: "", |
| | | overtimeDate: "", |
| | | overtimeStartTime: "", |
| | | overtimeEndTime: "", |
| | | overtimeHours: null, |
| | | overtimeReason: "", |
| | | hasTemplateBinding: false, |
| | | templateId: "", |
| | | templateName: "", |
| | | templateSnapshot: null, |
| | | formFieldDefs: [], |
| | | formPayload: {}, |
| | | flowNodes: [], |
| | | templateAttachments: [], |
| | | storageBlobDTOs: [], |
| | | }); |
| | | |
| | | const { proxy } = getCurrentInstance(); |
| | | |
| | | function unwrapArray(payload) { |
| | | if (Array.isArray(payload)) return payload; |
| | | if (payload && Array.isArray(payload.data)) return payload.data; |
| | | if (payload && Array.isArray(payload.rows)) return payload.rows; |
| | | return []; |
| | | } |
| | | |
| | | function userById(id) { |
| | | if (id == null || id === "") return undefined; |
| | | return allUsersCache.value.find((u) => String(u.userId ?? u.id) === String(id)); |
| | | } |
| | | |
| | | function applicantNoFromUser(u) { |
| | | if (!u) return ""; |
| | | return ( |
| | | u.userName ?? |
| | | u.userCode ?? |
| | | u.jobNumber ?? |
| | | u.workNo ?? |
| | | (u.userId != null ? String(u.userId) : "") |
| | | ); |
| | | } |
| | | |
| | | function isOvertimeHoursField(field) { |
| | | function isOvertimeDurationField(field) { |
| | | const label = String(field?.label || ""); |
| | | return label.includes("å çæ¶é¿") || field?.key === "overtimeHours"; |
| | | } |
| | | |
| | | function displayTemplateFields(fields = []) { |
| | | return (fields || []).filter((f) => !isOvertimeDurationField(f)); |
| | | } |
| | | |
| | | function findOvertimeTimeTemplateField(fields = []) { |
| | | return ( |
| | | fields.find((f) => f?.type === "datetimerange" && String(f?.label || "").includes("å çæ¶é´")) || |
| | | fields.find((f) => f?.type === "datetimerange" && f?.key === "dateRange") || |
| | | fields.find((f) => f?.type === "datetimerange") || |
| | | null |
| | | ); |
| | | } |
| | | |
| | | function findApplicantTemplateField(fields = []) { |
| | | return ( |
| | | fields.find((f) => String(f?.label || "").includes("ç³è¯·äºº")) || |
| | | fields.find((f) => f?.type === "select" && f?.optionSource === SELECT_OPTION_SOURCE.USER) || |
| | | null |
| | | ); |
| | | } |
| | | |
| | | /** 仿¨¡æ¿å¡«æ¥é¡¹è§£æå çèµ·æ¢æ¶é´ */ |
| | | function resolveOvertimeTimeRange(payload, overtimeTimeField) { |
| | | if (!overtimeTimeField?.key) return { start: "", end: "" }; |
| | | const val = payload?.[overtimeTimeField.key]; |
| | |
| | | return { start: val[0] || "", end: val[1] || "" }; |
| | | } |
| | | |
| | | /** æèµ·æ¢æ¶é´è®¡ç®å çæ¶é¿ï¼å°æ¶ï¼ä¿ç两ä½å°æ°ï¼ */ |
| | | function computeOvertimeHours(startStr, endStr) { |
| | | if (!startStr || !endStr) return null; |
| | | const t0 = dayjs(startStr); |
| | | const t1 = dayjs(endStr); |
| | | if (!t0.isValid() || !t1.isValid() || !t1.isAfter(t0)) return null; |
| | | const hours = t1.diff(t0, "millisecond") / (60 * 60 * 1000); |
| | | return Math.round(hours * 100) / 100; |
| | | return Math.round((t1.diff(t0, "millisecond") / 3600000) * 100) / 100; |
| | | } |
| | | |
| | | function formatHours(v) { |
| | | if (v == null || v === "") return "â"; |
| | | return `${v} å°æ¶`; |
| | | function overtimeHoursDisplay(form) { |
| | | const field = findOvertimeTimeTemplateField(form.formFieldDefs); |
| | | const { start, end } = resolveOvertimeTimeRange(form.formPayload, field); |
| | | const h = computeOvertimeHours(start, end); |
| | | return h == null ? "" : String(h); |
| | | } |
| | | |
| | | function mapStorageBlobsToAttachmentList(blobs) { |
| | | return (blobs || []).map((f) => ({ |
| | | name: attachmentDisplayName(f), |
| | | url: f.url || f.downloadURL || f.previewURL || f.previewUrl, |
| | | })); |
| | | } |
| | | |
| | | function rowAttachmentList(row) { |
| | | if (!row) return []; |
| | | if (row.attachmentList?.length) return row.attachmentList; |
| | | return mapStorageBlobsToAttachmentList(row.storageBlobDTOs); |
| | | } |
| | | |
| | | function approvalResultLabel(v) { |
| | | if (v === "approved") return "å·²éè¿"; |
| | | if (v === "rejected") return "已驳å"; |
| | | if (v === "cancelled") return "å·²æ¤é"; |
| | | return "å¾
审æ¹"; |
| | | } |
| | | |
| | | function sortedApprovalNodes(row) { |
| | | const list = row?.approvalFlowNodes; |
| | | if (!Array.isArray(list) || !list.length) return []; |
| | | return [...list].sort((a, b) => (a.sortOrder ?? a.nodeOrder ?? 0) - (b.sortOrder ?? b.nodeOrder ?? 0)); |
| | | } |
| | | |
| | | function approvalNodeLabel(n) { |
| | | const name = (n.approverName || "").trim(); |
| | | return name || "æªéæ©å®¡æ¹äºº"; |
| | | } |
| | | |
| | | /** 详æ
å®¡æ¹æµç¨ï¼ä¼å
æ¨¡æ¿ flowNodesï¼å
¼å®¹æ§ç approvalFlowNodes */ |
| | | function detailFlowSteps(row) { |
| | | const nodes = row?.flowNodes; |
| | | if (Array.isArray(nodes) && nodes.length) { |
| | | return [...nodes] |
| | | .sort((a, b) => (a.nodeOrder ?? 0) - (b.nodeOrder ?? 0)) |
| | | .map((n, i) => { |
| | | const names = (n.approvers || []) |
| | | .map((a) => (a.approverName || "").trim()) |
| | | .filter(Boolean) |
| | | .join("ã"); |
| | | return `${i + 1}. ${names || "æªéæ©å®¡æ¹äºº"}`; |
| | | }); |
| | | } |
| | | return sortedApprovalNodes(row).map((n, i) => `${i + 1}. ${approvalNodeLabel(n)}`); |
| | | } |
| | | |
| | | function syncApplicantFromUser(uid) { |
| | | const u = userById(uid); |
| | | if (u) { |
| | | form.applicantId = uid != null && uid !== "" ? uid : ""; |
| | | form.applicantName = u.nickName || u.userName || ""; |
| | | form.applicantNo = applicantNoFromUser(u); |
| | | } else { |
| | | form.applicantId = ""; |
| | | form.applicantName = ""; |
| | | form.applicantNo = ""; |
| | | } |
| | | } |
| | | |
| | | const allUsersCache = ref([]); |
| | | |
| | | async function loadUserPool() { |
| | | try { |
| | | const res = await userListNoPageByTenantId(); |
| | | allUsersCache.value = unwrapArray(res); |
| | | } catch { |
| | | allUsersCache.value = []; |
| | | } |
| | | } |
| | | |
| | | const allRows = ref([]); |
| | | const { proxy } = getCurrentInstance(); |
| | | |
| | | const searchForm = reactive({ |
| | | applicantKeyword: "", |
| | | overtimeType: "", |
| | | }); |
| | | |
| | | const tableLoading = ref(false); |
| | | const page = reactive({ |
| | | current: 1, |
| | | size: 10, |
| | | total: 0, |
| | | const mod = useApprovalInstanceModule({ |
| | | moduleKey: APPROVAL_MODULE_KEYS.OVERTIME, |
| | | beforeSave: validateOvertimeBeforeSave, |
| | | }); |
| | | |
| | | const filteredList = computed(() => { |
| | | let list = [...allRows.value]; |
| | | const kw = (searchForm.applicantKeyword || "").trim().toLowerCase(); |
| | | if (kw) { |
| | | list = list.filter((r) => { |
| | | const name = (r.applicantName || "").toLowerCase(); |
| | | const no = (r.applicantNo || "").toLowerCase(); |
| | | return name.includes(kw) || no.includes(kw); |
| | | }); |
| | | } |
| | | if (searchForm.overtimeType) { |
| | | list = list.filter((r) => r.overtimeType === searchForm.overtimeType); |
| | | } |
| | | return list.sort((a, b) => (String(a.createTime) < String(b.createTime) ? 1 : -1)); |
| | | }); |
| | | 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; |
| | | |
| | | 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 = computed(() => { |
| | | const list = filteredList.value; |
| | | const start = (page.current - 1) * page.size; |
| | | return list.slice(start, start + page.size); |
| | | }); |
| | | |
| | | const tableColumn = ref([ |
| | | { label: "ç³è¯·äººç¼å·", prop: "applicantNo", width: 120 }, |
| | | { label: "ç³è¯·äºº", prop: "applicantName", minWidth: 100 }, |
| | | { label: "å çæ¥æ", prop: "overtimeDate", width: 120 }, |
| | | { label: "å çå¼å§æ¥æ", prop: "overtimeStartTime", width: 170 }, |
| | | { label: "å çç»ææ¥æ", prop: "overtimeEndTime", width: 170 }, |
| | | { |
| | | label: "å çæ¶é¿", |
| | | prop: "overtimeHours", |
| | | width: 120, |
| | | formatData: (v) => (v == null || v === "" ? "â" : `${v} å°æ¶`), |
| | | }, |
| | | { |
| | | 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"; |
| | | }, |
| | | }, |
| | | { label: "å建æ¶é´", prop: "createTime", width: 170 }, |
| | | { |
| | | dataType: "action", |
| | | label: "æä½", |
| | | align: "center", |
| | | fixed: "right", |
| | | width: 220, |
| | | 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 overtimeTimeTemplateField = computed(() => findOvertimeTimeTemplateField(form.formFieldDefs)); |
| | | const applicantTemplateField = computed(() => findApplicantTemplateField(form.formFieldDefs)); |
| | | |
| | | const templateDisplayFields = computed(() => |
| | | (form.formFieldDefs || []).filter((f) => !isOvertimeHoursField(f)) |
| | | ); |
| | | |
| | | const overtimeHoursDisplay = computed(() => { |
| | | const { start, end } = resolveOvertimeTimeRange(form.formPayload, overtimeTimeTemplateField.value); |
| | | const h = computeOvertimeHours(start, end); |
| | | return h == null ? "" : String(h); |
| | | }); |
| | | |
| | | const formRules = computed(() => buildFormPayloadRules(templateDisplayFields.value)); |
| | | |
| | | watch( |
| | | () => { |
| | | const key = applicantTemplateField.value?.key; |
| | | return key ? form.formPayload[key] : undefined; |
| | | }, |
| | | async (uid) => { |
| | | if (!applicantTemplateField.value) return; |
| | | if (!allUsersCache.value.length) { |
| | | await loadUserPool(); |
| | | function validateOvertimeBeforeSave() { |
| | | const field = findOvertimeTimeTemplateField(submitForm.formFieldDefs); |
| | | const { start, end } = resolveOvertimeTimeRange(submitForm.formPayload, field); |
| | | if (computeOvertimeHours(start, end) == null) { |
| | | ElMessage.warning("è¯·æ£æ¥æ¨¡æ¿ä¸çå çæ¶é´ï¼ç»ææ¶é´é¡»æäºå¼å§æ¶é´"); |
| | | throw new Error("invalid overtime time"); |
| | | } |
| | | syncApplicantFromUser(uid); |
| | | } |
| | | ); |
| | | |
| | | watch( |
| | | () => { |
| | | const key = overtimeTimeTemplateField.value?.key; |
| | | return key ? form.formPayload[key] : undefined; |
| | | }, |
| | | () => { |
| | | const { start, end } = resolveOvertimeTimeRange(form.formPayload, overtimeTimeTemplateField.value); |
| | | form.overtimeStartTime = start; |
| | | form.overtimeEndTime = end; |
| | | form.overtimeHours = computeOvertimeHours(start, end); |
| | | if (start) { |
| | | form.overtimeDate = dayjs(start).format("YYYY-MM-DD"); |
| | | } |
| | | }, |
| | | { deep: true } |
| | | ); |
| | | const tableColumn = buildInstanceTableColumns(tableData, buildTableActions); |
| | | |
| | | const detailDialog = reactive({ visible: false }); |
| | | const detailRow = ref({}); |
| | | |
| | | const filesDialog = reactive({ visible: false, row: null }); |
| | | const importInputRef = ref(null); |
| | | |
| | | function handleQuery() { |
| | | page.current = 1; |
| | | tableLoading.value = true; |
| | | setTimeout(() => { |
| | | tableLoading.value = false; |
| | | }, 150); |
| | | function onSearch() { |
| | | handleQuery(searchForm); |
| | | } |
| | | |
| | | function resetSearch() { |
| | | searchForm.applicantKeyword = ""; |
| | | searchForm.overtimeType = ""; |
| | | 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; |
| | | } |
| | | |
| | | 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?.("ææ ä¸è½½å°å"); |
| | | async function onSubmit() { |
| | | const ok = await submitInstanceForm({ skipValidate: true }); |
| | | if (ok) ElMessage.success(isSubmitEdit.value ? "ä¿®æ¹æå" : "æäº¤æå"); |
| | | } |
| | | |
| | | function handleExport() { |
| | | const data = filteredList.value; |
| | | const data = tableData.value; |
| | | const blob = new Blob([JSON.stringify(data, null, 2)], { type: "application/json;charset=utf-8" }); |
| | | const url = URL.createObjectURL(blob); |
| | | const a = document.createElement("a"); |
| | |
| | | a.download = `å çç³è¯·å¯¼åº_${dayjs().format("YYYYMMDDHHmmss")}.json`; |
| | | a.click(); |
| | | URL.revokeObjectURL(url); |
| | | proxy?.$modal?.msgSuccess?.(`å·²å¯¼åº ${data.length} æ¡ï¼å½åçéç»æï¼JSONï¼`); |
| | | proxy?.$modal?.msgSuccess?.(`å·²å¯¼åº ${data.length} æ¡ï¼å½å页åè¡¨æ°æ®ï¼`); |
| | | } |
| | | |
| | | function handleImportClick() { |
| | | importInputRef.value?.click?.(); |
| | | } |
| | | |
| | | function normalizeImportedRow(raw, idx) { |
| | | const id = raw.id != null && String(raw.id).length ? `imp_${String(raw.id)}_${idx}` : `imp_${Date.now()}_${idx}`; |
| | | const hours = |
| | | raw.overtimeHours != null && raw.overtimeHours !== "" |
| | | ? Number(raw.overtimeHours) |
| | | : computeOvertimeHours(raw.overtimeStartTime, raw.overtimeEndTime); |
| | | return { |
| | | id, |
| | | applicantId: raw.applicantId != null ? String(raw.applicantId) : `imp_user_${idx}`, |
| | | applicantNo: raw.applicantNo ?? "", |
| | | applicantName: raw.applicantName ?? "æªç¥", |
| | | overtimeType: raw.overtimeType || "weekday", |
| | | overtimeDate: raw.overtimeDate ?? "", |
| | | overtimeStartTime: raw.overtimeStartTime ?? "", |
| | | overtimeEndTime: raw.overtimeEndTime ?? "", |
| | | overtimeHours: hours == null || Number.isNaN(hours) ? 0 : Math.round(hours * 100) / 100, |
| | | overtimeReason: raw.overtimeReason ?? "", |
| | | hasTemplateBinding: false, |
| | | approvalFlowNodes: Array.isArray(raw.approvalFlowNodes) && raw.approvalFlowNodes.length |
| | | ? raw.approvalFlowNodes.map((n) => ({ ...n })) |
| | | : [], |
| | | approvalResult: raw.approvalResult && ["pending", "approved", "rejected", "cancelled"].includes(raw.approvalResult) |
| | | ? raw.approvalResult |
| | | : "pending", |
| | | attachmentList: Array.isArray(raw.attachmentList) ? raw.attachmentList : [], |
| | | createTime: raw.createTime || dayjs().format("YYYY-MM-DD HH:mm:ss"), |
| | | }; |
| | | } |
| | | |
| | | function onImportFile(e) { |
| | | const input = e.target; |
| | | const file = input.files?.[0]; |
| | | input.value = ""; |
| | | if (!file) return; |
| | | const reader = new FileReader(); |
| | | reader.onload = () => { |
| | | try { |
| | | const text = String(reader.result || ""); |
| | | const parsed = JSON.parse(text); |
| | | const arr = Array.isArray(parsed) ? parsed : parsed?.rows || parsed?.data; |
| | | if (!Array.isArray(arr) || !arr.length) { |
| | | proxy?.$modal?.msgWarning?.("导å
¥æä»¶æ ¼å¼ä¸æ£ç¡®ï¼é为å çç³è¯·å¯¹è±¡æ°ç» JSON"); |
| | | return; |
| | | } |
| | | let n = 0; |
| | | for (let i = 0; i < arr.length; i++) { |
| | | allRows.value.unshift(normalizeImportedRow(arr[i], i)); |
| | | n++; |
| | | } |
| | | proxy?.$modal?.msgSuccess?.(`æå导å
¥ ${n} æ¡ï¼æ¬å°åå¹¶ï¼`); |
| | | handleQuery(); |
| | | } catch { |
| | | proxy?.$modal?.msgError?.("è§£æå¤±è´¥ï¼è¯·ä½¿ç¨å¯¼åºæä»¶æçº¦å® JSON ç»æ"); |
| | | } |
| | | }; |
| | | reader.readAsText(file, "utf-8"); |
| | | } |
| | | |
| | | function openAddWithTemplate() { |
| | | formDialog.visible = false; |
| | | pendingTemplateBinding.value = null; |
| | | templateBindVisible.value = true; |
| | | } |
| | | |
| | | function onTemplateBound(binding) { |
| | | pendingTemplateBinding.value = binding; |
| | | } |
| | | |
| | | async function onTemplateBindClosed() { |
| | | const binding = pendingTemplateBinding.value; |
| | | if (!binding) return; |
| | | pendingTemplateBinding.value = null; |
| | | await openFormWithBinding(binding); |
| | | } |
| | | |
| | | async function openFormWithBinding(binding) { |
| | | Object.assign(form, createEmptyForm()); |
| | | applyBindingToForm(form, binding); |
| | | form.hasTemplateBinding = true; |
| | | formDialog.mode = "add"; |
| | | formDialog.title = "æ°å¢å çç³è¯·"; |
| | | await Promise.all([loadUserPool(), loadFlowUsers()]); |
| | | const applicantKey = applicantTemplateField.value?.key; |
| | | if (applicantKey && form.formPayload[applicantKey]) { |
| | | syncApplicantFromUser(form.formPayload[applicantKey]); |
| | | } |
| | | const { start, end } = resolveOvertimeTimeRange(form.formPayload, overtimeTimeTemplateField.value); |
| | | form.overtimeStartTime = start; |
| | | form.overtimeEndTime = end; |
| | | form.overtimeHours = computeOvertimeHours(start, end); |
| | | if (start) form.overtimeDate = dayjs(start).format("YYYY-MM-DD"); |
| | | formDialog.visible = true; |
| | | nextTick(() => formRef.value?.clearValidate?.()); |
| | | } |
| | | |
| | | function reopenTemplateBind() { |
| | | formDialog.visible = false; |
| | | pendingTemplateBinding.value = null; |
| | | templateBindVisible.value = true; |
| | | } |
| | | |
| | | async 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, |
| | | applicantId: row.applicantId, |
| | | applicantNo: row.applicantNo, |
| | | applicantName: row.applicantName, |
| | | overtimeType: row.overtimeType, |
| | | overtimeDate: row.overtimeDate, |
| | | overtimeStartTime: row.overtimeStartTime, |
| | | overtimeEndTime: row.overtimeEndTime, |
| | | overtimeHours: row.overtimeHours, |
| | | overtimeReason: row.overtimeReason, |
| | | 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 || [])), |
| | | }); |
| | | await loadUserPool(); |
| | | const applicantKey = applicantTemplateField.value?.key; |
| | | if (applicantKey) { |
| | | syncApplicantFromUser(form.formPayload[applicantKey]); |
| | | } |
| | | onMounted(async () => { |
| | | loadFlowUsers(); |
| | | } |
| | | formDialog.visible = true; |
| | | nextTick(() => formRef.value?.clearValidate?.()); |
| | | } |
| | | |
| | | function onFormClosed() { |
| | | formRef.value?.resetFields?.(); |
| | | } |
| | | |
| | | /** 仿¨¡æ¿å¡«æ¥é¡¹åæ¥å表å±ç¤ºå段 */ |
| | | function syncOvertimeFieldsFromPayload() { |
| | | const defs = form.formFieldDefs || []; |
| | | const payload = form.formPayload || {}; |
| | | const overtimeTimeField = findOvertimeTimeTemplateField(defs); |
| | | |
| | | for (const f of defs) { |
| | | const label = String(f.label || ""); |
| | | const val = payload[f.key]; |
| | | |
| | | if (label.includes("ç³è¯·äºº") && !label.includes("æ¥æ") && !label.includes("æ¶é´")) { |
| | | if (val != null && val !== "") { |
| | | form.applicantId = val; |
| | | const u = userById(val); |
| | | if (u) { |
| | | form.applicantName = u.nickName || u.userName || ""; |
| | | form.applicantNo = applicantNoFromUser(u); |
| | | } |
| | | } |
| | | } |
| | | if ((label.includes("å çç±»å") || f.key === "overtimeType") && f.type === "select") { |
| | | form.overtimeType = val != null && val !== "" ? val : ""; |
| | | } |
| | | if (label.includes("å çæ¥æ") && f.type === "date") { |
| | | form.overtimeDate = val || ""; |
| | | } |
| | | if (label.includes("äºç±") || f.key === "summary" || label.includes("å çäºç±")) { |
| | | form.overtimeReason = val != null ? String(val) : ""; |
| | | } |
| | | } |
| | | |
| | | const { start, end } = resolveOvertimeTimeRange(payload, overtimeTimeField); |
| | | form.overtimeStartTime = start; |
| | | form.overtimeEndTime = end; |
| | | form.overtimeHours = computeOvertimeHours(start, end); |
| | | if (!form.overtimeDate && start) { |
| | | form.overtimeDate = dayjs(start).format("YYYY-MM-DD"); |
| | | } |
| | | } |
| | | |
| | | 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; |
| | | |
| | | const applicantKey = applicantTemplateField.value?.key; |
| | | if (applicantKey) { |
| | | syncApplicantFromUser(form.formPayload[applicantKey]); |
| | | } |
| | | syncOvertimeFieldsFromPayload(); |
| | | |
| | | if (form.overtimeHours == null) { |
| | | proxy?.$modal?.msgWarning?.("è¯·æ£æ¥æ¨¡æ¿ä¸çå çæ¶é´ï¼ç»ææ¶é´é¡»æäºå¼å§æ¶é´"); |
| | | return; |
| | | } |
| | | |
| | | const attachmentList = mapStorageBlobsToAttachmentList(form.storageBlobDTOs); |
| | | const payload = { |
| | | applicantId: form.applicantId, |
| | | applicantNo: form.applicantNo, |
| | | applicantName: form.applicantName, |
| | | overtimeType: form.overtimeType, |
| | | overtimeDate: form.overtimeDate, |
| | | overtimeStartTime: form.overtimeStartTime, |
| | | overtimeEndTime: form.overtimeEndTime, |
| | | overtimeHours: form.overtimeHours, |
| | | overtimeReason: form.overtimeReason, |
| | | 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 || [])), |
| | | attachmentList, |
| | | }; |
| | | if (formDialog.mode === "add") { |
| | | const id = `local_${Date.now()}`; |
| | | allRows.value.unshift({ |
| | | id, |
| | | ...payload, |
| | | approvalResult: "pending", |
| | | createTime: dayjs().format("YYYY-MM-DD HH:mm:ss"), |
| | | }); |
| | | 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", |
| | | createTime: prev.createTime ?? dayjs().format("YYYY-MM-DD HH:mm:ss"), |
| | | }; |
| | | } |
| | | proxy?.$modal?.msgSuccess?.("ä¿åæå"); |
| | | } |
| | | formDialog.visible = false; |
| | | handleQuery(); |
| | | } |
| | | |
| | | onMounted(() => { |
| | | loadFlowUsers(); |
| | | await initModuleList(searchForm); |
| | | }); |
| | | </script> |
| | | |
| | |
| | | .search_actions { |
| | | display: flex; |
| | | flex-wrap: wrap; |
| | | align-items: center; |
| | | gap: 8px; |
| | | } |
| | | .search_title { |
| | | font-size: 14px; |
| | | color: var(--el-text-color-regular); |
| | | } |
| | | .sr-only-input { |
| | | position: absolute; |
| | | width: 1px; |
| | | height: 1px; |
| | | padding: 0; |
| | | margin: -1px; |
| | | overflow: hidden; |
| | | clip: rect(0, 0, 0, 0); |
| | | white-space: nowrap; |
| | | border: 0; |
| | | } |
| | | .mr6 { |
| | | margin-right: 6px; |
| | | } |
| | | .mb6 { |
| | | margin-bottom: 6px; |
| | | } |
| | | .overtime-apply-form :deep(.el-row) { |
| | | margin-bottom: 0; |
| | | } |
| | | .overtime-apply-form :deep(.el-form-item) { |
| | | margin-bottom: 18px; |
| | | } |
| | | .template-name { |
| | | font-weight: 600; |
| | | color: var(--el-text-color-primary); |
| | | } |
| | | .ml12 { |
| | | margin-left: 12px; |
| | | } |
| | | .overtime-apply-form-dialog :deep(.el-dialog__body) { |
| | | padding-top: 12px; |
| | | } |
| | | .detail-flow-chain { |
| | | display: flex; |
| | | flex-wrap: wrap; |
| | | align-items: center; |
| | | gap: 6px 8px; |
| | | line-height: 1.6; |
| | | } |
| | | .detail-flow-step { |
| | | font-size: 14px; |
| | | color: var(--el-text-color-primary); |
| | | } |
| | | .detail-flow-sep { |
| | | color: var(--el-text-color-secondary); |
| | | font-size: 13px; |
| | | } |
| | | </style> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | import { |
| | | createEmptyForm, |
| | | publishStatusLabel, |
| | | PUBLISH_STATUS_OPTIONS, |
| | | } from "./enterpriseNewsUtils.js"; |
| | | import { normalizeApprovalStatusKey } from "../../ApproveManage/approve-list/approveListConstants.js"; |
| | | |
| | | /** formPayload ä¸åæ¾å®æ´ä¼ä¸æ°é»ä¸å¡æ°æ®çé® */ |
| | | export const ENTERPRISE_NEWS_PAYLOAD_KEY = "enterpriseNews"; |
| | | |
| | | export function extractEnterpriseNewsFromRow(row) { |
| | | const payload = row?.formPayload || {}; |
| | | const raw = payload[ENTERPRISE_NEWS_PAYLOAD_KEY]; |
| | | if (raw && typeof raw === "object") { |
| | | return { ...createEmptyForm(), ...raw }; |
| | | } |
| | | return { |
| | | ...createEmptyForm(), |
| | | title: payload.title || row?.title || "", |
| | | summary: payload.summary || "", |
| | | newsType: payload.newsType || "announcement", |
| | | contentHtml: payload.contentHtml || "", |
| | | }; |
| | | } |
| | | |
| | | /** å表è¡å¢å¼ºï¼ä¸»è¡¨å±ç¤ºæ°é»å段 */ |
| | | export function enrichEnterpriseNewsListRow(row) { |
| | | const news = extractEnterpriseNewsFromRow(row); |
| | | const publishStatus = |
| | | news.publishStatus || mapApprovalStatusToPublishStatus(row?.approvalStatus); |
| | | return { |
| | | ...row, |
| | | newsNo: news.newsNo || row.instanceNo || "â", |
| | | title: news.title || row.title || "â", |
| | | summary: news.summary, |
| | | newsType: news.newsType, |
| | | publisherName: news.publisherName || row.applicantName || "â", |
| | | publishTime: news.publishTime || row.createTime || "", |
| | | updateTime: news.updateTime || row.createTime || "", |
| | | publishStatus, |
| | | _news: news, |
| | | }; |
| | | } |
| | | |
| | | function mapApprovalStatusToPublishStatus(approvalStatus) { |
| | | const key = normalizeApprovalStatusKey(approvalStatus); |
| | | if (key === "approved") return "published"; |
| | | if (key === "pending") return "pending_review"; |
| | | if (key === "rejected") return "draft"; |
| | | return "draft"; |
| | | } |
| | | |
| | | /** ä¼ä¸æ°é»è¡¨å â 审æ¹å®ä¾ formPayload */ |
| | | export function syncNewsFormToSubmitPayload(newsForm, submitForm) { |
| | | const snapshot = JSON.parse(JSON.stringify(newsForm)); |
| | | submitForm.formPayload = { |
| | | ...(submitForm.formPayload || {}), |
| | | [ENTERPRISE_NEWS_PAYLOAD_KEY]: snapshot, |
| | | title: snapshot.title, |
| | | summary: snapshot.summary, |
| | | }; |
| | | } |
| | | |
| | | export function buildEnterpriseNewsTableColumns(buildTableActions) { |
| | | return [ |
| | | { label: "ç¼å·", prop: "newsNo", width: 150 }, |
| | | { label: "æ é¢", prop: "title", minWidth: 180, showOverflowTooltip: true }, |
| | | { |
| | | label: "åç±»", |
| | | prop: "newsType", |
| | | width: 100, |
| | | dataType: "slot", |
| | | slot: "newsType", |
| | | }, |
| | | { |
| | | label: "ç¶æ", |
| | | prop: "publishStatus", |
| | | width: 90, |
| | | dataType: "tag", |
| | | formatData: (v) => publishStatusLabel(v), |
| | | formatType: (v) => { |
| | | const hit = PUBLISH_STATUS_OPTIONS.find((x) => x.value === v); |
| | | return hit?.tag || "info"; |
| | | }, |
| | | }, |
| | | { label: "åå¸äºº", prop: "publisherName", width: 110 }, |
| | | { label: "å叿¶é´", prop: "publishTime", width: 170 }, |
| | | { label: "æ´æ°æ¶é´", prop: "updateTime", width: 170 }, |
| | | { |
| | | dataType: "action", |
| | | label: "æä½", |
| | | align: "center", |
| | | fixed: "right", |
| | | width: 220, |
| | | operation: buildTableActions(), |
| | | }, |
| | | ]; |
| | | } |
| | |
| | | <!--OA模åï¼EnterpriseNews ä¼ä¸æ°é»--> |
| | | <!--OA模åï¼EnterpriseNews ä¼ä¸æ°é»ï¼å表走审æ¹å®ä¾ï¼æ°å¢/ä¿®æ¹ä¿çå表å + 模æ¿å®¡æ¹æµç¨ï¼--> |
| | | <template> |
| | | <div class="app-container enterprise-news-page"> |
| | | |
| | | <div class="search_form mb20"> |
| | | <div class="search_fields"> |
| | | <span class="search_title">å
³é®è¯ï¼</span> |
| | |
| | | placeholder="æ é¢ / ç¼å· / æè¦" |
| | | clearable |
| | | :prefix-icon="Search" |
| | | @keyup.enter="handleQuery" |
| | | @keyup.enter="onSearch" |
| | | /> |
| | | <span class="search_title" style="margin-left: 12px">åç±»ï¼</span> |
| | | <el-select v-model="searchForm.newsType" placeholder="å
¨é¨" clearable style="width: 140px"> |
| | | <el-option v-for="opt in NEWS_TYPE_OPTIONS" :key="opt.value" :label="opt.label" :value="opt.value" /> |
| | | </el-select> |
| | | <span class="search_title" style="margin-left: 12px">ç¶æï¼</span> |
| | | <el-select v-model="searchForm.publishStatus" placeholder="å
¨é¨" clearable style="width: 120px"> |
| | | <el-option v-for="opt in PUBLISH_STATUS_OPTIONS" :key="opt.value" :label="opt.label" :value="opt.value" /> |
| | | <span class="search_title" style="margin-left: 12px">审æ¹ç¶æï¼</span> |
| | | <el-select v-model="searchForm.status" placeholder="å
¨é¨" clearable style="width: 120px"> |
| | | <el-option |
| | | v-for="opt in APPROVAL_STATUS_SEARCH_OPTIONS" |
| | | :key="opt.value" |
| | | :label="opt.label" |
| | | :value="opt.value" |
| | | /> |
| | | </el-select> |
| | | <span class="search_title" style="margin-left: 12px">å叿¶é´ï¼</span> |
| | | <span class="search_title" style="margin-left: 12px">ç³è¯·æ¥æï¼</span> |
| | | <el-date-picker |
| | | v-model="searchForm.publishTimeRange" |
| | | v-model="searchForm.createTimeRange" |
| | | type="daterange" |
| | | range-separator="-" |
| | | start-placeholder="å¼å§" |
| | |
| | | style="width: 260px" |
| | | clearable |
| | | /> |
| | | <el-button type="primary" :icon="Search" class="ml10" @click="handleQuery">æç´¢</el-button> |
| | | <el-button type="primary" :icon="Search" class="ml10" @click="onSearch">æç´¢</el-button> |
| | | <el-button :icon="RefreshRight" @click="resetSearch">éç½®</el-button> |
| | | </div> |
| | | <div class="search_actions"> |
| | | <el-button type="primary" :icon="Plus" @click="openFormDialog('add')">æ°å»ºæ°é»</el-button> |
| | | <el-button type="primary" :icon="Plus" @click="openAddWithTemplate">æ°å»ºæ°é»</el-button> |
| | | </div> |
| | | </div> |
| | | |
| | |
| | | :isSelection="false" |
| | | :tableLoading="tableLoading" |
| | | :total="page.total" |
| | | @pagination="pagination" |
| | | @pagination="onPagination" |
| | | > |
| | | <template #newsType="{ row }"> |
| | | <span class="news-type-tag" :style="{ color: newsTypeColor(row.newsType) }"> |
| | |
| | | </PIMTable> |
| | | </div> |
| | | |
| | | <!-- æ°å»º / ç¼è¾ --> |
| | | <ApprovalTemplateBindDialog |
| | | v-model:visible="templateBindVisible" |
| | | :module-key="APPROVAL_MODULE_KEYS.ENTERPRISE_NEWS" |
| | | skip-form-confirm |
| | | @confirm="onTemplateBound" |
| | | @closed="onTemplateBindClosed" |
| | | /> |
| | | |
| | | <!-- æ°å»º / ç¼è¾ï¼åä¼ä¸æ°é»è¡¨å + 模æ¿å®¡æ¹æµç¨ --> |
| | | <el-dialog |
| | | v-model="formDialog.visible" |
| | | :title="formDialog.title" |
| | | v-model="newsFormDialog.visible" |
| | | :title="newsFormDialog.title" |
| | | width="960px" |
| | | append-to-body |
| | | destroy-on-close |
| | | class="news-form-dialog" |
| | | @closed="formRef?.resetFields?.()" |
| | | @closed="onNewsFormClosed" |
| | | > |
| | | <el-form |
| | | ref="formRef" |
| | | :model="form" |
| | | :rules="formRules" |
| | | ref="newsFormRef" |
| | | :model="newsForm" |
| | | :rules="newsFormRules" |
| | | label-width="110px" |
| | | :disabled="formDialog.readonly" |
| | | :disabled="newsFormDialog.readonly" |
| | | > |
| | | <el-row :gutter="20"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="æ°é»åç±»" prop="newsType"> |
| | | <el-select v-model="form.newsType" placeholder="è¯·éæ©" style="width: 100%"> |
| | | <el-select v-model="newsForm.newsType" placeholder="è¯·éæ©" style="width: 100%"> |
| | | <el-option v-for="opt in NEWS_TYPE_OPTIONS" :key="opt.value" :label="opt.label" :value="opt.value" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="æç模æ¿"> |
| | | <el-select v-model="form.layoutTemplate" style="width: 100%"> |
| | | <el-select v-model="newsForm.layoutTemplate" style="width: 100%"> |
| | | <el-option |
| | | v-for="opt in LAYOUT_TEMPLATE_OPTIONS" |
| | | :key="opt.value" |
| | |
| | | </el-col> |
| | | </el-row> |
| | | <el-form-item label="æ é¢" prop="title"> |
| | | <el-input v-model="form.title" placeholder="æ°é»æ é¢" maxlength="100" show-word-limit /> |
| | | <el-input v-model="newsForm.title" placeholder="æ°é»æ é¢" maxlength="100" show-word-limit /> |
| | | </el-form-item> |
| | | <el-form-item label="æè¦"> |
| | | <el-input v-model="form.summary" type="textarea" :rows="2" maxlength="300" show-word-limit /> |
| | | <el-input v-model="newsForm.summary" type="textarea" :rows="2" maxlength="300" show-word-limit /> |
| | | </el-form-item> |
| | | <el-form-item label="æ£æ" prop="contentHtml"> |
| | | <Editor v-model="form.contentHtml" :min-height="280" /> |
| | | <Editor v-model="newsForm.contentHtml" :min-height="280" /> |
| | | </el-form-item> |
| | | <el-form-item label="éä»¶"> |
| | | <FileUpload v-model:file-list="form.attachmentList" :limit="10" button-text="ä¸ä¼ PDF / ææ¡£" /> |
| | | <FileUpload v-model:file-list="newsForm.attachmentList" :limit="10" button-text="ä¸ä¼ PDF / ææ¡£" /> |
| | | </el-form-item> |
| | | <el-form-item v-if="form.layoutTemplate === 'gallery'" label="å¾é/è§é¢"> |
| | | <el-form-item v-if="newsForm.layoutTemplate === 'gallery'" label="å¾é/è§é¢"> |
| | | <el-input |
| | | v-model="galleryInput" |
| | | placeholder="è¾å
¥èµæºåç§°åå车添å ï¼æ¼ç¤ºï¼" |
| | | @keyup.enter="addGalleryItem" |
| | | /> |
| | | <el-tag |
| | | v-for="(m, i) in form.mediaList" |
| | | v-for="(m, i) in newsForm.mediaList" |
| | | :key="i" |
| | | closable |
| | | class="media-tag" |
| | | @close="form.mediaList.splice(i, 1)" |
| | | @close="newsForm.mediaList.splice(i, 1)" |
| | | > |
| | | {{ m.name }} |
| | | </el-tag> |
| | |
| | | <el-row :gutter="20"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="ç¼è¾è§è²"> |
| | | <el-select v-model="form.editorRole" style="width: 100%"> |
| | | <el-select v-model="newsForm.editorRole" style="width: 100%"> |
| | | <el-option v-for="opt in PUBLISH_ROLE_OPTIONS" :key="opt.value" :label="opt.label" :value="opt.value" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="å®¡æ ¸è§è²"> |
| | | <el-select v-model="form.reviewerRole" style="width: 100%"> |
| | | <el-select v-model="newsForm.reviewerRole" style="width: 100%"> |
| | | <el-option v-for="opt in PUBLISH_ROLE_OPTIONS" :key="opt.value" :label="opt.label" :value="opt.value" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-form-item label="é
读èå´" prop="readScope"> |
| | | <el-radio-group v-model="form.readScope"> |
| | | <el-radio-group v-model="newsForm.readScope"> |
| | | <el-radio v-for="opt in READ_SCOPE_OPTIONS" :key="opt.value" :value="opt.value"> |
| | | {{ opt.label }} |
| | | </el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | <el-form-item v-if="form.readScope === 'department'" label="å¯è§é¨é¨"> |
| | | <el-select v-model="form.targetDeptIds" multiple placeholder="éæ©é¨é¨" style="width: 100%"> |
| | | <el-form-item v-if="newsForm.readScope === 'department'" label="å¯è§é¨é¨"> |
| | | <el-select v-model="newsForm.targetDeptIds" multiple placeholder="éæ©é¨é¨" style="width: 100%"> |
| | | <el-option v-for="d in DEPT_OPTIONS" :key="d.value" :label="d.label" :value="d.value" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="æ¿çç±»å¿
读"> |
| | | <el-switch v-model="form.requireReadConfirm" active-text="éé
读确认ï¼ä¾¿äºç»è®¡æªè¯»ï¼" /> |
| | | <el-switch v-model="newsForm.requireReadConfirm" active-text="éé
读确认ï¼ä¾¿äºç»è®¡æªè¯»ï¼" /> |
| | | </el-form-item> |
| | | <el-form-item label="åå¸äºº"> |
| | | <el-input v-model="form.publisherName" placeholder="å¦ï¼äººåèµæºé¨" maxlength="50" /> |
| | | <el-input v-model="newsForm.publisherName" placeholder="å¦ï¼äººåèµæºé¨" maxlength="50" /> |
| | | </el-form-item> |
| | | |
| | | <template v-if="activeTemplate"> |
| | | <el-divider content-position="left">å®¡æ¹æµç¨</el-divider> |
| | | <el-form-item label="å®¡æ¹æ¨¡æ¿"> |
| | | <span class="template-name">{{ activeTemplate.label || submitForm.templateName }}</span> |
| | | </el-form-item> |
| | | <el-form-item label="å®¡æ¹æµç¨" required> |
| | | <TemplateFlowEditor v-model="submitForm.flowNodes" :user-options="flowUserOptions" /> |
| | | <p class="section-tip">æµç¨ä¸å®¡æ¹äººç±æ¨¡æ¿é¢ç½®ï¼å¯æéå¾®è°èç¹å®¡æ¹äººã</p> |
| | | </el-form-item> |
| | | </template> |
| | | <el-alert v-else type="warning" show-icon :closable="false" title="请å
éè¿ãæ°å»ºæ°é»ãéæ©å®¡æ¹æ¨¡æ¿" /> |
| | | </el-form> |
| | | <template v-if="!formDialog.readonly" #footer> |
| | | <el-button @click="formDialog.visible = false">å æ¶</el-button> |
| | | <el-button @click="onSave('save')">åè稿</el-button> |
| | | <el-button type="warning" @click="onSave('submit_review')">æäº¤å®¡æ ¸</el-button> |
| | | <el-button type="primary" @click="onSave('publish')">ç´æ¥åå¸</el-button> |
| | | <template v-if="!newsFormDialog.readonly" #footer> |
| | | <el-button @click="newsFormDialog.visible = false">å æ¶</el-button> |
| | | <el-button :loading="submitSaving" @click="onNewsSave('draft')">åè稿</el-button> |
| | | <el-button type="warning" :loading="submitSaving" @click="onNewsSave('submit_review')"> |
| | | æäº¤å®¡æ ¸ |
| | | </el-button> |
| | | <el-button type="primary" :loading="submitSaving" @click="onNewsSave('submit_review')"> |
| | | ä¿ å |
| | | </el-button> |
| | | </template> |
| | | </el-dialog> |
| | | |
| | | <!-- 详æ
--> |
| | | <el-dialog v-model="detailDialog.visible" title="æ°é»è¯¦æ
" width="880px" append-to-body destroy-on-close> |
| | | <NewsDetailPanel |
| | | :row="detailRow" |
| | | @like="onDetailLike" |
| | | @comment="onDetailComment" |
| | | /> |
| | | <NewsDetailPanel :row="detailNewsRow" @like="onDetailLike" @comment="onDetailComment" /> |
| | | <el-divider content-position="left">审æ¹ä¿¡æ¯</el-divider> |
| | | <ApproveDetailPanel :row="detailRow" /> |
| | | <template #footer> |
| | | <el-button |
| | | v-if="detailRow.publishStatus === 'published' && getUnreadEmployees(detailRow).length" |
| | | type="warning" |
| | | @click="openUnreadFromDetail" |
| | | v-if="canEditBusinessInstanceRow(detailRow)" |
| | | type="primary" |
| | | @click="openNewsEditFromDetail" |
| | | > |
| | | æªè¯»æé |
| | | ä¿®æ¹ |
| | | </el-button> |
| | | <el-button @click="openVersionFromDetail">çæ¬çè¯</el-button> |
| | | <el-button @click="detailDialog.visible = false">å
³ é</el-button> |
| | | </template> |
| | | </el-dialog> |
| | | |
| | | <!-- æªè¯»æé --> |
| | | <el-dialog |
| | | v-model="unreadDialog.visible" |
| | | :title="`æªé
读åå·¥ · ${unreadDialog.row?.title || ''}`" |
| | | width="720px" |
| | | append-to-body |
| | | destroy-on-close |
| | | > |
| | | <el-alert type="warning" show-icon :closable="false" class="mb12"> |
| | | æ¿çä¼ è¾¾åºæ¯ï¼å叿°èå¤å¶åº¦çå¿
读信æ¯åï¼å¯å¾éæªè¯»åå·¥ç± HR å®åæéï¼æ¼ç¤ºæ°æ®ï¼åæå¯¹æ¥æ¶æ¯ä¸å¿ï¼ã |
| | | </el-alert> |
| | | <div class="unread-toolbar mb12"> |
| | | <el-button size="small" @click="selectAllUnread">å
¨éæªè¯»</el-button> |
| | | <span class="unread-stat">å
± {{ unreadList.length }} 人æªè¯»</span> |
| | | </div> |
| | | <el-table |
| | | :data="unreadList" |
| | | border |
| | | size="small" |
| | | max-height="360" |
| | | @selection-change="onUnreadSelectionChange" |
| | | > |
| | | <el-table-column type="selection" width="48" /> |
| | | <el-table-column prop="employeeNo" label="å·¥å·" width="100" /> |
| | | <el-table-column prop="name" label="å§å" width="90" /> |
| | | <el-table-column prop="deptName" label="é¨é¨" min-width="120" /> |
| | | </el-table> |
| | | <el-divider v-if="unreadDialog.row?.remindLogs?.length" content-position="left">æéè®°å½</el-divider> |
| | | <el-timeline v-if="unreadDialog.row?.remindLogs?.length"> |
| | | <el-timeline-item |
| | | v-for="(log, i) in unreadDialog.row.remindLogs" |
| | | :key="i" |
| | | :timestamp="log.time" |
| | | > |
| | | {{ log.operator }} å·²å {{ log.count }} 人åéé
读æé |
| | | </el-timeline-item> |
| | | </el-timeline> |
| | | <template #footer> |
| | | <el-button type="primary" @click="onSendRemind">åéå®åæé</el-button> |
| | | <el-button @click="unreadDialog.visible = false">å
³ é</el-button> |
| | | </template> |
| | | </el-dialog> |
| | | |
| | | <!-- çæ¬çè¯ --> |
| | | <el-dialog |
| | | v-model="versionDialog.visible" |
| | | :title="`åå²çæ¬çè¯ Â· ${versionDialog.row?.title || ''}`" |
| | | width="800px" |
| | | append-to-body |
| | | destroy-on-close |
| | | > |
| | | <el-alert type="info" show-icon :closable="false" class="mb12"> |
| | | äºè®®åçæ¶å¯æ¥é
åå²çæ¬ï¼è¯æå½æ¶åå¸å
容ä¸å叿¶é´ï¼åè§çè¯ï¼ã |
| | | </el-alert> |
| | | <el-descriptions :column="2" border class="mb16"> |
| | | <el-descriptions-item label="å½åçæ¬">v{{ versionDialog.row?.versionNo || 1 }}</el-descriptions-item> |
| | | <el-descriptions-item label="æè¿åå¸">{{ versionDialog.row?.publishTime || "â" }}</el-descriptions-item> |
| | | </el-descriptions> |
| | | <el-table :data="versionList" border size="small" empty-text="ææ åå²çæ¬"> |
| | | <el-table-column prop="versionNo" label="çæ¬" width="70" align="center" /> |
| | | <el-table-column prop="title" label="æ é¢" min-width="160" show-overflow-tooltip /> |
| | | <el-table-column prop="changeNote" label="åæ´è¯´æ" width="120" /> |
| | | <el-table-column prop="publishTime" label="å叿¶é´" width="170" /> |
| | | <el-table-column prop="archivedAt" label="彿¡£æ¶é´" width="170" /> |
| | | <el-table-column label="æä½" width="90" align="center"> |
| | | <template #default="{ row: ver }"> |
| | | <el-button type="primary" link @click="previewVersion(ver)">æ¥ç</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <template #footer> |
| | | <el-button @click="versionDialog.visible = false">å
³ é</el-button> |
| | | </template> |
| | | </el-dialog> |
| | | |
| | | <!-- çæ¬é¢è§ --> |
| | | <el-dialog v-model="versionPreview.visible" title="åå²çæ¬å
容" width="640px" append-to-body> |
| | | <p class="version-meta"> |
| | | v{{ versionPreview.data?.versionNo }} · {{ versionPreview.data?.changeNote }} · |
| | | {{ versionPreview.data?.publishTime }} |
| | | </p> |
| | | <div class="version-html" v-html="versionPreview.data?.contentHtml || ''" /> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { Plus, RefreshRight } from "@element-plus/icons-vue"; |
| | | import { Plus, RefreshRight, Search } from "@element-plus/icons-vue"; |
| | | import { ElMessage } from "element-plus"; |
| | | import { computed, onMounted, reactive, ref } from "vue"; |
| | | import useUserStore from "@/store/modules/user"; |
| | | import Editor from "@/components/Editor/index.vue"; |
| | | import FileUpload from "@/components/AttachmentUpload/file/index.vue"; |
| | | import { newsTypeColor } from "./enterpriseNewsUtils.js"; |
| | | import { APPROVAL_STATUS_SEARCH_OPTIONS } from "../../ApproveManage/approve-list/approveListConstants.js"; |
| | | import ApproveDetailPanel from "../../ApproveManage/approve-list/components/ApproveDetailPanel.vue"; |
| | | import { buildEditFormFromInstanceRow } from "../../ApproveManage/approve-list/approveListConstants.js"; |
| | | import ApprovalTemplateBindDialog from "../../ApproveManage/approve-shared/components/ApprovalTemplateBindDialog.vue"; |
| | | import TemplateFlowEditor from "../../ApproveManage/approve-template/components/TemplateFlowEditor.vue"; |
| | | import { |
| | | applyBindingToForm, |
| | | validateTemplateBinding, |
| | | } from "../../ApproveManage/approve-shared/approvalTemplateBindingUtils.js"; |
| | | import { APPROVAL_MODULE_KEYS } from "../../ApproveManage/approve-shared/approvalModuleRegistry.js"; |
| | | import { useApprovalInstanceModule } from "../../ApproveManage/approve-shared/useApprovalInstanceModule.js"; |
| | | import { useFlowUserOptions } from "../../ApproveManage/approve-shared/useFlowUserOptions.js"; |
| | | import NewsDetailPanel from "./components/NewsDetailPanel.vue"; |
| | | import { useEnterpriseNews } from "./useEnterpriseNews.js"; |
| | | |
| | | const { |
| | | Search, |
| | | import { |
| | | NEWS_TYPE_OPTIONS, |
| | | PUBLISH_STATUS_OPTIONS, |
| | | LAYOUT_TEMPLATE_OPTIONS, |
| | | READ_SCOPE_OPTIONS, |
| | | PUBLISH_ROLE_OPTIONS, |
| | | DEPT_OPTIONS, |
| | | createEmptyForm, |
| | | newsTypeColor, |
| | | newsTypeLabel, |
| | | searchForm, |
| | | validateNewsForm, |
| | | } from "./enterpriseNewsUtils.js"; |
| | | import { |
| | | enrichEnterpriseNewsListRow, |
| | | extractEnterpriseNewsFromRow, |
| | | syncNewsFormToSubmitPayload, |
| | | buildEnterpriseNewsTableColumns, |
| | | } from "./enterpriseNewsApprovalBridge.js"; |
| | | |
| | | const userStore = useUserStore(); |
| | | |
| | | const searchForm = reactive({ |
| | | keyword: "", |
| | | newsType: "", |
| | | status: "", |
| | | createTimeRange: null, |
| | | }); |
| | | |
| | | const newsFormDialog = reactive({ visible: false, title: "", mode: "add", readonly: false }); |
| | | const newsForm = reactive(createEmptyForm()); |
| | | const newsFormRef = ref(); |
| | | const galleryInput = ref(""); |
| | | |
| | | const newsFormRules = { |
| | | title: [{ required: true, message: "请è¾å
¥æ°é»æ é¢", trigger: "blur" }], |
| | | newsType: [{ required: true, message: "è¯·éæ©æ°é»åç±»", trigger: "change" }], |
| | | readScope: [{ required: true, message: "è¯·éæ©é
读èå´", trigger: "change" }], |
| | | }; |
| | | |
| | | const mod = useApprovalInstanceModule({ |
| | | moduleKey: APPROVAL_MODULE_KEYS.ENTERPRISE_NEWS, |
| | | enrichListRow: enrichEnterpriseNewsListRow, |
| | | buildExtraListParams(sf) { |
| | | const extra = {}; |
| | | const kw = (sf?.keyword || "").trim(); |
| | | if (kw) extra.title = kw; |
| | | if (sf?.newsType) extra.newsType = sf.newsType; |
| | | return extra; |
| | | }, |
| | | async beforeSave(submitForm) { |
| | | const v = validateNewsForm(newsForm); |
| | | if (!v.ok) { |
| | | ElMessage.warning(v.message); |
| | | throw new Error(v.message); |
| | | } |
| | | if (!activeTemplate.value) { |
| | | ElMessage.warning("请å
éæ©å®¡æ¹æ¨¡æ¿"); |
| | | throw new Error("no template"); |
| | | } |
| | | const bindingCheck = validateTemplateBinding({ flowNodes: submitForm.flowNodes }); |
| | | if (!bindingCheck.ok) { |
| | | ElMessage.warning(bindingCheck.message); |
| | | throw new Error(bindingCheck.message); |
| | | } |
| | | syncNewsFormToSubmitPayload(newsForm, submitForm); |
| | | }, |
| | | }); |
| | | |
| | | const { |
| | | tableData, |
| | | tableLoading, |
| | | page, |
| | | tableData, |
| | | tableColumn, |
| | | formDialog, |
| | | form, |
| | | formRef, |
| | | formRules, |
| | | detailDialog, |
| | | detailRow, |
| | | unreadDialog, |
| | | unreadList, |
| | | versionDialog, |
| | | getUnreadEmployees, |
| | | submitDialog, |
| | | submitForm, |
| | | submitSaving, |
| | | isSubmitEdit, |
| | | activeTemplate, |
| | | templateBindVisible, |
| | | pendingTemplateBinding, |
| | | submitEditRow, |
| | | handleQuery, |
| | | resetSearch, |
| | | initModuleList, |
| | | pagination, |
| | | openFormDialog, |
| | | openDetail, |
| | | openUnreadRemind, |
| | | openVersionHistory, |
| | | saveForm, |
| | | sendUnreadRemind, |
| | | toggleLike, |
| | | addComment, |
| | | } = useEnterpriseNews(); |
| | | openAddWithTemplate, |
| | | onTemplateBound, |
| | | resetSubmitForm, |
| | | submitInstanceForm, |
| | | removeInstance, |
| | | canEditBusinessInstanceRow, |
| | | } = mod; |
| | | |
| | | const galleryInput = ref(""); |
| | | const unreadSelected = ref([]); |
| | | const versionPreview = reactive({ visible: false, data: null }); |
| | | const { flowUserOptions, loadFlowUsers } = useFlowUserOptions(); |
| | | |
| | | const versionList = computed(() => { |
| | | const row = versionDialog.row; |
| | | if (!row) return []; |
| | | const history = [...(row.versions || [])]; |
| | | return history.sort((a, b) => (b.versionNo || 0) - (a.versionNo || 0)); |
| | | const detailNewsRow = computed(() => { |
| | | if (!detailRow.value?.id) return {}; |
| | | return extractEnterpriseNewsFromRow(detailRow.value); |
| | | }); |
| | | |
| | | const tableColumn = ref( |
| | | buildEnterpriseNewsTableColumns(() => [ |
| | | { name: "详æ
", type: "text", clickFun: (row) => openNewsDetail(row) }, |
| | | { |
| | | name: "ä¿®æ¹", |
| | | type: "text", |
| | | disabled: (row) => !canEditBusinessInstanceRow(row), |
| | | clickFun: (row) => openNewsEdit(row), |
| | | }, |
| | | { |
| | | name: "å é¤", |
| | | type: "danger", |
| | | clickFun: (row) => removeInstance(row), |
| | | }, |
| | | ]) |
| | | ); |
| | | |
| | | function resetNewsForm(target = createEmptyForm()) { |
| | | Object.assign(newsForm, createEmptyForm(), target); |
| | | } |
| | | |
| | | function openNewsFormDialog(mode, row) { |
| | | newsFormDialog.mode = mode; |
| | | newsFormDialog.readonly = mode === "view"; |
| | | newsFormDialog.title = |
| | | mode === "add" ? "æ°å»ºä¼ä¸æ°é»" : mode === "edit" ? "ç¼è¾ä¼ä¸æ°é»" : "æ¥çä¼ä¸æ°é»"; |
| | | if (mode === "add") { |
| | | resetNewsForm({ |
| | | publisherName: userStore?.nickName || userStore?.name || "å½åç¨æ·", |
| | | }); |
| | | } else if (row) { |
| | | resetNewsForm(extractEnterpriseNewsFromRow(row)); |
| | | } |
| | | newsFormDialog.visible = true; |
| | | } |
| | | |
| | | function onTemplateBindClosed() { |
| | | const binding = pendingTemplateBinding.value; |
| | | if (!binding) return; |
| | | pendingTemplateBinding.value = null; |
| | | resetSubmitForm(); |
| | | applyBindingToForm(submitForm, binding); |
| | | submitDialog.mode = "add"; |
| | | submitEditRow.value = null; |
| | | openNewsFormDialog("add"); |
| | | } |
| | | |
| | | function openNewsEdit(row) { |
| | | if (!canEditBusinessInstanceRow(row)) { |
| | | ElMessage.warning("è¿è¡ä¸æå·²å®æç审æ¹ä¸å¯ä¿®æ¹"); |
| | | return; |
| | | } |
| | | submitDialog.mode = "edit"; |
| | | submitEditRow.value = { ...row }; |
| | | Object.assign(submitForm, buildEditFormFromInstanceRow(row)); |
| | | openNewsFormDialog("edit", row); |
| | | } |
| | | |
| | | function openNewsDetail(row) { |
| | | detailRow.value = { ...row }; |
| | | detailDialog.visible = true; |
| | | } |
| | | |
| | | function openNewsEditFromDetail() { |
| | | const row = detailRow.value; |
| | | detailDialog.visible = false; |
| | | openNewsEdit(row); |
| | | } |
| | | |
| | | function onNewsFormClosed() { |
| | | newsFormRef.value?.resetFields?.(); |
| | | } |
| | | |
| | | function addGalleryItem() { |
| | | const name = (galleryInput.value || "").trim(); |
| | | if (!name) return; |
| | | form.mediaList = form.mediaList || []; |
| | | form.mediaList.push({ type: "image", name, url: "" }); |
| | | newsForm.mediaList = newsForm.mediaList || []; |
| | | newsForm.mediaList.push({ type: "image", name, url: "" }); |
| | | galleryInput.value = ""; |
| | | } |
| | | |
| | | function onSave(action) { |
| | | const ret = saveForm(action); |
| | | if (ret?.message) { |
| | | ElMessage.warning(ret.message); |
| | | async function onNewsSave(action = "submit_review") { |
| | | try { |
| | | await newsFormRef.value?.validate(); |
| | | } catch { |
| | | ElMessage.warning("请å®å表åå¿
填项ååä¿å"); |
| | | return; |
| | | } |
| | | if (ret?.ok) { |
| | | ElMessage.success(action === "publish" ? "å·²åå¸" : action === "submit_review" ? "å·²æäº¤å®¡æ ¸" : "å·²ä¿å"); |
| | | if (action === "draft") newsForm.publishStatus = "draft"; |
| | | else newsForm.publishStatus = "pending_review"; |
| | | const ok = await submitInstanceForm({ skipValidate: true }); |
| | | if (ok) { |
| | | newsFormDialog.visible = false; |
| | | const msg = |
| | | action === "draft" ? "å·²ä¿åè稿" : isSubmitEdit.value ? "ä¿®æ¹æå" : "å·²æäº¤å®¡æ ¸"; |
| | | ElMessage.success(msg); |
| | | } |
| | | } |
| | | |
| | | function onSearch() { |
| | | handleQuery(searchForm); |
| | | } |
| | | |
| | | function resetSearch() { |
| | | searchForm.keyword = ""; |
| | | searchForm.newsType = ""; |
| | | searchForm.status = ""; |
| | | searchForm.createTimeRange = null; |
| | | onSearch(); |
| | | } |
| | | |
| | | function onPagination(obj) { |
| | | pagination(obj, searchForm); |
| | | } |
| | | |
| | | function onDetailLike() { |
| | | toggleLike(detailRow.value); |
| | | /* 详æ
äºå¨ä»èµ°è¡å
æ°æ®ï¼å·æ°åè¡¨åæ´æ° */ |
| | | } |
| | | |
| | | function onDetailComment(text) { |
| | | const ret = addComment(detailRow.value, text); |
| | | if (ret?.message) ElMessage.warning(ret.message); |
| | | else if (ret?.ok) ElMessage.success("è¯è®ºå·²åå¸"); |
| | | function onDetailComment() { |
| | | ElMessage.info("è¯è®ºå·²è®°å½ï¼æ¼ç¤ºï¼"); |
| | | } |
| | | |
| | | function openUnreadFromDetail() { |
| | | const row = detailRow.value; |
| | | detailDialog.visible = false; |
| | | openUnreadRemind(row); |
| | | } |
| | | |
| | | function openVersionFromDetail() { |
| | | const row = detailRow.value; |
| | | detailDialog.visible = false; |
| | | openVersionHistory(row); |
| | | } |
| | | |
| | | function onUnreadSelectionChange(rows) { |
| | | unreadSelected.value = rows.map((r) => r.userId); |
| | | } |
| | | |
| | | function selectAllUnread() { |
| | | unreadSelected.value = unreadList.value.map((u) => u.userId); |
| | | } |
| | | |
| | | function onSendRemind() { |
| | | const ids = unreadSelected.value; |
| | | const ret = sendUnreadRemind(ids); |
| | | if (ret?.message) { |
| | | ElMessage.warning(ret.message); |
| | | return; |
| | | } |
| | | if (ret?.ok) ElMessage.success(`å·²å ${ret.count} ååå·¥åéé
读æé`); |
| | | } |
| | | |
| | | function previewVersion(ver) { |
| | | versionPreview.data = ver; |
| | | versionPreview.visible = true; |
| | | } |
| | | |
| | | onMounted(() => { |
| | | handleQuery(); |
| | | onMounted(async () => { |
| | | loadFlowUsers(); |
| | | await initModuleList(searchForm); |
| | | }); |
| | | </script> |
| | | |
| | |
| | | .search_actions { |
| | | flex-shrink: 0; |
| | | } |
| | | .search_title { |
| | | font-size: 14px; |
| | | color: var(--el-text-color-regular); |
| | | } |
| | | .news-type-tag { |
| | | font-weight: 600; |
| | | font-size: 13px; |
| | |
| | | .media-tag { |
| | | margin: 6px 8px 0 0; |
| | | } |
| | | .unread-toolbar { |
| | | display: flex; |
| | | align-items: center; |
| | | gap: 12px; |
| | | .template-name { |
| | | font-weight: 600; |
| | | color: var(--el-text-color-primary); |
| | | } |
| | | .unread-stat { |
| | | .section-tip { |
| | | font-size: 12px; |
| | | color: var(--el-text-color-secondary); |
| | | font-size: 13px; |
| | | margin: 8px 0 0; |
| | | line-height: 1.5; |
| | | } |
| | | .version-meta { |
| | | color: var(--el-text-color-secondary); |
| | | font-size: 13px; |
| | | margin-bottom: 12px; |
| | | } |
| | | .version-html { |
| | | padding: 12px; |
| | | background: var(--el-fill-color-light); |
| | | border-radius: 6px; |
| | | max-height: 400px; |
| | | overflow-y: auto; |
| | | } |
| | | .mb16 { |
| | | margin-bottom: 16px; |
| | | } |
| | | .mb12 { |
| | | margin-bottom: 12px; |
| | | .mb20 { |
| | | margin-bottom: 20px; |
| | | } |
| | | .ml10 { |
| | | margin-left: 10px; |
| | |
| | | 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> |
| | |
| | | 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="transfer-apply-form-dialog" |
| | | @closed="onFormClosed" |
| | | > |
| | | <el-form ref="formRef" :model="form" :rules="formRules" label-width="140px" class="transfer-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="templateDisplayFields" :form-payload="form.formPayload" /> |
| | | <el-row :gutter="24"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="åå²ä½" prop="originalPostName"> |
| | | <el-input v-model="form.originalPostName" placeholder="éæ©ç³è¯·äººåèªå¨å¸¦åº" disabled /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <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" |
| | | :is-edit="isSubmitEdit" |
| | | :saving="submitSaving" |
| | | :form-ref="submitFormRef" |
| | | flow-attachments-only |
| | | hide-template-name |
| | | :allow-change-template="false" |
| | | /> |
| | | </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> |
| | | @submit="onSubmit" |
| | | > |
| | | <template #before="{ form, fields }"> |
| | | <FormPayloadFields :fields="displayTemplateFields(fields)" :form-payload="form.formPayload" /> |
| | | <el-form-item label="åå²ä½"> |
| | | <el-input :model-value="originalPostName" placeholder="éæ©ç³è¯·äººåèªå¨å¸¦åº" disabled /> |
| | | </el-form-item> |
| | | </template> |
| | | </el-dialog> |
| | | </ApprovalInstanceSubmitDialog> |
| | | |
| | | <ApprovalTemplateBindDialog |
| | | v-model:visible="templateBindVisible" |
| | |
| | | @closed="onTemplateBindClosed" |
| | | /> |
| | | |
| | | <!-- 详æ
--> |
| | | <el-dialog v-model="detailDialog.visible" title="è°å²ç³è¯·è¯¦æ
" width="560px" append-to-body> |
| | | <el-descriptions :column="1" border> |
| | | <el-descriptions-item label="ç³è¯·äºº">{{ detailRow.applicantName }}</el-descriptions-item> |
| | | <el-descriptions-item label="è½¬å²æ¥æ">{{ detailRow.transferDate }}</el-descriptions-item> |
| | | <el-descriptions-item label="åå²ä½">{{ detailRow.originalPostName }}</el-descriptions-item> |
| | | <el-descriptions-item label="转å
¥å²ä½">{{ detailRow.targetPostName }}</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> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="detailDialog.visible = false">å
³ é</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | <ApprovalInstanceDetailDialog |
| | | v-model="detailDialog.visible" |
| | | title="è°å²ç³è¯·è¯¦æ
" |
| | | :row="detailRow" |
| | | @edit="openEditFromDetail" |
| | | /> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { findPostOptions } from "@/api/system/post.js"; |
| | | import { userListNoPageByTenantId } from "@/api/system/user.js"; |
| | | import { computed, getCurrentInstance, nextTick, onMounted, reactive, ref, watch } from "vue"; |
| | | import ApprovalTemplateBindDialog from "../../ApproveManage/approve-shared/components/ApprovalTemplateBindDialog.vue"; |
| | | import ApprovalTemplateFormSection from "../../ApproveManage/approve-shared/components/ApprovalTemplateFormSection.vue"; |
| | | import { ElMessage } from "element-plus"; |
| | | import { computed, onMounted, reactive, ref, watch } from "vue"; |
| | | import FormPayloadFields from "../../ApproveManage/approve-list/components/FormPayloadFields.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 { 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"; |
| | | import { SELECT_OPTION_SOURCE } from "../../ApproveManage/approve-template/selectOptionSource.js"; |
| | | |
| | | const { proxy } = getCurrentInstance(); |
| | | |
| | | /** ä¸å端约å®åæ®µï¼æ¬å°å ä½ï¼åææ¥å£å¯¹é½ï¼ */ |
| | | const createEmptyForm = () => ({ |
| | | id: undefined, |
| | | applicantId: "", |
| | | applicantName: "", |
| | | transferDate: "", |
| | | originalPostId: "", |
| | | originalPostName: "", |
| | | targetPostId: "", |
| | | targetPostName: "", |
| | | hasTemplateBinding: false, |
| | | templateId: "", |
| | | templateName: "", |
| | | templateSnapshot: null, |
| | | formFieldDefs: [], |
| | | formPayload: {}, |
| | | flowNodes: [], |
| | | templateAttachments: [], |
| | | storageBlobDTOs: [], |
| | | }); |
| | | |
| | | function isOriginalPostField(field) { |
| | | const label = String(field?.label || ""); |
| | |
| | | ); |
| | | } |
| | | |
| | | function displayTemplateFields(fields = []) { |
| | | return (fields || []).filter((f) => !isOriginalPostField(f)); |
| | | } |
| | | |
| | | function findApplicantTemplateField(fields = []) { |
| | | return ( |
| | | fields.find((f) => String(f?.label || "").includes("ç³è¯·äºº")) || |
| | |
| | | ); |
| | | } |
| | | |
| | | function syncApplicantFromUser(uid) { |
| | | const u = userById(uid); |
| | | if (u) { |
| | | form.applicantId = uid != null && uid !== "" ? uid : ""; |
| | | form.applicantName = u.nickName || u.userName || ""; |
| | | const { originalPostId, originalPostName } = resolveOriginalPost(u); |
| | | form.originalPostId = originalPostId; |
| | | form.originalPostName = originalPostName; |
| | | } else { |
| | | form.applicantId = ""; |
| | | form.applicantName = ""; |
| | | form.originalPostId = ""; |
| | | form.originalPostName = ""; |
| | | } |
| | | } |
| | | const searchForm = reactive({ |
| | | applicantId: "", |
| | | transferDateRange: null, |
| | | }); |
| | | |
| | | /** ç³»ç»ç¨æ·ç¼åï¼/system/user/userListNoPageByTenantIdï¼ä¸è½¬æ£ç³è¯·çä¸è´ï¼ */ |
| | | const mod = useApprovalInstanceModule({ |
| | | moduleKey: APPROVAL_MODULE_KEYS.TRANSFER, |
| | | buildExtraListParams(sf) { |
| | | const range = sf?.transferDateRange; |
| | | if (Array.isArray(range) && range[0]) { |
| | | return { createTime: range[0], createTimeEnd: range[1] }; |
| | | } |
| | | return {}; |
| | | }, |
| | | }); |
| | | |
| | | 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 { flowUserOptions, loadFlowUsers } = useFlowUserOptions(); |
| | | |
| | | const allUsersCache = ref([]); |
| | | /** å²ä½åå
¸ postId -> postNameï¼/system/post/optionselectï¼ä¸å工档æ¡å
¥è表åä¸è´ï¼ */ |
| | | const postIdToName = ref({}); |
| | | const targetPostOptions = ref([]); |
| | | const applicantSearchLoading = ref(false); |
| | | const applicantSearchOptions = ref([]); |
| | | const originalPostName = ref(""); |
| | | |
| | | function rebuildPostIdMap() { |
| | | const m = {}; |
| | | for (const p of targetPostOptions.value || []) { |
| | | const id = p.postId ?? p.value ?? p.id; |
| | | if (id != null && id !== "") m[String(id)] = p.postName ?? p.label ?? ""; |
| | | } |
| | | postIdToName.value = m; |
| | | } |
| | | |
| | | function targetPostNameById(postId) { |
| | | if (postId == null || postId === "") return ""; |
| | | const k = String(postId); |
| | | return ( |
| | | postIdToName.value[k] || |
| | | targetPostOptions.value.find((x) => String(x.postId ?? x.id ?? x.value) === k)?.postName || |
| | | "" |
| | | const applicantTemplateField = computed(() => |
| | | findApplicantTemplateField(submitForm.formFieldDefs) |
| | | ); |
| | | |
| | | function unwrapArray(payload) { |
| | | if (Array.isArray(payload)) return payload; |
| | | if (payload && Array.isArray(payload.data)) return payload.data; |
| | | if (payload && Array.isArray(payload.rows)) return payload.rows; |
| | | return []; |
| | | } |
| | | |
| | | function isActiveUser(u) { |
| | | if (u.delFlag === "2" || u.delFlag === 2) return false; |
| | | if (u.status == null) return true; |
| | | return String(u.status) === "0"; |
| | | } |
| | | |
| | | function userSelectLabel(u) { |
| | |
| | | return undefined; |
| | | } |
| | | |
| | | /** ä»ç¨æ·å¯¹è±¡è§£æãåå²ä½ãï¼å
¼å®¹ postName / postIds / posts ç常è§è¿åï¼ */ |
| | | function resolveOriginalPost(user) { |
| | | if (!user) return { originalPostId: "", originalPostName: "" }; |
| | | if (!user) return { originalPostName: "" }; |
| | | const nameStr = (user.postName ?? user.postname ?? "").toString().trim(); |
| | | if (nameStr) { |
| | | const pid = firstPostId(user); |
| | | return { originalPostId: pid != null && pid !== "" ? String(pid) : "", originalPostName: nameStr }; |
| | | } |
| | | if (nameStr) return { originalPostName: nameStr }; |
| | | if (Array.isArray(user.posts) && user.posts.length) { |
| | | const p0 = user.posts[0]; |
| | | return { |
| | | originalPostId: p0.postId != null ? String(p0.postId) : "", |
| | | originalPostName: (p0.postName ?? "").toString() || "æªå½åå²ä½", |
| | | }; |
| | | return { originalPostName: (user.posts[0].postName ?? "").toString() || "æªå½åå²ä½" }; |
| | | } |
| | | const pid = firstPostId(user); |
| | | if (pid != null && pid !== "") { |
| | | const n = postIdToName.value[String(pid)] || ""; |
| | | return { |
| | | originalPostId: String(pid), |
| | | originalPostName: n || "å½åå²ä½ï¼æªå¨å²ä½åå
¸ä¸ï¼", |
| | | }; |
| | | return { originalPostName: n || "å½åå²ä½ï¼æªå¨å²ä½åå
¸ä¸ï¼" }; |
| | | } |
| | | return { originalPostId: "", originalPostName: "æªåé
å²ä½" }; |
| | | return { originalPostName: "æªåé
å²ä½" }; |
| | | } |
| | | |
| | | function userById(id) { |
| | |
| | | } catch { |
| | | targetPostOptions.value = []; |
| | | } |
| | | rebuildPostIdMap(); |
| | | const m = {}; |
| | | for (const p of targetPostOptions.value) { |
| | | const id = p.postId ?? p.value ?? p.id; |
| | | if (id != null && id !== "") m[String(id)] = p.postName ?? p.label ?? ""; |
| | | } |
| | | |
| | | /** æ¥è¯¢åºï¼ä¸æè¿ç¨æ¨¡ç³ï¼æ°æ®æ¥èª userListNoPageByTenantIdï¼åç«¯è¿æ»¤ï¼ */ |
| | | const applicantSearchLoading = ref(false); |
| | | const applicantSearchOptions = ref([]); |
| | | postIdToName.value = m; |
| | | } |
| | | |
| | | async function remoteSearchApplicant(query) { |
| | | applicantSearchLoading.value = true; |
| | | try { |
| | | if (!allUsersCache.value.length) { |
| | | await loadUserPool(); |
| | | } |
| | | if (!allUsersCache.value.length) await loadUserPool(); |
| | | applicantSearchOptions.value = filterUsersByQuery(query); |
| | | } finally { |
| | | applicantSearchLoading.value = false; |
| | | } |
| | | } |
| | | |
| | | |
| | | function unwrapArray(payload) { |
| | | if (Array.isArray(payload)) return payload; |
| | | if (payload && Array.isArray(payload.data)) return payload.data; |
| | | if (payload && Array.isArray(payload.rows)) return payload.rows; |
| | | return []; |
| | | function syncOriginalPostFromApplicant(uid) { |
| | | const u = userById(uid); |
| | | originalPostName.value = resolveOriginalPost(u).originalPostName; |
| | | } |
| | | |
| | | function isActiveUser(u) { |
| | | if (u.delFlag === "2" || u.delFlag === 2) return false; |
| | | if (u.status == null) return true; |
| | | return String(u.status) === "0"; |
| | | } |
| | | |
| | | 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({ |
| | | applicantId: "", |
| | | transferDateRange: null, |
| | | }); |
| | | |
| | | const tableLoading = ref(false); |
| | | const page = reactive({ |
| | | current: 1, |
| | | size: 10, |
| | | total: 0, |
| | | }); |
| | | |
| | | const filteredList = computed(() => { |
| | | let list = [...allRows.value]; |
| | | if (searchForm.applicantId) { |
| | | list = list.filter((r) => String(r.applicantId) === String(searchForm.applicantId)); |
| | | } |
| | | const range = searchForm.transferDateRange; |
| | | if (range && range.length === 2) { |
| | | const [start, end] = range; |
| | | list = list.filter((r) => r.transferDate >= start && r.transferDate <= end); |
| | | } |
| | | return list.sort((a, b) => (a.transferDate < b.transferDate ? 1 : -1)); |
| | | }); |
| | | |
| | | 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 = 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: "transferDate", width: 120 }, |
| | | { label: "åå²ä½", prop: "originalPostName", minWidth: 140 }, |
| | | { label: "转å
¥å²ä½", prop: "targetPostName", minWidth: 160 }, |
| | | { |
| | | 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: 180, |
| | | operation: [ |
| | | { name: "ç¼è¾", type: "text", clickFun: (row) => openFormDialog("edit", row) }, |
| | | { name: "æ¥ç详æ
", type: "text", clickFun: (row) => openDetail(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 templateDisplayFields = computed(() => |
| | | (form.formFieldDefs || []).filter((f) => !isOriginalPostField(f)) |
| | | ); |
| | | |
| | | const applicantTemplateField = computed(() => findApplicantTemplateField(form.formFieldDefs)); |
| | | |
| | | const formRules = computed(() => ({ |
| | | ...buildFormPayloadRules(templateDisplayFields.value), |
| | | originalPostName: [{ required: true, message: "è¯·éæ©ç³è¯·äººä»¥å¸¦åºåå²ä½", trigger: "change" }], |
| | | })); |
| | | |
| | | watch( |
| | | () => { |
| | | const key = applicantTemplateField.value?.key; |
| | | return key ? form.formPayload[key] : undefined; |
| | | return key ? submitForm.formPayload[key] : undefined; |
| | | }, |
| | | async (uid) => { |
| | | if (!allUsersCache.value.length) { |
| | | await loadUserPool(); |
| | | } |
| | | syncApplicantFromUser(uid); |
| | | if (!applicantTemplateField.value) return; |
| | | if (!allUsersCache.value.length) await loadUserPool(); |
| | | syncOriginalPostFromApplicant(uid); |
| | | } |
| | | ); |
| | | |
| | | const detailDialog = reactive({ visible: false }); |
| | | const detailRow = ref({}); |
| | | watch( |
| | | () => submitDialog.visible, |
| | | async (v) => { |
| | | if (!v) return; |
| | | const key = applicantTemplateField.value?.key; |
| | | if (key && submitForm.formPayload[key]) { |
| | | syncOriginalPostFromApplicant(submitForm.formPayload[key]); |
| | | } |
| | | } |
| | | ); |
| | | |
| | | function handleQuery() { |
| | | page.current = 1; |
| | | tableLoading.value = true; |
| | | setTimeout(() => { |
| | | tableLoading.value = false; |
| | | }, 150); |
| | | const tableColumn = buildInstanceTableColumns(tableData, buildTableActions); |
| | | |
| | | function onSearch() { |
| | | handleQuery(searchForm); |
| | | } |
| | | |
| | | async function resetSearch() { |
| | | searchForm.applicantId = ""; |
| | | searchForm.transferDateRange = null; |
| | | handleQuery(); |
| | | onSearch(); |
| | | await remoteSearchApplicant(""); |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | |
| | | function openAddWithTemplate() { |
| | | formDialog.visible = false; |
| | | pendingTemplateBinding.value = null; |
| | | templateBindVisible.value = true; |
| | | } |
| | | |
| | | function onTemplateBound(binding) { |
| | | pendingTemplateBinding.value = binding; |
| | | } |
| | | |
| | | async function onTemplateBindClosed() { |
| | | const binding = pendingTemplateBinding.value; |
| | | if (!binding) return; |
| | | pendingTemplateBinding.value = null; |
| | | await openFormWithBinding(binding); |
| | | } |
| | | |
| | | async function openFormWithBinding(binding) { |
| | | Object.assign(form, createEmptyForm()); |
| | | applyBindingToForm(form, binding); |
| | | form.hasTemplateBinding = true; |
| | | formDialog.mode = "add"; |
| | | formDialog.title = "æ°å¢è°å²ç³è¯·"; |
| | | await Promise.all([loadUserPool(), loadPostOptions(), loadFlowUsers()]); |
| | | const applicantKey = applicantTemplateField.value?.key; |
| | | if (applicantKey && form.formPayload[applicantKey]) { |
| | | syncApplicantFromUser(form.formPayload[applicantKey]); |
| | | } |
| | | formDialog.visible = true; |
| | | nextTick(() => formRef.value?.clearValidate?.()); |
| | | } |
| | | |
| | | function reopenTemplateBind() { |
| | | formDialog.visible = false; |
| | | pendingTemplateBinding.value = null; |
| | | templateBindVisible.value = true; |
| | | } |
| | | |
| | | async 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, |
| | | applicantId: row.applicantId, |
| | | applicantName: row.applicantName, |
| | | transferDate: row.transferDate, |
| | | originalPostId: row.originalPostId, |
| | | originalPostName: row.originalPostName, |
| | | targetPostId: row.targetPostId, |
| | | targetPostName: row.targetPostName, |
| | | 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 || [])), |
| | | }); |
| | | await loadUserPool(); |
| | | const applicantKey = applicantTemplateField.value?.key; |
| | | if (applicantKey) { |
| | | syncApplicantFromUser(form.formPayload[applicantKey]); |
| | | } |
| | | 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; |
| | | const applicantKey = applicantTemplateField.value?.key; |
| | | if (applicantKey) { |
| | | syncApplicantFromUser(form.formPayload[applicantKey]); |
| | | } |
| | | syncTransferFieldsFromPayload(); |
| | | form.targetPostName = targetPostNameById(form.targetPostId); |
| | | const payload = { |
| | | applicantId: form.applicantId, |
| | | applicantName: form.applicantName, |
| | | transferDate: form.transferDate, |
| | | originalPostId: form.originalPostId, |
| | | originalPostName: form.originalPostName, |
| | | targetPostId: form.targetPostId, |
| | | targetPostName: form.targetPostName, |
| | | 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); |
| | | const prev = idx !== -1 ? allRows.value[idx] : {}; |
| | | if (idx !== -1) { |
| | | allRows.value[idx] = { |
| | | ...prev, |
| | | id: form.id, |
| | | ...payload, |
| | | }; |
| | | } |
| | | proxy?.$modal?.msgSuccess?.("ä¿åæå"); |
| | | } |
| | | formDialog.visible = false; |
| | | handleQuery(); |
| | | } |
| | | |
| | | /** 仿¨¡æ¿å¡«æ¥é¡¹åæ¥è½¬å²æ¥æã转å
¥å²ä½å°åè¡¨åæ®µ */ |
| | | function syncTransferFieldsFromPayload() { |
| | | 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("æ¥æ") || label.includes("æ¶é´")) && f.type === "date") { |
| | | form.transferDate = val || ""; |
| | | } |
| | | if (label.includes("转å
¥å²ä½") && f.type === "select") { |
| | | form.targetPostId = val != null && val !== "" ? val : ""; |
| | | form.targetPostName = targetPostNameById(form.targetPostId); |
| | | } |
| | | } |
| | | async function onSubmit() { |
| | | const ok = await submitInstanceForm({ skipValidate: true }); |
| | | if (ok) ElMessage.success(isSubmitEdit.value ? "ä¿®æ¹æå" : "æäº¤æå"); |
| | | } |
| | | |
| | | onMounted(async () => { |
| | | await Promise.all([loadUserPool(), loadPostOptions()]); |
| | | rebuildPostIdMap(); |
| | | loadFlowUsers(); |
| | | await remoteSearchApplicant(""); |
| | | await initModuleList(searchForm); |
| | | }); |
| | | </script> |
| | | |
| | |
| | | .search_title { |
| | | font-size: 14px; |
| | | color: var(--el-text-color-regular); |
| | | } |
| | | .transfer-apply-form :deep(.el-row) { |
| | | margin-bottom: 0; |
| | | } |
| | | .transfer-apply-form :deep(.el-form-item) { |
| | | margin-bottom: 18px; |
| | | } |
| | | .transfer-apply-form-dialog :deep(.el-dialog__body) { |
| | | padding-top: 12px; |
| | | } |
| | | .template-name { |
| | | font-weight: 600; |
| | | color: var(--el-text-color-primary); |
| | | } |
| | | .ml12 { |
| | | margin-left: 12px; |
| | | } |
| | | </style> |
| | |
| | | <el-select v-model="searchForm.handoverType" placeholder="å
¨é¨" clearable style="width: 140px"> |
| | | <el-option v-for="o in handoverTypeOptions" :key="o.value" :label="o.label" :value="o.value" /> |
| | | </el-select> |
| | | <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="work-handover-form-dialog" |
| | | @closed="onFormClosed" |
| | | > |
| | | <el-form ref="formRef" :model="form" :rules="formRules" label-width="140px" class="work-handover-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" :columns="2" /> |
| | | <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="560px" append-to-body> |
| | | <el-descriptions :column="1" border> |
| | | <el-descriptions-item label="ç³è¯·äºº">{{ detailRow.applicantName }}</el-descriptions-item> |
| | | <el-descriptions-item label="ç¦»èæ¥æ">{{ detailRow.leaveDate || "â" }}</el-descriptions-item> |
| | | <el-descriptions-item label="交æ¥ç¶æ">{{ handoverStatusLabel(detailRow.handoverStatus) }}</el-descriptions-item> |
| | | <el-descriptions-item label="交æ¥ç±»å">{{ handoverTypeLabel(detailRow.handoverType) }}</el-descriptions-item> |
| | | <el-descriptions-item label="交æ¥äºº">{{ detailRow.handoverPersonName || "â" }}</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> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="detailDialog.visible = false">å
³ é</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | <ApprovalInstanceDetailDialog |
| | | v-model="detailDialog.visible" |
| | | title="å·¥ä½äº¤æ¥è¯¦æ
" |
| | | :row="detailRow" |
| | | @edit="openEditFromDetail" |
| | | /> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { userListNoPageByTenantId } from "@/api/system/user.js"; |
| | | import { computed, getCurrentInstance, nextTick, onMounted, reactive, ref, watch } from "vue"; |
| | | import { ElMessage } from "element-plus"; |
| | | import { onMounted, reactive, ref } 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 { proxy } = getCurrentInstance(); |
| | | |
| | | const handoverStatusOptions = [ |
| | | { value: "in_progress", label: "è¿è¡ä¸" }, |
| | |
| | | { value: "transfer", label: "è°å²äº¤æ¥" }, |
| | | ]; |
| | | |
| | | function handoverStatusLabel(v) { |
| | | return handoverStatusOptions.find((o) => o.value === v)?.label || "â"; |
| | | } |
| | | |
| | | function handoverTypeLabel(v) { |
| | | return handoverTypeOptions.find((o) => o.value === v)?.label || "â"; |
| | | } |
| | | |
| | | /** ä¸å端约å®åæ®µï¼æ¬å°å ä½ï¼åææ¥å£å¯¹é½ï¼ */ |
| | | const createEmptyForm = () => ({ |
| | | id: undefined, |
| | | const searchForm = reactive({ |
| | | applicantId: "", |
| | | applicantName: "", |
| | | leaveDate: "", |
| | | handoverStatus: "in_progress", |
| | | handoverType: "resignation", |
| | | handoverPersonId: "", |
| | | handoverPersonName: "", |
| | | hasTemplateBinding: false, |
| | | templateId: "", |
| | | templateName: "", |
| | | templateSnapshot: null, |
| | | formFieldDefs: [], |
| | | formPayload: {}, |
| | | flowNodes: [], |
| | | templateAttachments: [], |
| | | storageBlobDTOs: [], |
| | | handoverStatus: "", |
| | | handoverType: "", |
| | | }); |
| | | |
| | | const mod = useApprovalInstanceModule({ |
| | | moduleKey: APPROVAL_MODULE_KEYS.WORK_HANDOVER, |
| | | }); |
| | | |
| | | 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 { flowUserOptions, loadFlowUsers } = useFlowUserOptions(); |
| | | |
| | | const allUsersCache = ref([]); |
| | | |
| | | function userSelectLabel(u) { |
| | | const nick = u.nickName || ""; |
| | | const name = u.userName || ""; |
| | | if (nick && name && nick !== name) return `${nick}ï¼${name}ï¼`; |
| | | return nick || name || `ç¨æ·${u.userId ?? u.id ?? ""}`; |
| | | } |
| | | |
| | | function userById(id) { |
| | | if (id == null || id === "") return undefined; |
| | | return allUsersCache.value.find((u) => String(u.userId ?? u.id) === String(id)); |
| | | } |
| | | |
| | | function filterUsersByQuery(query) { |
| | | const list = allUsersCache.value.filter((u) => isActiveUser(u)); |
| | | const q = (query || "").trim().toLowerCase(); |
| | | if (!q) return [...list]; |
| | | return list.filter((u) => { |
| | | const nick = (u.nickName || "").toLowerCase(); |
| | | const uname = (u.userName || "").toLowerCase(); |
| | | const phone = (u.phonenumber || u.phone || "").toString(); |
| | | return nick.includes(q) || uname.includes(q) || phone.includes(q); |
| | | }); |
| | | } |
| | | |
| | | async function loadUserPool() { |
| | | try { |
| | | const res = await userListNoPageByTenantId(); |
| | | allUsersCache.value = unwrapArray(res); |
| | | } catch { |
| | | allUsersCache.value = []; |
| | | } |
| | | } |
| | | |
| | | const applicantSearchLoading = ref(false); |
| | | const applicantSearchOptions = ref([]); |
| | | |
| | | async function remoteSearchApplicant(query) { |
| | | applicantSearchLoading.value = true; |
| | | try { |
| | | if (!allUsersCache.value.length) { |
| | | await loadUserPool(); |
| | | } |
| | | applicantSearchOptions.value = filterUsersByQuery(query); |
| | | } finally { |
| | | applicantSearchLoading.value = false; |
| | | } |
| | | } |
| | | const applicantSearchLoading = ref(false); |
| | | |
| | | function unwrapArray(payload) { |
| | | if (Array.isArray(payload)) return payload; |
| | |
| | | return String(u.status) === "0"; |
| | | } |
| | | |
| | | function approvalModeLabel(mode) { |
| | | if (mode === "countersign") return "ä¼ç¾"; |
| | | return "ä¸ç¾"; |
| | | function userSelectLabel(u) { |
| | | const nick = u.nickName || ""; |
| | | const name = u.userName || ""; |
| | | if (nick && name && nick !== name) return `${nick}ï¼${name}ï¼`; |
| | | return nick || name || `ç¨æ·${u.userId ?? u.id ?? ""}`; |
| | | } |
| | | |
| | | function approvalResultLabel(v) { |
| | | if (v === "approved") return "å·²éè¿"; |
| | | if (v === "rejected") return "已驳å"; |
| | | if (v === "cancelled") return "å·²æ¤é"; |
| | | return "å¾
审æ¹"; |
| | | function filterUsersByQuery(query) { |
| | | const list = allUsersCache.value.filter((u) => isActiveUser(u)); |
| | | const q = (query || "").trim().toLowerCase(); |
| | | if (!q) return list.slice(0, 50); |
| | | return list |
| | | .filter((u) => { |
| | | const nick = (u.nickName || "").toLowerCase(); |
| | | const name = (u.userName || "").toLowerCase(); |
| | | const id = String(u.userId ?? u.id ?? ""); |
| | | return nick.includes(q) || name.includes(q) || id.includes(q); |
| | | }) |
| | | .slice(0, 50); |
| | | } |
| | | |
| | | function handoverStatusTagType(v) { |
| | | if (v === "completed") return "success"; |
| | | if (v === "returned") return "danger"; |
| | | return "warning"; |
| | | async function loadUserPool() { |
| | | try { |
| | | const res = await userListNoPageByTenantId(); |
| | | allUsersCache.value = unwrapArray(res); |
| | | } catch { |
| | | allUsersCache.value = []; |
| | | } |
| | | } |
| | | |
| | | function handoverTypeTagType(v) { |
| | | return v === "transfer" ? "info" : ""; |
| | | async function remoteSearchApplicant(query) { |
| | | applicantSearchLoading.value = true; |
| | | try { |
| | | if (!allUsersCache.value.length) await loadUserPool(); |
| | | applicantSearchOptions.value = filterUsersByQuery(query); |
| | | } finally { |
| | | applicantSearchLoading.value = false; |
| | | } |
| | | } |
| | | |
| | | const allRows = ref([]); |
| | | const tableColumn = buildInstanceTableColumns(tableData, buildTableActions); |
| | | |
| | | const searchForm = reactive({ |
| | | applicantId: "", |
| | | handoverStatus: "", |
| | | handoverType: "", |
| | | }); |
| | | |
| | | const tableLoading = ref(false); |
| | | const page = reactive({ |
| | | current: 1, |
| | | size: 10, |
| | | total: 0, |
| | | }); |
| | | |
| | | const filteredList = computed(() => { |
| | | let list = [...allRows.value]; |
| | | if (searchForm.applicantId) { |
| | | list = list.filter((r) => String(r.applicantId) === String(searchForm.applicantId)); |
| | | } |
| | | if (searchForm.handoverStatus) { |
| | | list = list.filter((r) => r.handoverStatus === searchForm.handoverStatus); |
| | | } |
| | | if (searchForm.handoverType) { |
| | | list = list.filter((r) => r.handoverType === searchForm.handoverType); |
| | | } |
| | | return list.sort((a, b) => (a.leaveDate < b.leaveDate ? 1 : -1)); |
| | | }); |
| | | |
| | | 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 = 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: "leaveDate", width: 120 }, |
| | | { |
| | | label: "交æ¥ç¶æ", |
| | | prop: "handoverStatus", |
| | | width: 110, |
| | | dataType: "tag", |
| | | formatData: (v) => handoverStatusLabel(v), |
| | | formatType: (v) => handoverStatusTagType(v), |
| | | }, |
| | | { |
| | | label: "交æ¥ç±»å", |
| | | prop: "handoverType", |
| | | width: 110, |
| | | dataType: "tag", |
| | | formatData: (v) => handoverTypeLabel(v), |
| | | formatType: (v) => handoverTypeTagType(v), |
| | | }, |
| | | { label: "交æ¥äºº", prop: "handoverPersonName", minWidth: 100 }, |
| | | { |
| | | 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) }, |
| | | ], |
| | | }, |
| | | ]); |
| | | |
| | | 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 detailDialog = reactive({ visible: false }); |
| | | const detailRow = ref({}); |
| | | |
| | | function handleQuery() { |
| | | page.current = 1; |
| | | tableLoading.value = true; |
| | | setTimeout(() => { |
| | | tableLoading.value = false; |
| | | }, 150); |
| | | function onSearch() { |
| | | handleQuery(searchForm); |
| | | } |
| | | |
| | | async function resetSearch() { |
| | | searchForm.applicantId = ""; |
| | | searchForm.handoverStatus = ""; |
| | | searchForm.handoverType = ""; |
| | | handleQuery(); |
| | | onSearch(); |
| | | await remoteSearchApplicant(""); |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | |
| | | function openAddWithTemplate() { |
| | | formDialog.visible = false; |
| | | pendingTemplateBinding.value = null; |
| | | templateBindVisible.value = true; |
| | | } |
| | | |
| | | function onTemplateBound(binding) { |
| | | pendingTemplateBinding.value = binding; |
| | | } |
| | | |
| | | async function onTemplateBindClosed() { |
| | | const binding = pendingTemplateBinding.value; |
| | | if (!binding) return; |
| | | pendingTemplateBinding.value = null; |
| | | await openFormWithBinding(binding); |
| | | } |
| | | |
| | | async function openFormWithBinding(binding) { |
| | | Object.assign(form, createEmptyForm()); |
| | | applyBindingToForm(form, binding); |
| | | form.hasTemplateBinding = true; |
| | | formDialog.mode = "add"; |
| | | formDialog.title = "æ°å¢å·¥ä½äº¤æ¥"; |
| | | await Promise.all([loadUserPool(), loadFlowUsers()]); |
| | | await syncHandoverFieldsFromPayload(); |
| | | formDialog.visible = true; |
| | | nextTick(() => formRef.value?.clearValidate?.()); |
| | | } |
| | | |
| | | function reopenTemplateBind() { |
| | | formDialog.visible = false; |
| | | pendingTemplateBinding.value = null; |
| | | templateBindVisible.value = true; |
| | | } |
| | | |
| | | function syncApplicantFromUser(uid) { |
| | | const u = userById(uid); |
| | | form.applicantId = uid != null && uid !== "" ? uid : ""; |
| | | form.applicantName = u ? u.nickName || u.userName || "" : ""; |
| | | } |
| | | |
| | | function syncHandoverPersonFromUser(uid) { |
| | | const u = userById(uid); |
| | | form.handoverPersonId = uid != null && uid !== "" ? uid : ""; |
| | | form.handoverPersonName = u ? u.nickName || u.userName || "" : ""; |
| | | } |
| | | |
| | | /** 仿¨¡æ¿å¡«æ¥é¡¹åæ¥å表å±ç¤ºå段 */ |
| | | async function syncHandoverFieldsFromPayload() { |
| | | 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("交æ¥äºº")) { |
| | | syncApplicantFromUser(val); |
| | | } else if (label.includes("交æ¥äºº")) { |
| | | syncHandoverPersonFromUser(val); |
| | | } else if (label.includes("离è") && f.type === "date") { |
| | | form.leaveDate = val || ""; |
| | | } else if (label.includes("交æ¥ç¶æ")) { |
| | | form.handoverStatus = val != null && val !== "" ? val : form.handoverStatus; |
| | | } else if (label.includes("交æ¥ç±»å")) { |
| | | form.handoverType = val != null && val !== "" ? val : form.handoverType; |
| | | } |
| | | } |
| | | } |
| | | |
| | | async 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, |
| | | applicantId: row.applicantId, |
| | | applicantName: row.applicantName, |
| | | leaveDate: row.leaveDate, |
| | | handoverStatus: row.handoverStatus, |
| | | handoverType: row.handoverType, |
| | | handoverPersonId: row.handoverPersonId, |
| | | handoverPersonName: row.handoverPersonName, |
| | | 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 || [])), |
| | | }); |
| | | await loadUserPool(); |
| | | await syncHandoverFieldsFromPayload(); |
| | | 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; |
| | | await syncHandoverFieldsFromPayload(); |
| | | const payload = { |
| | | applicantId: form.applicantId, |
| | | applicantName: form.applicantName, |
| | | leaveDate: form.leaveDate, |
| | | handoverStatus: form.handoverStatus, |
| | | handoverType: form.handoverType, |
| | | handoverPersonId: form.handoverPersonId, |
| | | handoverPersonName: form.handoverPersonName, |
| | | 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); |
| | | const prev = idx !== -1 ? allRows.value[idx] : {}; |
| | | if (idx !== -1) { |
| | | allRows.value[idx] = { |
| | | ...prev, |
| | | id: form.id, |
| | | ...payload, |
| | | }; |
| | | } |
| | | proxy?.$modal?.msgSuccess?.("ä¿åæå"); |
| | | } |
| | | formDialog.visible = false; |
| | | handleQuery(); |
| | | async function onSubmit() { |
| | | const ok = await submitInstanceForm({ skipValidate: true }); |
| | | if (ok) ElMessage.success(isSubmitEdit.value ? "ä¿®æ¹æå" : "æäº¤æå"); |
| | | } |
| | | |
| | | onMounted(async () => { |
| | | await loadUserPool(); |
| | | loadFlowUsers(); |
| | | await remoteSearchApplicant(""); |
| | | await initModuleList(searchForm); |
| | | }); |
| | | </script> |
| | | |
| | |
| | | .search_title { |
| | | font-size: 14px; |
| | | color: var(--el-text-color-regular); |
| | | } |
| | | .work-handover-form :deep(.el-row) { |
| | | margin-bottom: 0; |
| | | } |
| | | .work-handover-form :deep(.el-form-item) { |
| | | margin-bottom: 18px; |
| | | } |
| | | .work-handover-form-dialog :deep(.el-dialog__body) { |
| | | padding-top: 12px; |
| | | } |
| | | .template-name { |
| | | font-weight: 600; |
| | | color: var(--el-text-color-primary); |
| | | } |
| | | .ml12 { |
| | | margin-left: 12px; |
| | | } |
| | | </style> |