This commit is contained in:
pengxiaolong
2025-05-13 19:39:53 +08:00
parent 37da6765b8
commit c006a8e63d
1232 changed files with 96963 additions and 883 deletions

View File

@@ -0,0 +1,2 @@
import Transfer from './index.vue';
export default Transfer;

View File

@@ -0,0 +1,332 @@
<template>
<div
class="transfer"
:class="[!isPC ? 'transfer-h5' : '', isWeChat ? 'transfer-h5-wechat' : '']"
>
<header
v-if="!isPC"
class="transfer-header transfer-h5-header"
>
<div
v-if="!props.isHiddenBackIcon"
@click="cancel"
>
<Icon
class="icon"
:file="backIcon"
:width="'18px'"
:height="'18px'"
/>
</div>
<span class="title">{{ transferTitle }}</span>
<span class="space" />
</header>
<main class="main">
<div class="left">
<header class="transfer-header">
<!-- PC triggers @keyup.enter -->
<input
v-if="isPC && isTransferSearch"
type="text"
:value="searchValue"
:placeholder="TUITranslateService.t('component.请输入userID')"
enterkeyhint="search"
:class="[isUniFrameWork ? 'left-uniapp-input' : '']"
@keyup.enter="handleInput"
>
<!-- not PC triggers blur -->
<input
v-if="!isPC && isTransferSearch"
type="text"
:placeholder="TUITranslateService.t('component.请输入userID')"
enterkeyhint="search"
:value="searchValue"
:class="[isUniFrameWork ? 'left-uniapp-input' : '']"
@blur="handleInput"
@confirm="handleInput"
>
</header>
<main class="transfer-left-main">
<ul class="transfer-list">
<li
v-if="optional.length > 1 && !isRadio"
class="transfer-list-item"
@click="selectedAll"
>
<Icon
v-if="transferSelectedList.length === optional.length"
:file="selectedIcon"
:width="'18px'"
:height="'18px'"
/>
<i
v-else
class="icon-unselected"
/>
<span class="select-all">{{
TUITranslateService.t("component.全选")
}}</span>
</li>
<li
v-for="item in transferList"
:key="item.userID"
class="transfer-list-item"
@click="selected(item)"
>
<Icon
v-if="transferSelectedList.indexOf(item) > -1"
:file="selectedIcon"
:class="[item.isDisabled && 'disabled']"
:width="'18px'"
:height="'18px'"
/>
<i
v-else
:class="[item.isDisabled && 'disabled', 'icon-unselected']"
/>
<template v-if="!isTransferCustomItem">
<img
class="avatar"
:src="
item.avatar ||
'https://web.sdk.qcloud.com/component/TUIKit/assets/avatar_21.png'
"
onerror="this.onerror=null;this.src='https://web.sdk.qcloud.com/component/TUIKit/assets/avatar_21.png'"
>
<span class="name">{{ item.nick || item.userID }}</span>
<span v-if="item.isDisabled">{{ TUITranslateService.t("component.已在群中") }}</span>
</template>
<template v-else>
<slot
name="left"
:data="item"
/>
</template>
</li>
<li
v-if="transferTotal > transferList.length"
class="transfer-list-item more"
@click="getMore"
>
{{ TUITranslateService.t("component.查看更多") }}
</li>
</ul>
</main>
</div>
<div class="right">
<header
v-if="isPC"
class="transfer-header"
>
{{ transferTitle }}
</header>
<ul
v-if="resultShow"
class="transfer-list"
>
<p
v-if="transferSelectedList.length > 0 && isPC"
class="transfer-text"
>
{{ TUITranslateService.t("component.已选中")
}}{{ transferSelectedList.length
}}{{ TUITranslateService.t("component.人") }}
</p>
<li
v-for="(item, index) in transferSelectedList"
:key="index"
class="transfer-list-item space-between"
>
<aside class="transfer-list-item-content">
<template v-if="!isTransferCustomItem">
<img
class="avatar"
:src="
item.avatar ||
'https://web.sdk.qcloud.com/component/TUIKit/assets/avatar_21.png'
"
onerror="this.onerror=null;this.src='https://web.sdk.qcloud.com/component/TUIKit/assets/avatar_21.png'"
>
<span
v-if="isPC"
class="name"
>{{ item.nick || item.userID }}</span>
</template>
<template v-else>
<slot
name="right"
:data="item"
/>
</template>
</aside>
<span
v-if="isPC"
@click="selected(item)"
>
<Icon
:file="cancelIcon"
:width="'18px'"
:height="'18px'"
/>
</span>
</li>
</ul>
<footer class="transfer-right-footer">
<button
class="btn btn-cancel"
@click="cancel"
>
{{ TUITranslateService.t("component.取消") }}
</button>
<button
v-if="transferSelectedList.length > 0"
class="btn"
@click="submit"
>
{{ TUITranslateService.t("component.完成") }}
</button>
<button
v-else
class="btn btn-no"
@click="submit"
>
{{ TUITranslateService.t("component.完成") }}
</button>
</footer>
</div>
</main>
</div>
</template>
<script lang="ts" setup>
import { ref, watchEffect, computed } from '../../../adapter-vue';
import { TUITranslateService } from '@tencentcloud/chat-uikit-engine';
import { ITransferListItem } from '../../../interface';
import Icon from '../Icon.vue';
import selectedIcon from '../../../assets/icon/selected.svg';
import backIcon from '../../../assets/icon/back.svg';
import cancelIcon from '../../../assets/icon/cancel.svg';
import { isPC, isUniFrameWork, isWeChat } from '../../../utils/env';
const props = defineProps({
list: {
type: Array,
default: () => [],
},
selectedList: {
type: Array,
default: () => [],
},
isSearch: {
type: Boolean,
default: true,
},
isRadio: {
type: Boolean,
default: false,
},
isCustomItem: {
type: Boolean,
default: false,
},
title: {
type: String,
default: '',
},
type: {
type: String,
default: '',
},
resultShow: {
type: Boolean,
default: true,
},
total: {
type: Number,
default: 0,
},
isHiddenBackIcon: {
type: Boolean,
default: false,
},
});
const transferList = ref<ITransferListItem[]>([]);
const transferTotal = ref<number>(0);
const transferSelectedList = ref<ITransferListItem[]>([]);
const isTransferSearch = ref(true);
const isTransferCustomItem = ref(false);
const transferTitle = ref('');
const searchValue = ref('');
watchEffect(() => {
if (props.isCustomItem) {
for (let index = 0; index < props.list.length; index++) {
if (
(props.list[index] as any).conversationID.indexOf('@TIM#SYSTEM') > -1
) {
// eslint-disable-next-line vue/no-mutating-props
props.list.splice(index, 1);
}
transferList.value = props.list as ITransferListItem[];
}
} else {
transferList.value = props.list as ITransferListItem[];
}
transferTotal.value = props.total ? props.total : props.list.length;
transferSelectedList.value = (props.selectedList && props.selectedList.length > 0 ? props.selectedList : transferSelectedList.value) as any;
isTransferSearch.value = props.isSearch;
isTransferCustomItem.value = props.isCustomItem;
transferTitle.value = props.title;
});
const emit = defineEmits(['search', 'submit', 'cancel', 'getMore']);
const optional = computed(() =>
transferList.value.filter((item: any) => !item.isDisabled),
);
const handleInput = (e: any) => {
searchValue.value = e.target.value || e.detail.value;
emit('search', searchValue.value);
};
const selected = (item: any) => {
if (item.isDisabled) {
return;
}
let list: ITransferListItem[] = transferSelectedList.value;
const index: number = list.indexOf(item);
if (index > -1) {
return transferSelectedList.value.splice(index, 1);
}
if (props.isRadio) {
list = [];
}
list.push(item);
transferSelectedList.value = list;
};
const selectedAll = () => {
if (transferSelectedList.value.length === optional.value.length) {
transferSelectedList.value = [];
} else {
transferSelectedList.value = [...optional.value];
}
};
const submit = () => {
emit('submit', transferSelectedList.value);
searchValue.value = '';
};
const cancel = () => {
emit('cancel');
searchValue.value = '';
};
const getMore = () => {
emit('getMore');
};
</script>
<style lang="scss" scoped src="./style/transfer.scss"></style>

