extraFile avatar调整
This commit is contained in:
parent
1d3d0d3842
commit
e4186f613b
|
|
@ -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);
|
||||
}
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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">
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ export default function render(
|
|||
}
|
||||
entity="user"
|
||||
entityId={id}
|
||||
autoUpload={true}
|
||||
/>
|
||||
</div>
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue