list.component.ts 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. import { Component, OnInit, ViewChild } from '@angular/core';
  2. import { _HttpClient, ModalHelper } from '@delon/theme';
  3. import { STColumn, STComponent } from '@delon/abc';
  4. import { SFSchema } from '@delon/form';
  5. import { FbsWorkingStatistics } from 'app/entity/fbs/fbs-working-statistics';
  6. import { FbsWorkingStatisticsService } from 'app/services/fbs/fbs-working-statistics.service';
  7. import { FbsPersonnelService } from 'app/services/fbs/fbs-personnel.service';
  8. import { DatePipe } from '@angular/common';
  9. import { NzNotificationService, NzModalService } from 'ng-zorro-antd';
  10. import { FbsScanCodeUpdateTimeComponent } from '../update-time/update-time.component';
  11. @Component({
  12. selector: 'app-fbs-scan-code-list',
  13. templateUrl: './list.component.html',
  14. })
  15. export class FbsScanCodeListComponent implements OnInit {
  16. constructor(
  17. private fbsWorkingStatisticsService: FbsWorkingStatisticsService,
  18. private fbsPersonnelService: FbsPersonnelService,
  19. private datePipe: DatePipe,
  20. private nzNotificationService: NzNotificationService,
  21. private nzModalService: NzModalService,
  22. ) {}
  23. ngOnInit() {
  24. this.getList();
  25. this.getProperList();
  26. this.getTotalList();
  27. }
  28. dataList = []; //表格数据
  29. isLoading = false; //表格加载
  30. //分页参数
  31. page = {
  32. total: 0,
  33. current: 0,
  34. size: 0,
  35. };
  36. fbsWorkingStatistics: FbsWorkingStatistics = {}; //派工单对象
  37. /**
  38. * 查询按钮
  39. */
  40. query() {
  41. this.fbsWorkingStatistics.pageNo = 1;
  42. //主数据刷新
  43. this.getList();
  44. //计算各个合计
  45. this.getTotalList();
  46. }
  47. // 按页码查询
  48. pageIndexChange(event) {
  49. this.fbsWorkingStatistics.pageNo = event;
  50. //主数据刷新
  51. this.getList();
  52. }
  53. /**
  54. * 主数据查询
  55. */
  56. getList() {
  57. this.isLoading = true;
  58. //时间格式化
  59. this.fbsWorkingStatistics.start = this.datePipe.transform(this.fbsWorkingStatistics.start, 'yyyy-MM-dd');
  60. this.fbsWorkingStatistics.end = this.datePipe.transform(this.fbsWorkingStatistics.end, 'yyyy-MM-dd');
  61. this.fbsWorkingStatisticsService.list(this.fbsWorkingStatistics).then(response => {
  62. if (response.success) {
  63. //查询成功
  64. this.dataList = response.result.records; //表格数据
  65. this.page = response.result; //分页数据
  66. // this.getTotal();//查询总计//计算各个合计
  67. this.getTotalList();
  68. this.isLoading = false;
  69. }
  70. });
  71. }
  72. /**
  73. * 计算各个总计
  74. */
  75. getTotalList() {
  76. this.fbsWorkingStatistics.start = this.datePipe.transform(this.fbsWorkingStatistics.start, 'yyyy-MM-dd');
  77. this.fbsWorkingStatistics.end = this.datePipe.transform(this.fbsWorkingStatistics.end, 'yyyy-MM-dd');
  78. let fbsWorkingStatistics = JSON.parse(JSON.stringify(this.fbsWorkingStatistics));
  79. fbsWorkingStatistics.pageSize = -1;
  80. this.fbsWorkingStatisticsService.list(fbsWorkingStatistics).then(response => {
  81. if (response.success) {
  82. //查询成功
  83. let dataList = response.result.records; //表格数据
  84. this.getTotal(dataList); //查询总计
  85. this.isLoading = false;
  86. }
  87. });
  88. }
  89. /**
  90. * 初始化总计变量
  91. */
  92. totalList: any = {};
  93. initializationTotal() {
  94. this.totalList = {
  95. workingHoursTotal: 0,
  96. qualifiedNumberTotal: 0,
  97. };
  98. }
  99. /**
  100. * 计算工时、数量总计
  101. */
  102. getTotal(dataList) {
  103. this.initializationTotal();
  104. dataList.forEach(element => {
  105. this.totalList.workingHoursTotal += Number(element.workingHours);
  106. this.totalList.qualifiedNumberTotal += Number(element.qualifiedNumber);
  107. });
  108. this.totalList.workingHoursTotal = this.totalList.workingHoursTotal.toFixed(1);
  109. this.totalList.qualifiedNumberTotal = this.totalList.qualifiedNumberTotal.toFixed(1);
  110. }
  111. /**
  112. * 初始化人员下拉数据集合
  113. */
  114. properList = [];
  115. getProperList() {
  116. // this.fbsWorkshopDispatchListService.getPerAndDerp().then((response)=>{
  117. // this.properList=response.result
  118. // })
  119. this.fbsPersonnelService.list({ pageSize: 1000 }).then(response => {
  120. this.properList = response.result.records;
  121. });
  122. }
  123. update(item) {
  124. const modal = this.nzModalService.create({
  125. nzTitle: '修改',
  126. nzWidth: '50%',
  127. nzContent: FbsScanCodeUpdateTimeComponent,
  128. nzComponentParams: {
  129. id: item.id,
  130. },
  131. nzFooter: [
  132. {
  133. //取消
  134. label: '取消',
  135. type: 'default',
  136. onClick: model => {
  137. model.close();
  138. },
  139. },
  140. {
  141. label: '保存',
  142. type: 'primary',
  143. onClick: model => {
  144. // model.save().then(()=>{
  145. // this.getList()
  146. // })
  147. model.save().then(() => {
  148. this.fbsWorkingStatisticsService.updateTime(model.fbsWorkingStatistics).then(response => {
  149. if (response.success) {
  150. this.nzNotificationService.success('修改成功', '');
  151. //刷新list列表
  152. model.close();
  153. this.getList();
  154. this.isLoading = false;
  155. } else {
  156. this.nzNotificationService.error('修改失败', response.message);
  157. this.isLoading = false;
  158. }
  159. });
  160. });
  161. },
  162. },
  163. ],
  164. });
  165. }
  166. /**
  167. * 取消报工
  168. */
  169. cancelWorkReport(item){
  170. if(!item.rueck&&!item.rmzhl){
  171. this.nzNotificationService.warning('SAP确认号与计数器为空,不能取消报工', '');
  172. return;
  173. }
  174. this.fbsWorkingStatisticsService.cancelWorkReport(item).then(response=>{
  175. if (response.success) {
  176. this.nzNotificationService.success('取消成功', '');
  177. //刷新list列表
  178. this.getList();
  179. this.isLoading = false;
  180. } else {
  181. this.nzNotificationService.error('取消失败', response.message);
  182. this.isLoading = false;
  183. }
  184. })
  185. }
  186. view() {}
  187. }