...
|
...
|
@@ -11,151 +11,71 @@ |
11
|
11
|
</BasicDrawer>
|
12
|
12
|
</template>
|
13
|
13
|
<script lang="ts">
|
14
|
|
-<<<<<<< HEAD:src/views/system/dept/DeptDrawer.vue
|
15
|
14
|
import { defineComponent, ref, computed, unref } from 'vue';
|
16
|
|
- import { BasicForm, useForm } from '/@/components/Form/index';
|
17
|
|
- import { formSchema } from './dept.data';
|
|
15
|
+ import { BasicForm, useForm } from '/@/components/Form';
|
|
16
|
+ import { formSchema } from './organization.data';
|
18
|
17
|
import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
|
19
|
|
-
|
20
|
|
- // 加载部门
|
21
|
|
- import { getDeptList } from '/@/api/system/dept';
|
22
|
18
|
import { useI18n } from '/@/hooks/web/useI18n';
|
23
|
|
- import { saveOrEditDeptApi } from '/@/api/system/dept';
|
24
|
|
-
|
|
19
|
+ import { getOrganizationList, saveOrUpdateOrganization } from '/@/api/system/system';
|
25
|
20
|
export default defineComponent({
|
26
|
|
- name: 'DeptDrawer',
|
|
21
|
+ name: 'OrganizationDrawer',
|
27
|
22
|
components: { BasicDrawer, BasicForm },
|
28
|
23
|
emits: ['success', 'register'],
|
29
|
24
|
setup(_, { emit }) {
|
30
|
25
|
const isUpdate = ref(true);
|
31
|
|
- let deptId, tenantCode, creator, createTime;
|
|
26
|
+ let organizationId;
|
32
|
27
|
|
33
|
28
|
const [registerForm, { resetFields, setFieldsValue, updateSchema, validate }] = useForm({
|
34
|
29
|
labelWidth: 100,
|
35
|
30
|
schemas: formSchema,
|
36
|
31
|
showActionButtonGroup: false,
|
37
|
|
- baseColProps: { lg: 12, md: 24 },
|
38
|
32
|
});
|
39
|
33
|
const { t } = useI18n(); //加载国际化
|
40
|
34
|
|
41
|
35
|
//默认传递页面数据
|
42
|
36
|
const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
|
43
|
|
- resetFields();
|
|
37
|
+ await resetFields();
|
44
|
38
|
setDrawerProps({ confirmLoading: false });
|
45
|
39
|
isUpdate.value = !!data?.isUpdate;
|
46
|
40
|
|
47
|
41
|
//如果是编辑操作,设置页面数据
|
48
|
42
|
if (unref(isUpdate)) {
|
49
|
43
|
//为表单赋值
|
50
|
|
- setFieldsValue({
|
|
44
|
+ await setFieldsValue({
|
51
|
45
|
...data.record,
|
52
|
46
|
});
|
53
|
47
|
}
|
54
|
48
|
if (isUpdate.value) {
|
55
|
|
- tenantCode = Reflect.get(data.record, 'tenantCode');
|
56
|
|
- creator = Reflect.get(data.record, 'creator');
|
57
|
|
- createTime = Reflect.get(data.record, 'createTime');
|
58
|
|
- deptId = Reflect.get(data.record, 'id');
|
|
49
|
+ organizationId = Reflect.get(data.record, 'id');
|
59
|
50
|
}
|
60
|
|
- //加载部门
|
61
|
|
- let treeData = await getDeptList();
|
62
|
|
- updateSchema({
|
|
51
|
+ let treeData = await getOrganizationList();
|
|
52
|
+ await updateSchema({
|
63
|
53
|
field: 'parentId',
|
64
|
54
|
componentProps: { treeData },
|
65
|
55
|
});
|
66
|
56
|
});
|
67
|
|
-=======
|
68
|
|
-import {defineComponent, ref, computed, unref} from 'vue';
|
69
|
|
-import {BasicForm, useForm} from '/@/components/Form';
|
70
|
|
-import {formSchema} from './organization.data';
|
71
|
|
-import {BasicDrawer, useDrawerInner} from '/@/components/Drawer';
|
72
|
|
-import {useI18n} from "/@/hooks/web/useI18n";
|
73
|
|
-import {getOrganizationList, saveOrUpdateOrganization} from "/@/api/system/system";
|
74
|
|
-export default defineComponent({
|
75
|
|
- name: 'OrganizationDrawer',
|
76
|
|
- components: {BasicDrawer, BasicForm},
|
77
|
|
- emits: ['success', 'register'],
|
78
|
|
- setup(_, {emit}) {
|
79
|
|
- const isUpdate = ref(true);
|
80
|
|
- let organizationId;
|
81
|
|
-
|
82
|
|
- const [registerForm, {resetFields, setFieldsValue, updateSchema, validate}] = useForm({
|
83
|
|
- labelWidth: 100,
|
84
|
|
- schemas: formSchema,
|
85
|
|
- showActionButtonGroup: false
|
86
|
|
- });
|
87
|
|
- const {t} = useI18n(); //加载国际化
|
88
|
|
-
|
89
|
|
- //默认传递页面数据
|
90
|
|
- const [registerDrawer, {setDrawerProps, closeDrawer}] = useDrawerInner(async (data) => {
|
91
|
|
- await resetFields();
|
92
|
|
- setDrawerProps({confirmLoading: false});
|
93
|
|
- isUpdate.value = !!data?.isUpdate;
|
94
|
|
-
|
95
|
|
- //如果是编辑操作,设置页面数据
|
96
|
|
- if (unref(isUpdate)) {
|
97
|
|
- //为表单赋值
|
98
|
|
- await setFieldsValue({
|
99
|
|
- ...data.record,
|
100
|
|
- });
|
101
|
|
-
|
102
|
|
- }
|
103
|
|
- if (isUpdate.value) {
|
104
|
|
- organizationId = Reflect.get(data.record, 'id');
|
105
|
|
- }
|
106
|
|
- let treeData = await getOrganizationList();
|
107
|
|
- await updateSchema({
|
108
|
|
- field: 'parentId',
|
109
|
|
- componentProps: {treeData},
|
110
|
|
- });
|
111
|
|
- });
|
112
|
|
-
|
113
|
|
- //得到页面标题
|
114
|
|
- const getTitle = computed(() => (!unref(isUpdate) ? t('routes.common.organization.toolCreateOrganization') : t('routes.common.organization.toolEditOrganization')));
|
115
|
|
->>>>>>> main:src/views/system/organization/OrganizationDrawer.vue
|
116
|
57
|
|
117
|
58
|
//得到页面标题
|
118
|
59
|
const getTitle = computed(() =>
|
119
|
60
|
!unref(isUpdate)
|
120
|
|
- ? t('routes.common.dept.toolCreateDept')
|
121
|
|
- : t('routes.common.dept.toolEditDept')
|
|
61
|
+ ? t('routes.common.organization.toolCreateOrganization')
|
|
62
|
+ : t('routes.common.organization.toolEditOrganization')
|
122
|
63
|
);
|
123
|
64
|
|
124
|
|
-<<<<<<< HEAD:src/views/system/dept/DeptDrawer.vue
|
125
|
65
|
//提交按钮
|
126
|
66
|
async function handleSubmit() {
|
127
|
67
|
try {
|
128
|
68
|
const values = await validate();
|
129
|
69
|
setDrawerProps({ confirmLoading: true });
|
130
|
|
-
|
131
|
70
|
if (isUpdate.value) {
|
132
|
|
- Reflect.set(values, 'id', deptId);
|
133
|
|
- Reflect.set(values, 'tenantCode', tenantCode);
|
134
|
|
- Reflect.set(values, 'creator', creator);
|
135
|
|
- Reflect.set(values, 'createTime', createTime);
|
|
71
|
+ Reflect.set(values, 'id', organizationId);
|
136
|
72
|
}
|
137
|
|
-
|
138
|
|
- // TODO custom api
|
139
|
|
- // console.log("-------------提交后台的参数-------------------");
|
140
|
|
- // console.log(values);
|
141
|
|
- const data = await saveOrEditDeptApi(values, isUpdate.value);
|
142
|
|
- console.log('_______保存返回结果____data:', data);
|
143
|
|
-
|
|
73
|
+ await saveOrUpdateOrganization(values, isUpdate.value);
|
144
|
74
|
closeDrawer(); //关闭侧框
|
145
|
75
|
emit('success');
|
146
|
76
|
} finally {
|
147
|
77
|
setDrawerProps({ confirmLoading: false });
|
148
|
78
|
}
|
149
|
|
-=======
|
150
|
|
- if (isUpdate.value) {
|
151
|
|
- Reflect.set(values, 'id', organizationId);
|
152
|
|
- }
|
153
|
|
- await saveOrUpdateOrganization(values, isUpdate.value);
|
154
|
|
- closeDrawer();//关闭侧框
|
155
|
|
- emit('success');
|
156
|
|
- } finally {
|
157
|
|
- setDrawerProps({confirmLoading: false});
|
158
|
|
->>>>>>> main:src/views/system/organization/OrganizationDrawer.vue
|
159
|
79
|
}
|
160
|
80
|
|
161
|
81
|
return { registerDrawer, registerForm, getTitle, handleSubmit };
|
...
|
...
|
|