完成单位管理的接口

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

@@ -12,7 +12,7 @@
</view>
<view class="info-row">
<text class="label">性别</text>
<text class="value"></text>
<text class="value">{{auditsDetail.gender === 1? '男' : '女'}}</text>
</view>
<view class="info-row">
<text class="label">证件号</text>
@@ -24,7 +24,7 @@
</view>
<view class="info-row">
<text class="label">所属单位</text>
<text class="value">{{auditsDetail.name}}</text>
<text class="value">{{auditsDetail.unitName}}</text>
</view>
<!-- 人脸图片区域 -->
@@ -53,7 +53,7 @@
</view>
<!-- 底部按钮 -->
<view v-if="pageType === 'handle'" class="action-buttons">
<view v-if="pageType === 'handle'&&auditsDetail.isAuditState===1" class="action-buttons">
<button class="approve-btn" @click="handleApprove">通过</button>
<button class="reject-btn" @click="handleReject">拒绝</button>
</view>
@@ -121,7 +121,6 @@
this.auditsDetail = res.data;
});
}
// 其他原有方法...
}
};
</script>

View File

@@ -23,21 +23,21 @@
<text class="name">{{ item.userName }}</text>
<image
class="gender-icon"
:src="item.gender === '1' ? '/static/ic_man.png' : '/static/ic_women.png'"
:src="item.gender === 1 ? '/static/ic_man.png' : '/static/ic_women.png'"
/>
<text class="phone">{{ item.phone }}</text>
</view>
<text class="time">{{ item.applyTime }}</text>
<text class="time">{{ item.createTime }}</text>
</view>
<!-- 审核状态 - 精确贴合右上角 -->
<view class="status-badge"
:class="{
'status-pending': item.status === '1',
'status-processed': item.status === '2'
'status-pending': item.isAuditState === 1,
'status-processed': item.isAuditState === 2
}">
{{ item.status === '1' ? "待处理" : "已处理" }}
{{ item.isAuditState === 1 ? "待处理" : "已处理" }}
</view>
</view>
@@ -86,7 +86,6 @@ export default {
let res = await this.$u.api.unit.queryEmployee({
pageNum: this.pageNum,
pageSize: this.pageSize,
isAudit:2
});
if (res.code == "200") {
let rows = res.rows || [];

View File

@@ -6,23 +6,23 @@
<view class="user-info">
<view class="info-row">
<text class="label">用户姓名</text>
<text class="value">余永乐</text>
<text class="value">{{employeeDetail.userName}}</text>
</view>
<view class="info-row">
<text class="label">性别</text>
<text class="value"></text>
<text class="value">{{employeeDetail.gender === 1? '男' : '女'}}</text>
</view>
<view class="info-row">
<text class="label">证件号</text>
<text class="value">5001255658789955</text>
<text class="value">{{employeeDetail.idCard}}</text>
</view>
<view class="info-row">
<text class="label">联系电话</text>
<text class="value">17898987887</text>
<text class="value">{{employeeDetail.phone}}</text>
</view>
<view class="info-row">
<text class="label">所属单位</text>
<text class="value">x x x x x</text>
<text class="value">{{employeeDetail.unitName}}</text>
</view>
<!-- 人脸图片区域 -->
@@ -30,7 +30,7 @@
<text class="label">人脸图片</text>
<image
class="face-image"
:src="auditsDetail.avatar || '/static/ic_avg.png'"
:src="employeeDetail.img || '/static/ic_avg.png'"
mode="aspectFill"
/>
</view>
@@ -41,11 +41,11 @@
<view class="user-info">
<view class="info-row">
<text class="label">邮箱</text>
<text class="value">-</text>
<text class="value">{{employeeDetail.email}}</text>
</view>
<view class="info-row">
<text class="label">车牌号</text>
<text class="value">-</text>
<text class="value">{{employeeDetail.carNumber}}</text>
</view>
</view>
</view>
@@ -54,26 +54,27 @@
<view class="user-info">
<view class="info-row">
<text class="label">入驻时间</text>
<text class="value">-</text>
<text class="value">{{employeeDetail.updateTime}}</text>
</view>
<view class="info-row">
<text class="label">在职状态</text>
<view class="status-options">
<!-- 启用选项 -->
<view class="radio-option" @click="changeStatus(auditsDetail, '1')">
<view class="radio-circle" :class="{ 'active': auditsDetail.status === '1' }"></view>
<view class="radio-option" @click="changeStatus(1)">
<view class="radio-circle" :class="{ 'active': employeeDetail.state === 1 }"></view>
<text class="radio-label">启用</text>
</view>
<!-- 禁用选项 -->
<view class="radio-option" @click="changeStatus(auditsDetail, '0')">
<view class="radio-circle" :class="{ 'active': auditsDetail.status === '0' }"></view>
<view class="radio-option" @click="changeStatus(0)">
<view class="radio-circle" :class="{ 'active': employeeDetail.state === 0 }"></view>
<text class="radio-label">禁用</text>
</view>
</view>
</view>
</view>
</view>
<button class="submit-btn" @click="saveInfo">保存</button>
</view>
</template>
@@ -82,14 +83,17 @@ export default {
data() {
return {
pageType: 'handle', // 'handle' 或 'detail'
auditsDetail: {status:'0'},
handleDesc: '',
selectedImages: [],
realImages: [],
infoImages: []
employeeDetail: {},
};
},
methods: {
onLoad(options) {
if (options.id) {
const id = options.id;
this.employeeDetail.id = id;
this.queryEmployee();
}
},
// 原有方法保持不变...
handleApprove() {
console.log('approve');
@@ -100,19 +104,28 @@ export default {
async submit(action) {
// 提交逻辑...
},
queryEmployee(){
this.$u.api.unit.queryEmployeeById(this.employeeDetail).then(res => {
this.employeeDetail = res.data;
});
},
// 新增状态变更方法
changeStatus(item, newStatus) {
item.status = newStatus;
// 这里可以添加API调用更新状态
this.$u.api.updateEmployeeStatus({
id: item.id,
status: newStatus
}).then(res => {
if (res.code === '200') {
changeStatus(newState) {
this.employeeDetail.state = newState;
},
saveInfo(){
console.log( this.employeeDetail);
this.$u.api.unit.updateEmployee( this.employeeDetail).then(res => {
if (res.code === 200) {
uni.showToast({
title: '状态更新成功',
icon: 'success'
});
}else {
uni.showToast({
title: '状态更新失败',
icon: 'none'
});
}
});
}
@@ -252,4 +265,15 @@ export default {
font-size: 28rpx;
color: #333;
}
.submit-btn {
width: 100%;
height: 44px;
line-height: 44px;
font-size: 16px;
color: #fff;
background-color: #409eff;
border-radius: 4px;
border: none;
}
</style>

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;