Ver código fonte

3.0.73 部门管理页增加编辑公司

liuyanpeng 2 anos atrás
pai
commit
f7ace67565
3 arquivos alterados com 151 adições e 26 exclusões
  1. 2 2
      package.json
  2. 43 0
      src/api/department/index.js
  3. 106 24
      src/client/OrganizationEditPanel.vue

+ 2 - 2
package.json

@@ -1,7 +1,7 @@
 {
   "name": "client-base-v4",
   "description": "Leanwo Prodog Client",
-  "version": "3.0.72",
+  "version": "3.0.73",
   "author": "yangzhijie1488 <yangzhijie1488@163.com>",
   "scripts": {
     "dev": "cross-env webpack serve --config ./webpack.dev.js",
@@ -20,7 +20,7 @@
     "dayjs": "^1.11.6",
     "dingtalk-jsapi": "^2.10.3",
     "moment": "^2.29.4",
-    "pc-component-v3": "1.0.66",
+    "pc-component-v3": "1.0.67",
     "uuid": "^8.3.2",
     "v-tooltip": "^4.0.0-beta.17",
     "vue-request": "^1.2.4",

+ 43 - 0
src/api/department/index.js

@@ -195,4 +195,47 @@ export const getUsersByName = searchQueryParam => {
       },
     });
   });
+};
+// 根据公司id获取公司的信息
+export const getClientInfo  = id => {
+  var requestUrl = 'clientResourceV2/uniqueByClientId?clientId=' + id;
+  return new Promise((resolve, reject) => {
+    $.ajax({
+      url: Common.getApiURL(requestUrl),
+      type: 'get',
+      dataType: 'json',
+      beforeSend: function (request) {
+        Common.addTokenToRequest(request);
+      },
+      processData: false,
+      success: function (data) {
+        resolve(data);
+      },
+      error: function (XMLHttpRequest, textStatus, errorThrown) {
+        reject(XMLHttpRequest);
+      },
+    });
+  });
+};
+
+// 更新公司信息
+export const updateClientInfo = client => {
+  var requestUrl = 'clientResourceV2/update';
+  return new Promise((resolve, reject) => {
+    $.ajax({
+      url: Common.getApiURL(requestUrl),
+      type: 'post',
+      contentType: 'application/json',
+      data: JSON.stringify(client),
+      beforeSend: function (request) {
+        Common.addTokenToRequest(request);
+      },
+      success: function (data) {
+        resolve(data);
+      },
+      error: function (XMLHttpRequest, textStatus, errorThrown) {
+        reject(XMLHttpRequest);
+      },
+    });
+  });
 };

+ 106 - 24
src/client/OrganizationEditPanel.vue

@@ -9,7 +9,7 @@
     <a-button type="primary" @click="editOrganization(true)">
       {{ $t("lang.OrganizationEditPanel.newDepartment") }}
     </a-button>
-    <a-button type="dashed" style="margin-left: 8px" @click="getOrganization">
+    <a-button type="dashed" style="margin-left: 8px" @click="refreshData">
       {{ $t("lang.OrganizationEditPanel.refresh") }}
     </a-button>
     <a-select
@@ -21,6 +21,9 @@
       :options="companies.map((item) => ({ value: item.id, label: item.name }))"
       @change="getClientId"
     />
+    <a-button type="primary" style="margin-left: 8px" @click="editClient">
+      编辑公司
+    </a-button>
   </div>
 
   <a-table
@@ -62,17 +65,7 @@
   >
     <div class="form-group">
       <label>{{ $t("lang.OrganizationEditPanel.corporateName") }}</label>
-      <!-- v-if="organization.id" -->
       <a-input v-model:value="organization.clientName" disabled />
-      <!-- <SearchWidget
-        v-else
-        info-window-no="286633"
-        :field-value="clientFieldValue"
-        :title-name="$t('lang.OrganizationEditPanel.departmentInquiry')"
-        display-name="ct.name"
-        :where-clause-source="clientAdditionHql"
-        @value-changed="clientValueChanged"
-      /> -->
     </div>
     <div class="form-group">
       <label>{{ $t("lang.OrganizationEditPanel.departmentNumber") }}</label>
@@ -127,6 +120,47 @@
       </a-button>
     </template>
   </a-drawer>
+  <a-drawer
+    v-model:visible="isEditClient"
+    title="编辑公司"
+    :width="500"
+    placement="right"
+  >
+    <div class="form-group">
+      <label>公司ID</label>
+      <a-input v-model:value="client.id" disabled />
+    </div>
+    <div class="form-group">
+      <label>{{ $t("lang.OrganizationEditPanel.corporateName") }}</label>
+      <a-input v-model:value="client.name" />
+    </div>
+    <div class="form-group">
+      <label>{{ $t("lang.OrganizationEditPanel.companyNumber") }}</label>
+      <a-input v-model:value="client.no" />
+    </div>
+    <div class="form-group">
+      <label>公司简介</label>
+      <textarea v-model="client.description" class="form-control" rows="3" />
+    </div>
+    <div class="form-group">
+      <label>{{ $t("lang.OrganizationEditPanel.departmentManager") }}</label>
+      <div>
+        <v-select
+          id="departmentManagerSelect"
+          v-model="client.managerUsers"
+          multiple
+          label="name"
+          :options="userList"
+          @search="fetchUserList"
+        />
+      </div>
+    </div>
+    <template #footer>
+      <a-button type="primary" @click="updateClient(client.id)">
+        {{ $t("lang.OrganizationEditPanel.save") }}
+      </a-button>
+    </template>
+  </a-drawer>
 </template>
 
 <script setup>
