修改页面
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
<!-- 员工审核卡片 -->
|
||||
<view v-for="(item, index) in employeeList" :key="index" class="employee-card" @click="handleCardClick(item)">
|
||||
<!-- 左侧头像 -->
|
||||
<image class="avatar" :src="item.avatar || '/static/ic_avg.png'"/>
|
||||
<image class="avatar" :src="item.img || '/static/ic_avg.png'"/>
|
||||
|
||||
<!-- 右侧信息 -->
|
||||
<view class="info-container">
|
||||
@@ -52,8 +52,7 @@
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
employeeList: [
|
||||
], // 员工列表数据
|
||||
employeeList: [], // 员工列表数据
|
||||
pageNum: 1, // 当前页码
|
||||
pageSize: 10, // 每页数量
|
||||
noMore: false, // 是否没有更多数据
|
||||
@@ -86,6 +85,7 @@ export default {
|
||||
let res = await this.$u.api.unit.queryEmployee({
|
||||
pageNum: this.pageNum,
|
||||
pageSize: this.pageSize,
|
||||
unitId: uni.getStorageSync('lifeData').vuex_user.unitId,
|
||||
});
|
||||
if (res.code == "200") {
|
||||
let rows = res.rows || [];
|
||||
@@ -98,6 +98,7 @@ export default {
|
||||
} else {
|
||||
this.employeeList = [...this.employeeList, ...rows];
|
||||
}
|
||||
await this.getImageUrl();
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
@@ -107,13 +108,46 @@ export default {
|
||||
},
|
||||
// 点击卡片事件
|
||||
handleCardClick(item) {
|
||||
console.log(item.id);
|
||||
if (item.state === 1) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/sys/workbench/unitManagement/auditsDetail?id=${item.id}`,
|
||||
});
|
||||
uni.navigateTo({
|
||||
url: `/pages/sys/workbench/unitManagement/auditsDetail?id=${item.id}`,
|
||||
});
|
||||
},
|
||||
async getImageUrl() {
|
||||
// 收集所有需要获取链接的图片ID
|
||||
const imgIds = [];
|
||||
const imgIdToIndexMap = []; // 保存图片ID对应的list索引
|
||||
|
||||
for (let i = 0; i < this.employeeList.length; i++) {
|
||||
const item = this.employeeList[i];
|
||||
if (item.img) {
|
||||
imgIds.push(item.img);
|
||||
imgIdToIndexMap.push({
|
||||
id: item.img,
|
||||
index: i
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 如果有图片ID需要处理,则调用API一次获取所有图片链接
|
||||
if (imgIds.length > 0) {
|
||||
console.log(imgIds);
|
||||
try {
|
||||
const imgRes = await this.$u.api.getImageUrl({}, imgIds.join(','));
|
||||
if (imgRes.code == 200 && imgRes.data) {
|
||||
// 将返回的图片URL映射回对应的list项
|
||||
imgRes.data.forEach(imgItem => {
|
||||
const mapping = imgIdToIndexMap.find(m => m.id === imgItem.ossId);
|
||||
if (mapping) {
|
||||
this.$set(this.employeeList[mapping.index], 'img', this.vuex_config.imgUrl+imgItem.url);
|
||||
}
|
||||
});
|
||||
}
|
||||
console.log(this.employeeList);
|
||||
} catch (error) {
|
||||
console.error('获取图片链接失败:', error);
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
@@ -196,7 +230,7 @@ export default {
|
||||
border-top-left-radius: 10px;
|
||||
border-bottom-left-radius: 10px;
|
||||
width: 26%;
|
||||
text-align:left;
|
||||
text-align: left;
|
||||
font-weight: bold;
|
||||
color: #fff;
|
||||
}
|
||||
|
Reference in New Issue
Block a user