|
|
@@ -1274,7 +1274,7 @@
|
|
|
deptIds: ['1998632792148717569', '1998632872721297409']
|
|
|
})
|
|
|
: listOrganizations();
|
|
|
- apiRequest.then((list) => {
|
|
|
+ return apiRequest.then((list) => {
|
|
|
// console.log('listOrganizations', list);
|
|
|
this.groupData = list;
|
|
|
this.groupTreeData = this.$util.toTreeData({
|
|
|
@@ -1918,6 +1918,9 @@
|
|
|
// this.clientEnvironmentId =
|
|
|
// this.$store.state.user.info.clientEnvironmentId;
|
|
|
this.row = row;
|
|
|
+ if (this.groupData.length == 0) {
|
|
|
+ await this.getGroupAll();
|
|
|
+ }
|
|
|
if (this.enterprisePage.length == 0) {
|
|
|
await this.getEnterprisePage();
|
|
|
}
|
|
|
@@ -1926,13 +1929,9 @@
|
|
|
if (type == 'add') {
|
|
|
this.form.transactionMode = this.defaultTransactionMode;
|
|
|
this.isUpdate = false;
|
|
|
- if (this.enterprisePage.length > 0) {
|
|
|
- this.form.partbName = this.enterprisePage[0].name;
|
|
|
- this.form.partbId = this.enterprisePage[0].id;
|
|
|
- this.form.partbUnifiedSocialCreditCode =
|
|
|
- this.enterprisePage[0].unifiedSocialCreditCode;
|
|
|
- this.form.partbFax = this.enterprisePage[0].fax;
|
|
|
- this.form.partbAddress = this.enterprisePage[0].address;
|
|
|
+ const enterprise = this.getCurrentEnterprise();
|
|
|
+ if (enterprise) {
|
|
|
+ this.getEnterprise(enterprise);
|
|
|
}
|
|
|
if (this.contactData.id) {
|
|
|
this.changeParent({ id: this.contactData.id });
|
|
|
@@ -1988,23 +1987,22 @@
|
|
|
this.title = '新增';
|
|
|
this.visible = true;
|
|
|
this.isUpdate = false;
|
|
|
+ if (this.groupData.length == 0) {
|
|
|
+ await this.getGroupAll();
|
|
|
+ }
|
|
|
if (this.enterprisePage.length == 0) {
|
|
|
await this.getEnterprisePage();
|
|
|
}
|
|
|
- if (this.enterprisePage.length > 0) {
|
|
|
- this.form.partbName = this.enterprisePage[0].name;
|
|
|
- this.form.partbId = this.enterprisePage[0].id;
|
|
|
- this.form.partbUnifiedSocialCreditCode =
|
|
|
- this.enterprisePage[0].unifiedSocialCreditCode;
|
|
|
- this.form.partbFax = this.enterprisePage[0].fax;
|
|
|
- this.form.partbAddress = this.enterprisePage[0].address;
|
|
|
+ const enterprise = this.getCurrentEnterprise();
|
|
|
+ if (enterprise) {
|
|
|
+ this.getEnterprise(enterprise);
|
|
|
}
|
|
|
this.form.createDeptName = this.user.info.groupName;
|
|
|
this.form.isGenerateReceiptPlan = +this.isGenReceiptPlan;
|
|
|
await this.changeContract(row);
|
|
|
},
|
|
|
getEnterprisePage() {
|
|
|
- enterprisePage({
|
|
|
+ return enterprisePage({
|
|
|
pageNum: 1,
|
|
|
size: 100
|
|
|
}).then((res) => {
|
|
|
@@ -2012,10 +2010,26 @@
|
|
|
this.enterprisePage.push(...res.list);
|
|
|
});
|
|
|
},
|
|
|
- getEnterprise() {
|
|
|
- let data = this.enterprisePage.find(
|
|
|
- (item) => item.name == this.form.partbName
|
|
|
- );
|
|
|
+ getCurrentEnterprise() {
|
|
|
+ let groupId = this.$store.state.user.info?.groupId;
|
|
|
+ const visitedGroupIds = [];
|
|
|
+ while (groupId && !visitedGroupIds.includes(groupId)) {
|
|
|
+ const enterprise = this.enterprisePage.find(
|
|
|
+ (item) => item.groupId == groupId
|
|
|
+ );
|
|
|
+ if (enterprise) {
|
|
|
+ return enterprise;
|
|
|
+ }
|
|
|
+ visitedGroupIds.push(groupId);
|
|
|
+ const group = this.groupData.find((item) => item.id == groupId);
|
|
|
+ groupId = group?.parentId;
|
|
|
+ }
|
|
|
+ return this.enterprisePage.length === 1 ? this.enterprisePage[0] : null;
|
|
|
+ },
|
|
|
+ getEnterprise(enterprise) {
|
|
|
+ let data =
|
|
|
+ enterprise ||
|
|
|
+ this.enterprisePage.find((item) => item.name == this.form.partbName);
|
|
|
this.form.partbName = data.name;
|
|
|
this.form.partbId = data.id;
|
|
|
this.form.partbUnifiedSocialCreditCode = data.unifiedSocialCreditCode;
|