| | |
| | | import dayjs from "dayjs"; |
| | | import { getTypeEnums } from "@/api/basicData/enum.js"; |
| | | import { TEMPLATE_TYPE_CUSTOM } from "@/api/officeProcessAutomation/approvalTemplate.js"; |
| | | import { |
| | | TEMPLATE_TYPE_BUILTIN, |
| | | TEMPLATE_TYPE_CUSTOM, |
| | | } from "@/api/officeProcessAutomation/approvalTemplate.js"; |
| | | import { APPROVAL_TYPE_OPTIONS } from "../approve-list/approveListConstants.js"; |
| | | import { |
| | | buildFormConfigJson, |
| | |
| | | } catch { |
| | | return []; |
| | | } |
| | | } |
| | | |
| | | /** 是否为系统内置模板(templateType === 0) */ |
| | | export function isBuiltinTemplate(row) { |
| | | return Number(row?.templateType) === TEMPLATE_TYPE_BUILTIN; |
| | | } |
| | | |
| | | /** 节点内审批方式:会签 / 或签 */ |
| | |
| | | return { createdTime, updatedTime, createTime: createdTime, updateTime: updatedTime }; |
| | | } |
| | | |
| | | function normalizeTimeValue(val) { |
| | | if (val == null || val === "") return ""; |
| | | if (Array.isArray(val) && val.length >= 3) { |
| | | const [y, m, d, h = 0, min = 0, s = 0] = val; |
| | | return dayjs(new Date(y, m - 1, d, h, min, s)).format("YYYY-MM-DD HH:mm:ss"); |
| | | } |
| | | if (typeof val === "number") { |
| | | const d = val > 1e12 ? dayjs(val) : dayjs.unix(val); |
| | | return d.isValid() ? d.format("YYYY-MM-DD HH:mm:ss") : ""; |
| | | } |
| | | const s = String(val).trim(); |
| | | if (!s) return ""; |
| | | const parsed = dayjs(s.includes("T") ? s : s.replace(/-/g, "/")); |
| | | return parsed.isValid() ? parsed.format("YYYY-MM-DD HH:mm:ss") : s; |
| | | |
| | | /** |
| | | * @param {any} val 时间值 |
| | | * @param {boolean} [onlyDate=true] true:只年月日,false:年月日时分秒 |
| | | */ |
| | | function normalizeTimeValue(val, onlyDate = true) { |
| | | if (val == null || val === "") return ""; |
| | | const fmt = onlyDate ? "YYYY-MM-DD" : "YYYY-MM-DD HH:mm:ss"; |
| | | |
| | | if (Array.isArray(val) && val.length >= 3) { |
| | | const [y, m, d, h = 0, min = 0, s = 0] = val; |
| | | return dayjs(new Date(y, m - 1, d, h, min, s)).format(fmt); |
| | | } |
| | | if (typeof val === "number") { |
| | | const d = val > 1e12 ? dayjs(val) : dayjs.unix(val); |
| | | return d.isValid() ? d.format(fmt) : ""; |
| | | } |
| | | const s = String(val).trim(); |
| | | if (!s) return ""; |
| | | const parsed = dayjs(s.includes("T") ? s : s.replace(/-/g, "/")); |
| | | return parsed.isValid() ? parsed.format(fmt) : s; |
| | | } |
| | | |
| | | export function formatDisplayTime(val) { |
| | | const t = normalizeTimeValue(val); |
| | | export function formatDisplayTime(val,onlyDate) { |
| | | const t = normalizeTimeValue(val,onlyDate); |
| | | return t || "—"; |
| | | } |
| | | |
| | |
| | | templateName: (form.templateName || "").trim(), |
| | | description: (form.description || "").trim(), |
| | | enabled: mapEnabledToApi(form.enabled), |
| | | templateType: TEMPLATE_TYPE_CUSTOM, |
| | | templateType: |
| | | form.templateType != null ? Number(form.templateType) : TEMPLATE_TYPE_CUSTOM, |
| | | businessType: form.businessType ?? "", |
| | | formConfig: buildFormConfigJson(form.formConfigData), |
| | | nodes: nodes.map((n, i) => { |
| | |
| | | return dto; |
| | | } |
| | | |
| | | export function buildApprovalTemplateListParams({ page, searchForm, templateType = TEMPLATE_TYPE_CUSTOM }) { |
| | | export function buildApprovalTemplateListParams({ page, searchForm }) { |
| | | const params = { |
| | | current: page.current, |
| | | size: page.size, |
| | | templateType: searchForm?.templateType != null && searchForm.templateType !== "" |
| | | ? searchForm.templateType |
| | | : templateType, |
| | | }; |
| | | const kw = (searchForm?.keyword || "").trim(); |
| | | if (kw) params.templateName = kw; |
| | |
| | | templateName: "", |
| | | description: "", |
| | | templateType: TEMPLATE_TYPE_CUSTOM, |
| | | lockedFormFieldUids: [], |
| | | businessType: "", |
| | | formConfig: "", |
| | | formConfigData: createEmptyFormConfigData(), |