Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
499 views
in Technique[技术] by (71.8m points)

javascript - 是否有任何JavaScript函数或任何laravel查询来优化现金交易历史记录页面的放置时间?(Is there any javascript function or any laravel query to optimize cash transaction history page loding time?)

I want to optimize cash transactions history page loading time and optimize bankDetails function.

(我想优化现金交易历史记录页面的加载时间并优化bankDetails函数。)

Every time I load Cash Ledger or "accounts/bank-details/cash" page either my whole laravel serve is crush neither this page loading time minimum about 10m, it is too difficult to handle this page or reset every time laravel serve.

(每次我加载Cash Ledger或“帐户/银行明细/现金”页面时,我的整个laravel服务都不会被粉碎,该页面的加载时间至少不得少于10m,因此每次Laravel服务都很难处理此页面或重置。)

Is there any optimization function or method to optimize the loading time of Cash Ledger page?

(是否有优化功能或方法来优化“现金分类帐”页面的加载时间?)

My Route is:

(我的路线是:)

Route::get('/bank-details/{id}', 'BankController@bankDetails')->name('bank.show');

BankController.php bankDetails function

(BankController.php bankDetails函数)

public function bankDetails($id) {
        if(!Auth::user()->isAdmin() && !Auth::user()->isAccountant()) {
            return redirectBackWithNotification('error', 'You are not authorised!');
        }

        if($id == 'cash') {
            $projects = Project::select(['bsoft_projects.project_id', 'bsoft_projects.project_name'])->get();

            return view('admin.accounting.banks.show')
                ->with([
                    'projects'   => $projects
                ]);
        }

        $bank = BankAccount::findOrFail($id);

        if(!$bank->user) {
            $payments = Payment::where('payment_from_bank_account', '=', $bank->bank_id)
                ->orWhere('payment_to_bank_account', '=', $bank->bank_id)
                ->get();
            $balance = $bank->bank_balance;
        }
        else {
            $payments = Payment::where('payment_from_bank_account', '=', $bank->bank_id)
                ->orWhere('payment_to_bank_account', '=', $bank->bank_id)
                ->orWhere('payment_to_user', '=', $bank->user->id)
                ->orWhere('payment_from_user', '=', $bank->user->id)
                ->get();
            $balance = 0;
            $exp = 0;
            $inc = 0;
            foreach ($payments as $payment) {
                if($payment->payment_from_user == $bank->user->id) {
                    $exp += $payment->payment_amount;
                }
                elseif ($payment->payment_to_user == $bank->user->id) {
                    $inc += $payment->payment_amount;
                }
            }
            $balance = $inc - $exp;
        }

        return view('admin.accounting.banks.show')
            ->with([
                'bank'       => $bank,
                'payments'   => $payments,
                'balance'    => $balance
            ]);
    }

index.blade.php

(index.blade.php)

<div class="card-footer text-center">
                    <a href="{{ route('bank.show', ['id' => 'cash']) }}" class="btn btn-link text-white">Cash Transaction History</a>
                </div>

TransactionsDataTable.vue

(TransactionsDataTable.vue)


