EmployeeFieldApplyDrawer.vue
8.24 KB
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
<template>
<!-- 申请权限抽屉 -->
<BasicDrawer
v-bind="$attrs"
@register="registerDrawer"
@ok="handleApplySubmit"
title="字段编辑权限申请"
width="60%"
:destroyOnClose="true"
:isDetail="true"
:showFooter="true"
okText="申请"
:showDetailBack="false"
:closable="true"
class="apply-permission-drawer"
>
<div>
<h3 style="margin-bottom: 16px; color: #1890ff;">请选择需要申请编辑权限的字段:</h3>
<BasicForm @register="registerApplyForm" />
</div>
</BasicDrawer>
<!-- 申请理由组件 -->
<ApproveReason @register="registerApproveReason" @success="handleApproveSuccess" />
</template>
<script lang="ts">
import { defineComponent, ref } from 'vue';
import { BasicDrawer, useDrawer, useDrawerInner } from '/@/components/Drawer';
import { BasicForm, useForm } from '/@/components/Form/index';
import { useModal } from '/@/components/Modal';
import { message } from 'ant-design-vue';
import ApproveReason from '../personnel/salary/attendance/ApproveReason.vue';
export default defineComponent({
name: 'EmployeeFieldApplyDrawer',
components: {
BasicDrawer,
BasicForm,
ApproveReason,
},
setup() {
const currentApplyRecord = ref<any>(null);
const selectedApplyFields = ref<any>({});
// 注册申请权限抽屉,使用useDrawerInner接收数据
const [registerDrawer, { closeDrawer }] = useDrawerInner(async (data) => {
if (data?.record) {
currentApplyRecord.value = { ...data.record };
}
});
// 注册申请理由模态框
const [registerApproveReason, { openModal: openApproveReasonModal }] = useModal();
// 定义申请权限表单字段
const getApplySchema = () => [
{
field: 'attendanceAllowance',
label: '全勤奖',
component: 'Switch',
componentProps: {
checkedValue: 'UN_LOCKED',
unCheckedValue: 'LOCKED',
},
colProps: {
span: 8,
},
},
{
field: 'basicWages',
label: '基本工资',
component: 'Switch',
componentProps: {
checkedValue: 'UN_LOCKED',
unCheckedValue: 'LOCKED',
},
colProps: {
span: 8,
},
},
{
field: 'contractEndTime',
label: '合同结束时间',
component: 'Switch',
componentProps: {
checkedValue: 'UN_LOCKED',
unCheckedValue: 'LOCKED',
},
colProps: {
span: 8,
},
},
{
field: 'contractStartTime',
label: '合同签署时间',
component: 'Switch',
componentProps: {
checkedValue: 'UN_LOCKED',
unCheckedValue: 'LOCKED',
},
colProps: {
span: 8,
},
},
{
field: 'managementAllowance',
label: '管理岗位津贴',
component: 'Switch',
componentProps: {
checkedValue: 'UN_LOCKED',
unCheckedValue: 'LOCKED',
},
colProps: {
span: 8,
},
},
{
field: 'mealAllowance',
label: '餐补',
component: 'Switch',
componentProps: {
checkedValue: 'UN_LOCKED',
unCheckedValue: 'LOCKED',
},
colProps: {
span: 8,
},
},
{
field: 'monthlyAttendanceName',
label: '考勤组',
component: 'Switch',
componentProps: {
checkedValue: 'UN_LOCKED',
unCheckedValue: 'LOCKED',
},
colProps: {
span: 8,
},
},
{
field: 'performanceAllowance',
label: '绩效部分',
component: 'Switch',
componentProps: {
checkedValue: 'UN_LOCKED',
unCheckedValue: 'LOCKED',
},
colProps: {
span: 8,
},
},
{
field: 'periodEndTime',
label: '试用期结束时间',
component: 'Switch',
componentProps: {
checkedValue: 'UN_LOCKED',
unCheckedValue: 'LOCKED',
},
colProps: {
span: 8,
},
},
{
field: 'periodStartTime',
label: '试用期开始时间',
component: 'Switch',
componentProps: {
checkedValue: 'UN_LOCKED',
unCheckedValue: 'LOCKED',
},
colProps: {
span: 8,
},
},
{
field: 'phoneAllowance',
label: '话费补贴',
component: 'Switch',
componentProps: {
checkedValue: 'UN_LOCKED',
unCheckedValue: 'LOCKED',
},
colProps: {
span: 8,
},
},
{
field: 'postAllowance',
label: '岗位津贴',
component: 'Switch',
componentProps: {
checkedValue: 'UN_LOCKED',
unCheckedValue: 'LOCKED',
},
colProps: {
span: 8,
},
},
{
field: 'roleName',
label: '岗位',
component: 'Switch',
componentProps: {
checkedValue: 'UN_LOCKED',
unCheckedValue: 'LOCKED',
},
colProps: {
span: 8,
},
},
{
field: 'socialSettingName',
label: '社保待遇',
component: 'Switch',
componentProps: {
checkedValue: 'UN_LOCKED',
unCheckedValue: 'LOCKED',
},
colProps: {
span: 8,
},
},
{
field: 'transportationAllowance',
label: '交通补贴',
component: 'Switch',
componentProps: {
checkedValue: 'UN_LOCKED',
unCheckedValue: 'LOCKED',
},
colProps: {
span: 8,
},
},
];
// 注册申请权限表单
const [registerApplyForm, { getFieldsValue: getApplyFieldsValue }] = useForm({
labelWidth: 180,
schemas: getApplySchema(),
showActionButtonGroup: false,
actionColOptions: {
span: 24,
},
});
// 处理申请权限提交
const handleApplySubmit = async () => {
try {
const fieldValues = getApplyFieldsValue();
selectedApplyFields.value = fieldValues;
closeDrawer();
// 打开申请理由模态框
openApproveReasonModal(true, {
fieldValues: selectedApplyFields.value,
userId: currentApplyRecord.value?.id,
apiUrl: '/order/erp/users/fieldApply'
});
} catch (error) {
console.error('获取表单数据失败:', error);
message.error('获取表单数据失败');
}
};
// 处理申请成功回调
const handleApproveSuccess = () => {
selectedApplyFields.value = {};
currentApplyRecord.value = null;
message.success('申请提交成功');
};
return {
registerDrawer,
registerApplyForm,
registerApproveReason,
handleApplySubmit,
handleApproveSuccess,
};
},
});
</script>
<style lang="less" scoped>
// 申请权限抽屉样式,与出勤统计表保持一致
:deep(.apply-permission-drawer) {
.ant-drawer-content {
position: fixed;
z-index: 10;
}
}
</style>