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