Commit c6d883b38e091aa72cac9b5473c8b7339900cf91

Authored by 赵凤
1 parent 8b4449ae

add 工作类型配置

config/routers/backlog.ts
... ... @@ -7,4 +7,9 @@ export default [
7 7 path: "./backlog/taskTime", // 待办时效
8 8 component: "./backlog/TaskTime",
9 9 },
  10 + /**工作类型配置 */
  11 + {
  12 + path: "./backlog/workConfig",
  13 + component: "./backlog/WorkTypeConfig",
  14 + },
10 15 ];
... ...
src/pages/backlog/TaskTime/index.tsx
... ... @@ -81,7 +81,6 @@ export default function TaskConfig() {
81 81 }}
82 82 />
83 83 <Column
84   - // title="待办延时时间"
85 84 title={
86 85 <Popover
87 86 placement="topLeft"
... ... @@ -93,7 +92,6 @@ export default function TaskConfig() {
93 92 }
94 93 >
95 94 <span>
96   - {" "}
97 95 待办延时时间&nbsp;&nbsp;
98 96 <ExclamationCircleFilled style={{ color: "#40a9ff" }} />
99 97 </span>
... ...
src/pages/backlog/WorkTypeConfig/api.ts 0 → 100644
  1 +/*
  2 + * @Date: 2021-12-29 15:35:12
  3 + * @LastEditors: wangqiang@feewee.cn
  4 + * @LastEditTime: 2022-01-05 17:53:12
  5 + */
  6 +import request from "@/utils/request";
  7 +import { common } from "@/typing/common";
  8 +import { BACKLOG } from "@/utils/host";
  9 +import { http } from "@/typing/http";
  10 +
  11 +interface ListParams extends common.PaginationParam {
  12 + keywords?: string;
  13 +}
  14 +
  15 +export interface Pramas {
  16 + name?: string;
  17 +}
  18 +/**
  19 + * 列表项
  20 + */
  21 +export interface ListVO {
  22 + id?: number; //ID
  23 + name?: string; // 名称
  24 + createTime?: string; //创建时间
  25 +}
  26 +
  27 +/**
  28 + * 工作类型列表
  29 + * @param name 类型名称
  30 + * @returns
  31 + */
  32 +export function getWorkTypeListApi(params: Pramas): http.PromisePageResp<ListVO> {
  33 + return request.get(`${BACKLOG}/work/type/list`, { params });
  34 +}
  35 +
  36 +export interface SaveParams {
  37 + /** 名称 */
  38 + name: string,
  39 + /** id */
  40 + id?: number
  41 +}
  42 +
  43 +/**
  44 + * 新增|编辑工作类
  45 + * work/type/save
  46 + * @param id
  47 + * @returns
  48 + */
  49 +export function saveWorkType(params: SaveParams) {
  50 + return request.post(`${BACKLOG}/work/type/save`, { ...params });
  51 +}
... ...
src/pages/backlog/WorkTypeConfig/components/CreateModal.tsx 0 → 100644
  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;
  11 +
  12 +interface Props {
  13 + visible: boolean;
  14 + onCancel: () => void;
  15 + onRefreshing: () => void;
  16 + item: ListVO;
  17 + /** 角色列表 */
  18 + // roleList: CommonApi.RoleCodeVO[],
  19 +}
  20 +export default function CreateModal({
  21 + visible,
  22 + onCancel,
  23 + item,
  24 + onRefreshing,
  25 +}: Props) {
  26 + const [form] = Form.useForm();
  27 + 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 +
  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]);
  65 +
  66 + function handleSave(feildValue: any) {
  67 + setSaveLoading(true);
  68 + console.log("表单数据:", feildValue);
  69 +
  70 + const params = {
  71 + ...feildValue,
  72 + name: (feildValue.name || "").trim(),
  73 + };
  74 + setSaveLoading(false);
  75 +
  76 + return;
  77 + saveWorkType(params)
  78 + .then((res) => {
  79 + message.success("操作成功!");
  80 + onRefreshing && onRefreshing();
  81 + setSaveLoading(false);
  82 + onCancel && onCancel();
  83 + })
  84 + .catch((e) => {
  85 + message.error(e.message);
  86 + setSaveLoading(false);
  87 + });
  88 + }
  89 +
  90 + return (
  91 + <Modal
  92 + visible={visible}
  93 + onCancel={onCancel}
  94 + onOk={form.submit}
  95 + title={`${item.name ? "编辑" : "新增"}工作类型`}
  96 + confirmLoading={saveLoading}
  97 + maskClosable={false}
  98 + >
  99 + <Form
  100 + form={form}
  101 + onFinish={handleSave}
  102 + wrapperCol={{ span: 18 }}
  103 + labelCol={{ span: 6 }}
  104 + >
  105 + <Form.Item
  106 + label="工作类型id"
  107 + name="id"
  108 + // rules={[{ required: true }]}
  109 + >
  110 + <InputNumber placeholder="请输入工作类型id" />
  111 + </Form.Item>
  112 + <Form.Item
  113 + label="工作类型名称"
  114 + name="name"
  115 + rules={[{ required: true }]}
  116 + >
  117 + <Input placeholder="请输入工作类型名称" />
  118 + </Form.Item>
  119 + </Form>
  120 + </Modal>
  121 + );
  122 +}
