Commit 3f6ecf02965d505106cc56f5c65e1c6357678045
1 parent
ce698ce0
添加 工作类型设置(内部),并对接接口;
Showing
4 changed files
with
230 additions
and
116 deletions
config/routers/office.ts
1 | /* | 1 | /* |
2 | * @Date: 2021-08-10 09:51:37 | 2 | * @Date: 2021-08-10 09:51:37 |
3 | * @LastEditors: wangqiang@feewee.cn | 3 | * @LastEditors: wangqiang@feewee.cn |
4 | - * @LastEditTime: 2021-10-12 14:36:13 | 4 | + * @LastEditTime: 2023-01-30 10:41:51 |
5 | */ | 5 | */ |
6 | export default [ | 6 | export default [ |
7 | /** 会议办公 **/ | 7 | /** 会议办公 **/ |
8 | { | 8 | { |
9 | - path: '/office/workStandardSetting', // 工作项标准配置 | ||
10 | - component: './office/Work/WorkStandardSetting' | 9 | + path: "/office/workStandardSetting", // 工作项标准配置 |
10 | + component: "./office/Work/WorkStandardSetting", | ||
11 | }, | 11 | }, |
12 | { | 12 | { |
13 | - path: '/office/workShopStandardSetting', // 门店工作项匹配标准设置 | ||
14 | - component: './office/Work/WorkShopStandardSetting' | 13 | + path: "/office/workShopStandardSetting", // 门店工作项匹配标准设置 |
14 | + component: "./office/Work/WorkShopStandardSetting", | ||
15 | }, | 15 | }, |
16 | { | 16 | { |
17 | - path: '/office/punishmentMattersSettings', // 处罚事项设置 | ||
18 | - component: './office/PunishmentMattersSettings' | 17 | + path: "/office/punishmentMattersSettings", // 处罚事项设置 |
18 | + component: "./office/PunishmentMattersSettings", | ||
19 | }, | 19 | }, |
20 | { | 20 | { |
21 | - path: '/office/rewardAmountSetting', // 奖励额度设置 | ||
22 | - component: './office/RewardAmountSetting' | 21 | + path: "/office/rewardAmountSetting", // 奖励额度设置 |
22 | + component: "./office/RewardAmountSetting", | ||
23 | }, | 23 | }, |
24 | { | 24 | { |
25 | - path: '/office/workTypeSetting', // 工作类型设置 | ||
26 | - component: './office/WorkTypeSetting' | 25 | + path: "/office/workTypeSetting", // 工作类型设置 |
26 | + component: "./office/WorkTypeSetting", | ||
27 | + }, | ||
28 | + { | ||
29 | + path: "/office/workTypeSetting_private", // 工作类型设置(内部) | ||
30 | + component: "./office/WorkTypeSetting", | ||
27 | }, | 31 | }, |
28 | ]; | 32 | ]; |
29 | \ No newline at end of file | 33 | \ No newline at end of file |
src/pages/office/WorkTypeSetting/api.ts
1 | /* | 1 | /* |
2 | * @Date: 2021-03-23 17:48:39 | 2 | * @Date: 2021-03-23 17:48:39 |
3 | * @LastEditors: wangqiang@feewee.cn | 3 | * @LastEditors: wangqiang@feewee.cn |
4 | - * @LastEditTime: 2021-10-08 10:06:58 | 4 | + * @LastEditTime: 2023-01-30 10:47:34 |
5 | */ | 5 | */ |
6 | -import request from '@/utils/request'; | ||
7 | -import { OFFICE } from '@/utils/host'; | ||
8 | -import { http } from '@/typing/http'; | 6 | +import request from "@/utils/request"; |
7 | +import { OFFICE } from "@/utils/host"; | ||
8 | +import { http } from "@/typing/http"; | ||
9 | 9 | ||
10 | /** | 10 | /** |
11 | * @description: 工作类型分页 | 11 | * @description: 工作类型分页 |
12 | * @param {WorkTypeSetting.QueryParams} params | 12 | * @param {WorkTypeSetting.QueryParams} params |
13 | * @return {http.PromisePageResp<WorkTypeSetting.WorkTypeItemVO>} | 13 | * @return {http.PromisePageResp<WorkTypeSetting.WorkTypeItemVO>} |
14 | */ | 14 | */ |
15 | -export function getWorkTypeListApi(params: WorkTypeSetting.QueryParams): http.PromisePageResp<WorkTypeSetting.WorkTypeItemVO> { | ||
16 | - return request.get(`${OFFICE}/erp/work/config//type/page`, { params }); | 15 | +export function getWorkTypeListApi( |
16 | + params: WorkTypeSetting.QueryParams | ||
17 | +): http.PromisePageResp<WorkTypeSetting.WorkTypeItemVO> { | ||
18 | + return request.get(`${OFFICE}/erp/work/config/type/page`, { params }); | ||
17 | } | 19 | } |
18 | 20 | ||
19 | /** | 21 | /** |
@@ -21,7 +23,9 @@ export function getWorkTypeListApi(params: WorkTypeSetting.QueryParams): http.Pr | @@ -21,7 +23,9 @@ export function getWorkTypeListApi(params: WorkTypeSetting.QueryParams): http.Pr | ||
21 | * @param {WorkTypeSetting.WorkTypeItemVO} params | 23 | * @param {WorkTypeSetting.WorkTypeItemVO} params |
22 | * @return {http.PromiseResp<string>} | 24 | * @return {http.PromiseResp<string>} |
23 | */ | 25 | */ |
24 | -export function saveWorkTypeApi(params: WorkTypeSetting.WorkTypeItemVO): http.PromiseResp<string> { | 26 | +export function saveWorkTypeApi( |
27 | + params: WorkTypeSetting.WorkTypeItemVO | ||
28 | +): http.PromiseResp<string> { | ||
25 | return request.post(`${OFFICE}/erp/work/config//type/save`, params); | 29 | return request.post(`${OFFICE}/erp/work/config//type/save`, params); |
26 | } | 30 | } |
27 | 31 | ||
@@ -31,5 +35,7 @@ export function saveWorkTypeApi(params: WorkTypeSetting.WorkTypeItemVO): http.Pr | @@ -31,5 +35,7 @@ export function saveWorkTypeApi(params: WorkTypeSetting.WorkTypeItemVO): http.Pr | ||
31 | * @return {http.PromiseResp<string>} | 35 | * @return {http.PromiseResp<string>} |
32 | */ | 36 | */ |
33 | export function deleteWorkTypeApi(id: number): http.PromiseResp<string> { | 37 | export function deleteWorkTypeApi(id: number): http.PromiseResp<string> { |
34 | - return request.get(`${OFFICE}/erp/work/config//type/remove`, { params: { id } }); | ||
35 | -} | ||
36 | \ No newline at end of file | 38 | \ No newline at end of file |
39 | + return request.get(`${OFFICE}/erp/work/config//type/remove`, { | ||
40 | + params: { id }, | ||
41 | + }); | ||
42 | +} |
src/pages/office/WorkTypeSetting/index.tsx
1 | /* | 1 | /* |
2 | * @Date: 2021-03-23 17:47:45 | 2 | * @Date: 2021-03-23 17:47:45 |
3 | * @LastEditors: wangqiang@feewee.cn | 3 | * @LastEditors: wangqiang@feewee.cn |
4 | - * @LastEditTime: 2021-10-08 10:17:36 | 4 | + * @LastEditTime: 2023-01-30 11:19:10 |
5 | */ | 5 | */ |
6 | -import React, { useEffect, useState } from 'react'; | ||
7 | -import { Modal, List, Button, Row, Col, Input, Popconfirm, message, Card, ConfigProvider } from 'antd'; | ||
8 | -import { PlusOutlined, CloseOutlined, DatabaseOutlined, PlusCircleOutlined, EditOutlined, CheckCircleOutlined, CloseCircleOutlined, DeleteOutlined } from '@ant-design/icons'; | ||
9 | -import { getWorkTypeListApi, saveWorkTypeApi, deleteWorkTypeApi } from './api'; | ||
10 | -import { debounce } from 'lodash'; | ||
11 | -import usePagination from '@/hooks/usePagination'; | ||
12 | -import { PageHeaderWrapper } from '@ant-design/pro-layout'; | ||
13 | -import zhCN from 'antd/lib/locale-provider/zh_CN'; | 6 | +import React, { useEffect, useState } from "react"; |
7 | +import { | ||
8 | + Modal, | ||
9 | + Button, | ||
10 | + Row, | ||
11 | + Input, | ||
12 | + Popconfirm, | ||
13 | + message, | ||
14 | + Card, | ||
15 | + ConfigProvider, | ||
16 | + Table, | ||
17 | + Divider, | ||
18 | + Form, | ||
19 | + Spin, | ||
20 | +} from "antd"; | ||
21 | +import { PlusOutlined } from "@ant-design/icons"; | ||
22 | +import { getWorkTypeListApi, saveWorkTypeApi, deleteWorkTypeApi } from "./api"; | ||
23 | +import { debounce } from "lodash"; | ||
24 | +import usePagination from "@/hooks/usePagination"; | ||
25 | +import { PageHeaderWrapper } from "@ant-design/pro-layout"; | ||
26 | +import zhCN from "antd/lib/locale-provider/zh_CN"; | ||
27 | +import { history } from "umi"; | ||
28 | +import FeeweeFilterOption from "@/pages/notice/components/FeeweeFilterOption"; | ||
14 | 29 | ||
15 | export default function WorkTypeSettings() { | 30 | export default function WorkTypeSettings() { |
16 | - const examTypePagination = usePagination(getWorkTypeListApi); | ||
17 | - const { list, loading, setLoading, paginationConfig, setParams: setExamTypeParams } = examTypePagination; | ||
18 | - const [isAdd, setIsAdd] = useState(false); | ||
19 | - const [addInputValue, setAddInputValue] = useState<string>(); | ||
20 | - const [edit, setEdit] = useState<{ id?: number, value?: string }>(); | 31 | + const systemDefine = history.location.pathname.includes( |
32 | + "workTypeSetting_private" | ||
33 | + ); | ||
34 | + const workTypePagination = usePagination(getWorkTypeListApi, { | ||
35 | + systemDefine, | ||
36 | + }); | ||
37 | + const { | ||
38 | + list, | ||
39 | + loading, | ||
40 | + setLoading, | ||
41 | + paginationConfig, | ||
42 | + setParams: setExamTypeParams, | ||
43 | + } = workTypePagination; | ||
44 | + const [form] = Form.useForm(); | ||
45 | + const [confirmLoading, setConfirmLoading] = useState(false); | ||
46 | + const [current, setCurrent] = useState<WorkTypeSetting.WorkTypeItemVO>(); | ||
47 | + const [open, setOpen] = useState(false); | ||
21 | 48 | ||
22 | - const editItem = (): any => { | ||
23 | - if (!edit?.value || (edit?.value && !edit?.value.trim())) return message.error('工作类型不能为空!'); | ||
24 | - saveWorkTypeApi({ id: edit?.id, name: edit?.value }).then(res => { | ||
25 | - message.success('操作成功'); | ||
26 | - setLoading(true); | ||
27 | - setEdit(undefined); | ||
28 | - }).catch(error => { | ||
29 | - message.error(error.message); | ||
30 | - }); | ||
31 | - } | 49 | + useEffect(() => { |
50 | + if (open) { | ||
51 | + current && | ||
52 | + form.setFieldsValue({ | ||
53 | + ...current, | ||
54 | + }); | ||
55 | + } else { | ||
56 | + form.resetFields(); | ||
57 | + } | ||
58 | + }, [open, current]); | ||
32 | 59 | ||
33 | const delItem = (id: number) => { | 60 | const delItem = (id: number) => { |
34 | - deleteWorkTypeApi(id).then(res => { | ||
35 | - message.success('删除成功'); | ||
36 | - setLoading(true); | ||
37 | - }).catch(error => message.error(error.message)); | ||
38 | - } | 61 | + deleteWorkTypeApi(id) |
62 | + .then((res) => { | ||
63 | + message.success("删除成功"); | ||
64 | + setLoading(true); | ||
65 | + }) | ||
66 | + .catch((error) => message.error(error.message)); | ||
67 | + }; | ||
39 | 68 | ||
40 | - const addOption = (): any => { | ||
41 | - if (!addInputValue || (addInputValue && !addInputValue.trim())) return message.error('工作类型不能为空!'); | ||
42 | - saveWorkTypeApi({ name: addInputValue }).then(res => { | ||
43 | - message.success('操作成功'); | ||
44 | - setAddInputValue(undefined); | ||
45 | - setLoading(true); | ||
46 | - }).catch(error => { | ||
47 | - message.error(error.message); | ||
48 | - }); | ||
49 | - } | 69 | + const onSearch = debounce( |
70 | + (name: string) => setExamTypeParams({ name, current: 1 }, true), | ||
71 | + 500 | ||
72 | + ); | ||
50 | 73 | ||
51 | - const renderItem = (item: ExamSetting.TypeItem) => <List.Item key={item.id}> | ||
52 | - <DatabaseOutlined style={{ marginRight: 10 }} /> | ||
53 | - <Input | ||
54 | - readOnly={edit?.id !== item.id} | ||
55 | - bordered={edit?.id === item.id} | ||
56 | - allowClear | ||
57 | - value={edit && edit.id === item.id ? edit.value : item.name} | ||
58 | - onChange={e => setEdit({ ...edit, value: e.target.value })} | ||
59 | - onClick={() => setEdit({ id: item.id, value: item.name })} | ||
60 | - suffix={edit && edit.id === item.id ? | ||
61 | - <Popconfirm title={`确定修改工作类型?`} onConfirm={() => editItem()}> | ||
62 | - <Button type='link' icon={<CheckCircleOutlined />} /> | ||
63 | - </Popconfirm> : | ||
64 | - <> | ||
65 | - <Button type='link' icon={<EditOutlined />} onClick={() => setEdit({ id: item.id, value: item.name })} /> | ||
66 | - <Popconfirm title={`确定删除【${item.name}】工作类型?`} onConfirm={() => delItem(item.id!)}> | ||
67 | - <Button type='link' icon={<DeleteOutlined />} danger /> | ||
68 | - </Popconfirm> | ||
69 | - </>} | ||
70 | - /> | ||
71 | - </List.Item> | ||
72 | - | ||
73 | - const onSearch = debounce((name: string) => setExamTypeParams({ name, current: 1 }, true), 500); | 74 | + const onOk = (val: any) => { |
75 | + const params: WorkTypeSetting.WorkTypeItemVO = { | ||
76 | + id: current?.id, | ||
77 | + name: val.name, | ||
78 | + key: val?.key, | ||
79 | + pageLink: val.pageLink, | ||
80 | + systemDefine, | ||
81 | + }; | ||
82 | + setConfirmLoading(true); | ||
83 | + saveWorkTypeApi(params) | ||
84 | + .then((res) => { | ||
85 | + setConfirmLoading(false); | ||
86 | + message.success(res.result); | ||
87 | + setOpen(false); | ||
88 | + setLoading(true); | ||
89 | + }) | ||
90 | + .catch((error) => { | ||
91 | + setConfirmLoading(false); | ||
92 | + message.error(error.message || "保存工作类型失败"); | ||
93 | + }); | ||
94 | + }; | ||
74 | 95 | ||
75 | return ( | 96 | return ( |
76 | - <PageHeaderWrapper title="工作类型设置"> | 97 | + <PageHeaderWrapper title={`工作类型设置${systemDefine ? "(内部)" : ""}`}> |
77 | <ConfigProvider locale={zhCN}> | 98 | <ConfigProvider locale={zhCN}> |
78 | <Card bordered={false}> | 99 | <Card bordered={false}> |
79 | <Row justify="space-between" style={{ marginBottom: 20 }}> | 100 | <Row justify="space-between" style={{ marginBottom: 20 }}> |
80 | - <Input placeholder="输入工作项大类查询" allowClear style={{ width: 260 }} onChange={e => onSearch(e.target.value)} /> | ||
81 | - <Button type='link' icon={<CloseCircleOutlined />} disabled={!edit} onClick={() => setEdit(undefined)}>取消编辑</Button> | 101 | + <FeeweeFilterOption title="工作类型"> |
102 | + <Input | ||
103 | + placeholder="输入工作类型查询" | ||
104 | + allowClear | ||
105 | + style={{ minWidth: 260 }} | ||
106 | + onChange={(e) => onSearch(e.target.value)} | ||
107 | + /> | ||
108 | + </FeeweeFilterOption> | ||
109 | + <Button | ||
110 | + type="primary" | ||
111 | + icon={<PlusOutlined />} | ||
112 | + onClick={() => { | ||
113 | + setCurrent(undefined); | ||
114 | + setOpen(true); | ||
115 | + }} | ||
116 | + > | ||
117 | + 添加 | ||
118 | + </Button> | ||
82 | </Row> | 119 | </Row> |
83 | - <List | ||
84 | - bordered | ||
85 | - loading={loading} | ||
86 | - pagination={{ ...paginationConfig, size: 'small' }} | 120 | + <Table |
87 | dataSource={list} | 121 | dataSource={list} |
122 | + pagination={paginationConfig} | ||
123 | + loading={loading} | ||
88 | rowKey="id" | 124 | rowKey="id" |
89 | - renderItem={item => renderItem(item)} | ||
90 | - /> | ||
91 | - <Row justify='space-between' style={{ height: 42, marginTop: 20 }}> | ||
92 | - <Col span={6} style={{ justifyContent: 'center', alignItems: 'center', display: 'flex' }}> | ||
93 | - <Button type='link' icon={isAdd ? <CloseOutlined /> : <PlusOutlined />} onClick={() => setIsAdd(!isAdd)} style={{ padding: '4px 0' }}>{isAdd ? '取消添加类型' : '添加工作类型'}</Button> | ||
94 | - </Col> | ||
95 | - <Col span={18}> | ||
96 | - {isAdd && <Input | ||
97 | - style={{ width: '100%' }} | ||
98 | - placeholder='请输入工作类型' | ||
99 | - allowClear | ||
100 | - value={addInputValue} | ||
101 | - onChange={e => setAddInputValue(e.target.value)} | ||
102 | - suffix={ | ||
103 | - <Popconfirm title={`确定添加工作类型?`} onConfirm={() => addOption()}> | ||
104 | - <Button type='link' icon={<PlusCircleOutlined />} disabled={!addInputValue} /> | ||
105 | - </Popconfirm> | ||
106 | - } /> | ||
107 | - } | ||
108 | - </Col> | ||
109 | - </Row> | 125 | + > |
126 | + <Table.Column title="工作类型" dataIndex="name" align="left" /> | ||
127 | + {systemDefine ? ( | ||
128 | + <> | ||
129 | + <Table.Column | ||
130 | + title="业务详情key" | ||
131 | + dataIndex="key" | ||
132 | + align="left" | ||
133 | + render={(key: string) => key || "-"} | ||
134 | + /> | ||
135 | + <Table.Column | ||
136 | + title="业务详情APP路径" | ||
137 | + dataIndex="pageLink" | ||
138 | + align="left" | ||
139 | + render={(pageLink: string) => pageLink || "-"} | ||
140 | + /> | ||
141 | + </> | ||
142 | + ) : null} | ||
143 | + <Table.Column | ||
144 | + title="操作" | ||
145 | + align="left" | ||
146 | + render={(record: WorkTypeSetting.WorkTypeItemVO) => ( | ||
147 | + <> | ||
148 | + <a | ||
149 | + onClick={() => { | ||
150 | + setCurrent(record); | ||
151 | + setOpen(true); | ||
152 | + }} | ||
153 | + > | ||
154 | + 编辑 | ||
155 | + </a> | ||
156 | + {/* <Divider type="vertical" /> | ||
157 | + <Popconfirm | ||
158 | + title={`确定删除【${record.name}】工作类型?`} | ||
159 | + onConfirm={() => delItem(record.id!)} | ||
160 | + > | ||
161 | + <a style={{ color: "#F0492C" }}>删除</a> | ||
162 | + </Popconfirm> */} | ||
163 | + </> | ||
164 | + )} | ||
165 | + /> | ||
166 | + </Table> | ||
167 | + <Modal | ||
168 | + title={`${current ? "编辑" : "添加"}工作类型`} | ||
169 | + open={open} | ||
170 | + maskClosable={false} | ||
171 | + onOk={form.submit} | ||
172 | + onCancel={() => setOpen(false)} | ||
173 | + afterClose={() => { | ||
174 | + setCurrent(undefined); | ||
175 | + }} | ||
176 | + confirmLoading={confirmLoading} | ||
177 | + > | ||
178 | + <Spin spinning={confirmLoading}> | ||
179 | + <Form form={form} onFinish={onOk}> | ||
180 | + <Form.Item | ||
181 | + name="name" | ||
182 | + label="工作类型" | ||
183 | + rules={[{ required: true, message: "请输入工作类型" }]} | ||
184 | + > | ||
185 | + <Input placeholder="请输入工作类型" allowClear /> | ||
186 | + </Form.Item> | ||
187 | + {systemDefine ? ( | ||
188 | + <> | ||
189 | + <Form.Item | ||
190 | + name="key" | ||
191 | + label="业务详情key" | ||
192 | + rules={[{ required: true, message: "请输入业务详情key" }]} | ||
193 | + > | ||
194 | + <Input placeholder="请输入业务详情key" allowClear /> | ||
195 | + </Form.Item> | ||
196 | + <Form.Item | ||
197 | + name="pageLink" | ||
198 | + label="业务详情APP路径" | ||
199 | + rules={[ | ||
200 | + { required: true, message: "请输入业务详情APP路径" }, | ||
201 | + ]} | ||
202 | + > | ||
203 | + <Input placeholder="请输入业务详情APP路径" allowClear /> | ||
204 | + </Form.Item> | ||
205 | + </> | ||
206 | + ) : null} | ||
207 | + </Form> | ||
208 | + </Spin> | ||
209 | + </Modal> | ||
110 | </Card> | 210 | </Card> |
111 | </ConfigProvider> | 211 | </ConfigProvider> |
112 | </PageHeaderWrapper> | 212 | </PageHeaderWrapper> |
113 | - ) | ||
114 | -} | ||
115 | \ No newline at end of file | 213 | \ No newline at end of file |
214 | + ); | ||
215 | +} |
src/pages/office/WorkTypeSetting/interface.d.ts
1 | /* | 1 | /* |
2 | * @Date: 2021-08-11 15:51:56 | 2 | * @Date: 2021-08-11 15:51:56 |
3 | * @LastEditors: wangqiang@feewee.cn | 3 | * @LastEditors: wangqiang@feewee.cn |
4 | - * @LastEditTime: 2021-10-08 10:07:01 | 4 | + * @LastEditTime: 2023-01-30 11:07:33 |
5 | */ | 5 | */ |
6 | declare namespace WorkTypeSetting { | 6 | declare namespace WorkTypeSetting { |
7 | interface QueryParams { | 7 | interface QueryParams { |
8 | - name?: string // 工作项名称 | 8 | + name?: string; // 工作项名称 |
9 | + systemDefine?: boolean; // 内部设置:true,外部设置:false | ||
9 | } | 10 | } |
10 | 11 | ||
11 | interface WorkTypeItemVO { | 12 | interface WorkTypeItemVO { |
12 | - id?: number //工作类型id | ||
13 | - name?: string //工作类型名称 | 13 | + id?: number; //工作类型id |
14 | + name?: string; //工作类型名称 | ||
15 | + key?: string; // 业务详情key | ||
16 | + pageLink?: string; // 业务详情路径 | ||
17 | + systemDefine?: boolean; // 内部设置:true,外部设置:false | ||
14 | } | 18 | } |
15 | } | 19 | } |