<template>
|
<div class="upgrade-dialog">
|
<el-dialog title="修改用户" v-model="isShowDialog" width="1069px" center>
|
<el-form :model="ruleForm" :rules="rules" ref="edituserForm" label-width="90px">
|
<el-row :gutter="35">
|
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
<el-form-item label="用户代号" prop="userNo">
|
<el-input v-model="ruleForm.userNo" placeholder="请输入用户代号" clearable></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
<el-form-item label="用户姓名" prop="userName">
|
<el-input v-model="ruleForm.userName" placeholder="请输入用户姓名" clearable></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
<el-form-item label="手机号" prop="userMobile">
|
<el-input v-model="ruleForm.userMobile" placeholder="请输入手机号" clearable></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
<el-form-item label="用户状态">
|
<el-switch v-model="ruleForm.isValid" inline-prompt :inactive-value="0" :active-value="1" active-text="启" inactive-text="禁"></el-switch>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
<el-form-item label="所属医院">
|
<div style="border: 1px solid #EBEDF0;padding: 5px; ">
|
<el-checkbox-group v-model="ruleForm.clientCodes">
|
<el-checkbox v-for="(client,index) in clientData" :label="client.clientName" :value="client.code" :key="index" />
|
</el-checkbox-group>
|
</div>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
<el-form-item label="用户描述">
|
<el-input v-model="ruleForm.remark" type="textarea" placeholder="请输入用户描述" maxlength="150"></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-form>
|
<template #footer>
|
<span class="dialog-footer">
|
<el-button @click="onCancel" :loading="loading" >取 消</el-button>
|
<el-button type="primary" :loading="loading" @click="onSubmit" >修 改</el-button>
|
</span>
|
</template>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script lang="ts">
|
import { reactive, toRefs, onMounted,getCurrentInstance } from 'vue';
|
import {update,getClientList} from '/@/api/register'
|
export default {
|
name: 'systemEditUser',
|
setup(props,context) {
|
const { proxy } = getCurrentInstance() as any;
|
const state = reactive({
|
isShowDialog: false,
|
ruleForm: {
|
userName: '', // 账户名称
|
userNo: '', // 用户昵称
|
roleSign: '', // 关联角色
|
userMobile: '', // 手机号
|
userEmail: '', // 邮箱
|
userGender: 0, // 性别
|
userTitle:'',//职称(编号)
|
overdueTime: '', // 账户过期
|
isValid: 0, // 用户状态
|
clientCodes:'',
|
remark: '', // 用户描述
|
|
},
|
|
clientData: [], // 部门数据
|
rules: {
|
userName: { required: true, message: '请输入用户姓名', trigger: 'blur' },
|
userNo: { required: true, message: '请输入用户代号', trigger: 'blur' },
|
userMobile: [
|
{ required: true, message: '请输入用户手机号码', trigger: 'blur' },
|
{ pattern: /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/, message: '请输入有效的手机号', trigger: 'blur' }
|
],
|
},
|
loading: false,
|
});
|
// 打开弹窗
|
const openDialog = (row: any) => {
|
state.ruleForm =row
|
state.isShowDialog = true;
|
};
|
// 关闭弹窗
|
const closeDialog = () => {
|
state.isShowDialog = false;
|
};
|
// 取消
|
const onCancel = () => {
|
closeDialog();
|
};
|
// 新增
|
const onSubmit = () => {
|
proxy.$refs['edituserForm'].validate(async (valid) => {
|
if(valid){
|
state.loading = true;
|
update(state.ruleForm).then(()=>{
|
closeDialog();
|
context.emit("update:Search");//调用父级方法参数
|
}).finally(() => {
|
state.loading = false;
|
})
|
}
|
})
|
};
|
// 初始化部门数据
|
const initTableData = () => {
|
const pas={
|
page: 0,
|
size: 0,
|
wherecondition: '',
|
ordercondition: 'create_time desc'
|
}
|
getClientList(pas).then((res)=>{
|
state.clientData=res.data.list
|
console.log(res.data.list,'部门数据')
|
})
|
|
};
|
// 页面加载时
|
onMounted(() => {
|
initTableData();
|
});
|
return {
|
openDialog,
|
closeDialog,
|
onCancel,
|
onSubmit,
|
...toRefs(state),
|
};
|
},
|
};
|
</script>
|
<style scoped lang="scss">
|
.upgrade-dialog {
|
:deep(.el-dialog) {
|
padding:0;
|
padding-bottom: 20px;
|
.el-dialog__body {
|
padding: 5 !important;
|
}
|
.el-dialog__header {
|
background: #409EFF;
|
height: 50px;
|
line-height: 50px;
|
margin-bottom: 30px;
|
.span{
|
color: white;
|
}
|
|
}
|
|
}
|
}
|
</style>
|