完成单位管理的接口

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

View File

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

View File

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

View File

@@ -6,7 +6,7 @@
<!-- 修改后的搜索栏 --> <!-- 修改后的搜索栏 -->
<view class="search-bar"> <view class="search-bar">
<u-search <u-search
placeholder="请输入姓名或手机号搜索" placeholder="请输入姓名或完整手机号搜索"
v-model="searchKeyword" v-model="searchKeyword"
@search="handleSearch" @search="handleSearch"
@clear="handleClearSearch" @clear="handleClearSearch"
@@ -17,61 +17,59 @@
></u-search> ></u-search>
</view> </view>
</view> </view>
<!-- 员工审核列表 --> <!-- 员工审核列表 -->
<scroll-view <scroll-view
class="list-container" class="list-container"
scroll-y scroll-y
:refresher-enabled="true" :refresher-enabled="true"
refresher-background="#f7f7f7" refresher-background="#f7f7f7"
:refresher-triggered="refresherTriggered" :refresher-triggered="refresherTriggered"
@refresherrefresh="onRefresh" @refresherrefresh="onRefresh"
@scrolltolower="loadMore" @scrolltolower="loadMore"
:lower-threshold="50" :lower-threshold="50"
scroll-with-animation> scroll-with-animation>
<!-- 员工审核卡片 --> <!-- 员工审核卡片 -->
<view v-for="(item, index) in list" :key="index" class="employee-card"> <view v-for="(item, index) in list" :key="index" class="employee-card">
<!-- 左侧头像 --> <!-- 左侧头像 -->
<image class="avatar" :src="item.avatar || '/static/ic_avg.png'"/> <image class="avatar" :src="item.img || '/static/ic_avg.png'"/>
<!-- 右侧信息 --> <!-- 右侧信息 -->
<view class="info-container"> <view class="info-container">
<view class="name-row"> <view class="name-row">
<text class="name">{{ item.name }}</text> <text class="name">{{ item.userName }}</text>
<image <image
class="gender-icon" 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'"
/> />
</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> </view>
<text class="phone">{{ item.phone }}</text>
</view> </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="loading" class="loading-text">加载中...</view>
<view v-if="noMore" class="loading-text">没有更多数据了</view> <view v-if="noMore" class="loading-text">没有更多数据了</view>
<view v-if="searchKeyword && filteredList.length === 0" class="loading-text">未找到匹配结果</view> <view v-if="searchKeyword && list.length === 0" class="loading-text">未找到匹配结果</view>
</scroll-view> </scroll-view>
</view> </view>
</template> </template>
<script> <script>
export default { export default {
data() { data() {
return { return {
list: [ list: [], // 员工列表数据
{name: "于永乐", gender: "1", phone: "12448155", applyTime: "2025-09-01 10:51:32", status: "1"}
], // 员工列表数据
pageNum: 1, // 当前页码 pageNum: 1, // 当前页码
pageSize: 10, // 每页数量 pageSize: 10, // 每页数量
noMore: false, // 是否没有更多数据 noMore: false, // 是否没有更多数据
@@ -83,17 +81,6 @@ export default {
created() { created() {
this.loadData(); 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: { methods: {
// 下拉刷新 // 下拉刷新
async onRefresh() { async onRefresh() {
@@ -113,11 +100,24 @@ export default {
async loadData() { async loadData() {
this.loading = true; this.loading = true;
try { try {
let res = await this.$u.api.getEmployeeAuditList({ // 判断搜索内容是否是手机号(简单判断)
const isPhone = /^[0-9]{11}$/.test(this.searchKeyword);
let params = {
pageNum: this.pageNum, pageNum: this.pageNum,
pageSize: this.pageSize 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") { if (res.code == "200") {
let rows = res.rows || []; let rows = res.rows || [];
if (rows.length < this.pageSize) { if (rows.length < this.pageSize) {
@@ -138,9 +138,9 @@ export default {
}, },
// 点击卡片事件 // 点击卡片事件
handleCardClick(item) { handleCardClick(item) {
if (item.status === '1') { if (item.state === 1) {
uni.navigateTo({ 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 { .loading-text {
text-align: center; text-align: center;
color: #999; color: #999;