|
@@ -1,10 +1,11 @@
|
|
<template>
|
|
<template>
|
|
<my-dialog
|
|
<my-dialog
|
|
- v-model:visible="visible"
|
|
|
|
- @close="emit('close')"
|
|
|
|
- :header="`${!!curRow ? '修改' : '新增'}用户`"
|
|
|
|
|
|
+ :visible="visible"
|
|
|
|
+ @close="emit('update:visible', false)"
|
|
|
|
+ :header="`${isEdit ? '修改' : '新增'}用户`"
|
|
:width="600"
|
|
:width="600"
|
|
:closeOnOverlayClick="false"
|
|
:closeOnOverlayClick="false"
|
|
|
|
+ :callBacks="[run1, run2.bind(null, { pageNumber: 1, pageSize: 1000 })]"
|
|
>
|
|
>
|
|
<t-form ref="formRef" :data="formData" labelWidth="120px" :rules="rules">
|
|
<t-form ref="formRef" :data="formData" labelWidth="120px" :rules="rules">
|
|
<t-form-item label="登录名" name="loginName">
|
|
<t-form-item label="登录名" name="loginName">
|
|
@@ -38,31 +39,24 @@
|
|
</t-form-item>
|
|
</t-form-item>
|
|
</t-form>
|
|
</t-form>
|
|
<template #foot>
|
|
<template #foot>
|
|
- <t-button theme="default" @click="visible = false">取消</t-button>
|
|
|
|
|
|
+ <t-button theme="default" @click="emit('update:visible', false)"
|
|
|
|
+ >取消</t-button
|
|
|
|
+ >
|
|
<t-button theme="primary" @click="save">保存</t-button>
|
|
<t-button theme="primary" @click="save">保存</t-button>
|
|
</template>
|
|
</template>
|
|
</my-dialog>
|
|
</my-dialog>
|
|
</template>
|
|
</template>
|
|
<script setup name="AddUserDialog">
|
|
<script setup name="AddUserDialog">
|
|
-// import useClearDialog from '@/hooks/useClearDialog';
|
|
|
|
-import { ref, computed, reactive } from 'vue';
|
|
|
|
|
|
+import useClearDialog from '@/hooks/useClearDialog';
|
|
|
|
+import { ref, computed } from 'vue';
|
|
import { getOrgStructList, getRoleList, addUser } from '@/api/user';
|
|
import { getOrgStructList, getRoleList, addUser } from '@/api/user';
|
|
import { useRequest } from 'vue-request';
|
|
import { useRequest } from 'vue-request';
|
|
-const visible = ref(false);
|
|
|
|
const props = defineProps({
|
|
const props = defineProps({
|
|
- // visible: Boolean,
|
|
|
|
|
|
+ visible: Boolean,
|
|
curRow: Object,
|
|
curRow: Object,
|
|
});
|
|
});
|
|
const emit = defineEmits(['close', 'success']);
|
|
const emit = defineEmits(['close', 'success']);
|
|
const formRef = ref(null);
|
|
const formRef = ref(null);
|
|
-const formData = reactive({
|
|
|
|
- loginName: '',
|
|
|
|
- realName: '',
|
|
|
|
- genderStr: '男',
|
|
|
|
- mobileNumber: '',
|
|
|
|
- orgId: '',
|
|
|
|
- roleIds: [],
|
|
|
|
-});
|
|
|
|
const getDetail = async () => {
|
|
const getDetail = async () => {
|
|
//编辑状态下获取回显数据的接口请求业务,如果curRow里的字段够用,就直接把curRow里的字段赋值给formData
|
|
//编辑状态下获取回显数据的接口请求业务,如果curRow里的字段够用,就直接把curRow里的字段赋值给formData
|
|
for (let key in formData) {
|
|
for (let key in formData) {
|
|
@@ -72,17 +66,21 @@ const getDetail = async () => {
|
|
}
|
|
}
|
|
formData.roleIds = props.curRow.roles.map((item) => item.id);
|
|
formData.roleIds = props.curRow.roles.map((item) => item.id);
|
|
};
|
|
};
|
|
-
|
|
|
|
-if (!!props.curRow) {
|
|
|
|
- getDetail();
|
|
|
|
-}
|
|
|
|
-const { data: treeData } = useRequest(getOrgStructList, {
|
|
|
|
- manual: false,
|
|
|
|
-});
|
|
|
|
-const { data: roleData } = useRequest(getRoleList, {
|
|
|
|
- manual: false,
|
|
|
|
- defaultParams: [{ pageNumber: 1, pageSize: 1000 }],
|
|
|
|
-});
|
|
|
|
|
|
+const { formData, isEdit } = useClearDialog(
|
|
|
|
+ {
|
|
|
|
+ loginName: '',
|
|
|
|
+ realName: '',
|
|
|
|
+ genderStr: '男',
|
|
|
|
+ mobileNumber: '',
|
|
|
|
+ orgId: '',
|
|
|
|
+ roleIds: [],
|
|
|
|
+ },
|
|
|
|
+ props,
|
|
|
|
+ formRef,
|
|
|
|
+ getDetail
|
|
|
|
+);
|
|
|
|
+const { data: treeData, run: run1 } = useRequest(getOrgStructList);
|
|
|
|
+const { data: roleData, run: run2 } = useRequest(getRoleList);
|
|
const roleList = computed(() => {
|
|
const roleList = computed(() => {
|
|
return roleData.value?.records.map((item) => ({
|
|
return roleData.value?.records.map((item) => ({
|
|
label: item.name,
|
|
label: item.name,
|