|
|
@@ -12,6 +12,15 @@
|
|
|
<a-button type="dashed" style="margin-left: 8px" @click="getOrganization">
|
|
|
{{ $t("lang.OrganizationEditPanel.refresh") }}
|
|
|
</a-button>
|
|
|
+ <a-select
|
|
|
+ v-model:value="clientIdStr"
|
|
|
+ show-search
|
|
|
+ option-filter-prop="label"
|
|
|
+ style="width: 50%; margin-left: 16px"
|
|
|
+ placeholder="请选择公司"
|
|
|
+ :options="companies.map((item) => ({ value: item.id, label: item.name }))"
|
|
|
+ @change="getClientId"
|
|
|
+ />
|
|
|
</div>
|
|
|
|
|
|
<a-table
|
|
|
@@ -46,12 +55,9 @@
|
|
|
>
|
|
|
<div class="form-group">
|
|
|
<label>{{ $t("lang.OrganizationEditPanel.corporateName") }}</label>
|
|
|
- <a-input
|
|
|
- v-if="organization.id"
|
|
|
- v-model:value="organization.clientName"
|
|
|
- disabled
|
|
|
- />
|
|
|
- <SearchWidget
|
|
|
+ <!-- v-if="organization.id" -->
|
|
|
+ <a-input v-model:value="organization.clientName" disabled />
|
|
|
+ <!-- <SearchWidget
|
|
|
v-else
|
|
|
info-window-no="286633"
|
|
|
:field-value="clientFieldValue"
|
|
|
@@ -59,7 +65,7 @@
|
|
|
display-name="ct.name"
|
|
|
:where-clause-source="clientAdditionHql"
|
|
|
@value-changed="clientValueChanged"
|
|
|
- />
|
|
|
+ /> -->
|
|
|
</div>
|
|
|
<div class="form-group">
|
|
|
<label>{{ $t("lang.OrganizationEditPanel.departmentNumber") }}</label>
|
|
|
@@ -102,7 +108,14 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
<template #footer>
|
|
|
- <a-button type="primary" @click="saveOrUpdate(organization.id)">
|
|
|
+ <a-button v-if="isCreate" type="primary" @click="createNew(organization)">
|
|
|
+ 创建
|
|
|
+ </a-button>
|
|
|
+ <a-button
|
|
|
+ v-else
|
|
|
+ type="primary"
|
|
|
+ @click="updateOrganization(organization.id)"
|
|
|
+ >
|
|
|
{{ $t("lang.OrganizationEditPanel.save") }}
|
|
|
</a-button>
|
|
|
</template>
|
|
|
@@ -118,20 +131,28 @@ import { ref, onMounted, getCurrentInstance } from 'vue';
|
|
|
|
|
|
import {
|
|
|
columns,
|
|
|
- getAllOrganization,
|
|
|
- loadOrganization,
|
|
|
- loadSubClients,
|
|
|
+ create,
|
|
|
+ update,
|
|
|
+ getCompony,
|
|
|
getUsersByName,
|
|
|
+ loadOrganization,
|
|
|
deleteDepartment,
|
|
|
- save,
|
|
|
+ getAllOrganization,
|
|
|
} from '../api/department/index';
|
|
|
+import { message } from 'ant-design-vue';
|
|
|
|
|
|
+const clientId = ref(''); //公司id
|
|
|
+const id = ref(''); //公司id
|
|
|
+const companies = ref([]); //所有公司
|
|
|
+const clientIdStr = ref(undefined);
|
|
|
const userList = ref([]); // 用户清单
|
|
|
+const isCreate = ref(false); // 是否新建
|
|
|
const dataSource = ref([]); // 表格部门
|
|
|
const drawerTitle = ref(''); //抽屉标题
|
|
|
const organization = ref({}); // 部门详情
|
|
|
const editVisible = ref(false); // 抽屉开关
|
|
|
-const clientAdditionHql = ref('');
|
|
|
+// const clientAdditionHql = ref({});
|
|
|
+const clientNameStr = ref('');
|
|
|
const { proxy } = getCurrentInstance(); //访问this
|
|
|
const parentOrganizationAdditionHql = ref('');
|
|
|
const parentOrganizationFieldValue = ref({
|
|
|
@@ -145,12 +166,34 @@ const clientFieldValue = ref({
|
|
|
id: null,
|
|
|
});
|
|
|
onMounted(() => {
|
|
|
- getOrganization();
|
|
|
+ getCompony().then(
|
|
|
+ success => {
|
|
|
+ if (success.errorCode == 0) {
|
|
|
+ companies.value = success.datas;
|
|
|
+ } else {
|
|
|
+ message.error(success.errorMessage);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ err => {
|
|
|
+ Common.processException(err);
|
|
|
+ },
|
|
|
+ );
|
|
|
});
|
|
|
|
|
|
+// 获取所选公司id 名字
|
|
|
+const getClientId = (value, client) => {
|
|
|
+ id.value = value;
|
|
|
+ clientId.value = value;
|
|
|
+ clientNameStr.value = client.label;
|
|
|
+ getOrganization();
|
|
|
+};
|
|
|
+
|
|
|
// 新建部门
|
|
|
const createOrganization = () => {
|
|
|
+ console.log(clientNameStr.value, '6666');
|
|
|
organization.value = {};
|
|
|
+ organization.value.clientName = clientNameStr.value;
|
|
|
+ organization.value.clientName = clientNameStr.value;
|
|
|
(clientFieldValue.value = {
|
|
|
displayValue: [],
|
|
|
fieldType: 'Key',
|
|
|
@@ -164,15 +207,19 @@ const createOrganization = () => {
|
|
|
parentOrganizationAdditionHql.value = '';
|
|
|
};
|
|
|
|
|
|
-// 获取所有部门
|
|
|
-const getOrganization = () => {
|
|
|
- dataSource.value = [];
|
|
|
- getAllOrganization().then(
|
|
|
+// 创建按钮
|
|
|
+const createNew = organization => {
|
|
|
+ organization.parentName = parentOrganizationFieldValue.value.displayValue[0];
|
|
|
+ organization.clientId = id.value;
|
|
|
+ create(organization).then(
|
|
|
success => {
|
|
|
if (success.errorCode == 0) {
|
|
|
- traversalTree(success.datas, dataSource.value);
|
|
|
+ message.success('新建部门成功');
|
|
|
+ getOrganization();
|
|
|
+ editVisible.value = false;
|
|
|
+ } else {
|
|
|
+ message.error(success.errorMessage);
|
|
|
}
|
|
|
- loadAllSubClients();
|
|
|
},
|
|
|
err => {
|
|
|
Common.processException(err);
|
|
|
@@ -180,39 +227,20 @@ const getOrganization = () => {
|
|
|
);
|
|
|
};
|
|
|
|
|
|
-// 获取所有子部门
|
|
|
-const loadAllSubClients = () => {
|
|
|
- var rootClientId = null;
|
|
|
- for (let index = 0; index < dataSource.value.length; index++) {
|
|
|
- var clientOrganization = dataSource.value[index];
|
|
|
- if (clientOrganization.children == null) {
|
|
|
- rootClientId = clientOrganization.id;
|
|
|
- }
|
|
|
- }
|
|
|
- loadSubClients(rootClientId).then(
|
|
|
+// 获取所有部门
|
|
|
+const getOrganization = () => {
|
|
|
+ dataSource.value = [];
|
|
|
+ const datas = [];
|
|
|
+ const id = clientId.value;
|
|
|
+ getAllOrganization(id).then(
|
|
|
success => {
|
|
|
- if (success) {
|
|
|
- clientAdditionHql.value = ' ct.id in (' + success.join(',') + ')';
|
|
|
- } else {
|
|
|
- clientAdditionHql.value = {
|
|
|
- customerDataDimensions: [
|
|
|
- {
|
|
|
- fieldName: 'ct.id',
|
|
|
- dataDimensionTypeNo: '202201191757',
|
|
|
- defaultDataDimensionTypeValueNo: '1',
|
|
|
- },
|
|
|
- ],
|
|
|
- };
|
|
|
- parentOrganizationAdditionHql.value = {
|
|
|
- customerDataDimensions: [
|
|
|
- {
|
|
|
- fieldName: 'organization.id',
|
|
|
- dataDimensionTypeNo: '202201191700',
|
|
|
- defaultDataDimensionTypeValueNo: '1',
|
|
|
- },
|
|
|
- ],
|
|
|
- };
|
|
|
+ if (success.errorCode == 0) {
|
|
|
+ success.datas.forEach(item => {
|
|
|
+ datas.push(item.childrenOrganizations);
|
|
|
+ });
|
|
|
+ traversalTree(datas.flat(1), dataSource.value);
|
|
|
}
|
|
|
+ // loadAllSubClients();
|
|
|
},
|
|
|
err => {
|
|
|
Common.processException(err);
|
|
|
@@ -222,37 +250,48 @@ const loadAllSubClients = () => {
|
|
|
|
|
|
// 编辑部门
|
|
|
const editOrganization = (flag, id) => {
|
|
|
- editVisible.value = true;
|
|
|
if (flag) {
|
|
|
- drawerTitle.value = '新建部门';
|
|
|
- createOrganization();
|
|
|
- fetchUserList();
|
|
|
+ if (clientNameStr.value !== '') {
|
|
|
+ editVisible.value = true;
|
|
|
+ drawerTitle.value = '新建部门';
|
|
|
+ createOrganization();
|
|
|
+ fetchUserList();
|
|
|
+ isCreate.value = true;
|
|
|
+ } else {
|
|
|
+ message.warning('请选择公司');
|
|
|
+ }
|
|
|
} else {
|
|
|
+ editVisible.value = true;
|
|
|
drawerTitle.value = '编辑部门';
|
|
|
loadOrganization(id).then(
|
|
|
success => {
|
|
|
- organization.value = success;
|
|
|
- parentOrganizationFieldValue.value = {
|
|
|
- displayValue: [success.parentName],
|
|
|
- fieldType: 'Key',
|
|
|
- id: success.parentId,
|
|
|
- };
|
|
|
- clientFieldValue.value = {
|
|
|
- displayValue: [success.clientName],
|
|
|
- fieldType: 'Key',
|
|
|
- id: success.clientId,
|
|
|
- };
|
|
|
- fetchUserList();
|
|
|
+ if (success.errorCode == 0) {
|
|
|
+ organization.value = success.data;
|
|
|
+ parentOrganizationFieldValue.value = {
|
|
|
+ displayValue: [success.data.parentName],
|
|
|
+ fieldType: 'Key',
|
|
|
+ id: success.data.parentId,
|
|
|
+ };
|
|
|
+ clientFieldValue.value = {
|
|
|
+ displayValue: [success.data.clientName],
|
|
|
+ fieldType: 'Key',
|
|
|
+ id: success.data.clientId,
|
|
|
+ };
|
|
|
+ fetchUserList();
|
|
|
+ } else {
|
|
|
+ message.error(success.errorMessage);
|
|
|
+ }
|
|
|
},
|
|
|
err => {
|
|
|
Common.processException(err);
|
|
|
},
|
|
|
+ (isCreate.value = false),
|
|
|
);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
//保存事件
|
|
|
-const saveOrUpdate = () => {
|
|
|
+const updateOrganization = () => {
|
|
|
const organizationValue = JSON.parse(JSON.stringify(organization.value));
|
|
|
const { clientId, name, no } = organizationValue;
|
|
|
if (
|
|
|
@@ -270,22 +309,28 @@ const saveOrUpdate = () => {
|
|
|
);
|
|
|
return;
|
|
|
}
|
|
|
- save(organizationValue).then(
|
|
|
+ update(organizationValue).then(
|
|
|
success => {
|
|
|
- Notify.success(
|
|
|
- proxy.$t('lang.Notify.success'),
|
|
|
- proxy.$t('lang.OrganizationEditPanel.describe6'),
|
|
|
- true,
|
|
|
- );
|
|
|
- organization.value = {};
|
|
|
+ if (success.errorCode == 0) {
|
|
|
+ if (success.data) {
|
|
|
+ Notify.success(
|
|
|
+ proxy.$t('lang.Notify.success'),
|
|
|
+ proxy.$t('lang.OrganizationEditPanel.describe6'),
|
|
|
+ true,
|
|
|
+ );
|
|
|
+ organization.value = {};
|
|
|
|
|
|
- organization.value.clientId = clientFieldValue.value.id;
|
|
|
- parentOrganizationFieldValue.value = {
|
|
|
- displayValue: [],
|
|
|
- fieldType: 'Key',
|
|
|
- id: null,
|
|
|
- };
|
|
|
- getOrganization();
|
|
|
+ organization.value.clientId = clientFieldValue.value.id;
|
|
|
+ parentOrganizationFieldValue.value = {
|
|
|
+ displayValue: [],
|
|
|
+ fieldType: 'Key',
|
|
|
+ id: null,
|
|
|
+ };
|
|
|
+ getOrganization();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ message.error(success.errorMessage);
|
|
|
+ }
|
|
|
editVisible.value = false;
|
|
|
},
|
|
|
err => {
|
|
|
@@ -298,7 +343,7 @@ const saveOrUpdate = () => {
|
|
|
const deleteOrganization = id => {
|
|
|
loadOrganization(id).then(
|
|
|
success => {
|
|
|
- const organization = success;
|
|
|
+ const organization = success.data;
|
|
|
if (organization == undefined) {
|
|
|
Notify.error(
|
|
|
proxy.$t('lang.Notify.error'),
|
|
|
@@ -307,15 +352,24 @@ const deleteOrganization = id => {
|
|
|
);
|
|
|
return;
|
|
|
}
|
|
|
- deleteDepartment(organization).then(
|
|
|
+ const params = {
|
|
|
+ id: organization.id,
|
|
|
+ no: organization.no,
|
|
|
+ name: organization.name,
|
|
|
+ };
|
|
|
+ deleteDepartment(params).then(
|
|
|
success => {
|
|
|
- Notify.success(
|
|
|
- proxy.$t('lang.Notify.success'),
|
|
|
- proxy.$t('lang.OrganizationEditPanel.describe3'),
|
|
|
- true,
|
|
|
- );
|
|
|
- organization.value = undefined;
|
|
|
- getOrganization();
|
|
|
+ if (success.errorCode == 0) {
|
|
|
+ Notify.success(
|
|
|
+ proxy.$t('lang.Notify.success'),
|
|
|
+ proxy.$t('lang.OrganizationEditPanel.describe3'),
|
|
|
+ true,
|
|
|
+ );
|
|
|
+ organization.value = undefined;
|
|
|
+ getOrganization();
|
|
|
+ }else{
|
|
|
+ message.error(success.errorMessage);
|
|
|
+ }
|
|
|
},
|
|
|
err => {
|
|
|
Common.processException(err);
|
|
|
@@ -365,26 +419,79 @@ const clientValueChanged = newFieldValue => {
|
|
|
|
|
|
// 上级部门change事件
|
|
|
const parentOrganizationValueChanged = newFieldValue => {
|
|
|
+ console.log(newFieldValue, '555555555555555555');
|
|
|
parentOrganizationFieldValue.value = newFieldValue;
|
|
|
organization.value.parentId = newFieldValue.id;
|
|
|
+ organization.value.parentName = newFieldValue.displayValue[0];
|
|
|
};
|
|
|
|
|
|
-// 递归将childrenDatas赋值给children
|
|
|
+// 递归将childrenOrganizations赋值给children
|
|
|
const traversalTree = (array, target) => {
|
|
|
array.map((item, index) => {
|
|
|
target.push({
|
|
|
- key: item.id,
|
|
|
- name: item.name,
|
|
|
+ id: item.id,
|
|
|
no: item.no,
|
|
|
+ key: item.id,
|
|
|
children: [],
|
|
|
+ type: item.type,
|
|
|
+ name: item.name,
|
|
|
+ description: item.description,
|
|
|
});
|
|
|
- if (item.childrenDatas.length !== 0) {
|
|
|
- traversalTree(item.childrenDatas, target[index].children);
|
|
|
+ if (
|
|
|
+ item.childrenOrganizations !== null &&
|
|
|
+ item.childrenOrganizations.length !== 0
|
|
|
+ ) {
|
|
|
+ traversalTree(item.childrenOrganizations, target[index].children);
|
|
|
} else {
|
|
|
delete target[index].children;
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
+
|
|
|
+// 获取所有子部门
|
|
|
+/**
|
|
|
+const loadAllSubClients = () => {
|
|
|
+ var rootClientId = null;
|
|
|
+ for (let i = 0; i < dataSource.value.length; i++) {
|
|
|
+ var clientOrganization = dataSource.value[i];
|
|
|
+ if (clientOrganization.children == null) {
|
|
|
+ rootClientId = clientOrganization.key;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ loadSubClients(rootClientId).then(
|
|
|
+ success => {
|
|
|
+ if (success.errorCode == 0) {
|
|
|
+ if (success.datas) {
|
|
|
+ clientAdditionHql.value = ' ct.id in (' + success.join(',') + ')';
|
|
|
+ } else {
|
|
|
+ clientAdditionHql.value = {
|
|
|
+ customerDataDimensions: [
|
|
|
+ {
|
|
|
+ fieldName: 'ct.id',
|
|
|
+ dataDimensionTypeNo: '202201191757',
|
|
|
+ defaultDataDimensionTypeValueNo: '1',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ };
|
|
|
+ parentOrganizationAdditionHql.value = {
|
|
|
+ customerDataDimensions: [
|
|
|
+ {
|
|
|
+ fieldName: 'organization.id',
|
|
|
+ dataDimensionTypeNo: '202201191700',
|
|
|
+ defaultDataDimensionTypeValueNo: '1',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ };
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ message.error(success.errorMessage);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ err => {
|
|
|
+ Common.processException(err);
|
|
|
+ },
|
|
|
+ );
|
|
|
+};*/
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|