From a1df9699594b0a0e46d26a0394eafb1eb030c68b Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期三, 20 五月 2026 17:42:09 +0800
Subject: [PATCH] 企业新闻
---
src/views/officeProcessAutomation/HrManage/regular-apply/index.vue | 495 ++++++++-----------------------------------------------
1 files changed, 72 insertions(+), 423 deletions(-)
diff --git a/src/views/officeProcessAutomation/HrManage/regular-apply/index.vue b/src/views/officeProcessAutomation/HrManage/regular-apply/index.vue
index 4821495..ef4a1e8 100644
--- a/src/views/officeProcessAutomation/HrManage/regular-apply/index.vue
+++ b/src/views/officeProcessAutomation/HrManage/regular-apply/index.vue
@@ -10,7 +10,7 @@
placeholder="璇疯緭鍏ョ敵璇蜂汉"
clearable
:prefix-icon="Search"
- @keyup.enter="handleQuery"
+ @keyup.enter="onSearch"
/>
<span class="search_title" style="margin-left: 12px">鐢宠鏃ユ湡锛�</span>
<el-date-picker
@@ -24,7 +24,7 @@
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>
@@ -39,56 +39,24 @@
: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"
- :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
+ 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"
+ @submit="onSubmit"
+ />
<ApprovalTemplateBindDialog
v-model:visible="templateBindVisible"
@@ -98,392 +66,95 @@
@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 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));
-});
-
-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;
- }
+const mod = useApprovalInstanceModule({
+ moduleKey: APPROVAL_MODULE_KEYS.REGULAR,
+ buildExtraListParams(sf) {
+ const extra = {};
+ const name = (sf?.applicantName || "").trim();
+ if (name) extra.applicantName = name;
+ return extra;
},
- { 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: "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 {
+ 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 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>
@@ -501,27 +172,5 @@
.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>
--
Gitblit v1.9.3