... ...
src/pages/backlog/WorkTypeConfig/components/PageParams.tsx 0 → 100644
  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 +}
0 54 \ No newline at end of file
... ...
src/pages/backlog/WorkTypeConfig/entity.ts 0 → 100644
  1 +export enum NotifyTypeEnum {
  2 + "app消息" = 1,
  3 + "短信" = 2,
  4 + "不通知" = 9
  5 +}
  6 +
  7 +export enum TodoTypeEnum {
  8 + "业务性" = 1,
  9 + "提示性" = 2,
  10 +}
0 11 \ No newline at end of file
... ...
src/pages/backlog/WorkTypeConfig/index.tsx 0 → 100644
  1 +import React, { useState, useEffect } from "react";
  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";
  13 +import { PlusOutlined } from "@ant-design/icons";
  14 +import usePagination from "@/hooks/usePagination";
  15 +import { ListVO, getWorkTypeListApi, taskEnableApi } from "./api";
  16 +import { TodoTypeEnum } from "./entity";
  17 +import moment from "moment";
  18 +import { debounce } from "lodash";
  19 +import CreateModal from "./components/CreateModal";
  20 +import { getAllRoleCodeApi } from "@/common/api";
  21 +import { systemListApi } from "@/pages/admin/Privilege/api";
  22 +
  23 +const Column = Table.Column;
  24 +const Search = Input.Search;
  25 +
  26 +export default function TaskConfig() {
  27 + const { list, loading, paginationConfig, setList, setParams, setLoading } =
  28 + usePagination<ListVO>(getWorkTypeListApi, {});
  29 + console.log("工作类型列表:", list);
  30 + 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 + });
  39 +
  40 + useEffect(() => {
  41 + getAllRoleCodeApi()
  42 + .then((res) => {})
  43 + .catch((e) => {
  44 + message.error(`获取角色列表失败:${e.message}`);
  45 + });
  46 + }, []);
  47 +
  48 + function triggerModal(row: ListVO = {}) {
  49 + setModalData({ visible: !modalData.visible, row });
  50 + }
  51 +
  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 + });
  76 + };
  77 +
  78 + // 删除待办
  79 + const handleDelete = (record: any) => {
  80 + taskDeleteApi(record.id)
  81 + .then((res) => {
  82 + message.success("删除成功!");
  83 + setLoading(true);
  84 + })
  85 + .catch((e) => {
  86 + setSwitchLoading(false);
  87 + message.error(e.message);
  88 + });
  89 + };
  90 +
  91 + //根据系统名称搜索
  92 + const _onChangeSys = debounce((e: any) => {
  93 + setParams({ sysId: e, current: 1 }, true);
  94 + }, 500);
  95 +
  96 + return (
  97 + <PageHeaderWrapper title="工作类型配置">
  98 + <Card>
  99 + <div
  100 + style={{
  101 + display: "flex",
  102 + flexDirection: "row",
  103 + justifyContent: "space-between",
  104 + alignItems: "center",
  105 + marginBottom: 20,
  106 + }}
  107 + >
  108 + <div style={{ display: "flex" }}>
  109 + <Search
  110 + allowClear
  111 + placeholder="输入工作类型名称"
  112 + onChange={(e) => _onChange(e.target.value)}
  113 + style={{ maxWidth: 260, marginRight: 15 }}
  114 + />
  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 + </div>
  128 + <Button
  129 + type="primary"
  130 + icon={<PlusOutlined />}
  131 + onClick={() => triggerModal()}
  132 + >
  133 + 新增
  134 + </Button>
  135 + </div>
  136 + <Table
  137 + loading={loading}
  138 + dataSource={list}
  139 + pagination={paginationConfig}
  140 + rowKey="itemCode"
  141 + >
  142 + <Column
  143 + title="工作类型"
  144 + dataIndex="name"
  145 + align="center"
  146 + />
  147 + <Column
  148 + title="创建时间"
  149 + dataIndex="createTime"
  150 + align="center"
  151 + render={(text) => moment(text).format("YYYY-MM-DD")}
  152 + />
  153 +
  154 + <Column
  155 + title="操作"
  156 + align="center"
  157 + render={(val, row: ListVO) => (
  158 + <>
  159 + <Button type="link" onClick={() => triggerModal(row)}>
  160 + 编辑
  161 + </Button>
  162 + <Popconfirm
  163 + placement="top"
  164 + title="确认删除?"
  165 + onConfirm={() => handleDelete(row)}
  166 + >
  167 + <Button type="link">删除</Button>
  168 + </Popconfirm>
  169 + </>
  170 + )}
  171 + />
  172 + </Table>
  173 + <CreateModal
  174 + visible={modalData.visible}
  175 + onCancel={triggerModal}
  176 + onRefreshing={() => setLoading(true)}
  177 + item={modalData.row}
  178 + />
  179 + </Card>
  180 + </PageHeaderWrapper>
  181 + );
  182 +}
... ...