Commit c0188e80ed88cc7ded6d304b110db3805c00b334

Authored by 曾柯
1 parent b26bcd3b

考评bugfix0306

config/routers/performance.ts
@@ -91,7 +91,7 @@ export default [ @@ -91,7 +91,7 @@ export default [
91 }, 91 },
92 /** 考评数据导入==> 查看数据清单 */ 92 /** 考评数据导入==> 查看数据清单 */
93 { 93 {
94 - path: "/morax/evaDataImport/edit/:id?", 94 + path: "/morax/evaDataImport/edit/:id?/:num?",
95 component: "./performance/EvaDataImport/EditComfirm/index", 95 component: "./performance/EvaDataImport/EditComfirm/index",
96 }, 96 },
97 97
src/pages/performance/EvaDataImport/EditComfirm/index.tsx
@@ -25,7 +25,7 @@ function Index(props: Props) { @@ -25,7 +25,7 @@ function Index(props: Props) {
25 const [delay, setDelay] = useState(true); 25 const [delay, setDelay] = useState(true);
26 const [newData, setNewData] = useState<any>([]); 26 const [newData, setNewData] = useState<any>([]);
27 const { match } = props; 27 const { match } = props;
28 - const { id } = match.params; 28 + const { id, num } = match.params;
29 useEffect(() => { 29 useEffect(() => {
30 setId(id); 30 setId(id);
31 }, [id]); 31 }, [id]);
@@ -35,6 +35,7 @@ function Index(props: Props) { @@ -35,6 +35,7 @@ function Index(props: Props) {
35 setDelay(false); 35 setDelay(false);
36 } 36 }
37 }, [configId]); 37 }, [configId]);
  38 + console.log('num', num);
