Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <template>
- <div class="dashboard-contents">
- <div class="row">
- <div class="col-lg-6" style="margin-top: 20px;">
- <h2 style="padding:15px; margin-top: 10px;">Daftar Bundle</h2>
- </div>
- <div class="col-lg-6" style="padding-top: 15px; margin-top: 20px;">
- <div class="row">
- <div class="col-lg-6"></div>
- <div class="col-lg-3">
- <download-excel class="btn waves-effect waves-circle waves-float pull-right button-export"
- worksheet = "Daftar bundle"
- name = "data_bundle.xls"
- :data = "exportData">
- <img src="@/assets/images/file-text.png" alt="Alternate Text" /> Export
- </download-excel>
- </div>
- <div class="col-lg-3">
- <router-link :to="{name: 'BundleManagement.create'}" type="button" class="btn waves-effect waves-circle waves-float pull-right button-create">
- <img src="@/assets/images/plus-circle.png" alt="Alternate Text" /> Tambah
- </router-link>
- </div>
- </div>
- </div>
- </div>
- <div class="row">
- <div class="col-lg-12 second-row">
- <div class="row">
- <div class="col-lg-10"></div>
- <div class="col-lg-2 search-div">
- <input type="text" name="permission" placeholder="Cari bundle..." ng-model="query" value="" style="width: 100%; height: 34px; float: right; margin-bottom: 10px; border: 1px solid rgba(184, 55, 62, 0.5); background-color: white; border-radius: 5px; padding: 5px; margin-bottom: 24px;" />
- </div>
- </div>
- </div>
- </div>
- <div class="row">
- <div class="col-lg-12">
- <div class="table-div">
- <!-- <table class="table table-hover table-striped">
- <thead style="text-align:center;">
- <tr>
- <th style="text-align:center; border-right: 1px solid rgba(240, 237, 237, 1); border-left: 1px solid rgba(240, 237, 237, 1);">
- <div style="margin-bottom: 10px;">
- Actions <img src="@/assets/images/Down arrow small.png" alt="Alternate Text" />
- </div>
- <div>
- <input readonly type="text" name="made_by" value="" style="margin-bottom: 10px; border: none; background-color: white; border-radius: 5px; padding: 5px; cursor: default;" />
- </div>
- </th>
- <th style="text-align:center; border-right: 1px solid rgba(240, 237, 237, 1)">
- <div style="margin-bottom: 10px;">
- Kode Bundle <img src="@/assets/images/Down arrow small.png" alt="Alternate Text" />
- </div>
- <div>
- <input type="text" ng-model="query.code" value="" style="margin-bottom: 10px; border: 1px solid rgba(184, 55, 62, 0.5); background-color: #F0eded; border-radius: 5px; padding: 5px;" />
- </div>
- </th>
- <th style="text-align:center; border-right: 1px solid rgba(240, 237, 237, 1)">
- <div style="margin-bottom: 10px;">
- Nama Bundle <img src="@/assets/images/Down arrow small.png" alt="Alternate Text" />
- </div>
- <div>
- <input type="text" ng-model="query.name" value="" style="margin-bottom: 10px; border: 1px solid rgba(184, 55, 62, 0.5); background-color: #F0eded; border-radius: 5px; padding: 5px;" />
- </div>
- </th>
- <th style="text-align:center; border-right: 1px solid rgba(240, 237, 237, 1)">
- <div style="margin-bottom: 10px;">
- Jumlah Bundle <img src="@/assets/images/Down arrow small.png" alt="Alternate Text" />
- </div>
- <div>
- <input type="text" ng-model="query.bundleQuantity" value="" style="margin-bottom: 10px; border: 1px solid rgba(184, 55, 62, 0.5); background-color: #F0eded; border-radius: 5px; padding: 5px;" />
- </div>
- </th>
- <th style="text-align:center; border-right: 1px solid rgba(240, 237, 237, 1)">
- <div style="margin-bottom: 10px;">
- Harga Bundle <img src="@/assets/images/Down arrow small.png" alt="Alternate Text" />
- </div>
- <div>
- <input type="text" ng-model="query.price" value="" style="margin-bottom: 10px; border: 1px solid rgba(184, 55, 62, 0.5); background-color: #F0eded; border-radius: 5px; padding: 5px;" />
- </div>
- </th>
- </tr>
- </thead>
- <tbody>
- <tr v-for="item in bundle" :key="item.id">
- <td style="padding-top: 18px; text-align:center;">
- <div class="btn-group">
- <b-dropdown text="Action" variant="primary" style="width: 120px;">
- <b-dropdown-item><router-link :to="{ name: 'BundleManagement.edit', params:{ id: item.Id } }">Edit</router-link></b-dropdown-item>
- <b-dropdown-item @click="del(item.Id)">Delete</b-dropdown-item>
- </b-dropdown>
- </div>
- </td>
- <td style="border-right: 1px solid rgba(240, 237, 237, 1); padding-top: 18px;">
- <router-link :to="{ name: 'BundleManagement.detail', params:{ id: item.Id } }" style="cursor: pointer;" ng-click="vm.detail(bundle)">{{ item.Code }}</router-link>
- </td>
- <td style="border-right: 1px solid rgba(240, 237, 237, 1); padding-top: 18px;">{{ item.Name }}</td>
- <td style="border-right: 1px solid rgba(240, 237, 237, 1); padding-top: 18px;">{{ item.BundleQuantity }}</td>
- <td style="border-right: 1px solid rgba(240, 237, 237, 1); padding-top: 18px;">{{ item.Price | currency }}</td>
- </tr>
- </tbody>
- </table> -->
- <b-table striped hover
- id="bundleTable"
- :items="bundle"
- :fields="bundleField"
- :total-rows="rows"
- :per-page="perPage"
- :current-page="currentPage"
- class="table table-hover table-striped"
- style="margin-top: 10px;">
- <template v-slot:cell(Actions)="data">
- <b-dropdown text="Action" variant="primary" style="width: 120px;">
- <b-dropdown-item @click="edit(data.item.Id)">Edit</b-dropdown-item>
- <b-dropdown-item @click="del(data.item.Id)">Delete</b-dropdown-item>
- </b-dropdown>
- </template>
- <template v-slot:cell(Code)="data">
- <a @click="detail(data.item.Id)">{{ data.item.Code }}</a>
- </template>
- <template v-slot:cell(Price)="data">
- {{ data.item.Price | currency }}
- </template>
- </b-table>
- </div>
- <b-pagination
- v-model="currentPage"
- :total-rows="rows"
- :per-page="perPage"
- aria-controls="bundleTable">
- </b-pagination>
- </div>
- </div>
- </div>
- </template>
- <script>
- import moment from 'moment'
- import $ from 'jquery'
- import DownloadExcel from 'vue-json-excel'
- import Bundles from '@/services/Inventories/Bundle'
- import LegalEntities from '@/services/Companies/LegalEntities'
- import Branches from '@/services/Companies/Branches'
- export default {
- name: 'BundleManagement.index',
- components: {
- DownloadExcel
- },
- computed: {
- rows () {
- //hitung panjang data Transaksi Internal
- return this.bundle.length
- }
- },
- data () {
- return {
- //definisikan per page dan halaman current isi 1 untuk awal
- perPage: 10,
- currentPage: 1,
- //selesai
- bundleField: [
- { key: 'Actions', label: 'Actions' },
- { key: 'Code', label: 'Nomor Bundle' },
- { key: 'Name', label: 'Nama Bundle' },
- { key: 'BundleQuantity', label: 'Jumlah Bundle' },
- { key: 'Price', label: 'Harga Bundle' },
- ],
- exportData: [],
- userData: {},
- bundle: [],
- roles: [],
- legalEntity: [],
- branch: []
- }
- },
- created: function () {
- this.init()
- },
- mounted: function () {
- window.$ = $
- if(localStorage.userData !== undefined) {
- this.userData = JSON.parse(localStorage.userData)
- } else {
- this.$router.push({ name: 'home' })
- location.reload()
- }
- },
- methods: {
- init: async function () {
- let result = await Bundles.index()
- let legalEntity = await LegalEntities.index()
- let branch = await Branches.index()
- this.bundle = result.data
- this.legalEntity = this.itemLookup(legalEntity.data)
- this.branch = this.itemLookup(branch.data)
- },
- itemLookup: function (json) {
- let data = []
- for(var i = 0; i< json.length; i++) {
- data[json[i].Id] = json[i]
- }
- return data
- },
- formatDate(time) {
- var formattedTime = moment(time).format('DD MMMM YYYY HH:mm')
- if(formattedTime == 'Invalid date') {
- formattedTime = '-'
- }
- return formattedTime
- },
- detail: function (id) {
- this.$router.push({ name: 'BundleManagement.detail', params: { id: id } })
- },
- edit: function (id) {
- this.$router.push({ name: 'BundleManagement.edit', params: { id: id } })
- },
- del: async function (id) {
- this.$fire({
- text: "Apakah anda yakin ingin menghapus bundle ini?",
- type: "warning",
- showCancelButton: true,
- confirmButtonText: 'Ya',
- cancelButtonText: 'Tidak',
- }).then(() => {
- if(result.status == 200) {
- // alert(result.data.message)
- this.$router.push({ name: 'BundleManagement.index' })
- location.reload()
- } else {
- alert("Delete Gagal")
- location.reload()
- }
- })
- let result = await Bundles.delete(id)
- }
- }
- }
- </script>
- <style>
- .table-div {
- padding-left: 30px;
- margin-left: 0px !important;
- overflow-x: auto;
- overflow-y: auto;
- }
- .second-row {
- margin-top: 30px;
- padding-left: 30px;
- }
- .select-dropdown {
- width: 100%;
- height: 45px;
- border-color: #0059aa;
- border-radius: 5px;
- }
- .button-export {
- width: 100%;
- height: 45px;
- background-color: #0059aa;
- color:white;
- border-radius: 5px;
- }
- .button-create {
- width: 100%;
- height: 45px;
- background-color: #20c197;
- color:white;
- border-radius: 5px;
- }
- </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement