|
|
@@ -245,6 +245,14 @@
|
|
|
v-hasPermi="['qw:user:bind']"
|
|
|
>查或换绑企微</el-button>
|
|
|
|
|
|
+ <el-button
|
|
|
+ size="mini"
|
|
|
+ type="text"
|
|
|
+ icon="el-icon-user"
|
|
|
+ plain
|
|
|
+ @click="handleBindUser(scope.row)"
|
|
|
+ >绑定用户</el-button>
|
|
|
+
|
|
|
<el-button v-if="scope.row.userType !== '00'" size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['company:user:edit']">修改</el-button>
|
|
|
<el-button v-if="scope.row.userType !== '00'" size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['company:user:remove']">删除</el-button>
|
|
|
<el-button size="mini" type="text" icon="el-icon-key" @click="handleResetPwd(scope.row)" v-hasPermi="['company:user:resetPwd']">重置密码</el-button>
|
|
|
@@ -618,6 +626,61 @@
|
|
|
<selectDoctor ref="selectDoctor" @bindCompanyUserDoctorId="bindCompanyUserDoctorId"></selectDoctor>
|
|
|
</el-dialog>
|
|
|
|
|
|
+ <!-- 绑定用户对话框 -->
|
|
|
+ <el-dialog title="绑定用户" :visible.sync="bindUserDialog.open" width="900px" append-to-body @close="resetBindUserForm">
|
|
|
+ <el-form :model="bindUserForm" label-width="100px">
|
|
|
+ <el-form-item label="手机号码">
|
|
|
+ <el-input
|
|
|
+ v-model="bindUserForm.phone"
|
|
|
+ placeholder="请输入手机号码(完全匹配)"
|
|
|
+ clearable
|
|
|
+ style="width: 300px;"
|
|
|
+ @keyup.enter.native="queryFsUserByPhone"
|
|
|
+ >
|
|
|
+ <el-button slot="append" icon="el-icon-search" @click="queryFsUserByPhone">查询</el-button>
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+
|
|
|
+ <!-- 已绑定用户信息 -->
|
|
|
+ <div v-if="boundUsersList.length > 0" style="margin-bottom: 20px;">
|
|
|
+ <el-divider content-position="left">已绑定用户</el-divider>
|
|
|
+ <el-table :data="boundUsersList" border style="width: 100%">
|
|
|
+ <el-table-column prop="userId" label="用户ID" width="100" align="center"></el-table-column>
|
|
|
+ <el-table-column prop="nickname" label="用户名称" align="center"></el-table-column>
|
|
|
+ <el-table-column prop="phone" label="电话" align="center"></el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- 查询结果 -->
|
|
|
+ <div v-if="fsUserList.length > 0">
|
|
|
+ <el-divider content-position="left">查询结果(可多选)</el-divider>
|
|
|
+ <el-table
|
|
|
+ :data="fsUserList"
|
|
|
+ border
|
|
|
+ v-loading="bindUserLoading"
|
|
|
+ @selection-change="handleFsUserSelectionChange"
|
|
|
+ style="width: 100%"
|
|
|
+ >
|
|
|
+ <el-table-column type="selection" width="55" align="center"></el-table-column>
|
|
|
+ <el-table-column prop="userId" label="用户ID" width="100" align="center"></el-table-column>
|
|
|
+ <el-table-column prop="nickname" label="用户名称" align="center"></el-table-column>
|
|
|
+ <el-table-column prop="phone" label="电话" align="center"></el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </div>
|
|
|
+ <div v-else-if="bindUserForm.phone && !bindUserLoading" style="text-align: center; padding: 20px; color: #909399;">
|
|
|
+ 暂无查询结果
|
|
|
+ </div>
|
|
|
+ <div v-if="bindUserLoading" style="text-align: center; padding: 20px;">
|
|
|
+ <i class="el-icon-loading"></i> 查询中...
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="bindUserDialog.open = false">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="submitBindUser" :disabled="selectedFsUserIds.length === 0">确 定</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
@@ -636,7 +699,10 @@ import {
|
|
|
generateSubDomain,
|
|
|
setIsRegisterMember,
|
|
|
updateCompanyUserAreaList,
|
|
|
- isAllowedAllRegister, unBindDoctorId, bindDoctorId,updateBatchUserRoles
|
|
|
+ isAllowedAllRegister, unBindDoctorId, bindDoctorId,updateBatchUserRoles,
|
|
|
+ queryFsUserByPhone,
|
|
|
+ batchBindCompanyUserId,
|
|
|
+ getBoundUsers
|
|
|
} from "@/api/company/companyUser";
|
|
|
import { getToken } from "@/utils/auth";
|
|
|
import { treeselect } from "@/api/company/companyDept";
|
|
|
@@ -847,6 +913,19 @@ export default {
|
|
|
userIds: [],
|
|
|
roleIds: []
|
|
|
},
|
|
|
+ // 绑定用户相关
|
|
|
+ bindUserDialog: {
|
|
|
+ open: false,
|
|
|
+ title: '绑定用户'
|
|
|
+ },
|
|
|
+ bindUserForm: {
|
|
|
+ phone: '',
|
|
|
+ companyUserId: null
|
|
|
+ },
|
|
|
+ fsUserList: [],
|
|
|
+ selectedFsUserIds: [],
|
|
|
+ boundUsersList: [],
|
|
|
+ bindUserLoading: false,
|
|
|
};
|
|
|
},
|
|
|
watch: {
|
|
|
@@ -1609,6 +1688,107 @@ export default {
|
|
|
this.getList();
|
|
|
})
|
|
|
},
|
|
|
+ /** 绑定用户按钮操作 */
|
|
|
+ handleBindUser(row) {
|
|
|
+ this.bindUserForm.companyUserId = row.userId;
|
|
|
+ this.bindUserForm.phone = '';
|
|
|
+ this.fsUserList = [];
|
|
|
+ this.selectedFsUserIds = [];
|
|
|
+ this.boundUsersList = [];
|
|
|
+ this.bindUserDialog.open = true;
|
|
|
+
|
|
|
+ // 查询已绑定的用户
|
|
|
+ this.loadBoundUsers(row.userId);
|
|
|
+ },
|
|
|
+ /** 查询已绑定的用户 */
|
|
|
+ loadBoundUsers(companyUserId) {
|
|
|
+ getBoundUsers(companyUserId).then(response => {
|
|
|
+ if (response.code === 200 && response.data) {
|
|
|
+ this.boundUsersList = Array.isArray(response.data) ? response.data : [response.data];
|
|
|
+ } else {
|
|
|
+ this.boundUsersList = [];
|
|
|
+ }
|
|
|
+ }).catch(() => {
|
|
|
+ this.boundUsersList = [];
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /** 根据手机号码查询fs_user */
|
|
|
+ queryFsUserByPhone() {
|
|
|
+ if (!this.bindUserForm.phone) {
|
|
|
+ this.$message.warning('请输入手机号码');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 验证手机号码格式
|
|
|
+ const phonePattern = /^1[3|4|5|6|7|8|9][0-9]\d{8}$/;
|
|
|
+ if (!phonePattern.test(this.bindUserForm.phone)) {
|
|
|
+ this.$message.error('请输入正确的手机号码');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.bindUserLoading = true;
|
|
|
+ queryFsUserByPhone(this.bindUserForm.phone).then(response => {
|
|
|
+ this.bindUserLoading = false;
|
|
|
+ if (response.code === 200) {
|
|
|
+ if (response.data) {
|
|
|
+ // 如果返回的是单个对象,转换为数组
|
|
|
+ this.fsUserList = Array.isArray(response.data) ? response.data : [response.data];
|
|
|
+ if (this.fsUserList.length === 0) {
|
|
|
+ this.$message.info('未找到匹配的用户');
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.fsUserList = [];
|
|
|
+ this.$message.info('未找到匹配的用户');
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.fsUserList = [];
|
|
|
+ this.$message.error(response.msg || '查询失败');
|
|
|
+ }
|
|
|
+ }).catch(error => {
|
|
|
+ this.bindUserLoading = false;
|
|
|
+ this.fsUserList = [];
|
|
|
+ this.$message.error('查询失败');
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /** 处理fs_user选择变化 */
|
|
|
+ handleFsUserSelectionChange(selection) {
|
|
|
+ this.selectedFsUserIds = selection.map(item => item.userId);
|
|
|
+ },
|
|
|
+ /** 提交绑定用户 */
|
|
|
+ submitBindUser() {
|
|
|
+ if (this.selectedFsUserIds.length === 0) {
|
|
|
+ this.$message.warning('请至少选择一个用户');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const data = {
|
|
|
+ companyUserId: this.bindUserForm.companyUserId,
|
|
|
+ fsUserIds: this.selectedFsUserIds
|
|
|
+ };
|
|
|
+
|
|
|
+ batchBindCompanyUserId(data).then(response => {
|
|
|
+ if (response.code === 200) {
|
|
|
+ this.$message.success('绑定成功');
|
|
|
+ this.bindUserDialog.open = false;
|
|
|
+ this.getList();
|
|
|
+ } else {
|
|
|
+ this.$message.error(response.msg || '绑定失败');
|
|
|
+ }
|
|
|
+ }).catch(error => {
|
|
|
+ this.$message.error('绑定失败');
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /** 重置绑定用户表单 */
|
|
|
+ resetBindUserForm() {
|
|
|
+ this.bindUserForm = {
|
|
|
+ phone: '',
|
|
|
+ companyUserId: null
|
|
|
+ };
|
|
|
+ this.fsUserList = [];
|
|
|
+ this.selectedFsUserIds = [];
|
|
|
+ this.boundUsersList = [];
|
|
|
+ this.bindUserLoading = false;
|
|
|
+ },
|
|
|
},
|
|
|
}
|
|
|
</script>
|