Browse Source

feat(notice): fix lint error

lind 3 years ago
parent
commit
7e57a5e961

+ 12 - 9
src/components/FBraftEditor/index.tsx

@@ -1,15 +1,17 @@
-import {connect, mapProps} from '@formily/react';
-import BraftEditor, {BraftEditorProps, EditorState} from 'braft-editor';
+import { connect, mapProps } from '@formily/react';
+import BraftEditor, { BraftEditorProps, EditorState } from 'braft-editor';
 import 'braft-editor/dist/index.css';
-import {useState} from "react";
+import { useState } from 'react';
 
 interface Props extends BraftEditorProps {
-  value: any
-  onChange: (data: any) => void
+  value: any;
+  onChange: (data: any) => void;
 }
 
 const FBraftEditor = connect((props: Props) => {
-  const [editorState, setEditorState] = useState<EditorState>(BraftEditor.createEditorState(props.value));
+  const [editorState, setEditorState] = useState<EditorState>(
+    BraftEditor.createEditorState(props.value),
+  );
 
   return (
     <>
@@ -19,10 +21,11 @@ const FBraftEditor = connect((props: Props) => {
           value={editorState}
           onChange={(state) => {
             setEditorState(state);
-            props.onChange(state.toHTML())
+            props.onChange(state.toHTML());
           }}
-        />}
+        />
+      }
     </>
-  )
+  );
 }, mapProps());
 export default FBraftEditor;

+ 19 - 18
src/components/Upload/index.tsx

@@ -1,12 +1,12 @@
-import {LoadingOutlined, PlusOutlined, UploadOutlined} from '@ant-design/icons';
+import { LoadingOutlined, PlusOutlined, UploadOutlined } from '@ant-design/icons';
 import SystemConst from '@/utils/const';
 import Token from '@/utils/token';
