#
Junjie
2024-07-02 d6a0e5667b4dde018b8244808fcc33f68f5b07ad
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
164
165
166
167
168
169
170
171
172
173
174
<script setup>
import { ref, nextTick } from 'vue';
import { get, post, postBlob, postForm } from '@/utils/request.js'
import { formatMessage } from '@/utils/localeUtils.js';
import { message } from 'ant-design-vue';
 
const submitButton = ref(null);
const isSave = ref(true);
const open = ref(false);
const initFormData = {}
let formData = ref(initFormData);
const treeData = ref(null);
 
const emit = defineEmits(['tableReload'])
 
const handleOk = (e) => {
    nextTick(() => {
        setTimeout(() => {
            submitButton.value.$el.click();
        }, 100);
    });
};
 
const onFinish = values => {
    // console.log('Success:', values);
    open.value = false;
    post(isSave.value ? '/api/user/save' : '/api/user/update', formData.value).then((resp) => {
        let result = resp.data;
        if (result.code === 200) {
            message.success(formatMessage('page.update.success', '更新成功'));
        } else {
            message.error(result.msg);
        }
        emit('tableReload', 'reload')
    })
};
const onFinishFailed = errorInfo => {
    console.log('Failed:', errorInfo);
};
 
const DeptQueryList = ref(null);
DeptQuery();
function DeptQuery() {
    postForm('/api/dept/query', {}).then(resp => {
        let result = resp.data;
        DeptQueryList.value = result.data;
    })
}
const UserQueryList = ref(null);
UserQuery();
function UserQuery() {
    postForm('/api/user/query', {}).then(resp => {
        let result = resp.data;
        UserQueryList.value = result.data;
    })
}
 
 
defineExpose({
    open,
    formData,
    initFormData,
    treeData,
    isSave,
})
 
</script>
 
<script>
export default {
    name: '用户管理-edit'
}
</script>
 
<template>
    <div>
        <a-modal v-model:open="open"
            :title="isSave ? formatMessage('page.add', '添加') : formatMessage('page.edit', '编辑')" @ok="handleOk"
            style="width: 600px;">
            <a-form :model="formData" name="formTable" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }"
                style="display: flex;justify-content: space-between;flex-wrap: wrap;" autocomplete="off"
                @finish="onFinish" @finishFailed="onFinishFailed">
                <a-form-item label="账号" name="username" style="width: 250px;" :rules="[{ required: true }]">
                    <a-input v-model:value="formData.username" />
                </a-form-item>
                <a-form-item label="密码" name="password" style="width: 250px;">
                    <a-input v-model:value="formData.password" />
                </a-form-item>
                <a-form-item label="昵称" name="nickname" style="width: 250px;">
                    <a-input v-model:value="formData.nickname" />
                </a-form-item>
                <a-form-item label="头像" name="avatar" style="width: 250px;">
                    <a-input v-model:value="formData.avatar" />
                </a-form-item>
                <a-form-item label="工号" name="code" style="width: 250px;">
                    <a-input v-model:value="formData.code" />
                </a-form-item>
                <a-form-item label="性别" name="sex" style="width: 250px;">
                    <a-select v-model:value="formData.sex" :options="[
                        { label: '未知', value: 0 },
                        { label: '男', value: 1 },
                        { label: '女', value: 2 },
                    ]">
                    </a-select>
                </a-form-item>
                <a-form-item label="手机号" name="phone" style="width: 250px;">
                    <a-input v-model:value="formData.phone" />
                </a-form-item>
                <a-form-item label="邮箱" name="email" style="width: 250px;">
                    <a-input v-model:value="formData.email" />
                </a-form-item>
                <a-form-item label="邮箱验证" name="emailVerified" style="width: 250px;">
                    <a-select v-model:value="formData.emailVerified" :options="[
                        { label: '否', value: 0 },
                        { label: '是', value: 1 },
                    ]">
                    </a-select>
                </a-form-item>
                <a-form-item label="所属部门" name="deptId" style="width: 250px;">
                    <a-select v-model:value="formData.deptId" placeholder="Select users" style="width: 100%" show-search
                        :options="DeptQueryList" optionFilterProp="label" optionLabelProp="label">
                    </a-select>
                </a-form-item>
                <a-form-item label="真实姓名" name="realName" style="width: 250px;">
                    <a-input v-model:value="formData.realName" />
                </a-form-item>
                <a-form-item label="身份证号" name="idCard" style="width: 250px;">
                    <a-input v-model:value="formData.idCard" />
                </a-form-item>
                <a-form-item label="出生日期" name="birthday" style="width: 250px;">
                    <a-input v-model:value="formData.birthday" />
                </a-form-item>
                <a-form-item label="个人简介" name="introduction" style="width: 250px;">
                    <a-input v-model:value="formData.introduction" />
                </a-form-item>
                <a-form-item label="状态" name="status" style="width: 250px;">
                    <a-select v-model:value="formData.status" :options="[
                        { label: '正常', value: 1 },
                        { label: '禁用', value: 0 },
                    ]">
                    </a-select>
                </a-form-item>
                <a-form-item label="添加时间" name="createTime" style="width: 250px;">
                    <a-date-picker v-model:value="formData.createTime" show-time format="YYYY-MM-DD HH:mm:ss"
                        value-format="YYYY-MM-DD HH:mm:ss" />
                </a-form-item>
                <a-form-item label="添加人员" name="createBy" style="width: 250px;">
                    <a-select v-model:value="formData.createBy" placeholder="Select users" style="width: 100%"
                        show-search :options="UserQueryList" optionFilterProp="label" optionLabelProp="label">
                    </a-select>
                </a-form-item>
                <a-form-item label="修改时间" name="updateTime" style="width: 250px;">
                    <a-date-picker v-model:value="formData.updateTime" show-time format="YYYY-MM-DD HH:mm:ss"
                        value-format="YYYY-MM-DD HH:mm:ss" />
                </a-form-item>
                <a-form-item label="修改人员" name="updateBy" style="width: 250px;">
                    <a-select v-model:value="formData.updateBy" placeholder="Select users" style="width: 100%"
                        show-search :options="UserQueryList" optionFilterProp="label" optionLabelProp="label">
                    </a-select>
                </a-form-item>
                <a-form-item label="备注" name="memo" style="width: 250px;">
                    <a-input v-model:value="formData.memo" />
                </a-form-item>
 
                <a-form-item>
                    <a-button type="primary" html-type="submit" ref="submitButton"
                        style="visibility: hidden;">Submit</a-button>
                </a-form-item>
            </a-form>
        </a-modal>
    </div>
</template>
 
<style></style>