|
@@ -2,8 +2,8 @@ import { Component, OnInit, HostListener, ElementRef, Input } from '@angular/cor
|
|
import { _HttpClient } from '@delon/theme';
|
|
import { _HttpClient } from '@delon/theme';
|
|
import { NzDrawerRef, NzMessageService, NzModalService, NzNotificationService } from 'ng-zorro-antd';
|
|
import { NzDrawerRef, NzMessageService, NzModalService, NzNotificationService } from 'ng-zorro-antd';
|
|
import { CustomerService } from 'app/services/basedata/customer.service';
|
|
import { CustomerService } from 'app/services/basedata/customer.service';
|
|
-import { BasedataCustomerCustomerAddComponent } from '../customer-add/customer-add.component';
|
|
|
|
import { Customer } from 'app/entity/basedata/customer';
|
|
import { Customer } from 'app/entity/basedata/customer';
|
|
|
|
+import { BasedataCustomerCustomerAddComponent } from '../customer-add/customer-add.component';
|
|
import { I18NService } from '@core';
|
|
import { I18NService } from '@core';
|
|
import { CustomerContacts } from 'app/entity/basedata/customer-contacts';
|
|
import { CustomerContacts } from 'app/entity/basedata/customer-contacts';
|
|
import { messageShared } from '@shared/utils/message';
|
|
import { messageShared } from '@shared/utils/message';
|
|
@@ -13,6 +13,9 @@ import { BaseCustomerIndustry } from 'app/entity/basedata/base-customer-industry
|
|
import { BaseCustomerIndustryService } from 'app/services/basedata/base-customer-industry.service';
|
|
import { BaseCustomerIndustryService } from 'app/services/basedata/base-customer-industry.service';
|
|
import { BaseSalesStatus } from 'app/entity/basedata/base-sales-status';
|
|
import { BaseSalesStatus } from 'app/entity/basedata/base-sales-status';
|
|
import { BaseSalesStatusService } from 'app/services/basedata/base-sales-status.service';
|
|
import { BaseSalesStatusService } from 'app/services/basedata/base-sales-status.service';
|
|
|
|
+import { PersonnelService } from 'app/services/basedata/personnel.service'; //销售人员
|
|
|
|
+import { BasedataCustomerModalTableComponent } from '../modal-table/modal-table.component';
|
|
|
|
+import { recursiveQuery } from '@shared/utils/yuan copy'; //筛选可选择
|
|
|
|
|
|
@Component({
|
|
@Component({
|
|
selector: 'app-basedata-customer-edit',
|
|
selector: 'app-basedata-customer-edit',
|
|
@@ -35,6 +38,7 @@ import { BaseSalesStatusService } from 'app/services/basedata/base-sales-status.
|
|
})
|
|
})
|
|
export class BasedataCustomerEditComponent implements OnInit {
|
|
export class BasedataCustomerEditComponent implements OnInit {
|
|
@Input() id: string; //项目id
|
|
@Input() id: string; //项目id
|
|
|
|
+
|
|
customer = {
|
|
customer = {
|
|
code: '',
|
|
code: '',
|
|
name: '',
|
|
name: '',
|
|
@@ -66,13 +70,16 @@ export class BasedataCustomerEditComponent implements OnInit {
|
|
//销售状态id
|
|
//销售状态id
|
|
baseSalesStatusId: '',
|
|
baseSalesStatusId: '',
|
|
//客商属性
|
|
//客商属性
|
|
- customerAttribute: '',
|
|
|
|
|
|
+ customerAttribute: '1', //默认选中 1 客户
|
|
|
|
+ // pageNo: '1', //默认页码
|
|
//客商分组(数据字典)
|
|
//客商分组(数据字典)
|
|
customerGroupingDictValue: '',
|
|
customerGroupingDictValue: '',
|
|
//商务关系(数据字典)
|
|
//商务关系(数据字典)
|
|
businessRelationsDictValue: '',
|
|
businessRelationsDictValue: '',
|
|
//上级单位(本表id)
|
|
//上级单位(本表id)
|
|
parentId: '',
|
|
parentId: '',
|
|
|
|
+ //上级单位名称
|
|
|
|
+ parentName: '',
|
|
//使用状态(数据字典)
|
|
//使用状态(数据字典)
|
|
useStatusDictValue: '',
|
|
useStatusDictValue: '',
|
|
//休眠类型(数据字典)
|
|
//休眠类型(数据字典)
|
|
@@ -92,7 +99,7 @@ export class BasedataCustomerEditComponent implements OnInit {
|
|
annualTurnover: 0,
|
|
annualTurnover: 0,
|
|
//客户关系(数据字典)
|
|
//客户关系(数据字典)
|
|
customerRelationshipDictValue: '',
|
|
customerRelationshipDictValue: '',
|
|
- //价值级别(数据字典)
|
|
|
|
|
|
+ // 价值级别(数据字典)
|
|
valueLevelDictValue: '',
|
|
valueLevelDictValue: '',
|
|
//销售人员id
|
|
//销售人员id
|
|
salesmanId: '',
|
|
salesmanId: '',
|
|
@@ -115,21 +122,17 @@ export class BasedataCustomerEditComponent implements OnInit {
|
|
//开发时间
|
|
//开发时间
|
|
/**开发时间 yyyy-MM-dd*/
|
|
/**开发时间 yyyy-MM-dd*/
|
|
developmentDate: '',
|
|
developmentDate: '',
|
|
-
|
|
|
|
- radioValue: 'c' //客商属性 单选框默认值
|
|
|
|
};
|
|
};
|
|
|
|
|
|
- // 客商行业 字段规范
|
|
|
|
- baseCustomerIndustry: BaseCustomerIndustry = {};
|
|
|
|
- // 销售状态
|
|
|
|
- baseSalesStatus: BaseSalesStatus = {};
|
|
|
|
-
|
|
|
|
|
|
+ baseCustomerIndustry: BaseCustomerIndustry = {}; // 客商行业 字段规范
|
|
|
|
+ baseSalesStatus: BaseSalesStatus = {}; // 销售状态
|
|
listOfData = []; //客户联系人集合
|
|
listOfData = []; //客户联系人集合
|
|
|
|
+
|
|
enable = false; //是否停用
|
|
enable = false; //是否停用
|
|
codeDisabled = false;
|
|
codeDisabled = false;
|
|
cryptoJS = require('crypto-js');
|
|
cryptoJS = require('crypto-js');
|
|
tripledes = require('crypto-js/tripledes');
|
|
tripledes = require('crypto-js/tripledes');
|
|
-
|
|
|
|
|
|
+ selectId: { [key: string]: boolean } = {};
|
|
|
|
|
|
constructor(
|
|
constructor(
|
|
private nzDrawerRef: NzDrawerRef,
|
|
private nzDrawerRef: NzDrawerRef,
|
|
@@ -142,20 +145,30 @@ export class BasedataCustomerEditComponent implements OnInit {
|
|
private dictService: DictService,
|
|
private dictService: DictService,
|
|
private baseCustomerIndustryService: BaseCustomerIndustryService,
|
|
private baseCustomerIndustryService: BaseCustomerIndustryService,
|
|
private baseSalesStatusService: BaseSalesStatusService,
|
|
private baseSalesStatusService: BaseSalesStatusService,
|
|
|
|
+ private personnelService: PersonnelService, //销售人员
|
|
) {}
|
|
) {}
|
|
|
|
|
|
ngOnInit() {
|
|
ngOnInit() {
|
|
//所有字典数据
|
|
//所有字典数据
|
|
this.getDictList()
|
|
this.getDictList()
|
|
.then(res => {
|
|
.then(res => {
|
|
- //客商行业数树
|
|
|
|
|
|
+ //客商行业数 树
|
|
return this.getListIndustryTree();
|
|
return this.getListIndustryTree();
|
|
})
|
|
})
|
|
.then(res => {
|
|
.then(res => {
|
|
- //销售状态
|
|
|
|
|
|
+ //销售状态 树
|
|
return this.getSalesStatusTree();
|
|
return this.getSalesStatusTree();
|
|
|
|
+ })
|
|
|
|
+ // .then(res => {
|
|
|
|
+ // //上级单位 弹框内列表
|
|
|
|
+ // return this.getTableList();
|
|
|
|
+ // })
|
|
|
|
+ .then(res => {
|
|
|
|
+ //销售人员 树
|
|
|
|
+ return this.getSalesStaffTree();
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ //根据id 判断新增 or 编辑
|
|
if (this.id == '') {
|
|
if (this.id == '') {
|
|
//新增
|
|
//新增
|
|
} else {
|
|
} else {
|
|
@@ -171,11 +184,59 @@ export class BasedataCustomerEditComponent implements OnInit {
|
|
customerSourceList = []; //客商来源数据
|
|
customerSourceList = []; //客商来源数据
|
|
baseCustomerIndustryId = String; //客商行业字段(树)
|
|
baseCustomerIndustryId = String; //客商行业字段(树)
|
|
merchantsIndustryList: any = []; //客商行业数据
|
|
merchantsIndustryList: any = []; //客商行业数据
|
|
- salesStatusList: any = []; //销售状态数据
|
|
|
|
|
|
+ salesStatusList: any = []; //销售状态数据(树)
|
|
customerGroupList = []; //客商分组
|
|
customerGroupList = []; //客商分组
|
|
busRelDictList = []; //商务关系数据
|
|
busRelDictList = []; //商务关系数据
|
|
|
|
+ useStatusList = []; //使用状态
|
|
|
|
+ sleepTypeList = []; //休眠状态
|
|
|
|
+ unitSizeList = []; //单位规模
|
|
|
|
+ personnelSizeList = []; //人员规模
|
|
|
|
+ registeredCapitalList = []; //注册资金
|
|
|
|
+ customerRelationshipList = []; //客户关系
|
|
|
|
+ valueLevelList = []; //价值级别
|
|
|
|
+ salesStaffList: any = []; //销售人员数据(树)
|
|
|
|
|
|
- // 查询所有字典数据
|
|
|
|
|
|
+ //金额格式化 (公司注册资金)
|
|
|
|
+ formatterDollar = (value: number) => {
|
|
|
|
+ if (value) {
|
|
|
|
+ return `$ ${value}`;
|
|
|
|
+ } else {
|
|
|
|
+ return `$ `;
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ parserDollar = (value: string) => value.replace('$ ', '');
|
|
|
|
+
|
|
|
|
+ //点击放大镜 上级单位 弹框
|
|
|
|
+ modalTable() {
|
|
|
|
+ const modalRef = this.modalService.create({
|
|
|
|
+ nzTitle: '选择上级单位',
|
|
|
|
+ nzContent: BasedataCustomerModalTableComponent,
|
|
|
|
+ nzWidth: 1400,
|
|
|
|
+ nzFooter: [
|
|
|
|
+ {
|
|
|
|
+ label: '关闭',
|
|
|
|
+ type: 'default',
|
|
|
|
+ onClick: addModel => {
|
|
|
|
+ addModel.handleCancel();
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ label: '确定',
|
|
|
|
+ type: 'primary',
|
|
|
|
+ onClick: addModel => {
|
|
|
|
+ addModel.handleOk();
|
|
|
|
+ // addModel.selectObj 包含勾选项的 id 和 name
|
|
|
|
+ this.customer.parentName = addModel.selectObj[0].name;
|
|
|
|
+ this.customer.parentId = addModel.selectObj[0].id;
|
|
|
|
+ console.log('addModel.selectObj:', this.customer.parentName, this.customer.parentId);
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 所有字典数据
|
|
getDictList() {
|
|
getDictList() {
|
|
return new Promise(resolve => {
|
|
return new Promise(resolve => {
|
|
//获取客商分类数据
|
|
//获取客商分类数据
|
|
@@ -185,18 +246,54 @@ export class BasedataCustomerEditComponent implements OnInit {
|
|
//客商来源
|
|
//客商来源
|
|
this.dictService.getByDictCode('information_sources').then(response => {
|
|
this.dictService.getByDictCode('information_sources').then(response => {
|
|
this.customerSourceList = response.result;
|
|
this.customerSourceList = response.result;
|
|
- console.log(this.customerSourceList);
|
|
|
|
|
|
+ // console.log(this.customerSourceList);
|
|
resolve();
|
|
resolve();
|
|
//客商分组
|
|
//客商分组
|
|
this.dictService.getByDictCode('customer_grouping').then(response => {
|
|
this.dictService.getByDictCode('customer_grouping').then(response => {
|
|
this.customerGroupList = response.result;
|
|
this.customerGroupList = response.result;
|
|
- console.log(this.customerGroupList);
|
|
|
|
|
|
+ // console.log(this.customerGroupList);
|
|
resolve();
|
|
resolve();
|
|
//客商分组
|
|
//客商分组
|
|
this.dictService.getByDictCode('business_relations').then(response => {
|
|
this.dictService.getByDictCode('business_relations').then(response => {
|
|
this.busRelDictList = response.result;
|
|
this.busRelDictList = response.result;
|
|
- console.log(this.customerGroupList);
|
|
|
|
|
|
+ // console.log(this.customerGroupList);
|
|
resolve();
|
|
resolve();
|
|
|
|
+ //使用状态
|
|
|
|
+ this.dictService.getByDictCode('use_status').then(response => {
|
|
|
|
+ this.useStatusList = response.result;
|
|
|
|
+ // console.log(this.customerGroupList);
|
|
|
|
+ resolve();
|
|
|
|
+ //休眠类型
|
|
|
|
+ this.dictService.getByDictCode('sleep_type').then(response => {
|
|
|
|
+ this.sleepTypeList = response.result;
|
|
|
|
+ resolve();
|
|
|
|
+ //单位规模
|
|
|
|
+ this.dictService.getByDictCode('unit_size').then(response => {
|
|
|
|
+ this.unitSizeList = response.result;
|
|
|
|
+ resolve();
|
|
|
|
+ //人员规模
|
|
|
|
+ this.dictService.getByDictCode('personnel_size').then(response => {
|
|
|
|
+ this.personnelSizeList = response.result;
|
|
|
|
+ resolve();
|
|
|
|
+ //注册资金
|
|
|
|
+ this.dictService.getByDictCode('registered_capital').then(response => {
|
|
|
|
+ this.registeredCapitalList = response.result;
|
|
|
|
+ resolve();
|
|
|
|
+ //客户关系
|
|
|
|
+ this.dictService.getByDictCode('customer-relationship').then(response => {
|
|
|
|
+ this.customerRelationshipList = response.result;
|
|
|
|
+ resolve();
|
|
|
|
+ //价值级别
|
|
|
|
+ this.dictService.getByDictCode('value_level').then(response => {
|
|
|
|
+ this.valueLevelList = response.result;
|
|
|
|
+ resolve();
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ });
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
@@ -214,6 +311,7 @@ export class BasedataCustomerEditComponent implements OnInit {
|
|
// console.log('merchantsIndustryList--->', this.merchantsIndustryList);
|
|
// console.log('merchantsIndustryList--->', this.merchantsIndustryList);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
+
|
|
//销售状态 树
|
|
//销售状态 树
|
|
getSalesStatusTree() {
|
|
getSalesStatusTree() {
|
|
let baseSalesStatus = new BaseSalesStatus();
|
|
let baseSalesStatus = new BaseSalesStatus();
|
|
@@ -225,6 +323,32 @@ export class BasedataCustomerEditComponent implements OnInit {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 销售人员 树 (筛选可选择项)
|
|
|
|
+ getSalesStaffTree() {
|
|
|
|
+ this.personnelService
|
|
|
|
+ .queryApprover(sessionStorage.getItem('pkOrg'))
|
|
|
|
+ .then(res => {
|
|
|
|
+ //赋值第一行是 “ 请选择 ”
|
|
|
|
+ this.salesStaffList = [{ id: '', value: '', title: '请选择', isLeaf: true }];
|
|
|
|
+ this.salesStaffList = this.salesStaffList.concat(res.result);
|
|
|
|
+ console.log('销售人员树--->', this.salesStaffList);
|
|
|
|
+ })
|
|
|
|
+ // 调用筛选 可选择的 树方法recursiveQuery
|
|
|
|
+ .then(res => {
|
|
|
|
+ console.log('000');
|
|
|
|
+ recursiveQuery(this.salesStaffList);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //拿到选择的 销售人员ID
|
|
|
|
+ onChangeSalesmanId($event) {
|
|
|
|
+ console.log('????', $event);
|
|
|
|
+ this.customer.salesmanId = $event;
|
|
|
|
+ console.log('选择销售的id', this.customer.salesmanId);
|
|
|
|
+ }
|
|
|
|
+ //公司成立日期自带方法
|
|
|
|
+ companyDateChange() {}
|
|
|
|
+
|
|
// 客商行业 自带方法
|
|
// 客商行业 自带方法
|
|
onChangeMI($event) {}
|
|
onChangeMI($event) {}
|
|
// 销售状态 自带方法
|
|
// 销售状态 自带方法
|
|
@@ -453,7 +577,7 @@ export class BasedataCustomerEditComponent implements OnInit {
|
|
|
|
|
|
//最后保存
|
|
//最后保存
|
|
save() {
|
|
save() {
|
|
- console.log(this.listOfData);
|
|
|
|
|
|
+ console.log('edit最后的保存', this.listOfData);
|
|
var isdefault = 0;
|
|
var isdefault = 0;
|
|
this.listOfData.forEach(element => {
|
|
this.listOfData.forEach(element => {
|
|
if (element.isDefault == '1') {
|
|
if (element.isDefault == '1') {
|
|
@@ -473,6 +597,11 @@ export class BasedataCustomerEditComponent implements OnInit {
|
|
} else {
|
|
} else {
|
|
this.saveCustomer();
|
|
this.saveCustomer();
|
|
}
|
|
}
|
|
|
|
+ //判断是否选择销售人员
|
|
|
|
+ if (!this.customer.salesmanId) {
|
|
|
|
+ this.notification.warning('错误提示', '必须选择销售人员'); //通知提醒框
|
|
|
|
+ console.log('选择的销售人员', this.customer.salesmanId);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
//客户保存
|
|
//客户保存
|