-import type {ReactNode} from 'react';
-import {useState} from 'react';
-import {connect} from '@formily/react';
-import {Input, Upload} from 'antd';
-import type {UploadChangeParam} from 'antd/lib/upload/interface';
-import type {UploadListType} from 'antd/es/upload/interface';
+import type { ReactNode } from 'react';
+import { useState } from 'react';
+import { connect } from '@formily/react';
+import { Input, Upload } from 'antd';
+import type { UploadChangeParam } from 'antd/lib/upload/interface';
+import type { UploadListType } from 'antd/es/upload/interface';
 import './index.less';
 
 interface Props {
@@ -14,7 +14,7 @@ interface Props {
   onChange: (value: string | FileProperty | any) => void;
   type?: 'file' | 'image';
   placeholder: string;
-  display?: string
+  display?: string;
 }
 
 type FileProperty = {
@@ -36,27 +36,29 @@ const FUpload = connect((props: Props) => {
       const f = {
         size: info.file.size || 0,
         url: info.file.response?.result,
-        name: info.file.name
+        name: info.file.name,
       };
       setUrl(f);
       props.onChange(f);
     }
   };
 
-  const map = new Map<string,
+  const map = new Map<
+    string,
     {
       node: ReactNode;
       type: UploadListType;
-    }>();
+    }
+  >();
   map.set('image', {
     node: (
       <>
         {url ? (
-          <img src={url as string} alt="avatar" style={{width: '100%'}}/>
+          <img src={url as string} alt="avatar" style={{ width: '100%' }} />
         ) : (
           <div>
-            {loading ? <LoadingOutlined/> : <PlusOutlined/>}
-            <div style={{marginTop: 8}}>选择图片</div>
+            {loading ? <LoadingOutlined /> : <PlusOutlined />}
+            <div style={{ marginTop: 8 }}>选择图片</div>
           </div>
         )}
       </>
@@ -71,15 +73,14 @@ const FUpload = connect((props: Props) => {
           placeholder={props.placeholder}
           // 如果display 有值的话,显示display 的值
           value={(url as FileProperty)[props?.display || 'url']}
-          onChange={value => {
-            // @ts-ignore
-            props.display && props.onChange({[props?.display]: value.target.value, url: null, size: null})
+          onChange={(value) => {
+            props.onChange({ [props?.display || '_a']: value.target.value, url: null, size: null });
           }}
           onClick={(e) => {
             e.preventDefault();
             e.stopPropagation();
           }}
-          addonAfter={<UploadOutlined/>}
+          addonAfter={<UploadOutlined />}
         />
       </>
     ),

+ 53 - 36
src/pages/notice/Config/Debug/index.tsx

@@ -1,14 +1,23 @@
-import {message, Modal} from 'antd';
-import {useMemo} from 'react';
-import {createForm, Field, onFieldReact, onFieldValueChange} from '@formily/core';
-import {createSchemaField, observer} from '@formily/react';
-import {ArrayTable, DatePicker, Form, FormItem, Input, NumberPicker, PreviewText, Select} from '@formily/antd';
-import {ISchema} from '@formily/json-schema';
-import {service, state} from '@/pages/notice/Config';
-import {useLocation} from 'umi';
-import {useAsyncDataSource} from '@/utils/util';
-import {Store} from 'jetlinks-store';
-import FUpload from "@/components/Upload";
+import { message, Modal } from 'antd';
+import { useMemo } from 'react';
+import { createForm, Field, onFieldReact, onFieldValueChange } from '@formily/core';
+import { createSchemaField, observer } from '@formily/react';
+import {
+  ArrayTable,
+  DatePicker,
+  Form,
+  FormItem,
+  Input,
+  NumberPicker,
+  PreviewText,
+  Select,
+} from '@formily/antd';
+import { ISchema } from '@formily/json-schema';
+import { service, state } from '@/pages/notice/Config';
+import { useLocation } from 'umi';
+import { useAsyncDataSource } from '@/utils/util';
+import { Store } from 'jetlinks-store';
+import FUpload from '@/components/Upload';
 
 const Debug = observer(() => {
   const location = useLocation<{ id: string }>();
@@ -65,16 +74,21 @@ const Debug = observer(() => {
     },
   });
 
-
-  const getTemplate = () => service.getTemplate(state.current?.id!, {
-    terms: [{column: 'type', value: id}, {column: 'provider', value: state.current?.provider}]
-  }).then((resp) => {
-    Store.set('notice-template-list', resp.result);
-    return resp.result?.map((item: any) => ({
-      label: item.name,
-      value: item.id,
-    }));
-  })
+  const getTemplate = () =>
+    service
+      .getTemplate(state.current?.id || '', {
+        terms: [
+          { column: 'type', value: id },
+          { column: 'provider', value: state.current?.provider },
+        ],
+      })
+      .then((resp) => {
+        Store.set('notice-template-list', resp.result);
+        return resp.result?.map((item: any) => ({
+          label: item.name,
+          value: item.id,
+        }));
+      });
 
   const schema: ISchema = {
     type: 'object',
@@ -92,8 +106,8 @@ const Debug = observer(() => {
         'x-decorator': 'FormItem',
         'x-component': 'ArrayTable',
         'x-component-props': {
-          pagination: {pageSize: 9999},
-          scroll: {x: '100%'},
+          pagination: { pageSize: 9999 },
+          scroll: { x: '100%' },
         },
         items: {
           type: 'object',
@@ -101,7 +115,7 @@ const Debug = observer(() => {
             column1: {
               type: 'void',
               'x-component': 'ArrayTable.Column',
-              'x-component-props': {title: '变量', width: '120px'},
+              'x-component-props': { title: '变量', width: '120px' },
               properties: {
                 id: {
                   type: 'string',
@@ -114,7 +128,7 @@ const Debug = observer(() => {
             column2: {
               type: 'void',
               'x-component': 'ArrayTable.Column',
-              'x-component-props': {title: '名称', width: '120px'},
+              'x-component-props': { title: '名称', width: '120px' },
               properties: {
                 name: {
                   type: 'string',
@@ -127,7 +141,7 @@ const Debug = observer(() => {
             column3: {
               type: 'void',
               'x-component': 'ArrayTable.Column',
-              'x-component-props': {title: '值', width: '120px'},
+              'x-component-props': { title: '值', width: '120px' },
               properties: {
                 value: {
                   type: 'string',
@@ -141,9 +155,9 @@ const Debug = observer(() => {
       },
     },
   };
-  
+
   const start = async () => {
-    const data: { templateId: string, variableDefinitions: any } = await form.submit();
+    const data: { templateId: string; variableDefinitions: any } = await form.submit();
     // 应该取选择的配置信息
     if (!state.current) return;
     const templateId = data.templateId;
@@ -152,17 +166,20 @@ const Debug = observer(() => {
 
     const resp = await service.debug(state?.current.id, {
       template: _template,
-      context: data.variableDefinitions?.reduce((previousValue: any, currentValue: { id: any; value: any; }) => {
-        return {
-          ...previousValue,
-          [currentValue.id]: currentValue.value
-        }
-      }, {})
+      context: data.variableDefinitions?.reduce(
+        (previousValue: any, currentValue: { id: any; value: any }) => {
+          return {
+            ...previousValue,
+            [currentValue.id]: currentValue.value,
+          };
+        },
+        {},
+      ),
     });
     if (resp.status === 200) {
       message.success('操作成功!');
     }
-  }
+  };
   return (
     <Modal
       title="调试"
@@ -172,7 +189,7 @@ const Debug = observer(() => {
       onOk={start}
     >
       <Form form={form} layout={'vertical'}>
-        <SchemaField schema={schema} scope={{getTemplate, useAsyncDataSource}}/>
+        <SchemaField schema={schema} scope={{ getTemplate, useAsyncDataSource }} />
       </Form>
     </Modal>
   );

+ 14 - 17
src/pages/notice/Config/Log/index.tsx

@@ -1,11 +1,11 @@
-import {Modal} from 'antd';
-import {observer} from '@formily/react';
-import {service, state} from '..';
-import ProTable, {ActionType, ProColumns} from '@jetlinks/pro-table';
+import { Modal } from 'antd';
+import { observer } from '@formily/react';
+import { service, state } from '..';
+import ProTable, { ActionType, ProColumns } from '@jetlinks/pro-table';
 import SearchComponent from '@/components/SearchComponent';
-import {useLocation} from 'umi';
-import {InfoCircleOutlined} from '@ant-design/icons';
-import {useRef, useState} from "react";
+import { useLocation } from 'umi';
+import { InfoCircleOutlined } from '@ant-design/icons';
+import { useRef, useState } from 'react';
 
 const Log = observer(() => {
   const location = useLocation<{ id: string }>();
@@ -23,7 +23,7 @@ const Log = observer(() => {
     {
       dataIndex: 'state',
       title: '状态',
-      renderText: (text) => text.text
+      renderText: (text) => text.text,
     },
     {
       dataIndex: 'action',
@@ -35,16 +35,13 @@ const Log = observer(() => {
               title: '详情信息',
               width: '30vw',
               content: (
-                <div style={{height: '300px', overflowY: 'auto'}}>
-                  {JSON.stringify(record)}
-                </div>
+                <div style={{ height: '300px', overflowY: 'auto' }}>{JSON.stringify(record)}</div>
               ),
-              onOk() {
-              },
+              onOk() {},
             });
           }}
         >
-          <InfoCircleOutlined/>
+          <InfoCircleOutlined />
         </a>,
       ],
     },
@@ -54,7 +51,7 @@ const Log = observer(() => {
   return (
     <Modal onCancel={() => (state.log = false)} title="通知记录" width={'70vw'} visible={state.log}>
       <SearchComponent
-        defaultParam={[{column: 'type$IN', value: id}]}
+        defaultParam={[{ column: 'type$IN', value: id }]}
         field={columns}
         onSearch={(data) => {
           actionRef.current?.reset?.();
@@ -66,10 +63,10 @@ const Log = observer(() => {
         params={param}
         search={false}
         pagination={{
-          pageSize: 5
+          pageSize: 5,
         }}
         columns={columns}
-        request={async (params) => service.getHistoryLog(state.current?.id!, params)}
+        request={async (params) => service.getHistoryLog(state.current?.id || '', params)}
       />
     </Modal>
   );

+ 32 - 32
src/pages/notice/Config/index.tsx

@@ -1,5 +1,5 @@
-import {PageContainer} from '@ant-design/pro-layout';
-import type {ActionType, ProColumns} from '@jetlinks/pro-table';
+import { PageContainer } from '@ant-design/pro-layout';
+import type { ActionType, ProColumns } from '@jetlinks/pro-table';
 import {
   ArrowDownOutlined,
   BarsOutlined,
@@ -9,22 +9,22 @@ import {
   PlusOutlined,
   UnorderedListOutlined,
 } from '@ant-design/icons';
-import {Button, message, Popconfirm, Space, Tooltip, Upload} from 'antd';
-import {useRef, useState} from 'react';
-import {useIntl} from '@@/plugin-locale/localeExports';
-import {downloadObject} from '@/utils/util';
+import { Button, message, Popconfirm, Space, Tooltip, Upload } from 'antd';
+import { useRef, useState } from 'react';
+import { useIntl } from '@@/plugin-locale/localeExports';
+import { downloadObject } from '@/utils/util';
 import Service from '@/pages/notice/Config/service';
-import {observer} from '@formily/react';
+import { observer } from '@formily/react';
 import SearchComponent from '@/components/SearchComponent';
-import {getMenuPathByParams, MENUS_CODE} from '@/utils/menu';
-import {history, useLocation} from 'umi';
-import {model} from '@formily/reactive';
+import { getMenuPathByParams, MENUS_CODE } from '@/utils/menu';
+import { history, useLocation } from 'umi';
+import { model } from '@formily/reactive';
 import moment from 'moment';
-import {ProTableCard} from '@/components';
+import { ProTableCard } from '@/components';
 import NoticeConfig from '@/components/ProTableCard/CardItems/noticeConfig';
 import Debug from '@/pages/notice/Config/Debug';
 import Log from '@/pages/notice/Config/Log';
-import {typeList} from "@/components/ProTableCard/CardItems/noticeTemplate";
+import { typeList } from '@/components/ProTableCard/CardItems/noticeTemplate';
 
 export const service = new Service('notifier/config');
 
@@ -54,7 +54,7 @@ const Config = observer(() => {
     {
       dataIndex: 'provider',
       title: '通知方式',
-      renderText: (text, record) => typeList[record.type][record.provider]
+      renderText: (text, record) => typeList[record.type][record.provider],
     },
     {
       dataIndex: 'description',
@@ -83,7 +83,7 @@ const Config = observer(() => {
               defaultMessage: '编辑',
             })}
           >
-            <EditOutlined/>
+            <EditOutlined />
           </Tooltip>
         </a>,
         <a
@@ -101,7 +101,7 @@ const Config = observer(() => {
               defaultMessage: '下载配置',
             })}
           >
-            <ArrowDownOutlined/>
+            <ArrowDownOutlined />
           </Tooltip>
         </a>,
         <a
@@ -117,7 +117,7 @@ const Config = observer(() => {
               defaultMessage: '调试',
             })}
           >
-            <BugOutlined/>
+            <BugOutlined />
           </Tooltip>
         </a>,
         <a
@@ -132,7 +132,7 @@ const Config = observer(() => {
               defaultMessage: '通知记录',
             })}
           >
-            <BarsOutlined/>
+            <BarsOutlined />
           </Tooltip>
         </a>,
         <a key="remove">
@@ -155,7 +155,7 @@ const Config = observer(() => {
                 defaultMessage: '删除',
               })}
             >
-              <DeleteOutlined/>
+              <DeleteOutlined />
             </Tooltip>
           </Popconfirm>
         </a>,
@@ -167,7 +167,7 @@ const Config = observer(() => {
   return (
     <PageContainer>
       <SearchComponent
-        defaultParam={[{column: 'type$IN', value: id}]}
+        defaultParam={[{ column: 'type$IN', value: id }]}
         field={columns}
         onSearch={(data) => {
           actionRef.current?.reset?.();
@@ -175,12 +175,12 @@ const Config = observer(() => {
         }}
       />
       <ProTableCard<ConfigItem>
-        rowKey='id'
+        rowKey="id"
         actionRef={actionRef}
         search={false}
         params={param}
         columns={columns}
-        headerTitle={(
+        headerTitle={
           <Space>
             <Button
               onClick={() => {
@@ -188,7 +188,7 @@ const Config = observer(() => {
                 history.push(getMenuPathByParams(MENUS_CODE['notice/Config/Detail'], id));
               }}
               key="button"
-              icon={<PlusOutlined/>}
+              icon={<PlusOutlined />}
               type="primary"
             >
               {intl.formatMessage({
@@ -226,12 +226,12 @@ const Config = observer(() => {
                 return false;
               }}
             >
-              <Button style={{marginLeft: 12}}>导入</Button>
+              <Button style={{ marginLeft: 12 }}>导入</Button>
             </Upload>
             <Popconfirm
               title={'确认导出当前页数据?'}
               onConfirm={async () => {
-                const resp: any = await service.queryNoPagingPost({...param, paging: false});
+                const resp: any = await service.queryNoPagingPost({ ...param, paging: false });
                 if (resp.status === 200) {
                   downloadObject(resp.result, '通知配置数据');
                   message.success('导出成功');
@@ -243,7 +243,7 @@ const Config = observer(() => {
               <Button>导出</Button>
             </Popconfirm>
           </Space>
-        )}
+        }
         gridColumn={3}
         request={async (params) => service.query(params)}
         cardRender={(record) => (
@@ -259,7 +259,7 @@ const Config = observer(() => {
                   history.push(getMenuPathByParams(MENUS_CODE['notice/Config/Detail'], id));
                 }}
               >
-                <EditOutlined/>
+                <EditOutlined />
                 编辑
               </Button>,
               <Button
@@ -269,7 +269,7 @@ const Config = observer(() => {
                   state.current = record;
                 }}
               >
-                <BugOutlined/>
+                <BugOutlined />
                 调试
               </Button>,
               <Button
@@ -281,7 +281,7 @@ const Config = observer(() => {
                   )
                 }
               >
-                <ArrowDownOutlined/>
+                <ArrowDownOutlined />
                 导出
               </Button>,
               <Button
@@ -291,7 +291,7 @@ const Config = observer(() => {
                   state.current = record;
                 }}
               >
-                <UnorderedListOutlined/>
+                <UnorderedListOutlined />
                 通知记录
               </Button>,
               <Popconfirm
@@ -303,15 +303,15 @@ const Config = observer(() => {
                 }}
               >
                 <Button key="delete">
-                  <DeleteOutlined/>
+                  <DeleteOutlined />
                 </Button>
               </Popconfirm>,
             ]}
           />
         )}
       />
-      <Debug/>
-      <Log/>
+      <Debug />
+      <Log />
     </PageContainer>
   );
 });

+ 5 - 6
src/pages/notice/Config/service.ts

@@ -1,5 +1,5 @@
 import BaseService from '@/utils/BaseService';
-import {request} from 'umi';
+import { request } from 'umi';
 import SystemConst from '@/utils/const';
 
 class Service extends BaseService<ConfigItem> {
@@ -16,7 +16,7 @@ class Service extends BaseService<ConfigItem> {
   public getTemplate = (configId: string, data: Record<string, any>) =>
     request(`${SystemConst.API_BASE}/notifier/template/${configId}/_query`, {
       method: 'POST',
-      data
+      data,
     });
 
   public getTemplateVariable = (templateId: string) =>
@@ -25,15 +25,14 @@ class Service extends BaseService<ConfigItem> {
   public getHistoryLog = (configId: string, data: Record<string, any>) =>
     request(`${SystemConst.API_BASE}/notify/history/config/${configId}/_query`, {
       method: 'POST',
-      data
+      data,
     });
 
   public debug = (id: string, data: Record<string, any>) =>
     request(`${SystemConst.API_BASE}/notifier/${id}/_send`, {
       method: 'POST',
-      data
-    })
-
+      data,
+    });
 }
 
 export default Service;

+ 1 - 1
src/pages/notice/Config/typings.d.ts

@@ -7,7 +7,7 @@ type ConfigItem = {
   creatorId: string;
   createTime: number;
   configuration: Record<string, unknown>;
-  description: string
+  description: string;
 };
 
 type Provider = {

+ 37 - 25
src/pages/notice/Template/Debug/index.tsx

@@ -1,13 +1,22 @@
-import {message, Modal} from 'antd';
-import {useEffect, useMemo} from 'react';
-import {createForm, Field, onFieldReact, onFieldValueChange} from '@formily/core';
-import {createSchemaField, observer} from '@formily/react';
-import {ArrayTable, DatePicker, Form, FormItem, Input, NumberPicker, PreviewText, Select,} from '@formily/antd';
-import {ISchema} from '@formily/json-schema';
-import {configService, service, state} from '@/pages/notice/Template';
-import {useLocation} from 'umi';
-import {useAsyncDataSource} from '@/utils/util';
-import {Store} from 'jetlinks-store';
+import { message, Modal } from 'antd';
+import { useEffect, useMemo } from 'react';
+import { createForm, Field, onFieldReact, onFieldValueChange } from '@formily/core';
+import { createSchemaField, observer } from '@formily/react';
+import {
+  ArrayTable,
+  DatePicker,
+  Form,
+  FormItem,
+  Input,
+  NumberPicker,
+  PreviewText,
+  Select,
+} from '@formily/antd';
+import { ISchema } from '@formily/json-schema';
+import { configService, service, state } from '@/pages/notice/Template';
+import { useLocation } from 'umi';
+import { useAsyncDataSource } from '@/utils/util';
+import { Store } from 'jetlinks-store';
 import FUpload from '@/components/Upload';
 
 const Debug = observer(() => {
@@ -77,7 +86,7 @@ const Debug = observer(() => {
   const getConfig = () =>
     configService
       .queryNoPagingPost({
-        terms: [{column: 'type$IN', value: id}],
+        terms: [{ column: 'type$IN', value: id }],
       })
       .then((resp: any) => {
         // 缓存通知配置
@@ -104,8 +113,8 @@ const Debug = observer(() => {
         'x-decorator': 'FormItem',
         'x-component': 'ArrayTable',
         'x-component-props': {
-          pagination: {pageSize: 9999},
-          scroll: {x: '100%'},
+          pagination: { pageSize: 9999 },
+          scroll: { x: '100%' },
         },
         items: {
           type: 'object',
@@ -113,7 +122,7 @@ const Debug = observer(() => {
             column1: {
               type: 'void',
               'x-component': 'ArrayTable.Column',
-              'x-component-props': {title: '变量', width: '120px'},
+              'x-component-props': { title: '变量', width: '120px' },
               properties: {
                 id: {
                   type: 'string',
@@ -126,7 +135,7 @@ const Debug = observer(() => {
             column2: {
               type: 'void',
               'x-component': 'ArrayTable.Column',
-              'x-component-props': {title: '名称', width: '120px'},
+              'x-component-props': { title: '名称', width: '120px' },
               properties: {
                 name: {
                   type: 'string',
@@ -139,7 +148,7 @@ const Debug = observer(() => {
             column3: {
               type: 'void',
               'x-component': 'ArrayTable.Column',
-              'x-component-props': {title: '值', width: '120px'},
+              'x-component-props': { title: '值', width: '120px' },
               properties: {
                 value: {
                   type: 'string',
@@ -155,22 +164,25 @@ const Debug = observer(() => {
   };
 
   const start = async () => {
-    const data: { templateId: string, variableDefinitions: any } = await form.submit();
+    const data: { templateId: string; variableDefinitions: any } = await form.submit();
     // 应该取选择的配置信息
     if (!state.current) return;
     const resp = await service.debug(state?.current.id, {
       template: state.current,
-      context: data.variableDefinitions?.reduce((previousValue: any, currentValue: { id: any; value: any; }) => {
-        return {
-          ...previousValue,
-          [currentValue.id]: currentValue.value
-        }
-      }, {})
+      context: data.variableDefinitions?.reduce(
+        (previousValue: any, currentValue: { id: any; value: any }) => {
+          return {
+            ...previousValue,
+            [currentValue.id]: currentValue.value,
+          };
+        },
+        {},
+      ),
     });
     if (resp.status === 200) {
       message.success('操作成功!');
     }
-  }
+  };
   return (
     <Modal
       title="调试"
@@ -180,7 +192,7 @@ const Debug = observer(() => {
       onOk={start}
     >
       <Form form={form} layout={'vertical'}>
-        <SchemaField schema={schema} scope={{getConfig, useAsyncDataSource}}/>
+        <SchemaField schema={schema} scope={{ getConfig, useAsyncDataSource }} />
       </Form>
     </Modal>
   );

+ 50 - 48
src/pages/notice/Template/Detail/index.tsx

@@ -15,20 +15,20 @@ import {
   Submit,
   Switch,
 } from '@formily/antd';
-import type {Field} from '@formily/core';
-import {createForm, onFieldInit, onFieldValueChange} from '@formily/core';
-import {createSchemaField, observer} from '@formily/react';
-import type {ISchema} from '@formily/json-schema';
+import type { Field } from '@formily/core';
+import { createForm, onFieldInit, onFieldValueChange } from '@formily/core';
+import { createSchemaField, observer } from '@formily/react';
+import type { ISchema } from '@formily/json-schema';
 import styles from './index.less';
-import {useEffect, useMemo, useState} from 'react';
+import { useEffect, useMemo, useState } from 'react';
 import FUpload from '@/components/Upload';
-import {useParams} from 'umi';
-import {PageContainer} from '@ant-design/pro-layout';
-import {Card, Col, message, Row} from 'antd';
-import {typeList} from '@/pages/notice';
-import {configService, service, state} from '@/pages/notice/Template';
+import { useParams } from 'umi';
+import { PageContainer } from '@ant-design/pro-layout';
+import { Card, Col, message, Row } from 'antd';
+import { typeList } from '@/pages/notice';
+import { configService, service, state } from '@/pages/notice/Template';
 import FBraftEditor from '@/components/FBraftEditor';
-import {useAsyncDataSource} from '@/utils/util';
+import { useAsyncDataSource } from '@/utils/util';
 import WeixinCorp from '@/pages/notice/Template/Detail/doc/WeixinCorp';
 import WeixinApp from '@/pages/notice/Template/Detail/doc/WeixinApp';
 import DingTalk from '@/pages/notice/Template/Detail/doc/DingTalk';
@@ -39,31 +39,31 @@ import Email from '@/pages/notice/Template/Detail/doc/Email';
 
 export const docMap = {
   weixin: {
-    corpMessage: <WeixinCorp/>,
-    officialMessage: <WeixinApp/>,
+    corpMessage: <WeixinCorp />,
+    officialMessage: <WeixinApp />,
   },
   dingTalk: {
-    dingTalkMessage: <DingTalk/>,
-    dingTalkRobotWebHook: <DingTalkRebot/>,
+    dingTalkMessage: <DingTalk />,
+    dingTalkRobotWebHook: <DingTalkRebot />,
   },
   voice: {
-    aliyun: <AliyunVoice/>,
+    aliyun: <AliyunVoice />,
   },
   sms: {
-    aliyunSms: <AliyunSms/>,
+    aliyunSms: <AliyunSms />,
   },
   email: {
-    embedded: <Email/>,
+    embedded: <Email />,
   },
 };
 
 const Detail = observer(() => {
-  const {id} = useParams<{ id: string }>();
+  const { id } = useParams<{ id: string }>();
 
   const getConfig = () =>
     configService
       .queryNoPagingPost({
-        terms: [{column: 'type$IN', value: id}],
+        terms: [{ column: 'type$IN', value: id }],
       })
       .then((resp: any) => {
         return resp.result?.map((item: any) => ({
@@ -104,10 +104,12 @@ const Detail = observer(() => {
           });
           onFieldValueChange('template.message', (field, form1) => {
             const value = (field as Field).value;
-            const idList = (typeof value === 'string') && value
-              ?.match(pattern)
-              ?.filter((i: string) => i)
-              .map((item: string) => ({id: item, type: 'string', format: '--'}));
+            const idList =
+              typeof value === 'string' &&
+              value
+                ?.match(pattern)
+                ?.filter((i: string) => i)
+                .map((item: string) => ({ id: item, type: 'string', format: '--' }));
             if (form1.modified) {
               form1.setValuesIn('variableDefinitions', idList);
             }
@@ -119,11 +121,11 @@ const Detail = observer(() => {
               case 'date':
                 format.setComponent(Select);
                 format.setDataSource([
-                  {label: 'String类型的UTC时间戳 (毫秒)', value: 'string'},
-                  {label: 'yyyy-MM-dd', value: 'yyyy-MM-dd'},
-                  {label: 'yyyy-MM-dd HH:mm:ss', value: 'yyyy-MM-dd HH:mm:ss'},
-                  {label: 'yyyy-MM-dd HH:mm:ss EE', value: 'yyyy-MM-dd HH:mm:ss EE'},
-                  {label: 'yyyy-MM-dd HH:mm:ss zzz', value: 'yyyy-MM-dd HH:mm:ss zzz'},
+                  { label: 'String类型的UTC时间戳 (毫秒)', value: 'string' },
+                  { label: 'yyyy-MM-dd', value: 'yyyy-MM-dd' },
+                  { label: 'yyyy-MM-dd HH:mm:ss', value: 'yyyy-MM-dd HH:mm:ss' },
+                  { label: 'yyyy-MM-dd HH:mm:ss EE', value: 'yyyy-MM-dd HH:mm:ss EE' },
+                  { label: 'yyyy-MM-dd HH:mm:ss zzz', value: 'yyyy-MM-dd HH:mm:ss zzz' },
                 ]);
                 format.setValue('string');
                 break;
@@ -138,9 +140,9 @@ const Detail = observer(() => {
               case 'file':
                 format.setComponent(Select);
                 format.setDataSource([
-                  {label: '视频', value: 'video'},
-                  {label: '图片', value: 'img'},
-                  {label: '全部', value: 'any'},
+                  { label: '视频', value: 'video' },
+                  { label: '图片', value: 'img' },
+                  { label: '全部', value: 'any' },
                 ]);
                 format.setValue('any');
                 break;
@@ -374,8 +376,8 @@ const Detail = observer(() => {
                     'x-component': 'Radio.Group',
                     'x-decorator': 'FormItem',
                     enum: [
-                      {label: '是', value: true},
-                      {label: '否', value: false},
+                      { label: '是', value: true },
+                      { label: '否', value: false },
                     ],
                   },
                   userIdList: {
@@ -430,9 +432,9 @@ const Detail = observer(() => {
                     'x-component': 'Select',
                     'x-decorator': 'FormItem',
                     enum: [
-                      {label: 'markdown', value: 'markdown'},
-                      {label: 'text', value: 'text'},
-                      {label: 'link', value: 'link'},
+                      { label: 'markdown', value: 'markdown' },
+                      { label: 'text', value: 'text' },
+                      { label: 'link', value: 'link' },
                     ],
                   },
                   markdown: {
@@ -703,8 +705,8 @@ const Detail = observer(() => {
         'x-decorator': 'FormItem',
         'x-component': 'ArrayTable',
         'x-component-props': {
-          pagination: {pageSize: 9999},
-          scroll: {x: '100%'},
+          pagination: { pageSize: 9999 },
+          scroll: { x: '100%' },
         },
         items: {
           type: 'object',
@@ -712,7 +714,7 @@ const Detail = observer(() => {
             column1: {
               type: 'void',
               'x-component': 'ArrayTable.Column',
-              'x-component-props': {title: '变量', width: '120px'},
+              'x-component-props': { title: '变量', width: '120px' },
               properties: {
                 id: {
                   type: 'string',
@@ -725,7 +727,7 @@ const Detail = observer(() => {
             column2: {
               type: 'void',
               'x-component': 'ArrayTable.Column',
-              'x-component-props': {title: '名称'},
+              'x-component-props': { title: '名称' },
               properties: {
                 name: {
                   type: 'string',
@@ -738,7 +740,7 @@ const Detail = observer(() => {
             column3: {
               type: 'void',
               'x-component': 'ArrayTable.Column',
-              'x-component-props': {title: '类型', width: '120px'},
+              'x-component-props': { title: '类型', width: '120px' },
               properties: {
                 type: {
                   type: 'string',
@@ -746,11 +748,11 @@ const Detail = observer(() => {
                   'x-component': 'Select',
                   required: true,
                   enum: [
-                    {label: '字符串', value: 'string'},
-                    {label: '时间', value: 'date'},
-                    {label: '数字', value: 'number'},
-                    {label: '文件', value: 'file'},
-                    {label: '其他', value: 'other'},
+                    { label: '字符串', value: 'string' },
+                    { label: '时间', value: 'date' },
+                    { label: '数字', value: 'number' },
+                    { label: '文件', value: 'file' },
+                    { label: '其他', value: 'other' },
                   ],
                 },
               },
@@ -758,7 +760,7 @@ const Detail = observer(() => {
             column4: {
               type: 'void',
               'x-component': 'ArrayTable.Column',
-              'x-component-props': {title: '格式', width: '150px'},
+              'x-component-props': { title: '格式', width: '150px' },
               required: true,
               properties: {
                 format: {

+ 19 - 19
src/pages/notice/Template/Log/index.tsx

@@ -1,10 +1,11 @@
-import {Modal} from 'antd';
-import {observer} from '@formily/react';
-import {service, state} from '..';
-import ProTable, {ProColumns} from '@jetlinks/pro-table';
+import { Modal } from 'antd';
+import { observer } from '@formily/react';
+import { service, state } from '..';
+import ProTable, { ActionType, ProColumns } from '@jetlinks/pro-table';
 import SearchComponent from '@/components/SearchComponent';
-import {useLocation} from 'umi';
-import {InfoCircleOutlined} from '@ant-design/icons';
+import { useLocation } from 'umi';
+import { InfoCircleOutlined } from '@ant-design/icons';
+import { useRef, useState } from 'react';
 
 const Log = observer(() => {
   const location = useLocation<{ id: string }>();
@@ -28,35 +29,33 @@ const Log = observer(() => {
       title: '操作',
       render: (text, record) => [
         <a
-          key='info'
+          key="info"
           onClick={() => {
             Modal.info({
               title: '详情信息',
               width: '30vw',
               content: (
-                <div style={{height: '300px', overflowY: 'auto'}}>
-                  {record.errorStack}
-                </div>
+                <div style={{ height: '300px', overflowY: 'auto' }}>{record.errorStack}</div>
               ),
-              onOk() {
-              },
+              onOk() {},
             });
           }}
         >
-          <InfoCircleOutlined/>
-        </a>
+          <InfoCircleOutlined />
+        </a>,
       ],
     },
   ];
+  const [param, setParam] = useState<any>();
+  const actionRef = useRef<ActionType>();
   return (
     <Modal onCancel={() => (state.log = false)} title="通知记录" width={'70vw'} visible={state.log}>
       <SearchComponent
-        defaultParam={[{column: 'type$IN', value: id}]}
+        defaultParam={[{ column: 'type$IN', value: id }]}
         field={columns}
         onSearch={(data) => {
-          // actionRef.current?.reset?.();
-          // setParam(data);
-          console.log(data);
+          actionRef.current?.reset?.();
+          setParam(data);
         }}
         enableSave={false}
       />
@@ -65,8 +64,9 @@ const Log = observer(() => {
         pagination={{
           pageSize: 5,
         }}
+        params={param}
         columns={columns}
-        request={async (params) => service.getHistoryLog(state.current?.id!, params)}
+        request={async (params) => service.getHistoryLog(state.current?.id || '', params)}
       />
     </Modal>
   );

+ 32 - 34
src/pages/notice/Template/index.tsx

@@ -1,6 +1,6 @@
-import {PageContainer} from '@ant-design/pro-layout';
-import {useRef, useState} from 'react';
-import type {ActionType, ProColumns} from '@jetlinks/pro-table';
+import { PageContainer } from '@ant-design/pro-layout';
+import { useRef, useState } from 'react';
+import type { ActionType, ProColumns } from '@jetlinks/pro-table';
 import {
   ArrowDownOutlined,
   BugOutlined,
@@ -9,20 +9,20 @@ import {
   PlusOutlined,
   UnorderedListOutlined,
 } from '@ant-design/icons';
-import {Button, message, Popconfirm, Space, Tooltip, Upload} from 'antd';
-import {useIntl} from '@@/plugin-locale/localeExports';
+import { Button, message, Popconfirm, Space, Tooltip, Upload } from 'antd';
+import { useIntl } from '@@/plugin-locale/localeExports';
 import Service from '@/pages/notice/Template/service';
 import ConfigService from '@/pages/notice/Config/service';
 import SearchComponent from '@/components/SearchComponent';
-import {history, useLocation} from 'umi';
-import {getMenuPathByParams, MENUS_CODE} from '@/utils/menu';
-import {model} from '@formily/reactive';
+import { history, useLocation } from 'umi';
+import { getMenuPathByParams, MENUS_CODE } from '@/utils/menu';
+import { model } from '@formily/reactive';
 import Debug from './Debug';
 import Log from '@/pages/notice/Template/Log';
-import {downloadObject} from '@/utils/util';
+import { downloadObject } from '@/utils/util';
 import moment from 'moment';
-import {ProTableCard} from '@/components';
-import NoticeCard, {typeList} from '@/components/ProTableCard/CardItems/noticeTemplate';
+import { ProTableCard } from '@/components';
+import NoticeCard, { typeList } from '@/components/ProTableCard/CardItems/noticeTemplate';
 
 export const service = new Service('notifier/template');
 
@@ -49,12 +49,12 @@ const Template = () => {
     {
       dataIndex: 'provider',
       title: '通知方式',
-      renderText: (text, record) => typeList[record.type][record.provider]
+      renderText: (text, record) => typeList[record.type][record.provider],
     },
     {
       dataIndex: 'createTime',
       title: '时间',
-      valueType: 'dateTime'
+      valueType: 'dateTime',
     },
     {
       title: intl.formatMessage({
@@ -78,7 +78,7 @@ const Template = () => {
               defaultMessage: '编辑',
             })}
           >
-            <EditOutlined/>
+            <EditOutlined />
           </Tooltip>
         </a>,
         <Popconfirm
@@ -96,7 +96,7 @@ const Template = () => {
                 defaultMessage: '删除',
               })}
             >
-              <DeleteOutlined/>
+              <DeleteOutlined />
             </Tooltip>
           </a>
         </Popconfirm>,
@@ -109,10 +109,8 @@ const Template = () => {
             );
           }}
         >
-          <Tooltip
-            title='导出'
-          >
-            <ArrowDownOutlined/>
+          <Tooltip title="导出">
+            <ArrowDownOutlined />
           </Tooltip>
         </a>,
         <a
@@ -128,7 +126,7 @@ const Template = () => {
               defaultMessage: '调试',
             })}
           >
-            <BugOutlined/>
+            <BugOutlined />
           </Tooltip>
         </a>,
         <a
@@ -138,7 +136,7 @@ const Template = () => {
           }}
         >
           <Tooltip title="通知记录">
-            <UnorderedListOutlined/>
+            <UnorderedListOutlined />
           </Tooltip>
         </a>,
       ],
@@ -149,7 +147,7 @@ const Template = () => {
   return (
     <PageContainer>
       <SearchComponent
-        defaultParam={[{column: 'type$IN', value: id}]}
+        defaultParam={[{ column: 'type$IN', value: id }]}
         field={columns}
         onSearch={(data) => {
           actionRef.current?.reset?.();
@@ -162,7 +160,7 @@ const Template = () => {
         search={false}
         params={param}
         columns={columns}
-        headerTitle={(
+        headerTitle={
           <Space>
             <Button
               onClick={() => {
@@ -170,7 +168,7 @@ const Template = () => {
                 history.push(getMenuPathByParams(MENUS_CODE['notice/Template/Detail'], id));
               }}
               key="button"
-              icon={<PlusOutlined/>}
+              icon={<PlusOutlined />}
               type="primary"
             >
               {intl.formatMessage({
@@ -204,12 +202,12 @@ const Template = () => {
                 return false;
               }}
             >
-              <Button style={{marginLeft: 12}}>导入</Button>
+              <Button style={{ marginLeft: 12 }}>导入</Button>
             </Upload>
             <Popconfirm
               title={'确认导出当前页数据?'}
               onConfirm={async () => {
-                const resp: any = await service.queryNoPagingPost({...param, paging: false});
+                const resp: any = await service.queryNoPagingPost({ ...param, paging: false });
                 if (resp.status === 200) {
                   downloadObject(resp.result, '通知模版数据');
                   message.success('导出成功');
@@ -221,7 +219,7 @@ const Template = () => {
               <Button>导出</Button>
             </Popconfirm>
           </Space>
-        )}
+        }
         gridColumn={3}
         cardRender={(record) => (
           <NoticeCard
@@ -235,7 +233,7 @@ const Template = () => {
                   history.push(getMenuPathByParams(MENUS_CODE['notice/Template/Detail'], id));
                 }}
               >
-                <EditOutlined/>
+                <EditOutlined />
                 编辑
               </Button>,
               <Button
@@ -245,7 +243,7 @@ const Template = () => {
                   state.current = record;
                 }}
               >
-                <BugOutlined/>
+                <BugOutlined />
                 调试
               </Button>,
               <Button
@@ -257,7 +255,7 @@ const Template = () => {
                   );
                 }}
               >
-                <ArrowDownOutlined/>
+                <ArrowDownOutlined />
                 导出
               </Button>,
               <Button
@@ -266,7 +264,7 @@ const Template = () => {
                   state.log = true;
                 }}
               >
-                <UnorderedListOutlined/>
+                <UnorderedListOutlined />
                 通知记录
               </Button>,
               <Popconfirm
@@ -278,7 +276,7 @@ const Template = () => {
                 }}
               >
                 <Button key="delete">
-                  <DeleteOutlined/>
+                  <DeleteOutlined />
                 </Button>
               </Popconfirm>,
             ]}
@@ -286,8 +284,8 @@ const Template = () => {
         )}
         request={async (params) => service.query(params)}
       />
-      <Debug/>
-      <Log/>
+      <Debug />
+      <Log />
     </PageContainer>
   );
 };

+ 5 - 5
src/pages/notice/Template/service.ts

@@ -1,5 +1,5 @@
 import BaseService from '@/utils/BaseService';
-import {request} from 'umi';
+import { request } from 'umi';
 import SystemConst from '@/utils/const';
 
 class Service extends BaseService<TemplateItem> {
@@ -16,7 +16,7 @@ class Service extends BaseService<TemplateItem> {
   public batchInsert = (data: Record<any, any>[]) =>
     request(`${this.uri}/_batch`, {
       method: 'POST',
-      data
+      data,
     });
 
   public getConfigs = (data: any) =>
@@ -28,14 +28,14 @@ class Service extends BaseService<TemplateItem> {
   public getHistoryLog = (templateId: string, data: Record<string, any>) =>
     request(`${SystemConst.API_BASE}/notify/history/template/${templateId}/_query`, {
       method: 'POST',
-      data
+      data,
     });
 
   public debug = (id: string, data: Record<string, any>) =>
     request(`${SystemConst.API_BASE}/notifier/${id}/_send`, {
       method: 'POST',
-      data
-    })
+      data,
+    });
 
   public sendMessage = (notifierId: string) =>
     request(`${SystemConst.API_BASE}/notifier/${notifierId}/_send`, {

+ 1 - 1
src/pages/notice/Template/typings.d.ts

@@ -15,5 +15,5 @@ type LogItem = {
   config: string;
   sendTime: number;
   state: string;
-  errorStack?: string
+  errorStack?: string;
 };

+ 9 - 10
src/utils/BaseService.ts

@@ -1,6 +1,6 @@
 import Token from '@/utils/token';
 import SystemConst from '@/utils/const';
-import {request} from 'umi';
+import { request } from 'umi';
 
 interface IBaseService<T> {
   query: (params: any) => Promise<any>;
@@ -20,37 +20,36 @@ class BaseService<T> implements IBaseService<T> {
   }
 
   query(data: any): Promise<any> {
-    return request(`${this.uri}/_query/`, {data, method: 'POST'});
+    return request(`${this.uri}/_query/`, { data, method: 'POST' });
   }
 
   queryNoPagingPost(data: any): Promise<unknown> {
-    return request(`${this.uri}/_query/no-paging?paging=false`, {data, method: 'POST'});
+    return request(`${this.uri}/_query/no-paging?paging=false`, { data, method: 'POST' });
   }
 
   queryNoPaging(params: any): Promise<unknown> {
-    return request(`${this.uri}/_query/no-paging?paging=false`, {params, method: 'GET'});
+    return request(`${this.uri}/_query/no-paging?paging=false`, { params, method: 'GET' });
   }
 
   remove(id: string): Promise<unknown> {
-    return request(`${this.uri}/${id}`, {method: 'DELETE'});
+    return request(`${this.uri}/${id}`, { method: 'DELETE' });
   }
 
   save(data: Partial<T>): Promise<unknown> {
-    return request(this.uri, {data, method: 'POST'});
+    return request(this.uri, { data, method: 'POST' });
   }
 
-
   savePatch(data: Partial<T>): Promise<unknown> {
-    return request(this.uri, {data, method: 'PATCH'});
+    return request(this.uri, { data, method: 'PATCH' });
   }
 
   update(data: Partial<T>): Promise<any> {
     // @ts-ignore
-    return data.id ? request(this.uri, {data, method: 'PATCH'}) : this.save(data);
+    return data.id ? request(this.uri, { data, method: 'PATCH' }) : this.save(data);
   }
 
   detail(id: string): Promise<any> {
-    return request(`${this.uri}/${id}`, {method: 'GET'});
+    return request(`${this.uri}/${id}`, { method: 'GET' });
   }
 
   modify(id: string, data: Partial<T>): Promise<any> {