Răsfoiți Sursa

4.0.11 部门管理上级部门优化

liuyanpeng 2 ani în urmă
părinte
comite
b96d283d42
2 a modificat fișierele cu 50 adăugiri și 67 ștergeri
  1. 1 1
      package.json
  2. 49 66
      src/client/OrganizationEditPanel.vue

+ 1 - 1
package.json

@@ -1,7 +1,7 @@
 {
   "name": "client-base-v4",
   "description": "Leanwo Prodog Client",
-  "version": "4.0.01",
+  "version": "4.0.11",
   "author": "yangzhijie1488 <yangzhijie1488@163.com>",
   "scripts": {
     "dev": "cross-env webpack serve --config ./webpack.dev.js",

+ 49 - 66
src/client/OrganizationEditPanel.vue

@@ -77,14 +77,24 @@
     </div>
     <div class="form-group">
       <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"
         :field-value="parentOrganizationFieldValue"
         :title-name="$t('lang.OrganizationEditPanel.departmentInquiry')"
         display-name="name"
         :where-clause-source="parentOrganizationAdditionHql"
         @value-changed="parentOrganizationValueChanged"
-      />
+      /> -->
     </div>
     <div class="form-group">
       <label>{{ $t("lang.OrganizationEditPanel.departmentProfile") }}</label>
@@ -183,6 +193,8 @@ import {
   getAllOrganization,
 } from '../api/department/index';
 import { message } from 'ant-design-vue';
+import { TreeSelect } from 'ant-design-vue';
+const SHOW_PARENT = TreeSelect.SHOW_PARENT;
 
 const clientId = ref(''); //公司id
 const id = ref(''); //公司id
@@ -197,22 +209,12 @@ const organization = ref({}); // 部门详情
 const client = ref({}); // 公司详情
 const editVisible = ref(false); // 抽屉开关
 const organizationId = ref(''); // 所选部门ID
-// const clientAdditionHql = ref({});
 const clientNameStr = ref('');
 const { proxy } = getCurrentInstance(); //访问this
-const parentOrganizationAdditionHql = ref('');
-const parentFieldValue = ref({});
-const clients = 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(() => {
   getComponyInfo();
 });
@@ -222,7 +224,7 @@ const getComponyInfo = () => {
   getCompony().then(
     success => {
       if (success.errorCode == 0) {
-        if(success.datas && success.datas.length >0){
+        if (success.datas && success.datas.length > 0) {
           getALLClient(success.datas);
         }
       } else {
@@ -236,9 +238,9 @@ const getComponyInfo = () => {
 };
 // 展示子公司数据
 const getALLClient = datas => {
-  datas.forEach(item =>{
-    companies.value.push({id:item.id,name:item.name});
-    if(item.childrenClients && item.childrenClients.length >0){
+  datas.forEach(item => {
+    companies.value.push({ id: item.id, name: item.name });
+    if (item.childrenClients && item.childrenClients.length > 0) {
       getALLClient(item.childrenClients);
     }
   });
@@ -299,22 +301,12 @@ const getClientId = (value, client) => {
 const createOrganization = () => {
   organization.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 => {
-  organization.parentName = parentOrganizationFieldValue.value.displayValue[0];
   organization.clientId = id.value;
   create(organization).then(
     success => {
@@ -348,6 +340,7 @@ const getOrganization = () => {
           datas.push(item.childrenOrganizations);
         });
         traversalTree(datas.flat(1), dataSource.value);
+        clientOrganizations(dataSource.value);
       }
       // loadAllSubClients();
     },
@@ -356,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) => {
   organizationId.value = id;
@@ -377,17 +380,8 @@ const editOrganization = (flag, id) => {
       success => {
         if (success.errorCode == 0) {
           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();
         } else {
           message.error(success.errorMessage);
@@ -419,12 +413,6 @@ const updateOrganization = () => {
         if (success.data) {
           message.success(proxy.$t('lang.OrganizationEditPanel.describe6'));
           organization.value = {};
-          organization.value.clientId = clientFieldValue.value.id;
-          parentOrganizationFieldValue.value = {
-            displayValue: [],
-            fieldType: 'Key',
-            id: null,
-          };
           getOrganization();
         }
       } else {
@@ -505,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事件
-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('不能将自己作为上级部门!');
-    parentOrganizationFieldValue.value = {
-      displayValue: [parentFieldValue.value.displayValue[0]],
-      fieldType: 'Key',
-      id: parentFieldValue.value.id,
-    };
+    organization.value.parentId = oldParentId.value;
+    organization.value.parentName = oldParentName.value;
   } else {
-    parentOrganizationFieldValue.value = newFieldValue;
-    organization.value.parentId = newFieldValue.id;
-    organization.value.parentName = newFieldValue.displayValue[0];
+    organization.value.parentId = value;
+    organization.value.parentName = label[0];
   }
 };