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

This commit is contained in:
Xu Chang 2023-10-26 16:52:21 +08:00
commit 475cb7b976
4 changed files with 37 additions and 34 deletions

View File

@ -14,16 +14,20 @@ export default OakComponent({
objectId: 1,
filename: 1,
extra1: 1,
extra2: 1,
extension: 1,
type: 1,
entity: 1,
entityId: 1,
sort: 1,
applicationId: 1,
},
features: ['extraFile2'],
formData({ data: extraFiles, features }) {
const avatar = extraFiles?.filter(
(ele) => !ele.$$deleteAt$$ && ele.tag1 === 'avatar'
)[0];
const avatarUrl = features.extraFile.getUrl(
const avatarUrl = features.extraFile2.getUrl(
avatar as EntityDict['extraFile']['OpSchema']
);
return {
@ -44,8 +48,8 @@ export default OakComponent({
preview: true as boolean,
entity: '' as keyof EntityDict,
entityId: '' as string,
autoUpload: false,
},
methods: {
async onPickByMp() {
try {
@ -109,13 +113,14 @@ export default OakComponent({
size: number;
}) {
const { origin, type, tag1, avatar } = this.state;
const { entityId, entity } = this.props;
const { entityId, entity, autoUpload = false } = this.props;
const { name, extra1, fileType, size } = options;
const extension = name.substring(name.lastIndexOf('.') + 1);
const filename = name.substring(0, name.lastIndexOf('.'));
const applicationId = this.features.application.getApplicationId();
assert(entity, '必须传入entity');
const updateData = {
extra1,
applicationId,
origin,
type,
tag1,
@ -127,35 +132,25 @@ export default OakComponent({
fileType,
id: generateNewId(),
entityId,
sort: 1000,
} as EntityDict['extraFile']['CreateSingle']['data'];
// try {
// const { bucket } = await this.features.extraFile.upload(
// updateData
// );
// Object.assign(updateData, {
// bucket,
// extra1: null,
// });
// } catch (error) {
// //todo 保存extraFile失败 需要remove七牛图片
// throw error;
// }
this.addItem(Object.assign({}, updateData, {
extra1: null,
}), undefined, async () => {
await this.features.extraFile.upload(
updateData, extra1
)
});
if (avatar) {
this.removeItem(avatar.id as string);
}
// 如果entityId不存在, 说明是级联创建
if (entityId) {
await this.execute();
// 如果autoUpload
if (autoUpload) {
await this.features.extraFile2.autoUpload(
updateData as EntityDict['extraFile']['OpSchema'],
extra1
);
if (avatar) {
this.removeItem(avatar.id as string);
this.execute();
}
} else {
const id = this.addItem(updateData);
if (avatar) {
this.removeItem(avatar.id as string);
}
this.features.extraFile2.addLocalFile(id, extra1);
}
},
},

View File

@ -2,7 +2,7 @@
<view class="col">
<l-list title="头像">
<view slot="right-section" class="avatar">
<oak-extraFile-avatar oakAutoUnmount="{{true}}" oakPath="{{ oakFullpath ? oakFullpath + '.extraFile$entity' : undefined }}" entity="user" entityId="{{id}}"/>
<oak-extraFile-avatar oakAutoUnmount="{{true}}" oakPath="{{ oakFullpath ? oakFullpath + '.extraFile$entity' : undefined }}" entity="user" entityId="{{id}}" autoUpload="{{true}}"/>
</view>
</l-list>
<l-list title="昵称" data-attr="nickname" bind:lintap="setVisibleMp">

View File

@ -16,6 +16,7 @@ import { WebComponentProps } from 'oak-frontend-base';
import { EntityDict } from '../../../oak-app-domain';
import PageHeader from '../../../components/common/pageHeader';
import OakAvatar from '../../../components/extraFile/avatar';
import ExtraFileCommit from '../../../components/extraFile/commit';
import MobileLogin from '../../../pages/mobile/login';
import WechatLoginQrCode from '../../../components/wechatLogin/qrCode';
import WechatUserList from '../../../components/wechatUser/bindingList';
@ -203,7 +204,7 @@ export default function Render(
}}
>
<Space>
<Button
{/* <Button
disabled={oakExecuting || !oakDirty}
type="primary"
onClick={() => {
@ -211,7 +212,13 @@ export default function Render(
}}
>
</Button>
</Button> */}
<ExtraFileCommit
oakPath={oakFullpath}
efPaths={[
'extraFile$entity',
]}
/>
</Space>
</Form.Item>
</Form>

View File

@ -88,6 +88,7 @@ export default function render(
}
entity="user"
entityId={id}
autoUpload={true}
/>
</div>
}