|
@@ -77,14 +77,24 @@
|
|
|
</div>
|
|
</div>
|
|
|
<div class="form-group">
|
|
<div class="form-group">
|
|
|
<label>{{ $t("lang.OrganizationEditPanel.superiorDepartment") }}</label>
|
|
<label>{{ $t("lang.OrganizationEditPanel.superiorDepartment") }}</label>
|
|
|
- <SearchWidget
|
|
|
|
|
|
|
+ <a-tree-select
|
|
|
|
|
+ v-model:value="organization.parentId"
|
|
|
|
|
+ show-search
|
|
|
|
|
+ allow-clear
|
|
|
|
|
+ style="width: 100%"
|
|
|
|
|
+ :tree-data="organizations"
|
|
|
|
|
+ tree-node-filter-prop="label"
|
|
|
|
|
+ :dropdown-style="{ maxHeight: '300px', overflow: 'auto' }"
|
|
|
|
|
+ @change="parentOrganizationValueChanged"
|
|
|
|
|
+ />
|
|
|
|
|
+ <!-- <SearchWidget
|
|
|
info-window-no="20220420_233656"
|
|
info-window-no="20220420_233656"
|
|
|
:field-value="parentOrganizationFieldValue"
|
|
:field-value="parentOrganizationFieldValue"
|
|
|
:title-name="$t('lang.OrganizationEditPanel.departmentInquiry')"
|
|
:title-name="$t('lang.OrganizationEditPanel.departmentInquiry')"
|
|
|
display-name="name"
|
|
display-name="name"
|
|
|
:where-clause-source="parentOrganizationAdditionHql"
|
|
:where-clause-source="parentOrganizationAdditionHql"
|
|
|
@value-changed="parentOrganizationValueChanged"
|
|
@value-changed="parentOrganizationValueChanged"
|
|
|
- />
|
|
|
|
|
|
|
+ /> -->
|
|
|
</div>
|
|
</div>
|
|
|
<div class="form-group">
|
|
<div class="form-group">
|
|
|
<label>{{ $t("lang.OrganizationEditPanel.departmentProfile") }}</label>
|
|
<label>{{ $t("lang.OrganizationEditPanel.departmentProfile") }}</label>
|
|
@@ -183,6 +193,8 @@ import {
|
|
|
getAllOrganization,
|
|
getAllOrganization,
|
|
|
} from '../api/department/index';
|
|
} from '../api/department/index';
|
|
|
import { message } from 'ant-design-vue';
|
|
import { message } from 'ant-design-vue';
|
|
|
|
|
+import { TreeSelect } from 'ant-design-vue';
|
|
|
|
|
+const SHOW_PARENT = TreeSelect.SHOW_PARENT;
|
|
|
|
|
|
|
|
const clientId = ref(''); //公司id
|
|
const clientId = ref(''); //公司id
|
|
|
const id = ref(''); //公司id
|
|
const id = ref(''); //公司id
|
|
@@ -197,30 +209,24 @@ const organization = ref({}); // 部门详情
|
|
|
const client = ref({}); // 公司详情
|
|
const client = ref({}); // 公司详情
|
|
|
const editVisible = ref(false); // 抽屉开关
|
|
const editVisible = ref(false); // 抽屉开关
|
|
|
const organizationId = ref(''); // 所选部门ID
|
|
const organizationId = ref(''); // 所选部门ID
|
|
|
-// const clientAdditionHql = ref({});
|
|
|
|
|
const clientNameStr = ref('');
|
|
const clientNameStr = ref('');
|
|
|
const { proxy } = getCurrentInstance(); //访问this
|
|
const { proxy } = getCurrentInstance(); //访问this
|
|
|
-const parentOrganizationAdditionHql = ref('');
|
|
|
|
|
-const parentFieldValue = ref({});
|
|
|
|
|
-const parentOrganizationFieldValue = ref({
|
|
|
|
|
- displayValue: [],
|
|
|
|
|
- fieldType: 'Key',
|
|
|
|
|
- id: null,
|
|
|
|
|
-});
|
|
|
|
|
-const clientFieldValue = ref({
|
|
|
|
|
- displayValue: [],
|
|
|
|
|
- fieldType: 'Key',
|
|
|
|
|
- id: null,
|
|
|
|
|
-});
|
|
|
|
|
|
|
+const superiorDepartment = ref('');
|
|
|
|
|
+const organizations = ref([]);
|
|
|
|
|
+const oldParentId = ref('');
|
|
|
|
|
+const oldParentName = ref('');
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
getComponyInfo();
|
|
getComponyInfo();
|
|
|
});
|
|
});
|
|
|
// 获取公司名称id
|
|
// 获取公司名称id
|
|
|
const getComponyInfo = () => {
|
|
const getComponyInfo = () => {
|
|
|
|
|
+ companies.value = [];
|
|
|
getCompony().then(
|
|
getCompony().then(
|
|
|
success => {
|
|
success => {
|
|
|
if (success.errorCode == 0) {
|
|
if (success.errorCode == 0) {
|
|
|
- companies.value = success.datas;
|
|
|
|
|
|
|
+ if (success.datas && success.datas.length > 0) {
|
|
|
|
|
+ getALLClient(success.datas);
|
|
|
|
|
+ }
|
|
|
} else {
|
|
} else {
|
|
|
message.error(success.errorMessage);
|
|
message.error(success.errorMessage);
|
|
|
}
|
|
}
|
|
@@ -230,7 +236,15 @@ const getComponyInfo = () => {
|
|
|
},
|
|
},
|
|
|
);
|
|
);
|
|
|
};
|
|
};
|
|
|
-
|
|
|
|
|
|
|
+// 展示子公司数据
|
|
|
|
|
+const getALLClient = datas => {
|
|
|
|
|
+ datas.forEach(item => {
|
|
|
|
|
+ companies.value.push({ id: item.id, name: item.name });
|
|
|
|
|
+ if (item.childrenClients && item.childrenClients.length > 0) {
|
|
|
|
|
+ getALLClient(item.childrenClients);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+};
|
|
|
// 编辑公司(获取公司信息)
|
|
// 编辑公司(获取公司信息)
|
|
|
const editClient = () => {
|
|
const editClient = () => {
|
|
|
if (clientNameStr.value) {
|
|
if (clientNameStr.value) {
|
|
@@ -287,22 +301,12 @@ const getClientId = (value, client) => {
|
|
|
const createOrganization = () => {
|
|
const createOrganization = () => {
|
|
|
organization.value = {};
|
|
organization.value = {};
|
|
|
organization.value.clientName = clientNameStr.value;
|
|
organization.value.clientName = clientNameStr.value;
|
|
|
- (clientFieldValue.value = {
|
|
|
|
|
- displayValue: [],
|
|
|
|
|
- fieldType: 'Key',
|
|
|
|
|
- id: null,
|
|
|
|
|
- }),
|
|
|
|
|
- (parentOrganizationFieldValue.value = {
|
|
|
|
|
- displayValue: [],
|
|
|
|
|
- fieldType: 'Key',
|
|
|
|
|
- id: null,
|
|
|
|
|
- });
|
|
|
|
|
- parentOrganizationAdditionHql.value = '';
|
|
|
|
|
|
|
+ organization.value.parentId = null;
|
|
|
|
|
+ organization.value.parentName = null;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// 创建按钮
|
|
// 创建按钮
|
|
|
const createNew = organization => {
|
|
const createNew = organization => {
|
|
|
- organization.parentName = parentOrganizationFieldValue.value.displayValue[0];
|
|
|
|
|
organization.clientId = id.value;
|
|
organization.clientId = id.value;
|
|
|
create(organization).then(
|
|
create(organization).then(
|
|
|
success => {
|
|
success => {
|
|
@@ -336,6 +340,7 @@ const getOrganization = () => {
|
|
|
datas.push(item.childrenOrganizations);
|
|
datas.push(item.childrenOrganizations);
|
|
|
});
|
|
});
|
|
|
traversalTree(datas.flat(1), dataSource.value);
|
|
traversalTree(datas.flat(1), dataSource.value);
|
|
|
|
|
+ clientOrganizations(dataSource.value);
|
|
|
}
|
|
}
|
|
|
// loadAllSubClients();
|
|
// loadAllSubClients();
|
|
|
},
|
|
},
|
|
@@ -344,7 +349,17 @@ const getOrganization = () => {
|
|
|
},
|
|
},
|
|
|
);
|
|
);
|
|
|
};
|
|
};
|
|
|
-
|
|
|
|
|
|
|
+// 处理上级部门数据
|
|
|
|
|
+const clientOrganizations = datas => {
|
|
|
|
|
+ datas.forEach(item => {
|
|
|
|
|
+ item.value = item.id;
|
|
|
|
|
+ item.label = item.name;
|
|
|
|
|
+ if (item.children && item.children.length > 0) {
|
|
|
|
|
+ clientOrganizations(item.children);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ organizations.value = datas;
|
|
|
|
|
+};
|
|
|
// 编辑部门(获取部门信息)
|
|
// 编辑部门(获取部门信息)
|
|
|
const editOrganization = (flag, id) => {
|
|
const editOrganization = (flag, id) => {
|
|
|
organizationId.value = id;
|
|
organizationId.value = id;
|
|
@@ -365,17 +380,8 @@ const editOrganization = (flag, id) => {
|
|
|
success => {
|
|
success => {
|
|
|
if (success.errorCode == 0) {
|
|
if (success.errorCode == 0) {
|
|
|
organization.value = success.data;
|
|
organization.value = success.data;
|
|
|
- parentOrganizationFieldValue.value = {
|
|
|
|
|
- displayValue: [success.data.parentName],
|
|
|
|
|
- fieldType: 'Key',
|
|
|
|
|
- id: success.data.parentId,
|
|
|
|
|
- };
|
|
|
|
|
- parentFieldValue.value = parentOrganizationFieldValue.value;
|
|
|
|
|
- clientFieldValue.value = {
|
|
|
|
|
- displayValue: [success.data.clientName],
|
|
|
|
|
- fieldType: 'Key',
|
|
|
|
|
- id: success.data.clientId,
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ oldParentName.value = success.data.parentName;
|
|
|
|
|
+ oldParentId.value = success.data.parentId;
|
|
|
fetchUserList();
|
|
fetchUserList();
|
|
|
} else {
|
|
} else {
|
|
|
message.error(success.errorMessage);
|
|
message.error(success.errorMessage);
|
|
@@ -407,12 +413,6 @@ const updateOrganization = () => {
|
|
|
if (success.data) {
|
|
if (success.data) {
|
|
|
message.success(proxy.$t('lang.OrganizationEditPanel.describe6'));
|
|
message.success(proxy.$t('lang.OrganizationEditPanel.describe6'));
|
|
|
organization.value = {};
|
|
organization.value = {};
|
|
|
- organization.value.clientId = clientFieldValue.value.id;
|
|
|
|
|
- parentOrganizationFieldValue.value = {
|
|
|
|
|
- displayValue: [],
|
|
|
|
|
- fieldType: 'Key',
|
|
|
|
|
- id: null,
|
|
|
|
|
- };
|
|
|
|
|
getOrganization();
|
|
getOrganization();
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
@@ -493,26 +493,21 @@ const fetchUserList = (search, loading) => {
|
|
|
},
|
|
},
|
|
|
);
|
|
);
|
|
|
};
|
|
};
|
|
|
-// 公司change事件
|
|
|
|
|
-const clientValueChanged = newFieldValue => {
|
|
|
|
|
- clientFieldValue.value = newFieldValue;
|
|
|
|
|
- organization.value.clientId = newFieldValue.id;
|
|
|
|
|
- parentOrganizationAdditionHql.value = ' client.id = ' + newFieldValue.id; // 添加部门约束
|
|
|
|
|
-};
|
|
|
|
|
|
|
|
|
|
// 上级部门change事件
|
|
// 上级部门change事件
|
|
|
-const parentOrganizationValueChanged = newFieldValue => {
|
|
|
|
|
- if (organizationId.value == newFieldValue.id) {
|
|
|
|
|
|
|
+const parentOrganizationValueChanged = (value, label) => {
|
|
|
|
|
+ if(!value && label.length == 0){
|
|
|
|
|
+ organization.value.parentId = null;
|
|
|
|
|
+ organization.value.parentName = null;
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (organizationId.value == value) {
|
|
|
message.warning('不能将自己作为上级部门!');
|
|
message.warning('不能将自己作为上级部门!');
|
|
|
- parentOrganizationFieldValue.value = {
|
|
|
|
|
- displayValue: [parentFieldValue.value.displayValue[0]],
|
|
|
|
|
- fieldType: 'Key',
|
|
|
|
|
- id: parentFieldValue.value.id,
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ organization.value.parentId = oldParentId.value;
|
|
|
|
|
+ organization.value.parentName = oldParentName.value;
|
|
|
} else {
|
|
} else {
|
|
|
- parentOrganizationFieldValue.value = newFieldValue;
|
|
|
|
|
- organization.value.parentId = newFieldValue.id;
|
|
|
|
|
- organization.value.parentName = newFieldValue.displayValue[0];
|
|
|
|
|
|
|
+ organization.value.parentId = value;
|
|
|
|
|
+ organization.value.parentName = label[0];
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|