Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <template>
- <div>
- <b-card>
- <!-- Header-->
- <template v-slot:header>
- <h6 class="mt-2 mb-0">
- <b-icon icon="card-list" aria-hidden="true" scale="2" class="mx-2"></b-icon>
- <strong class="ml-1"> LIST DATA</strong>
- <br />
- <b-card-text class="mt-2">
- <small>
- <em>
- Seluruh data yang telah disimpan akan ditampilkan pada list ini.
- <br />Anda dapat melihat detail, mengedit atau pun menghapusnya sesuai dengan hak akses Anda.
- </em>
- </small>
- </b-card-text>
- </h6>
- </template>
- <!-- end Header -->
- <b-card-body class="px-0 py-0">
- <!-- reload and add button -->
- <b-row>
- <b-col md="12">
- <b-button class="btn-shadow mr-1" variant="outline-primary" size @click="reload()">
- <b-icon icon="arrow-repeat"></b-icon>Reload
- </b-button>
- <b-button class="btn-shadow" :variant="'outline-primary'" size @click="create()">
- <b-icon icon="plus"></b-icon>Tambah
- </b-button>
- </b-col>
- </b-row>
- <hr class="my-2" />
- <!-- end reload and add button -->
- <!-- filter section -->
- <b-row>
- <b-col md="6" class="mb-3">
- <b-form-group :label-cols="3" label="Filter By" class="mb-0 my-1">
- <b-input-group size="md">
- <b-form-select
- v-model="filterBy"
- :options="fieldOptions"
- @change="changeFilterBy()"
- >
- <option slot="first" :value="'all'">All Data</option>
- </b-form-select>
- </b-input-group>
- </b-form-group>
- <b-form-group
- :label-cols="3"
- label="Filter"
- class="mb-0"
- description="Type to Search or Click Clear to Stop Searching "
- >
- <b-input-group size="md">
- <b-form-input v-model="filter" placeholder="Type to Search" />
- <b-input-group-append>
- <b-btn :disabled="!filter" @click="filter = ''">Clear</b-btn>
- </b-input-group-append>
- </b-input-group>
- </b-form-group>
- </b-col>
- <b-col md="6" class="mt-1">
- <b-form-group :label-cols="3" label="Sort direction" class="mb-0">
- <b-input-group size="md">
- <b-form-select v-model="sortDirection" slot="append" disabled>
- <option value="asc">Asc</option>
- <option value="desc">Desc</option>
- <option value="last">Last</option>
- </b-form-select>
- </b-input-group>
- </b-form-group>
- <b-form-group :label-cols="3" label="Sort" class="mb-0 my-1">
- <b-input-group size="md">
- <b-form-select v-model="sortBy" :options="fieldOptions">
- <option slot="first" :value="null">-- none --</option>
- </b-form-select>
- <b-form-select :disabled="!sortBy" v-model="sortDesc" slot="append">
- <option :value="false">Asc</option>
- <option :value="true">Desc</option>
- </b-form-select>
- </b-input-group>
- </b-form-group>
- </b-col>
- </b-row>
- <!-- end filter section -->
- <!-- Data Table & Pagination -->
- <b-table
- responsive
- show-empty
- small
- id="masTable"
- ref="masTable"
- head-variant="light"
- :hover="true"
- :busy.sync="isBusy"
- :items="myGetData"
- :fields="fields"
- :current-page="currentPage"
- :per-page="perPage"
- :filter="filter"
- :sort-by.sync="sortBy"
- :sort-desc.sync="sortDesc"
- :sort-direction="sortDirection"
- >
- <template v-slot:table-busy>
- <div class="text-center text-danger my-2">
- <b-spinner class="align-middle"></b-spinner>
- <strong>Loading...</strong>
- </div>
- </template>
- <!-- gunakan cara ini jika ada data yang mau di gabungkan -->
- <template v-slot:cell(kantor)="data">
- {{ data.item.bank.kode }}<br/>
- {{ data.item.bank_kantor_status.kode }} {{ data.item.nama }}
- </template>
- <template v-slot:cell(kontak)="data">
- Handphone: {{ data.item.nomp }}<br/>
- Telepon: {{ data.item.notelepon }}<br/>
- No Fax: {{ data.item.nofax }}<br/>
- E-mail: {{ data.item.email }}
- </template>
- <template v-slot:cell(alamat)="data">
- {{ data.item.alamat }},
- {{ data.item.kelurahan ? data.item.kelurahan + ', ' : '' }}
- {{ data.item.kecamatan ? data.item.kecamatan + ', ' : ''}}
- {{ data.item.kabkota ? data.item.kabkota + ', ' : '' }}
- {{ data.item.provinsi ? data.item.provinsi : '' }}
- </template>
- <!-- button actions -->
- <template v-slot:cell(actions)="row">
- <!-- view data -->
- <b-button
- @click="show(row.item, row.index, $event.target)"
- class="btn-sm btn-icon btn-icon-only mr-1"
- variant="outline-dark"
- title="View Detail"
- >
- <b-icon icon="eye"></b-icon>
- </b-button>
- <!-- edit data -->
- <b-button
- @click="edit(row.item, row.index, $event.target)"
- class="btn-sm btn-icon btn-icon-only mr-1"
- variant="outline-primary"
- title="Edit Detail"
- >
- <b-icon icon="pencil"></b-icon>
- </b-button>
- <!-- delete data -->
- <b-button
- @click="destroy(row.item, row.index, $event.target)"
- class="btn-sm btn-icon btn-icon-only"
- variant="outline-danger"
- title="Delete Data"
- >
- <b-icon icon="trash"></b-icon>
- </b-button>
- </template>
- <!-- end button actions -->
- </b-table>
- <div class="divider"></div>
- <!-- pagination section -->
- <b-row>
- <div class="divider"></div>
- <b-col md="6" class="my-0">
- <b-form-group :label-cols="2" label="Per page" class="mb-0">
- <b-form inline>
- <b-form-select :options="pageOptions" style="width: 100px;" v-model="perPage" />
- <label class="ml-1 mr-1">/</label>
- <b-form-input
- :disabled="true"
- v-model="totalRows"
- style="width: 100px;"
- class="text-right"
- />
- <label class="ml-1">Rows</label>
- </b-form>
- </b-form-group>
- </b-col>
- <b-col md="6" class="my-0">
- <b-pagination
- v-model="currentPage"
- :total-rows="totalRows"
- :per-page="perPage"
- align="fill"
- size="md"
- class="my-0"
- ></b-pagination>
- </b-col>
- </b-row>
- <!-- end pagination section -->
- <!-- end Data Table & Pagination -->
- </b-card-body>
- <!-- Footer -->
- <!-- <template v-slot:footer>
- <em>Footer Slot</em>
- </template> -->
- <!-- end Footer -->
- </b-card>
- <!--MODAL ADD -->
- <b-modal
- v-model="showModalForm"
- :id="infoModal.id"
- ref="modal"
- :title="editMode ? 'Edit ' + AllTitle: 'Tambah ' + AllTitle"
- size="lg"
- variant="primary"
- no-close-on-backdrop
- static
- hide-footer
- hide-header
- >
- <form @submit.prevent="editMode ? update() : store()" @keydown="form.onKeydown($event)">
- <b-card class="mb-0">
- <template v-slot:header>
- <h6 class="mt-2 mb-0">
- <b-icon icon="input-cursor-text" aria-hidden="true" scale="2" class="mx-2"></b-icon>
- <strong>FORM {{ AllTitle }}</strong>
- <br />
- <b-card-text class="mt-2">
- <small>
- <em>
- Silahkan mengisi seluruh kolom yamg tersedia.
- <br />Kolom bertanda bintang merah wajib diisi.
- </em>
- </small>
- </b-card-text>
- </h6>
- </template>
- <alert-error :form="form" class="border-danger mb-2"></alert-error>
- <div class="form-group row mb-2">
- <label class="col-sm-3 col-form-label" for="kode">
- Kode Bank <font style="color: red;">*</font>
- </label>
- <div class="col-sm-9">
- <input
- type="text"
- class="form-control"
- v-model="form.kode"
- id="kode"
- name="kode"
- autofocus
- />
- <small v-if="form.errors.has('kode')" class="form-text text-danger">{{errors.kode[0]}}</small>
- </div>
- </div>
- <div class="orm-group row mb-2">
- <label class="col-sm-3 col-form-label" for="nama">
- Nama Bank
- <font style="color: red;">*</font>
- </label>
- <div class="col-sm-9">
- <input
- type="text"
- class="form-control"
- v-model="form.nama"
- id="nama"
- name="nama"
- />
- <small
- v-if="form.errors.has('nama')"
- class="form-text text-danger"
- >{{errors.nama[0]}}</small>
- </div>
- </div>
- <template v-slot:footer>
- <b-row>
- <b-col md="6" class="mb-3">
- <small class="text-muted"></small>
- </b-col>
- <b-col md="6" class="float-right text-right">
- <b-button
- :disabled="form.busy"
- id="btnSave"
- type="submit"
- class="mr-1 btn-shadow"
- :variant="'primary'"
- >
- <!-- <CIcon name="cil-save"/> -->
- <b-icon icon="check" scale="2"></b-icon>
- {{ btnSave.Saving ? 'Sending...':btnSave.Title }}
- </b-button>
- <b-button class="btn-shadow" :variant="'light'" @click="showModalForm=false">
- <b-icon icon="x" scale="2"></b-icon>Close
- </b-button>
- </b-col>
- </b-row>
- </template>
- </b-card>
- </form>
- </b-modal>
- <!-- end MODAL ADD -->
- </div>
- </template>
- <script>
- /* eslint-disable */
- // eslint-disable-next-line
- // eslint-disable vue/no-unused-vars
- // eslint-disable-line no-unused-vars
- // Import Components
- // ==================================================
- import axios from "axios";
- export default {
- // Call Components
- // ==================================================
- components: {},
- data: () => ({
- // url : "api/bank/kantor-status/",
- // PageTitle
- // ==================================================
- headingBold: "Data: ",
- heading: "Bank Kantor List",
- subheading: "Halaman Kantor Bank",
- icon: "fa-list-ol",
- breadcrumb: [
- {
- title: "",
- link: "/ourzone",
- icon: "fa-home",
- active: false,
- },
- {
- title: "Perusahaan",
- link: "",
- icon: "",
- active: false,
- },
- {
- title: "Status Kantor",
- link: "/ourzone/perusahaan/kantorstatus",
- icon: "",
- active: true,
- },
- ],
- // Data Master /page
- AllTitle: "DATA KANTOR BANK",
- // end Data Master /page
- // Data & Format Table
- fields: [
- {
- key: "kantor",
- label: "Kantor",
- sortable: true,
- // sortDirection: 'asc'
- },
- {
- key: "alamat",
- label: "Alamat",
- sortable: true,
- // sortDirection: 'asc'
- },
- {
- key: "kontak",
- label: "Kontak",
- sortable: true,
- // sortDirection: 'asc'
- },
- {
- key: "actions",
- label: "Actions",
- class: "text-right",
- sortable: false,
- },
- ],
- // end Data & Format Table
- card: {
- show: true,
- isCollapsed: true,
- },
- // Tools
- isBusy: false,
- sortBy: null,
- sortDesc: true,
- sortDirection: "asc",
- filter: null,
- filterBy: "all",
- // ---
- pageOptions: [5, 10, 15, 25],
- perPage: 10,
- currentPage: 1,
- totalRows: 0,
- // end Tools
- // Form Modal Add/Edit/View
- showModalForm: false,
- showModalView: false,
- editMode: false,
- infoModal: {
- id: "modalForm",
- title: "",
- content: "",
- },
- // ini form untuk update atau store data
- form: new Form({
- id: "",
- bank_id: "",
- bankkantorstatus_id: "",
- nama: "",
- nomp: "",
- notelepon: "",
- nofax: "",
- email: "",
- alamat: "",
- kelurahan: "",
- kecamatan: "",
- kabkota: "",
- provinsi: "",
- kodepos: ""
- }),
- errors: [],
- // With FormData
- // form: {
- // id: "",
- // username: "",
- // name: "",
- // email: "",
- // nomp: "",
- // fotoname: null,
- // locked: "0",
- // haspermission: [], // Use Check Button / 1 User Has Many Role
- // },
- // formData: {},
- // errors: {
- // msg: "",
- // fields: [],
- // },
- // end With FormData
- btnSave: {
- Saving: false,
- Title: "Save changes",
- },
- // ---
- name: "",
- nameState: null,
- submittedNames: [],
- // end Form Modal Add/Edit/View
- }),
- mounted() {
- // const url = "api/bank/kantor-status"
- },
- computed: {
- fieldOptions() {
- // Create an options list from our fields
- return this.fields
- .filter((f) => f.sortable)
- .map((f) => {
- return {
- text: f.label,
- value: f.key,
- };
- });
- },
- },
- methods: {
- myGetData(ctx) {
- // ctx =
- // berasal dari tag <b-table></b-table>
- this.$Progress.start();
- this.isBusy = true;
- let promise = axios.get("api/bank/kantor", {
- params: {
- page: ctx.currentPage,
- perpage: ctx.perPage,
- sortby: ctx.sortBy,
- sortdesc: ctx.sortDesc,
- filter: ctx.filter,
- filterby: this.filterBy,
- },
- });
- return promise
- .then((response) => {
- const items = response.data.data;
- // Data Pagination
- // configPagination(response.data.meta);
- this.totalRows = response.data.meta.total;
- // Here we could override the busy state, setting isBusy to false
- this.$Progress.finish();
- this.isBusy = false;
- return items;
- })
- .catch((error) => {
- // console.error(error);
- // Here we could override the busy state, setting isBusy to false
- this.$Progress.fail();
- this.isBusy = false;
- // Returning an empty array, allows table to correctly handle
- // internal busy state in case of error
- return [];
- });
- },
- reload() {
- // with id="masTable" in tag b-table
- // this.$root.$emit('bv::refresh::table', 'masTable')
- // with property ref="masTable" in tag b-table
- this.$refs.masTable.refresh();
- },
- changeFilterBy() {
- if (this.filter) {
- this.$refs.masTable.refresh();
- }
- },
- // ---
- resetForm() {
- this.btnSave.Saving = false;
- this.editMode = false;
- this.form.reset();
- this.form.clear();
- this.errors = [];
- },
- create() {
- this.resetForm();
- this.$root.$emit("bv::show::modal", this.infoModal.id);
- this.showModalForm == true;
- },
- // simpan data
- store() {
- this.btnSave.Saving = true;
- this.$Progress.start();
- this.form.busy = true;
- this.form
- .post("/api/bank/kantor")
- .then(
- (response) => {
- if (this.form.successful) {
- this.$Progress.finish();
- this.$snotify.success(
- this.AllTitle + " Successfully Saved",
- "Success"
- );
- this.reload();
- this.resetForm();
- } else {
- this.$Progress.fail();
- this.$snotify.error(
- "Something went wrong try again later.",
- "Error"
- );
- this.btnSave.Saving = false;
- }
- }
- // error => {
- // this.$Progress.fail();
- // this.btnLogin.Saving = false;
- // if (error.response.status == 403) {
- // this.form.reset();
- // this.form.clear();
- // this.$swal({
- // title: "Warning",
- // text: error.response.data.message,
- // icon: "warning"
- // }).then((result) => {
- // // this.routelink("SimaksiLacak", "_self")
- // })
- // }else if(error.response.status == 422) {
- // this.errors = error.response.data.errors;
- // }else{
- // console.error(error);
- // this.$snotify.error(
- // "Something went wrong try again later.",
- // "Error"
- // );
- // }
- // }
- )
- .catch((e) => {
- this.$Progress.fail();
- this.errors = e.response.data.errors;
- this.btnSave.Saving = false;
- });
- },
- show(item, index, button) {
- // this.infoModal.title = `Row index: ${index}`
- //this.infoModal.content = JSON.stringify(item, null, 2)
- this.form.fill(item);
- this.$root.$emit("bv::show::modal", "ModalView", button);
- },
- edit(item, index, button) {
- this.resetForm();
- this.editMode = true;
- this.form.fill(item);
- this.$root.$emit("bv::show::modal", this.infoModal.id, button);
- },
- // edit/update data
- update() {
- this.btnSave.Status = true;
- this.$Progress.start();
- this.form.busy = true;
- this.form
- .put("/api/bank/kantor/" + this.form.id)
- .then(
- (response) => {
- if (this.form.successful) {
- this.$Progress.finish();
- this.$snotify.success(
- this.AllTitle + " Successfully Updated",
- "Success"
- );
- this.reload();
- this.resetForm();
- this.$root.$emit("bv::hide::modal", this.infoModal.id);
- } else {
- this.$Progress.fail();
- this.$snotify.error(
- "Something went wrong try again later.",
- "Error"
- );
- this.btnSave.Status = false;
- }
- }
- // error => {
- // this.$Progress.fail();
- // this.btnLogin.Saving = false;
- // if (error.response.status == 403) {
- // this.form.reset();
- // this.form.clear();
- // this.$swal({
- // title: "Warning",
- // text: error.response.data.message,
- // icon: "warning"
- // }).then((result) => {
- // // this.routelink("SimaksiLacak", "_self")
- // })
- // }else if(error.response.status == 422) {
- // this.errors = error.response.data.errors;
- // }else{
- // console.error(error);
- // this.$snotify.error(
- // "Something went wrong try again later.",
- // "Error"
- // );
- // }
- // }
- )
- .catch((e) => {
- this.$Progress.fail();
- this.errors = e.response.data.errors;
- // console.log(e);
- this.btnSave.Status = false;
- });
- },
- // delete data
- destroy(item, index, button) {
- this.$snotify.clear();
- this.$snotify.confirm(
- "You will not be able to recover this data!",
- "Are you sure?",
- {
- showProgressBar: false,
- closeOnClick: false,
- pauseOnHover: true,
- buttons: [
- {
- text: "Yes",
- action: (toast) => {
- this.$snotify.remove(toast.id);
- this.$Progress.start();
- axios
- .delete("/api/bank/kantor/" + item.id)
- .then((response) => {
- this.$refs.masTable.refresh();
- this.$Progress.finish();
- this.$snotify.success(
- this.AllTitle + " Successfully Deleted",
- "Success"
- );
- })
- .catch((e) => {
- this.$Progress.fail();
- // console.log(e);
- });
- },
- bold: true,
- },
- {
- text: "No",
- action: (toast) => {
- this.$snotify.remove(toast.id);
- },
- bold: true,
- },
- ],
- }
- );
- },
- },
- };
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement