|
|
@@ -1,699 +1,501 @@
|
|
|
<template>
|
|
|
- <div class="container">
|
|
|
- <NavBar
|
|
|
- :title="$t('lang.OrganizationEditPanel.departmentManagement')"
|
|
|
- :is-go-back="false"
|
|
|
+ <header>
|
|
|
+ <h3 style="margin: 0px; padding: 5px 0px 9px 0px">
|
|
|
+ {{ $t("lang.OrganizationEditPanel.departmentManagement") }}
|
|
|
+ </h3>
|
|
|
+ <a-divider style="margin: 0px" />
|
|
|
+ </header>
|
|
|
+ <div style="margin-top: 8px">
|
|
|
+ <a-button type="primary" @click="editOrganization(true)">
|
|
|
+ {{ $t("lang.OrganizationEditPanel.newDepartment") }}
|
|
|
+ </a-button>
|
|
|
+ <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>
|
|
|
|
|
|
- <div class="grid-container">
|
|
|
- <div class="grid-item-row1-column1">
|
|
|
- <div>
|
|
|
- <div>
|
|
|
- <button
|
|
|
- class="btn btn-primary"
|
|
|
- @click="createOrganization()"
|
|
|
- >
|
|
|
- {{ $t('lang.OrganizationEditPanel.newDepartment') }}
|
|
|
- </button>
|
|
|
- <button
|
|
|
- class="btn btn-danger"
|
|
|
- @click="deleteOrganization()"
|
|
|
- >
|
|
|
- {{ $t('lang.OrganizationEditPanel.deleteDepartment') }}
|
|
|
- </button>
|
|
|
- <button
|
|
|
- class="btn btn-default"
|
|
|
- @click="refresh()"
|
|
|
- >
|
|
|
- {{ $t('lang.OrganizationEditPanel.refresh') }}
|
|
|
- </button>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
- <div class="grid-item-row2-column1">
|
|
|
- <div
|
|
|
- v-for="clientOrganization in clientOrganizations"
|
|
|
- :key="clientOrganization.id"
|
|
|
- >
|
|
|
- <TreeViewNode
|
|
|
- :node="clientOrganization"
|
|
|
- :is-root="true"
|
|
|
- :is-show-check="true"
|
|
|
- @node-expand="nodeExpand"
|
|
|
- @node-select="nodeSelect"
|
|
|
- />
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
- <div class="grid-item-row2-column2">
|
|
|
- <div>
|
|
|
- <div v-if="organization">
|
|
|
- <div class="form-group">
|
|
|
- <label>{{ $t('lang.OrganizationEditPanel.corporateName') }}</label>
|
|
|
- <input
|
|
|
- v-if="organization.id"
|
|
|
- v-model="organization.clientName"
|
|
|
- autocomplete="off"
|
|
|
- type="text"
|
|
|
- class="form-control"
|
|
|
- readonly
|
|
|
- />
|
|
|
- <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>
|
|
|
- <input
|
|
|
- v-model="organization.no"
|
|
|
- autocomplete="off"
|
|
|
- type="text"
|
|
|
- class="form-control"
|
|
|
- />
|
|
|
- </div>
|
|
|
- <div class="form-group">
|
|
|
- <label>{{ $t('lang.OrganizationEditPanel.departmentName') }}</label>
|
|
|
- <input
|
|
|
- v-model="organization.name"
|
|
|
- autocomplete="off"
|
|
|
- type="text"
|
|
|
- class="form-control"
|
|
|
- />
|
|
|
- </div>
|
|
|
- <div class="form-group">
|
|
|
- <label>{{ $t('lang.OrganizationEditPanel.superiorDepartment') }}</label>
|
|
|
- <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>
|
|
|
- <textarea
|
|
|
- v-model="organization.description"
|
|
|
- class="form-control"
|
|
|
- rows="3"
|
|
|
- />
|
|
|
- </div>
|
|
|
- <div class="form-group">
|
|
|
- <label>{{ $t('lang.OrganizationEditPanel.departmentManager') }}</label>
|
|
|
- <div>
|
|
|
- <v-select
|
|
|
- id="departmentManagerSelect"
|
|
|
- v-model="organization.managerUsers"
|
|
|
- multiple
|
|
|
- label="name"
|
|
|
- :options="userList"
|
|
|
- @search="fetchUserList"
|
|
|
- />
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
- <button
|
|
|
- type="button"
|
|
|
- class="btn btn-primary"
|
|
|
- @click="saveOrUpdate()"
|
|
|
- >
|
|
|
- {{ $t('lang.OrganizationEditPanel.save') }}
|
|
|
- </button>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div>
|
|
|
- <div v-if="selectedClient && selectedClient.selected">
|
|
|
- <div class="form-group">
|
|
|
- <label>{{ $t('lang.OrganizationEditPanel.corporateName') }}</label>
|
|
|
- <div v-if="isInput">
|
|
|
- <input
|
|
|
- v-model="selectedClient.name"
|
|
|
- autocomplete="off"
|
|
|
- type="text"
|
|
|
- class="form-control"
|
|
|
- readonly
|
|
|
- />
|
|
|
- </div>
|
|
|
- <div v-else>
|
|
|
- <input
|
|
|
- v-model="companyName"
|
|
|
- autocomplete="off"
|
|
|
- type="text"
|
|
|
- class="form-control"
|
|
|
- />
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div class="form-group">
|
|
|
- <label>{{ $t('lang.OrganizationEditPanel.companyNumber') }}</label>
|
|
|
- <input
|
|
|
- v-model="selectedClient.no"
|
|
|
- autocomplete="off"
|
|
|
- type="text"
|
|
|
- class="form-control"
|
|
|
- readonly
|
|
|
- />
|
|
|
- </div>
|
|
|
- <div class="form-group">
|
|
|
- <label>{{ $t('lang.OrganizationEditPanel.companyManger') }}</label>
|
|
|
- <div>
|
|
|
- <v-select
|
|
|
- id="companyMangerSelect"
|
|
|
- v-model="selectedClient.managerUsers"
|
|
|
- multiple
|
|
|
- label="name"
|
|
|
- :options="userList"
|
|
|
- @search="fetchUserList"
|
|
|
- />
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <button
|
|
|
- type="button"
|
|
|
- class="btn btn-default"
|
|
|
- @click="edit()"
|
|
|
- >
|
|
|
- {{ isInput ? $t('lang.OrganizationEditPanel.edit') : $t('lang.OrganizationEditPanel.cancelEditing') }}
|
|
|
- </button>
|
|
|
- <button
|
|
|
- type="button"
|
|
|
- class="btn btn-primary"
|
|
|
- @click="updateCompany"
|
|
|
- >
|
|
|
- {{ $t('lang.OrganizationEditPanel.save') }}
|
|
|
- </button>
|
|
|
- </div>
|
|
|
+ <a-table
|
|
|
+ style="margin-top: 6px"
|
|
|
+ :columns="columns"
|
|
|
+ :data-source="dataSource"
|
|
|
+ :pagination="false"
|
|
|
+ :scroll="{ y: 440 }"
|
|
|
+ filter-search
|
|
|
+ >
|
|
|
+ <template #bodyCell="{ column, record }">
|
|
|
+ <template v-if="column.dataIndex === 'operation'">
|
|
|
+ <div class="editable-row-operations">
|
|
|
+ <span>
|
|
|
+ <a @click="editOrganization(false, record.key)">{{
|
|
|
+ $t("lang.OrganizationEditPanel.edit")
|
|
|
+ }}</a>
|
|
|
+ </span>
|
|
|
+ <span>
|
|
|
+ <a style="color: red" @click="deleteOrganization(record.key)">删除</a>
|
|
|
+ </span>
|
|
|
</div>
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+ </a-table>
|
|
|
+
|
|
|
+ <a-drawer
|
|
|
+ v-model:visible="editVisible"
|
|
|
+ :title="drawerTitle"
|
|
|
+ :width="500"
|
|
|
+ placement="right"
|
|
|
+ >
|
|
|
+ <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>
|
|
|
+ <a-input v-model:value="organization.no" />
|
|
|
+ </div>
|
|
|
+ <div class="form-group">
|
|
|
+ <label>{{ $t("lang.OrganizationEditPanel.departmentName") }}</label>
|
|
|
+ <a-input v-model:value="organization.name" />
|
|
|
+ </div>
|
|
|
+ <div class="form-group">
|
|
|
+ <label>{{ $t("lang.OrganizationEditPanel.superiorDepartment") }}</label>
|
|
|
+ <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>
|
|
|
+ <textarea
|
|
|
+ v-model="organization.description"
|
|
|
+ class="form-control"
|
|
|
+ rows="3"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <div class="form-group">
|
|
|
+ <label>{{ $t("lang.OrganizationEditPanel.departmentManager") }}</label>
|
|
|
+ <div>
|
|
|
+ <v-select
|
|
|
+ id="departmentManagerSelect"
|
|
|
+ v-model="organization.managerUsers"
|
|
|
+ multiple
|
|
|
+ label="name"
|
|
|
+ :options="userList"
|
|
|
+ @search="fetchUserList"
|
|
|
+ />
|
|
|
</div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
+ <template #footer>
|
|
|
+ <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>
|
|
|
+ </a-drawer>
|
|
|
</template>
|
|
|
|
|
|
-<script>
|
|
|
-import Common from '../common/Common.js';
|
|
|
-
|
|
|
-
|
|
|
-import TreeViewNode from '../widget/TreeViewNode.vue';
|
|
|
-
|
|
|
+<script setup>
|
|
|
import vSelect from 'vue-select';
|
|
|
-import OrganizationResource from '../api/base/OrganizationResource';
|
|
|
-import UserResource from '../api/base/UserResource.js';
|
|
|
-
|
|
|
import 'vue-select/dist/vue-select.css';
|
|
|
-import { Notify, Uuid } from 'pc-component-v3';
|
|
|
-
|
|
|
-export default {
|
|
|
-
|
|
|
- components: {
|
|
|
- TreeViewNode,
|
|
|
- vSelect,
|
|
|
- },
|
|
|
- data: function () {
|
|
|
- return {
|
|
|
- isInput: true,
|
|
|
- companyName: ' ',
|
|
|
- clientId: null,
|
|
|
- clientName: '',
|
|
|
- selectedClient: undefined, // 选择的公司
|
|
|
- selectedOrganization: undefined,
|
|
|
- organization: undefined,
|
|
|
- clientFieldValue: {
|
|
|
- displayValue: [],
|
|
|
- fieldType: 'Key',
|
|
|
- id: null,
|
|
|
- },
|
|
|
- parentOrganizationFieldValue: {
|
|
|
- displayValue: [],
|
|
|
- fieldType: 'Key',
|
|
|
- id: null,
|
|
|
- },
|
|
|
- //clientAdditionHql: "id IN (SELECT client.id FROM com.leanwo.prodog.model.base.Organization WHERE id IN (:EnvOrganizationIdList))",
|
|
|
- //parentOrganizationAdditionHql: "id IN (:EnvOrganizationIdList)",
|
|
|
- clientAdditionHql: '',
|
|
|
- parentOrganizationAdditionHql: '',
|
|
|
- // 其是树形结构
|
|
|
- clientOrganizations: [],
|
|
|
- subClienIds: [],
|
|
|
- // 用户清单
|
|
|
- userList: [],
|
|
|
- expandClientIds: [], // 展开的公司节点id
|
|
|
- expandOrganizationIds: [], // 展开的部门节点id
|
|
|
- };
|
|
|
- },
|
|
|
-
|
|
|
- mounted: function () {
|
|
|
- this.getClientOrganization();
|
|
|
- },
|
|
|
+import Common from '../common/Common.js';
|
|
|
+import { Notify } from 'pc-component-v3';
|
|
|
+import { ref, onMounted, getCurrentInstance } from 'vue';
|
|
|
+
|
|
|
+import {
|
|
|
+ columns,
|
|
|
+ create,
|
|
|
+ update,
|
|
|
+ getCompony,
|
|
|
+ getUsersByName,
|
|
|
+ loadOrganization,
|
|
|
+ deleteDepartment,
|
|
|
+ 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 clientNameStr = ref('');
|
|
|
+const { proxy } = getCurrentInstance(); //访问this
|
|
|
+const parentOrganizationAdditionHql = ref('');
|
|
|
+const parentOrganizationFieldValue = ref({
|
|
|
+ displayValue: [],
|
|
|
+ fieldType: 'Key',
|
|
|
+ id: null,
|
|
|
+});
|
|
|
+const clientFieldValue = ref({
|
|
|
+ displayValue: [],
|
|
|
+ fieldType: 'Key',
|
|
|
+ id: null,
|
|
|
+});
|
|
|
+onMounted(() => {
|
|
|
+ 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();
|
|
|
+};
|
|
|
|
|
|
- methods: {
|
|
|
- createOrganization: function () {
|
|
|
- var _self = this;
|
|
|
- this.organization = {};
|
|
|
- (this.clientFieldValue = {
|
|
|
- displayValue: [],
|
|
|
- fieldType: 'Key',
|
|
|
- id: null,
|
|
|
- }),
|
|
|
- (this.parentOrganizationFieldValue = {
|
|
|
- displayValue: [],
|
|
|
- fieldType: 'Key',
|
|
|
- id: null,
|
|
|
- });
|
|
|
+// 新建部门
|
|
|
+const createOrganization = () => {
|
|
|
+ console.log(clientNameStr.value, '6666');
|
|
|
+ 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 = '';
|
|
|
+};
|
|
|
|
|
|
- // 新建的时候取消已经勾选的单位或部门
|
|
|
- if (this.selectedClient != undefined) {
|
|
|
- this.selectedClient.selected = false;
|
|
|
- }
|
|
|
- if (this.selectedOrganization != undefined) {
|
|
|
- this.selectedOrganization.selected = false;
|
|
|
+// 创建按钮
|
|
|
+const createNew = organization => {
|
|
|
+ organization.parentName = parentOrganizationFieldValue.value.displayValue[0];
|
|
|
+ organization.clientId = id.value;
|
|
|
+ create(organization).then(
|
|
|
+ success => {
|
|
|
+ if (success.errorCode == 0) {
|
|
|
+ message.success('新建部门成功');
|
|
|
+ getOrganization();
|
|
|
+ editVisible.value = false;
|
|
|
+ } else {
|
|
|
+ message.error(success.errorMessage);
|
|
|
}
|
|
|
-
|
|
|
- this.parentOrganizationAdditionHql = '';
|
|
|
},
|
|
|
+ err => {
|
|
|
+ Common.processException(err);
|
|
|
+ },
|
|
|
+ );
|
|
|
+};
|
|
|
|
|
|
- saveOrUpdate: function () {
|
|
|
- var _self = this;
|
|
|
- if (
|
|
|
- _self.organization.clientId == undefined ||
|
|
|
- _self.organization.clientId == '' ||
|
|
|
- _self.organization.name == undefined ||
|
|
|
- _self.organization.name == '' ||
|
|
|
- _self.organization.no == undefined ||
|
|
|
- _self.organization.no == ''
|
|
|
- ) {
|
|
|
- Notify.error(_self.$t('lang.Notify.error'), _self.$t('lang.OrganizationEditPanel.describe5'), true);
|
|
|
- return;
|
|
|
+// 获取所有部门
|
|
|
+const getOrganization = () => {
|
|
|
+ dataSource.value = [];
|
|
|
+ const datas = [];
|
|
|
+ const id = clientId.value;
|
|
|
+ getAllOrganization(id).then(
|
|
|
+ success => {
|
|
|
+ if (success.errorCode == 0) {
|
|
|
+ success.datas.forEach(item => {
|
|
|
+ datas.push(item.childrenOrganizations);
|
|
|
+ });
|
|
|
+ traversalTree(datas.flat(1), dataSource.value);
|
|
|
}
|
|
|
+ // loadAllSubClients();
|
|
|
+ },
|
|
|
+ err => {
|
|
|
+ Common.processException(err);
|
|
|
+ },
|
|
|
+ );
|
|
|
+};
|
|
|
|
|
|
- $.ajax({
|
|
|
- url: Common.getApiURL('organizationResource/saveOrUpdate'),
|
|
|
- type: 'post',
|
|
|
- beforeSend: function (request) {
|
|
|
- Common.addTokenToRequest(request);
|
|
|
- },
|
|
|
- data: JSON.stringify(_self.organization),
|
|
|
- contentType: 'application/json; charset=utf-8',
|
|
|
- processData: false,
|
|
|
- success: function (data) {
|
|
|
- Notify.success(_self.$t('lang.Notify.success'), _self.$t('lang.OrganizationEditPanel.describe6'), true);
|
|
|
- _self.organization = {};
|
|
|
+// 编辑部门
|
|
|
+const editOrganization = (flag, id) => {
|
|
|
+ if (flag) {
|
|
|
+ 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 => {
|
|
|
+ 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),
|
|
|
+ );
|
|
|
+ }
|
|
|
+};
|
|
|
|
|
|
- _self.organization.clientId = _self.clientFieldValue.id;
|
|
|
- _self.parentOrganizationFieldValue = {
|
|
|
+//保存事件
|
|
|
+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 == ''
|
|
|
+ ) {
|
|
|
+ Notify.error(
|
|
|
+ proxy.$t('lang.Notify.error'),
|
|
|
+ proxy.$t('lang.OrganizationEditPanel.describe5'),
|
|
|
+ true,
|
|
|
+ );
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ update(organizationValue).then(
|
|
|
+ success => {
|
|
|
+ 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,
|
|
|
};
|
|
|
-
|
|
|
- if(data.parentId != null){
|
|
|
- _self.expandOrganizationIds.push(data.parentId);
|
|
|
- }
|
|
|
-
|
|
|
- _self.expandOrganizationIds.push(data.id);
|
|
|
-
|
|
|
- _self.refresh();
|
|
|
- },
|
|
|
- error: function (XMLHttpRequest, textStatus, errorThrown) {
|
|
|
- Common.processException(XMLHttpRequest, textStatus, errorThrown);
|
|
|
- },
|
|
|
- });
|
|
|
+ getOrganization();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ message.error(success.errorMessage);
|
|
|
+ }
|
|
|
+ editVisible.value = false;
|
|
|
},
|
|
|
+ err => {
|
|
|
+ Common.processException(err);
|
|
|
+ },
|
|
|
+ );
|
|
|
+};
|
|
|
|
|
|
- deleteOrganization: function () {
|
|
|
- var _self = this;
|
|
|
- if (_self.organization == undefined) {
|
|
|
- Notify.error(_self.$t('lang.Notify.error'), _self.$t('lang.OrganizationEditPanel.describe4'), true);
|
|
|
+// 删除部门
|
|
|
+const deleteOrganization = id => {
|
|
|
+ loadOrganization(id).then(
|
|
|
+ success => {
|
|
|
+ const organization = success.data;
|
|
|
+ if (organization == undefined) {
|
|
|
+ Notify.error(
|
|
|
+ proxy.$t('lang.Notify.error'),
|
|
|
+ proxy.$t('lang.OrganizationEditPanel.describe4'),
|
|
|
+ true,
|
|
|
+ );
|
|
|
return;
|
|
|
}
|
|
|
- $.ajax({
|
|
|
- url: Common.getApiURL('organizationResource/delete'),
|
|
|
- type: 'post',
|
|
|
- beforeSend: function (request) {
|
|
|
- Common.addTokenToRequest(request);
|
|
|
- },
|
|
|
- data: JSON.stringify(_self.organization),
|
|
|
- contentType: 'application/json; charset=utf-8',
|
|
|
- processData: false,
|
|
|
- success: function (data) {
|
|
|
- Notify.success(_self.$t('lang.Notify.success'), _self.$t('lang.OrganizationEditPanel.describe3'), true);
|
|
|
- _self.organization = undefined;
|
|
|
- _self.refresh();
|
|
|
+ const params = {
|
|
|
+ id: organization.id,
|
|
|
+ no: organization.no,
|
|
|
+ name: organization.name,
|
|
|
+ };
|
|
|
+ deleteDepartment(params).then(
|
|
|
+ success => {
|
|
|
+ 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);
|
|
|
+ }
|
|
|
},
|
|
|
- error: function (XMLHttpRequest, textStatus, errorThrown) {
|
|
|
- Common.processException(XMLHttpRequest, textStatus, errorThrown);
|
|
|
+ err => {
|
|
|
+ Common.processException(err);
|
|
|
},
|
|
|
- });
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 刷新
|
|
|
- */
|
|
|
- refresh: function () {
|
|
|
- this.getClientOrganization();
|
|
|
+ );
|
|
|
},
|
|
|
-
|
|
|
- /**
|
|
|
- * 单位发生修改
|
|
|
- */
|
|
|
- clientValueChanged: function (newFieldValue) {
|
|
|
- var _self = this;
|
|
|
- _self.clientFieldValue = newFieldValue;
|
|
|
- _self.organization.clientId = newFieldValue.id;
|
|
|
-
|
|
|
- // 添加部门约束
|
|
|
- _self.parentOrganizationAdditionHql = ' client.id = ' + newFieldValue.id;
|
|
|
+ err => {
|
|
|
+ Common.processException(err);
|
|
|
},
|
|
|
+ );
|
|
|
+};
|
|
|
|
|
|
- /**
|
|
|
- * 上级部门发生修改
|
|
|
- */
|
|
|
- parentOrganizationValueChanged: function (newFieldValue) {
|
|
|
- var _self = this;
|
|
|
- _self.parentOrganizationFieldValue = newFieldValue;
|
|
|
- _self.organization.parentId = newFieldValue.id;
|
|
|
+// 部门管理员输入的过滤条件发生改变
|
|
|
+const fetchUserList = (search, loading) => {
|
|
|
+ if (loading != null) {
|
|
|
+ loading(true);
|
|
|
+ }
|
|
|
+ let searchQueryParam = {
|
|
|
+ conditional: search,
|
|
|
+ range: {
|
|
|
+ start: 0,
|
|
|
+ length: 100,
|
|
|
},
|
|
|
-
|
|
|
- // 节点打开事件
|
|
|
- nodeExpand: function (node) {
|
|
|
- var _self = this;
|
|
|
- console.log(node);
|
|
|
- if (node.open === true) {
|
|
|
- if (node.isClient) {
|
|
|
- _self.expandClientIds.push(node.id);
|
|
|
- } else {
|
|
|
- _self.expandOrganizationIds.push(node.id);
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (node.isClient) {
|
|
|
- let index = _self.expandClientIds.indexOf(node.id);
|
|
|
- if(index >= 0){
|
|
|
- _self.expandClientIds.splice(index, 1);
|
|
|
- }
|
|
|
- } else {
|
|
|
- let index = _self.expandOrganizationIds.indexOf(node.id);
|
|
|
- if(index >= 0){
|
|
|
- _self.expandOrganizationIds.splice(index, 1);
|
|
|
- }
|
|
|
- }
|
|
|
+ };
|
|
|
+ getUsersByName(searchQueryParam).then(
|
|
|
+ successData => {
|
|
|
+ if (loading != null) {
|
|
|
+ loading(false);
|
|
|
}
|
|
|
-
|
|
|
+ userList.value = successData.resultList;
|
|
|
},
|
|
|
-
|
|
|
- // 节点选择事件
|
|
|
- nodeSelect: function (node) {
|
|
|
- var _self = this;
|
|
|
-
|
|
|
- var nodeSelectStatus = node.selected;
|
|
|
-
|
|
|
- if (_self.selectedClient != undefined) {
|
|
|
- _self.selectedClient.selected = false;
|
|
|
- }
|
|
|
-
|
|
|
- if (_self.selectedOrganization != undefined) {
|
|
|
- _self.selectedOrganization.selected = false;
|
|
|
- }
|
|
|
-
|
|
|
- // 如果选择的是单位
|
|
|
- if (node.isClient == true) {
|
|
|
- console.log(node);
|
|
|
- _self.selectedClient = node;
|
|
|
- _self.selectedOrganization = undefined;
|
|
|
- _self.organization = undefined;
|
|
|
- _self.parentOrganizationFieldValue = undefined;
|
|
|
- _self.clientFieldValue = undefined;
|
|
|
- } else {
|
|
|
- // 如果选择的是部门
|
|
|
- _self.selectedClient = undefined;
|
|
|
- _self.organization = undefined;
|
|
|
- _self.parentOrganizationFieldValue = undefined;
|
|
|
- _self.clientFieldValue = undefined;
|
|
|
- _self.selectedOrganization = node;
|
|
|
- _self.loadOrganization(node.id);
|
|
|
-
|
|
|
+ errorData => {
|
|
|
+ if (loading != null) {
|
|
|
+ loading(false);
|
|
|
}
|
|
|
|
|
|
- node.selected = !nodeSelectStatus;
|
|
|
-
|
|
|
-
|
|
|
+ Common.processException(errorData);
|
|
|
},
|
|
|
+ );
|
|
|
+};
|
|
|
+// 公司change事件
|
|
|
+const clientValueChanged = newFieldValue => {
|
|
|
+ clientFieldValue.value = newFieldValue;
|
|
|
+ organization.value.clientId = newFieldValue.id;
|
|
|
+ parentOrganizationAdditionHql.value = ' client.id = ' + newFieldValue.id; // 添加部门约束
|
|
|
+};
|
|
|
|
|
|
- // 获取单位部门
|
|
|
- getClientOrganization: function () {
|
|
|
- var _self = this;
|
|
|
- $.ajax({
|
|
|
- type: 'get',
|
|
|
- dataType: 'json',
|
|
|
- url: Common.getApiURL('organizationResource/findByClientId'),
|
|
|
- beforeSend: function (request) {
|
|
|
- Common.addTokenToRequest(request);
|
|
|
- },
|
|
|
- success: function (data) {
|
|
|
- // console.log(data);
|
|
|
- if(data.errorCode != 0){
|
|
|
- Notify.error(_self.$t('lang.OrganizationEditPanel.describe2'), data.errorCode, false);
|
|
|
- return;
|
|
|
- }
|
|
|
- function setOpen(node) {
|
|
|
- node.open = false;
|
|
|
- node.selected = false;
|
|
|
- node.isShowCheck = true;
|
|
|
- node.text = node.no + ' ' + node.name;
|
|
|
- if (node.isClient) {
|
|
|
- if (_self.expandClientIds.indexOf(node.id) >= 0) {
|
|
|
- node.open = true;
|
|
|
- };
|
|
|
- } else {
|
|
|
- if (_self.expandOrganizationIds.indexOf(node.id) >= 0) {
|
|
|
- node.open = true;
|
|
|
- };
|
|
|
- }
|
|
|
- if (
|
|
|
- node.childrenDatas != undefined &&
|
|
|
- node.childrenDatas.length > 0
|
|
|
- ) {
|
|
|
- node.childrenDatas.forEach(function (item) {
|
|
|
- setOpen(item);
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- data.datas.forEach(function (item) {
|
|
|
- setOpen(item);
|
|
|
- });
|
|
|
- _self.clientOrganizations = data.datas;
|
|
|
- // 查询所有子部门
|
|
|
- _self.loadSubClients();
|
|
|
- },
|
|
|
- error: function (XMLHttpRequest, textStatus, errorThrown) {
|
|
|
- Common.processException(XMLHttpRequest, textStatus, errorThrown);
|
|
|
- },
|
|
|
- });
|
|
|
- },
|
|
|
-
|
|
|
- // 从服务器加载Organization
|
|
|
- loadOrganization: function (id) {
|
|
|
- var _self = this;
|
|
|
- $.ajax({
|
|
|
- url: Common.getApiURL('organizationResource/unique') +
|
|
|
- '?organizationId=' +
|
|
|
- id,
|
|
|
- type: 'get',
|
|
|
- beforeSend: function (request) {
|
|
|
- Common.addTokenToRequest(request);
|
|
|
- },
|
|
|
- processData: false,
|
|
|
- success: function (data) {
|
|
|
- _self.organization = data;
|
|
|
- _self.parentOrganizationFieldValue = {
|
|
|
- displayValue: [data.parentName],
|
|
|
- fieldType: 'Key',
|
|
|
- id: data.parentId,
|
|
|
- };
|
|
|
- _self.clientFieldValue = {
|
|
|
- displayValue: [data.clientName],
|
|
|
- fieldType: 'Key',
|
|
|
- id: data.clientId,
|
|
|
- };
|
|
|
-
|
|
|
+// 上级部门change事件
|
|
|
+const parentOrganizationValueChanged = newFieldValue => {
|
|
|
+ console.log(newFieldValue, '555555555555555555');
|
|
|
+ parentOrganizationFieldValue.value = newFieldValue;
|
|
|
+ organization.value.parentId = newFieldValue.id;
|
|
|
+ organization.value.parentName = newFieldValue.displayValue[0];
|
|
|
+};
|
|
|
|
|
|
- //_self.userList.splice(0, _self.userList.length);
|
|
|
- _self.fetchUserList();
|
|
|
- // 添加到下拉菜单中
|
|
|
- // if(_self.organization != null && _self.organization.managerUsers != null){
|
|
|
- // _self.organization.managerUsers.forEach(item => {
|
|
|
- // _self.$set(_self.userList, _self.userList.length, item);
|
|
|
- // });
|
|
|
- // }
|
|
|
- },
|
|
|
- error: function (XMLHttpRequest, textStatus, errorThrown) {
|
|
|
- Common.processException(XMLHttpRequest, textStatus, errorThrown);
|
|
|
- },
|
|
|
- });
|
|
|
- },
|
|
|
+// 递归将childrenOrganizations赋值给children
|
|
|
+const traversalTree = (array, target) => {
|
|
|
+ array.map((item, index) => {
|
|
|
+ target.push({
|
|
|
+ id: item.id,
|
|
|
+ no: item.no,
|
|
|
+ key: item.id,
|
|
|
+ children: [],
|
|
|
+ type: item.type,
|
|
|
+ name: item.name,
|
|
|
+ description: item.description,
|
|
|
+ });
|
|
|
+ if (
|
|
|
+ item.childrenOrganizations !== null &&
|
|
|
+ item.childrenOrganizations.length !== 0
|
|
|
+ ) {
|
|
|
+ traversalTree(item.childrenOrganizations, target[index].children);
|
|
|
+ } else {
|
|
|
+ delete target[index].children;
|
|
|
+ }
|
|
|
+ });
|
|
|
+};
|
|
|
|
|
|
- loadSubClients: function () {
|
|
|
- var _self = this;
|
|
|
- var rootClientId = null;
|
|
|
- for (let index = 0; index < _self.clientOrganizations.length; index++) {
|
|
|
- var clientOrganization = _self.clientOrganizations[index];
|
|
|
- if (clientOrganization.childrenDatas == null) {
|
|
|
- rootClientId = clientOrganization.id;
|
|
|
- }
|
|
|
- }
|
|
|
- $.ajax({
|
|
|
- url: Common.getApiURL('ClientResource/getSubClientIds'),
|
|
|
- type: 'get',
|
|
|
- beforeSend: function (request) {
|
|
|
- Common.addTokenToRequest(request);
|
|
|
- },
|
|
|
- data: {
|
|
|
- rootClientId: rootClientId,
|
|
|
- },
|
|
|
- success: function (data) {
|
|
|
- if (data) {
|
|
|
- data.push(rootClientId);
|
|
|
- _self.subClienIds = data;
|
|
|
- _self.clientAdditionHql = ' ct.id in (' + data.join(',') + ')';
|
|
|
- } else {
|
|
|
- // buy find by jack
|
|
|
- _self.clientAdditionHql = {
|
|
|
- customerDataDimensions:[{
|
|
|
+// 获取所有子部门
|
|
|
+/**
|
|
|
+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',
|
|
|
- }],
|
|
|
- };
|
|
|
- // 'id IN (SELECT client.id FROM com.leanwo.prodog.model.base.Organization WHERE id IN (:EnvOrganizationIdList))';
|
|
|
- _self.parentOrganizationAdditionHql = {
|
|
|
- customerDataDimensions:[{
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ };
|
|
|
+ parentOrganizationAdditionHql.value = {
|
|
|
+ customerDataDimensions: [
|
|
|
+ {
|
|
|
fieldName: 'organization.id',
|
|
|
dataDimensionTypeNo: '202201191700',
|
|
|
defaultDataDimensionTypeValueNo: '1',
|
|
|
- }],
|
|
|
- };
|
|
|
- }
|
|
|
- },
|
|
|
- error: function (XMLHttpRequest, textStatus, errorThrown) {
|
|
|
- Common.processException(XMLHttpRequest, textStatus, errorThrown);
|
|
|
- },
|
|
|
- });
|
|
|
- },
|
|
|
- /**
|
|
|
- * 修改公司
|
|
|
- */
|
|
|
- updateCompany: function () {
|
|
|
- var _self = this;
|
|
|
- if (
|
|
|
- _self.selectedClient != null &&
|
|
|
- _self.companyName != null &&
|
|
|
- _self.companyName.length != 0
|
|
|
- ) {
|
|
|
- _self.selectedClient.name = _self.companyName;
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ };
|
|
|
+ }
|
|
|
} else {
|
|
|
- Notify.error(_self.$t('lang.Notify.error'), _self.$t('lang.OrganizationEditPanel.describe1'));
|
|
|
- return;
|
|
|
+ message.error(success.errorMessage);
|
|
|
}
|
|
|
- OrganizationResource.update(_self.selectedClient).then(
|
|
|
- successData => {
|
|
|
- _self.isInput = true;
|
|
|
- _self.refresh();
|
|
|
- Notify.success(_self.$t('lang.Notify.prompt'), successData.message);
|
|
|
- },
|
|
|
- errorData => { },
|
|
|
- );
|
|
|
},
|
|
|
- /**
|
|
|
- * 编辑/取消编辑
|
|
|
- */
|
|
|
- edit: function () {
|
|
|
- var _self = this;
|
|
|
- if (_self.isInput) {
|
|
|
- _self.companyName = _self.selectedClient.name;
|
|
|
- } else {
|
|
|
- _self.companyName = null;
|
|
|
- }
|
|
|
- _self.isInput = !_self.isInput;
|
|
|
+ err => {
|
|
|
+ Common.processException(err);
|
|
|
},
|
|
|
-
|
|
|
- /**
|
|
|
- * 输入的过滤条件发生改变
|
|
|
- * Triggered when the search text changes.
|
|
|
- *
|
|
|
- * @param search {String} Current search text
|
|
|
- * @param loading {Function} Toggle loading class
|
|
|
- */
|
|
|
- fetchUserList: function (search, loading) {
|
|
|
- let _self = this;
|
|
|
- if (loading != null) {
|
|
|
- loading(true);
|
|
|
- }
|
|
|
-
|
|
|
- let searchQueryParam = {
|
|
|
- conditional: search,
|
|
|
- range: {
|
|
|
- start: 0,
|
|
|
- length: 100,
|
|
|
- },
|
|
|
- };
|
|
|
-
|
|
|
- UserResource.getUsersByName(searchQueryParam).then(successData => {
|
|
|
- if (loading != null) {
|
|
|
- loading(false);
|
|
|
- }
|
|
|
-
|
|
|
- _self.userList = successData.resultList;
|
|
|
- }, errorData => {
|
|
|
- if (loading != null) {
|
|
|
- loading(false);
|
|
|
- }
|
|
|
-
|
|
|
- Common.processException(errorData);
|
|
|
- });
|
|
|
- },
|
|
|
- },
|
|
|
-};
|
|
|
+ );
|
|
|
+};*/
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
|
-.grid-container {
|
|
|
- margin-top: 10px;
|
|
|
- display: grid;
|
|
|
- grid-template-columns: 400px auto;
|
|
|
- grid-template-rows: 35px auto;
|
|
|
- gap: 10px;
|
|
|
- justify-items: stretch;
|
|
|
- align-items: stretch;
|
|
|
- height: calc(100vh - 170px);
|
|
|
- overflow: auto;
|
|
|
-}
|
|
|
-
|
|
|
-.grid-item-row1-column1 {
|
|
|
- grid-row-start: 1;
|
|
|
- grid-row-end: 2;
|
|
|
- grid-column-start: 1;
|
|
|
- grid-column-end: 3;
|
|
|
-}
|
|
|
-
|
|
|
-.grid-item-row2-column1 {
|
|
|
- grid-row-start: 2;
|
|
|
- grid-row-end: 3;
|
|
|
- grid-column-start: 1;
|
|
|
- grid-column-end: 2;
|
|
|
- overflow: auto;
|
|
|
- border: 1px solid #e1e1e8;
|
|
|
- padding: 0px 10px 0px 10px;
|
|
|
-}
|
|
|
-
|
|
|
-.grid-item-row2-column2 {
|
|
|
- grid-row-start: 2;
|
|
|
- grid-row-end: 3;
|
|
|
- grid-column-start: 2;
|
|
|
- grid-column-end: 3;
|
|
|
- overflow: auto;
|
|
|
+.editable-row-operations a {
|
|
|
+ margin-right: 8px;
|
|
|
}
|
|
|
-</style>
|
|
|
+</style>
|