完成单位管理的接口

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,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>