Merge branch 'dev' of codeup.aliyun.com:61c14a7efa282c88e103c23f/oak-general-business into dev

This commit is contained in:
qsc 2023-10-25 12:21:41 +08:00
commit 6833edab1e
4 changed files with 35 additions and 21 deletions

View File

@ -30,7 +30,7 @@ export default OakComponent({
beforeCommit: (() => true),
},
methods: {
getEfIds() {
getEfIds(strict) {
const { efPaths } = this.props;
const { oakFullpath } = this.state;
assert(efPaths && efPaths.length > 0);
@ -41,8 +41,10 @@ export default OakComponent({
? `${oakFullpath}.${path}`
: oakFullpath;
const data = this.features.runningTree.getFreshValue(path2);
assert(data, `efPath为${path}的路径上取不到extraFile数据请设置正确的相对路径`);
return data.map((ele) => ele.id);
if (strict) {
assert(data, `efPath为${path}的路径上取不到extraFile数据请设置正确的相对路径`);
}
return data?.map((ele) => ele.id);
})
.flat()
.filter((ele) => !!ele);
@ -51,8 +53,10 @@ export default OakComponent({
return [];
},
async upload() {
const ids = this.getEfIds();
assert(ids.length > 0);
const ids = this.getEfIds(true);
if (ids.length === 0) {
return;
}
const promises = [];
ids.forEach((id) => {
const fileState = this.features.extraFile2.getFileState(id);

View File

@ -18,7 +18,8 @@ export default function render(props) {
text = t('upload');
}
}
return (_jsx(Button, { type: type, size: size, block: block, disabled: disabled, onClick: async () => {
return (_jsx(Button, {
type: type, size: size, block: block, disabled: disabled, onClick: async () => {
if (oakExecutable) {
if (beforeCommit) {
const beforeCommitResult = await beforeCommit();
@ -38,5 +39,6 @@ export default function render(props) {
afterCommit();
}
}
}, ...buttonProps, children: text }));
}, ...buttonProps, children: text
}));
}

View File

@ -33,7 +33,7 @@ exports.default = OakComponent({
beforeCommit: (() => true),
},
methods: {
getEfIds() {
getEfIds(strict) {
const { efPaths } = this.props;
const { oakFullpath } = this.state;
(0, assert_1.default)(efPaths && efPaths.length > 0);
@ -44,8 +44,10 @@ exports.default = OakComponent({
? `${oakFullpath}.${path}`
: oakFullpath;
const data = this.features.runningTree.getFreshValue(path2);
(0, assert_1.default)(data, `efPath为${path}的路径上取不到extraFile数据请设置正确的相对路径`);
return data.map((ele) => ele.id);
if (strict) {
(0, assert_1.default)(data, `efPath为${path}的路径上取不到extraFile数据请设置正确的相对路径`);
}
return data?.map((ele) => ele.id);
})
.flat()
.filter((ele) => !!ele);
@ -54,8 +56,10 @@ exports.default = OakComponent({
return [];
},
async upload() {
const ids = this.getEfIds();
(0, assert_1.default)(ids.length > 0);
const ids = this.getEfIds(true);
if (ids.length === 0) {
return;
}
const promises = [];
ids.forEach((id) => {
const fileState = this.features.extraFile2.getFileState(id);

View File

@ -29,11 +29,11 @@ export default OakComponent({
type: 'primary',
executeText: '',
buttonProps: {},
afterCommit: () => {},
afterCommit: () => { },
beforeCommit: (() => true) as () => boolean | undefined | Promise<boolean | undefined>,
},
methods: {
getEfIds() {
getEfIds(strict?: boolean) {
const { efPaths } = this.props;
const { oakFullpath } = this.state;
assert(efPaths && efPaths.length > 0);
@ -45,13 +45,15 @@ export default OakComponent({
: oakFullpath;
const data =
this.features.runningTree.getFreshValue(path2);
assert(
data,
`efPath为${path}的路径上取不到extraFile数据请设置正确的相对路径`
);
if (strict) {
assert(
data,
`efPath为${path}的路径上取不到extraFile数据请设置正确的相对路径`
);
}
return (
data as EntityDict['extraFile']['OpSchema'][]
).map((ele) => ele.id);
)?.map((ele) => ele.id);
})
.flat()
.filter((ele) => !!ele) as string[];
@ -60,8 +62,10 @@ export default OakComponent({
return [];
},
async upload() {
const ids = this.getEfIds();
assert(ids.length > 0);
const ids = this.getEfIds(true);
if (ids.length === 0) {
return;
}
const promises: Promise<void>[] = [];
ids.forEach((id) => {