From 3f6ecf02965d505106cc56f5c65e1c6357678045 Mon Sep 17 00:00:00 2001 From: 王强 Date: Mon, 30 Jan 2023 11:23:09 +0800 Subject: [PATCH] 添加 工作类型设置(内部),并对接接口; --- config/routers/office.ts | 26 +++++++++++++++----------- src/pages/office/WorkTypeSetting/api.ts | 24 +++++++++++++++--------- src/pages/office/WorkTypeSetting/index.tsx | 284 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------------------------------------------- src/pages/office/WorkTypeSetting/interface.d.ts | 12 ++++++++---- 4 files changed, 230 insertions(+), 116 deletions(-) diff --git a/config/routers/office.ts b/config/routers/office.ts index 7fbfc7c..75549c8 100644 --- a/config/routers/office.ts +++ b/config/routers/office.ts @@ -1,28 +1,32 @@ /* * @Date: 2021-08-10 09:51:37 * @LastEditors: wangqiang@feewee.cn - * @LastEditTime: 2021-10-12 14:36:13 + * @LastEditTime: 2023-01-30 10:41:51 */ export default [ /** 会议办公 **/ { - path: '/office/workStandardSetting', // 工作项标准配置 - component: './office/Work/WorkStandardSetting' + path: "/office/workStandardSetting", // 工作项标准配置 + component: "./office/Work/WorkStandardSetting", }, { - path: '/office/workShopStandardSetting', // 门店工作项匹配标准设置 - component: './office/Work/WorkShopStandardSetting' + path: "/office/workShopStandardSetting", // 门店工作项匹配标准设置 + component: "./office/Work/WorkShopStandardSetting", }, { - path: '/office/punishmentMattersSettings', // 处罚事项设置 - component: './office/PunishmentMattersSettings' + path: "/office/punishmentMattersSettings", // 处罚事项设置 + component: "./office/PunishmentMattersSettings", }, { - path: '/office/rewardAmountSetting', // 奖励额度设置 - component: './office/RewardAmountSetting' + path: "/office/rewardAmountSetting", // 奖励额度设置 + component: "./office/RewardAmountSetting", }, { - path: '/office/workTypeSetting', // 工作类型设置 - component: './office/WorkTypeSetting' + path: "/office/workTypeSetting", // 工作类型设置 + component: "./office/WorkTypeSetting", + }, + { + path: "/office/workTypeSetting_private", // 工作类型设置(内部) + component: "./office/WorkTypeSetting", }, ]; \ No newline at end of file diff --git a/src/pages/office/WorkTypeSetting/api.ts b/src/pages/office/WorkTypeSetting/api.ts index 1d05939..6acbb8e 100644 --- a/src/pages/office/WorkTypeSetting/api.ts +++ b/src/pages/office/WorkTypeSetting/api.ts @@ -1,19 +1,21 @@ /* * @Date: 2021-03-23 17:48:39 * @LastEditors: wangqiang@feewee.cn - * @LastEditTime: 2021-10-08 10:06:58 + * @LastEditTime: 2023-01-30 10:47:34 */ -import request from '@/utils/request'; -import { OFFICE } from '@/utils/host'; -import { http } from '@/typing/http'; +import request from "@/utils/request"; +import { OFFICE } from "@/utils/host"; +import { http } from "@/typing/http"; /** * @description: 工作类型分页 * @param {WorkTypeSetting.QueryParams} params * @return {http.PromisePageResp} */ -export function getWorkTypeListApi(params: WorkTypeSetting.QueryParams): http.PromisePageResp { - return request.get(`${OFFICE}/erp/work/config//type/page`, { params }); +export function getWorkTypeListApi( + params: WorkTypeSetting.QueryParams +): http.PromisePageResp { + return request.get(`${OFFICE}/erp/work/config/type/page`, { params }); } /** @@ -21,7 +23,9 @@ export function getWorkTypeListApi(params: WorkTypeSetting.QueryParams): http.Pr * @param {WorkTypeSetting.WorkTypeItemVO} params * @return {http.PromiseResp} */ -export function saveWorkTypeApi(params: WorkTypeSetting.WorkTypeItemVO): http.PromiseResp { +export function saveWorkTypeApi( + params: WorkTypeSetting.WorkTypeItemVO +): http.PromiseResp { return request.post(`${OFFICE}/erp/work/config//type/save`, params); } @@ -31,5 +35,7 @@ export function saveWorkTypeApi(params: WorkTypeSetting.WorkTypeItemVO): http.Pr * @return {http.PromiseResp} */ export function deleteWorkTypeApi(id: number): http.PromiseResp { - return request.get(`${OFFICE}/erp/work/config//type/remove`, { params: { id } }); -} \ No newline at end of file + return request.get(`${OFFICE}/erp/work/config//type/remove`, { + params: { id }, + }); +} diff --git a/src/pages/office/WorkTypeSetting/index.tsx b/src/pages/office/WorkTypeSetting/index.tsx index e7c736b..4ab6247 100644 --- a/src/pages/office/WorkTypeSetting/index.tsx +++ b/src/pages/office/WorkTypeSetting/index.tsx @@ -1,114 +1,214 @@ /* * @Date: 2021-03-23 17:47:45 * @LastEditors: wangqiang@feewee.cn - * @LastEditTime: 2021-10-08 10:17:36 + * @LastEditTime: 2023-01-30 11:19:10 */ -import React, { useEffect, useState } from 'react'; -import { Modal, List, Button, Row, Col, Input, Popconfirm, message, Card, ConfigProvider } from 'antd'; -import { PlusOutlined, CloseOutlined, DatabaseOutlined, PlusCircleOutlined, EditOutlined, CheckCircleOutlined, CloseCircleOutlined, DeleteOutlined } from '@ant-design/icons'; -import { getWorkTypeListApi, saveWorkTypeApi, deleteWorkTypeApi } from './api'; -import { debounce } from 'lodash'; -import usePagination from '@/hooks/usePagination'; -import { PageHeaderWrapper } from '@ant-design/pro-layout'; -import zhCN from 'antd/lib/locale-provider/zh_CN'; +import React, { useEffect, useState } from "react"; +import { + Modal, + Button, + Row, + Input, + Popconfirm, + message, + Card, + ConfigProvider, + Table, + Divider, + Form, + Spin, +} from "antd"; +import { PlusOutlined } from "@ant-design/icons"; +import { getWorkTypeListApi, saveWorkTypeApi, deleteWorkTypeApi } from "./api"; +import { debounce } from "lodash"; +import usePagination from "@/hooks/usePagination"; +import { PageHeaderWrapper } from "@ant-design/pro-layout"; +import zhCN from "antd/lib/locale-provider/zh_CN"; +import { history } from "umi"; +import FeeweeFilterOption from "@/pages/notice/components/FeeweeFilterOption"; export default function WorkTypeSettings() { - const examTypePagination = usePagination(getWorkTypeListApi); - const { list, loading, setLoading, paginationConfig, setParams: setExamTypeParams } = examTypePagination; - const [isAdd, setIsAdd] = useState(false); - const [addInputValue, setAddInputValue] = useState(); - const [edit, setEdit] = useState<{ id?: number, value?: string }>(); + const systemDefine = history.location.pathname.includes( + "workTypeSetting_private" + ); + const workTypePagination = usePagination(getWorkTypeListApi, { + systemDefine, + }); + const { + list, + loading, + setLoading, + paginationConfig, + setParams: setExamTypeParams, + } = workTypePagination; + const [form] = Form.useForm(); + const [confirmLoading, setConfirmLoading] = useState(false); + const [current, setCurrent] = useState(); + const [open, setOpen] = useState(false); - const editItem = (): any => { - if (!edit?.value || (edit?.value && !edit?.value.trim())) return message.error('工作类型不能为空!'); - saveWorkTypeApi({ id: edit?.id, name: edit?.value }).then(res => { - message.success('操作成功'); - setLoading(true); - setEdit(undefined); - }).catch(error => { - message.error(error.message); - }); - } + useEffect(() => { + if (open) { + current && + form.setFieldsValue({ + ...current, + }); + } else { + form.resetFields(); + } + }, [open, current]); const delItem = (id: number) => { - deleteWorkTypeApi(id).then(res => { - message.success('删除成功'); - setLoading(true); - }).catch(error => message.error(error.message)); - } + deleteWorkTypeApi(id) + .then((res) => { + message.success("删除成功"); + setLoading(true); + }) + .catch((error) => message.error(error.message)); + }; - const addOption = (): any => { - if (!addInputValue || (addInputValue && !addInputValue.trim())) return message.error('工作类型不能为空!'); - saveWorkTypeApi({ name: addInputValue }).then(res => { - message.success('操作成功'); - setAddInputValue(undefined); - setLoading(true); - }).catch(error => { - message.error(error.message); - }); - } + const onSearch = debounce( + (name: string) => setExamTypeParams({ name, current: 1 }, true), + 500 + ); - const renderItem = (item: ExamSetting.TypeItem) => - - setEdit({ ...edit, value: e.target.value })} - onClick={() => setEdit({ id: item.id, value: item.name })} - suffix={edit && edit.id === item.id ? - editItem()}> - + + onSearch(e.target.value)} + /> + + - renderItem(item)} - /> - - - - - - {isAdd && setAddInputValue(e.target.value)} - suffix={ - addOption()}> -