View File

@@ -0,0 +1,68 @@
.main {
background: #FFF;
border: 1px solid #E0E0E0;
box-shadow: 0 -4px 12px 0 rgba(0, 0, 0, 0.06);
.left {
border-right: 1px solid #E8E8E9;
}
.transfer-header {
font-weight: 500;
color: #000;
letter-spacing: 0;
input {
background: #FFF;
border: 1px solid #DEE0E3;
font-weight: 500;
color: #8F959E;
letter-spacing: 0;
}
}
.transfer-list {
.transfer-text {
font-weight: 500;
color: #8F959E;
letter-spacing: 0;
}
&-item {
.disabled {
background: #eee;
}
}
}
}
.btn {
background: #3370FF;
border: 0 solid #2F80ED;
font-weight: 400;
color: #FFF;
&-cancel {
background: #FFF;
border: 1px solid #DDD;
color: #828282;
}
}
.btn-no {
background: #e8e8e9;
border: 1px solid #DDD;
font-weight: 400;
color: #FFF;
}
.transfer-h5-header {
background: #FFF;
.title {
font-family: PingFangSC-Medium;
font-weight: 500;
color: #000;
letter-spacing: 0;
}
}

View File

@@ -0,0 +1,93 @@
.transfer-h5 {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
&-wechat {
width: 100vw;
height: 100vh;
}
&-header {
position: relative;
display: flex;
justify-content: space-between;
align-items: center;
font-size: 18px;
padding: 16px 18px;
.space, .icon {
width: 18px;
height: 18px;
}
}
.main {
flex: 1;
flex-direction: column;
width: auto;
height: auto;
border-radius: 0;
border: none;
box-shadow: none;
max-height: calc(100% - 50px);
padding: 0;
.avatar {
border-radius: 5px;
}
.left {
padding: 0;
flex: 1;
border: none;
display: flex;
flex-direction: column;
.transfer-header {
position: sticky;
top: 0;
padding: 0 18px;
input {
border-radius: 5px;
font-size: 14px;
}
}
&-uniapp-input {
height: 36px;
}
}
.right {
flex: 0;
flex-direction: row;
align-items: center;
box-shadow: inset 0 1px 0 0 #EEE;
padding: 8px 18px ;
.transfer-list {
flex-direction: row;
width: 0;
&-item {
&-content {
flex: none;
}
}
}
.transfer-right-footer {
padding: 6px 0;
display: flex;
align-items: center;
.btn {
font-size: 14px;
}
}
}
}
}

