chenyc
2025-09-23 afa0ffca1673eb61c27496b9988fa8559678bd94
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<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>