Commit c4a486ae4838db47fc15c3e2c60e5a97d915e5e4
1 parent
c6d883b3
待办配置add工作类型字段
Showing
7 changed files
with
238 additions
and
235 deletions
src/pages/backlog/TaskConfig/api.ts
... | ... | @@ -50,6 +50,8 @@ export interface ListVO { |
50 | 50 | customTemp?: boolean; // 是否使用自定义模板 |
51 | 51 | customTempPath?: string; // 自定义模板路径 |
52 | 52 | closeStand?: boolean; // 是否关单站岗 |
53 | + /** 工作类型 */ | |
54 | + workType?:number; | |
53 | 55 | } |
54 | 56 | |
55 | 57 | export function getConfigListApi(params: ListParams): http.PromisePageResp<ListVO> { | ... | ... |
src/pages/backlog/TaskConfig/components/CreateModal.tsx
... | ... | @@ -14,6 +14,10 @@ interface Props { |
14 | 14 | onCancel: () => void; |
15 | 15 | onRefreshing: () => void; |
16 | 16 | item: ListVO; |
17 | + /** 系统列表 */ | |
18 | + systemList: any[]; | |
19 | + /** 工作类型列表 */ | |
20 | + workTyoeList: any[]; | |
17 | 21 | /** 角色列表 */ |
18 | 22 | // roleList: CommonApi.RoleCodeVO[], |
19 | 23 | } |
... | ... | @@ -22,13 +26,16 @@ export default function CreateModal({ |
22 | 26 | onCancel, |
23 | 27 | item, |
24 | 28 | onRefreshing, |
29 | + systemList, | |
30 | + workTyoeList, | |
25 | 31 | }: Props) { |
26 | 32 | const [form] = Form.useForm(); |
27 | 33 | const [saveLoading, setSaveLoading] = useState(false); |
28 | - const { list } = usePagination(systemListApi, { current: 1, pageSize: 100 }); | |
29 | 34 | const [value, setValue] = useState<ValueVO[]>([]); |
30 | 35 | |
31 | 36 | useEffect(() => { |
37 | + /** 编辑时,表单数据回显 */ | |
38 | + // if (visible && item.id) { | |
32 | 39 | if (visible) { |
33 | 40 | const prePageParam: { [key: string]: any } = JSON.parse( |
34 | 41 | item.pageParam || "{}" |
... | ... | @@ -53,6 +60,7 @@ export default function CreateModal({ |
53 | 60 | notifyType: item.notifyType || 1, |
54 | 61 | pageParam, |
55 | 62 | applySysId: item.applySysId, |
63 | + workType: item.workType, | |
56 | 64 | customTemp: item.customTemp, |
57 | 65 | customTempPath: item.customTempPath, |
58 | 66 | closeStand: checkNull(item.closeStand) ? true : item.closeStand, |
... | ... | @@ -109,6 +117,7 @@ export default function CreateModal({ |
109 | 117 | title={item.itemCode ? "编辑待办项" : "新增待办项"} |
110 | 118 | confirmLoading={saveLoading} |
111 | 119 | maskClosable={false} |
120 | + // afterClose={() => form.resetFields()} | |
112 | 121 | > |
113 | 122 | <Form |
114 | 123 | form={form} |
... | ... | @@ -180,7 +189,9 @@ export default function CreateModal({ |
180 | 189 | |
181 | 190 | <Form.Item |
182 | 191 | noStyle |
183 | - shouldUpdate={(pre, cur) => pre.dock !== cur.dock || pre.itemType !== cur.itemType} | |
192 | + shouldUpdate={(pre, cur) => | |
193 | + pre.dock !== cur.dock || pre.itemType !== cur.itemType | |
194 | + } | |
184 | 195 | > |
185 | 196 | {({ getFieldValue }) => { |
186 | 197 | const dock = getFieldValue("dock"); |
... | ... | @@ -207,9 +218,11 @@ export default function CreateModal({ |
207 | 218 | |
208 | 219 | <Form.Item |
209 | 220 | noStyle |
210 | - shouldUpdate={(pre, cur) => pre.customTemp !== cur.customTemp || | |
221 | + shouldUpdate={(pre, cur) => | |
222 | + pre.customTemp !== cur.customTemp || | |
211 | 223 | pre.dock !== cur.dock || |
212 | - pre.itemType !== cur.itemType} | |
224 | + pre.itemType !== cur.itemType | |
225 | + } | |
213 | 226 | > |
214 | 227 | {({ getFieldValue }) => { |
215 | 228 | const dock = getFieldValue("dock"); |
... | ... | @@ -242,9 +255,11 @@ export default function CreateModal({ |
242 | 255 | |
243 | 256 | <Form.Item |
244 | 257 | noStyle |
245 | - shouldUpdate={(pre, cur) => pre.dock !== cur.dock || | |
258 | + shouldUpdate={(pre, cur) => | |
259 | + pre.dock !== cur.dock || | |
246 | 260 | pre.itemType !== cur.itemType || |
247 | - pre.customTemp !== cur.customTemp} | |
261 | + pre.customTemp !== cur.customTemp | |
262 | + } | |
248 | 263 | > |
249 | 264 | {({ getFieldValue }) => { |
250 | 265 | const dock = getFieldValue("dock"); |
... | ... | @@ -322,7 +337,9 @@ export default function CreateModal({ |
322 | 337 | |
323 | 338 | <Form.Item |
324 | 339 | noStyle |
325 | - shouldUpdate={(pre, cur) => pre.itemType !== cur.itemType || pre.customTemp !== cur.customTemp} | |
340 | + shouldUpdate={(pre, cur) => | |
341 | + pre.itemType !== cur.itemType || pre.customTemp !== cur.customTemp | |
342 | + } | |
326 | 343 | > |
327 | 344 | {({ getFieldValue }) => { |
328 | 345 | const itemType = getFieldValue("itemType"); |
... | ... | @@ -364,7 +381,7 @@ export default function CreateModal({ |
364 | 381 | rules={[{ required: true, message: "适用系统不能为空" }]} |
365 | 382 | > |
366 | 383 | <Select placeholder="请选择"> |
367 | - {list.map((item) => ( | |
384 | + {systemList.map((item) => ( | |
368 | 385 | <Select.Option value={item.id} key={item.id}> |
369 | 386 | {item.sysName} |
370 | 387 | </Select.Option> |
... | ... | @@ -384,6 +401,19 @@ export default function CreateModal({ |
384 | 401 | ))} |
385 | 402 | </Radio.Group> |
386 | 403 | </Form.Item> |
404 | + <Form.Item | |
405 | + name="workType" | |
406 | + label="工作类型" | |
407 | + rules={[{ required: true, message: "工作类型不能为空" }]} | |
408 | + > | |
409 | + <Select placeholder="请选择"> | |
410 | + {workTyoeList.map((item) => ( | |
411 | + <Select.Option value={item.id} key={item.id}> | |
412 | + {item.name} | |
413 | + </Select.Option> | |
414 | + ))} | |
415 | + </Select> | |
416 | + </Form.Item> | |
387 | 417 | </Form> |
388 | 418 | </Modal> |
389 | 419 | ); | ... | ... |
src/pages/backlog/TaskConfig/index.tsx
1 | 1 | import React, { useState, useEffect } from "react"; |
2 | 2 | import { PageHeaderWrapper } from "@ant-design/pro-layout"; |
3 | -import { Card, Table, Popconfirm, Switch, message, Button, Input, Select } from "antd"; | |
3 | +import { | |
4 | + Card, | |
5 | + Table, | |
6 | + Popconfirm, | |
7 | + Switch, | |
8 | + message, | |
9 | + Button, | |
10 | + Input, | |
11 | + Select, | |
12 | +} from "antd"; | |
4 | 13 | import { PlusOutlined } from "@ant-design/icons"; |
5 | 14 | import usePagination from "@/hooks/usePagination"; |
6 | -import { ListVO, getConfigListApi, taskEnableApi, taskDeleteApi, taskDisableApi } from "./api"; | |
15 | +import { | |
16 | + ListVO, | |
17 | + getConfigListApi, | |
18 | + taskEnableApi, | |
19 | + taskDeleteApi, | |
20 | + taskDisableApi, | |
21 | +} from "./api"; | |
7 | 22 | import { TodoTypeEnum } from "./entity"; |
8 | 23 | import moment from "moment"; |
9 | 24 | import { debounce } from "lodash"; |
10 | 25 | import CreateModal from "./components/CreateModal"; |
11 | 26 | import { getAllRoleCodeApi } from "@/common/api"; |
12 | 27 | import { systemListApi } from "@/pages/admin/Privilege/api"; |
28 | +import { | |
29 | + getWorkTypeListApi, | |
30 | + WorkTypeListVO, | |
31 | +} from "@/pages/backlog/WorkTypeConfig/api"; | |
13 | 32 | |
14 | 33 | const Column = Table.Column; |
15 | 34 | const Search = Input.Search; |
16 | 35 | |
17 | 36 | export default function TaskConfig() { |
18 | - const { list, loading, paginationConfig, setList, setParams, setLoading } = usePagination<ListVO>( | |
19 | - getConfigListApi, | |
20 | - {}, | |
21 | - {} | |
22 | - ); | |
37 | + const { list, loading, paginationConfig, setList, setParams, setLoading } = | |
38 | + usePagination<ListVO>(getConfigListApi, {}, {}); | |
23 | 39 | const [switchLoading, setSwitchLoading] = useState(false); |
24 | - const [modalData, setModalData] = useState<{ visible: boolean; row: ListVO }>({ visible: false, row: {} }); | |
25 | - | |
26 | - const { list: syslist } = usePagination(systemListApi, { current: 1, pageSize: 100 }); | |
40 | + const [modalData, setModalData] = useState<{ visible: boolean; row: ListVO }>( | |
41 | + { visible: false, row: {} } | |
42 | + ); | |
43 | + /** | |
44 | + * 查询系统列表 | |
45 | + */ | |
46 | + const { list: syslist } = usePagination(systemListApi, { | |
47 | + current: 1, | |
48 | + pageSize: 100, | |
49 | + }); | |
27 | 50 | |
51 | + /** | |
52 | + * 查询工作类型列表 | |
53 | + */ | |
54 | + const { list: workTyoeList } = usePagination<WorkTypeListVO>( | |
55 | + getWorkTypeListApi, | |
56 | + {} | |
57 | + ); | |
28 | 58 | useEffect(() => { |
29 | 59 | getAllRoleCodeApi() |
30 | - .then((res) => { | |
31 | - }) | |
60 | + .then((res) => {}) | |
32 | 61 | .catch((e) => { |
33 | 62 | message.error(`获取角色列表失败:${e.message}`); |
34 | 63 | }); |
... | ... | @@ -78,9 +107,9 @@ export default function TaskConfig() { |
78 | 107 | }; |
79 | 108 | |
80 | 109 | //根据系统名称搜索 |
81 | - const _onChangeSys = debounce((e: any) => { | |
82 | - setParams({ sysId: e, current: 1 }, true); | |
83 | - }, 500); | |
110 | + const _onChangeSys = (value: any) => { | |
111 | + setParams({ ...value, current: 1 }, true); | |
112 | + }; | |
84 | 113 | |
85 | 114 | return ( |
86 | 115 | <PageHeaderWrapper title="待办配置"> |
... | ... | @@ -95,34 +124,109 @@ export default function TaskConfig() { |
95 | 124 | }} |
96 | 125 | > |
97 | 126 | <div style={{ display: "flex" }}> |
98 | - <Search allowClear placeholder="搜索待办名" onChange={(e) => _onChange(e.target.value)} style={{ maxWidth: 260, marginRight: 15 }} /> | |
99 | - <Select allowClear placeholder="搜索系统名称" style={{ width: 260, marginRight: 5 }} onChange={(e: any) => _onChangeSys(e)}> | |
127 | + <Search | |
128 | + allowClear | |
129 | + placeholder="搜索待办名" | |
130 | + onChange={(e) => _onChange(e.target.value)} | |
131 | + style={{ maxWidth: 260, marginRight: 15 }} | |
132 | + /> | |
133 | + <Select | |
134 | + allowClear | |
135 | + placeholder="选择归属系统" | |
136 | + style={{ width: 260, marginRight: 5 }} | |
137 | + onChange={(value: any) => _onChangeSys({ sysId: value })} | |
138 | + > | |
100 | 139 | {syslist.map((item) => ( |
101 | 140 | <Select.Option value={item.id!} key={item.id}> |
102 | 141 | {item.sysName} |
103 | 142 | </Select.Option> |
104 | 143 | ))} |
105 | 144 | </Select> |
145 | + <Select | |
146 | + allowClear | |
147 | + placeholder="选择工作类型" | |
148 | + style={{ width: 260, marginRight: 5 }} | |
149 | + onChange={(value: number) => _onChangeSys({ workType: value })} | |
150 | + > | |
151 | + {workTyoeList.map((item) => ( | |
152 | + <Select.Option value={item.id!} key={item.id}> | |
153 | + {item.name} | |
154 | + </Select.Option> | |
155 | + ))} | |
156 | + </Select> | |
106 | 157 | </div> |
107 | - <Button type="primary" icon={<PlusOutlined />} onClick={() => triggerModal()}> | |
158 | + <Button | |
159 | + type="primary" | |
160 | + icon={<PlusOutlined />} | |
161 | + onClick={() => triggerModal()} | |
162 | + > | |
108 | 163 | 新增配置 |
109 | 164 | </Button> |
110 | 165 | </div> |
111 | - <Table loading={loading} dataSource={list} pagination={paginationConfig} rowKey="itemCode"> | |
166 | + <Table | |
167 | + loading={loading} | |
168 | + dataSource={list} | |
169 | + pagination={paginationConfig} | |
170 | + rowKey="itemCode" | |
171 | + > | |
112 | 172 | <Column title="待办项" dataIndex="itemName" align="center" /> |
113 | 173 | <Column title="待办编码" dataIndex="itemCode" align="center" /> |
114 | - <Column title="类型" dataIndex="itemType" align="center" render={(t) => TodoTypeEnum[t]} /> | |
174 | + <Column | |
175 | + title="类型" | |
176 | + dataIndex="itemType" | |
177 | + align="center" | |
178 | + render={(t) => TodoTypeEnum[t]} | |
179 | + /> | |
115 | 180 | |
116 | - <Column title="对接新待办" dataIndex="dock" align="center" render={(text) => (String(text) === "true" ? "是" : "否")} /> | |
117 | - <Column title="待办时效考核" dataIndex="assess" align="center" render={(text) => (String(text) === "true" ? "是" : "否")} /> | |
118 | - <Column title="创建时间" dataIndex="createTime" align="center" render={(text) => moment(text).format("YYYY-MM-DD")} /> | |
181 | + <Column | |
182 | + title="对接新待办" | |
183 | + dataIndex="dock" | |
184 | + align="center" | |
185 | + render={(text) => (String(text) === "true" ? "是" : "否")} | |
186 | + /> | |
187 | + <Column | |
188 | + title="待办时效考核" | |
189 | + dataIndex="assess" | |
190 | + align="center" | |
191 | + render={(text) => (String(text) === "true" ? "是" : "否")} | |
192 | + /> | |
193 | + <Column | |
194 | + title="归属系统" | |
195 | + dataIndex="applySysName" | |
196 | + align="center" | |
197 | + render={(text) => <span>{text || "--"}</span>} | |
198 | + /> | |
199 | + <Column | |
200 | + title="工作类型" | |
201 | + dataIndex="workTypeName" | |
202 | + align="center" | |
203 | + render={(text) => <span>{text || "--"}</span>} | |
204 | + /> | |
205 | + <Column | |
206 | + title="创建时间" | |
207 | + dataIndex="createTime" | |
208 | + align="center" | |
209 | + render={(text) => moment(text).format("YYYY-MM-DD")} | |
210 | + /> | |
119 | 211 | <Column |
120 | 212 | title="状态" |
121 | 213 | align="center" |
122 | 214 | dataIndex="status" |
123 | 215 | render={(val, row: ListVO) => ( |
124 | - <Popconfirm placement="top" title={`确认${val ? "禁用" : "启用"}?`} onConfirm={() => handleChangeStatus(row)} onCancel={() => setSwitchLoading(false)}> | |
125 | - <Switch checkedChildren="启用" unCheckedChildren="禁用" checked={!!val} size="small" loading={switchLoading} onClick={() => setSwitchLoading(true)} /> | |
216 | + <Popconfirm | |
217 | + placement="top" | |
218 | + title={`确认${val ? "禁用" : "启用"}?`} | |
219 | + onConfirm={() => handleChangeStatus(row)} | |
220 | + onCancel={() => setSwitchLoading(false)} | |
221 | + > | |
222 | + <Switch | |
223 | + checkedChildren="启用" | |
224 | + unCheckedChildren="禁用" | |
225 | + checked={!!val} | |
226 | + size="small" | |
227 | + loading={switchLoading} | |
228 | + onClick={() => setSwitchLoading(true)} | |
229 | + /> | |
126 | 230 | </Popconfirm> |
127 | 231 | )} |
128 | 232 | /> |
... | ... | @@ -134,7 +238,11 @@ export default function TaskConfig() { |
134 | 238 | <Button type="link" onClick={() => triggerModal(row)}> |
135 | 239 | 编辑 |
136 | 240 | </Button> |
137 | - <Popconfirm placement="top" title="确认删除?" onConfirm={() => handleDelete(row)}> | |
241 | + <Popconfirm | |
242 | + placement="top" | |
243 | + title="确认删除?" | |
244 | + onConfirm={() => handleDelete(row)} | |
245 | + > | |
138 | 246 | <Button type="link">删除</Button> |
139 | 247 | </Popconfirm> |
140 | 248 | </> |
... | ... | @@ -146,6 +254,8 @@ export default function TaskConfig() { |
146 | 254 | onCancel={triggerModal} |
147 | 255 | onRefreshing={() => setLoading(true)} |
148 | 256 | item={modalData.row} |
257 | + systemList={syslist || []} | |
258 | + workTyoeList={workTyoeList||[]} | |
149 | 259 | /> |
150 | 260 | </Card> |
151 | 261 | </PageHeaderWrapper> | ... | ... |
src/pages/backlog/WorkTypeConfig/api.ts
... | ... | @@ -18,7 +18,7 @@ export interface Pramas { |
18 | 18 | /** |
19 | 19 | * 列表项 |
20 | 20 | */ |
21 | -export interface ListVO { | |
21 | +export interface WorkTypeListVO { | |
22 | 22 | id?: number; //ID |
23 | 23 | name?: string; // 名称 |
24 | 24 | createTime?: string; //创建时间 |
... | ... | @@ -29,15 +29,13 @@ export interface ListVO { |
29 | 29 | * @param name 类型名称 |
30 | 30 | * @returns |
31 | 31 | */ |
32 | -export function getWorkTypeListApi(params: Pramas): http.PromisePageResp<ListVO> { | |
32 | +export function getWorkTypeListApi(params: Pramas): http.PromisePageResp<WorkTypeListVO> { | |
33 | 33 | return request.get(`${BACKLOG}/work/type/list`, { params }); |
34 | 34 | } |
35 | 35 | |
36 | 36 | export interface SaveParams { |
37 | 37 | /** 名称 */ |
38 | 38 | name: string, |
39 | - /** id */ | |
40 | - id?: number | |
41 | 39 | } |
42 | 40 | |
43 | 41 | /** |
... | ... | @@ -49,3 +47,10 @@ export interface SaveParams { |
49 | 47 | export function saveWorkType(params: SaveParams) { |
50 | 48 | return request.post(`${BACKLOG}/work/type/save`, { ...params }); |
51 | 49 | } |
50 | + | |
51 | +/** | |
52 | + * 删除工作类型 | |
53 | + */ | |
54 | +export function deleteWorkTypeApi(id: number): http.PromisePageResp<null> { | |
55 | + return request.get(`${BACKLOG}/work/type/delete`, { params: { id } }); | |
56 | +} | ... | ... |
src/pages/backlog/WorkTypeConfig/components/CreateModal.tsx
1 | 1 | import React, { useEffect, useState } from "react"; |
2 | -import { Modal, Form, Input, Radio, message, InputNumber } from "antd"; | |
3 | -import { ListVO, saveWorkType } from "../api"; | |
4 | -import { NotifyTypeEnum, TodoTypeEnum } from "../entity"; | |
5 | -import PageParams, { ValueVO } from "./PageParams"; | |
6 | -import { systemListApi } from "@/pages/admin/Privilege/api"; | |
7 | -import usePagination from "@/hooks/usePagination"; | |
8 | -import { checkNull } from "@/utils/validate"; | |
9 | - | |
10 | -const { TextArea } = Input; | |
2 | +import { Modal, Form, Input, message } from "antd"; | |
3 | +import { WorkTypeListVO, saveWorkType } from "../api"; | |
11 | 4 | |
12 | 5 | interface Props { |
13 | 6 | visible: boolean; |
14 | 7 | onCancel: () => void; |
15 | 8 | onRefreshing: () => void; |
16 | - item: ListVO; | |
17 | - /** 角色列表 */ | |
18 | - // roleList: CommonApi.RoleCodeVO[], | |
9 | + item: WorkTypeListVO; | |
19 | 10 | } |
20 | 11 | export default function CreateModal({ |
21 | 12 | visible, |
... | ... | @@ -25,66 +16,33 @@ export default function CreateModal({ |
25 | 16 | }: Props) { |
26 | 17 | const [form] = Form.useForm(); |
27 | 18 | const [saveLoading, setSaveLoading] = useState(false); |
28 | - const { list } = usePagination(systemListApi, { current: 1, pageSize: 100 }); | |
29 | - const [value, setValue] = useState<ValueVO[]>([]); | |
30 | - | |
31 | - // useEffect(() => { | |
32 | - // if (visible) { | |
33 | - // const prePageParam: { [key: string]: any } = JSON.parse( | |
34 | - // item.pageParam || "{}" | |
35 | - // ); | |
36 | - // let pageParam: ValueVO[] = [{ key: "", value: "" }]; | |
37 | - // for (let [key, value] of Object.entries(prePageParam)) { | |
38 | - // pageParam.unshift({ key, value }); | |
39 | - // } | |
40 | - // setValue(pageParam); | |
41 | 19 | |
42 | - // form.setFieldsValue({ | |
43 | - // ...item, | |
44 | - // funcPage: item.funcPage, | |
45 | - // itemName: item.itemName, | |
46 | - // dock: item.dock, | |
47 | - // exShow: item.exShow, | |
48 | - // assess: item.assess, | |
49 | - // itemType: item.itemType || TodoTypeEnum["业务性"], | |
50 | - // listPage: item.listPage, | |
51 | - // detailPage: item.detailPage, | |
52 | - // dynamicTemp: item.dynamicTemp, | |
53 | - // notifyType: item.notifyType || 1, | |
54 | - // pageParam, | |
55 | - // applySysId: item.applySysId, | |
56 | - // customTemp: item.customTemp, | |
57 | - // customTempPath: item.customTempPath, | |
58 | - // closeStand: checkNull(item.closeStand) ? true : item.closeStand, | |
59 | - // }); | |
60 | - // } | |
61 | - // if (!visible) { | |
62 | - // setSaveLoading(false); | |
63 | - // } | |
64 | - // }, [visible]); | |
20 | + useEffect(() => { | |
21 | + if (visible) { | |
22 | + form.setFieldsValue({ | |
23 | + ...item, | |
24 | + }); | |
25 | + } | |
26 | + }, [visible]); | |
65 | 27 | |
66 | 28 | function handleSave(feildValue: any) { |
67 | 29 | setSaveLoading(true); |
68 | - console.log("表单数据:", feildValue); | |
69 | - | |
70 | 30 | const params = { |
71 | 31 | ...feildValue, |
32 | + id: item.id, | |
72 | 33 | name: (feildValue.name || "").trim(), |
73 | 34 | }; |
74 | - setSaveLoading(false); | |
75 | 35 | |
76 | - return; | |
36 | + setSaveLoading(false); | |
77 | 37 | saveWorkType(params) |
78 | 38 | .then((res) => { |
79 | - message.success("操作成功!"); | |
80 | - onRefreshing && onRefreshing(); | |
81 | - setSaveLoading(false); | |
39 | + message.success("保存成功!"); | |
82 | 40 | onCancel && onCancel(); |
83 | 41 | }) |
84 | 42 | .catch((e) => { |
85 | 43 | message.error(e.message); |
86 | - setSaveLoading(false); | |
87 | - }); | |
44 | + }) | |
45 | + .finally(() => setSaveLoading(false)); | |
88 | 46 | } |
89 | 47 | |
90 | 48 | return ( |
... | ... | @@ -95,6 +53,9 @@ export default function CreateModal({ |
95 | 53 | title={`${item.name ? "编辑" : "新增"}工作类型`} |
96 | 54 | confirmLoading={saveLoading} |
97 | 55 | maskClosable={false} |
56 | + afterClose={() => { | |
57 | + form.resetFields(); | |
58 | + }} | |
98 | 59 | > |
99 | 60 | <Form |
100 | 61 | form={form} |
... | ... | @@ -103,13 +64,6 @@ export default function CreateModal({ |
103 | 64 | labelCol={{ span: 6 }} |
104 | 65 | > |
105 | 66 | <Form.Item |
106 | - label="工作类型id" | |
107 | - name="id" | |
108 | - // rules={[{ required: true }]} | |
109 | - > | |
110 | - <InputNumber placeholder="请输入工作类型id" /> | |
111 | - </Form.Item> | |
112 | - <Form.Item | |
113 | 67 | label="工作类型名称" |
114 | 68 | name="name" |
115 | 69 | rules={[{ required: true }]} | ... | ... |
src/pages/backlog/WorkTypeConfig/components/PageParams.tsx deleted
1 | -import React from 'react'; | |
2 | -import { Input, Card, Button } from 'antd'; | |
3 | -import { PlusOutlined, DeleteOutlined } from '@ant-design/icons'; | |
4 | - | |
5 | -export interface ValueVO { | |
6 | - key: string, | |
7 | - value: string | |
8 | -} | |
9 | - | |
10 | -interface Props { | |
11 | - value?: ValueVO[], | |
12 | - onChange?: (value: ValueVO[]) => any | |
13 | -} | |
14 | - | |
15 | -export default function PageParams({ value = [{ key: "", value: "" }], onChange }: Props) { | |
16 | - function changeLabel(key1: string, i: number) { | |
17 | - value[i].key = key1; | |
18 | - onChange && onChange([...value]); | |
19 | - } | |
20 | - | |
21 | - function changeValue(key2: string, i: number) { | |
22 | - value[i].value = key2; | |
23 | - onChange && onChange([...value]); | |
24 | - } | |
25 | - | |
26 | - function addValue() { | |
27 | - value.push({ key: "", value: "" }); | |
28 | - onChange && onChange([...value]); | |
29 | - } | |
30 | - | |
31 | - function deleteValue(i: number) { | |
32 | - value.splice(i, 1); | |
33 | - onChange && onChange([...value]); | |
34 | - } | |
35 | - | |
36 | - return ( | |
37 | - <Card | |
38 | - extra={ | |
39 | - <div style={{ flex: 1, display: 'flex', justifyContent: "space-between", flexDirection: 'row' }}> | |
40 | - <Button type="primary" icon={<PlusOutlined />} onClick={addValue}>新增</Button> | |
41 | - </div>} | |
42 | - > | |
43 | - {value.map((v, i) => ( | |
44 | - <div key={`key_${i}`} style={{ flex: 1, display: 'flex', justifyContent: "space-between", alignItems: "center", flexDirection: 'row', marginBottom: 5 }}> | |
45 | - <Input value={v.key} placeholder="key" onChange={(e) => changeLabel(e.target.value, i)} /> | |
46 | - <span style={{ marginLeft: 5, marginRight: 5 }}> : </span> | |
47 | - <Input value={v.value} placeholder="value" onChange={(e) => changeValue(e.target.value, i)} /> | |
48 | - <DeleteOutlined color="#FF0000" style={{ color: "#FF0000", fontSize: 14, marginLeft: 10 }} onClick={() => deleteValue(i)} /> | |
49 | - </div> | |
50 | - ))} | |
51 | - </Card> | |
52 | - ) | |
53 | -} | |
54 | 0 | \ No newline at end of file |
src/pages/backlog/WorkTypeConfig/index.tsx
1 | 1 | import React, { useState, useEffect } from "react"; |
2 | 2 | import { PageHeaderWrapper } from "@ant-design/pro-layout"; |
3 | -import { | |
4 | - Card, | |
5 | - Table, | |
6 | - Popconfirm, | |
7 | - Switch, | |
8 | - message, | |
9 | - Button, | |
10 | - Input, | |
11 | - Select, | |
12 | -} from "antd"; | |
3 | +import { Card, Table, Popconfirm, message, Button, Input } from "antd"; | |
13 | 4 | import { PlusOutlined } from "@ant-design/icons"; |
14 | 5 | import usePagination from "@/hooks/usePagination"; |
15 | -import { ListVO, getWorkTypeListApi, taskEnableApi } from "./api"; | |
16 | -import { TodoTypeEnum } from "./entity"; | |
6 | +import { WorkTypeListVO, getWorkTypeListApi, deleteWorkTypeApi } from "./api"; | |
17 | 7 | import moment from "moment"; |
18 | 8 | import { debounce } from "lodash"; |
19 | 9 | import CreateModal from "./components/CreateModal"; |
20 | 10 | import { getAllRoleCodeApi } from "@/common/api"; |
21 | -import { systemListApi } from "@/pages/admin/Privilege/api"; | |
22 | 11 | |
23 | 12 | const Column = Table.Column; |
24 | 13 | const Search = Input.Search; |
25 | 14 | |
26 | 15 | export default function TaskConfig() { |
27 | - const { list, loading, paginationConfig, setList, setParams, setLoading } = | |
28 | - usePagination<ListVO>(getWorkTypeListApi, {}); | |
29 | - console.log("工作类型列表:", list); | |
16 | + const { list, loading, paginationConfig, setParams, setLoading } = | |
17 | + usePagination<WorkTypeListVO>(getWorkTypeListApi, {}); | |
30 | 18 | const [switchLoading, setSwitchLoading] = useState(false); |
31 | - const [modalData, setModalData] = useState<{ visible: boolean; row: ListVO }>( | |
32 | - { visible: false, row: {} } | |
33 | - ); | |
34 | - | |
35 | - const { list: syslist } = usePagination(systemListApi, { | |
36 | - current: 1, | |
37 | - pageSize: 100, | |
38 | - }); | |
19 | + const [modalData, setModalData] = useState<{ | |
20 | + visible: boolean; | |
21 | + row: WorkTypeListVO; | |
22 | + }>({ visible: false, row: {} }); | |
39 | 23 | |
40 | 24 | useEffect(() => { |
41 | 25 | getAllRoleCodeApi() |
... | ... | @@ -45,54 +29,41 @@ export default function TaskConfig() { |
45 | 29 | }); |
46 | 30 | }, []); |
47 | 31 | |
48 | - function triggerModal(row: ListVO = {}) { | |
32 | + function triggerModal(row: WorkTypeListVO = {}) { | |
49 | 33 | setModalData({ visible: !modalData.visible, row }); |
50 | 34 | } |
51 | 35 | |
52 | - const _onChange = debounce((val: string) => { | |
53 | - setParams({ keywords: val.trim(), current: 1 }, true); | |
54 | - }, 500); | |
55 | - | |
56 | - // 禁用或启用待办 | |
57 | - const handleChangeStatus = (record: ListVO) => { | |
58 | - const API = record.status ? taskDisableApi : taskEnableApi; | |
59 | - record.id && | |
60 | - API(record.id) | |
61 | - .then((res) => { | |
62 | - setSwitchLoading(false); | |
63 | - message.success(record.status ? "禁用成功" : "启用成功"); | |
64 | - const tempList = list.map((item: ListVO) => { | |
65 | - if (item.id == record.id) { | |
66 | - return { ...item, status: record.status == 0 ? 1 : 0 }; | |
67 | - } | |
68 | - return item; | |
69 | - }); | |
70 | - setList(tempList); | |
71 | - }) | |
72 | - .catch((e) => { | |
73 | - setSwitchLoading(false); | |
74 | - message.error(e.message); | |
75 | - }); | |
36 | + /** | |
37 | + * 关闭弹窗 | |
38 | + */ | |
39 | + const _onCancelModal = () => { | |
40 | + setModalData({ visible: false, row: {} }); | |
41 | + // onRefreshing && onRefreshing(); | |
42 | + setLoading(true); | |
76 | 43 | }; |
77 | 44 | |
78 | - // 删除待办 | |
45 | + /** | |
46 | + * 根据工作类型名称搜索 | |
47 | + */ | |
48 | + const _searchByName = debounce((val: string) => { | |
49 | + setParams({ name: val.trim(), current: 1 }, true); | |
50 | + }, 500); | |
51 | + | |
52 | + // 删除工作类型 | |
79 | 53 | const handleDelete = (record: any) => { |
80 | - taskDeleteApi(record.id) | |
54 | + setSwitchLoading(true); | |
55 | + deleteWorkTypeApi(record.id) | |
81 | 56 | .then((res) => { |
82 | 57 | message.success("删除成功!"); |
83 | 58 | setLoading(true); |
84 | 59 | }) |
85 | 60 | .catch((e) => { |
86 | - setSwitchLoading(false); | |
61 | + // setSwitchLoading(false); | |
87 | 62 | message.error(e.message); |
88 | - }); | |
63 | + }) | |
64 | + .finally(() => setSwitchLoading(false)); | |
89 | 65 | }; |
90 | 66 | |
91 | - //根据系统名称搜索 | |
92 | - const _onChangeSys = debounce((e: any) => { | |
93 | - setParams({ sysId: e, current: 1 }, true); | |
94 | - }, 500); | |
95 | - | |
96 | 67 | return ( |
97 | 68 | <PageHeaderWrapper title="工作类型配置"> |
98 | 69 | <Card> |
... | ... | @@ -109,21 +80,9 @@ export default function TaskConfig() { |
109 | 80 | <Search |
110 | 81 | allowClear |
111 | 82 | placeholder="输入工作类型名称" |
112 | - onChange={(e) => _onChange(e.target.value)} | |
83 | + onChange={(e) => _searchByName(e.target.value)} | |
113 | 84 | style={{ maxWidth: 260, marginRight: 15 }} |
114 | 85 | /> |
115 | - {/* <Select | |
116 | - allowClear | |
117 | - placeholder="搜索系统名称" | |
118 | - style={{ width: 260, marginRight: 5 }} | |
119 | - onChange={(e: any) => _onChangeSys(e)} | |
120 | - > | |
121 | - {syslist.map((item) => ( | |
122 | - <Select.Option value={item.id!} key={item.id}> | |
123 | - {item.sysName} | |
124 | - </Select.Option> | |
125 | - ))} | |
126 | - </Select> */} | |
127 | 86 | </div> |
128 | 87 | <Button |
129 | 88 | type="primary" |
... | ... | @@ -134,23 +93,19 @@ export default function TaskConfig() { |
134 | 93 | </Button> |
135 | 94 | </div> |
136 | 95 | <Table |
137 | - loading={loading} | |
96 | + loading={loading || switchLoading} | |
138 | 97 | dataSource={list} |
139 | 98 | pagination={paginationConfig} |
140 | - rowKey="itemCode" | |
99 | + rowKey={(record) => `id${record.id}`} | |
141 | 100 | > |
142 | - <Column | |
143 | - title="工作类型" | |
144 | - dataIndex="name" | |
145 | - align="center" | |
146 | - /> | |
101 | + <Column title="工作类型" dataIndex="name" align="center" /> | |
147 | 102 | <Column |
148 | 103 | title="创建时间" |
149 | 104 | dataIndex="createTime" |
150 | 105 | align="center" |
151 | 106 | render={(text) => moment(text).format("YYYY-MM-DD")} |
152 | 107 | /> |
153 | - | |
108 | + | |
154 | 109 | <Column |
155 | 110 | title="操作" |
156 | 111 | align="center" |
... | ... | @@ -172,7 +127,7 @@ export default function TaskConfig() { |
172 | 127 | </Table> |
173 | 128 | <CreateModal |
174 | 129 | visible={modalData.visible} |
175 | - onCancel={triggerModal} | |
130 | + onCancel={_onCancelModal} | |
176 | 131 | onRefreshing={() => setLoading(true)} |
177 | 132 | item={modalData.row} |
178 | 133 | /> | ... | ... |