View File

@@ -0,0 +1,13 @@
@import '../../../../assets/styles/common';
@import "./color";
@import "./web";
@import "./h5";
.icon-unselected {
width: 18px;
height: 18px;
background: #FFF;
border: 1px solid #DDD;
border-radius: 11px;
box-sizing: border-box;
}

View File

@@ -0,0 +1,141 @@
.avatar {
width: 36px;
height: 36px;
border-radius: 5px;
font-size: 12px;
display: flex;
justify-content: center;
align-items: center;
}
.main {
box-sizing: border-box;
width: 620px;
height: 394px;
display: flex;
border-radius: 8px;
padding: 20px 0;
.transfer-header {
font-size: 14px;
line-height: 14px;
padding-bottom: 20px;
input {
box-sizing: border-box;
width: 100%;
border-radius: 30px;
font-size: 10px;
line-height: 14px;
padding: 9px 12px;
}
}
.transfer-list {
flex: 1;
display: flex;
flex-direction: column;
.transfer-text {
font-size: 10px;
line-height: 14px;
}
&-item {
padding: 6px 0;
display: flex;
align-items: center;
font-size: 14px;
text-align: left;
&-content {
flex: 1;
display: flex;
align-items: center;
}
.avatar {
margin: 0 5px 0 8px;
border-radius: 50%;
}
.name {
width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
flex: 1;
}
}
}
.right {
padding: 0 20px;
flex: 1;
display: flex;
flex-direction: column;
.transfer-right-footer {
align-self: flex-end;
.btn-cancel {
margin-right: 12px;
}
}
.transfer-list {
padding-right: 20px;
overflow-y: auto;
}
}
.left {
flex: 1;
overflow-y: hidden;
display: flex;
flex-direction: column;
.transfer-header {
padding: 0 20px;
}
.transfer-left-main {
flex: 1;
overflow-y: auto;
padding: 0 13px;
}
}
}
.btn {
padding: 4px 28px;
font-size: 12px;
line-height: 24px;
border-radius: 4px;
}
.btn-no {
padding: 4px 28px;
font-size: 12px;
line-height: 24px;
border-radius: 4px;
}
.space-between {
justify-content: space-between;
}
.select-all {
padding-left: 8px;
font-size: 14px;
}
.more {
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
font-size: 14px;
}