<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
</head>
<body>
    <!--Content S-->
    <div class="col-md-12 col-sm-12 col-xs-12">
        <h3>訂單編號: {{orderObj.orderNum}}</h3>
    </div>
    <div class="x_panel">
        <div class="x_content top_search">
            <select name="ddlproductType" class="form-control btn btn-default ddl-5" v-model="query.productType" @change="getList(1);">
                <option value="-1">= 類型 =</option>
                <option v-for="item in ltProductType" :value="item.value">{{item.name}}</option>
            </select>

            <select name="ddlparentId" class="form-control btn btn-default ddl-5" v-model="query.parentId" @change="query.categoryId=-1;getList(1);">
                <option value="-1">= 大分類 =</option>
                <option v-for="item in ltCategory" :value="item.id" v-if="item.parentId == null || item.parentId == -1">{{item.name}}</option>
            </select>
            <select name="ddlcategoryId" class="form-control btn btn-default ddl-5" v-model="query.categoryId" @change="getList(1);">
                <option value="-1">= 中分類 =</option>
                <option v-for="item in ltCategory" :value="item.id" v-if="query.parentId > 0 && item.parentId == query.parentId">{{item.name}}</option>
            </select>

            <input type="text" name="keyword" class="form-control keyword" v-model="query.keyword" placeholder="型號、品名(輸入關鍵字查詢)"
                    @change="query.keyword=$event.target.value" @keypress="keychange($event);" />

            <div class="group-btn">
                <button class="btn btn-success" @click="getList(1);">搜尋</button>&nbsp;
                <button class="btn btn-primary" @click="clearCriteria();">清除條件</button>
            </div>
        </div>
    </div>

    <table border="0" cellpadding="5" cellspacing="1" class="table table-striped jambo_table">
        <thead>
            <tr>
                <td>類型</td>
                <td>型號</td>
                <td></td>
                <td></td>
                <td>品名</td>
                <td class="text-right">售價</td>
                <td class="text-right">月租費</td>
                <td class="text-right">週租費</td>
                <td class="text-right">耗材</td>
                <td class="text-right">押金</td>
                <td class="text-center">可租用</td>
            </tr>
        </thead>
        <tbody>
            <tr v-for="(item, index) in list">
                <td>{{item.productTypeString}}</td>
                <td>{{item.productCode}}</td>
                <td class="text-center"><img :src="item.coverImage" v-if="item.coverImage != null && item.coverImage != ''" /></td>
                <td class="text-center">
                    <span v-if="item.monthlyCharge + item.weeklyCharge + item.salePrice == 0" class="btn btn-sm">--</span>
                    <a v-else-if="item.availableQty > 0" @click="selectProduct(item)" class="btn btn-success btn-sm">加入</a>
                    <span v-else class="btn btn-sm">無庫存</span>
                </td>
                <td class="small">{{item.name}}</td>
                <td class="text-right">
                    <span v-if="item.salePrice >= 0">{{item.salePrice}}</span>
                    <span v-else>--</span>
                </td>
                <td class="text-right">
                    <span v-if="item.monthlyCharge >= 0">{{item.monthlyCharge}}</span>
                    <span v-else>--</span>
                </td>
                <td class="text-right">
                    <span v-if="item.weeklyCharge >= 0">{{item.weeklyCharge}}</span>
                    <span v-else>--</span>
                </td>
                <td class="text-right">{{item.consumableFee.toLocaleString()}}</td>
                <td class="text-right">{{item.deposit.toLocaleString()}}</td>
                <td class="text-center">{{item.availableQty}}</td>
            </tr>
        </tbody>
    </table>
    <div v-if="pager != null" class="dataTables_wrapper form-inline dt-bootstrap no-footer">
        <div class="row">
            <div class="col-sm-4">
                <div class="dataTables_info">總筆數 {{pager.totalRecord}} 筆, 第 {{pager.startItemIndex}} ~ {{pager.endItemIndex}} 筆</div>
            </div>
            <div class="col-sm-8">
                <div class="dataTables_paginate paging_simple_numbers">
                    <ul class="pagination">
                        <li class="paginate_button previous" v-if="pager.currentPage > 1"><a @click="goPage(1);"><i class="fas fa-angle-double-left"></i></a></li>
                        <li class="paginate_button previous" v-if="pager.currentPage > 1"><a @click="goPage(pager.currentPage - 1 );"><i class="fas fa-angle-left"></i></a></li>

                        <li class="paginate_button" :class="{ active: n == pager.currentPage }" v-for="n in pager.endPage" v-if="n >= pager.startPage">
                            <a @click="goPage(n);">{{n}}</a>
                        </li>

                        <li class="paginate_button next" v-if="pager.totalPage > pager.currentPage"><a @click="goPage(pager.currentPage + 1 );"><i class="fas fa-angle-right"></i></a></li>
                        <li class="paginate_button next" v-if="pager.totalPage > pager.currentPage"><a @click="goPage(pager.totalPage);"><i class="fas fa-angle-double-right"></i></a></li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
    <!--Content E-->
    <!--FinalScript S-->
    <script src="_productlist.js" type="module"></script>
    <!--FinalScript E-->
</body>
</html>