index.tsx
6.41 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
import React, { useEffect, useState } from "react";
import {
Card,
Form,
InputNumber,
Button,
message,
Popconfirm,
Result,
Radio,
Descriptions,
Popover,
} from "antd";
import { PlusOutlined, ExclamationCircleFilled } from "@ant-design/icons";
import { PageHeaderWrapper } from "@ant-design/pro-layout";
import useInitial from "@/hooks/useInitail";
import {
getConfigApi,
DetailParams,
SaveParams,
saveConfigApi,
fetchList,
Item,
} from "./api";
const FormItem = Form.Item;
export default function StarRatingRules() {
const { data, setLoading, loading, errMsg } = useInitial<Item, any>(
fetchList,
{},
{}
);
const [disabled, setDisabled] = useState(true);
const [submitLoading, setSubmitLoading] = useState(false);
const [form] = Form.useForm();
useEffect(() => {
initData();
}, [data]);
function onHandleCancel(initFlag: boolean = true) {
initFlag && initData();
setDisabled(!disabled);
}
function initData() {
form.setFieldsValue({
...data,
});
}
function onFinish(feildValue: SaveParams) {
setSubmitLoading(true);
const params = {
...feildValue,
};
try {
saveConfigApi(params)
.then((res) => {
message.success("保存成功");
setDisabled(true);
setSubmitLoading(false);
})
.catch((err) => {
message.error(err.message);
setSubmitLoading(false);
});
} catch (err) {
message.error(err.message);
setSubmitLoading(false);
}
}
return (
<PageHeaderWrapper title="系统设置">
<Card loading={loading}>
{errMsg ? (
<Result
title="页面错误"
subTitle={errMsg}
status="error"
extra={
<Button type="primary" onClick={() => setLoading(true)}>
重新加载
</Button>
}
/>
) : (
<Form
form={form}
onFinish={onFinish}
labelCol={{ span: 10 }}
layout="vertical"
wrapperCol={{ span: 5 }}
style={{
padding: 150,
}}
>
<h3 style={{ width: "100%" }}>开放管理层查看薪酬:</h3>
<FormItem
name="leaderVisibility"
style={{ paddingLeft: 100 }}
rules={[{ required: true, message: "请输入" }]}
>
<Radio.Group disabled={disabled} >
<Radio value>开放</Radio>
<Radio value={false}>不开放</Radio>
</Radio.Group>
</FormItem>
<h3 style={{ width: "100%" }}>工资申诉时间:</h3>
<div
style={{
display: "flex",
paddingLeft: 50,
flexWrap: "wrap",
}}
>
<FormItem
name="startDateOfAppeal"
label="可申诉开始日期"
style={{ paddingLeft: 50 }}
rules={[{ required: true, message: "请输入" }]}
>
<InputNumber
placeholder="请输入"
min={1}
precision={0}
disabled={disabled}
addonAfter="日"
style={{ marginRight: 6, width: 400 }}
/>
</FormItem>
<FormItem
name="endDateOfAppeal"
label="可申诉结束日期"
style={{ paddingLeft: 50 }}
rules={[{ required: true, message: "请输入" }]}
>
<InputNumber
placeholder="请输入"
style={{ width: 400 }}
min={1}
max={28}
addonAfter="日"
disabled={disabled}
precision={0}
/>
</FormItem>
</div>
<h3 style={{ width: "100%" }}>工资发放时间:</h3>
<div
style={{
display: "flex",
paddingLeft: 50,
flexWrap: "wrap",
}}
>
<FormItem
name="payoffDate"
label="每月"
style={{ paddingLeft: 50 }}
rules={[{ required: true, message: "请输入" }]}
>
<InputNumber
placeholder="请输入"
min={1}
precision={0}
max={28}
disabled={disabled}
style={{ marginRight: 6, width: 400 }}
addonAfter="日"
/>
</FormItem>
</div>
<h3 style={{ width: "100%" }}>薪酬发放限制:</h3>
<div
style={{
display: "flex",
paddingLeft: 50,
flexWrap: "wrap",
}}
>
<FormItem
name="payoffLimit"
label="公户发放最大金额"
style={{ paddingLeft: 50 }}
>
<InputNumber
placeholder="请输入"
min={0}
precision={2}
disabled={disabled}
addonAfter="元"
style={{ marginRight: 6, width: 400 }}
/>
</FormItem>
</div>
<FormItem
wrapperCol={{ offset: 7, span: 14 }}
style={{ marginTop: 40 }}
>
<Popconfirm
title="确定取消?取消将重置数据"
onConfirm={() => onHandleCancel(true)}
>
<Button hidden={disabled} style={{ marginRight: 30 }}>
取消
</Button>
</Popconfirm>
<Button
hidden={disabled}
type="primary"
htmlType="submit"
loading={submitLoading}
>
提交
</Button>
<Button
hidden={!disabled}
type="primary"
htmlType="button"
onClick={() => onHandleCancel(false)}
>
编辑
</Button>
</FormItem>
</Form>
)}
</Card>
</PageHeaderWrapper>
);
}