@@ -141,7 +175,9 @@ import {
   create,
   update,
   getCompony,
+  getClientInfo,
   getUsersByName,
+  updateClientInfo,
   loadOrganization,
   deleteDepartment,
   getAllOrganization,
@@ -154,9 +190,11 @@ const companies = ref([]); //所有公司
 const clientIdStr = ref(undefined);
 const userList = ref([]); // 用户清单
 const isCreate = ref(false); // 是否新建
+const isEditClient = ref(false); // 编辑公司
 const dataSource = ref([]); // 表格部门
 const drawerTitle = ref(''); //抽屉标题
 const organization = ref({}); // 部门详情
+const client = ref({}); // 公司详情
 const editVisible = ref(false); // 抽屉开关
 const organizationId = ref(''); // 所选部门ID
 // const clientAdditionHql = ref({});
@@ -175,6 +213,10 @@ const clientFieldValue = ref({
   id: null,
 });
 onMounted(() => {
+  getComponyInfo();
+});
+// 获取公司名称id
+const getComponyInfo = () => {
   getCompony().then(
     success => {
       if (success.errorCode == 0) {
@@ -187,8 +229,52 @@ onMounted(() => {
       Common.processException(err);
     },
   );
-});
+};
 
+// 编辑公司(获取公司信息)
+const editClient = () => {
+  if (clientNameStr.value) {
+    isEditClient.value = true;
+    getClientInfo(clientId.value).then(
+      success => {
+        if (success.errorCode == 0) {
+          fetchUserList();
+          client.value = success.data;
+        } else {
+          message.error(success.errorMessage);
+        }
+      },
+      error => {
+        Common.processException(error);
+      },
+    );
+  } else {
+    message.warning('请选择公司');
+  }
+};
+// 更新公司信息
+const updateClient = () => {
+  const clientValue = JSON.parse(JSON.stringify(client.value));
+  const { id, name, no } = clientValue;
+  if (!id || !name || !no) {
+    return;
+  }
+  updateClientInfo(clientValue).then(
+    success => {
+      isEditClient.value = false;
+      if (success.errorCode == 0) {
+        getComponyInfo();
+        client.value = {};
+        message.success(proxy.$t('lang.OrganizationEditPanel.describe6'));
+      } else {
+        message.error(success.errorMessage);
+      }
+    },
+    err => {
+      Common.processException(err);
+    },
+  );
+};
 // 获取所选公司id 名字
 const getClientId = (value, client) => {
   id.value = value;
@@ -201,7 +287,6 @@ const getClientId = (value, client) => {
 const createOrganization = () => {
   organization.value = {};
   organization.value.clientName = clientNameStr.value;
-  organization.value.clientName = clientNameStr.value;
   (clientFieldValue.value = {
     displayValue: [],
     fieldType: 'Key',
@@ -234,7 +319,11 @@ const createNew = organization => {
     },
   );
 };
-
+//刷新数据
+const refreshData = () => {
+  getComponyInfo();
+  getOrganization();
+};
 // 获取所有部门
 const getOrganization = () => {
   dataSource.value = [];
@@ -256,7 +345,7 @@ const getOrganization = () => {
   );
 };
 
-// 编辑部门
+// 编辑部门(获取部门信息)
 const editOrganization = (flag, id) => {
   organizationId.value = id;
   if (flag) {
@@ -281,7 +370,7 @@ const editOrganization = (flag, id) => {
             fieldType: 'Key',
             id: success.data.parentId,
           };
-          parentFieldValue.value =  parentOrganizationFieldValue.value;
+          parentFieldValue.value = parentOrganizationFieldValue.value;
           clientFieldValue.value = {
             displayValue: [success.data.clientName],
             fieldType: 'Key',
@@ -304,14 +393,7 @@ const editOrganization = (flag, id) => {
 const updateOrganization = () => {
   const organizationValue = JSON.parse(JSON.stringify(organization.value));
   const { clientId, name, no } = organizationValue;
-  if (
-    clientId == undefined ||
-    clientId == '' ||
-    name == undefined ||
-    name == '' ||
-    no == undefined ||
-    no == ''
-  ) {
+  if (!clientId || !name || !no) {
     Notify.error(
       proxy.$t('lang.Notify.error'),
       proxy.$t('lang.OrganizationEditPanel.describe5'),