<template>
    <div class="rbt-data-table">
        <div class="card">
            <div class="card-header">
                <h4 class="text-center w-100">Cash Ledger</h4>
            </div>
            <div class="card-body">

                <div class="selection-form">
                    <form>
                        <div class="form-group">
                            <strong class="font-weight-bold">Select Type: &nbsp;&nbsp;</strong>
                            <div class="custom-control custom-radio custom-control-inline">
                                <input type="radio" id="customRadioInline1" class="custom-control-input" v-model="type" value="all">
                                <label class="custom-control-label" for="customRadioInline1">All</label>
                            </div>
                            <div class="custom-control custom-radio custom-control-inline">
                                <input type="radio" id="customRadioInline2" class="custom-control-input" v-model="type" value="loan">
                                <label class="custom-control-label" for="customRadioInline2">Loans</label>
                            </div>
                            <div class="custom-control custom-radio custom-control-inline">
                                <input type="radio" id="customRadioInline3" class="custom-control-input" v-model="type" value="project">
                                <label class="custom-control-label" for="customRadioInline3">By Project</label>
                            </div>
                        </div>
                    </form>
                </div>

                <div class="data-table-header" v-if="!isLoading">
                    <div class="row justify-content-between">
                        <div class="col-sm-4 d-none d-sm-block">
                            <div class="data-per-page">
                                <label>
                                    Show:
                                    <select v-model="perPage" class="custom-select">
                                        <option value="15">15</option>
                                        <option value="25">25</option>
                                        <option value="50">50</option>
                                        <option value="100">100</option>
                                    </select>
                                </label>
                            </div>
                        </div>

                        <div class="col-sm-8">
                            <div class="data-search float-right">
                                <!--<label class="sr-only" for="Search">Search</label>
                                <div class="input-group">
                                    <input v-model="search" @keyup="fetchData()" type="text" class="form-control" id="Search" placeholder="Search Here">
                                    <div class="input-group-append">
                                        <div class="input-group-text"><i class="feather icon-search text-dark"></i></div>
                                    </div>
                                </div>-->
                                <div class="data-search" v-if="type === 'project'">
                                    <label for="project_id">
                                        For Project:&nbsp;
                                        <select class="custom-select" id="project_id" style="width: auto !important;" v-model="projectId">
                                            <option value="">Select A Project</option>
                                            <option v-for="project in projects" :value="project.project_id">{{ project.project_name }}</option>
                                        </select>
                                    </label>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="table-responsive">
                    <table class="table table-bordered table-striped" id="FranchiseTable" style="width: 100%;">
                        <thead>
                        <tr>
                            <th scope="col">Date</th>
                            <th scope="col">Method</th>
                            <th scope="col">Type</th>
                            <th scope="col">Amounts</th>
                            <th scope="col">Purpose</th>
                            <th scope="col" v-if="type === 'all'">Project</th>
                            <th scope="col">From</th>
                            <th scope="col">To</th>
                            <th scope="col">Received By</th>
                        </tr>
                        </thead>

                        <tbody>
                        <tr v-for="data in paginatedData.data">

                            <th scope="row">{{ data.date }}</th>
                            <td>{{ data.method }}</td>
                            <td>{{ data.type }}</td>
<!--                            <td class="font-weight-bold">{{ data.amount }}</td>-->
                            <td style="text-transform: capitalize;">{{ data.purpose }}</td>
                            <td v-if="type === 'all'">
                                <a :href="'/project/show/' + data.project_id">{{ data.project_name }}</a>
                            </td>
                            <td>{{ data.from }}</td>
                            <td>{{ data.to }}</td>
                            <td>{{ data.by }}</td>
                        </tr>
                        </tbody>
                    </table>
                </div>

                <div class="data-table-footer">
                    <div class="row">
                        <div class="col-lg-6">
                            <div class="data-showing">
                                Showing <strong>{{ paginatedData.from }} - {{ paginatedData.to }}</strong>
                            </div>
                        </div>
                        <div class="col-lg-6">
                            <div class="data-pagination">
                                <ul class="pagination float-right">
                                    <li class="page-item pagination-page-nav" v-if="paginatedData.current_page > 1">
                                        <a href="#" class="page-link" @click.prevent="previousPage">
                                            <i class="fa fa-angle-double-left"></i>
                                        </a>
                                    </li>
                                    <li class="page-item pagination-page-nav" v-if="paginatedData.current_page > 1">
                                        <a href="#" class="page-link" @click.prevent="fetchData(1)">
                                            1
                                        </a>
                                    </li>
                                    <li class="page-item pagination-page-nav active" v-if="paginatedData.current_page">
                                        <a href="#" class="page-link">
                                            {{ paginatedData.current_page }}
                                        </a>
                                    </li>
                                    <li class="page-item pagination-page-nav" v-if="paginatedData.current_page !== paginatedData.last_page">
                     

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...