<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
    <!--Header S-->
    <style>
        td input[type=number] { width: 100%; display: block; }
    </style>
    <!--Header E-->
</head>
<body>
    <!--Content S-->
    <div class="" role="tabpanel" data-example-id="togglable-tabs">
        <ul id="myTab" class="nav nav-tabs bar_tabs" role="tablist">
            <li><a :href="'edit?id=' + store.id">基本資料</a></li>
            <li><a :href="'userlist?sid=' + store.id">門市帳號</a></li>
            <li class="active"><a :href="'pricelist?sid=' + store.id">價格</a></li>
            <li><a :href="'freightlist?sid=' + store.id">運費</a></li>
            <li><a :href="'orderlist?sid=' + store.id">租賃記錄</a></li>
            <li><a :href="'stocklist?sid=' + store.id">輔具動態</a></li>
            <li><a href="list">回列表</a></li>
        </ul>
    </div>
    <div class="col-md-12 col-sm-12 col-xs-12"></div>
    <div class="col-md-4 col-sm-4 col-xs-12">
        <ul class="info">
            <li>
                <span class="title">通路</span>
                <span>{{store.marketName}}</span>
            </li>
            <li>
                <span class="title">門市</span>
                <span>{{store.name}}</span>
                <a :href="'@printqrcode?id=' + store.id" class="iframe alignright"><i class="fas fa-qrcode fa-lg"></i></a>
            </li>
            <li>
                <span class="title">佳醫代收</span>
                <label class="label label-info" v-if="store.isCodConsumableFee == 1">耗材費</label>
                <label class="label label-default" v-if="store.isCodFreight == 1">運費</label>
                <span v-if="store.isCodConsumableFee == 0 && store.isCodFreight == 0">--</span>
            </li>
        </ul>
    </div>
    <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>
                <a :href="'_productlist?sid=' + store.id" class="btn btn-success alignright iframe">新增</a>
            </div>
        </div>

    </div>
    <div class="col-md-12 col-sm-12 col-xs-12"></div>
    <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>
    <table border="0" cellpadding="5" cellspacing="1" class="table table-striped jambo_table">
        <thead>
            <tr>
                <td>類型</td>
                <td>型號</td>
                <td class="text-center">封面圖</td>
                <td class="text-center">售價</td>
                <td class="text-center">售價對帳</td>
                <td class="text-center">月租費</td>
                <td class="text-center">月租對帳</td>
                <td class="text-center">週租費</td>
                <td class="text-center">週租對帳</td>
                <td></td>
                <td></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><input type="number" class="form-control" v-model="item.salePrice" min="-1" /></td>
                <td><input type="number" class="form-control" v-model="item.salePriceCost" min="-1" /></td>
                <td><input type="number" class="form-control" v-model="item.monthlyCharge" min="-1" /></td>
                <td><input type="number" class="form-control" v-model="item.monthlyCost" min="-1" /></td>
                <td><input type="number" class="form-control" v-model="item.weeklyCharge" min="-1" /></td>
                <td><input type="number" class="form-control" v-model="item.weeklyCost" min="-1" /></td>
                <td>
                    <a @click="saveProduct(item);" class="btn btn-success btn-sm">儲存</a>
                </td>
                <td>
                    <a @click="removeProduct(item)" class="btn btn-danger btn-sm">移除商品</a>
                </td>
            </tr>
            <tr v-show="list == null || list.length == 0">
                <td colspan="10" class="text-center">No Data.</td>
            </tr>
        </tbody>
        <tfoot v-show="list != null && list.length > 0">
            <tr>
                <td colspan="3"></td>
                <td colspan="5" class="text-center"><a @click="saveAll();" class="btn btn-success btn-sm">儲存所有價格</a></td>
                <td colspan="2"></td>
            </tr>
        </tfoot>
    </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="pricelist.js" type="module"></script>
    <!--FinalScript E-->
</body>
</html>