From 91eff4781fa4142d1f62d30a0fa1de5cae424eaf Mon Sep 17 00:00:00 2001
From: liu <2021943741@qq.com>
Date: 星期三, 16 九月 2026 18:23:12 +0800
Subject: [PATCH] refactor: 单据审核改为审批配置状态机(前端统一审核弹窗)
---
src/views/hrm/performance-appraise/modules/audit-modal.vue | 93 ++++++++++++++++++++++++----------------------
1 files changed, 49 insertions(+), 44 deletions(-)
diff --git a/src/views/hrm/performance-appraise/modules/audit-modal.vue b/src/views/hrm/performance-appraise/modules/audit-modal.vue
index 9bc18f5..30a2f0f 100644
--- a/src/views/hrm/performance-appraise/modules/audit-modal.vue
+++ b/src/views/hrm/performance-appraise/modules/audit-modal.vue
@@ -1,5 +1,8 @@
<script lang="ts" setup>
-import { ref } from 'vue';
+import type { VbenFormSchema } from '#/adapter/form';
+import type { HrmPerformanceAppraiseApi } from '#/api/hrm/performance-appraise';
+
+import { computed, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
@@ -10,42 +13,42 @@
const emit = defineEmits(['success']);
-const appraiseId = ref<number>();
+const pass = ref(true); // true=瀹℃牳閫氳繃 / false=瀹℃牳涓嶉�氳繃
+const rowData = ref<HrmPerformanceAppraiseApi.Appraise>();
+const getTitle = computed(() => (pass.value ? '瀹℃牳閫氳繃' : '瀹℃牳涓嶉�氳繃'));
const [Form, formApi] = useVbenForm({
commonConfig: {
componentProps: {
class: 'w-full',
},
- labelWidth: 100,
+ formItemClass: 'col-span-1',
+ labelWidth: 90,
},
wrapperClass: 'grid-cols-1',
- layout: 'vertical',
- schema: [
- {
- fieldName: 'auditStatus',
- label: '瀹℃壒缁撴灉',
- component: 'RadioGroup',
- componentProps: {
- options: [
- { label: '閫氳繃', value: 20 },
- { label: '椹冲洖', value: 30 },
- ],
- },
- rules: 'selectRequired',
- },
- {
- fieldName: 'remark',
- label: '瀹℃壒澶囨敞',
- component: 'Textarea',
- componentProps: {
- placeholder: '璇疯緭鍏ュ鎵瑰娉�',
- rows: 3,
- },
- },
- ],
+ layout: 'horizontal',
+ schema: [],
showDefaultActions: false,
});
+
+/** 瀹℃牳琛ㄥ崟瀛楁锛氫笉閫氳繃鏃跺繀椤诲~鍐欏師鍥� */
+function useAuditSchema(): VbenFormSchema[] {
+ return [
+ {
+ fieldName: 'reviewRemark',
+ label: '瀹℃牳鎰忚',
+ component: 'Textarea',
+ formItemClass: 'col-span-1',
+ componentProps: {
+ rows: 3,
+ placeholder: pass.value
+ ? '璇疯緭鍏ュ鏍告剰瑙侊紙鍙�夛級'
+ : '璇疯緭鍏ヤ笉閫氳繃鍘熷洜锛堝繀濉級',
+ },
+ rules: pass.value ? '' : 'required',
+ },
+ ];
+}
const [Modal, modalApi] = useVbenModal({
async onConfirm() {
@@ -54,38 +57,40 @@
return;
}
modalApi.lock();
+ const values = await formApi.getValues();
try {
- const values = await formApi.getValues<{
- auditStatus: number;
- remark?: string;
- }>();
- await auditAppraise({
- id: appraiseId.value!,
- auditStatus: values.auditStatus,
- remark: values.remark,
- });
+ await auditAppraise(rowData.value!.id!, pass.value, values.reviewRemark);
await modalApi.close();
emit('success');
- message.success('瀹℃壒瀹屾垚');
+ message.success(pass.value ? '瀹℃牳閫氳繃' : '宸查��鍥烇紝鍙慨鏀瑰悗閲嶆柊鎻愪氦');
} finally {
modalApi.unlock();
}
},
async onOpenChange(isOpen: boolean) {
if (!isOpen) {
- appraiseId.value = undefined;
- await formApi.resetForm();
+ rowData.value = undefined;
return;
}
- const data = modalApi.getData<{ id: number }>();
- appraiseId.value = data?.id;
- await formApi.setValues({ auditStatus: 20 });
+ const data = modalApi.getData<{
+ pass: boolean;
+ row: HrmPerformanceAppraiseApi.Appraise;
+ }>();
+ rowData.value = data.row;
+ pass.value = data.pass;
+ formApi.setState({ schema: useAuditSchema() });
+ formApi.resetForm();
},
});
</script>
<template>
- <Modal title="瀹℃壒缁╂晥鑰冩牳鏂规" class="w-1/3">
- <Form class="mx-3" />
+ <Modal :title="getTitle" class="w-2/5">
+ <div v-if="rowData" class="mx-4 mb-4 text-sm text-gray-600">
+ <div>鏂规鍚嶇О锛歿{ rowData.name }}</div>
+ <div>鑰冩牳鍛ㄦ湡锛歿{ rowData.period }}</div>
+ <div>鑰冩牳鎸囨爣鏁帮細{{ rowData.itemCount }}</div>
+ </div>
+ <Form class="mx-4" />
</Modal>
</template>
--
Gitblit v1.9.3