-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdashboard.html
More file actions
154 lines (154 loc) · 9.39 KB
/
dashboard.html
File metadata and controls
154 lines (154 loc) · 9.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Document</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous"/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vue-loading-overlay@3/dist/vue-loading.css"/>
<link rel="stylesheet" href="css/style.css"/>
</head>
<body>
<div class="container my-5" id="app">
<loading :active.sync="isLoading" :is-full-page="true"></loading>
<div class="mb-3 text-right">
<input class="btn btn-primary mb-3" type="button" value="新增產品" @click="openModal('new')"/>
<table class="table text-center">
<thead>
<tr>
<th scope="col" width="150">縮圖</th>
<th scope="col">分類</th>
<th scope="col">產品名稱</th>
<th scope="col">原價</th>
<th scope="col">售價</th>
<th scope="col">是否啟用</th>
<th scope="col">編輯</th>
</tr>
</thead>
<tbody>
<tr v-for="product in products" :key="product.id">
<td v-if="product.imageUrl"><span class="thumbnail" :style="{backgroundImage: 'url(' + product.imageUrl[0] + ')'}"></span></td>
<td class="align-middle">{{product.category}}</td>
<td class="align-middle">{{product.title}}</td>
<td class="text-right align-middle">{{product.origin_price}}</td>
<td class="text-right align-middle">{{product.price}}</td>
<td class="align-middle text-success" v-if="product.enabled">啟用</td>
<td class="align-middle" v-else="v-else">未啟用</td>
<td class="align-middle">
<div class="btn-group" role="group">
<button class="btn btn-outline-primary btn-sm" type="button" @click="openModal('edit', product)">編輯</button>
<button class="btn btn-outline-danger btn-sm" type="button" @click="openModal('del', product)">刪除</button>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<pagination :pages="pagination" @get-products="getProducts"></pagination>
<edit-modal :user="user" @get-products="getProducts" @change-loading="changeLoading" ref="editModal"></edit-modal>
<del-modal :temp-product="tempProduct" :user="user" @get-products="getProducts"></del-modal>
</div>
<script type="text/x-template" id="editModal">
<div class="modal fade" id="editModal" role="dialog" aria-labelledby="editModalLabel" aria-hidden="true">
<div class="modal-dialog modal-xl">
<div class="modal-content">
<div class="modal-header bg-dark text-light">
<h5 class="modal-title">新增產品</h5>
<button class="close" type="button" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
</div>
<div class="modal-body">
<div class="row">
<div class="col-4">
<div class="custom-file mb-3">
<input class="custom-file-input" id="customFile" type="file" accept="image/*" ref="file" @change="uploadFile"/>
<label class="custom-file-label" for="customFile">上傳檔案(不可超過 2 MB)</label>
</div>
<div class="form-group">
<label for="imageUrl">請輸入圖片網址</label>
<input class="form-control" id="imageUrl" type="text" v-model="tempProduct.imageUrl[0]" placeholder="請輸入圖片網址" required="required"/>
</div><img class="img-fluid" :src="tempProduct.imageUrl[0]"/>
</div>
<div class="col-8">
<div class="form-group">
<label for="title">標題</label>
<input class="form-control" id="title" type="text" v-model="tempProduct.title" placeholder="請輸入標題" required="required"/>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="category">分類</label>
<input class="form-control" id="category" type="text" v-model="tempProduct.category" placeholder="請輸入分類" required="required"/>
</div>
<div class="form-group col-md-6">
<label for="unit">單位</label>
<input class="form-control" id="unit" type="text" v-model="tempProduct.unit" placeholder="請輸入單位" required="required"/>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="origin_price">原價</label>
<input class="form-control" id="origin_price" type="number" v-model="tempProduct.origin_price" placeholder="請輸入原價" required="required"/>
</div>
<div class="form-group col-md-6">
<label for="price">售價</label>
<input class="form-control" id="price" type="number" v-model="tempProduct.price" placeholder="請輸入售價" required="required"/>
</div>
</div>
<hr/>
<div class="form-group">
<label for="description">產品描述</label>
<textarea class="form-control" id="description" row="3" v-model="tempProduct.description" placeholder="請輸入產品描述" required="required"></textarea>
</div>
<div class="form-group">
<label for="content">說明內容</label>
<textarea class="form-control" id="content" row="3" v-model="tempProduct.content" placeholder="請輸入說明內容" required="required"></textarea>
</div>
<div class="form-group form-check">
<input class="form-check-input" id="enabled" type="checkbox" v-model="tempProduct.enabled"/>
<label class="form-check-label" for="enabled">使否啟用</label>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-outline-secondary" type="button" data-dismiss="modal">取消</button>
<button class="btn btn-primary" type="button" @click="updateProduct()">儲存</button>
</div>
</div>
</div>
</div>
</script>
<script type="text/x-template" id="delModal">
<div class="modal fade" id="delModal" role="dialog" aria-labelledby="delModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header bg-danger text-light">
<h5 class="modal-title">確認刪除</h5>
<button class="close" type="button" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
</div>
<div class="modal-body">確定要刪除 {{tempProduct.title}}</div>
<div class="modal-footer">
<button class="btn btn-outline-secondary" type="button" data-dismiss="modal">取消</button>
<button class="btn btn-outline-danger" type="button" @click="delProduct(tempProduct.id)">確定刪除</button>
</div>
</div>
</div>
</div>
</script>
<script type="text/x-template" id="pagination">
<nav>
<ul class="pagination justify-content-center">
<li class="page-item" :class="{'disabled': pages.current_page === 1}"><a class="page-link" href="#" aria-label="Previous" @click.prevent="changePage(pages.current_page-1)"><span aria-hidden="true">«</span></a></li>
<li class="page-item" :class="{'active': n === pages.current_page}" v-for="n in pages.total_pages" :key="n"><a class="page-link" href="#" @click.prevent="changePage(n)">{{n}}</a></li>
<li class="page-item" :class="{'disabled': pages.current_page === pages.total_pages}"><a class="page-link" href="#" aria-label="Next" @click.prevent="changePage(pages.current_page+1)"><span aria-hidden="true">»</span></a></li>
</ul>
</nav>
</script>
</body>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js" integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.11/vue.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.19.2/axios.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue-loading-overlay@3"></script>
<script src="js/dashboard.js"></script>
</html>