This commit is contained in:
梁朝伟 2022-05-26 17:44:05 +08:00
parent 3d190c7476
commit 3c5b9e86a5
12 changed files with 71 additions and 67 deletions

View File

@ -3,5 +3,8 @@ import { Feature } from 'oak-frontend-base';
import { Aspect, Context, DeduceCreateOperationData } from 'oak-domain/lib/types'; import { Aspect, Context, DeduceCreateOperationData } from 'oak-domain/lib/types';
export declare class ExtraFile<ED extends EntityDict, Cxt extends Context<ED>, AD extends Record<string, Aspect<ED, Cxt>>> extends Feature<ED, Cxt, AD> { export declare class ExtraFile<ED extends EntityDict, Cxt extends Context<ED>, AD extends Record<string, Aspect<ED, Cxt>>> extends Feature<ED, Cxt, AD> {
constructor(); constructor();
upload(extraFile: DeduceCreateOperationData<ED['extraFile']['Schema']>, scene: string): Promise<any>; upload(extraFile: DeduceCreateOperationData<ED['extraFile']['Schema']>, scene: string): Promise<{
url: string;
bucket: string;
}>;
} }

View File

@ -8,16 +8,18 @@ const triggers = [
when: 'before', when: 'before',
fn: async ({ operation }, context, params) => { fn: async ({ operation }, context, params) => {
const { data, filter } = operation; const { data, filter } = operation;
const { result } = await context.rowStore.select('userEntityGrant', { // const { result } = await context.rowStore.select('userEntityGrant', {
data: Object.assign({ // data: Object.assign({
iState: 1 // id: 1,
}, data), // iState: 1
filter: { // }, data),
iState: 'init', // filter: {
}, // iState: 'init',
indexFrom: 0, // },
count: 1, // indexFrom: 0,
}, context, params); // count: 1,
// }, context, params);
return 0;
} }
}, },
]; ];

View File

@ -1,9 +1,12 @@
import { EntityDict } from 'oak-app-domain/EntityDict'; import { EntityDict } from 'oak-app-domain/EntityDict';
import { CreateTriggerInTxn, Trigger } from 'oak-domain/lib/types/Trigger'; import { CreateTriggerInTxn, Trigger } from 'oak-domain/lib/types/Trigger';
import { GeneralRuntimeContext } from '../RuntimeContext'; import { GeneralRuntimeContext } from '../RuntimeContext';
import { CreateOperationData as CreateUserEntityGrantData } from 'oak-app-domain/UserEntityGrant/Schema';
import { assign } from "lodash"; import { assign, keys } from 'lodash';
import { OakRowInconsistencyException } from 'oak-domain/lib/types'; import { OakRowInconsistencyException } from 'oak-domain/lib/types';
import assert from 'assert';
import { OpRecord } from '../../../oak-domain/src/types/Entity';
const triggers: Trigger<EntityDict, 'userEntityGrant', GeneralRuntimeContext<EntityDict>>[] = [ const triggers: Trigger<EntityDict, 'userEntityGrant', GeneralRuntimeContext<EntityDict>>[] = [
{ {
name: '当创建userEntityGrant时,查询是否有未过期的实体', name: '当创建userEntityGrant时,查询是否有未过期的实体',
@ -12,16 +15,37 @@ const triggers: Trigger<EntityDict, 'userEntityGrant', GeneralRuntimeContext<Ent
when: 'before', when: 'before',
fn: async ({ operation }, context, params) => { fn: async ({ operation }, context, params) => {
const { data, filter } = operation; const { data, filter } = operation;
const { result } = await context.rowStore.select('userEntityGrant', { const fn = async (userEntityGrantData: CreateUserEntityGrantData) => {
data: Object.assign({ const { action, entity, entityId, relation} = userEntityGrantData;
iState: 1 const { result } = await context.rowStore.select('userEntityGrant', {
}, data), data: {
filter: { id: 1,
iState: 'init', action: 1,
entity: 1,
entityId: 1,
relation: 1,
},
filter: {
iState: 'init',
action,
entity,
entityId,
relation,
}, },
indexFrom: 0, indexFrom: 0,
count: 1, count: 1,
}, context, params); }, context, params);
if (result.length) {
throw new OakRowInconsistencyException(result[0] as any, '该userEntityGrant未过期');
}
}
if (data instanceof Array) {
assert('授权不存在一对多的情况')
}
else {
fn(data)
}
return 0;
} }
}, },
]; ];

