<link rel="stylesheet" href="{{url_for('static',filename='upload/easy-upload.css')}}">
<script src="{{url_for('static',filename='upload/vendor/jquery.cookie-1.4.1.min.js')}}"></script>
<script src="{{url_for('static',filename='upload/easyUpload.js')}}"></script>
<table id="example" class="display" style="width:100%">
<thead>
<tr>
<th>产品名称</th>
<th>产品类型</th>
<th>品牌</th>
<th>价格</th>
<th>缩略图</th>
<th>操作</th>
</tr>
</thead>
<tfoot>
<tr>
<th>产品名称</th>
<th>产品类型</th>
<th>品牌</th>
<th>价格</th>
<th>缩略图</th>
<th>操作</th>
</tr>
</tfoot>
</table>
<!--加载商品列表-->
function loadProducts(){
$('#example').DataTable({
"ajax": {
"url":"/shop/product_list",
"dataType": "json",
"dataSrc": "data",
"contentType":"application/json"
},
"columns": [
{"data": "PRODUCT_NAME"},
{"data": "PRODUCT_TYPENAME"},
{"data": "BRAND"},
{"data": "PRICE"},
{"data": "PIC_PATH"},
{"data": "ID"}
]
});
}
@shop_view.route('/shop/product_list', methods=['GET', 'POST'])
@cache.cached(timeout=300, key_prefix='view_%s', unless=None)
def product_list():
'''商品管理'''
data = productservice.get_products()
result={'data':data}
return jsonify(result)
def get_products(self, typename=None, typeid=None, classification=None, key_word=None, pagesize=10, page_index=1):
'''获取产品列表'''
# results = []
# products_history = []
item_results = queryProducts(type_id=typeid, type_name=typename, classification_name=classification,
key_word=key_word, page_size=pagesize, page_index=page_index)
result = list(set(item_results))
if result is None:
return None
pageobjs = []
for (productObj, producttypeObj, classofproduct, shop) in result:
item = dict(ID=productObj.ID, PRODUCT_NAME=productObj.PRODUCT_NAME, PRODUCT_TYPENAME=producttypeObj.cn_name,
BRAND=productObj.BRAND, PRICE=productObj.PRICE, PIC_PATH=productObj.PIC_PATH)
pageobjs.append(item)
return pageobjs