/** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc */ import * as tslib_1 from "tslib"; import { Component, EventEmitter, Output, ViewChild } from '@angular/core'; import { ModalDirective } from 'ngx-bootstrap'; import { Common } from '../_services/common.service'; import { Request } from '../_services/request.service'; export class ModalStepViewComponent { /** * @param {?} request * @param {?} common */ constructor(request, common) { this.request = request; this.common = common; this.onUpdateModal = new EventEmitter(); this.submitted = false; this.title = 'สถานะขั้นตอน'; this.selectList = []; this.list = []; this.modalConfig = { ignoreBackdropClick: true }; this.selectedStep = {}; this.isMore = false; this.moreField = []; this.stepData = {}; this.lastStep = ''; this.stepName = ''; this.isSend = false; this.isRecieve = false; this.sendList = []; this.recieveList = []; } /** * @return {?} */ ngOnInit() { } /** * @param {?=} options * @return {?} */ open(options) { return tslib_1.__awaiter(this, void 0, void 0, function* () { console.log(options); this.stepData = {}; if (options) { this.title = options.option.title || 'สถานะขั้นตอน'; this.stepName = options.data.step_name || ''; this.stepData = JSON.parse(JSON.stringify(options.data)); this.downloadToken = options.downloadToken; // ต้องเปลี่ยนเป็นเรียก api if (this.stepData.step_id) { this.selectList = yield this.request.get('/db/ct_step?_where=(id,eq,' + this.stepData.step_id + ')'); /** @type {?} */ const step = this.selectList[0]; if (step.flag) { for (let i = 0; i < step.flag.length; i++) { /** @type {?} */ const flag = step.flag.charAt(i); /** @type {?} */ const ct_step_flag = yield this.request.get('/db/ct_step_flag?_where=(flag,eq,' + flag + ')'); /** @type {?} */ const newField = ct_step_flag[0]; this.moreField.push(newField); } this.isMore = true; } else { this.isMore = false; if (step.type_id === 8 || step.type_id === 13) { /** @type {?} */ let filter = { filter: { ct_step_data_id: this.stepData.id }, order_by: ["is_important", "send_book_no", "created_at"] }; /** @type {?} */ const sendDataList = yield this.request.post('/search/v_ct_step_sent', filter); this.sendList = sendDataList.resultData; this.isSend = true; this.isRecieve = false; } else if (step.type_id === 9 || step.type_id === 14) { /** @type {?} */ let filter = { filter: { ct_step_data_id: this.stepData.id }, order_by: ["is_important", "send_book_no", "created_at"] }; /** @type {?} */ const recieveDataList = yield this.request.post('/search/v_ct_step_sent', filter); this.recieveList = recieveDataList.resultData; this.isRecieve = true; this.isSend = false; } else { this.isRecieve = false; this.isSend = false; } } } } this.modal.show(); }); } /** * @return {?} */ closeModal() { this.submitted = false; this.selectList = []; this.list = []; this.selectedStep = {}; this.isMore = false; this.isSend = false; this.isRecieve = false; this.moreField = []; this.stepData = {}; this.lastStep = ''; this.modal.hide(); } /** * @param {?} data * @return {?} */ getFieldId(data) { /** @type {?} */ let id = ''; if (data.type === 'text') { id += 'txtView'; } else if (data.type === 'datetime') { id += 'txtView'; } /** @type {?} */ const field = data.field_name.charAt(0).toLocaleUpperCase() + data.field_name.substring(1); id += field; return id; } /** * @param {?} data * @return {?} */ getRowIndex(data) { if (!data.data) { return ''; } /** @type {?} */ const no = data.row.dataIndex + 1; return no; } /** * @param {?} e * @return {?} */ onCellPrepared(e) { if (e.rowType === 'data') { for (const i in e.component.columns) { if (e.column.dataField === e.component.columns[i]) { e.cellElement.accessKey = e.component.columns[i]; } } } } /** * @param {?} data * @return {?} */ isImportant(data) { return data.is_important ? "สำคัญ" : ""; } /** * @param {?} data * @return {?} */ getImageLink(data) { return data.url + '?downloadToken=' + this.downloadToken; } } ModalStepViewComponent.decorators = [ { type: Component, args: [{ selector: 'modal-step-view', template: "