list.component.ts 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. import { Component, OnInit, ViewChild } from '@angular/core';
  2. import { _HttpClient, ModalHelper } from '@delon/theme';
  3. import { STColumn, STComponent, XlsxService } 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. private xlsx: XlsxService
  23. ) {}
  24. ngOnInit() {
  25. this.getList();
  26. this.getProperList();
  27. this.getTotalList();
  28. }
  29. dataList = []; //表格数据
  30. isLoading = false; //表格加载
  31. //分页参数
  32. page = {
  33. total: 0,
  34. current: 0,
  35. size: 0,
  36. };
  37. fbsWorkingStatistics: FbsWorkingStatistics = {}; //派工单对象
  38. /**
  39. * 查询按钮
  40. */
  41. query() {
  42. this.fbsWorkingStatistics.pageNo = 1;
  43. //主数据刷新
  44. this.getList();
  45. //计算各个合计
  46. this.getTotalList();
  47. }
  48. // 按页码查询
  49. pageIndexChange(event) {
  50. this.fbsWorkingStatistics.pageNo = event;
  51. //主数据刷新
  52. this.getList();
  53. }
  54. /**
  55. * 主数据查询
  56. */
  57. getList() {
  58. this.isLoading = true;
  59. //时间格式化
  60. this.fbsWorkingStatistics.start = this.datePipe.transform(this.fbsWorkingStatistics.start, 'yyyy-MM-dd');
  61. this.fbsWorkingStatistics.end = this.datePipe.transform(this.fbsWorkingStatistics.end, 'yyyy-MM-dd');
  62. this.fbsWorkingStatisticsService.list(this.fbsWorkingStatistics).then(response => {
  63. if (response.success) {
  64. //查询成功
  65. this.dataList = response.result.records; //表格数据
  66. this.page = response.result; //分页数据
  67. // this.getTotal();//查询总计//计算各个合计
  68. this.getTotalList();
  69. this.isLoading = false;
  70. }
  71. });
  72. }
  73. /**
  74. * 计算各个总计
  75. */
  76. getTotalList() {
  77. this.fbsWorkingStatistics.start = this.datePipe.transform(this.fbsWorkingStatistics.start, 'yyyy-MM-dd');
  78. this.fbsWorkingStatistics.end = this.datePipe.transform(this.fbsWorkingStatistics.end, 'yyyy-MM-dd');
  79. let fbsWorkingStatistics = JSON.parse(JSON.stringify(this.fbsWorkingStatistics));
  80. fbsWorkingStatistics.pageSize = -1;
  81. this.fbsWorkingStatisticsService.list(fbsWorkingStatistics).then(response => {
  82. if (response.success) {
  83. //查询成功
  84. let dataList = response.result.records; //表格数据
  85. this.getTotal(dataList); //查询总计
  86. this.isLoading = false;
  87. }
  88. });
  89. }
  90. /**
  91. * 初始化总计变量
  92. */
  93. totalList: any = {};
  94. initializationTotal() {
  95. this.totalList = {
  96. workingHoursTotal: 0,
  97. qualifiedNumberTotal: 0,
  98. };
  99. }
  100. /**
  101. * 计算工时、数量总计
  102. */
  103. getTotal(dataList) {
  104. this.initializationTotal();
  105. dataList.forEach(element => {
  106. this.totalList.workingHoursTotal += Number(element.workingHours);
  107. this.totalList.qualifiedNumberTotal += Number(element.qualifiedNumber);
  108. });
  109. this.totalList.workingHoursTotal = this.totalList.workingHoursTotal.toFixed(1);
  110. this.totalList.qualifiedNumberTotal = this.totalList.qualifiedNumberTotal.toFixed(1);
  111. }
  112. /**
  113. * 初始化人员下拉数据集合
  114. */
  115. properList = [];
  116. getProperList() {
  117. // this.fbsWorkshopDispatchListService.getPerAndDerp().then((response)=>{
  118. // this.properList=response.result
  119. // })
  120. this.fbsPersonnelService.list({ pageSize: 1000 }).then(response => {
  121. this.properList = response.result.records;
  122. });
  123. }
  124. update(item) {
  125. const modal = this.nzModalService.create({
  126. nzTitle: '修改',
  127. nzWidth: '50%',
  128. nzContent: FbsScanCodeUpdateTimeComponent,
  129. nzComponentParams: {
  130. id: item.id,
  131. },
  132. nzFooter: [
  133. {
  134. //取消
  135. label: '取消',
  136. type: 'default',
  137. onClick: model => {
  138. model.close();
  139. },
  140. },
  141. {
  142. label: '保存',
  143. type: 'primary',
  144. onClick: model => {
  145. // model.save().then(()=>{
  146. // this.getList()
  147. // })
  148. model.save().then(() => {
  149. this.fbsWorkingStatisticsService.updateTime(model.fbsWorkingStatistics).then(response => {
  150. if (response.success) {
  151. this.nzNotificationService.success('修改成功', '');
  152. //刷新list列表
  153. model.close();
  154. this.getList();
  155. this.isLoading = false;
  156. } else {
  157. this.nzNotificationService.error('修改失败', response.message);
  158. this.isLoading = false;
  159. }
  160. });
  161. });
  162. },
  163. },
  164. ],
  165. });
  166. }
  167. /**
  168. * 取消报工
  169. */
  170. cancelWorkReport(item){
  171. if(!item.rueck&&!item.rmzhl){
  172. this.nzNotificationService.warning('SAP确认号与计数器为空,不能取消报工', '');
  173. return;
  174. }
  175. this.fbsWorkingStatisticsService.cancelWorkReport(item).then(response=>{
  176. if (response.success) {
  177. this.nzNotificationService.success('取消成功', '');
  178. //刷新list列表
  179. this.getList();
  180. this.isLoading = false;
  181. } else {
  182. this.nzNotificationService.error('取消失败', response.message);
  183. this.isLoading = false;
  184. }
  185. })
  186. }
  187. view() {}
  188. /**
  189. * 导出
  190. */
  191. exportLoading=false;
  192. export() {
  193. this.exportLoading=true;
  194. //时间格式化
  195. // this.fbsWorkingStatistics.start = this.datePipe.transform(this.fbsWorkingStatistics.start, 'yyyy-MM-dd');
  196. // this.fbsWorkingStatistics.end = this.datePipe.transform(this.fbsWorkingStatistics.end, 'yyyy-MM-dd');
  197. let fbsWorkingStatistics =JSON.parse(JSON.stringify(this.fbsWorkingStatistics));
  198. fbsWorkingStatistics.pageNo=1
  199. fbsWorkingStatistics.pageSize = -1;
  200. this.fbsWorkingStatisticsService.list(fbsWorkingStatistics).then(response => {
  201. if (response.success) {
  202. //查询成功
  203. let dataList = response.result.records; //表格数据
  204. let data=[];
  205. //设置导出头
  206. let title=[
  207. ['项目编号'],
  208. ['项目名称'],
  209. ['人员编码'],
  210. ['姓名'],
  211. ['订单编号'],
  212. ['物料编码'],
  213. ['物料名称'],
  214. ['工艺流程'],
  215. ['上岗时间'],
  216. ['下岗时间'],
  217. ['扫码信息'],
  218. ['工时'],
  219. ['完成数量']
  220. ]
  221. data.push(title);
  222. //添加导出行数据
  223. if(dataList){
  224. dataList.forEach(element => {
  225. let row=[];
  226. row.push(element.costItemCode)
  227. row.push(element.projectName)
  228. row.push(element.personnelCode)
  229. row.push(element.personnelName)
  230. row.push(element.orderNumber)
  231. row.push(element.materielCode)
  232. row.push(element.materielName)
  233. row.push(element.fbsTechnologicalProcessItemName)
  234. row.push(element.firstTime)
  235. row.push(element.finalTime)
  236. row.push(element.finalInfo)
  237. row.push(element.workingHours)
  238. row.push(element.qualifiedNumber)
  239. data.push(row)
  240. });
  241. data.push([
  242. '总计',
  243. '',
  244. '',
  245. '',
  246. '',
  247. '',
  248. '',
  249. '',
  250. '',
  251. '',
  252. this.totalList.workingHoursTotal,
  253. this.totalList.qualifiedNumberTotal
  254. ])
  255. }
  256. // 导出
  257. this.xlsx.export({
  258. sheets: [
  259. {
  260. data: data,
  261. name: '扫码记录',
  262. },
  263. ],
  264. filename: '扫码记录.xlsx',
  265. });
  266. this.exportLoading = false;
  267. }
  268. });
  269. }
  270. reportExportLoading=false
  271. reportExport(){
  272. this.reportExportLoading=true;
  273. let fbsWorkingStatistics =JSON.parse(JSON.stringify(this.fbsWorkingStatistics));
  274. this.fbsWorkingStatisticsService.getReportExport(fbsWorkingStatistics).then(response => {
  275. if (response.success) {
  276. //查询成功
  277. let dataList = response.result; //表格数据
  278. let data=[];
  279. //设置导出头
  280. let title=[
  281. ['项目编号'],
  282. ['项目名称'],
  283. ['原价代码'],
  284. ['WBS元素'],
  285. ['WBS元素描述'],
  286. ['报工WBS'],
  287. ['网络号'],
  288. ['网络活动号'],
  289. ['完工成度'],
  290. ['过账日期'],
  291. ['正常工时'],
  292. ['单位'],
  293. ['完工数量']
  294. ]
  295. data.push(title);
  296. //添加导出行数据
  297. if(dataList){
  298. dataList.forEach(element => {
  299. let row=[];
  300. row.push(element.costItemCode)
  301. row.push(element.projectName)
  302. row.push(element.originalPriceCode)
  303. row.push(element.wbsElement)
  304. row.push(element.wbsElementDescription)
  305. row.push(element.workReportWbs)
  306. row.push(element.workReportNetwork)
  307. row.push(element.workReportingActivities)
  308. row.push(element.speedOfProgress)
  309. row.push(this.datePipe.transform(fbsWorkingStatistics.end, 'yyyyMMdd'))
  310. row.push(element.workingHours)
  311. row.push('H')
  312. row.push(element.qualifiedNumber)
  313. data.push(row)
  314. });
  315. }
  316. // 导出
  317. this.xlsx.export({
  318. sheets: [
  319. {
  320. data: data,
  321. name: '报表导出',
  322. },
  323. ],
  324. filename: '报表导出.xlsx',
  325. });
  326. this.reportExportLoading = false;
  327. }else{
  328. this.nzNotificationService.error('导出失败', response.message);
  329. this.reportExportLoading = false;
  330. }
  331. })
  332. }
  333. }