This commit is contained in:
parent
bf8f86fb33
commit
ca4fd42c14
|
|
@ -75,16 +75,16 @@ export default OakPage({
|
|||
],
|
||||
isList: true,
|
||||
formData: async function ({ data: users, props, features }) {
|
||||
const { entity } = props;
|
||||
const { entity, entityId } = props;
|
||||
const entityStr = firstLetterUpperCase(entity!);
|
||||
const filter = await this.getFilterByName('name');
|
||||
return {
|
||||
users: users?.map((ele: any) => {
|
||||
const { mobile$user, extraFile$entity } = ele || {};
|
||||
const mobile = mobile$user && mobile$user[0]?.mobile;
|
||||
const relations = ele[`user${entityStr}$user`]?.map(
|
||||
(ele) => ele.relation
|
||||
);
|
||||
const relations = ele[`user${entityStr}$user`]
|
||||
?.filter((ele) => ele[`${entity}Id`] === entityId)
|
||||
.map((ele) => ele.relation);
|
||||
const avatar =
|
||||
extraFile$entity &&
|
||||
extraFile$entity[0] &&
|
||||
|
|
@ -96,6 +96,10 @@ export default OakPage({
|
|||
});
|
||||
return user2;
|
||||
}),
|
||||
searchValue:
|
||||
filter?.$or &&
|
||||
(filter.$or as [{ name: { $includes: string } }])[0]?.name
|
||||
.$includes,
|
||||
};
|
||||
},
|
||||
properties: {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
"t-switch": "../../../miniprogram_npm/tdesign/switch/switch",
|
||||
"t-cell": "../../../miniprogram_npm/tdesign/cell/cell",
|
||||
"t-search": "../../../miniprogram_npm/tdesign/search/search",
|
||||
"t-image": "../../../miniprogram_npm/tdesign/image/image",
|
||||
"t-button-group": "../../../miniprogram_npm/tdesign/button-group/button-group"
|
||||
}
|
||||
}
|
||||
|
|
@ -20,27 +20,13 @@ page {
|
|||
|
||||
.search-bar {
|
||||
background-color: #fff;
|
||||
padding-top: 10rpx;
|
||||
padding-bottom: 10rpx;
|
||||
padding: 10rpx;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.card-view {
|
||||
margin: @spacer;
|
||||
margin-bottom: 0rpx;
|
||||
padding: @spacer;
|
||||
border-radius: 4rpx;
|
||||
.description {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
box-shadow: 0 4rpx 20rpx 0 rgba(212, 217, 223, 0.5);
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.row {
|
||||
margin-left: @spacer;
|
||||
display: flex;
|
||||
flex: 1;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.col {
|
||||
|
|
@ -49,21 +35,27 @@ page {
|
|||
flex-direction: column;
|
||||
}
|
||||
|
||||
.nickname {
|
||||
margin-bottom: 8rpx;
|
||||
.name {
|
||||
font-size: @font-size-base;
|
||||
}
|
||||
.mobile {
|
||||
font-size: @font-size-base;
|
||||
color: @text-level-3-color;
|
||||
}
|
||||
.avatar {
|
||||
height: 140rpx;
|
||||
width: 140rpx;
|
||||
border-radius: 50%;
|
||||
color: @text-level-2-color;
|
||||
}
|
||||
|
||||
.content {
|
||||
.mobile {
|
||||
font-size: @font-size-base;
|
||||
color: @text-level-2-color;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
height: 160rpx;
|
||||
width: 160rpx;
|
||||
}
|
||||
|
||||
.relation {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.relation-content {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: row;
|
||||
|
|
@ -82,13 +74,12 @@ page {
|
|||
|
||||
.btn-container {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
bottom: constant(safe-area-inset-bottom) !important;
|
||||
/* 兼容 iOS < 11.2 */
|
||||
bottom: env(safe-area-inset-bottom) !important;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
width: 100%;
|
||||
.btn {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.btn-search {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ export default OakPage(
|
|||
path: 'userRelation:list',
|
||||
entity: 'user',
|
||||
projection: async ({ props }) => {
|
||||
const { entity } = props;
|
||||
const { entity, relations, entityId } = props;
|
||||
const entityStr = firstLetterUpperCase(entity!);
|
||||
return {
|
||||
id: 1,
|
||||
|
|
@ -30,10 +30,10 @@ export default OakPage(
|
|||
},
|
||||
filter: {
|
||||
relation: {
|
||||
$in: props.relations!,
|
||||
$in: relations!,
|
||||
},
|
||||
[`${entity}Id`]: props.entityId!,
|
||||
}
|
||||
[`${entity}Id`]: entityId!,
|
||||
},
|
||||
},
|
||||
extraFile$entity: {
|
||||
$entity: 'extraFile',
|
||||
|
|
@ -68,16 +68,19 @@ export default OakPage(
|
|||
|
||||
return {
|
||||
users: users?.map((ele: any) => {
|
||||
const { mobile$user, extraFile$entity } =
|
||||
ele || {};
|
||||
const { mobile$user, extraFile$entity } = ele || {};
|
||||
const userEntity = ele![`user${entityStr}$user`];
|
||||
const mobile = mobile$user && mobile$user[0]?.mobile;
|
||||
const avatar =
|
||||
extraFile$entity &&
|
||||
extraFile$entity[0] &&
|
||||
composeFileUrl(extraFile$entity[0]);
|
||||
const relations = userEntity?.map((ele: any) => ele.relation);
|
||||
const hasRelation: boolean[] = this.props.relations.map(ele2 => relations.includes(ele2));
|
||||
const relations = userEntity?.map(
|
||||
(ele: any) => ele.relation
|
||||
);
|
||||
const hasRelation: boolean[] = props.relations?.map(
|
||||
(ele2) => relations.includes(ele2)
|
||||
);
|
||||
const user2 = Object.assign({}, ele, {
|
||||
mobile,
|
||||
avatar,
|
||||
|
|
@ -86,9 +89,10 @@ export default OakPage(
|
|||
});
|
||||
return user2;
|
||||
}),
|
||||
searchValue: (
|
||||
filter?.$or as [{ name: { $includes: string } }]
|
||||
)[0].name.$includes,
|
||||
searchValue:
|
||||
filter?.$or &&
|
||||
(filter.$or as [{ name: { $includes: string } }])[0]?.name
|
||||
.$includes,
|
||||
};
|
||||
},
|
||||
properties: {
|
||||
|
|
|
|||
|
|
@ -1,47 +1,39 @@
|
|||
<!-- index.wxml -->
|
||||
<view class="container">
|
||||
<view class="search-bar">
|
||||
<t-search style="width: 100%; margin: auto 0rpx" placeholder="搜索" shape="round" value="{{searchValue}}" bind:change="searchChange" bind:submit="searchConfirm" bind:clear="searchCancel" />
|
||||
<t-search placeholder="搜索" shape="round" value="{{searchValue}}" bind:change="searchChange" bind:submit="searchConfirm" bind:clear="searchCancel" />
|
||||
</view>
|
||||
<block wx:if="{{ users && users.length > 0 }}">
|
||||
<block wx:for="{{users}}" wx:for-index="index" wx:for-item="item" wx:key="idx">
|
||||
<view class="card-view">
|
||||
<block wx:if="{{item.avatar}}">
|
||||
<image class="avatar" src="{{item.avatar}}" mode="aspectFit" />
|
||||
</block>
|
||||
<block wx:else>
|
||||
<view class="img-view">
|
||||
<t-icon name="user-avatar" size="59px" />
|
||||
</view>
|
||||
</block>
|
||||
<view class="row">
|
||||
<view class="col">
|
||||
<text class="nickname">{{item.nickname || '未设置'}}</text>
|
||||
<text class="mobile">姓名: {{item.name || '未设置'}}</text>
|
||||
<text class="mobile">手机: {{item.mobile || '未设置'}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<block wx:if="{{relations.length === 1}}">
|
||||
<view slot="more">
|
||||
<t-switch value="{{item.hasRelation[0]}}" bind:change="onChange" data-id="{{item.id}}" data-relation="{{relations[0]}}" data-index="{{index}}" />
|
||||
</view>
|
||||
</block>
|
||||
<block wx:else>
|
||||
<t-divider />
|
||||
<view class="content">
|
||||
<block wx:for="{{relations}}" wx:key="idx" wx:for-index="index2" wx:for-item="relation">
|
||||
<view class="relation-item">
|
||||
<view>
|
||||
<text>{{relation}}</text>
|
||||
</view>
|
||||
<view>
|
||||
<t-switch value="{{item.hasRelation[index2]}}" bind:change="onChange" data-id="{{item.id}}" data-relation="{{relation}}" data-index="{{index}}" />
|
||||
</view>
|
||||
<t-cell title="{{item.nickname}}">
|
||||
<t-image slot="left-icon" t-class="avatar" src="{{item.avatar}}" mode="aspectFit" shape="circle"></t-image>
|
||||
<view slot="description" class="description">
|
||||
<text class="name">姓名: {{item.name || '未设置'}}</text>
|
||||
<text class="mobile">手机: {{item.mobile || '未设置'}}</text>
|
||||
<view class="relation">
|
||||
<block wx:if="{{relations.length === 1}}">
|
||||
<view slot="more">
|
||||
<t-switch value="{{item.hasRelation[0]}}" bind:change="onChange" data-id="{{item.id}}" data-relation="{{relations[0]}}" data-index="{{index}}" />
|
||||
</view>
|
||||
</block>
|
||||
<block wx:else>
|
||||
<t-divider />
|
||||
<view class="relation-content">
|
||||
<block wx:for="{{relations}}" wx:key="idx" wx:for-index="index2" wx:for-item="relation">
|
||||
<view class="relation-item">
|
||||
<view>
|
||||
<text>{{t(entity + ':r.' + relation)}}</text>
|
||||
</view>
|
||||
<view>
|
||||
<t-switch value="{{item.hasRelation[index2]}}" bind:change="onChange" data-id="{{item.id}}" data-relation="{{relation}}" data-index="{{index}}" />
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
</t-cell>
|
||||
</block>
|
||||
<t-button-group class="btn-container">
|
||||
<t-button icon="search" theme="primary" style="margin: 16rpx" block size="large" bind:tap="goSearchUser" content="搜索人员" />
|
||||
|
|
@ -50,7 +42,7 @@
|
|||
</block>
|
||||
<block wx:else>
|
||||
<view class="btn-search">
|
||||
<t-button theme="primary" style="margin: 16rpx" block size="medium" bind:tap="goSearchUser" content="搜索人员" />
|
||||
<t-button theme="primary" style="margin: 16rpx" size="medium" bind:tap="goSearchUser" content="搜索人员" />
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
Loading…
Reference in New Issue