<template>
    <v-layout>
        <v-dialog v-model="dialogprogress" persistent max-width="350">
            <v-card>
                <v-card-title color="warning" class="headline">Proses sedang berjalan</v-card-title>
                <v-card-text>
                    <v-layout row>
                        <v-flex xs12>
                            <v-progress-linear :indeterminate="true"></v-progress-linear>
                        </v-flex>
                    </v-layout>
                    <v-layout row>
                        <v-flex xs12>
                            <p>Santai saja sejenak, biarkan sistem merangkai harga</p>
                            <p>Mungkin sedikit tidak enak, kesabaran mohon tetap dijaga</p>
                            <p>...</p>
                        </v-flex>
                    </v-layout>
                </v-card-text>
                <v-card-actions>
                    <v-spacer></v-spacer>
                    <!--<v-btn color="green darken-1" flat @click="dialogprogress">OK</v-btn>-->
                </v-card-actions>
            </v-card>
        </v-dialog>
        <v-flex xs12>
            <v-card class="mb-2" color="white">
                <v-toolbar color="blue lighten-3" dark height="50px">
                    <v-toolbar-title>Agreement Perusahaan : {{xcompany.name}}</v-toolbar-title>
                    <v-spacer></v-spacer>
                    <v-btn @click="openFormMou(0)" icon>
                        <v-icon>library_add</v-icon>
                    </v-btn>
                </v-toolbar>

                <v-layout row>
                    <v-flex xs12 pl-2 pr-2 pt-2 pb-2>
                        <v-data-table :headers="headers" :items="mous" :loading="isLoading" :pagination.sync="pagination" class="elevation-1">
                            <template slot="items" slot-scope="props">
                                <td class="text-xs-left pa-2" v-html="props.item.numberx">
                                </td>
                                <td class="text-xs-left pa-2" v-html="props.item.namex">
                                </td>
                                <td class="text-xs-left pa-2" v-html="props.item.periode">
                                </td>
                                <td class="text-xs-left pa-2" v-html="props.item.M_MouTypeName">
                                </td>
                                <td class="text-xs-left pa-2">
                                    <v-btn class="xs3 ma-1" color="info" @click="setStatusOrder(props.item)">{{ props.item.aksi}}</v-btn>
                                </td>
                                <td class="text-xs-left pa-2">
                                    <v-icon small v-if="props.item.isverified == 'N' && props.item.isreleased == 'N'" class="ml-3" color="primary" @click="editFormMou(props.item)">edit</v-icon>
                                    <v-icon small v-if="props.item.isverified == 'N' && props.item.isreleased == 'N'" class="ml-3" color="error" @click="deleteMou(props.item)">delete</v-icon>
                                    <v-icon small v-if="props.item.isverified == 'N' && props.item.isreleased == 'N'" class="ml-3" color="success" @click="doPriceList(props.item)">add</v-icon>
                                    <v-icon small v-if="props.item.isverified == 'N'" class="ml-3" color="success" @click="verifyMou(props.item)">check</v-icon>
                                    <v-icon small v-if="props.item.isverified == 'Y' && props.item.isreleased == 'N'" class="ml-3" color="primary" @click="releaseMou(props.item)">check</v-icon>
                                    <v-icon small v-if="props.item.isverified == 'Y' && props.item.isreleased == 'Y'" class="ml-3" color="primary" @click="unreleaseMou(props.item)">clear</v-icon>
                                    <v-icon small v-if="props.item.isverified == 'Y' && props.item.isreleased == 'N'" class="ml-3" color="success" @click="unverifyMou(props.item)">clear</v-icon>
                                    <v-icon small v-if="props.item.isverified == 'Y'" class="ml-3" color="success" @click="doPrintVerify(props.item)">print</v-icon>
                                </td>
                            </template>
                            <template>
                                <div class="text-xs-center">
                                    <v-pagination v-model="page" :length="15" :total-visible="7"></v-pagination>
                                </div>
                            </template>
                        </v-data-table>
                    </v-flex>
                </v-layout>
                <template>

                    <v-dialog v-model="dialogdeletealertmou" max-width="600px">
                        <v-card>
                            <v-card-title class="headline grey lighten-2 pt-2 pb-2" primary-title>
                                Peringatan !
                            </v-card-title>
                            <v-card-text class="pt-2 pb-2">
                                <v-layout row>
                                    <v-flex xs12 d-flex>
                                        <v-layout row>
                                            <v-flex pb-1 xs12>
                                                <v-layout row>
                                                    <v-flex pt-2 pr-2 xs12>
                                                        {{msgalertmou}}
                                                    </v-flex>
                                                </v-layout>
                                            </v-flex>
                                        </v-layout>
                                    </v-flex>
                                </v-layout>
                            </v-card-text>
                            <v-divider></v-divider>
                            <v-card-actions>
                                <v-spacer></v-spacer>
                                <v-btn color="primary" flat @click="dialogdeletealertmou = false">
                                    Tutup
                                </v-btn>
                                <v-btn color="primary" flat @click="closeDeleteAlertMou()">
                                    Yakin lah
                                </v-btn>
                            </v-card-actions>
                        </v-card>
                    </v-dialog>

                </template>

                <template>

                    <v-dialog v-model="dialogverifyalertmou" max-width="600px">
                        <v-card>
                            <v-card-title class="headline grey lighten-2 pt-2 pb-2" primary-title>
                                Verifikasi

                            </v-card-title>
                            <v-card-text class="pt-0 pb-0">
                                <v-form ref="formcompanymou" v-model="validmou" lazy-validation>
                                    <v-layout wrap>
                                        <v-flex xs12>
                                            <v-icon color="orange darken-2" @click="doPrint()">folder_open</v-icon>PERUSAHAAN : {{xcompany.name}} <span> &nbsp;[ <span style="color:#2196F3;font-weight: 900;">{{number}} </span>&nbsp;]
                                        </v-flex>
                                        <v-flex xs12>
                                            <v-text-field readonly label="Nama" v-model="name"></v-text-field>
                                            <p v-if="checkError('requirename')" class="error pl-2 pr-2" style="color:#fff">Nama harus diisi dong</p>
                                        </v-flex>
                                        <v-flex xs12>
                                            <v-text-field readonly label="No Ref" v-model="refnumber"></v-text-field>
                                        </v-flex>
                                        <v-flex xs12>
                                            <v-layout>
                                                <v-flex xs6 pa-1>
                                                    <v-text-field label="Tgl. Mulai" placeholder="dd-mm-yyyy" mask="##-##-####" v-model="xstartdate"></v-text-field>
                                                </v-flex>
                                                <v-flex xs6 pa-1>
                                                    <v-text-field label="Tgl. Selesai" placeholder="dd-mm-yyyy" mask="##-##-####" v-model="xenddate"></v-text-field>
                                                </v-flex>
                                            </v-layout>

                                            <v-flex xs12>

                                                <v-select readonly item-text="basename" return-object :items="xbases" v-model="xbase" label="Dasar Agreement"></v-select>
                                                <p v-if="checkError('requirebase')" class="error pl-2 pr-2" style="color:#fff">Dasar Agreement harus diisi dong</p>
                                            </v-flex>
                                            <v-flex xs12>
                                                <v-select readonly item-text="M_OmzetTypeName" return-object :items="xomzettypes" v-model="xomzettype" label="Klasifikasi Omset"></v-select>
                                                <p v-if="checkError('requireomzet')" class="error pl-2 pr-2" style="color:#fff">Klasifikasi Omset harus diisi dong</p>
                                            </v-flex>
                                            <v-flex xs12>
                                                <v-select readonly item-text="M_MouTypeName" return-object :items="xmoutypes" v-model="xmoutype" label="Tipe Agreement"></v-select>
                                                <p v-if="checkError('requiremoutypr')" class="error pl-2 pr-2" style="color:#fff">Tipe Agreement harus diisi dong</p>
                                            </v-flex>
                                            <v-flex xs12>
                                                <v-select readonly item-text="M_AgingTypeName" return-object :items="xagingtypes" v-model="xagingtype" label="Tipe Aging"></v-select>

                                            </v-flex>
                                            <v-flex xs12>
                                                <v-textarea readonly v-model="xnote" label="Catatan"></v-textarea>
                                            </v-flex>
                                            <v-flex xs12 v-if="this.mouemail">
                                                    <v-checkbox v-model="isemail" readonly label="Otomatis Kirim Email?"></v-checkbox>
                                                </v-flex>
                                                <v-flex xs12>
                                                    <v-layout>
                                                        <v-flex xs6 pa-1>
                                                            <v-checkbox readonly v-model="isbill" label="Bill ?"></v-checkbox>
                                                        </v-flex>
                                                        <v-flex xs6 pa-1>
                                                            <v-text-field readonly v-if="this.isbill === false" label="Min DP (Persen)" v-model="mindp"></v-text-field>
                                                        </v-flex>
                                                    </v-layout>
                                                </v-flex>

                                                <v-flex xs12>
                                                    <v-layout>
                                                        <v-flex xs6 pa-1>
                                                            <v-checkbox readonly v-model="isaging" label="Aging on Hold ?"></v-checkbox>
                                                        </v-flex>
                                                        <v-flex xs6 pa-1>
                                                            <v-text-field readonly v-if="this.isaging === true" label="Keterangan Aging on Hold" v-model="agingnote"></v-text-field>
                                                            <p v-if="checkError('requireaging')" class="error pl-2 pr-2" style="color:#fff">Keterangan Aging harus diisi dong</p>
                                                        </v-flex>
                                                    </v-layout>
                                                </v-flex>
                                            <v-flex xs12>
                                                <v-checkbox readonly v-model="isdefault" label="Default ?"></v-checkbox>
                                            </v-flex>
                                            <v-flex xs12>
                                                <v-checkbox readonly v-model="isfavorit" label="Favorite ?"></v-checkbox>
                                            </v-flex>
                                            <v-flex xs12>
                                                <v-checkbox readonly v-model="ismcu" label="MCU ?"></v-checkbox>
                                            </v-flex>
                                            <v-flex xs12>
                                                <v-checkbox readonly v-model="isjpanetto" label="JPA Netto ?"></v-checkbox>
                                            </v-flex>
                                            <v-flex xs12>
                                                <v-layout>
                                                    <v-flex xs8 pa-1>
                                                        <v-text-field readonly label="JPA 1" v-model="jpa1Name"></v-text-field>
                                                    </v-flex>
                                                    <v-flex xs4 pa-1>
                                                        <v-text-field readonly label="Percent" v-model="jpa1Percent"></v-text-field>
                                                    </v-flex>
                                                </v-layout>
                                            </v-flex>
                                            <v-flex xs12>
                                                <v-layout>
                                                    <v-flex xs8 pa-1>
                                                        <v-text-field readonly label="JPA 2" v-model="jpa2Name"></v-text-field>
                                                    </v-flex>
                                                    <v-flex xs4 pa-1>
                                                        <v-text-field readonly label="Percent" v-model="jpa2Percent"></v-text-field>
                                                    </v-flex>
                                                </v-layout>
                                            </v-flex>
                                            <v-flex xs12>
                                                <v-layout>
                                                    <v-flex xs8 pa-1>
                                                        <v-text-field readonly label="JPA 3" v-model="jpa3Name"></v-text-field>
                                                    </v-flex>
                                                    <v-flex xs4 pa-1>
                                                        <v-text-field readonly label="Percent" v-model="jpa3Percent"></v-text-field>
                                                    </v-flex>
                                                </v-layout>
                                            </v-flex>

                                            <v-flex xs12>
                                                <v-layout>
                                                    <v-flex xs8 pa-1>
                                                        <v-text-field readonly label="JPA 4" v-model="jpa4Name"></v-text-field>
                                                    </v-flex>
                                                    <v-flex xs4 pa-1>
                                                        <v-text-field readonly label="Percent" v-model="jpa4Percent"></v-text-field>
                                                    </v-flex>
                                                </v-layout>
                                            </v-flex>
                                            <v-flex>
                                                <p v-for="(xerror,idx) in xerrors" class="error pl-2 pr-2" style="color:#fff">{{xerror.msg}}</p>
                                            </v-flex>
                                    </v-layout>
                            </v-card-text>
                            <v-divider></v-divider>
                            <v-card-actions>
                                <v-spacer></v-spacer>
                                <v-btn color="primary" flat @click="dialogverifyalertmou = false">
                                    Tutup
                                </v-btn>
                                <v-btn color="primary" flat @click="closeVerifyAlertMou()">
                                    Verifikasi
                                </v-btn>
                            </v-card-actions>
                        </v-card>
                    </v-dialog>

                </template>

                <template>

                    <v-dialog v-model="dialogunverifyalertmou" max-width="600px">
                        <v-card>
                            <v-card-title class="headline grey lighten-2 pt-2 pb-2" primary-title>
                                Batal Verifikasi
                            </v-card-title>
                            <v-card-text class="pt-0 pb-0">
                                <v-form ref="formcompanymou" v-model="validmou" lazy-validation>
                                    <v-layout wrap>
                                        <v-flex xs12>
                                            PERUSAHAAN : {{xcompany.name}} <span> &nbsp;[ <span style="color:#2196F3;font-weight: 900;">{{number}} </span>                                            &nbsp;]
                                        </v-flex>
                                        <v-flex xs12>
                                            <v-text-field readonly label="Nama" v-model="name"></v-text-field>
                                            <p v-if="checkError('requirename')" class="error pl-2 pr-2" style="color:#fff">Nama harus diisi dong</p>
                                        </v-flex>
                                        <v-flex xs12>
                                            <v-text-field readonly label="No Ref" v-model="refnumber"></v-text-field>
                                        </v-flex>
                                        <v-flex xs12>
                                            <v-layout>
                                                <v-flex xs6 pa-1>
                                                    <v-text-field label="Tgl. Mulai" placeholder="dd-mm-yyyy" mask="##-##-####" v-model="xstartdate"></v-text-field>
                                                </v-flex>
                                                <v-flex xs6 pa-1>
                                                    <v-text-field label="Tgl. Selesai" placeholder="dd-mm-yyyy" mask="##-##-####" v-model="xenddate"></v-text-field>
                                                </v-flex>
                                            </v-layout>

                                            <v-flex xs12>

                                                <v-select readonly item-text="basename" return-object :items="xbases" v-model="xbase" label="Dasar Agreement"></v-select>
                                                <p v-if="checkError('requirebase')" class="error pl-2 pr-2" style="color:#fff">Dasar Agreement harus diisi dong</p>
                                            </v-flex>
                                            <v-flex xs12>
                                                <v-select readonly item-text="M_OmzetTypeName" return-object :items="xomzettypes" v-model="xomzettype" label="Klasifikasi Omset"></v-select>
                                                <p v-if="checkError('requireomzet')" class="error pl-2 pr-2" style="color:#fff">Klasifikasi Omset harus diisi dong</p>
                                            </v-flex>
                                            <v-flex xs12>
                                                <v-select readonly item-text="M_MouTypeName" return-object :items="xmoutypes" v-model="xmoutype" label="Tipe Agreement"></v-select>
                                                <p v-if="checkError('requiremoutypr')" class="error pl-2 pr-2" style="color:#fff">Tipe Agreement harus diisi dong</p>
                                            </v-flex>
                                            <v-flex xs12>
                                                <v-select readonly item-text="M_AgingTypeName" return-object :items="xagingtypes" v-model="xagingtype" label="Tipe Aging"></v-select>

                                            </v-flex>
                                            <v-flex xs12>
                                                <v-textarea readonly v-model="xnote" label="Catatan"></v-textarea>
                                            </v-flex>
                                            <v-flex xs12 v-if="this.mouemail">
                                                    <v-checkbox v-model="isemail" readonly label="Otomatis Kirim Email?"></v-checkbox>
                                                </v-flex>
                                                <v-flex xs12>
                                                    <v-layout>
                                                        <v-flex xs6 pa-1>
                                                            <v-checkbox readonly v-model="isbill" label="Bill ?"></v-checkbox>
                                                        </v-flex>
                                                        <v-flex xs6 pa-1>
                                                            <v-text-field readonly v-if="this.isbill === false" label="Min DP (Persen)" v-model="mindp"></v-text-field>
                                                        </v-flex>
                                                    </v-layout>
                                                </v-flex>

                                                <v-flex xs12>
                                                    <v-layout>
                                                        <v-flex xs6 pa-1>
                                                            <v-checkbox readonly v-model="isaging" label="Aging on Hold ?"></v-checkbox>
                                                        </v-flex>
                                                        <v-flex xs6 pa-1>
                                                            <v-text-field readonly v-if="this.isaging === true" label="Keterangan Aging on Hold" v-model="agingnote"></v-text-field>
                                                            <p v-if="checkError('requireaging')" class="error pl-2 pr-2" style="color:#fff">Keterangan Aging harus diisi dong</p>
                                                        </v-flex>
                                                    </v-layout>
                                                </v-flex>
                                            <v-flex xs12>
                                                <v-checkbox readonly v-model="isdefault" label="Default ?"></v-checkbox>
                                            </v-flex>
                                            <v-flex xs12>
                                                <v-checkbox readonly v-model="isfavorit" label="Favorite ?"></v-checkbox>
                                            </v-flex>
                                            <v-flex xs12>
                                                <v-checkbox readonly v-model="ismcu" label="MCU ?"></v-checkbox>
                                            </v-flex>
                                            <v-flex xs12>
                                                <v-checkbox readonly v-model="isjpanetto" label="JPA Netto ?"></v-checkbox>
                                            </v-flex>
                                            <v-flex xs12>
                                                <v-layout>
                                                    <v-flex xs8 pa-1>
                                                        <v-text-field readonly label="JPA 1" v-model="jpa1Name"></v-text-field>
                                                    </v-flex>
                                                    <v-flex xs4 pa-1>
                                                        <v-text-field readonly label="Percent" v-model="jpa1Percent"></v-text-field>
                                                    </v-flex>
                                                </v-layout>
                                            </v-flex>
                                            <v-flex xs12>
                                                <v-layout>
                                                    <v-flex xs8 pa-1>
                                                        <v-text-field readonly label="JPA 2" v-model="jpa2Name"></v-text-field>
                                                    </v-flex>
                                                    <v-flex xs4 pa-1>
                                                        <v-text-field readonly label="Percent" v-model="jpa2Percent"></v-text-field>
                                                    </v-flex>
                                                </v-layout>
                                            </v-flex>
                                            <v-flex xs12>
                                                <v-layout>
                                                    <v-flex xs8 pa-1>
                                                        <v-text-field readonly label="JPA 3" v-model="jpa3Name"></v-text-field>
                                                    </v-flex>
                                                    <v-flex xs4 pa-1>
                                                        <v-text-field readonly label="Percent" v-model="jpa3Percent"></v-text-field>
                                                    </v-flex>
                                                </v-layout>
                                            </v-flex>

                                            <v-flex xs12>
                                                <v-layout>
                                                    <v-flex xs8 pa-1>
                                                        <v-text-field readonly label="JPA 4" v-model="jpa4Name"></v-text-field>
                                                    </v-flex>
                                                    <v-flex xs4 pa-1>
                                                        <v-text-field readonly label="Percent" v-model="jpa4Percent"></v-text-field>
                                                    </v-flex>
                                                </v-layout>
                                            </v-flex>
                                            <v-flex>
                                                <p v-for="(xerror,idx) in xerrors" class="error pl-2 pr-2" style="color:#fff">{{xerror.msg}}</p>
                                            </v-flex>
                                    </v-layout>
                            </v-card-text>
                            <v-divider></v-divider>
                            <v-card-actions>
                                <v-spacer></v-spacer>
                                <v-btn color="primary" flat @click="dialogunverifyalertmou = false">
                                    Tutup
                                </v-btn>
                                <v-btn color="primary" flat @click="closeUnVerifyAlertMou()">
                                    Batal Verifikasi
                                </v-btn>
                            </v-card-actions>
                        </v-card>
                    </v-dialog>

                </template>


                <template>

                    <v-dialog v-model="dialogreleasealertmou" max-width="600px">
                        <v-card>
                            <v-card-title>
                                <span class="headline">Konfirmasi Rilis</span>
                            </v-card-title>
                            <v-card-text class="pt-0 pb-0">
                                <v-form ref="formcompanymou" v-model="validmou" lazy-validation>
                                    <v-layout wrap>
                                        <v-flex xs12>
                                            <v-icon color="orange darken-2" @click="doPrint()">folder_open</v-icon>PERUSAHAAN : {{xcompany.name}} <span> &nbsp;[ <span style="color:#2196F3;font-weight: 900;">{{number}} </span>                                            &nbsp;]
                                        </v-flex>
                                        <v-flex xs12>
                                            <v-text-field readonly label="Nama" v-model="name"></v-text-field>
                                            <p v-if="checkError('requirename')" class="error pl-2 pr-2" style="color:#fff">Nama harus diisi dong</p>
                                        </v-flex>
                                        <v-flex xs12>
                                            <v-text-field readonly label="No Ref" v-model="refnumber"></v-text-field>
                                        </v-flex>
                                        <v-flex xs12>
                                            <v-layout>
                                                <v-flex xs6 pa-1>
                                                    <v-text-field label="Tgl. Mulai" placeholder="dd-mm-yyyy" mask="##-##-####" v-model="xstartdate"></v-text-field>
                                                </v-flex>
                                                <v-flex xs6 pa-1>
                                                    <v-text-field label="Tgl. Selesai" placeholder="dd-mm-yyyy" mask="##-##-####" v-model="xenddate"></v-text-field>
                                                </v-flex>
                                            </v-layout>

                                            <v-flex xs12>

                                                <v-select readonly item-text="basename" return-object :items="xbases" v-model="xbase" label="Dasar Agreement"></v-select>
                                                <p v-if="checkError('requirebase')" class="error pl-2 pr-2" style="color:#fff">Dasar Agreement harus diisi dong</p>
                                            </v-flex>
                                            <v-flex xs12>
                                                <v-select readonly item-text="M_OmzetTypeName" return-object :items="xomzettypes" v-model="xomzettype" label="Klasifikasi Omset"></v-select>
                                                <p v-if="checkError('requireomzet')" class="error pl-2 pr-2" style="color:#fff">Klasifikasi Omset harus diisi dong</p>
                                            </v-flex>
                                            <v-flex xs12>
                                                <v-select readonly item-text="M_MouTypeName" return-object :items="xmoutypes" v-model="xmoutype" label="Tipe Agreement"></v-select>
                                                <p v-if="checkError('requiremoutypr')" class="error pl-2 pr-2" style="color:#fff">Tipe Agreement harus diisi dong</p>
                                            </v-flex>
                                            <v-flex xs12>
                                                <v-select readonly item-text="M_AgingTypeName" return-object :items="xagingtypes" v-model="xagingtype" label="Tipe Aging"></v-select>

                                            </v-flex>
                                            <v-flex xs12>
                                                <v-textarea readonly v-model="xnote" label="Catatan"></v-textarea>
                                            </v-flex>
                                            <v-flex xs12 v-if="this.mouemail">
                                                    <v-checkbox v-model="isemail" readonly label="Otomatis Kirim Email?"></v-checkbox>
                                                </v-flex>
                                                <v-flex xs12>
                                                    <v-layout>
                                                        <v-flex xs6 pa-1>
                                                            <v-checkbox readonly v-model="isbill" label="Bill ?"></v-checkbox>
                                                        </v-flex>
                                                        <v-flex xs6 pa-1>
                                                            <v-text-field readonly v-if="this.isbill === false" label="Min DP (Persen)" v-model="mindp"></v-text-field>
                                                        </v-flex>
                                                    </v-layout>
                                                </v-flex>

                                                <v-flex xs12>
                                                    <v-layout>
                                                        <v-flex xs6 pa-1>
                                                            <v-checkbox readonly v-model="isaging" label="Aging on Hold ?"></v-checkbox>
                                                        </v-flex>
                                                        <v-flex xs6 pa-1>
                                                            <v-text-field readonly v-if="this.isaging === true" label="Keterangan Aging on Hold" v-model="agingnote"></v-text-field>
                                                            <p v-if="checkError('requireaging')" class="error pl-2 pr-2" style="color:#fff">Keterangan Aging harus diisi dong</p>
                                                        </v-flex>
                                                    </v-layout>
                                                </v-flex>
                                            <v-flex xs12>
                                                <v-checkbox readonly v-model="isdefault" label="Default ?"></v-checkbox>
                                            </v-flex>
                                            <v-flex xs12>
                                                <v-checkbox readonly v-model="isfavorit" label="Favorite ?"></v-checkbox>
                                            </v-flex>
                                            <v-flex xs12>
                                                <v-checkbox readonly v-model="ismcu" label="MCU ?"></v-checkbox>
                                            </v-flex>
                                            <v-flex xs12>
                                                <v-checkbox readonly v-model="isjpanetto" label="JPA Netto ?"></v-checkbox>
                                            </v-flex>
                                            <v-flex xs12>
                                                <v-layout>
                                                    <v-flex xs8 pa-1>
                                                        <v-text-field readonly label="JPA 1" v-model="jpa1Name"></v-text-field>
                                                    </v-flex>
                                                    <v-flex xs4 pa-1>
                                                        <v-text-field readonly label="Percent" v-model="jpa1Percent"></v-text-field>
                                                    </v-flex>
                                                </v-layout>
                                            </v-flex>
                                            <v-flex xs12>
                                                <v-layout>
                                                    <v-flex xs8 pa-1>
                                                        <v-text-field readonly label="JPA 2" v-model="jpa2Name"></v-text-field>
                                                    </v-flex>
                                                    <v-flex xs4 pa-1>
                                                        <v-text-field readonly label="Percent" v-model="jpa2Percent"></v-text-field>
                                                    </v-flex>
                                                </v-layout>
                                            </v-flex>
                                            <v-flex xs12>
                                                <v-layout>
                                                    <v-flex xs8 pa-1>
                                                        <v-text-field readonly label="JPA 3" v-model="jpa3Name"></v-text-field>
                                                    </v-flex>
                                                    <v-flex xs4 pa-1>
                                                        <v-text-field readonly label="Percent" v-model="jpa3Percent"></v-text-field>
                                                    </v-flex>
                                                </v-layout>
                                            </v-flex>

                                            <v-flex xs12>
                                                <v-layout>
                                                    <v-flex xs8 pa-1>
                                                        <v-text-field readonly label="JPA 4" v-model="jpa4Name"></v-text-field>
                                                    </v-flex>
                                                    <v-flex xs4 pa-1>
                                                        <v-text-field readonly label="Percent" v-model="jpa4Percent"></v-text-field>
                                                    </v-flex>
                                                </v-layout>
                                            </v-flex>
                                            <v-flex>
                                                <p v-for="(xerror,idx) in xerrors" class="error pl-2 pr-2" style="color:#fff">{{xerror.msg}}</p>
                                            </v-flex>
                                    </v-layout>
                            </v-card-text>
                            <v-divider></v-divider>
                            <v-card-actions>
                                <v-spacer></v-spacer>
                                <v-btn color="primary" flat @click="dialogreleasealertmou = false">
                                    Tutup
                                </v-btn>
                                <v-btn color="primary" flat @click="closeReleaseAlertMou()">
                                    Rilis
                                </v-btn>
                            </v-card-actions>
                        </v-card>
                    </v-dialog>

                </template>
                <template>

                    <v-dialog v-model="alertverify" max-width="30%">
                        <v-card>
                            <v-card-title class="headline grey lighten-2 pt-2 pb-2" primary-title>
                                Peringatan
                            </v-card-title>
                            <v-card-text class="pt-2 pb-2">
                                <v-layout row>
                                    <v-flex xs12 d-flex>
                                        <v-layout row>
                                            <v-flex pb-1 xs12>
                                                <v-layout row>
                                                    <v-flex pt-2 pr-2 xs12>
                                                        {{msgalertmou}}
                                                    </v-flex>
                                                </v-layout>
                                            </v-flex>
                                        </v-layout>
                                    </v-flex>
                                </v-layout>
                            </v-card-text>
                            <v-divider></v-divider>
                            <v-card-actions>
                                <v-spacer></v-spacer>
                                <v-btn color="primary" flat @click="alertverify = false">
                                    Tutup
                                </v-btn>
                                <v-btn color="primary" flat @click="doPrice()">
                                    Buat Harga
                                </v-btn>
                            </v-card-actions>
                        </v-card>
                    </v-dialog>

                </template>

                <template>

                    <v-dialog v-model="dialogunreleasealertmou" max-width="600px">
                        <v-card>
                            <v-card-title class="headline grey lighten-2 pt-2 pb-2" primary-title>
                                Batal Rilis
                            </v-card-title>
                            <v-card-text class="pt-0 pb-0">
                                <v-form ref="formcompanymou" v-model="validmou" lazy-validation>
                                    <v-layout wrap>
                                        <v-flex xs12>
                                            PERUSAHAAN : {{xcompany.name}} <span> &nbsp;[ <span style="color:#2196F3;font-weight: 900;">{{number}} </span>                                            &nbsp;]
                                        </v-flex>
                                        <v-flex xs12>
                                            <v-text-field readonly label="Nama" v-model="name"></v-text-field>
                                            <p v-if="checkError('requirename')" class="error pl-2 pr-2" style="color:#fff">Nama harus diisi dong</p>
                                        </v-flex>
                                        <v-flex xs12>
                                            <v-text-field readonly label="No Ref" v-model="refnumber"></v-text-field>
                                        </v-flex>
                                        <v-flex xs12>
                                            <v-layout>
                                                <v-flex xs6 pa-1>
                                                    <v-text-field label="Tgl. Mulai" placeholder="dd-mm-yyyy" mask="##-##-####" v-model="xstartdate"></v-text-field>
                                                </v-flex>
                                                <v-flex xs6 pa-1>
                                                    <v-text-field label="Tgl. Selesai" placeholder="dd-mm-yyyy" mask="##-##-####" v-model="xenddate"></v-text-field>
                                                </v-flex>
                                            </v-layout>

                                            <v-flex xs12>

                                                <v-select readonly item-text="basename" return-object :items="xbases" v-model="xbase" label="Dasar Agreement"></v-select>
                                                <p v-if="checkError('requirebase')" class="error pl-2 pr-2" style="color:#fff">Dasar Agreement harus diisi dong</p>
                                            </v-flex>
                                            <v-flex xs12>
                                                <v-select readonly item-text="M_OmzetTypeName" return-object :items="xomzettypes" v-model="xomzettype" label="Klasifikasi Omset"></v-select>
                                                <p v-if="checkError('requireomzet')" class="error pl-2 pr-2" style="color:#fff">Klasifikasi Omset harus diisi dong</p>
                                            </v-flex>
                                            <v-flex xs12>
                                                <v-select readonly item-text="M_MouTypeName" return-object :items="xmoutypes" v-model="xmoutype" label="Tipe Agreement"></v-select>
                                                <p v-if="checkError('requiremoutypr')" class="error pl-2 pr-2" style="color:#fff">Tipe Agreement harus diisi dong</p>
                                            </v-flex>
                                            <v-flex xs12>
                                                <v-select readonly item-text="M_AgingTypeName" return-object :items="xagingtypes" v-model="xagingtype" label="Tipe Aging"></v-select>

                                            </v-flex>
                                            <v-flex xs12>
                                                <v-textarea readonly v-model="xnote" label="Catatan"></v-textarea>
                                            </v-flex>
                                            <v-flex xs12 v-if="this.mouemail">
                                                    <v-checkbox v-model="isemail" readonly label="Otomatis Kirim Email?"></v-checkbox>
                                                </v-flex>
                                                <v-flex xs12>
                                                    <v-layout>
                                                        <v-flex xs6 pa-1>
                                                            <v-checkbox readonly v-model="isbill" label="Bill ?"></v-checkbox>
                                                        </v-flex>
                                                        <v-flex xs6 pa-1>
                                                            <v-text-field readonly v-if="this.isbill === false" label="Min DP (Persen)" v-model="mindp"></v-text-field>
                                                        </v-flex>
                                                    </v-layout>
                                                </v-flex>

                                                <v-flex xs12>
                                                    <v-layout>
                                                        <v-flex xs6 pa-1>
                                                            <v-checkbox readonly v-model="isaging" label="Aging on Hold ?"></v-checkbox>
                                                        </v-flex>
                                                        <v-flex xs6 pa-1>
                                                            <v-text-field readonly v-if="this.isaging === true" label="Keterangan Aging on Hold" v-model="agingnote"></v-text-field>
                                                            <p v-if="checkError('requireaging')" class="error pl-2 pr-2" style="color:#fff">Keterangan Aging harus diisi dong</p>
                                                        </v-flex>
                                                    </v-layout>
                                                </v-flex>
                                            <v-flex xs12>
                                                <v-checkbox readonly v-model="isdefault" label="Default ?"></v-checkbox>
                                            </v-flex>
                                            <v-flex xs12>
                                                <v-checkbox readonly v-model="isfavorit" label="Favorite ?"></v-checkbox>
                                            </v-flex>
                                            <v-flex xs12>
                                                <v-checkbox readonly v-model="ismcu" label="MCU ?"></v-checkbox>
                                            </v-flex>
                                            <v-flex xs12>
                                                <v-checkbox readonly v-model="isjpanetto" label="JPA Netto ?"></v-checkbox>
                                            </v-flex>
                                            <v-flex xs12>
                                                <v-layout>
                                                    <v-flex xs8 pa-1>
                                                        <v-text-field readonly label="JPA 1" v-model="jpa1Name"></v-text-field>
                                                    </v-flex>
                                                    <v-flex xs4 pa-1>
                                                        <v-text-field readonly label="Percent" v-model="jpa1Percent"></v-text-field>
                                                    </v-flex>
                                                </v-layout>
                                            </v-flex>
                                            <v-flex xs12>
                                                <v-layout>
                                                    <v-flex xs8 pa-1>
                                                        <v-text-field readonly label="JPA 2" v-model="jpa2Name"></v-text-field>
                                                    </v-flex>
                                                    <v-flex xs4 pa-1>
                                                        <v-text-field readonly label="Percent" v-model="jpa2Percent"></v-text-field>
                                                    </v-flex>
                                                </v-layout>
                                            </v-flex>
                                            <v-flex xs12>
                                                <v-layout>
                                                    <v-flex xs8 pa-1>
                                                        <v-text-field readonly label="JPA 3" v-model="jpa3Name"></v-text-field>
                                                    </v-flex>
                                                    <v-flex xs4 pa-1>
                                                        <v-text-field readonly label="Percent" v-model="jpa3Percent"></v-text-field>
                                                    </v-flex>
                                                </v-layout>
                                            </v-flex>

                                            <v-flex xs12>
                                                <v-layout>
                                                    <v-flex xs8 pa-1>
                                                        <v-text-field readonly label="JPA 4" v-model="jpa4Name"></v-text-field>
                                                    </v-flex>
                                                    <v-flex xs4 pa-1>
                                                        <v-text-field readonly label="Percent" v-model="jpa4Percent"></v-text-field>
                                                    </v-flex>
                                                </v-layout>
                                            </v-flex>
                                            <v-flex>
                                                <p v-for="(xerror,idx) in xerrors" class="error pl-2 pr-2" style="color:#fff">{{xerror.msg}}</p>
                                            </v-flex>
                                    </v-layout>
                            </v-card-text>
                            <v-divider></v-divider>
                            <v-card-actions>
                                <v-spacer></v-spacer>
                                <v-btn color="primary" flat @click="dialogunreleasealertmou = false">
                                    Tutup
                                </v-btn>
                                <v-btn color="primary" flat @click="closeUnReleaseAlertMou()">
                                    Batal Rilis
                                </v-btn>
                            </v-card-actions>
                        </v-card>
                    </v-dialog>

                </template>

                <template>
                    <v-layout row justify-center>
                        <v-dialog v-model="dialogstatusorder" persistent max-width="600px">
                            <v-card>
                                <v-card-title>
                                    <span class="headline">Status</span>
                                </v-card-title>
                                <v-card-text class="pt-0 pb-0">
                                    <v-timeline>
                                        <v-timeline-item v-for="(status, i) in xstatuss" :key="i" :waktu="status.waktu" :user="status.user" small>
                                            <template>
                                                <span :class="`headline font-weight-bold cyan--text`" v-text="status.status"></span>
                                            </template>
                                            <div class="py-3">
                                                <h2 :class="`headline font-weight-light mb-3 cyan--text`"></h2>
                                                <div>
                                                    {{status.waktu}}
                                                    <p> [ {{status.user}} ] </p>
                                                </div>
                                            </div>
                                        </v-timeline-item>
                                    </v-timeline>
                                    <v-card-actions>
                                        <v-spacer></v-spacer>
                                        <v-btn color="blue darken-1" flat @click="updateDialogStatusOrder()">Tutup</v-btn>
                                    </v-card-actions>
                            </v-card>
                        </v-dialog>
                    </v-layout>
                </template>

                <template>
                    <v-layout row justify-center>
                        <v-dialog v-model="dialogmou" persistent max-width="600px">
                            <v-card>
                                <v-card-title>
                                    <span class="headline">Form Agreement</span>
                                </v-card-title>
                                <v-card-text class="pt-0 pb-0">
                                    <v-form ref="formcompanymou" v-model="validmou" lazy-validation>
                                        <v-layout wrap>
                                            <v-flex xs12>
                                                PERUSAHAAN : {{xcompany.name}} <span> &nbsp;[ <span style="color:#2196F3;font-weight: 900;">{{number}} </span>                                                &nbsp;]
                                            </v-flex>
                                            <v-flex xs12>
                                                <v-text-field label="Nama" v-model="name"></v-text-field>
                                                <p v-if="checkError('requirename')" class="error pl-2 pr-2" style="color:#fff">Nama harus diisi dong</p>
                                            </v-flex>
                                            <v-flex xs12>
                                                <v-text-field label="No Ref" v-model="refnumber"></v-text-field>
                                            </v-flex>
                                            <v-flex xs12>
                                                <v-layout>
                                                    <v-flex xs6 pa-1>
                                                        <v-text-field label="Tgl. Mulai" placeholder="dd-mm-yyyy" mask="##-##-####" v-model="xstartdate"></v-text-field>
                                                    </v-flex>
                                                    <v-flex xs6 pa-1>
                                                        <v-text-field label="Tgl. Selesai" placeholder="dd-mm-yyyy" mask="##-##-####" v-model="xenddate"></v-text-field>
                                                    </v-flex>
                                                </v-layout>
                                                <v-flex xs12>
                                                    <v-select item-text="basename" return-object :items="xbases" v-model="xbase" label="Dasar Agreement"></v-select>
                                                    <p v-if="checkError('requirebase')" class="error pl-2 pr-2" style="color:#fff">Dasar Agreement harus diisi dong</p>
                                                </v-flex>
                                                <v-flex xs12>
                                                    <v-select item-text="M_OmzetTypeName" return-object :items="xomzettypes" v-model="xomzettype" label="Klasifikasi Omset"></v-select>
                                                    <p v-if="checkError('requireomzet')" class="error pl-2 pr-2" style="color:#fff">Klasifikasi Omset harus diisi dong</p>
                                                </v-flex>
                                                <v-flex xs12>
                                                    <v-select item-text="M_MouTypeName" return-object :items="xmoutypes" v-model="xmoutype" label="Tipe Agreement"></v-select>
                                                    <p v-if="checkError('requiremoutypr')" class="error pl-2 pr-2" style="color:#fff">Tipe Agreement harus diisi dong</p>
                                                </v-flex>
                                                <v-flex xs12>
                                                    <v-select item-text="M_AgingTypeName" return-object :items="xagingtypes" v-model="xagingtype" label="Tipe Aging"></v-select>

                                                </v-flex>
                                                <v-flex xs12>
                                                    <v-textarea v-model="xnote" label="Catatan"></v-textarea>
                                                </v-flex>
                                                <v-flex xs12 v-if="this.mouemail">
                                                    <v-checkbox v-model="isemail" label="Otomatis Kirim Email?"></v-checkbox>
                                                </v-flex>
                                                <v-flex xs12>
                                                    <v-layout>
                                                        <v-flex xs6 pa-1>
                                                            <v-checkbox v-model="isbill" label="Bill ?"></v-checkbox>
                                                        </v-flex>
                                                        <v-flex xs6 pa-1>
                                                            <v-text-field v-if="this.isbill === false" label="Min DP (Persen)" v-model="mindp"></v-text-field>
                                                        </v-flex>
                                                    </v-layout>
                                                </v-flex>

                                                <v-flex xs12>
                                                    <v-layout>
                                                        <v-flex xs6 pa-1>
                                                            <v-checkbox v-model="isaging" label="Aging on Hold ?"></v-checkbox>
                                                        </v-flex>
                                                        <v-flex xs6 pa-1>
                                                            <v-text-field v-if="this.isaging === true" label="Keterangan Aging on Hold" v-model="agingnote"></v-text-field>
                                                            <p v-if="checkError('requireaging')" class="error pl-2 pr-2" style="color:#fff">Keterangan Aging harus diisi dong</p>
                                                        </v-flex>
                                                    </v-layout>
                                                </v-flex>
                                                <v-flex xs12>
                                                    <v-checkbox v-model="isdefault" label="Default ?"></v-checkbox>
                                                </v-flex>
                                                <v-flex xs12>
                                                    <v-checkbox v-model="isfavorit" label="Favorite ?"></v-checkbox>
                                                </v-flex>
                                                <v-flex xs12>
                                                    <v-checkbox v-model="ismcu" label="MCU ?"></v-checkbox>
                                                </v-flex>
                                                <v-flex xs12>
                                                    <v-checkbox v-model="isjpanetto" label="JPA Netto ?"></v-checkbox>
                                                </v-flex>
                                                <v-flex xs12>
                                                    <v-layout>
                                                        <v-flex xs8 pa-1>
                                                            <v-text-field label="JPA 1" v-model="jpa1Name"></v-text-field>
                                                        </v-flex>
                                                        <v-flex xs4 pa-1>
                                                            <v-text-field label="Percent" v-model="jpa1Percent"></v-text-field>
                                                        </v-flex>
                                                    </v-layout>
                                                </v-flex>
                                                <v-flex xs12>
                                                    <v-layout>
                                                        <v-flex xs8 pa-1>
                                                            <v-text-field label="JPA 2" v-model="jpa2Name"></v-text-field>
                                                        </v-flex>
                                                        <v-flex xs4 pa-1>
                                                            <v-text-field label="Percent" v-model="jpa2Percent"></v-text-field>
                                                        </v-flex>
                                                    </v-layout>
                                                </v-flex>
                                                <v-flex xs12>
                                                    <v-layout>
                                                        <v-flex xs8 pa-1>
                                                            <v-text-field label="JPA 3" v-model="jpa3Name"></v-text-field>
                                                        </v-flex>
                                                        <v-flex xs4 pa-1>
                                                            <v-text-field label="Percent" v-model="jpa3Percent"></v-text-field>
                                                        </v-flex>
                                                    </v-layout>
                                                </v-flex>

                                                <v-flex xs12>
                                                    <v-layout>
                                                        <v-flex xs8 pa-1>
                                                            <v-text-field label="JPA 4" v-model="jpa4Name"></v-text-field>
                                                        </v-flex>
                                                        <v-flex xs4 pa-1>
                                                            <v-text-field label="Percent" v-model="jpa4Percent"></v-text-field>
                                                        </v-flex>
                                                    </v-layout>
                                                </v-flex>
                                                <v-flex>
                                                    <p v-for="(xerror,idx) in xerrors" class="error pl-2 pr-2" style="color:#fff">{{xerror.msg}}</p>
                                                </v-flex>
                                        </v-layout>
                                </v-card-text>
                                <v-card-actions>
                                    <v-spacer></v-spacer>
                                    <v-btn color="blue darken-1" flat @click="updateDialogFormMou()">Tutup</v-btn>
                                    <v-btn color="blue darken-1" flat @click="saveFormMou()">Simpan</v-btn>
                                </v-card-actions>
                                </v-form>
                            </v-card>
                        </v-dialog>
                    </v-layout>
                </template>

            </v-card>
            </v-flex>

            <one-dialog-print :title="printtitle" :width="printwidth" :height="500" :status="openprint" :urlprint="urlprint" @close-dialog-print="closePrint"></one-dialog-print>
            <one-dialog-print-verify :title="printtitleverify" :width="printwidthverify" :height="500" :status="openprintverify" :urlprint="urlprintverify"
                @close-dialog-print="closePrintVerify"></one-dialog-print-verify>


    </v-layout>
