|
@@ -5,21 +5,39 @@ import ShowTitleMenu from '../Attendance/components/ShowTitleMenu'
|
|
|
import type { FormInstance } from 'antd'
|
|
|
import { message } from 'antd'
|
|
|
import ProForm, { ProFormDigit } from '@ant-design/pro-form'
|
|
|
+import { fetchParametersDetail, updateParametersTime } from '@/services/user/system'
|
|
|
|
|
|
const titleOptions = [{ label: '通用设置', value: 0 }]
|
|
|
|
|
|
const CommonSetting: React.FC = () => {
|
|
|
const formRef = useRef<FormInstance>(null)
|
|
|
const [state, setState] = useState({
|
|
|
- menuId: 0,
|
|
|
- contentValue: ''
|
|
|
+ parametersType: 2,
|
|
|
+ menuId: 0
|
|
|
})
|
|
|
+
|
|
|
const onSelect = (menuId: string) => {
|
|
|
setState({ ...state, menuId })
|
|
|
}
|
|
|
- const { run: tryUpdateCommonSetting } = useRequest(
|
|
|
- (params: API.UpdateCommonSetting) => {
|
|
|
- return updateCommonSetting(params)
|
|
|
+ const { run: tryGetParametersDetail } = useRequest(
|
|
|
+ () => {
|
|
|
+ return fetchParametersDetail({ parametersType: 2 })
|
|
|
+ },
|
|
|
+ {
|
|
|
+ manual: true,
|
|
|
+ onSuccess: (result: API.ParametersDetailResult) => {
|
|
|
+ const contentObject = JSON.parse(result.content)
|
|
|
+ formRef.current?.setFieldsValue({
|
|
|
+ clientTimeList: contentObject.clientTimeList,
|
|
|
+ unitTimeList: contentObject.unitTimeList,
|
|
|
+ softTimeList: contentObject.softTimeList
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ )
|
|
|
+ const { run: tryUpdateParametersTime } = useRequest(
|
|
|
+ (params: API.UpdateParametersTime) => {
|
|
|
+ return updateParametersTime(params)
|
|
|
},
|
|
|
{
|
|
|
manual: true,
|
|
@@ -29,10 +47,8 @@ const CommonSetting: React.FC = () => {
|
|
|
}
|
|
|
)
|
|
|
useEffect(() => {
|
|
|
- if (state.menuId === 0) {
|
|
|
- formRef.current?.setFieldsValue(...state.contentValue)
|
|
|
- }
|
|
|
- }, [state.menuId])
|
|
|
+ tryGetParametersDetail(state.parametersType)
|
|
|
+ }, [])
|
|
|
return (
|
|
|
<PageContainer title={false} breadcrumb={false}>
|
|
|
<div className="h-full w-full flex flex-row">
|
|
@@ -44,23 +60,20 @@ const CommonSetting: React.FC = () => {
|
|
|
<div className="my-4 text-gray-500 text-opacity-50">
|
|
|
用户新建记录和备注后,可在设置的时间(小时)内进行[编辑]和[删除]操作。
|
|
|
</div>
|
|
|
- {state.menuId === 0 ? (
|
|
|
- <ProForm
|
|
|
- formRef={formRef}
|
|
|
- layout="horizontal"
|
|
|
- onFinish={async values => {
|
|
|
- await tryUpdateCommonSetting(values)
|
|
|
- message.success('更新成功')
|
|
|
- return true
|
|
|
- }}
|
|
|
- initialValues={{ parametersType: 1 }}>
|
|
|
- <ProForm.Group>
|
|
|
- <ProFormDigit label="客户服务记录:" width="xs" name="client" />
|
|
|
- <ProFormDigit label="单位服务记录:" width="xs" name="company" />
|
|
|
- <ProFormDigit label="软件锁备注:" width="xs" name="lock" />
|
|
|
- </ProForm.Group>
|
|
|
- </ProForm>
|
|
|
- ) : null}
|
|
|
+ <ProForm
|
|
|
+ formRef={formRef}
|
|
|
+ layout="horizontal"
|
|
|
+ onFinish={async values => {
|
|
|
+ await tryUpdateParametersTime(values)
|
|
|
+ return true
|
|
|
+ }}
|
|
|
+ initialValues={{ parametersType: 1 }}>
|
|
|
+ <ProForm.Group>
|
|
|
+ <ProFormDigit label="客户服务记录:" width="xs" name="clientTimeList" />
|
|
|
+ <ProFormDigit label="单位服务记录:" width="xs" name="unitTimeList" />
|
|
|
+ <ProFormDigit label="软件锁备注:" width="xs" name="softTimeList" />
|
|
|
+ </ProForm.Group>
|
|
|
+ </ProForm>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|