View File

@ -1,5 +1,5 @@
{ {
"navigationBarTitleText": "添加权限", "navigationBarTitleText": "二维码",
"usingComponents": { "usingComponents": {
"g-btn": "../../../components/UI/g-btn/index", "g-btn": "../../../components/UI/g-btn/index",
"g-input": "../../../components/UI/g-input/index", "g-input": "../../../components/UI/g-input/index",

View File

@ -11,16 +11,8 @@
box-sizing: border-box; box-sizing: border-box;
.safe-area-inset-bottom(); .safe-area-inset-bottom();
} }
.label { .col {
display: flex;
align-items: center;
padding: @size-spacing-base;
border-bottom: 1px solid @background-color-base;
}
.cell-col {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
background-color: #fff; align-items: center;
border-top: 1px solid @background-color-base
} }

View File

@ -38,36 +38,15 @@ OakPage({
...userEntityGrant, ...userEntityGrant,
}), }),
}, { }, {
properties: {
entity: String,
entityId: String,
relations: String,
},
data: { data: {
}, },
lifetimes: { lifetimes: {
ready(options) { ready(options) {
this.data.entity && this.setUpdateData('entity', this.data.entity);
this.data.entityId && this.setUpdateData('entityId', this.data.entityId);
this.setUpdateData('action', 'grant');
this.setData({
relationArr: JSON.parse(this.data.relations),
})
if (!this.data.wechatQrCode$entity[0] || this.data.wechatQrCode$entity[0].expiresAt) { if (!this.data.wechatQrCode$entity[0] || this.data.wechatQrCode$entity[0].expiresAt) {
//请求创建wechatQrcode //请求创建wechatQrcode
// const result = await requestWechatQrcode();
this.setData({
url: result.url,
})
} }
} }
}, },
methods: { methods: {
radioChange(e) {
this.setUpdateData('relation', e.detail.value);
},
requestWechatQrcode() {
}
} }
}); });

View File

@ -0,0 +1,6 @@
<!-- index.wxml -->
<view class="page-body">
<view class="col">
<image src="{{url}}" />
</view>
</view>

View File

@ -38,6 +38,18 @@ OakPage({
methods: { methods: {
radioChange(e) { radioChange(e) {
this.setUpdateData('relation', e.detail.value); this.setUpdateData('relation', e.detail.value);
},
handleConfirm() {
try {
this.execute(
this.data.oakId ? 'update' : 'create',
() => {
}
);
}
catch (error) {
console.log(error);
}
} }
} }
}); });

View File

@ -4,11 +4,11 @@
<radio-group bindchange="radioChange" class="test"> <radio-group bindchange="radioChange" class="test">
<label class="label" wx:for="{{relationArr}}" wx:key="*this"> <label class="label" wx:for="{{relationArr}}" wx:key="*this">
<view> <view>
<radio value="{{item}}" checked="true" /> <radio value="{{item}}" />
</view> </view>
<view>{{item}}</view> <view>{{item}}</view>
</label> </label>
</radio-group> </radio-group>
</view> </view>
<g-btn type="primary">确定</g-btn> <g-btn type="primary" bind:click="handleConfirm">确定</g-btn>
</view> </view>

View File

@ -1,14 +0,0 @@
<!-- index.wxml -->
<view class="page-body">
<view class="cell-col">
<radio-group bindchange="radioChange" class="test">
<label class="label" wx:for="{{relationArr}}" wx:key="*this">
<view>
<radio value="{{item}}" checked="true" />
</view>
<view>{{item}}</view>
</label>
</radio-group>
</view>
<g-btn type="primary">确定</g-btn>
</view>