essential-information.component.ts 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. import { Component, OnInit, Output, EventEmitter } from '@angular/core';
  2. import { NzModalRef, NzMessageService } from 'ng-zorro-antd';
  3. import { _HttpClient } from '@delon/theme';
  4. import { Validators, FormGroup, FormBuilder } from '@angular/forms';
  5. import { ProjectManageArchives } from 'app/entity/project-manage-archives/project-manage-archives';
  6. import { BaseArchivesProjectApproval } from 'app/entity/basedata/base-archives-project-approval';
  7. import { BaseArchivesProjectApprovalService } from 'app/services/basedata/base-archives-project-approval.service';
  8. import { Customer } from 'app/entity/basedata/customer';
  9. import { CustomerService } from 'app/services/basedata/customer.service';
  10. import { PersonnelService } from 'app/services/basedata/personnel.service';
  11. import { recursiveQuery } from '@shared/utils/yuan copy';
  12. @Component({
  13. selector: 'app-project-manage-archives-add-essential-information',
  14. templateUrl: './essential-information.component.html',
  15. })
  16. export class ProjectManageArchivesAddEssentialInformationComponent implements OnInit {
  17. constructor(
  18. private fb: FormBuilder,
  19. private baseArchivesProjectApprovalService: BaseArchivesProjectApprovalService,
  20. private customerService: CustomerService,
  21. private personnelService: PersonnelService,
  22. ) {}
  23. ngOnInit(): void {
  24. //初始化表单
  25. this.validateForm = this.fb.group({
  26. proId: [null, [Validators.required]],
  27. cusId: [null, [Validators.required]],
  28. totalPrice: [null, [Validators.required]],
  29. saleManagerId: [null],
  30. saleManIds: [null],
  31. impManagerId: [null],
  32. impConsultantIds: [null],
  33. deManagerId: [null],
  34. deEngineerIds: [null],
  35. seManagerId: [null],
  36. seEngineerIds: [null],
  37. milestoneId: [null, [Validators.required]]
  38. });
  39. this.getProList();
  40. this.getCusList();
  41. this.getPersonnelList();
  42. }
  43. validateForm!: FormGroup;
  44. projectManageArchivesa: ProjectManageArchives = {
  45. totalPrice: 0,
  46. }; //项目档案主表对象
  47. proList: any = []; //项目立项档案数据集合
  48. cusList = []; //客户档案数据集合
  49. //金额格式化
  50. formatterDollar = (value: number) => `$ ${value}`;
  51. parserDollar = (value: string) => value.replace('$ ', '');
  52. saleManIds = []; //业务员id绑定
  53. personnelList = []; //人员下拉数据
  54. impConsultantIds = []; //实施顾问下拉选择绑定
  55. deEngineerIds = []; //开发工程师下拉选择绑定
  56. seEngineerIds = []; //服务工程师下拉选择绑定
  57. milestoneList = []; //里程碑类型下拉数据
  58. /**
  59. * 查询项目立项
  60. */
  61. getProList() {
  62. return new Promise(resolve => {
  63. let baseArchivesProjectApproval = new BaseArchivesProjectApproval();
  64. baseArchivesProjectApproval.pkOrg = sessionStorage.getItem('pkOrg');
  65. this.baseArchivesProjectApprovalService.getTreeList(baseArchivesProjectApproval).then(response => {
  66. this.proList = response.result;
  67. resolve();
  68. });
  69. });
  70. }
  71. /**
  72. * 里程碑类型选择事件
  73. */
  74. //回写里程碑类型到其他页签查询明细
  75. @Output() milestone = new EventEmitter<{}>();
  76. milestoneChange(event) {
  77. if (event) {
  78. this.milestoneList.forEach(element => {
  79. if (element.value === event) {
  80. this.projectManageArchivesa.milestoneType = element.text;
  81. }
  82. });
  83. this.milestone.emit(this.projectManageArchivesa);
  84. }
  85. }
  86. /**
  87. * 项目立项选择事件
  88. * @param event 立项id
  89. */
  90. proChange(event) {
  91. this.getChild(this.proList, event);
  92. }
  93. //递归查找项目名称
  94. getChild(list, event) {
  95. list.forEach(element => {
  96. if (event === element.id) {
  97. this.projectManageArchivesa.proCode = element.code;
  98. this.projectManageArchivesa.proName = element.title;
  99. } else {
  100. //如果没找到则进入子集查找
  101. if (element.children && element.children.length > 0) {
  102. this.getChild(element.children, event);
  103. }
  104. }
  105. });
  106. }
  107. /**
  108. * 客户档案数据
  109. */
  110. getCusList() {
  111. return new Promise(resolve => {
  112. let customer = new Customer();
  113. customer.pkOrg = sessionStorage.getItem('pkOrg');
  114. customer.pageSize = 20000;
  115. this.customerService.getCustomer1(customer).then(response => {
  116. this.cusList = response.result.records;
  117. resolve();
  118. });
  119. });
  120. }
  121. /**
  122. * 客户档案选择事件
  123. */
  124. cusChange(event) {
  125. this.cusList.forEach(element => {
  126. if (event === element.id) {
  127. this.projectManageArchivesa.cusCode = element.code;
  128. this.projectManageArchivesa.cusName = element.name;
  129. }
  130. });
  131. this.getProjectManageArchivesa();
  132. }
  133. /**
  134. * 人员下拉查询
  135. */
  136. saleManagerList = []; //销售经理下拉数据
  137. impManagerList = []; //实施经理下拉数据
  138. deManagerList = []; //开发项目经理数据
  139. seManagerList = []; //服务项目经理数据
  140. getPersonnelList() {
  141. // return new Promise(resolve => {
  142. // this.personnelService.queryApprover(sessionStorage.getItem('pkOrg')).then(response => {
  143. // this.personnelList = JSON.parse(JSON.stringify(response.result));
  144. // this.saleManagerList = JSON.parse(JSON.stringify(response.result));
  145. // this.impManagerList = JSON.parse(JSON.stringify(response.result));
  146. // this.deManagerList = JSON.parse(JSON.stringify(response.result));
  147. // this.seManagerList = JSON.parse(JSON.stringify(response.result));
  148. // recursiveQuery(this.personnelList);
  149. // recursiveQuery(this.saleManagerList);
  150. // recursiveQuery(this.impManagerList);
  151. // recursiveQuery(this.deManagerList);
  152. // recursiveQuery(this.seManagerList);
  153. // resolve();
  154. // });
  155. // });
  156. }
  157. /**
  158. * 经理选择触发事件
  159. * @param event 经理id
  160. * @param type 经理类型
  161. */
  162. managerChange(event, type) {
  163. if (event) {
  164. this.saleManagerList.forEach(pkOrg => {
  165. pkOrg.children.forEach(depart => {
  166. depart.children.forEach(personnel => {
  167. if (personnel.key === event) {
  168. if (type === '1') {
  169. //销售经理名称
  170. this.projectManageArchivesa.saleManager = personnel.name;
  171. } else if (type === '2') {
  172. //实施项目经理名称
  173. this.projectManageArchivesa.impManager = personnel.name;
  174. } else if (type === '3') {
  175. //开发项目经理名称
  176. this.projectManageArchivesa.deManager = personnel.name;
  177. } else if (type === '4') {
  178. //服务经理名称
  179. this.projectManageArchivesa.seManager = personnel.name;
  180. }
  181. }
  182. });
  183. });
  184. });
  185. this.getProjectManageArchivesa();
  186. }
  187. }
  188. /**
  189. * 人员多选触发事件
  190. * @param event 人员id
  191. * @param type 经理类型
  192. */
  193. personnelChange(event, type) {
  194. if (event) {
  195. let names = '';
  196. let ids = '';
  197. let sort = 0;
  198. //根据下拉数据获取名称
  199. event.forEach(element => {
  200. this.saleManagerList.forEach(pkOrg => {
  201. pkOrg.children.forEach(depart => {
  202. depart.children.forEach(personnel => {
  203. if (personnel.key === element) {
  204. if (names === '') {
  205. names = personnel.name;
  206. ids = personnel.key;
  207. } else {
  208. names = names + '、' + personnel.name;
  209. ids = ids + '、' + personnel.key;
  210. }
  211. sort++;
  212. }
  213. });
  214. });
  215. });
  216. });
  217. //有数据则正常赋值
  218. if (sort > 0) {
  219. if (type === '1') {
  220. //业务员
  221. this.projectManageArchivesa.saleManId = ids;
  222. this.projectManageArchivesa.saleMan = names;
  223. } else if (type === '2') {
  224. //实施顾问
  225. this.projectManageArchivesa.impConsultantId = ids;
  226. this.projectManageArchivesa.impConsultant = names;
  227. } else if (type === '3') {
  228. //开发工程师
  229. this.projectManageArchivesa.deEngineerId = ids;
  230. this.projectManageArchivesa.deEngineer = names;
  231. } else if (type === '4') {
  232. //服务工程师
  233. this.projectManageArchivesa.seEngineerId = ids;
  234. this.projectManageArchivesa.seEngineer = names;
  235. }
  236. } else {
  237. //没数据则清空
  238. if (type === '1') {
  239. //业务员
  240. this.projectManageArchivesa.saleManId = '';
  241. this.projectManageArchivesa.saleMan = '';
  242. } else if (type === '2') {
  243. //实施顾问
  244. this.projectManageArchivesa.impConsultantId = '';
  245. this.projectManageArchivesa.impConsultant = '';
  246. } else if (type === '3') {
  247. //开发工程师
  248. this.projectManageArchivesa.deEngineerId = '';
  249. this.projectManageArchivesa.deEngineer = '';
  250. } else if (type === '4') {
  251. //服务工程师
  252. this.projectManageArchivesa.seEngineerId = '';
  253. this.projectManageArchivesa.seEngineer = '';
  254. }
  255. }
  256. this.getProjectManageArchivesa();
  257. }
  258. }
  259. //基本信息回写到其他页签
  260. @Output() projectManageArchivesaEntiy = new EventEmitter<{}>();
  261. getProjectManageArchivesa() {
  262. this.projectManageArchivesaEntiy.emit(this.projectManageArchivesa);
  263. }
  264. submitForm() {
  265. for (const i in this.validateForm.controls) {
  266. this.validateForm.controls[i].markAsDirty();
  267. this.validateForm.controls[i].updateValueAndValidity();
  268. }
  269. let valid = this.validateForm.valid;
  270. }
  271. }