Commit e9547bdfaede94df2e7cb6778825f05764c71a84

Authored by 曾柯
1 parent 0a78dfbc

人员质量对接接口

src/pages/performance/QualitySetting/api.ts
... ... @@ -21,14 +21,14 @@ export interface ShopList {
21 21 export function qualityConfigApi(
22 22 params: QualitySetteing.QualityListParams
23 23 ): http.PromisePageResp<QualitySetteing.QualityListItems> {
24   - return request.get(`${MORAX_HOST}/kpi/assess/page`, { params });
  24 + return request.get(`${MORAX_HOST}/erp/kpi/assess/page`, { params });
25 25 }
26 26 /**
27 27 * 人员清单(绩效转正后保护期员工)
28 28 * http://testgate.feewee.cn/morax/erp/kpi/real-time/staffs
29 29 */
30 30 export function fetchRealStaffs(params: QualitySetteing.RealStaffsParams): http.PromiseResp<QualitySetteing.RealStaffs[]> {
31   - return request.get(`${MORAX_HOST}/kpi/assess/regular-protection/staffs`, { params });
  31 + return request.get(`${MORAX_HOST}/erp/kpi/assess/regular-protection/staffs`, { params });
32 32 }
33 33  
34 34 /**
... ... @@ -36,7 +36,7 @@ export function fetchRealStaffs(params: QualitySetteing.RealStaffsParams): http.
36 36 * http://testgate.feewee.cn/morax/erp/kpi/real-time/staffs
37 37 */
38 38 export function fetchLevelDStaffs(params: QualitySetteing.RealStaffsParams): http.PromiseResp<QualitySetteing.RealStaffs[]> {
39   - return request.get(`${MORAX_HOST}/kpi/assess/real-time/staffs`, { params });
  39 + return request.get(`${MORAX_HOST}/erp/kpi/assess/real-time/staffs`, { params });
40 40 }
41 41  
42 42 /**
... ... @@ -44,7 +44,7 @@ export function fetchLevelDStaffs(params: QualitySetteing.RealStaffsParams): htt
44 44 * http://testgate.feewee.cn/morax/erp/kpi/real-time/staffs
45 45 */
46 46 export function fetchAssessStaffs(params: QualitySetteing.AssessStaffsParams): http.PromiseResp<QualitySetteing.RealStaffs[]> {
47   - return request.get(`${MORAX_HOST}/kpi/assess/assess/staffs`, { params });
  47 + return request.get(`${MORAX_HOST}/erp/erp/kpi/assess/assess/staffs`, { params });
48 48 }
49 49  
50 50 /**
... ... @@ -52,7 +52,7 @@ export function fetchAssessStaffs(params: QualitySetteing.AssessStaffsParams): h
52 52 * http://testgate.feewee.cn/morax/erp/kpi/indicators
53 53 */
54 54 export function saveQualitySetteing(params: QualitySetteing.QualityParams) {
55   - return request.post(`${MORAX_HOST}/kpi/assess/save`, params);
  55 + return request.post(`${MORAX_HOST}/erp/kpi/assess/save`, params);
56 56 }
57 57  
58 58 /**
... ... @@ -60,5 +60,5 @@ export function saveQualitySetteing(params: QualitySetteing.QualityParams) {
60 60 * http://testgate.feewee.cn/morax/erp/kpi/indicators
61 61 */
62 62 export function delQualitySetteing(params: {id: number}) {
63   - return request.get(`${MORAX_HOST}/kpi/assess/del`, {params});
  63 + return request.get(`${MORAX_HOST}/erp/kpi/assess/del`, { params });
64 64 }
... ...
src/pages/performance/QualitySetting/components/AddIndicatorsModal.tsx
... ... @@ -8,13 +8,16 @@ import useInitail from &quot;@/hooks/useInitail&quot;;
8 8 import { KpiGroupSetteing } from "@/pages/performance/KpiGroupSetting/interface";
9 9 import { getManagerRoleListApi } from "@/common/api";
10 10 import { QualitySetteing } from "@/pages/performance/QualitySetting/interface";
  11 +import EvaPersonModal from "./EvaPersonModal";
  12 +import { PageLoading } from "@ant-design/pro-layout";
11 13  
12 14 const Option = Select.Option;
13 15 interface Props {
14 16 visible: boolean;
15 17 onCancel: Function;
16 18 postId?: number;
17   - shopIds?: number[];
  19 + shopIds: string;
  20 + shopNames: string;
18 21 onOk: (vales: any) => void;
19 22 currentItem: QualitySetteing.QualityParams;
20 23 comItem: QualitySetteing.Details;
... ... @@ -29,14 +32,37 @@ export default function AddIndicatorsModal(props: Props) {
29 32 const [form] = Form.useForm();
30 33  
31 34 // 是否为百分比
32   - const { visible, onCancel, postId, shopIds, onOk, currentItem, comItem, type } = props;
  35 + const { visible, onCancel, postId, shopIds, onOk, currentItem, comItem, type, shopNames } = props;
  36 + // console.log(shopIds, shopNames, "sf");
  37 + const [evaPerson, setEvaPerson] = useState<QualitySetteing.EvaPerson>({
  38 + visible: false,
  39 + shopIds: "",
  40 + shopNames: "",
  41 + roleCodes: "",
  42 + roleNames: "",
  43 + });
33 44 const [roleList, setRoleList] = useState<any>([]);
34 45 useEffect(() => {
  46 + if (shopIds && shopNames) {
  47 + setEvaPerson({ ...evaPerson, shopIds, shopNames });
  48 + }
  49 + }, [shopIds, shopNames]);
  50 + // console.log("evaPerson", evaPerson);
  51 + useEffect(() => {
35 52 getRoleList();
36 53 // 修改
37   - if (visible && currentItem.id) {
  54 + if (visible && comItem.role) {
  55 + if (comItem.role) {
  56 + const roleCodes = comItem.role.map((item: any) => item.value).join(",");
  57 + const roleNames = comItem.role.map((item: any) => item.label).join(",");
  58 + setEvaPerson({
  59 + ...evaPerson,
  60 + roleCodes,
  61 + roleNames,
  62 + });
  63 + }
38 64 form.setFieldsValue({
39   - ...currentItem,
  65 + ...comItem,
40 66 });
41 67 }
42 68 }, [visible]);
... ... @@ -71,11 +97,20 @@ export default function AddIndicatorsModal(props: Props) {
71 97 console.log(fieldsValue);
72 98 const pa: any = transformDTO(fieldsValue);
73 99 console.log("大", pa);
  100 + onOk(pa);
  101 + onCancel && onCancel();
74 102 }
75   - console.log('type', type);
  103 + // 人员查看
  104 + const personView = () => {
  105 + if (!evaPerson.roleCodes) {
  106 + message.error("请选择考核对象角色");
  107 + return;
  108 + }
  109 + setEvaPerson({ ...evaPerson, visible: true });
  110 + };
76 111 return (
77 112 <Modal
78   - title={`${currentItem.id ? "编辑" : "新增"}考核对象`}
  113 + title={`${comItem.role ? "编辑" : "新增"}考核对象`}
79 114 visible={visible}
80 115 maskClosable={false}
81 116 afterClose={() => {
... ... @@ -109,6 +144,17 @@ export default function AddIndicatorsModal(props: Props) {
109 144 showSearch
110 145 optionFilterProp="children"
111 146 mode="multiple"
  147 + onChange={(
  148 + roles: {
  149 + key: number;
  150 + label: string;
  151 + value: string;
  152 + }[]
  153 + ) => {
  154 + const roleCodes = roles.map((item) => item.value).join(",");
  155 + const roleNames = roles.map((item) => item.label).join(",");
  156 + setEvaPerson({ ...evaPerson, roleCodes, roleNames });
  157 + }}
112 158 >
113 159 {roleList.map((item: any) => (
114 160 <Option value={item.roleCode}>{item.roleName}</Option>
... ... @@ -116,36 +162,128 @@ export default function AddIndicatorsModal(props: Props) {
116 162 </Select>
117 163 </Form.Item>
118 164 <div style={{ marginBottom: 15, marginLeft: 220 }}>
119   - <a onClick={() => console.log(123)}>{`考核人员清单 >`}</a>
  165 + <a onClick={() => personView()}>{`考核人员清单 >`}</a>
120 166 </div>
121 167 {type == 2 ? <div style={{ marginBottom: 15, marginLeft: 220 }}>考核方式:绩效排名差</div> : null}
122 168 <div style={{ marginBottom: 15, marginLeft: 220 }}>• 处罚:</div>
123 169 <Form.Item
124   - name="a"
125   - label="扣绩效分"
126   - rules={[{ required: true, message: "请输入扣绩效分" }]}
  170 + name="penaltyScore"
  171 + label="处罚绩效分"
  172 + rules={[{ required: true, message: "请输入处罚绩效分" }]}
  173 + style={{ marginBottom: 15 }}
  174 + >
  175 + <InputNumber placeholder="请输入处罚绩效分" addonAfter="分/名次" style={{ width: "100%" }} min={0} />
  176 + </Form.Item>
  177 + {type == 2 ? (
  178 + <Form.Item
  179 + name="capPersonPenaltyScore"
  180 + label="单人处罚封顶分数"
  181 + rules={[{ required: true, message: "请输入单人处罚封顶分数" }]}
  182 + style={{ marginBottom: 15 }}
  183 + >
  184 + <InputNumber placeholder="请输入单人处罚封顶分数" addonAfter="分/人" style={{ width: "100%" }} min={0} />
  185 + </Form.Item>
  186 + ) : null}
  187 + <Form.Item
  188 + name="capPenaltyScore"
  189 + label="封顶处罚分数"
  190 + rules={[{ required: true, message: "请输入封顶处罚分数" }]}
127 191 style={{ marginBottom: 15 }}
128 192 >
129   - <Input placeholder="请输入扣绩效分" addonAfter="分/名次" />
  193 + <InputNumber placeholder="请输入封顶处罚分数" addonAfter="分" style={{ width: "100%" }} min={0} />
130 194 </Form.Item>
131 195 <Form.Item
132   - name="b"
133   - label="单人处罚封顶"
134   - rules={[{ required: true, message: "请输入单人处罚封顶分数" }]}
  196 + name="penaltyMoney"
  197 + label="处罚金额"
  198 + rules={[{ required: true, message: "请输入处罚金额" }]}
135 199 style={{ marginBottom: 15 }}
136 200 >
137   - <Input placeholder="请输入单人处罚封顶分数" addonAfter="分/人" />
  201 + <InputNumber placeholder="请输入处罚金额" addonAfter="元/名次" style={{ width: "100%" }} min={0} />
138 202 </Form.Item>
  203 + {type == 2 ? (
  204 + <Form.Item
  205 + name="capPersonPenaltyMoney"
  206 + label="单人处罚封顶金额"
  207 + rules={[{ required: true, message: "请输入单人处罚封顶金额" }]}
  208 + style={{ marginBottom: 15 }}
  209 + >
  210 + <InputNumber placeholder="请输入单人处罚封顶金额" addonAfter="元/人" style={{ width: "100%" }} min={0} />
  211 + </Form.Item>
  212 + ) : null}
139 213 <Form.Item
140   - name="c"
141   - label="考核封顶"
142   - rules={[{ required: true, message: "请输入考核封顶分数" }]}
  214 + name="capPenaltyMoney"
  215 + label="封顶处罚金额"
  216 + rules={[{ required: true, message: "请输入封顶处罚金额" }]}
143 217 style={{ marginBottom: 15 }}
144 218 >
145   - <Input placeholder="请输入考核封顶分数" addonAfter="分" />
  219 + <InputNumber placeholder="请输入封顶处罚金额" addonAfter="元" style={{ width: "100%" }} min={0} />
146 220 </Form.Item>
  221 + {type == 2 ? (
  222 + <>
  223 + <div style={{ marginBottom: 15, marginLeft: 220 }}>• 奖励:</div>
  224 + <Form.Item
  225 + name="awardScore"
  226 + label="奖励绩效分"
  227 + rules={[{ required: true, message: "请输入奖励绩效分" }]}
  228 + style={{ marginBottom: 15 }}
  229 + >
  230 + <InputNumber placeholder="请输入奖励绩效分" addonAfter="分/名次" style={{ width: "100%" }} min={0} />
  231 + </Form.Item>
  232 + <Form.Item
  233 + name="capPersonAwardScore"
  234 + label="单人奖励封顶分数"
  235 + rules={[{ required: true, message: "请输入单人奖励封顶分数" }]}
  236 + style={{ marginBottom: 15 }}
  237 + >
  238 + <InputNumber
  239 + placeholder="请输入单人奖励封顶分数"
  240 + addonAfter="分/人"
  241 + style={{ width: "100%" }}
  242 + min={0}
  243 + />
  244 + </Form.Item>
  245 + <Form.Item
  246 + name="capAwardScore"
  247 + label="封顶奖励分数"
  248 + rules={[{ required: true, message: "请输入封顶奖励分数" }]}
  249 + style={{ marginBottom: 15 }}
  250 + >
  251 + <InputNumber placeholder="请输入封顶奖励分数" addonAfter="分" style={{ width: "100%" }} min={0} />
  252 + </Form.Item>
  253 + <Form.Item
  254 + name="awardMoney"
  255 + label="奖励金额"
  256 + rules={[{ required: true, message: "请输入奖励金额" }]}
  257 + style={{ marginBottom: 15 }}
  258 + >
  259 + <InputNumber placeholder="请输入奖励金额" addonAfter="元/名次" style={{ width: "100%" }} min={0} />
  260 + </Form.Item>
  261 + <Form.Item
  262 + name="capPersonAwardMoney"
  263 + label="单人奖励封顶金额"
  264 + rules={[{ required: true, message: "请输入单人奖励封顶金额" }]}
  265 + style={{ marginBottom: 15 }}
  266 + >
  267 + <InputNumber
  268 + placeholder="请输入单人奖励封顶金额"
  269 + addonAfter="元/人"
  270 + style={{ width: "100%" }}
  271 + min={0}
  272 + />
  273 + </Form.Item>
  274 + <Form.Item
  275 + name="capAwardMoney"
  276 + label="封顶奖励金额"
  277 + rules={[{ required: true, message: "请输入封顶奖励金额" }]}
  278 + style={{ marginBottom: 15 }}
  279 + >
  280 + <InputNumber placeholder="请输入封顶奖励金额" addonAfter="元" style={{ width: "100%" }} min={0} />
  281 + </Form.Item>
  282 + </>
  283 + ) : null}
147 284 </Form>
148 285 </Spin>
  286 + <EvaPersonModal item={evaPerson} setEvaPerson={setEvaPerson} />
149 287 </Modal>
150 288 );
151 289 }
... ...
src/pages/performance/QualitySetting/components/EditModal.tsx
1 1 import React, { useState, useEffect } from "react";
2 2 import { Form, Modal, message, Input, Select, Radio, Checkbox, InputNumber } from "antd";
3   -// import { saveKpiIndicators } from "../api";
4 3 import usePagination from "@/hooks/usePagination";
5 4 import { systemListApi } from "@/pages/admin/Privilege/api";
6 5 import { transformDTO, transformFormData } from "../entity";
7 6 import { KpiGroupSetteing } from "@/pages/performance/KpiGroupSetting/interface";
8 7 import * as api from "../../KpiGroupSetting/EditComfirm/api";
9   -import { ShopList } from "../api";
  8 +import { ShopList, saveQualitySetteing } from "../api";
10 9 import { getAllPostListApi } from "@/common/api";
11 10 import ShopSelectNew from "@/components/ShopSelectNew";
12 11 import PersonModal from "./PersonModal";
... ... @@ -38,47 +37,73 @@ export default function EditModal({ onClose, setItem, item, roleList }: Props) {
38 37 const [personModal, setPersonModal] = useState<QualitySetteing.Person>({
39 38 visible: false,
40 39 postId: 0,
41   - shopIds: [],
  40 + shopIds: "",
  41 + shopNames: "",
42 42 });
43 43 // 存储角色列表
44 44 const { list } = usePagination(systemListApi, { current: 1, pageSize: 500 });
  45 + const onCel = () => {
  46 + onClose?.(false);
  47 + setPersonModal({ ...personModal, postId: 0, shopIds: "", shopNames: "" });
  48 + };
45 49  
46 50 useEffect(() => {
47 51 if (visible && currentItem.id) {
48 52 if (currentItem.shop && currentItem.post) {
49 53 const shopIds = currentItem.shop.map((item: any) => item.value);
  54 + const shopNames = currentItem.shop.map((item: any) => item.label);
50 55 const postId = currentItem.post.value;
51 56 setPersonModal({
52 57 postId,
53 58 shopIds: shopIds.join(","),
54 59 visible: false,
  60 + shopNames: shopNames.join(","),
55 61 });
56 62 }
57 63 const result = transformFormData(currentItem, roleList, list);
58 64 form.setFieldsValue({ ...result });
59 65 setType(currentItem.type);
60 66 }
61   - // const newType = form.getFieldValue("type");
62   - // console.log(newType);
63   - // setType(newType);
64 67 }, [visible]);
  68 + function fetchSave(pa: any) {
  69 + setSaveLoading(true);
  70 + saveQualitySetteing(pa)
  71 + .then((res) => {
  72 + setSaveLoading(false);
  73 + message.success(res.result);
  74 + onClose?.(true);
  75 + })
  76 + .catch((e) => {
  77 + setSaveLoading(false);
  78 + message.error(e.message);
  79 + });
  80 + }
65 81 function handleSave(values: any) {
66 82 const pa = transformDTO(values);
67 83 if (currentItem.id) {
68 84 pa.id = currentItem.id;
69 85 }
70 86 console.log(pa);
71   - // setSaveLoading(true);
72   - // saveKpiIndicators(pa)
73   - // .then((res) => {
74   - // setSaveLoading(false);
75   - // message.success(res.result);
76   - // onClose?.(true);
77   - // })
78   - // .catch((e) => {
79   - // setSaveLoading(false);
80   - // message.error(e.message);
81   - // });
  87 + if (pa.type == 2) {
  88 + pa.details.forEach((item: any) => {
  89 + if (
  90 + !item.capPersonPenaltyScore ||
  91 + !item.capPersonPenaltyMoney ||
  92 + !item.awardScore ||
  93 + !item.capPersonAwardScore ||
  94 + !item.capAwardScore ||
  95 + !item.awardMoney ||
  96 + !item.capPersonAwardMoney ||
  97 + !item.capAwardMoney
  98 + ) {
  99 + message.error("考核详情中存在没有填的内容");
  100 + } else {
  101 + fetchSave(pa);
  102 + }
  103 + });
  104 + } else {
  105 + fetchSave(pa);
  106 + }
82 107 }
83 108 // 根据岗位查门店
84 109 function getDealerList(postId: number) {
... ... @@ -110,7 +135,7 @@ export default function EditModal({ onClose, setItem, item, roleList }: Props) {
110 135 title={`${currentItem.id ? "编辑" : "新增"}人员质量考核`}
111 136 open={visible}
112 137 onOk={form.submit}
113   - onCancel={() => onClose?.(false)}
  138 + onCancel={() => onCel()}
114 139 maskClosable={false}
115 140 getContainer={false}
116 141 confirmLoading={saveLoading}
... ... @@ -129,7 +154,8 @@ export default function EditModal({ onClose, setItem, item, roleList }: Props) {
129 154 setPersonModal({
130 155 postId: post.value,
131 156 visible: false,
132   - shopIds: [],
  157 + shopIds: "",
  158 + shopNames: "",
133 159 });
134 160 setPostId(post.value);
135 161 form.setFieldsValue({ shop: [] });
... ... @@ -156,8 +182,9 @@ export default function EditModal({ onClose, setItem, item, roleList }: Props) {
156 182 value: number;
157 183 }[]
158 184 ) => {
159   - const shopIds = shops.map((item) => item.value);
160   - setPersonModal({ ...personModal, shopIds });
  185 + const shopIds = shops.map((item) => item.value).join(",");
  186 + const shopNames = shops.map((item) => item.label).join(",");
  187 + setPersonModal({ ...personModal, shopIds, shopNames });
161 188 }}
162 189 />
163 190 </Form.Item>
... ...
src/pages/performance/QualitySetting/components/EvaPersonModal.tsx 0 → 100755
  1 +import React, { useState, useEffect } from "react";
  2 +import {
  3 + Input,
  4 + Select,
  5 + Modal,
  6 + Form,
  7 + message,
  8 + Tooltip,
  9 + Tag,
  10 + Button,
  11 + Space,
  12 + Table,
  13 +} from "antd";
  14 +import { MinusCircleOutlined, PlusOutlined } from "@ant-design/icons";
  15 +import {
  16 + transformDTO,
  17 + transformFormData,
  18 +} from "../entity";
  19 +import _ from "lodash";
  20 +import { systemListApi } from "@/pages/admin/Privilege/api";
  21 +import usePagination from "@/hooks/usePagination";
  22 +import { getAllRoleCodeApi } from "@/common/api";
  23 +import useInitial from "@/hooks/useInitail";
  24 +import toChineseBig from "@/utils/toChinease";
  25 +// fetchRealtimeStaffs;
  26 +import { fetchAssessStaffs, fetchLevelDStaffs } from "../api";
  27 +import { QualitySetteing } from "@/pages/performance/QualitySetting/interface";
  28 +
  29 +const { Column } = Table;
  30 +interface Props {
  31 + item: QualitySetteing.EvaPerson;
  32 + setEvaPerson: Function;
  33 +}
  34 +
  35 +export default function PersonModal({ item, setEvaPerson }: Props) {
  36 + const { visible, shopIds, shopNames, roleCodes, roleNames } = item;
  37 +
  38 + const [delay, setDelay] = useState(true);
  39 + const { data, setParams, loading } = useInitial(
  40 + fetchAssessStaffs,
  41 + [],
  42 + { shopIds, shopNames, roleCodes, roleNames },
  43 + delay
  44 + );
  45 +
  46 + useEffect(() => {
  47 + if (visible && shopIds.length > 0 && shopNames.length > 0 && roleCodes.length > 0 && roleNames.length > 0) {
  48 + setParams({ shopIds, shopNames, roleCodes, roleNames }, true);
  49 + setDelay(false);
  50 + }
  51 + }, [visible]);
  52 +
  53 + return (
  54 + <Modal
  55 + title="考核人员清单"
  56 + open={visible}
  57 + onCancel={() => setEvaPerson({ ...item, visible: false })}
  58 + footer={null}
  59 + >
  60 + {/* <Input.Search
  61 + allowClear
  62 + placeholder="请输入员工名称"
  63 + onSearch={(value) => {
  64 + setParams({ staffName: value, shopIds, shopNames, roleCodes, roleNames }, true);
  65 + }}
  66 + style={{ width: 250, marginRight: 10, marginBottom: 10 }}
  67 + /> */}
  68 + <Table
  69 + dataSource={data}
  70 + loading={loading}
  71 + rowKey={(row) => `id${row.userId}`}
  72 + pagination={{ total: data.length, pageSize: 10 }}
  73 + bordered
  74 + >
  75 + <Column title="员工" dataIndex="userName" key="userName" />
  76 + <Column title="当前岗位" dataIndex="postName" key="postName" />
  77 + <Column title="在职门店" dataIndex="shopName" key="shopName" />
  78 + <Column
  79 + title="不符合原因"
  80 + dataIndex="ignoreCauseDesc"
  81 + key="ignoreCauseDesc"
  82 + render={(text) => text || "--"}
  83 + />
  84 + </Table>
  85 + </Modal>
  86 + );
  87 +}
... ...
src/pages/performance/QualitySetting/components/IndivatorsTable.tsx
... ... @@ -6,6 +6,7 @@ import { KpiGroupSetteing } from &quot;@/pages/performance/KpiGroupSetting/interface&quot;
6 6 import RoleModal from "./RoleModal";
7 7 import AddIndicatorsModal from "./AddIndicatorsModal";
8 8 import { QualitySetteing } from "@/pages/performance/QualitySetting/interface";
  9 +import _ from "lodash";
9 10  
10 11 interface Props {
11 12 value?: any[];
... ... @@ -18,10 +19,9 @@ interface Props {
18 19 type Item = QualitySetteing.QualityParams;
19 20 type CommissionParams = QualitySetteing.Details;
20 21 const IndivatorsTable = ({ value, onChange, personModal, type }: Props) => {
21   - const { postId, shopIds } = personModal;
  22 + const { postId, shopIds, shopNames } = personModal;
  23 +
22 24 const [tableData, setTableData] = useState<Item[]>(value || []);
23   - const [tarVisible, setTarVisible] = useState(false);
24   - const [tarCommissionParams, setTarCommissionParams] = useState<[]>([]);
25 25 // 添加指标Modal
26 26 const [visible, setVisible] = useState(false);
27 27 // 存储当前编辑数据
... ... @@ -38,6 +38,14 @@ const IndivatorsTable = ({ value, onChange, personModal, type }: Props) =&gt; {
38 38 });
39 39 // 添加指标
40 40 const addIndicators = () => {
  41 + if (!postId) {
  42 + message.error("请先选择岗位");
  43 + return;
  44 + }
  45 + if (!shopIds) {
  46 + message.error("请先选择门店");
  47 + return;
  48 + }
41 49 setVisible(true);
42 50 };
43 51 useEffect(() => {
... ... @@ -45,20 +53,35 @@ const IndivatorsTable = ({ value, onChange, personModal, type }: Props) =&gt; {
45 53 setTableData([...value]);
46 54 }
47 55 }, [value]);
48   -
  56 + function transformFormData(detail: QualitySetteing.Details): any {
  57 + let formData: any = {};
  58 + _.each(detail, (value: any, key: string) => {
  59 + switch (key) {
  60 + case "roleCodes":
  61 + const _roleCodesOptions: string[] = value || [];
  62 + if (_roleCodesOptions.length) {
  63 + const _roleCodes = _roleCodesOptions.map((item, index) => ({
  64 + value: item,
  65 + label: detail.roleNames[index],
  66 + }));
  67 + formData.role = _roleCodes;
  68 + }
  69 + break;
  70 + default:
  71 + formData[key] = value;
  72 + break;
  73 + }
  74 + });
  75 + return formData;
  76 + }
49 77 // 编辑
50   - const onEdit = (record: Item, index: number) => {
  78 + const onEdit = (record: CommissionParams, index: number) => {
51 79 setVisible(true);
52   - setCurrentItem({ ...record, index });
53   - console.log({ ...record, index });
54   - };
55   -
56   - const lookTar = (record: any) => {
57   - setTarVisible(true);
58   - setTarCommissionParams(record);
  80 + const res = transformFormData(record);
  81 + setComItem({ ...res, index });
59 82 };
60 83 // 删除
61   - const _onDelete = (record: Item, index: number) => {
  84 + const _onDelete = (record: CommissionParams, index: number) => {
62 85 const tempData = [...(value || [])];
63 86 tempData.splice(index, 1); // splice直接修改原数组,不会返回新数组
64 87 onChange && onChange([...tempData]);
... ... @@ -69,25 +92,39 @@ const IndivatorsTable = ({ value, onChange, personModal, type }: Props) =&gt; {
69 92 const columns = [
70 93 {
71 94 title: "考核对象",
72   - key: "name1",
  95 + key: "roleCodes",
73 96 render: (_: any, record: any) => (
74 97 <Typography.Link onClick={() => setRoleModal({ visible: true, record })}>查看</Typography.Link>
75 98 ),
76 99 },
77 100 {
78   - title: "考核人员清单",
79   - dataIndex: "baseScore",
80   - key: "baseScore",
  101 + title: "考核方式",
  102 + key: "evaType",
  103 + render: (_: any, record: any) => "按绩效排名差",
81 104 },
82 105 {
83   - title: "考核方式",
84   - dataIndex: "baseScore2",
85   - key: "baseScore2",
  106 + title: "操作",
  107 + key: "operation",
  108 + render: (_: any, record: CommissionParams, index: number) => (
  109 + <Space split={<Divider type="vertical" />}>
  110 + <Typography.Link onClick={() => onEdit(record, index)}>编辑</Typography.Link>
  111 + <Typography.Link onClick={() => _onDelete(record, index)}>删除</Typography.Link>
  112 + </Space>
  113 + ),
  114 + },
  115 + ];
  116 + const smallColumns = [
  117 + {
  118 + title: "考核对象",
  119 + key: "roleCodes",
  120 + render: (_: any, record: any) => (
  121 + <Typography.Link onClick={() => setRoleModal({ visible: true, record })}>查看</Typography.Link>
  122 + ),
86 123 },
87 124 {
88 125 title: "操作",
89 126 key: "operation",
90   - render: (_: any, record: Item, index: number) => (
  127 + render: (_: any, record: CommissionParams, index: number) => (
91 128 <Space split={<Divider type="vertical" />}>
92 129 <Typography.Link onClick={() => onEdit(record, index)}>编辑</Typography.Link>
93 130 <Typography.Link onClick={() => _onDelete(record, index)}>删除</Typography.Link>
... ... @@ -97,7 +134,6 @@ const IndivatorsTable = ({ value, onChange, personModal, type }: Props) =&gt; {
97 134 ];
98 135 const onCancel = () => {
99 136 setVisible(false);
100   - setCurrentItem({});
101 137 setComItem({});
102 138 };
103 139 return (
... ... @@ -111,7 +147,7 @@ const IndivatorsTable = ({ value, onChange, personModal, type }: Props) =&gt; {
111 147 </div>
112 148 }
113 149 >
114   - <Table bordered dataSource={value || []} rowKey={(record: Item) => String(record.id)} columns={columns} />
  150 + <Table bordered dataSource={value || []} rowKey={(record: Item) => String(record.id)} columns={type == 2 ? columns : smallColumns} />
115 151 </Card>
116 152 <AddIndicatorsModal
117 153 visible={visible}
... ... @@ -120,13 +156,14 @@ const IndivatorsTable = ({ value, onChange, personModal, type }: Props) =&gt; {
120 156 onCancel={onCancel}
121 157 postId={postId}
122 158 shopIds={shopIds}
  159 + shopNames={shopNames}
123 160 type={type}
124 161 onOk={(values) => {
125   - if (!currentItem.id) {
  162 + if (!comItem.role) {
126 163 tableData.push(values);
127 164 onChange && onChange(tableData);
128 165 } else {
129   - const res = tableData.map((item, index) => (index === currentItem.index ? { ...values } : item));
  166 + const res = tableData.map((item, index) => (index === comItem.index ? { ...values } : item));
130 167 onChange && onChange(res);
131 168 }
132 169 }}
... ...
src/pages/performance/QualitySetting/components/PersonModal.tsx
... ... @@ -43,7 +43,6 @@ export default function PersonModal({ item, setPersonModal, type }: Props) {
43 43 { postId, shopIds },
44 44 delay
45 45 );
46   -
47 46 useEffect(() => {
48 47 if (visible && postId && shopIds.length > 0) {
49 48 setParams({ postId, shopIds }, true);
... ... @@ -53,7 +52,7 @@ export default function PersonModal({ item, setPersonModal, type }: Props) {
53 52  
54 53 return (
55 54 <Modal
56   - title="人员查看"
  55 + title="人员清单"
57 56 visible={visible}
58 57 onCancel={() => setPersonModal({ ...item, visible: false })}
59 58 footer={null}
... ...
src/pages/performance/QualitySetting/interface.d.ts
... ... @@ -27,6 +27,7 @@ declare namespace QualitySetteing {
27 27 details: Details[];
28 28 }
29 29 interface Details {
  30 + index: number;
30 31 id?: number;
31 32 kpiAssessId?: number;
32 33 roleCodes: string[];
... ... @@ -44,6 +45,7 @@ declare namespace QualitySetteing {
44 45 capPersonAwardMoney: number;
45 46 capAwardMoney: number;
46 47 groupId?: number;
  48 + role: any;
47 49 }
48 50  
49 51 /**
... ... @@ -64,18 +66,27 @@ declare namespace QualitySetteing {
64 66 interface Person {
65 67 visible: boolean;
66 68 postId: number; //岗位id
67   - shopIds: number[]; //门店id
  69 + shopIds: string; //门店id
  70 + shopNames: string;
  71 + }
  72 + interface EvaPerson {
  73 + visible: boolean;
  74 + shopIds: string; //门店id
  75 + shopNames: string;
  76 + roleCodes: string;
  77 + roleNames: string;
68 78 }
69 79 interface RealStaffsParams {
70   - shopIds: number[]; // 门店id
  80 + shopIds: string; // 门店id
71 81 postId: number; //岗位id
72 82 staffName?: string; // 员工名称
73 83 }
74 84 interface AssessStaffsParams {
75   - shopIds: string[]; // 门店id
76   - postId: number; //岗位id
77   - roleCodes: string[];
78   - roleNames: string[];
  85 + shopIds: string; // 门店id
  86 + shopNames: string; //岗位id
  87 + roleCodes: string;
  88 + roleNames: string;
  89 + staffName?: string;
79 90 }
80 91 interface RealStaffs {
81 92 kpiGroupId: number; //绩效组id
... ...