|
@@ -1,46 +1,83 @@
|
|
-import { FC, Key, useRef, useState } from "react";
|
|
|
|
-import { Button, Form, InputNumber, Radio, Space, Tag, Tooltip } from "antd";
|
|
|
|
-import { useNavigate } from "react-router-dom";
|
|
|
|
-import {
|
|
|
|
- ActionType,
|
|
|
|
- EditableFormInstance,
|
|
|
|
- EditableProTable,
|
|
|
|
-} from "@ant-design/pro-components";
|
|
|
|
|
|
+import { FC, Key, useEffect, useRef, useState } from "react";
|
|
|
|
+import { Button, Form, Space } from "antd";
|
|
|
|
+import { useParams } from "react-router-dom";
|
|
|
|
+import { ActionType, EditableProTable } from "@ant-design/pro-components";
|
|
import { PlusOutlined } from "@ant-design/icons";
|
|
import { PlusOutlined } from "@ant-design/icons";
|
|
import {
|
|
import {
|
|
AddIndexModal,
|
|
AddIndexModal,
|
|
AddIndexTemplateModal,
|
|
AddIndexTemplateModal,
|
|
- FormPageFooter,
|
|
|
|
PageContainer,
|
|
PageContainer,
|
|
Search,
|
|
Search,
|
|
} from "@/components";
|
|
} from "@/components";
|
|
-import { TableIndexType } from "../../types";
|
|
|
|
|
|
+// import { uniq, uniqBy } from "lodash";
|
|
|
|
+import {
|
|
|
|
+ AssIndexTreeItemType,
|
|
|
|
+ ASS_INDEX_TYPE,
|
|
|
|
+ IManageAssessmentIndex,
|
|
|
|
+} from "@/types";
|
|
|
|
+import style from "./index.module.scss";
|
|
|
|
+import { getManageAssFixedList, setManageAssFixed } from "@/api";
|
|
|
|
+import { DageLoading, DageTableActions } from "@dage/pc-components";
|
|
|
|
|
|
const SettingIndexPage: FC = () => {
|
|
const SettingIndexPage: FC = () => {
|
|
- const navigate = useNavigate();
|
|
|
|
|
|
+ const params = useParams();
|
|
const [form] = Form.useForm();
|
|
const [form] = Form.useForm();
|
|
const actionRef = useRef<ActionType>();
|
|
const actionRef = useRef<ActionType>();
|
|
- const tableRef = useRef<EditableFormInstance<TableIndexType>>();
|
|
|
|
|
|
+ // const tableRef = useRef<EditableFormInstance<TableIndexType>>();
|
|
const [keyword, setKeyword] = useState("");
|
|
const [keyword, setKeyword] = useState("");
|
|
const [indexModalVisible, setIndexModalVisible] = useState(false);
|
|
const [indexModalVisible, setIndexModalVisible] = useState(false);
|
|
const [indexTemplateModalVisible, setIndexTemplateModalVisible] =
|
|
const [indexTemplateModalVisible, setIndexTemplateModalVisible] =
|
|
useState(false);
|
|
useState(false);
|
|
const [editableKeys, setEditableKeys] = useState<Key[]>([]);
|
|
const [editableKeys, setEditableKeys] = useState<Key[]>([]);
|
|
|
|
+ const [loading, setLoading] = useState(false);
|
|
|
|
+ // 设置定级指标
|
|
|
|
+ const isFixed = params.type === ASS_INDEX_TYPE.FIXED;
|
|
|
|
|
|
- const handleSubmit = async () => {
|
|
|
|
- if (!(await form.validateFields())) return;
|
|
|
|
-
|
|
|
|
- console.log(form.getFieldsValue());
|
|
|
|
|
|
+ const getList = async () => {
|
|
|
|
+ try {
|
|
|
|
+ setLoading(true);
|
|
|
|
+ const data = await (isFixed
|
|
|
|
+ ? getManageAssFixedList
|
|
|
|
+ : getManageAssFixedList)(params.id!);
|
|
|
|
+ form.setFieldValue("list", data);
|
|
|
|
+ } finally {
|
|
|
|
+ setLoading(false);
|
|
|
|
+ }
|
|
};
|
|
};
|
|
|
|
|
|
- const handleAddIndexItem = (keys: Key[], list: TableIndexType[]) => {
|
|
|
|
- form.setFieldValue("list", [...list]);
|
|
|
|
- setEditableKeys([...keys]);
|
|
|
|
|
|
+ const handleAddIndexItem = async (keys: string[]) => {
|
|
|
|
+ if (isFixed) {
|
|
|
|
+ await setManageAssFixed(params.id!, keys);
|
|
|
|
+ }
|
|
|
|
+ getList();
|
|
};
|
|
};
|
|
|
|
+ // const handleAddIndexItem = async (
|
|
|
|
+ // keys: Key[],
|
|
|
|
+ // rows: AssIndexTreeItemType[]
|
|
|
|
+ // ) => {
|
|
|
|
+ // form.setFieldValue(
|
|
|
|
+ // "list",
|
|
|
|
+ // uniqBy([...(form.getFieldValue("list") || []), ...rows], "id")
|
|
|
|
+ // );
|
|
|
|
+ // setEditableKeys(uniq([...editableKeys, ...keys]));
|
|
|
|
+ // };
|
|
|
|
+
|
|
|
|
+ const handleSearch = () => {};
|
|
|
|
+
|
|
|
|
+ const handleDelete = (item: IManageAssessmentIndex) => {};
|
|
|
|
+
|
|
|
|
+ useEffect(() => {
|
|
|
|
+ getList();
|
|
|
|
+ }, []);
|
|
|
|
|
|
return (
|
|
return (
|
|
<PageContainer title="设置指标">
|
|
<PageContainer title="设置指标">
|
|
- <Form labelCol={{ span: 4, offset: 3 }} form={form} size="large">
|
|
|
|
|
|
+ <Form
|
|
|
|
+ labelCol={{ span: 4, offset: 3 }}
|
|
|
|
+ form={form}
|
|
|
|
+ size="large"
|
|
|
|
+ className={style.settingForm}
|
|
|
|
+ >
|
|
<Form.Item label="指标总分值">
|
|
<Form.Item label="指标总分值">
|
|
<Button type="primary">计算</Button>
|
|
<Button type="primary">计算</Button>
|
|
|
|
|
|
@@ -48,10 +85,10 @@ const SettingIndexPage: FC = () => {
|
|
</Form.Item>
|
|
</Form.Item>
|
|
<Form.Item required label="考核指标">
|
|
<Form.Item required label="考核指标">
|
|
<Form.Item noStyle name="list">
|
|
<Form.Item noStyle name="list">
|
|
- <EditableProTable<TableIndexType>
|
|
|
|
|
|
+ <EditableProTable<IManageAssessmentIndex>
|
|
className="custom-pro-table mw650"
|
|
className="custom-pro-table mw650"
|
|
actionRef={actionRef}
|
|
actionRef={actionRef}
|
|
- editableFormRef={tableRef}
|
|
|
|
|
|
+ // editableFormRef={tableRef}
|
|
rowKey="id"
|
|
rowKey="id"
|
|
style={{ marginTop: -15 }}
|
|
style={{ marginTop: -15 }}
|
|
recordCreatorProps={false}
|
|
recordCreatorProps={false}
|
|
@@ -70,49 +107,54 @@ const SettingIndexPage: FC = () => {
|
|
},
|
|
},
|
|
{
|
|
{
|
|
title: "填报方式",
|
|
title: "填报方式",
|
|
- dataIndex: "type",
|
|
|
|
|
|
+ dataIndex: "fill",
|
|
align: "center",
|
|
align: "center",
|
|
width: "230px",
|
|
width: "230px",
|
|
- renderFormItem: () => (
|
|
|
|
- <Radio.Group>
|
|
|
|
- <Radio value="point">手动填报</Radio>
|
|
|
|
- <Radio value="api">
|
|
|
|
- API{" "}
|
|
|
|
- <Tooltip title="以 type,start_date,end_date请求API数据。当API获取数据失败时,将自动转为手动填报">
|
|
|
|
- <Tag bordered={false} color="warning">
|
|
|
|
- 注
|
|
|
|
- </Tag>
|
|
|
|
- </Tooltip>
|
|
|
|
- </Radio>
|
|
|
|
- </Radio.Group>
|
|
|
|
- ),
|
|
|
|
|
|
+ // renderFormItem: () => (
|
|
|
|
+ // <Radio.Group>
|
|
|
|
+ // <Radio value="point">手动填报</Radio>
|
|
|
|
+ // <Radio value="api">
|
|
|
|
+ // API{" "}
|
|
|
|
+ // <Tooltip title="以 type,start_date,end_date请求API数据。当API获取数据失败时,将自动转为手动填报">
|
|
|
|
+ // <Tag bordered={false} color="warning">
|
|
|
|
+ // 注
|
|
|
|
+ // </Tag>
|
|
|
|
+ // </Tooltip>
|
|
|
|
+ // </Radio>
|
|
|
|
+ // </Radio.Group>
|
|
|
|
+ // ),
|
|
},
|
|
},
|
|
{
|
|
{
|
|
title: "分值",
|
|
title: "分值",
|
|
- dataIndex: "num",
|
|
|
|
|
|
+ dataIndex: "score",
|
|
align: "center",
|
|
align: "center",
|
|
width: "130px",
|
|
width: "130px",
|
|
- formItemProps: () => {
|
|
|
|
- return {
|
|
|
|
- rules: [{ required: true, message: "此项为必填项" }],
|
|
|
|
- };
|
|
|
|
- },
|
|
|
|
- renderFormItem: () => (
|
|
|
|
- <InputNumber
|
|
|
|
- variant="borderless"
|
|
|
|
- size="small"
|
|
|
|
- precision={0}
|
|
|
|
- placeholder="请填入正整数"
|
|
|
|
- className="w100"
|
|
|
|
- />
|
|
|
|
- ),
|
|
|
|
|
|
+ // formItemProps: () => {
|
|
|
|
+ // return {
|
|
|
|
+ // rules: [{ required: true, message: "此项为必填项" }],
|
|
|
|
+ // };
|
|
|
|
+ // },
|
|
|
|
+ // renderFormItem: () => (
|
|
|
|
+ // <InputNumber
|
|
|
|
+ // variant="borderless"
|
|
|
|
+ // size="small"
|
|
|
|
+ // precision={0}
|
|
|
|
+ // placeholder="请填入正整数"
|
|
|
|
+ // className="w100"
|
|
|
|
+ // />
|
|
|
|
+ // ),
|
|
},
|
|
},
|
|
{
|
|
{
|
|
title: "操作",
|
|
title: "操作",
|
|
align: "center",
|
|
align: "center",
|
|
valueType: "option",
|
|
valueType: "option",
|
|
- render: () => {
|
|
|
|
- return null;
|
|
|
|
|
|
+ render: (node, row) => {
|
|
|
|
+ return (
|
|
|
|
+ <DageTableActions
|
|
|
|
+ showEdit={false}
|
|
|
|
+ onDelete={handleDelete.bind(undefined, row)}
|
|
|
|
+ />
|
|
|
|
+ );
|
|
},
|
|
},
|
|
},
|
|
},
|
|
]}
|
|
]}
|
|
@@ -136,10 +178,11 @@ const SettingIndexPage: FC = () => {
|
|
}
|
|
}
|
|
toolBarRender={() => [
|
|
toolBarRender={() => [
|
|
<Search
|
|
<Search
|
|
|
|
+ value={keyword}
|
|
placeholder="请输入要搜索的指标名称"
|
|
placeholder="请输入要搜索的指标名称"
|
|
style={{ maxWidth: 335 }}
|
|
style={{ maxWidth: 335 }}
|
|
onChange={(v) => setKeyword(v.target.value)}
|
|
onChange={(v) => setKeyword(v.target.value)}
|
|
- onSearch={() => {}}
|
|
|
|
|
|
+ onSearch={handleSearch}
|
|
onReset={() => {}}
|
|
onReset={() => {}}
|
|
/>,
|
|
/>,
|
|
]}
|
|
]}
|
|
@@ -150,26 +193,27 @@ const SettingIndexPage: FC = () => {
|
|
return [defaultDoms.delete];
|
|
return [defaultDoms.delete];
|
|
},
|
|
},
|
|
onValuesChange: (record, recordList) => {
|
|
onValuesChange: (record, recordList) => {
|
|
- form.setFieldValue("deduction", recordList);
|
|
|
|
|
|
+ // form.setFieldValue("list", recordList);
|
|
|
|
+ setEditableKeys(recordList.map((i) => i.id));
|
|
},
|
|
},
|
|
}}
|
|
}}
|
|
/>
|
|
/>
|
|
</Form.Item>
|
|
</Form.Item>
|
|
</Form.Item>
|
|
</Form.Item>
|
|
- <FormPageFooter onSubmit={handleSubmit} onCancel={() => navigate(-1)} />
|
|
|
|
</Form>
|
|
</Form>
|
|
|
|
|
|
<AddIndexModal
|
|
<AddIndexModal
|
|
- checkedKeys={editableKeys}
|
|
|
|
open={indexModalVisible}
|
|
open={indexModalVisible}
|
|
onOk={handleAddIndexItem}
|
|
onOk={handleAddIndexItem}
|
|
onCancel={() => setIndexModalVisible(false)}
|
|
onCancel={() => setIndexModalVisible(false)}
|
|
/>
|
|
/>
|
|
<AddIndexTemplateModal
|
|
<AddIndexTemplateModal
|
|
open={indexTemplateModalVisible}
|
|
open={indexTemplateModalVisible}
|
|
- onOk={() => {}}
|
|
|
|
|
|
+ onOk={handleAddIndexItem}
|
|
onCancel={() => setIndexTemplateModalVisible(false)}
|
|
onCancel={() => setIndexTemplateModalVisible(false)}
|
|
/>
|
|
/>
|
|
|
|
+
|
|
|
|
+ {loading && <DageLoading />}
|
|
</PageContainer>
|
|
</PageContainer>
|
|
);
|
|
);
|
|
};
|
|
};
|