38 const { data, errMsg, setParams, loading } = useInitail(evaDataDetailApi, {}, {}, delay); 39 const { data, errMsg, setParams, loading } = useInitail(evaDataDetailApi, {}, {}, delay);
39 console.log(isArray(data)); 40 console.log(isArray(data));
40 useEffect(() => { 41 useEffect(() => {
@@ -46,7 +47,7 @@ function Index(props: Props) { @@ -46,7 +47,7 @@ function Index(props: Props) {
46 return ( 47 return (
47 <PageHeaderWrapper title="考评数据导入"> 48 <PageHeaderWrapper title="考评数据导入">
48 <Card> 49 <Card>
49 - <Table loading={loading} rowKey={(row) => `id${id}`} dataSource={newData}> 50 + <Table loading={loading} rowKey={(row) => `id${id}`} dataSource={newData} pagination={{ total: num }}>
50 <Column title="归属人员" dataIndex="userName" align="center" render={(name) => <span>{name || "--"}</span>} /> 51 <Column title="归属人员" dataIndex="userName" align="center" render={(name) => <span>{name || "--"}</span>} />
51 <Column title="归属门店" dataIndex="shopName" align="center" render={(name) => <span>{name || "--"}</span>} /> 52 <Column title="归属门店" dataIndex="shopName" align="center" render={(name) => <span>{name || "--"}</span>} />
52 <Column 53 <Column
@@ -80,7 +81,9 @@ function Index(props: Props) { @@ -80,7 +81,9 @@ function Index(props: Props) {
80 title="是否导入" 81 title="是否导入"
81 dataIndex="errorType" 82 dataIndex="errorType"
82 align="center" 83 align="center"
83 - render={(_: any, record: any) => (record.errorType ? <div className={st.no}>未导入</div> : <div className={st.yes}>已导入</div>)} 84 + render={(_: any, record: any) =>
  85 + record.errorType ? <div className={st.no}>未导入</div> : <div className={st.yes}>已导入</div>
  86 + }
84 /> 87 />
85 <Column 88 <Column
86 title="未导入原因" 89 title="未导入原因"
src/pages/performance/EvaDataImport/api.ts
@@ -44,3 +44,11 @@ export function evaDataDetailApi(params: { id: number }): http.PromisePageResp&lt;a @@ -44,3 +44,11 @@ export function evaDataDetailApi(params: { id: number }): http.PromisePageResp&lt;a
44 export function evaDataIndApi(): http.PromiseResp<any> { 44 export function evaDataIndApi(): http.PromiseResp<any> {
45 return request.get(`${MORAX_HOST}/erp/eval-indicator/indicators`, {}); 45 return request.get(`${MORAX_HOST}/erp/eval-indicator/indicators`, {});
46 } 46 }
  47 +
  48 +/**
  49 + * 保存上传人员数据
  50 + * http://testgate.feewee.cn/morax/erp/eval-indicator/save-import
  51 + */
  52 +export function saveEvaImportData(params: { key: string }) {
  53 + return request.get(`${MORAX_HOST}/erp/eval-indicator/save-import`, { params });
  54 +}
src/pages/performance/EvaDataImport/components/FileDatailsModal.tsx
@@ -19,6 +19,7 @@ import { TargetType, TargetTypeEnum } from &quot;@/pages/performance/entity&quot;; @@ -19,6 +19,7 @@ import { TargetType, TargetTypeEnum } from &quot;@/pages/performance/entity&quot;;
19 import { render } from "react-dom"; 19 import { render } from "react-dom";
20 import moment from "moment"; 20 import moment from "moment";
21 import { ReasonsEnum } from "../entity"; 21 import { ReasonsEnum } from "../entity";
  22 +import { saveEvaImportData } from "../api";
22 import { history } from "umi"; 23 import { history } from "umi";
23 import st from "./style.less"; 24 import st from "./style.less";
24 25
@@ -28,28 +29,40 @@ interface Props { @@ -28,28 +29,40 @@ interface Props {
28 visible: boolean; 29 visible: boolean;
29 fileData: any; 30 fileData: any;
30 tarOnCancel: Function; 31 tarOnCancel: Function;
  32 + setParams: Function;
  33 + innerParams: any;
31 } 34 }
32 -const columns = [  
33 - {  
34 - title: "目标名称",  
35 - dataIndex: "indicatorName",  
36 - key: "indicatorName",  
37 - },  
38 -  
39 - {  
40 - title: "目标值",  
41 - dataIndex: "targetValue",  
42 - key: "targetValue",  
43 - render: (value: Number, record: any) => {  
44 - return record.targetType === 2 ? `${value}%` : record.targetType === 3 ? `${value}元` : `${value}台`;  
45 - },  
46 - },  
47 -];  
48 -const TargetModal = ({ visible, fileData, tarOnCancel }: Props) => { 35 +const TargetModal = ({ visible, fileData, tarOnCancel, setParams, innerParams }: Props) => {
  36 + const [loading, setLoading] = useState<boolean>(false);
  37 + const onOk = async (key: string) => {
  38 + const pa = { key };
  39 + setLoading(true);
  40 + try {
  41 + const { success } = await saveEvaImportData(pa);
  42 + if (success) {
  43 + setLoading(false);
  44 + message.success(`数据上传成功`, 5);
  45 + // 重新刷新列表
  46 + setParams({ ...innerParams }, true);
  47 + tarOnCancel && tarOnCancel();
  48 + }
  49 + } catch (error: any) {
  50 + setLoading(false);
  51 + message.error(error.message);
  52 + }
  53 + };
49 return ( 54 return (
50 <> 55 <>
51 - <Modal title="导入数据详情" visible={visible} onCancel={() => tarOnCancel()} maskClosable={false} width={1500}>  
52 - <Table bordered dataSource={fileData.details}> 56 + <Modal
  57 + title="导入数据详情"
  58 + visible={visible}
  59 + onCancel={() => tarOnCancel()}
  60 + maskClosable={false}
  61 + width={1500}
  62 + onOk={() => onOk(fileData.key)}
  63 + confirmLoading={loading}
  64 + >
  65 + <Table bordered dataSource={fileData.details} pagination={{ total: fileData.num }}>
53 <Column title="归属人员" dataIndex="userName" align="center" render={(name) => <span>{name || "--"}</span>} /> 66 <Column title="归属人员" dataIndex="userName" align="center" render={(name) => <span>{name || "--"}</span>} />
54 <Column title="归属门店" dataIndex="shopName" align="center" render={(name) => <span>{name || "--"}</span>} /> 67 <Column title="归属门店" dataIndex="shopName" align="center" render={(name) => <span>{name || "--"}</span>} />
55 <Column 68 <Column
@@ -58,7 +71,7 @@ const TargetModal = ({ visible, fileData, tarOnCancel }: Props) =&gt; { @@ -58,7 +71,7 @@ const TargetModal = ({ visible, fileData, tarOnCancel }: Props) =&gt; {
58 align="center" 71 align="center"
59 render={(name) => <span>{name || "--"}</span>} 72 render={(name) => <span>{name || "--"}</span>}
60 /> 73 />
61 - <Column 74 + {/* <Column
62 title="指标值" 75 title="指标值"
63 dataIndex="indicatorValue" 76 dataIndex="indicatorValue"
64 align="center" 77 align="center"
@@ -71,7 +84,7 @@ const TargetModal = ({ visible, fileData, tarOnCancel }: Props) =&gt; { @@ -71,7 +84,7 @@ const TargetModal = ({ visible, fileData, tarOnCancel }: Props) =&gt; {
71 : "--"} 84 : "--"}
72 </span> 85 </span>
73 )} 86 )}
74 - /> 87 + /> */}
75 <Column 88 <Column
76 title="考核周期" 89 title="考核周期"
77 dataIndex="dataDate" 90 dataIndex="dataDate"
@@ -93,6 +106,12 @@ const TargetModal = ({ visible, fileData, tarOnCancel }: Props) =&gt; { @@ -93,6 +106,12 @@ const TargetModal = ({ visible, fileData, tarOnCancel }: Props) =&gt; {
93 render={(_: any, record: any) => (record.errorType ? ReasonsEnum[record.errorType] : "--")} 106 render={(_: any, record: any) => (record.errorType ? ReasonsEnum[record.errorType] : "--")}
94 /> 107 />
95 </Table> 108 </Table>
  109 + <div>
  110 + 成功条数: <span style={{ color: "#20c688" }}>{fileData.successNum}</span> 条
  111 + </div>
  112 + <div>
  113 + 失败条数: <span style={{ color: "#f4333c" }}>{fileData.errorNum}</span> 条
  114 + </div>
96 </Modal> 115 </Modal>
97 </> 116 </>
98 ); 117 );
src/pages/performance/EvaDataImport/index.tsx
@@ -20,7 +20,7 @@ export default () =&gt; { @@ -20,7 +20,7 @@ export default () =&gt; {
20 const [visible, setVisible] = useState<boolean>(false); 20 const [visible, setVisible] = useState<boolean>(false);
21 const uploadPerson: UploadProps = { 21 const uploadPerson: UploadProps = {
22 name: "file", 22 name: "file",
23 - action: "/api/morax/erp/eval-indicator/staff-indicator", 23 + action: "/api/morax/erp/eval-indicator/analysis-staff",
24 maxCount: 1, 24 maxCount: 1,
25 showUploadList: false, 25 showUploadList: false,
26 onChange(info) { 26 onChange(info) {
@@ -28,10 +28,8 @@ export default () =&gt; { @@ -28,10 +28,8 @@ export default () =&gt; {
28 console.log(info.file, info.fileList); 28 console.log(info.file, info.fileList);
29 } 29 }
30 if (info.file.status === "done") { 30 if (info.file.status === "done") {
31 - message.success(`${info.file.name} 上传成功`);  
32 - setParams({ ...innerParams }, true);  
33 - // setFileData(info.file.response.data);  
34 - // setVisible(true); 31 + setFileData(info.file.response.data);
  32 + setVisible(true);
35 } else if (info.file.status === "error") { 33 } else if (info.file.status === "error") {
36 message.error(`${info.file.name} 上传失败`); 34 message.error(`${info.file.name} 上传失败`);
37 } 35 }
@@ -39,7 +37,7 @@ export default () =&gt; { @@ -39,7 +37,7 @@ export default () =&gt; {
39 }; 37 };
40 const uploadShop: UploadProps = { 38 const uploadShop: UploadProps = {
41 name: "file", 39 name: "file",
42 - action: "/api/morax/erp/eval-indicator/shop-indicator", 40 + action: "/api/morax/erp/eval-indicator/analysis-shop",
43 maxCount: 1, 41 maxCount: 1,
44 showUploadList: false, 42 showUploadList: false,
45 onChange(info) { 43 onChange(info) {
@@ -47,8 +45,8 @@ export default () =&gt; { @@ -47,8 +45,8 @@ export default () =&gt; {
47 console.log(info.file, info.fileList); 45 console.log(info.file, info.fileList);
48 } 46 }
49 if (info.file.status === "done") { 47 if (info.file.status === "done") {
50 - message.success(`${info.file.name} 上传成功`);  
51 - setParams({ ...innerParams }, true); 48 + setFileData(info.file.response.data);
  49 + setVisible(true);
52 } else if (info.file.status === "error") { 50 } else if (info.file.status === "error") {
53 message.error(`${info.file.name} 上传失败`); 51 message.error(`${info.file.name} 上传失败`);
54 } 52 }
@@ -91,7 +89,7 @@ export default () =&gt; { @@ -91,7 +89,7 @@ export default () =&gt; {
91 </Row> 89 </Row>
92 <Table 90 <Table
93 loading={loading} 91 loading={loading}
94 - rowKey={(row) => `id${row.indicatorCode}`} 92 + rowKey={(row) => `id${row.id}`}
95 dataSource={list} 93 dataSource={list}
96 pagination={paginationConfig} 94 pagination={paginationConfig}
97 > 95 >
@@ -136,11 +134,11 @@ export default () =&gt; { @@ -136,11 +134,11 @@ export default () =&gt; {
136 align="center" 134 align="center"
137 dataIndex="enable" 135 dataIndex="enable"
138 width={150} 136 width={150}
139 - render={(text: boolean, record: KpiSetteing.KpiListItems) => ( 137 + render={(text: boolean, record: any) => (
140 <Space split={<Divider type="vertical" />}> 138 <Space split={<Divider type="vertical" />}>
141 <Typography.Link 139 <Typography.Link
142 onClick={() => { 140 onClick={() => {
143 - history.push(`/morax/evaDataImport/edit/${record.id}`); 141 + history.push(`/morax/evaDataImport/edit/${record.id}/${record.num}`);
144 }} 142 }}
145 > 143 >
146 查看 144 查看
@@ -149,7 +147,13 @@ export default () =&gt; { @@ -149,7 +147,13 @@ export default () =&gt; {
149 )} 147 )}
150 /> 148 />
151 </Table> 149 </Table>
152 - {/* <FileDatailsModal visible={visible} tarOnCancel={() => setVisible(false)} fileData={fileData} /> */} 150 + <FileDatailsModal
  151 + visible={visible}
  152 + tarOnCancel={() => setVisible(false)}
  153 + fileData={fileData}
  154 + setParams={setParams}
  155 + innerParams={innerParams}
  156 + />
153 </Card> 157 </Card>
154 </PageHeaderWrapper> 158 </PageHeaderWrapper>
155 ); 159 );
src/pages/performance/EvaGroupSetting/EditComfirm/components/AddEvaGroupModal.tsx
@@ -76,10 +76,10 @@ export default function AddIndicatorsModal(props: Props) { @@ -76,10 +76,10 @@ export default function AddIndicatorsModal(props: Props) {
76 76
77 // 查询门店 77 // 查询门店
78 useEffect(() => { 78 useEffect(() => {
79 - if (evaItem.postId) {  
80 - getDealerList(evaItem.postId); 79 + if (evaItem.post) {
  80 + getDealerList(evaItem.post.value);
81 } 81 }
82 - }, [evaItem.postId]); 82 + }, [evaItem]);
83 console.log("shopList", shopList); 83 console.log("shopList", shopList);
84 84
85 // 查询管理角色 85 // 查询管理角色
@@ -256,11 +256,28 @@ export default function AddIndicatorsModal(props: Props) { @@ -256,11 +256,28 @@ export default function AddIndicatorsModal(props: Props) {
256 } 256 }
257 </Form.Item> 257 </Form.Item>
258 258
259 - <Form.Item name="indicators" label="考评指标" rules={[{ required: true }]}>  
260 - <IndivatorsTable postId={postId} personModal={personModal} scopeType={scopeType} /> 259 + <Form.Item noStyle shouldUpdate={(prevValues, currentValues) => prevValues.rewards !== currentValues.rewards}>
  260 + {({ getFieldValue }) => {
  261 + const rewards = getFieldValue("rewards");
  262 + return (
  263 + <Form.Item name="indicators" label="考评指标" rules={[{ required: !(rewards && rewards.length > 0) }]}>
  264 + <IndivatorsTable postId={postId} personModal={personModal} scopeType={scopeType} />
  265 + </Form.Item>
  266 + );
  267 + }}
261 </Form.Item> 268 </Form.Item>
262 - <Form.Item name="rewards" label="考评奖惩" rules={[{ required: true }]}>  
263 - <RewardsTableSal postId={postId} personModal={personModal} scopeType={scopeType} /> 269 + <Form.Item
  270 + noStyle
  271 + shouldUpdate={(prevValues, currentValues) => prevValues.indicators !== currentValues.indicators}
  272 + >
  273 + {({ getFieldValue }) => {
  274 + const indicators = getFieldValue("indicators");
  275 + return (
  276 + <Form.Item name="rewards" label="考评奖惩" rules={[{ required: !(indicators && indicators.length > 0) }]}>
  277 + <RewardsTableSal postId={postId} personModal={personModal} scopeType={scopeType} />
  278 + </Form.Item>
  279 + );
  280 + }}
264 </Form.Item> 281 </Form.Item>
265 </Form> 282 </Form>
266 283
src/pages/performance/EvaGroupSetting/EditComfirm/components/RankModal.tsx
@@ -60,8 +60,13 @@ const TotalAmount = ({ @@ -60,8 +60,13 @@ const TotalAmount = ({
60 if (dataIndex == "upper" && isPercent == 2) { 60 if (dataIndex == "upper" && isPercent == 2) {
61 precision = 2; 61 precision = 2;
62 } 62 }
63 - const inputNode =  
64 - inputType === "number" ? <InputNumber precision={precision} max={isPercent == 2 ? 100 : 100000} /> : <Input />; 63 + let max = 0;
  64 + if ((dataIndex == "upper" || dataIndex == "lower") && isPercent == 2) {
  65 + max = 100;
  66 + } else {
  67 + max = 999999999999;
  68 + }
  69 + const inputNode = inputType === "number" ? <InputNumber precision={precision} max={max} /> : <Input />;
65 70
66 return ( 71 return (
67 <td {...restProps}> 72 <td {...restProps}>
src/pages/performance/EvaSetting/components/EditModal.tsx
@@ -98,7 +98,7 @@ export default function EditModal({ onClose, setItem, item, roleList }: Props) { @@ -98,7 +98,7 @@ export default function EditModal({ onClose, setItem, item, roleList }: Props) {
98 ))} 98 ))}
99 </Select> 99 </Select>
100 </Form.Item> 100 </Form.Item>
101 - <Form.Item name="belongSystem" label="归属系统" rules={[{ required: true }]}> 101 + {/* <Form.Item name="belongSystem" label="归属系统" rules={[{ required: true }]}>
102 <Select placeholder="请选择归属系统" showSearch allowClear labelInValue optionFilterProp="children"> 102 <Select placeholder="请选择归属系统" showSearch allowClear labelInValue optionFilterProp="children">
103 {list.map((item) => ( 103 {list.map((item) => (
104 <Option value={item.id} key={item.id}> 104 <Option value={item.id} key={item.id}>
@@ -106,7 +106,7 @@ export default function EditModal({ onClose, setItem, item, roleList }: Props) { @@ -106,7 +106,7 @@ export default function EditModal({ onClose, setItem, item, roleList }: Props) {
106 </Option> 106 </Option>
107 ))} 107 ))}
108 </Select> 108 </Select>
109 - </Form.Item> 109 + </Form.Item> */}
110 {/* 使用角色 */} 110 {/* 使用角色 */}
111 <Form.Item name="role" label="导入操作人员" rules={[{ required: true }]}> 111 <Form.Item name="role" label="导入操作人员" rules={[{ required: true }]}>
112 <Select placeholder="请选择导入操作角色类型" showSearch allowClear labelInValue optionFilterProp="children"> 112 <Select placeholder="请选择导入操作角色类型" showSearch allowClear labelInValue optionFilterProp="children">
src/pages/performance/EvaSetting/components/Filter.tsx
@@ -64,7 +64,7 @@ export default function Filter({ setParams, roleList }: Props) { @@ -64,7 +64,7 @@ export default function Filter({ setParams, roleList }: Props) {
64 </Option> 64 </Option>
65 ))} 65 ))}
66 </Select> 66 </Select>
67 - <Select 67 + {/* <Select
68 allowClear 68 allowClear
69 placeholder="选择归属系统" 69 placeholder="选择归属系统"
70 style={{ width: 260, marginRight: 5 }} 70 style={{ width: 260, marginRight: 5 }}
@@ -77,7 +77,7 @@ export default function Filter({ setParams, roleList }: Props) { @@ -77,7 +77,7 @@ export default function Filter({ setParams, roleList }: Props) {
77 {item.sysName} 77 {item.sysName}
78 </Select.Option> 78 </Select.Option>
79 ))} 79 ))}
80 - </Select> 80 + </Select> */}
81 <Select 81 <Select
82 placeholder="筛选禁用与启用" 82 placeholder="筛选禁用与启用"
83 style={{ width: 250, marginRight: 10, marginBottom: 10 }} 83 style={{ width: 250, marginRight: 10, marginBottom: 10 }}