完成单位管理的接口

This commit is contained in:
2025-09-08 12:06:02 +08:00
parent fd7093e613
commit d061b4d470
4 changed files with 118 additions and 97 deletions

View File

@@ -6,7 +6,7 @@
<!-- 修改后的搜索栏 -->
<view class="search-bar">
<u-search
placeholder="请输入姓名或手机号搜索"
placeholder="请输入姓名或完整手机号搜索"
v-model="searchKeyword"
@search="handleSearch"
@clear="handleClearSearch"
@@ -17,61 +17,59 @@
></u-search>
</view>
</view>
<!-- 员工审核列表 -->
<scroll-view
class="list-container"
scroll-y
:refresher-enabled="true"
refresher-background="#f7f7f7"
:refresher-triggered="refresherTriggered"
@refresherrefresh="onRefresh"
@scrolltolower="loadMore"
:lower-threshold="50"
scroll-with-animation>
<!-- 员工审核列表 -->
<scroll-view
class="list-container"
scroll-y
:refresher-enabled="true"
refresher-background="#f7f7f7"
:refresher-triggered="refresherTriggered"
@refresherrefresh="onRefresh"
@scrolltolower="loadMore"
:lower-threshold="50"
scroll-with-animation>
<!-- 员工审核卡片 -->
<view v-for="(item, index) in list" :key="index" class="employee-card">
<!-- 左侧头像 -->
<image class="avatar" :src="item.avatar || '/static/ic_avg.png'"/>
<!-- 员工审核卡片 -->
<view v-for="(item, index) in list" :key="index" class="employee-card">
<!-- 左侧头像 -->
<image class="avatar" :src="item.img || '/static/ic_avg.png'"/>
<!-- 右侧信息 -->
<view class="info-container">
<view class="name-row">
<text class="name">{{ item.name }}</text>
<image
class="gender-icon"
:src="item.gender === '1' ? '/static/ic_man.png' : '/static/ic_women.png'"
/>
</view>
<text class="phone">{{ item.phone }}</text>
</view>
<!-- 编辑图标 -->
<image
class="edit-icon"
src="/static/ic_edit.png"
@click.stop="handleCardClick(item)"
/>
<!-- 审核状态 - 精确贴合右上角 -->
<view class="date-badge">
{{ formatDate(item.applyTime ) }}
<!-- 右侧信息 -->
<view class="info-container">
<view class="name-row">
<text class="name">{{ item.userName }}</text>
<image
class="gender-icon"
:src="item.gender === 1 ? '/static/ic_man.png' : '/static/ic_women.png'"
/>
</view>
<text class="phone">{{ item.phone }}</text>
</view>
<!-- 编辑图标 -->
<image
class="edit-icon"
src="/static/ic_edit.png"
@click="handleCardClick(item)"
/>
<!-- 审核状态 - 精确贴合右上角 -->
<view class="date-badge">
{{ formatDate(item.createTime) }}
</view>
</view>
<!-- 底部加载提示 -->
<view v-if="loading" class="loading-text">加载中...</view>
<view v-if="noMore" class="loading-text">没有更多数据了</view>
<view v-if="searchKeyword && filteredList.length === 0" class="loading-text">未找到匹配结果</view>
</scroll-view>
</view>
<!-- 底部加载提示 -->
<view v-if="loading" class="loading-text">加载中...</view>
<view v-if="noMore" class="loading-text">没有更多数据了</view>
<view v-if="searchKeyword && list.length === 0" class="loading-text">未找到匹配结果</view>
</scroll-view>
</view>
</template>
<script>
export default {
data() {
return {
list: [
{name: "于永乐", gender: "1", phone: "12448155", applyTime: "2025-09-01 10:51:32", status: "1"}
], // 员工列表数据
list: [], // 员工列表数据
pageNum: 1, // 当前页码
pageSize: 10, // 每页数量
noMore: false, // 是否没有更多数据
@@ -83,17 +81,6 @@ export default {
created() {
this.loadData();
},
computed: {
// 添加过滤后的列表计算属性
filteredList() {
if (!this.searchKeyword) return this.list;
const keyword = this.searchKeyword.toLowerCase();
return this.list.filter(item =>
item.name.toLowerCase().includes(keyword) ||
(item.phone && item.phone.includes(keyword))
);
}
},
methods: {
// 下拉刷新
async onRefresh() {
@@ -113,11 +100,24 @@ export default {
async loadData() {
this.loading = true;
try {
let res = await this.$u.api.getEmployeeAuditList({
// 判断搜索内容是否是手机号(简单判断)
const isPhone = /^[0-9]{11}$/.test(this.searchKeyword);
let params = {
pageNum: this.pageNum,
pageSize: this.pageSize
});
};
// 根据输入内容决定使用哪个搜索字段
if (this.searchKeyword) {
if (isPhone) {
params.phone = this.searchKeyword;
} else {
params.userName = this.searchKeyword;
}
}
let res = await this.$u.api.unit.queryEmployee(params);
if (res.code == "200") {
let rows = res.rows || [];
if (rows.length < this.pageSize) {
@@ -138,9 +138,9 @@ export default {
},
// 点击卡片事件
handleCardClick(item) {
if (item.status === '1') {
if (item.state === 1) {
uni.navigateTo({
url: `/pages/sys/workbench/unitManagement/employeeEdit`
url: `/pages/sys/workbench/unitManagement/employeeEdit?id=${item.id}`
});
}
},
@@ -258,7 +258,6 @@ export default {
}
.loading-text {
text-align: center;
color: #999;