Browse Source

API参数调整

main
likunming 1 year ago
parent
commit
0d74211daa
  1. 2
      io.sc.platform.core.frontend/package.json
  2. 38
      io.sc.platform.core.frontend/src/platform/components/grid/WGrid.vue
  3. 45
      io.sc.platform.core.frontend/src/platform/components/toolbar/ChildrenBtn.vue
  4. 56
      io.sc.platform.core.frontend/src/platform/components/toolbar/WToolbar.vue
  5. 16
      io.sc.platform.core.frontend/src/platform/components/utils/FormValidators.ts
  6. 2
      io.sc.platform.core.frontend/src/platform/types/FormApiArgsType.ts
  7. 32
      io.sc.platform.core.frontend/src/platform/types/ToolbarApiArgsType.ts

2
io.sc.platform.core.frontend/package.json

@ -1,6 +1,6 @@
{
"name": "platform-core",
"version": "8.1.143",
"version": "8.1.144",
"description": "前端核心包,用于快速构建前端的脚手架",
"//main": "库的主文件",
"main": "dist/platform-core.js",

38
io.sc.platform.core.frontend/src/platform/components/grid/WGrid.vue

@ -624,8 +624,8 @@ const buttonObj = {
name: ButtonEnum.edit,
icon: IconEnum.编辑,
label: '编辑',
enableIf: (selected, ticked, grid) => {
if (selected && selected.length > 0) {
enableIf: (args) => {
if (args.selected) {
return true;
}
return false;
@ -648,21 +648,21 @@ const buttonObj = {
name: ButtonEnum.clone,
icon: 'content_copy',
label: '复制',
enableIf: (selected) => {
if (selected && selected.length > 0) {
enableIf: (args) => {
if (args.selected) {
return true;
}
return false;
},
click: (selected) => {
if (!selected || selected.length <= 0) {
click: (args) => {
if (!args.selected) {
NotifyManager.warn('请选择要复制的记录');
} else {
dialogRef.value.show();
dialog.dialogTitle = '复制';
nextTick(() => {
dialogFormRef.value.setStatus(PageStatusEnum.新增);
dialogFormRef.value.setData(selected[0]);
dialogFormRef.value.setData(args.selected);
});
}
},
@ -671,10 +671,10 @@ const buttonObj = {
name: ButtonEnum.remove,
icon: IconEnum.删除,
label: '删除',
enableIf: (selected, ticked, grid) => {
if (ticked && ticked.length > 0) {
enableIf: (args) => {
if (args.ticked) {
return true;
} else if (selected && selected.length > 0) {
} else if (args.selected) {
return true;
}
return false;
@ -698,13 +698,13 @@ const buttonObj = {
name: ButtonEnum.view,
icon: IconEnum.查看,
label: '查看',
enableIf: (selected) => {
if (selected && selected.length > 0) {
enableIf: (args) => {
if (args.selected) {
return true;
}
return false;
},
click: (selected, context) => {
click: () => {
view();
},
},
@ -712,7 +712,7 @@ const buttonObj = {
name: ButtonEnum.export,
icon: 'file_download',
label: '导出',
click: (selected, context) => {
click: () => {
const content = [tableColumns.value.map((col) => wrapCsvValue(col.label))]
.concat(
table.rows.map((row) =>
@ -738,7 +738,7 @@ const buttonObj = {
name: ButtonEnum.addTop,
icon: IconEnum.新增,
label: '新增顶级节点',
click: (selected, context) => {
click: () => {
dialog.dialogTitle = '新增顶级节点';
dialogRef.value.show();
nextTick(() => {
@ -751,13 +751,13 @@ const buttonObj = {
name: ButtonEnum.addChild,
icon: 'playlist_add',
label: '新增子节点',
enableIf: (selected) => {
if (selected && selected.length > 0) {
enableIf: (args) => {
if (args.selected) {
return true;
}
return false;
},
click: (selected, context) => {
click: () => {
dialog.dialogTitle = '新增子节点';
dialogRef.value.show();
nextTick(() => {
@ -770,7 +770,7 @@ const buttonObj = {
name: ButtonEnum.expand,
icon: expandIcon,
label: expandLabel,
click: (selected, context) => {
click: () => {
expandFun(table.rows, table.treeExpand);
table.treeExpand = !table.treeExpand;
},

45
io.sc.platform.core.frontend/src/platform/components/toolbar/ChildrenBtn.vue

@ -1,5 +1,19 @@
<template>
<q-item clickable :dense="dense" :disable="button[0].enableIf ? !button[0].enableIf(selectedComputed, tickedComputed, grid) : false">
<q-item
clickable
:dense="dense"
:disable="
button[0].enableIf
? !button[0].enableIf({
selected: firstSelectedComputed,
selecteds: selectedComputed,
ticked: firstTickedComputed,
tickeds: tickedComputed,
grid: grid,
})
: false
"
>
<q-item-section>
<q-item-label><q-icon v-if="button[0].icon" :name="button[0].icon" left size="20px"></q-icon> {{ button[0].label }}</q-item-label>
</q-item-section>
@ -23,7 +37,17 @@
<q-item
v-close-popup
clickable
:disable="childrenBtn.enableIf ? !childrenBtn.enableIf(selectedComputed, tickedComputed, grid) : false"
:disable="
childrenBtn.enableIf
? !childrenBtn.enableIf({
selected: firstSelectedComputed,
selecteds: selectedComputed,
ticked: firstTickedComputed,
tickeds: tickedComputed,
grid: grid,
})
: false
"
:dense="dense"
@click="buttonClick(childrenBtn)"
>
@ -60,11 +84,22 @@ const props = defineProps({
},
dense: { type: Boolean, default: false },
});
const firstSelectedComputed = computed(() => {
if (Object.keys(props.grid).length > 0 && props.grid.getSelectedRows().length > 0) {
return props.grid.getSelectedRows()[0];
}
return undefined;
});
const selectedComputed = computed(() => {
return props.grid.getSelectedRows();
return Object.keys(props.grid).length > 0 ? props.grid.getSelectedRows() : [];
});
const firstTickedComputed = computed(() => {
if (Object.keys(props.grid).length > 0 && props.grid.getTickedRows().length > 0) {
return props.grid.getTickedRows()[0];
}
return undefined;
});
const tickedComputed = computed(() => {
return props.grid.getTickedRows();
return Object.keys(props.grid).length > 0 ? props.grid.getTickedRows() : [];
});
</script>

56
io.sc.platform.core.frontend/src/platform/components/toolbar/WToolbar.vue

@ -19,10 +19,10 @@
:disable="
btn.data[0].enableIf
? !btn.data[0].enableIf({
firstSelected: firstSelectedComputed,
selected: selectedComputed,
firstTicked: firstTickedComputed,
ticked: tickedComputed,
selected: firstSelectedComputed,
selecteds: selectedComputed,
ticked: firstTickedComputed,
tickeds: tickedComputed,
grid: grid,
})
: false
@ -56,10 +56,10 @@
:disable="
childrenBtn.enableIf
? !childrenBtn.enableIf({
firstSelected: firstSelectedComputed,
selected: selectedComputed,
firstTicked: firstTickedComputed,
ticked: tickedComputed,
selected: firstSelectedComputed,
selecteds: selectedComputed,
ticked: firstTickedComputed,
tickeds: tickedComputed,
grid: grid,
})
: false
@ -80,10 +80,10 @@
:disable="
btn.data.enableIf
? !btn.data.enableIf({
firstSelected: firstSelectedComputed,
selected: selectedComputed,
firstTicked: firstTickedComputed,
ticked: tickedComputed,
selected: firstSelectedComputed,
selecteds: selectedComputed,
ticked: firstTickedComputed,
tickeds: tickedComputed,
grid: grid,
})
: false
@ -139,10 +139,10 @@
:disable="
childrenBtn.data.enableIf
? !childrenBtn.data.enableIf({
firstSelected: firstSelectedComputed,
selected: selectedComputed,
firstTicked: firstTickedComputed,
ticked: tickedComputed,
selected: firstSelectedComputed,
selecteds: selectedComputed,
ticked: firstTickedComputed,
tickeds: tickedComputed,
grid: grid,
})
: false
@ -367,20 +367,20 @@ const buttonClick = async (button) => {
const context = {};
if (button.beforeClick) {
beforeResult = await button.beforeClick({
firstSelected: firstSelectedComputed.value,
selected: selectedComputed.value,
firstTicked: firstTickedComputed.value,
ticked: tickedComputed.value,
selected: firstSelectedComputed.value,
selecteds: selectedComputed.value,
ticked: firstTickedComputed.value,
tickeds: tickedComputed.value,
grid: props.grid,
context: context,
});
}
if (beforeResult && button.click) {
await button.click({
firstSelected: firstSelectedComputed.value,
selected: selectedComputed.value,
firstTicked: firstTickedComputed.value,
ticked: tickedComputed.value,
selected: firstSelectedComputed.value,
selecteds: selectedComputed.value,
ticked: firstTickedComputed.value,
tickeds: tickedComputed.value,
grid: props.grid,
_click: button._click,
context: context,
@ -388,10 +388,10 @@ const buttonClick = async (button) => {
if (button.afterClick) {
nextTick(() => {
button.afterClick({
firstSelected: firstSelectedComputed.value,
selected: selectedComputed.value,
firstTicked: firstTickedComputed.value,
ticked: tickedComputed.value,
selected: firstSelectedComputed.value,
selecteds: selectedComputed.value,
ticked: firstTickedComputed.value,
tickeds: tickedComputed.value,
grid: props.grid,
context: context,
});

16
io.sc.platform.core.frontend/src/platform/components/utils/FormValidators.ts

@ -6,15 +6,15 @@ export class FormValidators {
*
* @returns
*/
public static required(msg: string) {
public static required(msg: string = '必填项未填写') {
return (val) => {
if (val === null || val === undefined) {
return msg || '必填项未填写';
return msg;
}
if (typeof val === 'string') {
return val !== '' || msg || '必填项未填写';
return val !== '' || msg;
} else if (Array.isArray(val)) {
return val.length > 0 || msg || '必填项未填写';
return val.length > 0 || msg;
} else {
return true;
}
@ -27,13 +27,13 @@ export class FormValidators {
* @param max
* @returns
*/
public static lengthRange(min: number, max: number, msg: string) {
public static lengthRange(min: number, max: number, msg: string = '长度不符合要求') {
return (val) => {
const tmp = String(val);
if (tmp === null || tmp === '' || (tmp.length >= min && tmp.length <= max)) {
return true;
} else {
return msg || '长度不符合要求(' + min + '-' + max + ')';
return msg + '(' + min + '-' + max + ')';
}
};
}
@ -43,7 +43,7 @@ export class FormValidators {
* @param precision
* @returns
*/
public static maxPrecision(precision: number, msg: string) {
public static maxPrecision(precision: number, msg: string = '最大允许输入的小数位:') {
return (val) => {
const tmp = String(val);
if (val === null || tmp === '' || tmp.indexOf('.') === -1 || tmp.substring(tmp.indexOf('.') + 1).length <= precision) {
@ -51,7 +51,7 @@ export class FormValidators {
} else if (precision === 0) {
return '只能输入整数';
} else {
return msg || '最大允许输入的小数位:' + precision;
return msg + precision;
}
};
}

2
io.sc.platform.core.frontend/src/platform/types/FormApiArgsType.ts

@ -28,7 +28,7 @@ export type ChangeEventArgsType = {
form: object;// form表单ref对象
};
export type CodeMirrorButtonClickEventArgsType = {
export type CodeMirrorButtonClickArgsType = {
value: any;// 组件更改后的值
form: object;// form表单ref对象
};

32
io.sc.platform.core.frontend/src/platform/types/ToolbarApiArgsType.ts

@ -1,35 +1,35 @@
export type ToolbarEnableIfArgsType = {
firstSelected: object;// 表格选中记录第一条
selected: Array<any>;// 表格选中记录
firstTicked: object;// 表格勾选记录第一条
ticked: Array<any>;// 表格勾选记录
selected: Array<any>;// 表格选中记录第一条
selecteds: object;// 表格选中记录
ticked: Array<any>;// 表格勾选记录第一条
tickeds: object;// 表格勾选记录
grid: object;// 表格ref对象
};
export type ToolbarBeforeClickArgsType = {
firstSelected: object;// 表格选中记录第一条
selected: Array<any>;// 表格选中记录
firstTicked: object;// 表格勾选记录第一条
ticked: Array<any>;// 表格勾选记录
selected: Array<any>;// 表格选中记录第一条
selecteds: object;// 表格选中记录
ticked: Array<any>;// 表格勾选记录第一条
tickeds: object;// 表格勾选记录
grid: object;// 表格ref对象
context: object;// beforeClick、click、afterClick事件上下文
};
export type ToolbarClickArgsType = {
firstSelected: object;// 表格选中记录第一条
selected: Array<any>;// 表格选中记录
firstTicked: object;// 表格勾选记录第一条
ticked: Array<any>;// 表格勾选记录
selected: Array<any>;// 表格选中记录第一条
selecteds: object;// 表格选中记录
ticked: Array<any>;// 表格勾选记录第一条
tickeds: object;// 表格勾选记录
grid: object;// 表格ref对象
_click: Function;// 内置按钮默认click事件的实现函数
context: object;// beforeClick、click、afterClick事件上下文
};
export type ToolbarAfterClickArgsType = {
firstSelected: object;// 表格选中记录第一条
selected: Array<any>;// 表格选中记录
firstTicked: object;// 表格勾选记录第一条
ticked: Array<any>;// 表格勾选记录
selected: Array<any>;// 表格选中记录第一条
selecteds: object;// 表格选中记录
ticked: Array<any>;// 表格勾选记录第一条
tickeds: object;// 表格勾选记录
grid: object;// 表格ref对象
context: object;// beforeClick、click、afterClick事件上下文
};
Loading…
Cancel
Save