</template>

<style scoped>
    .searchbox .v-input.v-text-field .v-input__slot {
        min-height: 60px;
    }

    .searchbox .v-btn {
        min-height: 60px;
    }

    table.v-table tbody td,
    table.v-table tbody th {
        height: 40px;
    }

    table.v-table thead tr {
        height: 40px;
    }
</style>

<script>
    module.exports = {
        components: {
            'one-date-picker': httpVueLoader('../../../common/oneDatePicker.vue'),
            'one-dialog-print': httpVueLoader('../../../common/oneDialogPrintX.vue'),
            'one-dialog-print-verify': httpVueLoader('../../../common/oneDialogPrintX.vue')
        },
        data() {
            return {
                query: "",
                items: [],
                openprint: false,
                urlprint: '',
                printtitle: '',
                printwidth: 600,
                openprintverify: false,
                urlprintverify: '',
                printtitleverify: '',
                printwidthverify: 600,
                formatreport: 'pdf',
                emailRules: [
                    v => !!v || 'Alamat email harus diisi'
                ],
                page: 1,
                headers: [{
                        text: "NO.",
                        align: "Center",
                        sortable: false,
                        value: "lab",
                        width: "18%",
                        class: "blue lighten-4"
                    },
                    {
                        text: "NAMA",
                        align: "Center",
                        sortable: false,
                        value: "name",
                        width: "25%",
                        class: "blue lighten-4"
                    },
                    {
                        text: "PERIODE",
                        align: "Center",
                        sortable: false,
                        value: "name",
                        width: "20%",
                        class: "blue lighten-4"
                    },
                    {
                        text: "TIPE",
                        align: "Center",
                        sortable: false,
                        value: "name",
                        width: "8%",
                        class: "blue lighten-4"
                    },
                    {
                        text: "STATUS",
                        align: "Center",
                        sortable: false,
                        value: "name",
                        width: "5%",
                        class: "blue lighten-4"
                    },
                    {
                        text: "AKSI",
                        align: "Center",
                        sortable: false,
                        value: "status",
                        width: "18%",
                        class: "blue lighten-4"
                    }
                ],
                pagination: {
                    descending: false,
                    page: 1,
                    rowsPerPage: 5,
                    sortBy: 'trx_id ASC',
                    totalItems: this.$store.state.mou.total_transactions
                },
                statuss: [{
                        waktu: '16-07-2019 10:00',
                        status: 'Order Dibuat',
                        user: 'Nagita Slavina'
                    },
                    {
                        waktu: '16-07-2019 11:00',
                        status: 'Order Dikirim',
                        user: 'Nagita Slavina'
                    },
                    {
                        waktu: '16-07-2019 12:00',
                        status: 'Order dikonfirmasi',
                        user: 'Chacha Frederica'
                    },
                    {
                        waktu: '16-07-2019 13:00',
                        status: 'Telah dibuat Surat Jalan',
                        user: 'Chacha Frederica'
                    },
                    {
                        waktu: '16-07-2019 14:00',
                        status: 'Kurir akan mengambil sampel',
                        user: 'Satria Subiantoro'
                    }
                ],
                color: "success",
                validmou: false,
                xid: 0,
                countprice: 0,
                name: "",
                number: "",
                refnumber: "",
                mindp: "",
                agingnote: "",
                xnote: "",
                mouemail: "",
                startdate: "",
                enddate: "",
                isbill: "",
                isdefault: "",
                isfavorit: "",
                isjpanetto: "",
                ismcu: "",
                isaging: "",
                isemail: "",
                menustartdate: false,
                menuenddate: false,
                date: new Date().toISOString().substr(0, 10),
                jpa1Name: '',
                jpa2Name: '',
                jpa3Name: '',
                jpa4Name: '',
                jpa1Percent: 0,
                jpa2Percent: 0,
                jpa3Percent: 0,
                jpa4Percent: 0,
                dialogdeletealertmou: false,
                dialogverifyalertmou: false,
                dialogreleasealertmou: false,
                alertverify: false,
                dialogunreleasealertmou: false,
                dialogunverifyalertmou: false,
                msgalertmou: ""
            };
        },
        mounted() {
            this.$store.dispatch("mou/selectbase")
            this.$store.dispatch("mou/selectomzettype")
            this.$store.dispatch("mou/selectmoutype")
            this.$store.dispatch("mou/selectagingtype")
        },
        computed: {
            dialogprogress: {
                get() {
                    return this.$store.state.mou.dialog_progress
                },
                set(v) {
                    this.$store.commit("mou/update_dialog_progress", v)
                }
            },
            mous() {
                return this.$store.state.mou.mous
            },
            xcompany() {
                return this.$store.state.company.selected_company
            },
            dialogmou() {
                return this.$store.state.mou.dialog_form_mou
            },
            xerrors() {
                return this.$store.state.mou.errors
            },
            isLoading() {
                return this.$store.state.mou.search_status == 1
            },
            jpa1_name: {
                get() {
                    return this.$store.state.mou.jpa1_name
                },
                set(v) {
                    return this.$store.state.mou.jpa1_name
                }
            },
            jpa2_name: {
                get() {
                    return this.$store.state.mou.jpa2_name
                },
                set(v) {
                    return this.$store.state.mou.jpa2_name
                }
            },
            jpa3_name: {
                get() {
                    return this.$store.state.mou.jpa3_name
                },
                set(v) {
                    return this.$store.state.mou.jpa3_name
                }
            },
            jpa4_name: {
                get() {
                    return this.$store.state.mou.jpa4_name
                },
                set(v) {
                    return this.$store.state.mou.jpa4_name
                }
            },
            jpa1_percent: {
                get() {
                    return this.$store.state.mou.jpa1_percent
                },
                set(v) {
                    return this.$store.state.mou.jpa1_percent
                }
            },
            jpa2_percent: {
                get() {
                    return this.$store.state.mou.jpa2_percent
                },
                set(v) {
                    return this.$store.state.mou.jpa2_percent
                }
            },
            jpa3_percent: {
                get() {
                    return this.$store.state.mou.jpa3_percent
                },
                set(v) {
                    return this.$store.state.mou.jpa3_percent
                }
            },
            jpa4_percent: {
                get() {
                    return this.$store.state.mou.jpa4_percent
                },
                set(v) {
                    return this.$store.state.mou.jpa4_percent
                }
            },
            startComputedDateFormatted() {
                return this.formatDate(this.xstartdate)
            },
            xstartdate: {
                get() {
                    return this.$store.state.mou.startdate
                },
                set(val) {
                    this.$store.commit("mou/update_startdate", val)
                }
            },
            endComputedDateFormatted() {
                return this.formatDate(this.xenddate)
            },
            xenddate: {
                get() {
                    return this.$store.state.mou.enddate
                },
                set(val) {
                    this.$store.commit("mou/update_enddate", val)
                }
            },
            xbases() {
                return this.$store.state.mou.bases
            },
            xbase: {
                get() {
                    return this.$store.state.mou.base
                },
                set(val) {
                    this.$store.commit("mou/update_base", val)
                }

            },
            xomzettypes() {
                return this.$store.state.mou.omzettypes
            },
            xomzettype: {
                get() {
                    return this.$store.state.mou.omzettype
                },
                set(val) {
                    this.$store.commit("mou/update_omzettype", val)
                }

            },
            xmoutypes() {
                return this.$store.state.mou.moutypes
            },
            xmoutype: {
                get() {
                    return this.$store.state.mou.moutype
                },
                set(val) {
                    this.$store.commit("mou/update_moutype", val)
                }

            },
            xagingtypes() {
                return this.$store.state.mou.agingtypes
            },
            xagingtype: {
                get() {
                    return this.$store.state.mou.agingtype
                },
                set(val) {
                    this.$store.commit("mou/update_agingtype", val)
                }

            },
            xstatuss() {
                return this.$store.state.mou.statuss
            },
            dialogstatusorder() {
                return this.$store.state.mou.dialog_status_order
            }
        },
        methods: {
            updateDialogFormMou() {
                this.$store.commit("mou/update_dialog_form_mou", false)
            },
            updateDialogStatusOrder() {
                this.$store.commit("mou/update_dialog_status_order", false)
            },
            setStatusOrder(val) {
                this.$store.commit("mou/update_mous", {})
                this.$store.commit("mou/update_dialog_status_order", true)
                this.$store.commit("mou/update_statuss", val.statuss)
            },
            doPriceList(val) {
                console.log(location)
                var id = val.id
                location.replace("/one-ui/test/vuex/one-md-price-copy-jpa/" + "?id=" + id)
            },
            doPrice() {
                console.log(location)
                var id = this.xid
                location.replace("/one-ui/test/vuex/one-md-price-copy-jpa/" + "?id=" + id)
            },
            doPrint() {
                console.log('doprint')
                this.printwidth = 1028
                this.printtitle = ""
                let user = one_user()
                var id = this.xid
                var d = new Date();
                var n = d.getTime()
                var rptname = 'price_mou'
                var formatrpt = this.formatreport


                this.urlprint = "/birt/run?__report=report/one/rekap/" + rptname + ".rptdesign&__format=" +
                    formatrpt + "&PID=" + id + "&username=" + user.M_UserUsername + "&tm=" + n

                this.openprint = true
            },
            closePrint() {
                this.openprint = false
            },
            doPrintVerify(val) {
                console.log('doprint')
                this.printwidthverify = 1028
                this.printtitleverify = ""
                let user = one_user()
                var id = val.id
                var d = new Date();
                var n = d.getTime()
                var rptname = 'price_mou'
                var formatrpt = this.formatreport

                this.urlprintverify = "/birt/run?__report=report/one/rekap/" + rptname + ".rptdesign&__format=" +
                    formatrpt + "&PID=" + id + "&username=" + user.M_UserUsername + "&tm=" + n

                this.openprintverify = true
            },
            closePrintVerify() {
                this.openprintverify = false
            },
            openFormMou(val) {
                this.xid = val
                this.name = ''
                this.number = ''
                this.refnumber = ''
                this.xstartdate = moment(new Date()).format('DD-MM-YYYY')
                this.xenddate = moment(new Date()).format('DD-MM-YYYY')
                this.isbill = ''
                this.isdefault = ''
                this.isfavorite = ''
                this.isjpanetto = ''
                this.ismcu = ''
                this.isaging = ''
                this.isemail = ''
                this.mindp = ''
                this.agingnote = ''
                this.xnote = ''
                this.mouemail = ''
                this.jpa1Name = ''
                this.jpa2Name = ''
                this.jpa3Name = ''
                this.jpa4Name = ''
                this.jpa1Percent = ''
                this.jpa2Percent = ''
                this.jpa3Percent = ''
                this.jpa4Percent = ''
                this.$store.commit("mou/update_moutype", {})
                this.$store.commit("mou/update_agingtype", {})
                this.$store.commit("mou/update_omzettype", {})
                this.$store.commit("mou/update_base", {})
                this.$store.commit("mou/update_dialog_form_mou", true)
            },
            editFormMou(val) {
                //  this.$store.commit("mou/update_error_name", false)
                this.xid = val.id
                this.name = val.name
                this.number = val.number
                this.refnumber = val.refnumber
                this.xstartdate = val.startdate
                this.xenddate = val.enddate
                this.isbill = val.isbill === 'N' ? false : true
                this.isdefault = val.isdefault === 'N' ? false : true
                this.isfavorit = val.isfavorit === 'N' ? false : true
                this.isjpanetto = val.isjpanetto === 'N' ? false : true
                this.ismcu = val.ismcu === 'N' ? false : true
                this.isaging = val.isaging === 'N' ? false : true
                this.isemail = val.isemail === 'N' ? false : true
                this.mindp = val.mindp
                this.agingnote = val.agingnote
                this.xnote = val.xnote
                this.mouemail = val.mouemail
                this.jpa1Name = val.M_MouJpa1Name
                this.jpa2Name = val.M_MouJpa2Name
                this.jpa3Name = val.M_MouJpa3Name
                this.jpa4Name = val.M_MouJpa4Name
                this.jpa1Percent = val.M_MouJpa1Percent
                this.jpa2Percent = val.M_MouJpa2Percent
                this.jpa3Percent = val.M_MouJpa3Percent
                this.jpa4Percent = val.M_MouJpa4Percent
                var bases = this.$store.state.mou.bases
                var idx_base = _.findIndex(bases, function (o) {
                    return o.baseid == val.baseid
                })
                var base = bases[idx_base]
                this.$store.commit("mou/update_base", base)

                var omzettypes = this.$store.state.mou.omzettypes
                var idx_omzettype = _.findIndex(omzettypes, function (o) {
                    return o.M_OmzetTypeID == val.M_OmzetTypeID
                })
                var omzettype = omzettypes[idx_omzettype]
                this.$store.commit("mou/update_omzettype", omzettype)

                var moutypes = this.$store.state.mou.moutypes
                var idx_moutype = _.findIndex(moutypes, function (o) {
                    return o.M_MouTypeID == val.M_MouTypeID
                })
                var moutype = moutypes[idx_moutype]
                this.$store.commit("mou/update_moutype", moutype)

                var agingtypes = this.$store.state.mou.agingtypes
                var idx_agingtype = _.findIndex(agingtypes, function (o) {
                    return o.M_AgingTypeID == val.M_AgingTypeID
                })
                var agingtype = agingtypes[idx_agingtype]
                this.$store.commit("mou/update_agingtype", agingtype)
                this.$store.commit("mou/update_dialog_form_mou", true)
            },
            checkError(value) {
                var errors = this.$store.state.mou.errors
                if (errors.includes(value)) {
                    return true
                } else {
                    return false
                }
            },
            saveFormMou() {
                this.$store.commit("mou/update_errors", [])
                var errors = this.$store.state.mou.errors
                if (this.name === '') {
                    errors.push("requirename")
                }
                if (_.isEmpty(this.xbase)) {
                    errors.push("requirebase")
                }
                if (_.isEmpty(this.xomzettype)) {
                    errors.push("requireomzet")
                }
                if (_.isEmpty(this.xmoutype)) {
                    errors.push("requiremoutypr")
                }
                if (this.isemail === true && this.mouemail === '') {
                    errors.push("requireemail")
                }
                if (this.isaging === true && this.agingnote === '') {
                    errors.push("requireaging")
                }
                if (errors.length === 0) {
                    this.$store.dispatch("mou/save", {
                        xid: this.xid,
                        companyid: this.$store.state.company.selected_company.id,
                        companyname: this.$store.state.company.selected_company.name,
                        name: this.name,
                        startdate: moment(this.xstartdate, 'DDMMYYYY').format('DD-MM-YYYY'),
                        enddate: moment(this.xenddate, 'DDMMYYYY').format('DD-MM-YYYY'),
                        isbill: this.isbill === true ? "Y" : "N",
                        isdefault: this.isdefault === true ? "Y" : "N",
                        isfavorit: this.isfavorit === true ? "Y" : "N",
                        isjpanetto: this.isjpanetto === true ? "Y" : "N",
                        ismcu: this.ismcu === true ? "Y" : "N",
                        isaging: this.isaging === true ? "Y" : "N",
                        isemail: this.isemail === true ? "Y" : "N",
                        number: this.number,
                        refnumber: this.refnumber,
                        mindp: this.mindp,
                        agingnote: this.isaging === true ? this.agingnote : "",
                        xnote: this.xnote,
                        mouemail: this.isemail === true ? this.mouemail : "",
                        base: this.xbase.baseid,
                        omzettype: this.xomzettype.M_OmzetTypeID,
                        moutype: this.xmoutype.M_MouTypeID,
                        agingtype: this.xagingtype.M_AgingTypeID,
                        jpa1Name: this.jpa1Name,
                        jpa2Name: this.jpa2Name,
                        jpa3Name: this.jpa3Name,
                        jpa4Name: this.jpa4Name,
                        jpa1Percent: this.jpa1Percent,
                        jpa2Percent: this.jpa2Percent,
                        jpa3Percent: this.jpa3Percent,
                        jpa4Percent: this.jpa4Percent
                    })
                }
            },
            set_date2(x) {
                this.startdate = x.new_date
            },
            set_date3(x) {
                this.enddate = x.new_date
            },
            formatDate(date) {
                if (!date) return null

                const [year, month, day] = date.split('-')
                return `${day}-${month}-${year}`
            },
            deFormatedDate(date) {
                if (!date) return null

                const [day, month, year] = date.split('-')
                return `${year}-${month.padStart(2, '0')}-${day.padStart(2, '0')}`
            },
            updateAlert_success(val) {
                this.$store.commit("company/update_alert_success", val)
            },
            deleteMou(data) {
                this.xid = data.id

                this.msgalertmou = "Yakin, mau hapus agreement ini?"
                this.dialogdeletealertmou = true
            },
            closeDeleteAlertMou() {
                this.$store.dispatch("mou/delete", {
                    xid: this.xid,
                    companyid: this.$store.state.company.selected_company.id,
                    companyname: this.$store.state.company.selected_company.name,
                    name: this.name
                })
                this.dialogdeletealertmou = false
            },
            verifyMou(val) {
                // this.xid = data.id

                //  this.msgalertmou = "Apakah Anda yakin akan mem-verifikasi agreement ini?"
                this.dialogverifyalertmou = true
                this.xid = val.id
                this.countprice = val.countprice
                this.name = val.name
                this.number = val.number
                this.refnumber = val.refnumber
                this.xstartdate = val.startdate
                this.xenddate = val.enddate
                this.isbill = val.isbill === 'N' ? false : true
                this.isdefault = val.isdefault === 'N' ? false : true
                this.isfavorit = val.isfavorit === 'N' ? false : true
                this.isjpanetto = val.isjpanetto === 'N' ? false : true
                this.ismcu = val.ismcu === 'N' ? false : true
                this.isaging = val.isaging === 'N' ? false : true
                this.isemail = val.isemail === 'N' ? false : true
                this.mindp = val.mindp
                this.agingnote = val.agingnote
                this.xnote = val.xnote
                this.mouemail = val.mouemail
                this.jpa1Name = val.M_MouJpa1Name
                this.jpa2Name = val.M_MouJpa2Name
                this.jpa3Name = val.M_MouJpa3Name
                this.jpa4Name = val.M_MouJpa4Name
                this.jpa1Percent = val.M_MouJpa1Percent
                this.jpa2Percent = val.M_MouJpa2Percent
                this.jpa3Percent = val.M_MouJpa3Percent
                this.jpa4Percent = val.M_MouJpa4Percent
                var bases = this.$store.state.mou.bases
                var idx_base = _.findIndex(bases, function (o) {
                    return o.baseid == val.baseid
                })
                var base = bases[idx_base]
                this.$store.commit("mou/update_base", base)

                var omzettypes = this.$store.state.mou.omzettypes
                var idx_omzettype = _.findIndex(omzettypes, function (o) {
                    return o.M_OmzetTypeID == val.M_OmzetTypeID
                })
                var omzettype = omzettypes[idx_omzettype]
                this.$store.commit("mou/update_omzettype", omzettype)

                var moutypes = this.$store.state.mou.moutypes
                var idx_moutype = _.findIndex(moutypes, function (o) {
                    return o.M_MouTypeID == val.M_MouTypeID
                })
                var moutype = moutypes[idx_moutype]
                this.$store.commit("mou/update_moutype", moutype)

                var agingtypes = this.$store.state.mou.agingtypes
                var idx_agingtype = _.findIndex(agingtypes, function (o) {
                    return o.M_AgingTypeID == val.M_AgingTypeID
                })
                var agingtype = agingtypes[idx_agingtype]
                this.$store.commit("mou/update_agingtype", agingtype)
            },
            closeVerifyAlertMou() {
                if (this.countprice == 0) {
                    this.msgalertmou = "Buat harga dulu sebelum verifikasi !"
                    this.alertverify = true
                } else {
                    this.$store.dispatch("mou/verify", {
                        xid: this.xid,
                        companyid: this.$store.state.company.selected_company.id,
                        companyname: this.$store.state.company.selected_company.name,
                        name: this.name
                    })
                    this.dialogverifyalertmou = false
                }

            },
            releaseMou(val) {
                //this.xid = data.id
                //this.msgalertmou = "Apakah Anda yakin akan merilis agreement ini?"

                this.dialogreleasealertmou = true
                this.xid = val.id
                this.countprice = val.countprice
                this.name = val.name
                this.number = val.number
                this.refnumber = val.refnumber
                this.xstartdate = val.startdate
                this.xenddate = val.enddate
                this.isbill = val.isbill === 'N' ? false : true
                this.isdefault = val.isdefault === 'N' ? false : true
                this.isfavorit = val.isfavorit === 'N' ? false : true
                this.isjpanetto = val.isjpanetto === 'N' ? false : true
                this.ismcu = val.ismcu === 'N' ? false : true
                this.isaging = val.isaging === 'N' ? false : true
                this.isemail = val.isemail === 'N' ? false : true
                this.mindp = val.mindp
                this.agingnote = val.agingnote
                this.xnote = val.xnote
                this.mouemail = val.mouemail
                this.jpa1Name = val.M_MouJpa1Name
                this.jpa2Name = val.M_MouJpa2Name
                this.jpa3Name = val.M_MouJpa3Name
                this.jpa4Name = val.M_MouJpa4Name
                this.jpa1Percent = val.M_MouJpa1Percent
                this.jpa2Percent = val.M_MouJpa2Percent
                this.jpa3Percent = val.M_MouJpa3Percent
                this.jpa4Percent = val.M_MouJpa4Percent
                var bases = this.$store.state.mou.bases
                var idx_base = _.findIndex(bases, function (o) {
                    return o.baseid == val.baseid
                })
                var base = bases[idx_base]
                this.$store.commit("mou/update_base", base)

                var omzettypes = this.$store.state.mou.omzettypes
                var idx_omzettype = _.findIndex(omzettypes, function (o) {
                    return o.M_OmzetTypeID == val.M_OmzetTypeID
                })
                var omzettype = omzettypes[idx_omzettype]
                this.$store.commit("mou/update_omzettype", omzettype)

                var moutypes = this.$store.state.mou.moutypes
                var idx_moutype = _.findIndex(moutypes, function (o) {
                    return o.M_MouTypeID == val.M_MouTypeID
                })
                var moutype = moutypes[idx_moutype]
                this.$store.commit("mou/update_moutype", moutype)

                var agingtypes = this.$store.state.mou.agingtypes
                var idx_agingtype = _.findIndex(agingtypes, function (o) {
                    return o.M_AgingTypeID == val.M_AgingTypeID
                })
                var agingtype = agingtypes[idx_agingtype]
                this.$store.commit("mou/update_agingtype", agingtype)
            },
            closeReleaseAlertMou() {
                this.dialogprogress = true
                this.$store.dispatch("mou/release", {
                    xid: this.xid,
                    companyid: this.$store.state.company.selected_company.id,
                    companyname: this.$store.state.company.selected_company.name,
                    name: this.name
                })
                this.dialogreleasealertmou = false
            },
            unreleaseMou(val) {
                // this.xid = data.id

                //  this.msgalertmou = "Apakah Anda yakin akan membatalkan rilis agreement ini?"
                this.dialogunreleasealertmou = true
                this.xid = val.id
                this.countprice = val.countprice
                this.name = val.name
                this.number = val.number
                this.refnumber = val.refnumber
                this.xstartdate = val.startdate
                this.xenddate = val.enddate
                this.isbill = val.isbill === 'N' ? false : true
                this.isdefault = val.isdefault === 'N' ? false : true
                this.isfavorit = val.isfavorit === 'N' ? false : true
                this.isjpanetto = val.isjpanetto === 'N' ? false : true
                this.ismcu = val.ismcu === 'N' ? false : true
                this.isaging = val.isaging === 'N' ? false : true
                this.isemail = val.isemail === 'N' ? false : true
                this.mindp = val.mindp
                this.agingnote = val.agingnote
                this.xnote = val.xnote
                this.mouemail = val.mouemail
                this.jpa1Name = val.M_MouJpa1Name
                this.jpa2Name = val.M_MouJpa2Name
                this.jpa3Name = val.M_MouJpa3Name
                this.jpa4Name = val.M_MouJpa4Name
                this.jpa1Percent = val.M_MouJpa1Percent
                this.jpa2Percent = val.M_MouJpa2Percent
                this.jpa3Percent = val.M_MouJpa3Percent
                this.jpa4Percent = val.M_MouJpa4Percent
                var bases = this.$store.state.mou.bases
                var idx_base = _.findIndex(bases, function (o) {
                    return o.baseid == val.baseid
                })
                var base = bases[idx_base]
                this.$store.commit("mou/update_base", base)

                var omzettypes = this.$store.state.mou.omzettypes
                var idx_omzettype = _.findIndex(omzettypes, function (o) {
                    return o.M_OmzetTypeID == val.M_OmzetTypeID
                })
                var omzettype = omzettypes[idx_omzettype]
                this.$store.commit("mou/update_omzettype", omzettype)

                var moutypes = this.$store.state.mou.moutypes
                var idx_moutype = _.findIndex(moutypes, function (o) {
                    return o.M_MouTypeID == val.M_MouTypeID
                })
                var moutype = moutypes[idx_moutype]
                this.$store.commit("mou/update_moutype", moutype)

                var agingtypes = this.$store.state.mou.agingtypes
                var idx_agingtype = _.findIndex(agingtypes, function (o) {
                    return o.M_AgingTypeID == val.M_AgingTypeID
                })
                var agingtype = agingtypes[idx_agingtype]
                this.$store.commit("mou/update_agingtype", agingtype)
            },
            closeUnReleaseAlertMou() {
                this.$store.dispatch("mou/unrelease", {
                    xid: this.xid,
                    companyid: this.$store.state.company.selected_company.id,
                    companyname: this.$store.state.company.selected_company.name,
                    name: this.name
                })
                this.dialogunreleasealertmou = false
            },
            unverifyMou(val) {
                //  this.xid = data.id

                // this.msgalertmou = "Apakah Anda yakin akan membatalkan verifikasi agreement ini?"
                this.dialogunverifyalertmou = true
                this.xid = val.id
                this.countprice = val.countprice
                this.name = val.name
                this.number = val.number
                this.refnumber = val.refnumber
                this.xstartdate = val.startdate
                this.xenddate = val.enddate
                this.isbill = val.isbill === 'N' ? false : true
                this.isdefault = val.isdefault === 'N' ? false : true
                this.isfavorit = val.isfavorit === 'N' ? false : true
                this.isjpanetto = val.isjpanetto === 'N' ? false : true
                this.ismcu = val.ismcu === 'N' ? false : true
                this.isaging = val.isaging === 'N' ? false : true
                this.isemail = val.isemail === 'N' ? false : true
                this.mindp = val.mindp
                this.agingnote = val.agingnote
                this.xnote = val.xnote
                this.mouemail = val.mouemail
                this.jpa1Name = val.M_MouJpa1Name
                this.jpa2Name = val.M_MouJpa2Name
                this.jpa3Name = val.M_MouJpa3Name
                this.jpa4Name = val.M_MouJpa4Name
                this.jpa1Percent = val.M_MouJpa1Percent
                this.jpa2Percent = val.M_MouJpa2Percent
                this.jpa3Percent = val.M_MouJpa3Percent
                this.jpa4Percent = val.M_MouJpa4Percent
                var bases = this.$store.state.mou.bases
                var idx_base = _.findIndex(bases, function (o) {
                    return o.baseid == val.baseid
                })
                var base = bases[idx_base]
                this.$store.commit("mou/update_base", base)

                var omzettypes = this.$store.state.mou.omzettypes
                var idx_omzettype = _.findIndex(omzettypes, function (o) {
                    return o.M_OmzetTypeID == val.M_OmzetTypeID
                })
                var omzettype = omzettypes[idx_omzettype]
                this.$store.commit("mou/update_omzettype", omzettype)

                var moutypes = this.$store.state.mou.moutypes
                var idx_moutype = _.findIndex(moutypes, function (o) {
                    return o.M_MouTypeID == val.M_MouTypeID
                })
                var moutype = moutypes[idx_moutype]
                this.$store.commit("mou/update_moutype", moutype)

                var agingtypes = this.$store.state.mou.agingtypes
                var idx_agingtype = _.findIndex(agingtypes, function (o) {
                    return o.M_AgingTypeID == val.M_AgingTypeID
                })
                var agingtype = agingtypes[idx_agingtype]
                this.$store.commit("mou/update_agingtype", agingtype)
            },
            closeUnVerifyAlertMou() {
                this.$store.dispatch("mou/unverify", {
                    xid: this.xid,
                    companyid: this.$store.state.company.selected_company.id,
                    companyname: this.$store.state.company.selected_company.name,
                    name: this.name
                })
                this.dialogunverifyalertmou = false
            }
        }
    }
</script>