<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
</head>
<body>
    <!--Content S-->
    <div class="col-md-8 col-sm-8 col-xs-12">
        <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>
    </div>
    <div class="col-md-4 col-sm-4 col-xs-12">
        <ul class="info">
            <li>
                <span class="title">通路</span>
                <span>{{market.name}}</span>
            </li>
        </ul>
    </div>

    <table border="0" cellpadding="5" cellspacing="1" class="table table-striped jambo_table">
        <thead>
            <tr>
                <td><label><input type="checkbox" :checked="checkAll" @click="SelectAll($event.target.checked)" />全選</label></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-right">週租對帳</td>
                <td class="text-right">耗材</td>
                <td class="text-right">押金</td>
            </tr>
        </thead>
        <tbody>
            <tr v-for="(item, index) in list">
                <td>
                    <input type="checkbox" :checked="isExistsCheckList(item.id)" @click="changeCKD(item, $event.target.checked)" :tabindex="(index + 1)" />
                </td>
                <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="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.salePriceCost >= 0">{{item.salePriceCost}}</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.monthlyCost >= 0" class="blue">{{item.monthlyCost}}</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">
                    <span v-if="item.weeklyCost >= 0" class="blue">{{item.weeklyCost}}</span>
                    <span v-else>--</span>
                </td>
                <td class="text-right">{{item.consumableFee.toLocaleString()}}</td>
                <td class="text-right">{{item.deposit.toLocaleString()}}</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>
    <div class="footer-action">
        <h4>操作：</h4>
        <a class="btn btn-success btn-lg" @click="addProduct()">加入輔具</a>
        <a class="btn btn-info btn-lg" @click="closeAndReloadParent()">關閉</a>
    </div>
    <!--Content E-->
    <!--FinalScript S-->
    <script src="_productlist.js" type="module"></script>
    <!--FinalScript E-->
</body>
</html>