Commit 2951e18b6284737deeae2ca3c26454196fb2385a
Merge remote-tracking branch 'origin/master' into test_line
Showing
9 changed files
with
351 additions
and
756 deletions
src/pages/cas/GrossProfit/api.ts
1 | -import { http } from "@/typing/http"; | |
2 | -import request from "@/utils/request"; | |
3 | -import { CAS_HOST } from "@/utils/host"; | |
4 | -import { GrossProfitStatusEnum } from "./entity"; | |
1 | +import { http } from '@/typing/http'; | |
2 | +import request from '@/utils/request'; | |
3 | +import { CAS_HOST } from '@/utils/host'; | |
4 | +import { GrossProfitStatusEnum } from './entity'; | |
5 | 5 | |
6 | 6 | type PromisePageResp<T> = Promise<http.PageResponse<T>>; |
7 | 7 | type PromiseResp<T> = http.PromiseResp<T>; |
... | ... | @@ -24,9 +24,7 @@ export interface ListItem { |
24 | 24 | } |
25 | 25 | |
26 | 26 | /** 各个月度毛利目标查询 */ |
27 | -export function getGrossProfitListApi( | |
28 | - params: ListParam | |
29 | -): PromisePageResp<ListItem> { | |
27 | +export function getGrossProfitListApi(params: ListParam): PromisePageResp<ListItem> { | |
30 | 28 | return request.get(`${CAS_HOST}/erp/grossProfit`, { params }); |
31 | 29 | } |
32 | 30 | |
... | ... | @@ -39,9 +37,7 @@ export interface GetNoGPShopItem { |
39 | 37 | } |
40 | 38 | |
41 | 39 | /** modal 未设置毛利目标门店列表 */ |
42 | -export function getNoGPShopListApi( | |
43 | - params: GetNoGPShopListApiParams | |
44 | -): PromiseResp<GetNoGPShopItem[]> { | |
40 | +export function getNoGPShopListApi(params: GetNoGPShopListApiParams): PromiseResp<GetNoGPShopItem[]> { | |
45 | 41 | return request.get(`${CAS_HOST}/erp/grossProfit/shopList`, { params }); |
46 | 42 | } |
47 | 43 | |
... | ... | @@ -71,9 +67,7 @@ export interface GetGPShopListApiRes { |
71 | 67 | } |
72 | 68 | |
73 | 69 | /** step1 当月已设置毛利目标店铺列表 */ |
74 | -export function getGPShopListApi( | |
75 | - params: GetGPShopListApiParams | |
76 | -): PromiseResp<GetGPShopListApiRes> { | |
70 | +export function getGPShopListApi(params: GetGPShopListApiParams): PromiseResp<GetGPShopListApiRes> { | |
77 | 71 | return request.get(`${CAS_HOST}/erp/grossProfit/grossProfitShopList`, { |
78 | 72 | params, |
79 | 73 | }); |
... | ... | @@ -105,9 +99,7 @@ export interface AdviserGPListItem extends ConfirmGPListItem { |
105 | 99 | } |
106 | 100 | |
107 | 101 | /** step2 确认毛利目标---查询列表接口 */ |
108 | -export function getConfirmGrossProfitList( | |
109 | - params: GetConfirmGrossProfitListParams | |
110 | -): PromisePageResp<ConfirmGPListItem> { | |
102 | +export function getConfirmGrossProfitList(params: GetConfirmGrossProfitListParams): PromisePageResp<ConfirmGPListItem> { | |
111 | 103 | return request.get(`${CAS_HOST}/erp/grossProfit/info`, { |
112 | 104 | params, |
113 | 105 | }); |
... | ... | @@ -136,6 +128,7 @@ export interface ShopBizTypeItem { |
136 | 128 | } |
137 | 129 | |
138 | 130 | export interface GrossProfitShopDto { |
131 | + id: number; | |
139 | 132 | grossProfitTarget?: number; |
140 | 133 | inboundRate?: number; |
141 | 134 | netProfitTarget?: number; |
... | ... | @@ -161,9 +154,7 @@ export interface CalcGrossProfitParams { |
161 | 154 | } |
162 | 155 | |
163 | 156 | /** 点击下一步之前---计算保存毛利目标 */ |
164 | -export function calcGrossProfit( | |
165 | - params?: CalcGrossProfitParams | |
166 | -): PromiseResp<boolean> { | |
157 | +export function calcGrossProfit(params?: CalcGrossProfitParams): PromiseResp<boolean> { | |
167 | 158 | return request.post(`${CAS_HOST}/erp/grossProfit`, params); |
168 | 159 | } |
169 | 160 | |
... | ... | @@ -179,10 +170,7 @@ export interface CancelGPParams { |
179 | 170 | } |
180 | 171 | |
181 | 172 | /** 撤销毛利目标 */ |
182 | -export function cancelGP({ | |
183 | - id, | |
184 | - ...restParams | |
185 | -}: CancelGPParams): PromiseResp<boolean> { | |
173 | +export function cancelGP({ id, ...restParams }: CancelGPParams): PromiseResp<boolean> { | |
186 | 174 | return request.put(`${CAS_HOST}/erp/grossProfit/${id}`, restParams); |
187 | 175 | } |
188 | 176 | |
... | ... | @@ -202,10 +190,7 @@ export interface AdjustTotalGPParams { |
202 | 190 | } |
203 | 191 | |
204 | 192 | /** 调整总毛利目标 */ |
205 | -export function adjustTotalGP({ | |
206 | - id, | |
207 | - ...restParams | |
208 | -}: AdjustTotalGPParams): PromiseResp<boolean> { | |
193 | +export function adjustTotalGP({ id, ...restParams }: AdjustTotalGPParams): PromiseResp<boolean> { | |
209 | 194 | return request.put(`${CAS_HOST}/erp/grossProfit/shop/${id}`, restParams); |
210 | 195 | } |
211 | 196 | |
... | ... | @@ -222,10 +207,7 @@ export interface AdjustAdviserGPParams { |
222 | 207 | } |
223 | 208 | |
224 | 209 | /** 调整服务顾问毛利目标 */ |
225 | -export function adjustAdviserGP({ | |
226 | - id, | |
227 | - ...restParams | |
228 | -}: AdjustAdviserGPParams): PromiseResp<boolean> { | |
210 | +export function adjustAdviserGP({ id, ...restParams }: AdjustAdviserGPParams): PromiseResp<boolean> { | |
229 | 211 | return request.put(`${CAS_HOST}/erp/grossProfit/adviser/${id}`, restParams); |
230 | 212 | } |
231 | 213 | ... | ... |
src/pages/cas/GrossProfit/index.tsx
1 | -import React, { useState } from "react"; | |
2 | -import { | |
3 | - Card, | |
4 | - Table, | |
5 | - Button, | |
6 | - Popconfirm, | |
7 | - Divider, | |
8 | - Radio, | |
9 | - RadioChangeEvent, | |
10 | - DatePicker, | |
11 | - Select, | |
12 | - Row, | |
13 | - message, | |
14 | - Tag, | |
15 | -} from "antd"; | |
16 | -import * as API from "./api"; | |
17 | -import { PlusOutlined } from "@ant-design/icons"; | |
18 | -import { PageHeaderWrapper } from "@ant-design/pro-layout"; | |
19 | -import { GrossProfitStatusFilter, GrossProfitStatusEnum } from "./entity"; | |
20 | -import usePagination from "@/hooks/usePagination"; | |
21 | -import { history } from "umi"; | |
22 | -import moment from "moment"; | |
23 | -import store from "./store"; | |
24 | -import ApprovalProgressModal from "./components/ApprovalProgressModal"; | |
25 | -import { createStore } from "@/hooks/moz"; | |
1 | +import React, { useState } from 'react'; | |
2 | +import { Card, Table, Button, Popconfirm, Divider, Radio, RadioChangeEvent, DatePicker, Select, Row, message, Tag } from 'antd'; | |
3 | +import * as API from './api'; | |
4 | +import { PlusOutlined } from '@ant-design/icons'; | |
5 | +import { PageHeaderWrapper } from '@ant-design/pro-layout'; | |
6 | +import { GrossProfitStatusFilter, GrossProfitStatusEnum } from './entity'; | |
7 | +import usePagination from '@/hooks/usePagination'; | |
8 | +import { history } from 'umi'; | |
9 | +import moment from 'moment'; | |
10 | +import store from './store'; | |
11 | +import ApprovalProgressModal from './components/ApprovalProgressModal'; | |
12 | +import { createStore } from '@/hooks/moz'; | |
26 | 13 | |
27 | 14 | const { Column } = Table; |
28 | 15 | const RadioButton = Radio.Button; |
... | ... | @@ -43,26 +30,18 @@ function GrossProfitList() { |
43 | 30 | const calcStatus = (currIsValid: number) => { |
44 | 31 | let statusArr = []; |
45 | 32 | if (currIsValid === 0) { |
46 | - statusArr = [ | |
47 | - GrossProfitStatusEnum.草稿, | |
48 | - GrossProfitStatusEnum.草稿已计算, | |
49 | - GrossProfitStatusEnum.待审批, | |
50 | - GrossProfitStatusEnum.驳回, | |
51 | - ]; | |
33 | + statusArr = [GrossProfitStatusEnum.草稿, GrossProfitStatusEnum.草稿已计算, GrossProfitStatusEnum.待审批, GrossProfitStatusEnum.驳回]; | |
52 | 34 | } else { |
53 | 35 | statusArr = [GrossProfitStatusEnum.通过]; |
54 | 36 | } |
55 | - return statusArr.join(","); | |
37 | + return statusArr.join(','); | |
56 | 38 | }; |
57 | 39 | |
58 | - const { list, loading, setParams, paginationConfig } = usePagination( | |
59 | - API.getGrossProfitListApi, | |
60 | - { | |
61 | - current: 1, | |
62 | - pageSize: 10, | |
63 | - status: calcStatus(isValid), | |
64 | - } | |
65 | - ); | |
40 | + const { list, loading, setParams, paginationConfig } = usePagination(API.getGrossProfitListApi, { | |
41 | + current: 1, | |
42 | + pageSize: 10, | |
43 | + status: calcStatus(isValid), | |
44 | + }); | |
66 | 45 | |
67 | 46 | const handleIsValidStatus = (e: RadioChangeEvent) => { |
68 | 47 | setIsValid(e.target.value); |
... | ... | @@ -81,14 +60,14 @@ function GrossProfitList() { |
81 | 60 | case GrossProfitStatusEnum.驳回: |
82 | 61 | return <Tag color="red">审批拒绝</Tag>; |
83 | 62 | default: |
84 | - return "-"; | |
63 | + return '-'; | |
85 | 64 | } |
86 | 65 | }; |
87 | 66 | |
88 | 67 | // 继续编辑 |
89 | 68 | const goToEditPage = (record: API.ListItem) => { |
90 | 69 | history.push({ |
91 | - pathname: "/cas/grossProfit/add", | |
70 | + pathname: '/cas/grossProfit/add', | |
92 | 71 | query: { |
93 | 72 | settingId: String(record.id), |
94 | 73 | validTime: record.validTime, |
... | ... | @@ -99,11 +78,11 @@ function GrossProfitList() { |
99 | 78 | // 提交审批 || 查看 || 变更 |
100 | 79 | const goToViewPage = (record: API.ListItem) => { |
101 | 80 | history.push({ |
102 | - pathname: "/cas/grossProfit/add", | |
81 | + pathname: '/cas/grossProfit/add', | |
103 | 82 | query: { |
104 | 83 | settingId: String(record.id), |
105 | 84 | validTime: record.validTime, |
106 | - step: "step2", // 步骤 2 --- 确认毛利目标 | |
85 | + step: 'step2', // 步骤 2 --- 确认毛利目标 | |
107 | 86 | }, |
108 | 87 | }); |
109 | 88 | }; |
... | ... | @@ -119,20 +98,18 @@ function GrossProfitList() { |
119 | 98 | |
120 | 99 | // 跳转新增月度毛利目标 |
121 | 100 | const goToAddPage = () => { |
122 | - history.push("/cas/grossProfit/add"); | |
101 | + history.push('/cas/grossProfit/add'); | |
123 | 102 | }; |
124 | 103 | |
125 | 104 | // 删除 |
126 | 105 | const handleDeleteGP = (record: API.ListItem) => { |
127 | 106 | API.deletetGP(record.id) |
128 | 107 | .then((res) => { |
129 | - message.success("删除成功"); | |
108 | + message.success('删除成功'); | |
109 | + setParams({}, true); | |
130 | 110 | }) |
131 | 111 | .catch((error: any) => { |
132 | - message.error(error.message ?? "请求失败"); | |
133 | - }) | |
134 | - .finally(() => { | |
135 | - setParams({}, true); | |
112 | + message.error(error.message ?? '请求失败'); | |
136 | 113 | }); |
137 | 114 | }; |
138 | 115 | |
... | ... | @@ -144,10 +121,10 @@ function GrossProfitList() { |
144 | 121 | yn: true, // 删除 传false |
145 | 122 | }) |
146 | 123 | .then((res) => { |
147 | - message.success("撤销成功"); | |
124 | + message.success('撤销成功'); | |
148 | 125 | }) |
149 | 126 | .catch((error: any) => { |
150 | - message.error(error.message ?? "请求失败"); | |
127 | + message.error(error.message ?? '请求失败'); | |
151 | 128 | }) |
152 | 129 | .finally(() => { |
153 | 130 | setParams({}, true); |
... | ... | @@ -162,22 +139,12 @@ function GrossProfitList() { |
162 | 139 | const upgradeBtn = <a onClick={() => goToViewPage(record)}>变更</a>; |
163 | 140 | const processBtn = <a onClick={() => goToProcess(record)}>流程进度</a>; |
164 | 141 | const deleteBtn = ( |
165 | - <Popconfirm | |
166 | - title={`是否删除【${record.validTime}】月度数据?`} | |
167 | - okText="确定" | |
168 | - cancelText="取消" | |
169 | - onConfirm={() => handleDeleteGP(record)} | |
170 | - > | |
171 | - <a style={{ color: "#999999" }}>删除</a> | |
142 | + <Popconfirm title={`是否删除【${record.validTime}】月度数据?`} okText="确定" cancelText="取消" onConfirm={() => handleDeleteGP(record)}> | |
143 | + <a style={{ color: '#999999' }}>删除</a> | |
172 | 144 | </Popconfirm> |
173 | 145 | ); |
174 | 146 | const cancelBtn = ( |
175 | - <Popconfirm | |
176 | - title={`是否撤销【${record.validTime}】月度数据?`} | |
177 | - okText="确定" | |
178 | - cancelText="取消" | |
179 | - onConfirm={() => handleCancelGP(record)} | |
180 | - > | |
147 | + <Popconfirm title={`是否撤销【${record.validTime}】月度数据?`} okText="确定" cancelText="取消" onConfirm={() => handleCancelGP(record)}> | |
181 | 148 | <a>撤销</a> |
182 | 149 | </Popconfirm> |
183 | 150 | ); |
... | ... | @@ -224,11 +191,7 @@ function GrossProfitList() { |
224 | 191 | </RadioGroup> |
225 | 192 | } |
226 | 193 | > |
227 | - <Row | |
228 | - align="middle" | |
229 | - justify="space-between" | |
230 | - style={{ marginBottom: 20 }} | |
231 | - > | |
194 | + <Row align="middle" justify="space-between" style={{ marginBottom: 20 }}> | |
232 | 195 | <Row align="middle" justify="space-between"> |
233 | 196 | <DatePicker |
234 | 197 | placeholder="月度" |
... | ... | @@ -255,26 +218,13 @@ function GrossProfitList() { |
255 | 218 | </Select> |
256 | 219 | )} |
257 | 220 | </Row> |
258 | - <Button | |
259 | - icon={<PlusOutlined />} | |
260 | - type="primary" | |
261 | - onClick={goToAddPage} | |
262 | - style={{ marginLeft: 10 }} | |
263 | - > | |
221 | + <Button icon={<PlusOutlined />} type="primary" onClick={goToAddPage} style={{ marginLeft: 10 }}> | |
264 | 222 | 新增 |
265 | 223 | </Button> |
266 | 224 | </Row> |
267 | - <Table | |
268 | - rowKey="id" | |
269 | - loading={loading} | |
270 | - dataSource={list} | |
271 | - pagination={paginationConfig} | |
272 | - > | |
225 | + <Table rowKey="id" loading={loading} dataSource={list} pagination={paginationConfig}> | |
273 | 226 | <Column title="月度" dataIndex="validTime" /> |
274 | - <Column | |
275 | - title="毛利目标(万元)" | |
276 | - dataIndex="doubleGrossProfitTarget" | |
277 | - /> | |
227 | + <Column title="毛利目标(万元)" dataIndex="doubleGrossProfitTarget" /> | |
278 | 228 | <Column title="状态" dataIndex="status" render={renderStatusBadge} /> |
279 | 229 | <Column title="操作" render={renderBtns} /> |
280 | 230 | </Table> | ... | ... |
src/pages/cas/GrossProfit/subpages/Add/components/GPAddOrEdit.tsx
1 | -import React, { | |
2 | - useEffect, | |
3 | - useImperativeHandle, | |
4 | - useMemo, | |
5 | - useState, | |
6 | -} from "react"; | |
7 | -import { InputNumber, Select, Row, Divider, Form, message } from "antd"; | |
8 | -import { | |
9 | - CheckCircleOutlined, | |
10 | - ExclamationCircleOutlined, | |
11 | -} from "@ant-design/icons"; | |
12 | -import * as API from "../../../api"; | |
13 | -import { useRequest } from "umi"; | |
14 | -import { observer } from "mobx-react-lite"; | |
15 | -import styles from "../index.less"; | |
16 | -import useInitial from "@/hooks/useInitail"; | |
17 | -import _ from "lodash"; | |
1 | +import React, { useEffect, useImperativeHandle, useMemo, useState } from 'react'; | |
2 | +import { InputNumber, Select, Row, Divider, Form, message, Input } from 'antd'; | |
3 | +import { CheckCircleOutlined, ExclamationCircleOutlined } from '@ant-design/icons'; | |
4 | +import * as API from '../../../api'; | |
5 | +import { useRequest } from 'umi'; | |
6 | +import { observer } from 'mobx-react-lite'; | |
7 | +import styles from '../index.less'; | |
8 | +import useInitial from '@/hooks/useInitail'; | |
9 | +import _ from 'lodash'; | |
18 | 10 | |
19 | 11 | let _callback: (data: any) => void; |
20 | 12 | |
... | ... | @@ -32,10 +24,7 @@ const GPAddOrEdit = (props: GPAddOrEditProps, ref: any) => { |
32 | 24 | const { row } = props; |
33 | 25 | const [shops, setShops] = useState<OptionItem[]>([]); // 用于前端本地模糊匹配搜索 |
34 | 26 | |
35 | - const { data: shopListDataSource } = useInitial< | |
36 | - API.GetNoGPShopItem[], | |
37 | - API.GetNoGPShopListApiParams | |
38 | - >(API.getNoGPShopListApi, [], { | |
27 | + const { data: shopListDataSource } = useInitial<API.GetNoGPShopItem[], API.GetNoGPShopListApiParams>(API.getNoGPShopListApi, [], { | |
39 | 28 | settingId: row.settingId, |
40 | 29 | }); |
41 | 30 | |
... | ... | @@ -55,22 +44,21 @@ const GPAddOrEdit = (props: GPAddOrEditProps, ref: any) => { |
55 | 44 | setShops(transListToOption(shopListDataSource)); |
56 | 45 | return; |
57 | 46 | } |
58 | - const filtersShops = shopListDataSource.filter( | |
59 | - (item) => item.shopName.indexOf(value) !== -1 | |
60 | - ); | |
47 | + const filtersShops = shopListDataSource.filter((item) => item.shopName.indexOf(value) !== -1); | |
61 | 48 | setShops(transListToOption(filtersShops)); |
62 | 49 | }, 1000); |
63 | 50 | |
64 | 51 | const handleSelectShop = (v: number) => { |
65 | 52 | const filteredShops = shopListDataSource.filter((item) => item.id === v); |
66 | 53 | if (filteredShops.length > 0) { |
67 | - form.setFieldValue("shopName", filteredShops[0].shopName); | |
54 | + form.setFieldValue('shopName', filteredShops[0].shopName); | |
68 | 55 | } |
69 | 56 | }; |
70 | 57 | |
71 | 58 | const addOrEditGPHook = useRequest(API.addOrEditGP, { |
72 | 59 | manual: true, |
73 | 60 | onSuccess: (data) => { |
61 | + message.success('操作成功'); | |
74 | 62 | if (_callback) _callback(data); |
75 | 63 | }, |
76 | 64 | onError: (error) => { |
... | ... | @@ -89,19 +77,24 @@ const GPAddOrEdit = (props: GPAddOrEditProps, ref: any) => { |
89 | 77 | }); |
90 | 78 | |
91 | 79 | const onFinish = (values: API.GrossProfitShopDto) => { |
92 | - const leftPercentVal = form.getFieldValue("leftPercent"); | |
80 | + const leftPercentVal = form.getFieldValue('leftPercent'); | |
93 | 81 | if (leftPercentVal > 0) { |
94 | - message.warn("业务类型占比总和不足 100%"); | |
82 | + message.warn('业务类型占比总和不足 100%'); | |
95 | 83 | return; |
96 | 84 | } |
97 | 85 | if (leftPercentVal < 0) { |
98 | - message.warn("业务类型占比总和已超出 100%"); | |
86 | + message.warn('业务类型占比总和已超出 100%'); | |
99 | 87 | return; |
100 | 88 | } |
101 | 89 | const newValues = { |
102 | 90 | ...values, |
103 | 91 | netProfitTarget: values.netProfitTarget, |
104 | 92 | }; |
93 | + | |
94 | + if (row?.grossProfitShopDto.id) { | |
95 | + newValues.id = row.grossProfitShopDto.id; | |
96 | + } | |
97 | + | |
105 | 98 | addOrEditGPHook.run({ |
106 | 99 | grossProfitShopDto: newValues, |
107 | 100 | validTime: row.validTime, |
... | ... | @@ -135,21 +128,12 @@ const GPAddOrEdit = (props: GPAddOrEditProps, ref: any) => { |
135 | 128 | }, [row]); |
136 | 129 | |
137 | 130 | return ( |
138 | - <Form | |
139 | - {...layout} | |
140 | - style={{ width: 720, margin: "0 auto" }} | |
141 | - labelAlign="left" | |
142 | - form={form} | |
143 | - initialValues={formatGPFormData} | |
144 | - onFinish={onFinish} | |
145 | - > | |
146 | - <div style={{ width: 660, margin: "0 auto" }}> | |
147 | - <Form.Item name="shopName" label="门店名称" hidden /> | |
148 | - <Form.Item | |
149 | - name="shopId" | |
150 | - label="门店" | |
151 | - rules={[{ required: true, message: "请选择门店" }]} | |
152 | - > | |
131 | + <Form {...layout} style={{ width: 720, margin: '0 auto' }} labelAlign="left" form={form} initialValues={formatGPFormData} onFinish={onFinish}> | |
132 | + <div style={{ width: 660, margin: '0 auto' }}> | |
133 | + <Form.Item name="shopName" label="门店" hidden={!formatGPFormData.shopId}> | |
134 | + <Input disabled /> | |
135 | + </Form.Item> | |
136 | + <Form.Item name="shopId" label="门店" rules={[{ required: true, message: '请选择门店' }]} hidden={!!formatGPFormData.shopId}> | |
153 | 137 | <Select |
154 | 138 | showSearch |
155 | 139 | allowClear |
... | ... | @@ -162,28 +146,24 @@ const GPAddOrEdit = (props: GPAddOrEditProps, ref: any) => { |
162 | 146 | /> |
163 | 147 | </Form.Item> |
164 | 148 | <Form.Item name="netProfitTarget" label="净利目标" required> |
165 | - <InputNumber | |
166 | - formatter={(value) => `${value}万元`} | |
167 | - parser={(value: any) => value.replace("万元", "")} | |
168 | - style={{ width: "100%" }} | |
169 | - /> | |
149 | + <InputNumber formatter={(value) => `${value}万元`} parser={(value: any) => value.replace('万元', '')} style={{ width: '100%' }} /> | |
170 | 150 | </Form.Item> |
171 | 151 | <Form.Item name="grossProfitTarget" label="毛利率要求" required> |
172 | 152 | <InputNumber |
173 | 153 | formatter={(value) => `${value}%`} |
174 | - parser={(value: any) => value.replace("%", "")} | |
154 | + parser={(value: any) => value.replace('%', '')} | |
175 | 155 | min={0} |
176 | 156 | max={100} |
177 | - style={{ width: "100%" }} | |
157 | + style={{ width: '100%' }} | |
178 | 158 | /> |
179 | 159 | </Form.Item> |
180 | 160 | <Form.Item name="inboundRate" label="进站率要求" required> |
181 | 161 | <InputNumber |
182 | 162 | formatter={(value) => `${value}%`} |
183 | - parser={(value: any) => value.replace("%", "")} | |
163 | + parser={(value: any) => value.replace('%', '')} | |
184 | 164 | min={0} |
185 | 165 | max={100} |
186 | - style={{ width: "100%" }} | |
166 | + style={{ width: '100%' }} | |
187 | 167 | /> |
188 | 168 | </Form.Item> |
189 | 169 | </div> |
... | ... | @@ -194,30 +174,22 @@ const GPAddOrEdit = (props: GPAddOrEditProps, ref: any) => { |
194 | 174 | }} |
195 | 175 | > |
196 | 176 | {({ getFieldValue }) => { |
197 | - const leftPercent = getFieldValue("leftPercent"); | |
177 | + const leftPercent = getFieldValue('leftPercent'); | |
198 | 178 | return ( |
199 | 179 | <Divider orientation="left" orientationMargin="0"> |
200 | 180 | <Row align="middle" justify="start" wrap={false}> |
201 | 181 | <div style={{ marginRight: 10 }}>业务类型占比</div> |
202 | 182 | {leftPercent === 0 ? ( |
203 | 183 | <Row align="middle" justify="start" wrap={false}> |
204 | - <CheckCircleOutlined | |
205 | - size={14} | |
206 | - style={{ color: "#20C688" }} | |
207 | - /> | |
184 | + <CheckCircleOutlined size={14} style={{ color: '#20C688' }} /> | |
208 | 185 | <span className={styles.pTip}>毛利分配占比 100%</span> |
209 | 186 | </Row> |
210 | 187 | ) : ( |
211 | 188 | <Row align="middle" justify="start" wrap={false}> |
212 | - <ExclamationCircleOutlined | |
213 | - size={14} | |
214 | - style={{ color: "#FF921C" }} | |
215 | - /> | |
189 | + <ExclamationCircleOutlined size={14} style={{ color: '#FF921C' }} /> | |
216 | 190 | <span className={styles.pTip}> |
217 | 191 | 占比合计必须为 100%,当前剩余 |
218 | - <span style={{ color: "#FF921C" }}> | |
219 | - {leftPercent ?? 100}% | |
220 | - </span> | |
192 | + <span style={{ color: '#FF921C' }}>{leftPercent ?? 100}%</span> | |
221 | 193 | </span> |
222 | 194 | </Row> |
223 | 195 | )} |
... | ... | @@ -226,44 +198,36 @@ const GPAddOrEdit = (props: GPAddOrEditProps, ref: any) => { |
226 | 198 | ); |
227 | 199 | }} |
228 | 200 | </Form.Item> |
229 | - <div style={{ width: 660, margin: "0 auto" }}> | |
201 | + <div style={{ width: 660, margin: '0 auto' }}> | |
230 | 202 | <Form.Item |
231 | 203 | noStyle |
232 | 204 | shouldUpdate={(prevValues, currentValues) => { |
233 | - return ( | |
234 | - prevValues.shopBizTypeList !== currentValues.shopBizTypeList || | |
235 | - prevValues.leftPercent !== currentValues.leftPercent | |
236 | - ); | |
205 | + return prevValues.shopBizTypeList !== currentValues.shopBizTypeList || prevValues.leftPercent !== currentValues.leftPercent; | |
237 | 206 | }} |
238 | 207 | > |
239 | 208 | {({ setFieldsValue, getFieldValue }) => { |
240 | 209 | return ( |
241 | 210 | <Form.List name="shopBizTypeList"> |
242 | 211 | {(fields) => { |
243 | - const typeListValue = getFieldValue( | |
244 | - "shopBizTypeList" | |
245 | - ) as API.ShopBizTypeItem[]; | |
212 | + const typeListValue = getFieldValue('shopBizTypeList') as API.ShopBizTypeItem[]; | |
246 | 213 | return fields.map(({ name, ...restFields }, index) => { |
247 | 214 | const currType = typeListValue[index]; |
248 | 215 | return ( |
249 | 216 | <Form.Item |
250 | 217 | {...restFields} |
251 | - name={[name, "grossProfitPercent"]} // 必须为此写法顺序 | |
218 | + name={[name, 'grossProfitPercent']} // 必须为此写法顺序 | |
252 | 219 | label={currType.label} |
253 | 220 | required |
254 | 221 | > |
255 | 222 | <InputNumber |
256 | 223 | min={0} |
257 | - style={{ width: "100%" }} | |
224 | + style={{ width: '100%' }} | |
258 | 225 | formatter={(value) => `${value}%`} |
259 | - parser={(value: any) => value.replace("%", "")} | |
226 | + parser={(value: any) => value.replace('%', '')} | |
260 | 227 | onBlur={() => { |
261 | - const totalPercent = typeListValue.reduce( | |
262 | - (total, curr) => { | |
263 | - return curr.grossProfitPercent + total; | |
264 | - }, | |
265 | - 0 | |
266 | - ); // 提示剩余百分比 | |
228 | + const totalPercent = typeListValue.reduce((total, curr) => { | |
229 | + return curr.grossProfitPercent + total; | |
230 | + }, 0); // 提示剩余百分比 | |
267 | 231 | const leftPercent = 100 - totalPercent; |
268 | 232 | setFieldsValue({ leftPercent }); |
269 | 233 | }} | ... | ... |
src/pages/cas/GrossProfit/subpages/Add/components/GPSetting.tsx
1 | -import React, { useRef, useState } from "react"; | |
2 | -import { | |
3 | - Table, | |
4 | - Button, | |
5 | - Radio, | |
6 | - Row, | |
7 | - Modal, | |
8 | - message, | |
9 | - Form, | |
10 | - InputNumber, | |
11 | - Input, | |
12 | -} from "antd"; | |
13 | -import { | |
14 | - PlusOutlined, | |
15 | - ExclamationCircleOutlined, | |
16 | - CheckCircleOutlined, | |
17 | -} from "@ant-design/icons"; | |
18 | -import GPAddOrEdit from "./GPAddOrEdit"; | |
19 | -import { observer } from "mobx-react-lite"; | |
20 | -import { GetGPShopListApiParams, GetGPShopListApiRes } from "../../../api"; | |
21 | -import { defaultShopBizTypeList } from "../../../entity"; | |
22 | -import useInitial from "@/hooks/useInitail"; | |
23 | -import * as API from "../../../api"; | |
24 | -import moment, { Moment } from "moment"; | |
25 | -import { useRequest } from "umi"; | |
1 | +import React, { useRef, useState } from 'react'; | |
2 | +import { Table, Button, Radio, Row, Modal, message, Form, InputNumber, Input } from 'antd'; | |
3 | +import { PlusOutlined, ExclamationCircleOutlined, CheckCircleOutlined } from '@ant-design/icons'; | |
4 | +import GPAddOrEdit from './GPAddOrEdit'; | |
5 | +import { observer } from 'mobx-react-lite'; | |
6 | +import { GetGPShopListApiParams, GetGPShopListApiRes } from '../../../api'; | |
7 | +import { defaultShopBizTypeList } from '../../../entity'; | |
8 | +import useInitial from '@/hooks/useInitail'; | |
9 | +import * as API from '../../../api'; | |
10 | +import moment, { Moment } from 'moment'; | |
11 | +import { useRequest } from 'umi'; | |
26 | 12 | |
27 | 13 | const { Column } = Table; |
28 | 14 | const RadioButton = Radio.Button; |
... | ... | @@ -42,26 +28,18 @@ interface GPSettingProps { |
42 | 28 | const GPSetting = ({ settingId, filterMonth, setCurrStep }: GPSettingProps) => { |
43 | 29 | const [bizTypeForm] = Form.useForm(); |
44 | 30 | const gpRef = useRef<GPAddOrEditForm>(null); |
45 | - const [gpRow, setGPRow] = useState<API.AddOrEditGPParams>( | |
46 | - {} as API.AddOrEditGPParams | |
47 | - ); | |
31 | + const [gpRow, setGPRow] = useState<API.AddOrEditGPParams>({} as API.AddOrEditGPParams); | |
48 | 32 | const [addOrEditModalVisible, setAddOrEditModalVisible] = useState(false); |
49 | 33 | const [bizTypeVisible, setBizTypeVisible] = useState(false); |
50 | 34 | |
51 | - const { data, loading, setParams } = useInitial< | |
52 | - GetGPShopListApiRes, | |
53 | - GetGPShopListApiParams | |
54 | - >(API.getGPShopListApi, {} as GetGPShopListApiRes, { | |
35 | + const { data, loading, setParams } = useInitial<GetGPShopListApiRes, GetGPShopListApiParams>(API.getGPShopListApi, {} as GetGPShopListApiRes, { | |
55 | 36 | settingId, |
56 | 37 | }); |
57 | 38 | |
58 | - const calcGrossProfitHook = useRequest( | |
59 | - (settingId) => API.calcGrossProfit({ settingId }), | |
60 | - { | |
61 | - manual: true, | |
62 | - throwOnError: true, | |
63 | - } | |
64 | - ); | |
39 | + const calcGrossProfitHook = useRequest((settingId) => API.calcGrossProfit({ settingId }), { | |
40 | + manual: true, | |
41 | + throwOnError: true, | |
42 | + }); | |
65 | 43 | |
66 | 44 | const filterByShopName = (value: string) => { |
67 | 45 | setParams({ shopName: value }, true); |
... | ... | @@ -70,24 +48,22 @@ const GPSetting = ({ settingId, filterMonth, setCurrStep }: GPSettingProps) => { |
70 | 48 | // 下一步---确认毛利目标 |
71 | 49 | const goToConfirm = async () => { |
72 | 50 | if (data.surplus > 0) { |
73 | - message.warn( | |
74 | - `请设置完剩余${data.surplus}个门店毛利目标,再进行下一步操作` | |
75 | - ); | |
51 | + message.warn(`请设置完剩余${data.surplus}个门店毛利目标,再进行下一步操作`); | |
76 | 52 | return; |
77 | 53 | } |
78 | 54 | Modal.confirm({ |
79 | - title: "确认进行下一步计算吗?", | |
55 | + title: '确认进行下一步计算吗?', | |
80 | 56 | zIndex: 1002, |
81 | 57 | onOk: async () => { |
82 | - const hide = message.loading("计算中,请稍候", 0); | |
58 | + const hide = message.loading('计算中,请稍候', 0); | |
83 | 59 | calcGrossProfitHook |
84 | 60 | .run(data.settingId!) |
85 | 61 | .then((res) => { |
86 | - message.success("计算成功"); | |
62 | + message.success('计算成功'); | |
87 | 63 | setCurrStep(1, data.settingId!); |
88 | 64 | }) |
89 | 65 | .catch((error: any) => { |
90 | - message.error(error.message ?? "请求失败"); | |
66 | + message.error(error.message ?? '请求失败'); | |
91 | 67 | }) |
92 | 68 | .finally(() => { |
93 | 69 | hide(); |
... | ... | @@ -99,7 +75,7 @@ const GPSetting = ({ settingId, filterMonth, setCurrStep }: GPSettingProps) => { |
99 | 75 | // 保存新增或者编辑的门店毛利目标 |
100 | 76 | const confirmAddOrEdit = () => { |
101 | 77 | gpRef.current?.submit((data) => { |
102 | - setParams({ settingId: data.id }, true); | |
78 | + setParams({ settingId: data.settingId }, true); | |
103 | 79 | setAddOrEditModalVisible(false); |
104 | 80 | }); |
105 | 81 | }; |
... | ... | @@ -112,7 +88,7 @@ const GPSetting = ({ settingId, filterMonth, setCurrStep }: GPSettingProps) => { |
112 | 88 | // 新增门店毛利目标 |
113 | 89 | const handleAddGP = () => { |
114 | 90 | if (data.surplus <= 0) { |
115 | - message.warn("已设置完所有门店毛利目标,可进行下一步操作"); | |
91 | + message.warn('已设置完所有门店毛利目标,可进行下一步操作'); | |
116 | 92 | return; |
117 | 93 | } |
118 | 94 | setGPRow({ |
... | ... | @@ -133,7 +109,7 @@ const GPSetting = ({ settingId, filterMonth, setCurrStep }: GPSettingProps) => { |
133 | 109 | // 查看业务类型分析 |
134 | 110 | const getBizTypeInfo = (record: API.ShopVOListItem) => { |
135 | 111 | setBizTypeVisible(true); |
136 | - bizTypeForm.setFieldValue("shopBizTypeList", record.bizTypeList); | |
112 | + bizTypeForm.setFieldValue('shopBizTypeList', record.bizTypeList); | |
137 | 113 | }; |
138 | 114 | |
139 | 115 | const closeBizTypeModal = () => { |
... | ... | @@ -147,6 +123,7 @@ const GPSetting = ({ settingId, filterMonth, setCurrStep }: GPSettingProps) => { |
147 | 123 | settingId: data.settingId, // 必有该值 |
148 | 124 | validTime: moment(data.validTime).valueOf(), // 时间为数据自带的时间 |
149 | 125 | grossProfitShopDto: { |
126 | + id: record.id, | |
150 | 127 | grossProfitTarget: record.grossProfitTarget, |
151 | 128 | inboundRate: record.inboundRate, |
152 | 129 | netProfitTarget: record.doubleNetProfitTarget, |
... | ... | @@ -175,53 +152,30 @@ const GPSetting = ({ settingId, filterMonth, setCurrStep }: GPSettingProps) => { |
175 | 152 | </RadioGroup> |
176 | 153 | {data.surplus <= 0 ? ( |
177 | 154 | <Row align="middle" justify="start" style={{ marginLeft: 10 }}> |
178 | - <CheckCircleOutlined style={{ color: "#20C688" }} /> | |
155 | + <CheckCircleOutlined style={{ color: '#20C688' }} /> | |
179 | 156 | <span style={{ marginLeft: 5 }}>已配置完所有门店</span> |
180 | 157 | </Row> |
181 | 158 | ) : ( |
182 | 159 | <Row align="middle" justify="start" style={{ marginLeft: 10 }}> |
183 | - <ExclamationCircleOutlined style={{ color: "#F4333C" }} /> | |
160 | + <ExclamationCircleOutlined style={{ color: '#F4333C' }} /> | |
184 | 161 | <span style={{ marginLeft: 5 }}> |
185 | 162 | 将所有门店配置完才可提交下一步,当前剩余 |
186 | - <span style={{ color: "#F4333C" }}>{data.surplus}</span>个门店 | |
163 | + <span style={{ color: '#F4333C' }}>{data.surplus}</span>个门店 | |
187 | 164 | </span> |
188 | 165 | </Row> |
189 | 166 | )} |
190 | 167 | </Row> |
191 | - <Row | |
192 | - align="bottom" | |
193 | - justify="space-between" | |
194 | - style={{ marginTop: 25, marginBottom: 20 }} | |
195 | - > | |
196 | - <Input.Search | |
197 | - allowClear | |
198 | - placeholder="门店名称" | |
199 | - onSearch={filterByShopName} | |
200 | - style={{ width: 260 }} | |
201 | - /> | |
168 | + <Row align="bottom" justify="space-between" style={{ marginTop: 25, marginBottom: 20 }}> | |
169 | + <Input.Search allowClear placeholder="门店名称" onSearch={filterByShopName} style={{ width: 260 }} /> | |
202 | 170 | <Button icon={<PlusOutlined />} type="primary" onClick={handleAddGP}> |
203 | 171 | 新增门店 |
204 | 172 | </Button> |
205 | 173 | </Row> |
206 | - <Table | |
207 | - scroll={{ y: 400 }} | |
208 | - dataSource={data.shopVOList} | |
209 | - pagination={false} | |
210 | - rowKey="id" | |
211 | - loading={loading} | |
212 | - > | |
174 | + <Table scroll={{ y: 400 }} dataSource={data.shopVOList} pagination={false} rowKey="id" loading={loading}> | |
213 | 175 | <Column title="门店" dataIndex="shopName" /> |
214 | 176 | <Column title="净利目标(万元)" dataIndex="doubleNetProfitTarget" /> |
215 | - <Column | |
216 | - title="毛利率要求" | |
217 | - dataIndex="grossProfitTarget" | |
218 | - render={(v) => `${v}%`} | |
219 | - /> | |
220 | - <Column | |
221 | - title="进站率要求" | |
222 | - dataIndex="inboundRate" | |
223 | - render={(v) => `${v}%`} | |
224 | - /> | |
177 | + <Column title="毛利率要求" dataIndex="grossProfitTarget" render={(v) => `${v}%`} /> | |
178 | + <Column title="进站率要求" dataIndex="inboundRate" render={(v) => `${v}%`} /> | |
225 | 179 | <Column |
226 | 180 | title="业务类型占比" |
227 | 181 | render={(value, record: API.ShopVOListItem) => { |
... | ... | @@ -239,22 +193,14 @@ const GPSetting = ({ settingId, filterMonth, setCurrStep }: GPSettingProps) => { |
239 | 193 | <Button onClick={() => history.back()} style={{ marginLeft: 10 }}> |
240 | 194 | 返回列表 |
241 | 195 | </Button> |
242 | - <Button | |
243 | - type="primary" | |
244 | - loading={calcGrossProfitHook.loading} | |
245 | - onClick={goToConfirm} | |
246 | - style={{ marginLeft: 10 }} | |
247 | - > | |
196 | + <Button type="primary" loading={calcGrossProfitHook.loading} onClick={goToConfirm} style={{ marginLeft: 10 }}> | |
248 | 197 | 下一步 |
249 | 198 | </Button> |
250 | 199 | </Row> |
200 | + | |
251 | 201 | <Modal |
252 | 202 | width={860} |
253 | - title={ | |
254 | - gpRow?.grossProfitShopDto?.shopId | |
255 | - ? "编辑门店毛利目标" | |
256 | - : "新增门店毛利目标" | |
257 | - } | |
203 | + title={gpRow?.grossProfitShopDto?.shopId ? '编辑门店毛利目标' : '新增门店毛利目标'} | |
258 | 204 | open={addOrEditModalVisible} |
259 | 205 | onCancel={handleCancelAddOrEdit} |
260 | 206 | onOk={confirmAddOrEdit} |
... | ... | @@ -275,12 +221,7 @@ const GPSetting = ({ settingId, filterMonth, setCurrStep }: GPSettingProps) => { |
275 | 221 | footer={<Button onClick={closeBizTypeModal}>关闭</Button>} |
276 | 222 | destroyOnClose |
277 | 223 | > |
278 | - <Form | |
279 | - form={bizTypeForm} | |
280 | - labelAlign="left" | |
281 | - labelCol={{ span: 8 }} | |
282 | - wrapperCol={{ span: 16 }} | |
283 | - > | |
224 | + <Form form={bizTypeForm} labelAlign="left" labelCol={{ span: 8 }} wrapperCol={{ span: 16 }}> | |
284 | 225 | <Form.Item |
285 | 226 | noStyle |
286 | 227 | shouldUpdate={(prevValues, currentValues) => { |
... | ... | @@ -291,23 +232,21 @@ const GPSetting = ({ settingId, filterMonth, setCurrStep }: GPSettingProps) => { |
291 | 232 | return ( |
292 | 233 | <Form.List name="shopBizTypeList"> |
293 | 234 | {(fields) => { |
294 | - const typeListValue = getFieldValue( | |
295 | - "shopBizTypeList" | |
296 | - ) as API.ShopBizTypeItem[]; | |
235 | + const typeListValue = getFieldValue('shopBizTypeList') as API.ShopBizTypeItem[]; | |
297 | 236 | return fields.map(({ name, ...restFields }, index) => { |
298 | 237 | const currType = typeListValue[index]; |
299 | 238 | return ( |
300 | 239 | <Form.Item |
301 | 240 | {...restFields} |
302 | - name={[name, "bizTypePercent"]} // 必须为此写法顺序 | |
241 | + name={[name, 'bizTypePercent']} // 必须为此写法顺序 | |
303 | 242 | label={currType.bizTypeName} |
304 | 243 | required |
305 | 244 | > |
306 | 245 | <InputNumber |
307 | 246 | disabled |
308 | - style={{ width: "100%" }} | |
247 | + style={{ width: '100%' }} | |
309 | 248 | formatter={(value) => `${value}%`} |
310 | - parser={(value: any) => value.replace("%", "")} | |
249 | + parser={(value: any) => value.replace('%', '')} | |
311 | 250 | /> |
312 | 251 | </Form.Item> |
313 | 252 | ); | ... | ... |
src/pages/performance/EvaSetting/components/EditModal.tsx
1 | -import React, { useState, useEffect } from "react"; | |
2 | -import { | |
3 | - Form, | |
4 | - Modal, | |
5 | - message, | |
6 | - Input, | |
7 | - Select, | |
8 | - Radio, | |
9 | - DatePicker, | |
10 | - InputNumber, | |
11 | - Checkbox, | |
12 | - Spin, | |
13 | -} from "antd"; | |
14 | -import { | |
15 | - saveEvaIndicators, | |
16 | - saveComIndicators, | |
17 | - comDetailListApi, | |
18 | - queryEvaIndicatorApi, | |
19 | -} from "../api"; | |
20 | -import usePagination from "@/hooks/usePagination"; | |
21 | -import { systemListApi } from "@/pages/admin/Privilege/api"; | |
22 | -import { | |
23 | - transformDTO, | |
24 | - transformFormData, | |
25 | - DataType, | |
26 | - TargetType, | |
27 | - DatePick, | |
28 | - UnitType, | |
29 | -} from "../entity"; | |
30 | -import IndivatorsTable from "./IndivatorsTable"; | |
31 | -import useInitial from "@/hooks/useInitail"; | |
1 | +import React, { useState, useEffect } from 'react'; | |
2 | +import { Form, Modal, message, Input, Select, Radio, DatePicker, InputNumber, Checkbox, Spin } from 'antd'; | |
3 | +import { saveEvaIndicators, saveComIndicators, comDetailListApi, queryEvaIndicatorApi } from '../api'; | |
4 | +import usePagination from '@/hooks/usePagination'; | |
5 | +import { systemListApi } from '@/pages/admin/Privilege/api'; | |
6 | +import { transformDTO, transformFormData, DataType, TargetType, DatePick, UnitType } from '../entity'; | |
7 | +import IndivatorsTable from './IndivatorsTable'; | |
8 | +import useInitial from '@/hooks/useInitail'; | |
32 | 9 | |
33 | 10 | const FormItem = Form.Item; |
34 | 11 | const { Option } = Select; |
... | ... | @@ -44,43 +21,26 @@ interface Props { |
44 | 21 | roleList: CommonApi.RoleCodeVO[]; |
45 | 22 | } |
46 | 23 | |
47 | -export default function EditModal({ | |
48 | - onClose, | |
49 | - setItem, | |
50 | - item, | |
51 | - roleList, | |
52 | - customIndicatorList, | |
53 | -}: Props) { | |
24 | +export default function EditModal({ onClose, setItem, item, roleList, customIndicatorList }: Props) { | |
54 | 25 | const [form] = Form.useForm(); |
55 | 26 | const { visible, currentItem = {} as EvaSetteing.CustomIndicator } = item; |
56 | 27 | const [saveLoading, setSaveLoading] = useState<boolean>(false); |
57 | 28 | const [comData, setComData] = useState({}); |
58 | 29 | const [customIndicator, setCustomIndicator] = useState<any[]>([]); |
59 | 30 | const [codeType, setCodeType] = useState<number>(0); |
60 | - const [isOriginCode, setIsOriginCode] = useState<boolean>( | |
61 | - !!currentItem.originCode | |
62 | - ); | |
31 | + const [isOriginCode, setIsOriginCode] = useState<boolean>(!!currentItem.originCode); | |
63 | 32 | useEffect(() => { |
64 | 33 | setIsOriginCode(!!item.currentItem?.originCode); |
65 | 34 | }, [item]); |
66 | 35 | // 存储系统列表 |
67 | - const { data, loading: customLoading } = useInitial( | |
68 | - queryEvaIndicatorApi, | |
69 | - [], | |
70 | - {} | |
71 | - ); | |
36 | + const { data, loading: customLoading } = useInitial(queryEvaIndicatorApi, [], {}); | |
72 | 37 | const { list } = usePagination(systemListApi, { current: 1, pageSize: 500 }); |
73 | 38 | const [detailsDelay, setDetailsDelay] = useState<boolean>(true); |
74 | 39 | const { |
75 | 40 | data: detailsData, |
76 | 41 | setParams: setDetailsParams, |
77 | 42 | loading, |
78 | - } = useInitial( | |
79 | - comDetailListApi, | |
80 | - {} as EvaSetteing.EvaListItems, | |
81 | - {} as any, | |
82 | - detailsDelay | |
83 | - ); | |
43 | + } = useInitial(comDetailListApi, {} as EvaSetteing.EvaListItems, {} as any, detailsDelay); | |
84 | 44 | useEffect(() => { |
85 | 45 | if (data && data?.length > 0) { |
86 | 46 | const cuData = data.map((item) => { |
... | ... | @@ -119,22 +79,16 @@ export default function EditModal({ |
119 | 79 | if (pa.indicators) { |
120 | 80 | if (pa.indicators.length > 1) { |
121 | 81 | pa.laddersType = 2; |
122 | - } else if ( | |
123 | - pa.indicators.length == 1 && | |
124 | - pa.indicators[0].targetType !== 1 | |
125 | - ) { | |
82 | + } else if (pa.indicators.length == 1 && pa.indicators[0].targetType !== 1) { | |
126 | 83 | pa.laddersType = 2; |
127 | - } else if ( | |
128 | - pa.indicators.length == 1 && | |
129 | - pa.indicators[0].targetType == 1 && | |
130 | - pa.indicators[0].dataType == 2 | |
131 | - ) { | |
84 | + } else if (pa.indicators.length == 1 && pa.indicators[0].targetType == 1 && pa.indicators[0].dataType == 2) { | |
132 | 85 | pa.laddersType = 2; |
133 | 86 | } else { |
134 | 87 | pa.laddersType = 1; |
135 | 88 | } |
136 | 89 | } |
137 | 90 | pa.dataScopeTypes = [1, 2]; |
91 | + pa.hasStageTarget = true; | |
138 | 92 | if (pa.originCode) { |
139 | 93 | const brother = data.find((item: any) => pa.originCode == item.code); |
140 | 94 | pa.roleCode = brother?.roleCode; |
... | ... | @@ -147,7 +101,7 @@ export default function EditModal({ |
147 | 101 | if (brother?.startTime !== undefined) pa.startTime = brother?.startTime; |
148 | 102 | if (brother?.orderType !== undefined) pa.orderType = brother?.orderType; |
149 | 103 | } |
150 | - console.log("提交指标pa", pa); | |
104 | + console.log('提交指标pa', pa); | |
151 | 105 | setSaveLoading(true); |
152 | 106 | if (codeType == 2 || currentItem.codeType == 2) { |
153 | 107 | saveEvaIndicators(pa) |
... | ... | @@ -177,7 +131,7 @@ export default function EditModal({ |
177 | 131 | return ( |
178 | 132 | <Modal |
179 | 133 | width={960} |
180 | - title={`${currentItem.code ? "编辑" : "新增"}自定义指标`} | |
134 | + title={`${currentItem.code ? '编辑' : '新增'}自定义指标`} | |
181 | 135 | open={visible} |
182 | 136 | onOk={form.submit} |
183 | 137 | onCancel={() => onClose?.(false)} |
... | ... | @@ -187,25 +141,12 @@ export default function EditModal({ |
187 | 141 | afterClose={() => form.resetFields()} |
188 | 142 | > |
189 | 143 | <Spin spinning={currentItem.codeType == 3 ? loading : false}> |
190 | - <Form | |
191 | - form={form} | |
192 | - onFinish={handleSave} | |
193 | - style={{ width: "80%", marginLeft: 100 }} | |
194 | - initialValues={{ ruleValues: [] }} | |
195 | - > | |
196 | - <FormItem | |
197 | - name="name" | |
198 | - label="指标名称" | |
199 | - rules={[{ required: true, message: "请输入指标名称" }]} | |
200 | - > | |
144 | + <Form form={form} onFinish={handleSave} style={{ width: '80%', marginLeft: 100 }} initialValues={{ ruleValues: [] }}> | |
145 | + <FormItem name="name" label="指标名称" rules={[{ required: true, message: '请输入指标名称' }]}> | |
201 | 146 | <Input placeholder="请输入指标名称" /> |
202 | 147 | </FormItem> |
203 | 148 | {!currentItem?.code && ( |
204 | - <FormItem | |
205 | - name="com" | |
206 | - label="是否组合指标" | |
207 | - rules={[{ required: true, message: "请选择是否组合指标" }]} | |
208 | - > | |
149 | + <FormItem name="com" label="是否组合指标" rules={[{ required: true, message: '请选择是否组合指标' }]}> | |
209 | 150 | <Radio.Group> |
210 | 151 | <Radio value={3}>是</Radio> |
211 | 152 | <Radio value={2}>否</Radio> |
... | ... | @@ -222,14 +163,10 @@ export default function EditModal({ |
222 | 163 | }} |
223 | 164 | > |
224 | 165 | {({ getFieldValue }) => { |
225 | - const _com = getFieldValue("com"); | |
166 | + const _com = getFieldValue('com'); | |
226 | 167 | if (_com == 3 || currentItem?.codeType == 3) { |
227 | 168 | return ( |
228 | - <Form.Item | |
229 | - name="indicators" | |
230 | - label="指标构成" | |
231 | - rules={[{ required: true, message: "请添加指标" }]} | |
232 | - > | |
169 | + <Form.Item name="indicators" label="指标构成" rules={[{ required: true, message: '请添加指标' }]}> | |
233 | 170 | <IndivatorsTable comData={comData} /> |
234 | 171 | </Form.Item> |
235 | 172 | ); |
... | ... | @@ -237,13 +174,7 @@ export default function EditModal({ |
237 | 174 | return ( |
238 | 175 | <> |
239 | 176 | <Form.Item name="originCode" label="原始关联指标(可不选)"> |
240 | - <Select | |
241 | - placeholder="原始关联指标(可不选)" | |
242 | - loading={customLoading} | |
243 | - showSearch | |
244 | - allowClear | |
245 | - optionFilterProp="children" | |
246 | - > | |
177 | + <Select placeholder="原始关联指标(可不选)" loading={customLoading} showSearch allowClear optionFilterProp="children"> | |
247 | 178 | {customIndicator.map((item) => ( |
248 | 179 | <Option value={item.value} key={item.value}> |
249 | 180 | {item.label} |
... | ... | @@ -254,16 +185,12 @@ export default function EditModal({ |
254 | 185 | <Form.Item |
255 | 186 | noStyle |
256 | 187 | shouldUpdate={(prevValues, currentValues) => { |
257 | - if ( | |
258 | - prevValues.originCode !== currentValues.originCode | |
259 | - ) { | |
188 | + if (prevValues.originCode !== currentValues.originCode) { | |
260 | 189 | setIsOriginCode(!!currentValues.originCode); |
261 | 190 | if (currentValues.originCode) { |
262 | - const brother = customIndicatorList.find( | |
263 | - (item: any) => { | |
264 | - return currentValues.originCode == item.code; | |
265 | - } | |
266 | - ); | |
191 | + const brother = customIndicatorList.find((item: any) => { | |
192 | + return currentValues.originCode == item.code; | |
193 | + }); | |
267 | 194 | form.setFieldsValue({ |
268 | 195 | unit: brother?.unit, |
269 | 196 | hasTarget: true, |
... | ... | @@ -271,24 +198,15 @@ export default function EditModal({ |
271 | 198 | }); |
272 | 199 | } |
273 | 200 | } |
274 | - return ( | |
275 | - prevValues.originCode !== currentValues.originCode | |
276 | - ); | |
201 | + return prevValues.originCode !== currentValues.originCode; | |
277 | 202 | }} |
278 | 203 | > |
279 | 204 | {() => { |
280 | 205 | return null; |
281 | 206 | }} |
282 | 207 | </Form.Item> |
283 | - <Form.Item | |
284 | - name="unit" | |
285 | - label="指标单位" | |
286 | - rules={[{ required: true }]} | |
287 | - > | |
288 | - <Select | |
289 | - disabled={isOriginCode} | |
290 | - placeholder="请选择指标单位" | |
291 | - > | |
208 | + <Form.Item name="unit" label="指标单位" rules={[{ required: true }]}> | |
209 | + <Select disabled={isOriginCode} placeholder="请选择指标单位"> | |
292 | 210 | {UnitType.map((item) => ( |
293 | 211 | <Option value={item.value} key={item.value}> |
294 | 212 | {item.label} |
... | ... | @@ -296,15 +214,8 @@ export default function EditModal({ |
296 | 214 | ))} |
297 | 215 | </Select> |
298 | 216 | </Form.Item> |
299 | - <Form.Item | |
300 | - name="dataType" | |
301 | - label="指标类型" | |
302 | - rules={[{ required: true }]} | |
303 | - > | |
304 | - <Select | |
305 | - disabled={isOriginCode} | |
306 | - placeholder="请选择指标类型" | |
307 | - > | |
217 | + <Form.Item name="dataType" label="指标类型" rules={[{ required: true }]}> | |
218 | + <Select disabled={isOriginCode} placeholder="请选择指标类型"> | |
308 | 219 | {DataType.map((item) => ( |
309 | 220 | <Option value={item.value} key={item.value}> |
310 | 221 | {item.label} |
... | ... | @@ -312,28 +223,8 @@ export default function EditModal({ |
312 | 223 | ))} |
313 | 224 | </Select> |
314 | 225 | </Form.Item> |
315 | - <Form.Item | |
316 | - name="hasTarget" | |
317 | - label="有无目标" | |
318 | - rules={[{ required: true }]} | |
319 | - > | |
320 | - <Select | |
321 | - disabled={isOriginCode} | |
322 | - placeholder="请选择有无目标" | |
323 | - > | |
324 | - {TargetType.map((item) => ( | |
325 | - <Option value={item.value} key={item.label}> | |
326 | - {item.label} | |
327 | - </Option> | |
328 | - ))} | |
329 | - </Select> | |
330 | - </Form.Item> | |
331 | - <Form.Item | |
332 | - name="hasStageTarget" | |
333 | - label="有无阶段目标" | |
334 | - rules={[{ required: true }]} | |
335 | - > | |
336 | - <Select placeholder="请选择有无阶段目标"> | |
226 | + <Form.Item name="hasTarget" label="有无目标" rules={[{ required: true }]}> | |
227 | + <Select disabled={isOriginCode} placeholder="请选择有无目标"> | |
337 | 228 | {TargetType.map((item) => ( |
338 | 229 | <Option value={item.value} key={item.label}> |
339 | 230 | {item.label} |
... | ... | @@ -344,46 +235,25 @@ export default function EditModal({ |
344 | 235 | <Form.Item |
345 | 236 | noStyle |
346 | 237 | shouldUpdate={(prevValues, currentValues) => { |
347 | - return ( | |
348 | - prevValues.originCode !== currentValues.originCode | |
349 | - ); | |
238 | + return prevValues.originCode !== currentValues.originCode; | |
350 | 239 | }} |
351 | 240 | > |
352 | 241 | {({ getFieldValue }) => { |
353 | - const originCode = getFieldValue("originCode"); | |
242 | + const originCode = getFieldValue('originCode'); | |
354 | 243 | if (!originCode) { |
355 | 244 | return ( |
356 | 245 | <> |
357 | 246 | {/* 使用角色 */} |
358 | - <Form.Item | |
359 | - name="role" | |
360 | - label="数据更新人员" | |
361 | - rules={[{ required: true }]} | |
362 | - > | |
363 | - <Select | |
364 | - placeholder="请选择导入操作角色类型" | |
365 | - showSearch | |
366 | - allowClear | |
367 | - labelInValue | |
368 | - optionFilterProp="children" | |
369 | - > | |
247 | + <Form.Item name="role" label="数据更新人员" rules={[{ required: true }]}> | |
248 | + <Select placeholder="请选择导入操作角色类型" showSearch allowClear labelInValue optionFilterProp="children"> | |
370 | 249 | {roleList.map((item) => ( |
371 | - <Option | |
372 | - value={item.roleCode} | |
373 | - key={item.roleCode} | |
374 | - > | |
250 | + <Option value={item.roleCode} key={item.roleCode}> | |
375 | 251 | {item.roleName} |
376 | 252 | </Option> |
377 | 253 | ))} |
378 | 254 | </Select> |
379 | 255 | </Form.Item> |
380 | - <Form.Item | |
381 | - name="ruleType" | |
382 | - label="更新周期" | |
383 | - rules={[ | |
384 | - { required: true, message: "请选择更新周期" }, | |
385 | - ]} | |
386 | - > | |
256 | + <Form.Item name="ruleType" label="更新周期" rules={[{ required: true, message: '请选择更新周期' }]}> | |
387 | 257 | <Radio.Group> |
388 | 258 | <Radio value={1}>按滚动天数</Radio> |
389 | 259 | <Radio value={2}>按星期指定</Radio> |
... | ... | @@ -394,14 +264,11 @@ export default function EditModal({ |
394 | 264 | <Form.Item |
395 | 265 | noStyle |
396 | 266 | shouldUpdate={(prevValues, currentValues) => { |
397 | - return ( | |
398 | - prevValues.ruleType !== | |
399 | - currentValues.ruleType | |
400 | - ); | |
267 | + return prevValues.ruleType !== currentValues.ruleType; | |
401 | 268 | }} |
402 | 269 | > |
403 | 270 | {({ getFieldValue }) => { |
404 | - const _ruleType = getFieldValue("ruleType"); | |
271 | + const _ruleType = getFieldValue('ruleType'); | |
405 | 272 | if (_ruleType === 1) { |
406 | 273 | return ( |
407 | 274 | <> |
... | ... | @@ -411,15 +278,11 @@ export default function EditModal({ |
411 | 278 | rules={[ |
412 | 279 | { |
413 | 280 | required: true, |
414 | - message: "请输入滚动天数", | |
281 | + message: '请输入滚动天数', | |
415 | 282 | }, |
416 | 283 | ]} |
417 | 284 | > |
418 | - <InputNumber | |
419 | - placeholder="请输入滚动天数" | |
420 | - addonAfter="天" | |
421 | - style={{ width: 567 }} | |
422 | - /> | |
285 | + <InputNumber placeholder="请输入滚动天数" addonAfter="天" style={{ width: 567 }} /> | |
423 | 286 | </Form.Item> |
424 | 287 | <Form.Item |
425 | 288 | name="startTime1" |
... | ... | @@ -427,7 +290,7 @@ export default function EditModal({ |
427 | 290 | rules={[ |
428 | 291 | { |
429 | 292 | required: true, |
430 | - message: "请选择开始日期", | |
293 | + message: '请选择开始日期', | |
431 | 294 | }, |
432 | 295 | ]} |
433 | 296 | > |
... | ... | @@ -443,7 +306,7 @@ export default function EditModal({ |
443 | 306 | rules={[ |
444 | 307 | { |
445 | 308 | required: true, |
446 | - message: "请选择星期几", | |
309 | + message: '请选择星期几', | |
447 | 310 | }, |
448 | 311 | ]} |
449 | 312 | > |
... | ... | @@ -466,22 +329,13 @@ export default function EditModal({ |
466 | 329 | rules={[ |
467 | 330 | { |
468 | 331 | required: true, |
469 | - message: "按月指定日期", | |
332 | + message: '按月指定日期', | |
470 | 333 | }, |
471 | 334 | ]} |
472 | 335 | > |
473 | - <Select | |
474 | - placeholder="请选择日期" | |
475 | - showSearch | |
476 | - allowClear | |
477 | - optionFilterProp="children" | |
478 | - mode="multiple" | |
479 | - > | |
336 | + <Select placeholder="请选择日期" showSearch allowClear optionFilterProp="children" mode="multiple"> | |
480 | 337 | {DatePick.map((item) => ( |
481 | - <Option | |
482 | - value={item.value} | |
483 | - key={item.value} | |
484 | - > | |
338 | + <Option value={item.value} key={item.value}> | |
485 | 339 | {item.label} |
486 | 340 | </Option> |
487 | 341 | ))} |
... | ... | @@ -497,19 +351,15 @@ export default function EditModal({ |
497 | 351 | rules={[ |
498 | 352 | { |
499 | 353 | required: true, |
500 | - message: "请输入滚动月数", | |
354 | + message: '请输入滚动月数', | |
501 | 355 | }, |
502 | 356 | { |
503 | 357 | pattern: /^(?:1[0-2]|[1-9])$/, |
504 | - message: "请输入1至12的正整数", | |
358 | + message: '请输入1至12的正整数', | |
505 | 359 | }, |
506 | 360 | ]} |
507 | 361 | > |
508 | - <InputNumber | |
509 | - placeholder="请输入滚动月数" | |
510 | - addonAfter="月" | |
511 | - style={{ width: 567 }} | |
512 | - /> | |
362 | + <InputNumber placeholder="请输入滚动月数" addonAfter="月" style={{ width: 567 }} /> | |
513 | 363 | </Form.Item> |
514 | 364 | <Form.Item |
515 | 365 | name="startTime4" |
... | ... | @@ -517,14 +367,11 @@ export default function EditModal({ |
517 | 367 | rules={[ |
518 | 368 | { |
519 | 369 | required: true, |
520 | - message: "请选择开始月数", | |
370 | + message: '请选择开始月数', | |
521 | 371 | }, |
522 | 372 | ]} |
523 | 373 | > |
524 | - <DatePicker | |
525 | - picker="month" | |
526 | - style={{ width: 567 }} | |
527 | - /> | |
374 | + <DatePicker picker="month" style={{ width: 567 }} /> | |
528 | 375 | </Form.Item> |
529 | 376 | <Form.Item |
530 | 377 | name="orderType" |
... | ... | @@ -532,7 +379,7 @@ export default function EditModal({ |
532 | 379 | rules={[ |
533 | 380 | { |
534 | 381 | required: true, |
535 | - message: "请选择滚动正数或倒数", | |
382 | + message: '请选择滚动正数或倒数', | |
536 | 383 | }, |
537 | 384 | ]} |
538 | 385 | > |
... | ... | @@ -547,20 +394,15 @@ export default function EditModal({ |
547 | 394 | rules={[ |
548 | 395 | { |
549 | 396 | required: true, |
550 | - message: "请输入滚动天数", | |
397 | + message: '请输入滚动天数', | |
551 | 398 | }, |
552 | 399 | { |
553 | - pattern: | |
554 | - /^(?:[1-9]|[1-2]\d|3[0-1])$/, | |
555 | - message: "请输入1至31的正整数", | |
400 | + pattern: /^(?:[1-9]|[1-2]\d|3[0-1])$/, | |
401 | + message: '请输入1至31的正整数', | |
556 | 402 | }, |
557 | 403 | ]} |
558 | 404 | > |
559 | - <InputNumber | |
560 | - placeholder="请输入滚动天数" | |
561 | - addonAfter="天" | |
562 | - style={{ width: 567 }} | |
563 | - /> | |
405 | + <InputNumber placeholder="请输入滚动天数" addonAfter="天" style={{ width: 567 }} /> | |
564 | 406 | </Form.Item> |
565 | 407 | </> |
566 | 408 | ); | ... | ... |
src/pages/performance/EvaSetting/entity.ts
1 | -import _ from "lodash"; | |
2 | -import moment from "moment"; | |
1 | +import _ from 'lodash'; | |
2 | +import moment from 'moment'; | |
3 | 3 | |
4 | 4 | // 指标类型 |
5 | 5 | export enum DataTypeEnum { |
6 | - "数量" = 1, | |
7 | - "百分比" = 2, | |
8 | - "金额" = 3, | |
6 | + '数量' = 1, | |
7 | + '百分比' = 2, | |
8 | + '金额' = 3, | |
9 | 9 | } |
10 | 10 | export enum TargetTypeEnum { |
11 | - "无目标" = 1, | |
12 | - "百分比" = 2, | |
13 | - "金额" = 3, | |
14 | - "台数" = 4, | |
11 | + '无目标' = 1, | |
12 | + '百分比' = 2, | |
13 | + '金额' = 3, | |
14 | + '台数' = 4, | |
15 | 15 | } |
16 | 16 | export enum WeekValueEnum { |
17 | - "一" = 1, | |
18 | - "二" = 2, | |
19 | - "三" = 3, | |
20 | - "四" = 4, | |
21 | - "五" = 5, | |
22 | - "六" = 6, | |
23 | - "天" = 7, | |
17 | + '一' = 1, | |
18 | + '二' = 2, | |
19 | + '三' = 3, | |
20 | + '四' = 4, | |
21 | + '五' = 5, | |
22 | + '六' = 6, | |
23 | + '天' = 7, | |
24 | 24 | } |
25 | 25 | export const DataType = [ |
26 | 26 | { |
27 | - label: "数量", | |
27 | + label: '数量', | |
28 | 28 | value: 1, |
29 | 29 | }, |
30 | 30 | { |
31 | - label: "百分比", | |
31 | + label: '百分比', | |
32 | 32 | value: 2, |
33 | 33 | }, |
34 | 34 | { |
35 | - label: "金额", | |
35 | + label: '金额', | |
36 | 36 | value: 3, |
37 | 37 | }, |
38 | 38 | ]; |
39 | 39 | export const UnitType = [ |
40 | 40 | { |
41 | - label: "台", | |
42 | - value: "台", | |
41 | + label: '台', | |
42 | + value: '台', | |
43 | 43 | }, |
44 | 44 | { |
45 | - label: "%", | |
46 | - value: "%", | |
45 | + label: '%', | |
46 | + value: '%', | |
47 | 47 | }, |
48 | 48 | { |
49 | - label: "元", | |
50 | - value: "元", | |
49 | + label: '元', | |
50 | + value: '元', | |
51 | 51 | }, |
52 | 52 | { |
53 | - label: "万元", | |
54 | - value: "万元", | |
53 | + label: '万元', | |
54 | + value: '万元', | |
55 | + }, | |
56 | + { | |
57 | + label: '个', | |
58 | + value: '个', | |
55 | 59 | }, |
56 | 60 | ]; |
57 | 61 | |
58 | 62 | // 绩效目标值类型; 1: 无 2:百分比 3: 金额 |
59 | 63 | export const TargetType = [ |
60 | 64 | { |
61 | - label: "无", | |
65 | + label: '无', | |
62 | 66 | value: false, |
63 | 67 | }, |
64 | 68 | { |
65 | - label: "有", | |
69 | + label: '有', | |
66 | 70 | value: true, |
67 | 71 | }, |
68 | 72 | // { |
... | ... | @@ -75,37 +79,37 @@ export const TargetType = [ |
75 | 79 | // }, |
76 | 80 | ]; |
77 | 81 | export const DatePick = [ |
78 | - { label: "1号", value: 1 }, | |
79 | - { label: "2号", value: 2 }, | |
80 | - { label: "3号", value: 3 }, | |
81 | - { label: "4号", value: 4 }, | |
82 | - { label: "5号", value: 5 }, | |
83 | - { label: "6号", value: 6 }, | |
84 | - { label: "7号", value: 7 }, | |
85 | - { label: "8号", value: 8 }, | |
86 | - { label: "9号", value: 9 }, | |
87 | - { label: "10号", value: 10 }, | |
88 | - { label: "11号", value: 11 }, | |
89 | - { label: "12号", value: 12 }, | |
90 | - { label: "13号", value: 13 }, | |
91 | - { label: "14号", value: 14 }, | |
92 | - { label: "15号", value: 15 }, | |
93 | - { label: "16号", value: 16 }, | |
94 | - { label: "17号", value: 17 }, | |
95 | - { label: "18号", value: 18 }, | |
96 | - { label: "19号", value: 19 }, | |
97 | - { label: "20号", value: 20 }, | |
98 | - { label: "21号", value: 21 }, | |
99 | - { label: "22号", value: 22 }, | |
100 | - { label: "23号", value: 23 }, | |
101 | - { label: "24号", value: 24 }, | |
102 | - { label: "25号", value: 25 }, | |
103 | - { label: "26号", value: 26 }, | |
104 | - { label: "27号", value: 27 }, | |
105 | - { label: "28号", value: 28 }, | |
106 | - { label: "29号", value: 29 }, | |
107 | - { label: "30号", value: 30 }, | |
108 | - { label: "31号", value: 31 }, | |
82 | + { label: '1号', value: 1 }, | |
83 | + { label: '2号', value: 2 }, | |
84 | + { label: '3号', value: 3 }, | |
85 | + { label: '4号', value: 4 }, | |
86 | + { label: '5号', value: 5 }, | |
87 | + { label: '6号', value: 6 }, | |
88 | + { label: '7号', value: 7 }, | |
89 | + { label: '8号', value: 8 }, | |
90 | + { label: '9号', value: 9 }, | |
91 | + { label: '10号', value: 10 }, | |
92 | + { label: '11号', value: 11 }, | |
93 | + { label: '12号', value: 12 }, | |
94 | + { label: '13号', value: 13 }, | |
95 | + { label: '14号', value: 14 }, | |
96 | + { label: '15号', value: 15 }, | |
97 | + { label: '16号', value: 16 }, | |
98 | + { label: '17号', value: 17 }, | |
99 | + { label: '18号', value: 18 }, | |
100 | + { label: '19号', value: 19 }, | |
101 | + { label: '20号', value: 20 }, | |
102 | + { label: '21号', value: 21 }, | |
103 | + { label: '22号', value: 22 }, | |
104 | + { label: '23号', value: 23 }, | |
105 | + { label: '24号', value: 24 }, | |
106 | + { label: '25号', value: 25 }, | |
107 | + { label: '26号', value: 26 }, | |
108 | + { label: '27号', value: 27 }, | |
109 | + { label: '28号', value: 28 }, | |
110 | + { label: '29号', value: 29 }, | |
111 | + { label: '30号', value: 30 }, | |
112 | + { label: '31号', value: 31 }, | |
109 | 113 | ]; |
110 | 114 | |
111 | 115 | /** |
... | ... | @@ -115,41 +119,41 @@ export function transformDTO(formData: any): any { |
115 | 119 | let detail: any = {}; |
116 | 120 | _.each(formData, (value: any, key: string) => { |
117 | 121 | switch (key) { |
118 | - case "belongSystem": | |
122 | + case 'belongSystem': | |
119 | 123 | const _options = value || {}; |
120 | 124 | detail.sysId = _options.value; |
121 | 125 | detail.sysName = _options.label; |
122 | 126 | break; |
123 | - case "role": | |
127 | + case 'role': | |
124 | 128 | const _rolesOptions = value || {}; |
125 | 129 | detail.roleCode = _rolesOptions.value; |
126 | 130 | detail.roleName = _rolesOptions.label; |
127 | 131 | break; |
128 | - case "rollValue1": | |
132 | + case 'rollValue1': | |
129 | 133 | const _rollValue1 = value; |
130 | 134 | detail.rollValue = _rollValue1; |
131 | 135 | break; |
132 | - case "rollValue4": | |
136 | + case 'rollValue4': | |
133 | 137 | const _rollValue4 = value; |
134 | 138 | detail.rollValue = _rollValue4; |
135 | 139 | break; |
136 | - case "startTime1": | |
140 | + case 'startTime1': | |
137 | 141 | const _startTime1 = value; |
138 | 142 | detail.startTime = moment(_startTime1).unix() * 1000; |
139 | 143 | break; |
140 | - case "startTime4": | |
144 | + case 'startTime4': | |
141 | 145 | const _startTime4 = value; |
142 | 146 | detail.startTime = moment(_startTime4).unix() * 1000; |
143 | 147 | break; |
144 | - case "ruleValues2": | |
148 | + case 'ruleValues2': | |
145 | 149 | const _ruleValues2 = value || []; |
146 | 150 | detail.ruleValues = _ruleValues2; |
147 | 151 | break; |
148 | - case "ruleValues3": | |
152 | + case 'ruleValues3': | |
149 | 153 | const _ruleValues3 = value || []; |
150 | 154 | detail.ruleValues = _ruleValues3; |
151 | 155 | break; |
152 | - case "ruleValues4": | |
156 | + case 'ruleValues4': | |
153 | 157 | const _ruleValues4 = value; |
154 | 158 | detail.ruleValues = [_ruleValues4]; |
155 | 159 | break; |
... | ... | @@ -166,27 +170,21 @@ export function transformDTO(formData: any): any { |
166 | 170 | * @param detail |
167 | 171 | * @returns |
168 | 172 | */ |
169 | -export function transformFormData( | |
170 | - detail: any, | |
171 | - roleList: CommonApi.RoleCodeVO[] = [], | |
172 | - list: Privilege.SystemListVO[] = [] | |
173 | -) { | |
173 | +export function transformFormData(detail: any, roleList: CommonApi.RoleCodeVO[] = [], list: Privilege.SystemListVO[] = []) { | |
174 | 174 | let formData = {}; |
175 | 175 | _.each(detail, (value: any, key: string) => { |
176 | 176 | switch (key) { |
177 | - case "roleCode": | |
177 | + case 'roleCode': | |
178 | 178 | const _roleCode = value; |
179 | - const res = roleList | |
180 | - .filter((item) => item.roleCode === _roleCode) | |
181 | - .map((it) => ({ label: it.roleName, value: it.roleCode })); | |
179 | + const res = roleList.filter((item) => item.roleCode === _roleCode).map((it) => ({ label: it.roleName, value: it.roleCode })); | |
182 | 180 | formData.role = res[0]; |
183 | 181 | break; |
184 | - case "sysId": | |
182 | + case 'sysId': | |
185 | 183 | const _sysId = value; |
186 | 184 | const _res = list.filter((item) => item.id === _sysId).map((it) => ({ label: it.sysName, value: it.id })); |
187 | 185 | formData.belongSystem = _res[0]; |
188 | 186 | break; |
189 | - case "rollValue": | |
187 | + case 'rollValue': | |
190 | 188 | const _rollValue = value; |
191 | 189 | if (detail.ruleType === 1) { |
192 | 190 | formData.rollValue1 = _rollValue; |
... | ... | @@ -194,7 +192,7 @@ export function transformFormData( |
194 | 192 | formData.rollValue4 = _rollValue; |
195 | 193 | } |
196 | 194 | break; |
197 | - case "startTime": | |
195 | + case 'startTime': | |
198 | 196 | const _startTime = value; |
199 | 197 | if (detail.ruleType === 1) { |
200 | 198 | formData.startTime1 = moment(_startTime); |
... | ... | @@ -202,7 +200,7 @@ export function transformFormData( |
202 | 200 | formData.startTime4 = moment(_startTime); |
203 | 201 | } |
204 | 202 | break; |
205 | - case "ruleValues": | |
203 | + case 'ruleValues': | |
206 | 204 | const _ruleValues = value; |
207 | 205 | if (detail.ruleType === 4) { |
208 | 206 | formData.ruleValues4 = _ruleValues[0]; | ... | ... |
src/pages/performance/KpiSetting/components/EditModal.tsx
1 | -import React, { useState, useEffect } from "react"; | |
2 | -import { Form, Modal, message, Input, Select, Radio } from "antd"; | |
3 | -import { saveKpiIndicators } from "../api"; | |
4 | -import usePagination from "@/hooks/usePagination"; | |
5 | -import { systemListApi } from "@/pages/admin/Privilege/api"; | |
6 | -import { | |
7 | - RoleType, | |
8 | - transformDTO, | |
9 | - transformFormData, | |
10 | - TargetType, | |
11 | - DataType, | |
12 | - UnitType, | |
13 | -} from "../entity"; | |
14 | -import useInitial from "@/hooks/useInitail"; | |
15 | -import { queryKpiIndicatorApi } from "../../EvaSetting/api"; | |
1 | +import React, { useState, useEffect } from 'react'; | |
2 | +import { Form, Modal, message, Input, Select, Radio } from 'antd'; | |
3 | +import { saveKpiIndicators } from '../api'; | |
4 | +import usePagination from '@/hooks/usePagination'; | |
5 | +import { systemListApi } from '@/pages/admin/Privilege/api'; | |
6 | +import { RoleType, transformDTO, transformFormData, TargetType, DataType, UnitType } from '../entity'; | |
7 | +import useInitial from '@/hooks/useInitail'; | |
8 | +import { queryKpiIndicatorApi } from '../../EvaSetting/api'; | |
16 | 9 | |
17 | 10 | const { Option } = Select; |
18 | 11 | |
... | ... | @@ -30,14 +23,8 @@ export default function EditModal({ onClose, setItem, item, roleList }: Props) { |
30 | 23 | const [customIndicator, setCustomIndicator] = useState<any[]>([]); |
31 | 24 | // 存储角色列表 |
32 | 25 | const { list } = usePagination(systemListApi, { current: 1, pageSize: 500 }); |
33 | - const { data, loading: customLoading } = useInitial( | |
34 | - queryKpiIndicatorApi, | |
35 | - [], | |
36 | - {} | |
37 | - ); | |
38 | - const [isOriginIndicatorCode, setIsOriginIndicatorCode] = useState<boolean>( | |
39 | - !!currentItem.originIndicatorCode | |
40 | - ); | |
26 | + const { data, loading: customLoading } = useInitial(queryKpiIndicatorApi, [], {}); | |
27 | + const [isOriginIndicatorCode, setIsOriginIndicatorCode] = useState<boolean>(!!currentItem.originIndicatorCode); | |
41 | 28 | useEffect(() => { |
42 | 29 | setIsOriginIndicatorCode(!!item.currentItem?.originIndicatorCode); |
43 | 30 | }, [item]); |
... | ... | @@ -67,10 +54,9 @@ export default function EditModal({ onClose, setItem, item, roleList }: Props) { |
67 | 54 | } |
68 | 55 | pa.applyTypes = [1, 2, 3]; |
69 | 56 | pa.dataScopeTypes = [1, 2]; |
57 | + pa.hasStageTarget = true; | |
70 | 58 | if (pa.originIndicatorCode) { |
71 | - const brother: any = data.find( | |
72 | - (item: any) => pa.originIndicatorCode == item.code | |
73 | - ); | |
59 | + const brother: any = data.find((item: any) => pa.originIndicatorCode == item.code); | |
74 | 60 | pa.dataType = brother.dataType; |
75 | 61 | pa.sysId = brother.sysId; |
76 | 62 | pa.sysName = brother.sysName; |
... | ... | @@ -79,7 +65,7 @@ export default function EditModal({ onClose, setItem, item, roleList }: Props) { |
79 | 65 | if (brother?.roleCodes !== undefined) pa.roleCodes = brother?.roleCodes; |
80 | 66 | if (brother?.roleNames !== undefined) pa.roleNames = brother?.roleNames; |
81 | 67 | } |
82 | - console.log("提交表单", pa); | |
68 | + console.log('提交表单', pa); | |
83 | 69 | setSaveLoading(true); |
84 | 70 | saveKpiIndicators(pa) |
85 | 71 | .then((res) => { |
... | ... | @@ -95,7 +81,7 @@ export default function EditModal({ onClose, setItem, item, roleList }: Props) { |
95 | 81 | |
96 | 82 | return ( |
97 | 83 | <Modal |
98 | - title={`${currentItem.id ? "编辑" : "新增"}系统指标`} | |
84 | + title={`${currentItem.id ? '编辑' : '新增'}系统指标`} | |
99 | 85 | open={visible} |
100 | 86 | onOk={form.submit} |
101 | 87 | onCancel={() => onClose?.(false)} |
... | ... | @@ -105,26 +91,12 @@ export default function EditModal({ onClose, setItem, item, roleList }: Props) { |
105 | 91 | afterClose={() => form.resetFields()} |
106 | 92 | destroyOnClose |
107 | 93 | > |
108 | - <Form | |
109 | - form={form} | |
110 | - onFinish={handleSave} | |
111 | - style={{ width: "80%", marginLeft: 50 }} | |
112 | - > | |
113 | - <Form.Item | |
114 | - name="indicatorName" | |
115 | - label="指标名称" | |
116 | - rules={[{ required: true, message: "请输入指标名称" }]} | |
117 | - > | |
94 | + <Form form={form} onFinish={handleSave} style={{ width: '80%', marginLeft: 50 }}> | |
95 | + <Form.Item name="indicatorName" label="指标名称" rules={[{ required: true, message: '请输入指标名称' }]}> | |
118 | 96 | <Input placeholder="请输入指标名称" /> |
119 | 97 | </Form.Item> |
120 | 98 | <Form.Item name="originIndicatorCode" label="原始关联指标(可不选)"> |
121 | - <Select | |
122 | - placeholder="原始关联指标(可选)" | |
123 | - loading={customLoading} | |
124 | - showSearch | |
125 | - allowClear | |
126 | - optionFilterProp="children" | |
127 | - > | |
99 | + <Select placeholder="原始关联指标(可选)" loading={customLoading} showSearch allowClear optionFilterProp="children"> | |
128 | 100 | {customIndicator.map((item) => ( |
129 | 101 | <Option value={item.value} key={item.value}> |
130 | 102 | {item.label} |
... | ... | @@ -135,15 +107,10 @@ export default function EditModal({ onClose, setItem, item, roleList }: Props) { |
135 | 107 | <Form.Item |
136 | 108 | noStyle |
137 | 109 | shouldUpdate={(prevValues, currentValues) => { |
138 | - if ( | |
139 | - prevValues.originIndicatorCode !== | |
140 | - currentValues.originIndicatorCode | |
141 | - ) { | |
110 | + if (prevValues.originIndicatorCode !== currentValues.originIndicatorCode) { | |
142 | 111 | setIsOriginIndicatorCode(!!currentValues.originIndicatorCode); |
143 | 112 | if (currentValues.originIndicatorCode) { |
144 | - const brother = data.find( | |
145 | - (item: any) => currentValues.originIndicatorCode == item.code | |
146 | - ); | |
113 | + const brother = data.find((item: any) => currentValues.originIndicatorCode == item.code); | |
147 | 114 | form.setFieldsValue({ |
148 | 115 | unit: brother?.unit, |
149 | 116 | hasTarget: true, |
... | ... | @@ -151,10 +118,7 @@ export default function EditModal({ onClose, setItem, item, roleList }: Props) { |
151 | 118 | }); |
152 | 119 | } |
153 | 120 | } |
154 | - return ( | |
155 | - prevValues.originIndicatorCode !== | |
156 | - currentValues.originIndicatorCode | |
157 | - ); | |
121 | + return prevValues.originIndicatorCode !== currentValues.originIndicatorCode; | |
158 | 122 | }} |
159 | 123 | > |
160 | 124 | {() => { |
... | ... | @@ -171,11 +135,7 @@ export default function EditModal({ onClose, setItem, item, roleList }: Props) { |
171 | 135 | </Select> |
172 | 136 | </Form.Item> |
173 | 137 | {!isOriginIndicatorCode && ( |
174 | - <Form.Item | |
175 | - name="dataType" | |
176 | - label="数值类型" | |
177 | - rules={[{ required: true }]} | |
178 | - > | |
138 | + <Form.Item name="dataType" label="数值类型" rules={[{ required: true }]}> | |
179 | 139 | <Select placeholder="请选择数值类型"> |
180 | 140 | {DataType.map((item) => ( |
181 | 141 | <Option value={item.value} key={item.value}> |
... | ... | @@ -185,11 +145,7 @@ export default function EditModal({ onClose, setItem, item, roleList }: Props) { |
185 | 145 | </Select> |
186 | 146 | </Form.Item> |
187 | 147 | )} |
188 | - <Form.Item | |
189 | - name="hasTarget" | |
190 | - label="有无目标" | |
191 | - rules={[{ required: true }]} | |
192 | - > | |
148 | + <Form.Item name="hasTarget" label="有无目标" rules={[{ required: true }]}> | |
193 | 149 | <Select disabled={isOriginIndicatorCode} placeholder="请选择有无目标"> |
194 | 150 | {TargetType.map((item) => ( |
195 | 151 | <Option value={item.value} key={item.label}> |
... | ... | @@ -199,34 +155,15 @@ export default function EditModal({ onClose, setItem, item, roleList }: Props) { |
199 | 155 | </Select> |
200 | 156 | </Form.Item> |
201 | 157 | <Form.Item |
202 | - name="hasStageTarget" | |
203 | - label="有无阶段目标" | |
204 | - rules={[{ required: true }]} | |
205 | - > | |
206 | - <Select placeholder="请选择有无阶段目标"> | |
207 | - {TargetType.map((item) => ( | |
208 | - <Option value={item.value} key={item.label}> | |
209 | - {item.label} | |
210 | - </Option> | |
211 | - ))} | |
212 | - </Select> | |
213 | - </Form.Item> | |
214 | - <Form.Item | |
215 | 158 | noStyle |
216 | 159 | shouldUpdate={(prevValues, currentValues) => { |
217 | 160 | return prevValues.targetType !== currentValues.targetType; |
218 | 161 | }} |
219 | 162 | > |
220 | 163 | {({ getFieldValue }) => { |
221 | - return getFieldValue("targetType") !== 1 ? ( | |
164 | + return getFieldValue('targetType') !== 1 ? ( | |
222 | 165 | <> |
223 | - <Form.Item | |
224 | - name="businessName" | |
225 | - label="业务报表指标名称" | |
226 | - rules={[ | |
227 | - { required: true, message: "请输入业务报表指标名称" }, | |
228 | - ]} | |
229 | - > | |
166 | + <Form.Item name="businessName" label="业务报表指标名称" rules={[{ required: true, message: '请输入业务报表指标名称' }]}> | |
230 | 167 | <Input placeholder="请输入业务报表指标名称" /> |
231 | 168 | </Form.Item> |
232 | 169 | </> |
... | ... | @@ -234,11 +171,7 @@ export default function EditModal({ onClose, setItem, item, roleList }: Props) { |
234 | 171 | }} |
235 | 172 | </Form.Item> |
236 | 173 | {!isOriginIndicatorCode && ( |
237 | - <Form.Item | |
238 | - name="innerIndicator" | |
239 | - label="内部指标" | |
240 | - rules={[{ required: true }]} | |
241 | - > | |
174 | + <Form.Item name="innerIndicator" label="内部指标" rules={[{ required: true }]}> | |
242 | 175 | <Radio.Group> |
243 | 176 | <Radio value>是</Radio> |
244 | 177 | <Radio value={false}>否</Radio> |
... | ... | @@ -246,18 +179,8 @@ export default function EditModal({ onClose, setItem, item, roleList }: Props) { |
246 | 179 | </Form.Item> |
247 | 180 | )} |
248 | 181 | {!isOriginIndicatorCode && ( |
249 | - <Form.Item | |
250 | - name="belongSystem" | |
251 | - label="归属系统" | |
252 | - rules={[{ required: true }]} | |
253 | - > | |
254 | - <Select | |
255 | - placeholder="请选择归属系统" | |
256 | - showSearch | |
257 | - allowClear | |
258 | - labelInValue | |
259 | - optionFilterProp="children" | |
260 | - > | |
182 | + <Form.Item name="belongSystem" label="归属系统" rules={[{ required: true }]}> | |
183 | + <Select placeholder="请选择归属系统" showSearch allowClear labelInValue optionFilterProp="children"> | |
261 | 184 | {list.map((item) => ( |
262 | 185 | <Option value={item.id} key={item.id}> |
263 | 186 | {item.sysName} |
... | ... | @@ -268,11 +191,7 @@ export default function EditModal({ onClose, setItem, item, roleList }: Props) { |
268 | 191 | )} |
269 | 192 | {/* 使用角色 */} |
270 | 193 | {!isOriginIndicatorCode && ( |
271 | - <Form.Item | |
272 | - name="roleType" | |
273 | - label="适用角色类型" | |
274 | - rules={[{ required: true }]} | |
275 | - > | |
194 | + <Form.Item name="roleType" label="适用角色类型" rules={[{ required: true }]}> | |
276 | 195 | <Select placeholder="请选择角色类型"> |
277 | 196 | {RoleType.map((item) => ( |
278 | 197 | <Option value={item.value} key={item.value}> |
... | ... | @@ -289,12 +208,8 @@ export default function EditModal({ onClose, setItem, item, roleList }: Props) { |
289 | 208 | }} |
290 | 209 | > |
291 | 210 | {({ getFieldValue }) => { |
292 | - return getFieldValue("roleType") === 3 ? ( | |
293 | - <Form.Item | |
294 | - name="roles" | |
295 | - label="适用角色" | |
296 | - rules={[{ required: true }]} | |
297 | - > | |
211 | + return getFieldValue('roleType') === 3 ? ( | |
212 | + <Form.Item name="roles" label="适用角色" rules={[{ required: true }]}> | |
298 | 213 | <Select |
299 | 214 | placeholder="请选择角色" |
300 | 215 | showSearch | ... | ... |
src/pages/performance/KpiSetting/entity.ts
1 | -import _ from "lodash"; | |
1 | +import _ from 'lodash'; | |
2 | 2 | |
3 | 3 | // roleType 适用角色类型; 1: 全部角色 2:全部管理角色 3: 自定义(See: 适用角色类型枚举) |
4 | 4 | export const RoleType = [ |
5 | 5 | { |
6 | - label: "全部角色", | |
6 | + label: '全部角色', | |
7 | 7 | value: 1, |
8 | 8 | }, |
9 | 9 | { |
10 | - label: "全部管理角色", | |
10 | + label: '全部管理角色', | |
11 | 11 | value: 2, |
12 | 12 | }, |
13 | 13 | { |
14 | - label: "自定义", | |
14 | + label: '自定义', | |
15 | 15 | value: 3, |
16 | 16 | }, |
17 | 17 | ]; |
18 | 18 | export const UnitType = [ |
19 | 19 | { |
20 | - label: "台", | |
21 | - value: "台", | |
20 | + label: '台', | |
21 | + value: '台', | |
22 | 22 | }, |
23 | 23 | { |
24 | - label: "%", | |
25 | - value: "%", | |
24 | + label: '%', | |
25 | + value: '%', | |
26 | 26 | }, |
27 | 27 | { |
28 | - label: "元", | |
29 | - value: "元", | |
28 | + label: '元', | |
29 | + value: '元', | |
30 | 30 | }, |
31 | 31 | { |
32 | - label: "万元", | |
33 | - value: "万元", | |
32 | + label: '万元', | |
33 | + value: '万元', | |
34 | + }, | |
35 | + { | |
36 | + label: '个', | |
37 | + value: '个', | |
34 | 38 | }, |
35 | 39 | ]; |
36 | 40 | |
37 | 41 | export enum Role_Type_Enum { |
38 | - "全部角色" = 1, | |
39 | - "全部管理角色", | |
40 | - "自定义", | |
42 | + '全部角色' = 1, | |
43 | + '全部管理角色', | |
44 | + '自定义', | |
41 | 45 | } |
42 | 46 | |
43 | 47 | // 审批状态 |
44 | 48 | export enum StatusEnum { |
45 | - "启用" = 1, | |
46 | - "禁用", | |
49 | + '启用' = 1, | |
50 | + '禁用', | |
47 | 51 | } |
48 | 52 | |
49 | 53 | export const Approval_Status = [ |
50 | 54 | { |
51 | - label: "启用", | |
55 | + label: '启用', | |
52 | 56 | value: 1, |
53 | 57 | }, |
54 | 58 | { |
55 | - label: "禁用", | |
59 | + label: '禁用', | |
56 | 60 | value: 2, |
57 | 61 | }, |
58 | 62 | ]; |
59 | 63 | // 绩效目标值类型; 1: 无 2:百分比 3: 金额 |
60 | 64 | export const TargetType = [ |
61 | 65 | { |
62 | - label: "无", | |
66 | + label: '无', | |
63 | 67 | value: false, |
64 | 68 | }, |
65 | 69 | { |
66 | - label: "有", | |
70 | + label: '有', | |
67 | 71 | value: true, |
68 | 72 | }, |
69 | 73 | // { |
... | ... | @@ -77,50 +81,50 @@ export const TargetType = [ |
77 | 81 | ]; |
78 | 82 | export const DataType = [ |
79 | 83 | { |
80 | - label: "数量", | |
84 | + label: '数量', | |
81 | 85 | value: 1, |
82 | 86 | }, |
83 | 87 | { |
84 | - label: "百分比", | |
88 | + label: '百分比', | |
85 | 89 | value: 2, |
86 | 90 | }, |
87 | 91 | { |
88 | - label: "金额", | |
92 | + label: '金额', | |
89 | 93 | value: 3, |
90 | 94 | }, |
91 | 95 | ]; |
92 | 96 | export const ApplyTypes = [ |
93 | 97 | { |
94 | - label: "绩效", | |
98 | + label: '绩效', | |
95 | 99 | value: 1, |
96 | 100 | }, |
97 | 101 | //sdhjfshvfasdasd |
98 | 102 | { |
99 | - label: "薪酬", | |
103 | + label: '薪酬', | |
100 | 104 | value: 2, |
101 | 105 | }, |
102 | 106 | { |
103 | - label: "考评", | |
107 | + label: '考评', | |
104 | 108 | value: 3, |
105 | 109 | }, |
106 | 110 | ]; |
107 | 111 | |
108 | 112 | // 审批状态 |
109 | 113 | export enum TargetTypeEnum { |
110 | - "无" = 1, | |
111 | - "百分比", | |
112 | - "金额", | |
114 | + '无' = 1, | |
115 | + '百分比', | |
116 | + '金额', | |
113 | 117 | } |
114 | 118 | // 指标类型 |
115 | 119 | export enum DataTypeEnum { |
116 | - "数量" = 1, | |
117 | - "百分比", | |
118 | - "金额", | |
120 | + '数量' = 1, | |
121 | + '百分比', | |
122 | + '金额', | |
119 | 123 | } |
120 | 124 | export enum ApplyTypesEnum { |
121 | - "绩效" = 1, | |
122 | - "薪酬", | |
123 | - "考评", | |
125 | + '绩效' = 1, | |
126 | + '薪酬', | |
127 | + '考评', | |
124 | 128 | } |
125 | 129 | export interface RoleList { |
126 | 130 | children: string; |
... | ... | @@ -141,12 +145,12 @@ export function transformDTO(formData: formData): KpiSetteing.KpiIndicatorsParam |
141 | 145 | let detail: KpiSetteing.KpiIndicatorsParams = {}; |
142 | 146 | _.each(formData, (value: any, key: string) => { |
143 | 147 | switch (key) { |
144 | - case "belongSystem": | |
148 | + case 'belongSystem': | |
145 | 149 | const _options = value || {}; |
146 | 150 | detail.sysId = _options.value; |
147 | 151 | detail.sysName = _options.label; |
148 | 152 | break; |
149 | - case "roles": | |
153 | + case 'roles': | |
150 | 154 | const _rolesOptions: { label: string; value: string }[] = value || []; |
151 | 155 | detail.roleCodes = _rolesOptions.map((item) => item.value); |
152 | 156 | detail.roleNames = _rolesOptions.map((item) => item.label); |
... | ... | @@ -167,12 +171,12 @@ export function transformDTO(formData: formData): KpiSetteing.KpiIndicatorsParam |
167 | 171 | export function transformFormData( |
168 | 172 | detail: ApprovalSetteing.ApprovalListItems, |
169 | 173 | roleList: CommonApi.RoleCodeVO[] = [], |
170 | - list: Privilege.SystemListVO[] = [] | |
174 | + list: Privilege.SystemListVO[] = [], | |
171 | 175 | ) { |
172 | 176 | let formData = {}; |
173 | 177 | _.each(detail, (value: any, key: string) => { |
174 | 178 | switch (key) { |
175 | - case "roleCodes": | |
179 | + case 'roleCodes': | |
176 | 180 | const _options: string[] = value || []; |
177 | 181 | if (_options.length) { |
178 | 182 | const _res = roleList |
... | ... | @@ -183,7 +187,7 @@ export function transformFormData( |
183 | 187 | formData.roles = [{}]; |
184 | 188 | } |
185 | 189 | break; |
186 | - case "sysId": | |
190 | + case 'sysId': | |
187 | 191 | const _sysId = value; |
188 | 192 | const _res = list.filter((item) => item.id === _sysId).map((it) => ({ label: it.sysName, value: it.id })); |
189 | 193 | formData.belongSystem = _res[0]; | ... | ... |
src/pages/performance/KpiSetting/interface.d.ts