extracommit 临时代码
This commit is contained in:
parent
3004a5a6aa
commit
87b8bf9d4f
|
|
@ -8,8 +8,7 @@ export default OakComponent({
|
||||||
if (ele) {
|
if (ele) {
|
||||||
if (['failed', 'local'].includes(ele.state)) {
|
if (['failed', 'local'].includes(ele.state)) {
|
||||||
state = ele.state;
|
state = ele.state;
|
||||||
}
|
} else if (ele.state === 'uploading' && state === 'uploaded') {
|
||||||
else if (ele.state === 'uploading' && state === 'uploaded') {
|
|
||||||
state = 'uploading';
|
state = 'uploading';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -26,12 +25,16 @@ export default OakComponent({
|
||||||
executeText: '',
|
executeText: '',
|
||||||
buttonProps: {},
|
buttonProps: {},
|
||||||
afterCommit: () => {},
|
afterCommit: () => {},
|
||||||
beforeCommit: (() => true),
|
beforeCommit: () => true,
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getEfIds() {
|
getEfIds() {
|
||||||
const entity = this.features.runningTree.getEntity(this.state.oakFullpath);
|
const entity = this.features.runningTree.getEntity(
|
||||||
const value = this.features.runningTree.getFreshValue(this.state.oakFullpath);
|
this.state.oakFullpath
|
||||||
|
);
|
||||||
|
const value = this.features.runningTree.getFreshValue(
|
||||||
|
this.state.oakFullpath
|
||||||
|
);
|
||||||
const efIds = [];
|
const efIds = [];
|
||||||
const getRecursive = (e, v) => {
|
const getRecursive = (e, v) => {
|
||||||
for (const attr in v) {
|
for (const attr in v) {
|
||||||
|
|
@ -41,28 +44,23 @@ export default OakComponent({
|
||||||
if (attr === 'extraFile') {
|
if (attr === 'extraFile') {
|
||||||
assert(v[attr].id);
|
assert(v[attr].id);
|
||||||
efIds.push(v[attr].id);
|
efIds.push(v[attr].id);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
getRecursive(attr, v[attr]);
|
getRecursive(attr, v[attr]);
|
||||||
}
|
}
|
||||||
}
|
} else if (typeof rel === 'string') {
|
||||||
else if (typeof rel === 'string') {
|
|
||||||
assert(typeof v[attr] === 'object');
|
assert(typeof v[attr] === 'object');
|
||||||
if (rel === 'extraFile') {
|
if (rel === 'extraFile') {
|
||||||
assert(v[attr].id);
|
assert(v[attr].id);
|
||||||
efIds.push(v[attr].id);
|
efIds.push(v[attr].id);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
getRecursive(rel, v[attr]);
|
getRecursive(rel, v[attr]);
|
||||||
}
|
}
|
||||||
}
|
} else if (rel instanceof Array) {
|
||||||
else if (rel instanceof Array) {
|
|
||||||
assert(v[attr] instanceof Array);
|
assert(v[attr] instanceof Array);
|
||||||
const [e2, fk2] = rel;
|
const [e2, fk2] = rel;
|
||||||
if (e2 === 'extraFile') {
|
if (e2 === 'extraFile') {
|
||||||
efIds.push(...v[attr].map((ele) => ele.id));
|
efIds.push(...v[attr].map((ele) => ele.id));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
v[attr].forEach((ele) => getRecursive(e2, ele));
|
v[attr].forEach((ele) => getRecursive(e2, ele));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -71,10 +69,13 @@ export default OakComponent({
|
||||||
if (value instanceof Array) {
|
if (value instanceof Array) {
|
||||||
value.forEach((ele) => getRecursive(entity, ele));
|
value.forEach((ele) => getRecursive(entity, ele));
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
getRecursive(entity, value);
|
getRecursive(entity, value);
|
||||||
|
}
|
||||||
|
|
||||||
return efIds;
|
return efIds;
|
||||||
},
|
},
|
||||||
async upload() {
|
async upload(ids) {
|
||||||
const ids = this.getEfIds();
|
const ids = this.getEfIds();
|
||||||
if (ids.length === 0) {
|
if (ids.length === 0) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -96,6 +97,7 @@ export default OakComponent({
|
||||||
async onSubmit() {
|
async onSubmit() {
|
||||||
const { oakExecutable } = this.state;
|
const { oakExecutable } = this.state;
|
||||||
const { beforeCommit, afterCommit, action } = this.props;
|
const { beforeCommit, afterCommit, action } = this.props;
|
||||||
|
const ids = this.getEfIds();
|
||||||
if (oakExecutable) {
|
if (oakExecutable) {
|
||||||
if (beforeCommit) {
|
if (beforeCommit) {
|
||||||
const beforeCommitResult = await beforeCommit();
|
const beforeCommitResult = await beforeCommit();
|
||||||
|
|
@ -104,13 +106,12 @@ export default OakComponent({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await this.execute(action || undefined);
|
await this.execute(action || undefined);
|
||||||
await this.upload();
|
await this.upload(ids);
|
||||||
if (afterCommit) {
|
if (afterCommit) {
|
||||||
afterCommit();
|
afterCommit();
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
await this.upload(ids);
|
||||||
await this.upload();
|
|
||||||
if (afterCommit) {
|
if (afterCommit) {
|
||||||
afterCommit();
|
afterCommit();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -87,12 +87,12 @@ export default OakComponent({
|
||||||
|
|
||||||
if (value instanceof Array) {
|
if (value instanceof Array) {
|
||||||
value.forEach((ele) => getRecursive(entity, ele));
|
value.forEach((ele) => getRecursive(entity, ele));
|
||||||
}
|
} else {
|
||||||
getRecursive(entity, value as any);
|
getRecursive(entity, value as any);
|
||||||
|
}
|
||||||
return efIds;
|
return efIds;
|
||||||
},
|
},
|
||||||
async upload() {
|
async upload(ids: string[]) {
|
||||||
const ids = this.getEfIds();
|
|
||||||
if (ids.length === 0) {
|
if (ids.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -115,6 +115,8 @@ export default OakComponent({
|
||||||
async onSubmit() {
|
async onSubmit() {
|
||||||
const { oakExecutable } = this.state;
|
const { oakExecutable } = this.state;
|
||||||
const { beforeCommit, afterCommit, action } = this.props;
|
const { beforeCommit, afterCommit, action } = this.props;
|
||||||
|
const ids = this.getEfIds();
|
||||||
|
|
||||||
if (oakExecutable) {
|
if (oakExecutable) {
|
||||||
if (beforeCommit) {
|
if (beforeCommit) {
|
||||||
const beforeCommitResult = await beforeCommit();
|
const beforeCommitResult = await beforeCommit();
|
||||||
|
|
@ -122,13 +124,14 @@ export default OakComponent({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.execute(action || undefined);
|
await this.execute(action || undefined);
|
||||||
await this.upload();
|
await this.upload(ids);
|
||||||
if (afterCommit) {
|
if (afterCommit) {
|
||||||
afterCommit();
|
afterCommit();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
await this.upload();
|
await this.upload(ids);
|
||||||
if (afterCommit) {
|
if (afterCommit) {
|
||||||
afterCommit();
|
afterCommit();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue