liu
2026-09-29 982c97ab82f3beb1b4febcf014562eda34b9fc05
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<script lang="ts" setup>
import type { VbenFormSchema } from '#/adapter/form';
import type { ResearchApplicationApi } from '#/api/research/application';
 
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
 
import { useVbenModal } from '@vben/common-ui';
 
import { message } from 'ant-design-vue';
 
import { useVbenForm } from '#/adapter/form';
import {
  createTopicReview,
  updateTopicReview,
} from '#/api/research/application';
 
defineOptions({ name: 'ResearchTopicReviewForm' });
 
const emit = defineEmits(['success']);
 
/** 四个评分维度与权重(与后端 ResearchTopicReviewServiceImpl 保持一致) */
const SCORE_ITEMS = [
  { fieldName: 'topicScore', label: '选题价值与意义', weight: '0.3' },
  { fieldName: 'planScore', label: '研究方案可行性', weight: '0.3' },
  { fieldName: 'teamScore', label: '团队与研究基础', weight: '0.2' },
  { fieldName: 'resultScore', label: '预期成果与效益', weight: '0.2' },
] as const;
 
const schema: VbenFormSchema[] = [
  {
    fieldName: 'id',
    component: 'Input',
    dependencies: {
      triggerFields: [''],
      show: () => false,
    },
  },
  {
    fieldName: 'applicationId',
    component: 'Input',
    dependencies: {
      triggerFields: [''],
      show: () => false,
    },
  },
  {
    fieldName: 'evaluatorName',
    label: '专家姓名',
    component: 'Input',
    componentProps: {
      placeholder: '请输入专家姓名',
      maxlength: 64,
    },
    rules: 'required',
  },
  {
    fieldName: 'evaluatorUnit',
    label: '专家单位',
    component: 'Input',
    componentProps: {
      placeholder: '请输入专家所在单位',
      maxlength: 128,
    },
  },
  {
    fieldName: 'evaluatorTitle',
    label: '专家职称',
    component: 'Input',
    componentProps: {
      placeholder: '请输入专家职称',
      maxlength: 64,
    },
  },
  ...SCORE_ITEMS.map((item) => ({
    fieldName: item.fieldName,
    label: `${item.label}(权重 ${item.weight})`,
    component: 'InputNumber' as const,
    componentProps: {
      class: '!w-full',
      placeholder: '0 ~ 100',
      min: 0,
      max: 100,
      precision: 2,
      addonAfter: '分',
    },
  })),
  {
    fieldName: 'conclusion',
    label: '评审结论',
    component: 'Select',
    componentProps: {
      options: getDictOptions(DICT_TYPE.RESEARCH_REVIEW_CONCLUSION, 'number'),
      placeholder: '请选择评审结论',
      allowClear: true,
    },
    rules: 'selectRequired',
  },
  {
    fieldName: 'opinion',
    label: '评审意见',
    component: 'Textarea',
    componentProps: {
      placeholder: '请输入对该课题的评审意见',
      maxlength: 1000,
      showCount: true,
      autoSize: { minRows: 4, maxRows: 8 },
    },
    formItemClass: 'col-span-2',
  },
];
 
const [Form, formApi] = useVbenForm({
  commonConfig: {
    componentProps: {
      class: 'w-full',
    },
    labelWidth: 170,
  },
  wrapperClass: 'grid-cols-2',
  layout: 'vertical',
  schema,
  showDefaultActions: false,
});
 
const [Modal, modalApi] = useVbenModal({
  async onConfirm() {
    const { valid } = await formApi.validate();
    if (!valid) {
      return;
    }
    modalApi.lock();
    const data =
      (await formApi.getValues()) as ResearchApplicationApi.TopicReview;
    try {
      await (data.id
        ? updateTopicReview(data)
        : createTopicReview(data));
      await modalApi.close();
      emit('success');
      message.success('保存成功,加权合计与排名已自动重算');
    } finally {
      modalApi.unlock();
    }
  },
  async onOpenChange(isOpen: boolean) {
    if (!isOpen) {
      return;
    }
    const data = modalApi.getData<{
      applicationId: number;
      review?: ResearchApplicationApi.TopicReview;
    }>();
    await formApi.resetForm();
    if (data.review) {
      await formApi.setValues(
        { ...data.review, applicationId: data.applicationId },
        false,
      );
    } else {
      await formApi.setValues({ applicationId: data.applicationId }, false);
    }
  },
});
</script>
 
<template>
  <Modal title="专家评分录入" class="w-1/2" :close-on-click-modal="false">
    <Form class="mx-3" />
    <p class="mx-3 text-sm text-gray-500">
      加权合计 = 选题价值×0.3 + 方案可行性×0.3 + 团队基础×0.2 + 预期成果×0.2,由系统自动计算
    </p>
  </Modal>
</template>