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

View File

@ -2,7 +2,7 @@
<view class="col"> <view class="col">
<l-list title="头像"> <l-list title="头像">
<view slot="right-section" class="avatar"> <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> </view>
</l-list> </l-list>
<l-list title="昵称" data-attr="nickname" bind:lintap="setVisibleMp"> <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 { EntityDict } from '../../../oak-app-domain';
import PageHeader from '../../../components/common/pageHeader'; import PageHeader from '../../../components/common/pageHeader';
import OakAvatar from '../../../components/extraFile/avatar'; import OakAvatar from '../../../components/extraFile/avatar';
import ExtraFileCommit from '../../../components/extraFile/commit';
import MobileLogin from '../../../pages/mobile/login'; import MobileLogin from '../../../pages/mobile/login';
import WechatLoginQrCode from '../../../components/wechatLogin/qrCode'; import WechatLoginQrCode from '../../../components/wechatLogin/qrCode';
import WechatUserList from '../../../components/wechatUser/bindingList'; import WechatUserList from '../../../components/wechatUser/bindingList';
@ -203,7 +204,7 @@ export default function Render(
}} }}
> >
<Space> <Space>
<Button {/* <Button
disabled={oakExecuting || !oakDirty} disabled={oakExecuting || !oakDirty}
type="primary" type="primary"
onClick={() => { onClick={() => {
@ -211,7 +212,13 @@ export default function Render(
}} }}
> >
</Button> </Button> */}
<ExtraFileCommit
oakPath={oakFullpath}
efPaths={[
'extraFile$entity',
]}
/>
</Space> </Space>
</Form.Item> </Form.Item>
</Form> </Form>

View File

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