feat: 抽奖增加用户头像显示

This commit is contained in:
hujinbin
2024-11-25 17:10:26 +08:00
parent d7b0fad62f
commit 7aa8fdf234
7 changed files with 76 additions and 4 deletions

Binary file not shown.

View File

@@ -44,7 +44,7 @@ const actionsColumns = computed<any[]>(() => {
<tr class="hover" v-for="item in data" :key="item.id"> <tr class="hover" v-for="item in data" :key="item.id">
<th>{{ item.id }}</th> <th>{{ item.id }}</th>
<td v-for="(column, index) in dataColumns" :key="index"> <td v-for="(column, index) in dataColumns" :key="index">
<span v-if="column.formatValue">{{ column.formatValue(item) }}</span> <span v-if="column.formatValue" v-html="column.formatValue(item)"></span>
<span v-else>{{ item[column.props] }}</span> <span v-else>{{ item[column.props] }}</span>
</td> </td>
<!-- action --> <!-- action -->

File diff suppressed because one or more lines are too long

View File

@@ -4,8 +4,9 @@
user-select: none; user-select: none;
.card-id { .card-id {
position: absolute; position: absolute;
top: 20px; top: 10px;
right: 20px; right: 20px;
z-index: 2;
} }
.card-name { .card-name {
@@ -17,6 +18,7 @@
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
z-index: 2;
} }
.card-detail { .card-detail {
@@ -24,12 +26,26 @@
left: 0; left: 0;
right: 0; right: 0;
bottom: 15px; bottom: 15px;
z-index: 2;
}
.card-avatar{
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 1;
img {
width: 140px !important;
height: auto !important;
object-fit: cover;
}
} }
} }
.lucky-element-card { .lucky-element-card {
cursor: default; cursor: default;
text-align: center;
&::before { &::before {
background-color: linear-gradient(-45deg, #e81cff 0%, #40c9ff 100%); background-color: linear-gradient(-45deg, #e81cff 0%, #40c9ff 100%);
border: 1px solid linear-gradient(-45deg, #e81cff 0%, #40c9ff 100%); border: 1px solid linear-gradient(-45deg, #e81cff 0%, #40c9ff 100%);
@@ -39,9 +55,12 @@
position: absolute; position: absolute;
top: 20px; top: 20px;
right: 20px; right: 20px;
z-index: 2;
} }
.card-name { .card-name {
text-align: center;
z-index: 2;
position: absolute; position: absolute;
top: 40px; top: 40px;
left: 0px; left: 0px;
@@ -59,6 +78,22 @@
position: absolute; position: absolute;
left: 0; left: 0;
right: 0; right: 0;
text-align: center;
z-index: 2;
bottom: 15px; bottom: 15px;
} }
.card-avatar{
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 1;
img {
width: 280px !important;
height: auto !important;
object-fit: cover;
}
}
} }

View File

@@ -87,6 +87,13 @@ const tableColumns = [
label: '姓名', label: '姓名',
props: 'name', props: 'name',
}, },
{
label: '头像',
props: 'avatar',
formatValue(row: any) {
return row.avatar ? `<img src="${row.avatar}" alt="avatar" style="width: 50px; height: 50px;"/>` : '-';
}
},
{ {
label: '部门', label: '部门',
props: 'department', props: 'department',

View File

@@ -33,6 +33,13 @@ const tableColumnsList = [
label: '姓名', label: '姓名',
props: 'name', props: 'name',
}, },
{
label: '头像',
props: 'avatar',
formatValue(row: any) {
return row.avatar ? `<img src="${row.avatar}" alt="avatar" style="width: 50px; height: 50px;"/>` : '-';
}
},
{ {
label: '部门', label: '部门',
props: 'department', props: 'department',
@@ -69,6 +76,13 @@ const tableColumnsDetail = [
label: '姓名', label: '姓名',
props: 'name', props: 'name',
}, },
{
label: '头像',
props: 'avatar',
formatValue(row: any) {
return row.avatar ? `<img src="${row.avatar}" alt="avatar" style="width: 50px; height: 50px;"/>` : '-';
}
},
{ {
label: '部门', label: '部门',
props: 'department', props: 'department',

View File

@@ -131,6 +131,16 @@ const init = () => {
detail.innerHTML = `${tableData.value[i].department}<br/>${tableData.value[i].identity}`; detail.innerHTML = `${tableData.value[i].department}<br/>${tableData.value[i].identity}`;
element.appendChild(detail); element.appendChild(detail);
const avatar = document.createElement('div');
avatar.className = 'card-avatar';
const img = document.createElement('img');
img.src = tableData.value[i].avatar;
img.alt = 'avatar';
img.style.width = '140px';
img.style.height = '140px';
avatar.appendChild(img);
element.appendChild(avatar);
element = useElementStyle(element, tableData.value[i], i, patternList.value, patternColor.value, cardColor.value, cardSize.value, textSize.value) element = useElementStyle(element, tableData.value[i], i, patternList.value, patternColor.value, cardColor.value, cardSize.value, textSize.value)
const object = new CSS3DObject(element); const object = new CSS3DObject(element);
object.position.x = Math.random() * 4000 - 2000; object.position.x = Math.random() * 4000 - 2000;