Skip to content

Commit

Permalink
feat: 定时任务
Browse files Browse the repository at this point in the history
  • Loading branch information
buqiyuan committed Dec 22, 2021
1 parent 7b7f17a commit ae2615d
Show file tree
Hide file tree
Showing 13 changed files with 1,877 additions and 232 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"path-browserify": "^1.0.1",
"postcss-html": "^1.3.0",
"prettier": "^2.5.1",
"stylelint": "^14.1.0",
"stylelint": "^14.2.0",
"stylelint-config-html": "^1.0.0",
"stylelint-config-prettier": "^9.0.3",
"stylelint-config-recommended": "^6.0.0",
Expand Down
80 changes: 80 additions & 0 deletions src/api/system/task/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { request } from '@/utils/request';
import Api from '@/core/permission/modules/sys/task';

type CommonParams = {
id: number;
};

export function getSysTaskList(params?: API.PageParams) {
return request<API.TableListResult<API.SysTaskListItem[]>>({
url: Api.page,
method: 'get',
params,
});
}

export function getSysTaskInfo(params: CommonParams) {
return request<API.SysTaskInfoResult>({
url: Api.info,
method: 'get',
params,
});
}

export function sysTaskAdd(data?: API.PageParams) {
return request(
{
url: Api.add,
method: 'post',
data,
},
{
successMsg: '添加成功',
},
);
}

export function sysTaskDelete(data?: API.PageParams) {
return request({
url: Api.delete,
method: 'post',
data,
});
}

export function sysTaskUpdate(data?: API.PageParams) {
return request(
{
url: Api.update,
method: 'post',
data,
},
{
successMsg: '修改成功',
},
);
}

export function sysTaskOnce(data: CommonParams) {
return request({
url: Api.once,
method: 'post',
data,
});
}

export function sysTaskStart(data: CommonParams) {
return request({
url: Api.start,
method: 'post',
data,
});
}

export function sysTaskStop(data: CommonParams) {
return request({
url: Api.stop,
method: 'post',
data,
});
}
57 changes: 57 additions & 0 deletions src/api/system/task/model.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
declare namespace API {
/** 任务列表项 */
export type SysTaskListItem = {
createdAt: string;
updatedAt: string;
id: number;
name: string;
service: string;
type: number;
status: number;
startTime: string;
endTime: string;
limit: number;
cron: string;
every: number;
data: string;
jobOpts: string;
remark: string;
};
/** 添加任务参数 */
export type SysTaskAddParams = {
name: string;
service: string;
type: number;
status: number;
startTime: string;
endTime: string;
limit: number;
cron: string;
every: number;
data: string;
remark: string;
};

/** 更新任务参数 */
export type SysTaskUpdateParams = SysTaskAddParams & {
id: number;
};
/** 获取任务详情返回结果 */
export type SysTaskInfoResult = {
createdAt: string;
updatedAt: string;
id: number;
name: string;
service: string;
type: number;
status: number;
startTime: string;
endTime: string;
limit: number;
cron: string;
every: number;
data: string;
jobOpts: string;
remark: string;
};
}
26 changes: 13 additions & 13 deletions src/components/JSON-schema-form/types/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ export type Rule = RuleObject & {
trigger?: 'blur' | 'change' | ['change', 'blur'];
};

export interface RenderCallbackParams {
export interface RenderCallbackParams<T = string> {
schemaItem: FormItemSchema;
formModel: Recordable;
field: string;
formModel: T extends string ? Recordable : T;
field: T extends string ? string : keyof T;
}

export interface ButtonProps {
Expand Down Expand Up @@ -131,7 +131,7 @@ export interface FormItemSchema<T = string> {
helpMessage?:
| string
| string[]
| ((renderCallbackParams: RenderCallbackParams) => string | string[]);
| ((renderCallbackParams: RenderCallbackParams<T>) => string | string[]);
// BaseHelp component props
helpComponentProps?: Partial<HelpComponentProps>;
// Label width, if it is passed, the labelCol and WrapperCol configured by itemProps will be invalid
Expand All @@ -150,15 +150,15 @@ export interface FormItemSchema<T = string> {
}) => ComponentProps);

componentSlots?:
| ((renderCallbackParams: RenderCallbackParams) => Recordable<(...args) => any>)
| ((renderCallbackParams: RenderCallbackParams<T>) => Recordable<(...args) => any>)
| VNode
| VNode[]
| string
| Recordable<(...args) => any>;
// Required
required?: boolean | ((renderCallbackParams: RenderCallbackParams) => boolean);
required?: boolean | ((renderCallbackParams: RenderCallbackParams<T>) => boolean);

suffix?: string | number | ((values: RenderCallbackParams) => string | number);
suffix?: string | number | ((values: RenderCallbackParams<T>) => string | number);

// Validation rules
rules?: Rule[];
Expand All @@ -178,25 +178,25 @@ export interface FormItemSchema<T = string> {
// Matching details components
span?: number;

vShow?: boolean | ((renderCallbackParams: RenderCallbackParams) => boolean);
vShow?: boolean | ((renderCallbackParams: RenderCallbackParams<T>) => boolean);

vIf?: boolean | ((renderCallbackParams: RenderCallbackParams) => boolean);
vIf?: boolean | ((renderCallbackParams: RenderCallbackParams<T>) => boolean);

// Render the content in the form-item tag
render?: (renderCallbackParams: RenderCallbackParams) => VNode | VNode[] | string;
render?: (renderCallbackParams: RenderCallbackParams<T>) => VNode | VNode[] | string;

// Rendering col content requires outer wrapper form-item
renderColContent?: (renderCallbackParams: RenderCallbackParams) => VNode | VNode[] | string;
renderColContent?: (renderCallbackParams: RenderCallbackParams<T>) => VNode | VNode[] | string;

// Custom slot, in from-item
slot?: string;

// Custom slot, similar to renderColContent
colSlot?: string;

dynamicDisabled?: boolean | ((renderCallbackParams: RenderCallbackParams) => boolean);
dynamicDisabled?: boolean | ((renderCallbackParams: RenderCallbackParams<T>) => boolean);

dynamicRules?: (renderCallbackParams: RenderCallbackParams) => Rule[];
dynamicRules?: (renderCallbackParams: RenderCallbackParams<T>) => Rule[];
}
export interface HelpComponentProps {
maxWidth: string;
Expand Down
16 changes: 15 additions & 1 deletion src/components/iconfont/icon-font.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export default defineComponent({
type: String as PropType<string>,
default: '',
},
prefix: {
type: String,
default: 'icon-',
},
color: {
type: String as PropType<string>,
default: 'unset',
Expand Down Expand Up @@ -49,6 +53,16 @@ export default defineComponent({
};
});

return () => <MyIconFont type={props.type || ''} {...attrs} style={unref(wrapStyleRef)} />;
return () => {
const { type, prefix } = props;

return type ? (
<MyIconFont
type={type.startsWith(prefix) ? type : `${prefix}${type}`}
{...attrs}
style={unref(wrapStyleRef)}
/>
) : null;
};
},
});
Loading

0 comments on commit ae2615d

Please sign in to comment.