hino / app / controllers / hoyu-order-split-approval / edit.js
edit.js
Raw
import Controller from '@ember/controller';
import { inject as service } from '@ember/service';

export default Controller.extend({
	hoyuOrderSplitApproval : service(),
	hoyuOrderSplitApprovalData : service(),
	hoyuOrderSplitApprovalListData : service(),
	session : service(),
	errors : service(),
	didValidate: false,
	rightActionInProgress: false,

	formConfig : {
		sourceSystemNo : { isEditable : true }, 
		unitSalesOrderId : { isEditable : true }, 
		orderSplitName : { isEditable : true }, 
		namaProduk : { isEditable : true }, 
		jumlah : { isEditable : true }, 
		status : { isEditable : true }, 
		unitSalesOrder : { isEditable : true }, 
		quotationDate : { isEditable : true }, 
		namaDealer : { isEditable : true }, 
		kodeDealer : { isEditable : true }, 
		namaProdukDisetujui : { isEditable : true }, 
		manufactureCode : { isEditable : true }, 
		quotationQty : { isEditable : true }, 
		warnaDiminta : { isEditable : true }, 
		warnaDisediakan : { isEditable : true }, 
		tangal : { isEditable : true }, 
		tanggalPelaksanaan : { isEditable : true }, 
		tahunProduksi : { isEditable : true }, 
		pemilik : { isEditable : true }, 
		perbedaanHarga : { isEditable : true }, 
		invoiceNumber : { isEditable : true }, 
		jenisOrder : { isEditable : true }, 
		project : { isEditable : true }, 
		finalTOP : { isEditable : true }, 
		defaultTOP : { isEditable : true }, 
		extendedTOPDay : { isEditable : true }, 
		extendedTOPAmmount : { isEditable : true }, 
		dueDateOfTOP : { isEditable : true }, 
		hargaKuncian : { isEditable : true }, 
		persetujuanSelanjutnyaOleh : { isEditable : true }, 
		requestedAdditionalDiscount : { isEditable : true }, 
		finalNetPrice : { isEditable : true }, 
		arSalesAmount : { isEditable : true }, 
		priceCode : { isEditable : true }, 
		termCode : { isEditable : true }, 
		osNotes : { isEditable : true }, 
		notes : { isEditable : true }, 
		dNPCurrent : { isEditable : true }, 
		totalDiskon : { isEditable : true }, 
		netPriceOrder : { isEditable : true }, 
		ketTOP : { isEditable : true }, 
		dNPQuotation : { isEditable : true }, 
		optionDiscount : { isEditable : true }, 
		dutroProgram : { isEditable : true }, 
		cashDiscount : { isEditable : true }, 
		eventDiscount : { isEditable : true }, 
		approvedVRF : { isEditable : true }, 
		totalDiscountQuotation : { isEditable : true }, 
		netPriceQuotation : { isEditable : true }, 
		hoyuOrderSplitApprovalList : { 
			orderSplitApprovalListId : { isEditable : true }, 
			approvedDate : { isEditable : true }, 
			additionalDiscount : { isEditable : true }, 
			approver : { isEditable : true }, 
			status : { isEditable : true }, 
			approverLevel : { isEditable : true }, 
			orderSplitId : { isEditable : true }, 
			approvalListName : { isEditable : true }, 
			currencyCode : { isEditable : true }, 
			suppliedProduct : { isEditable : true }, 
			quantity : { isEditable : true }, 
			hoyuOrderSplitApproval : { isEditable : true }, 
			createdBy : { isEditable : true }, 
			updatedBy : { isEditable : true }, 
		},
		quotationNo : { isEditable : true }, 
		noDo : { isEditable : true }, 
		createdBy : { isEditable : true }, 
		updatedBy : { isEditable : true }, 
		remarks : { isEditable : true }, 
		approvalActionType : { isEditable : true }, 
	},
	init() {
		this._super(...arguments);
	},

	actions: {
		async saveHoyuOrderSplitApproval() {
			this.set("rightActionInProgress", true);
			this.get('model')
				.validate()
				.then(async ({ validations }) => {
					this.set('didValidate', true); 
					if (validations.get('isValid')) {
						this.set('hoyuOrderSplitApproval.model.isApprovalData', false);
						this.hoyuOrderSplitApprovalData.save(this.hoyuOrderSplitApproval.model).then(response => {
							if (response != undefined) {
								this.transitionToRoute('hoyu-order-split-approval.detail', response.id); 
							}
						})
						.catch((e) => {
							this.set("rightActionInProgress", false);
							this.set('errorMessages', this.errors.getErrorMessages(e));
						});
					} else {
						this.set("rightActionInProgress", false);
					}
			}); 
		},

		addRowData(modal_type) {
			if (modal_type == "hoyu-order-split-approval-list") {
				let data = this.hoyuOrderSplitApprovalListData.createRecord();
				this.hoyuOrderSplitApproval.addRow(data, "hoyuOrderSplitApprovalList");
			}
		},
		deleteRowData(modal_type, data) {
			if (modal_type == "hoyu-order-split-approval-list") {
				this.hoyuOrderSplitApproval.deleteRow(data, "hoyuOrderSplitApprovalList");
			}
		},
	},
});