python学习
This commit is contained in:
853
.idea/workspace.xml
generated
853
.idea/workspace.xml
generated
File diff suppressed because it is too large
Load Diff
2
mina
2
mina
Submodule mina updated: 992d270a96...824f4c2e9e
290
web/controllers/furniture/Furniture.py
Normal file
290
web/controllers/furniture/Furniture.py
Normal file
@@ -0,0 +1,290 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from flask import Blueprint,request,jsonify,redirect
|
||||
from common.libs.Helper import ops_render,getCurrentDate,iPagination,getDictFilterField
|
||||
from application import app,db
|
||||
from common.models.food.Food import Food
|
||||
from common.models.food.FoodCat import FoodCat
|
||||
from common.models.food.FoodStockChangeLog import FoodStockChangeLog
|
||||
from common.libs.UrlManager import UrlManager
|
||||
from common.libs.food.FoodService import FoodService
|
||||
from decimal import Decimal
|
||||
from sqlalchemy import or_
|
||||
route_furniture = Blueprint( 'furniture_page',__name__ )
|
||||
|
||||
@route_furniture.route( "/index" )
|
||||
def index():
|
||||
resp_data = {}
|
||||
req = request.values
|
||||
page = int(req['p']) if ('p' in req and req['p']) else 1
|
||||
query = Food.query
|
||||
if 'mix_kw' in req:
|
||||
rule = or_(Food.name.ilike("%{0}%".format(req['mix_kw'])), Food.tags.ilike("%{0}%".format(req['mix_kw'])))
|
||||
query = query.filter( rule )
|
||||
|
||||
if 'status' in req and int( req['status'] ) > -1 :
|
||||
query = query.filter( Food.status == int( req['status'] ) )
|
||||
|
||||
if 'cat_id' in req and int( req['cat_id'] ) > 0 :
|
||||
query = query.filter( Food.cat_id == int( req['cat_id'] ) )
|
||||
|
||||
page_params = {
|
||||
'total':query.count(),
|
||||
'page_size': app.config['PAGE_SIZE'],
|
||||
'page':page,
|
||||
'display':app.config['PAGE_DISPLAY'],
|
||||
'url': request.full_path.replace("&p={}".format(page),"")
|
||||
}
|
||||
|
||||
pages = iPagination( page_params )
|
||||
offset = ( page - 1 ) * app.config['PAGE_SIZE']
|
||||
list = query.order_by( Food.id.desc() ).offset( offset ).limit( app.config['PAGE_SIZE'] ).all()
|
||||
|
||||
cat_mapping = getDictFilterField( FoodCat,FoodCat.id,"id",[] )
|
||||
resp_data['list'] = list
|
||||
resp_data['pages'] = pages
|
||||
resp_data['search_con'] = req
|
||||
resp_data['status_mapping'] = app.config['STATUS_MAPPING']
|
||||
resp_data['cat_mapping'] = cat_mapping
|
||||
resp_data['current'] = 'index'
|
||||
return ops_render( "furniture/index.html",resp_data )
|
||||
|
||||
@route_furniture.route( "/info" )
|
||||
def info():
|
||||
resp_data = {}
|
||||
req = request.args
|
||||
id = int(req.get("id", 0))
|
||||
reback_url = UrlManager.buildUrl("/food/index")
|
||||
|
||||
if id < 1:
|
||||
return redirect( reback_url )
|
||||
|
||||
info = Food.query.filter_by( id =id ).first()
|
||||
if not info:
|
||||
return redirect( reback_url )
|
||||
|
||||
stock_change_list = FoodStockChangeLog.query.filter( FoodStockChangeLog.food_id == id )\
|
||||
.order_by( FoodStockChangeLog.id.desc() ).all()
|
||||
|
||||
resp_data['info'] = info
|
||||
resp_data['stock_change_list'] = stock_change_list
|
||||
resp_data['current'] = 'index'
|
||||
return ops_render( "food/info.html",resp_data )
|
||||
|
||||
|
||||
@route_furniture.route( "/set" ,methods = [ 'GET','POST'] )
|
||||
def set():
|
||||
if request.method == "GET":
|
||||
resp_data = {}
|
||||
req = request.args
|
||||
id = int( req.get('id',0) )
|
||||
info = Food.query.filter_by( id = id ).first()
|
||||
if info and info.status != 1:
|
||||
return redirect( UrlManager.buildUrl("/food/index") )
|
||||
|
||||
cat_list = FoodCat.query.all()
|
||||
resp_data['info'] = info
|
||||
resp_data['cat_list'] = cat_list
|
||||
resp_data['current'] = 'index'
|
||||
return ops_render( "food/set.html" ,resp_data)
|
||||
|
||||
resp = {'code': 200, 'msg': '操作成功~~', 'data': {}}
|
||||
req = request.values
|
||||
id = int(req['id']) if 'id' in req and req['id'] else 0
|
||||
cat_id = int(req['cat_id']) if 'cat_id' in req else 0
|
||||
name = req['name'] if 'name' in req else ''
|
||||
price = req['price'] if 'price' in req else ''
|
||||
main_image = req['main_image'] if 'main_image' in req else ''
|
||||
summary = req['summary'] if 'summary' in req else ''
|
||||
stock = int(req['stock']) if 'stock' in req else ''
|
||||
tags = req['tags'] if 'tags' in req else ''
|
||||
|
||||
if cat_id < 1:
|
||||
resp['code'] = -1
|
||||
resp['msg'] = "请选择分类~~"
|
||||
return jsonify(resp)
|
||||
|
||||
if name is None or len(name) < 1:
|
||||
resp['code'] = -1
|
||||
resp['msg'] = "请输入符合规范的名称~~"
|
||||
return jsonify(resp)
|
||||
|
||||
if not price or len( price ) < 1:
|
||||
resp['code'] = -1
|
||||
resp['msg'] = "请输入符合规范的售卖价格~~"
|
||||
return jsonify(resp)
|
||||
|
||||
price = Decimal(price).quantize(Decimal('0.00'))
|
||||
if price <= 0:
|
||||
resp['code'] = -1
|
||||
resp['msg'] = "请输入符合规范的售卖价格~~"
|
||||
return jsonify(resp)
|
||||
|
||||
if main_image is None or len(main_image) < 3:
|
||||
resp['code'] = -1
|
||||
resp['msg'] = "请上传封面图~~"
|
||||
return jsonify(resp)
|
||||
|
||||
if summary is None or len(summary) < 3:
|
||||
resp['code'] = -1
|
||||
resp['msg'] = "请输入图书描述,并不能少于10个字符~~"
|
||||
return jsonify(resp)
|
||||
|
||||
if stock < 1:
|
||||
resp['code'] = -1
|
||||
resp['msg'] = "请输入符合规范的库存量~~"
|
||||
return jsonify(resp)
|
||||
|
||||
if tags is None or len(tags) < 1:
|
||||
resp['code'] = -1
|
||||
resp['msg'] = "请输入标签,便于搜索~~"
|
||||
return jsonify(resp)
|
||||
|
||||
|
||||
|
||||
food_info = Food.query.filter_by(id=id).first()
|
||||
before_stock = 0
|
||||
if food_info:
|
||||
model_food = food_info
|
||||
before_stock = model_food.stock
|
||||
else:
|
||||
model_food = Food()
|
||||
model_food.status = 1
|
||||
model_food.created_time = getCurrentDate()
|
||||
|
||||
model_food.cat_id = cat_id
|
||||
model_food.name = name
|
||||
model_food.price = price
|
||||
model_food.main_image = main_image
|
||||
model_food.summary = summary
|
||||
model_food.stock = stock
|
||||
model_food.tags = tags
|
||||
model_food.updated_time = getCurrentDate()
|
||||
|
||||
db.session.add(model_food)
|
||||
ret = db.session.commit()
|
||||
|
||||
FoodService.setStockChangeLog( model_food.id,int(stock) - int(before_stock),"后台修改" )
|
||||
return jsonify(resp)
|
||||
|
||||
|
||||
@route_furniture.route( "/cat" )
|
||||
def cat():
|
||||
resp_data = {}
|
||||
req = request.values
|
||||
query = FoodCat.query
|
||||
|
||||
if 'status' in req and int( req['status'] ) > -1:
|
||||
query = query.filter( FoodCat.status == int( req['status'] ) )
|
||||
|
||||
list = query.order_by( FoodCat.weight.desc(),FoodCat.id.desc() ).all()
|
||||
resp_data['list'] = list
|
||||
resp_data['search_con'] = req
|
||||
resp_data['status_mapping'] = app.config['STATUS_MAPPING']
|
||||
resp_data['current'] = 'cat'
|
||||
return ops_render( "food/cat.html",resp_data )
|
||||
|
||||
@route_furniture.route( "/cat-set",methods = [ "GET","POST" ] )
|
||||
def catSet():
|
||||
if request.method == "GET":
|
||||
resp_data = {}
|
||||
req = request.args
|
||||
id = int(req.get("id", 0))
|
||||
info = None
|
||||
if id:
|
||||
info = FoodCat.query.filter_by( id = id ).first()
|
||||
resp_data['info'] = info
|
||||
resp_data['current'] = 'cat'
|
||||
return ops_render( "food/cat_set.html" ,resp_data )
|
||||
|
||||
resp = {'code': 200, 'msg': '操作成功~~', 'data': {}}
|
||||
req = request.values
|
||||
|
||||
id = req['id'] if 'id' in req else 0
|
||||
name = req['name'] if 'name' in req else ''
|
||||
weight = int( req['weight'] ) if ( 'weight' in req and int( req['weight']) > 0 ) else 1
|
||||
|
||||
if name is None or len( name ) < 1:
|
||||
resp['code'] = -1
|
||||
resp['msg'] = "请输入符合规范的分类名称~~"
|
||||
return jsonify( resp )
|
||||
|
||||
food_cat_info = FoodCat.query.filter_by( id = id ).first()
|
||||
if food_cat_info:
|
||||
model_food_cat = food_cat_info
|
||||
else:
|
||||
model_food_cat = FoodCat()
|
||||
model_food_cat.created_time = getCurrentDate()
|
||||
model_food_cat.name = name
|
||||
model_food_cat.weight = weight
|
||||
model_food_cat.updated_time = getCurrentDate()
|
||||
db.session.add(model_food_cat)
|
||||
db.session.commit()
|
||||
return jsonify( resp )
|
||||
|
||||
@route_furniture.route("/cat-ops",methods = [ "POST" ])
|
||||
def catOps():
|
||||
resp = {'code': 200, 'msg': '操作成功~~', 'data': {}}
|
||||
req = request.values
|
||||
|
||||
id = req['id'] if 'id' in req else 0
|
||||
act = req['act'] if 'act' in req else ''
|
||||
if not id :
|
||||
resp['code'] = -1
|
||||
resp['msg'] = "请选择要操作的账号~~"
|
||||
return jsonify(resp)
|
||||
|
||||
if act not in [ 'remove','recover' ] :
|
||||
resp['code'] = -1
|
||||
resp['msg'] = "操作有误,请重试~~"
|
||||
return jsonify(resp)
|
||||
|
||||
food_cat_info = FoodCat.query.filter_by( id= id ).first()
|
||||
if not food_cat_info:
|
||||
resp['code'] = -1
|
||||
resp['msg'] = "指定分类不存在~~"
|
||||
return jsonify(resp)
|
||||
|
||||
if act == "remove":
|
||||
food_cat_info.status = 0
|
||||
elif act == "recover":
|
||||
food_cat_info.status = 1
|
||||
|
||||
food_cat_info.update_time = getCurrentDate()
|
||||
db.session.add( food_cat_info )
|
||||
db.session.commit()
|
||||
return jsonify(resp)
|
||||
|
||||
@route_furniture.route("/ops",methods=["POST"])
|
||||
def ops():
|
||||
resp = { 'code':200,'msg':'操作成功~~','data':{} }
|
||||
req = request.values
|
||||
|
||||
id = req['id'] if 'id' in req else 0
|
||||
act = req['act'] if 'act' in req else ''
|
||||
|
||||
if not id :
|
||||
resp['code'] = -1
|
||||
resp['msg'] = "请选择要操作的账号~~"
|
||||
return jsonify(resp)
|
||||
|
||||
if act not in [ 'remove','recover' ]:
|
||||
resp['code'] = -1
|
||||
resp['msg'] = "操作有误,请重试~~"
|
||||
return jsonify(resp)
|
||||
|
||||
food_info = Food.query.filter_by( id = id ).first()
|
||||
if not food_info:
|
||||
resp['code'] = -1
|
||||
resp['msg'] = "指定美食不存在~~"
|
||||
return jsonify(resp)
|
||||
|
||||
if act == "remove":
|
||||
food_info.status = 0
|
||||
elif act == "recover":
|
||||
food_info.status = 1
|
||||
|
||||
food_info.updated_time = getCurrentDate()
|
||||
db.session.add(food_info)
|
||||
db.session.commit()
|
||||
return jsonify( resp )
|
||||
|
||||
1
web/controllers/furniture/__init__.py
Normal file
1
web/controllers/furniture/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
@@ -81,6 +81,10 @@ var common_ops = {
|
||||
nav_name = "food";
|
||||
}
|
||||
|
||||
if( pathname.indexOf("/furniture") > -1 ){
|
||||
nav_name = "furniture";
|
||||
}
|
||||
|
||||
if( pathname.indexOf("/member") > -1 ){
|
||||
nav_name = "member";
|
||||
}
|
||||
|
||||
52
web/static/js/furniture/cat.js
Normal file
52
web/static/js/furniture/cat.js
Normal file
@@ -0,0 +1,52 @@
|
||||
;
|
||||
var food_cat_ops = {
|
||||
init:function(){
|
||||
this.eventBind();
|
||||
},
|
||||
eventBind:function(){
|
||||
var that = this;
|
||||
|
||||
$(".wrap_search select[name=status]").change(function(){
|
||||
$(".wrap_search").submit();
|
||||
});
|
||||
|
||||
$(".remove").click( function(){
|
||||
that.ops( "remove",$(this).attr("data") );
|
||||
} );
|
||||
|
||||
$(".recover").click( function(){
|
||||
that.ops( "recover",$(this).attr("data") );
|
||||
} );
|
||||
},
|
||||
ops:function( act,id ){
|
||||
var callback = {
|
||||
'ok':function(){
|
||||
$.ajax({
|
||||
url:common_ops.buildUrl( "/food/cat-ops" ),
|
||||
type:'POST',
|
||||
data:{
|
||||
act:act,
|
||||
id:id
|
||||
},
|
||||
dataType:'json',
|
||||
success:function( res ){
|
||||
var callback = null;
|
||||
if( res.code == 200 ){
|
||||
callback = function(){
|
||||
window.location.href = window.location.href;
|
||||
}
|
||||
}
|
||||
common_ops.alert( res.msg,callback );
|
||||
}
|
||||
});
|
||||
},
|
||||
'cancel':null
|
||||
};
|
||||
common_ops.confirm( ( act == "remove" ? "确定删除?":"确定恢复?" ), callback );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
$(document).ready( function(){
|
||||
food_cat_ops.init();
|
||||
} );
|
||||
62
web/static/js/furniture/cat_set.js
Normal file
62
web/static/js/furniture/cat_set.js
Normal file
@@ -0,0 +1,62 @@
|
||||
;
|
||||
var food_cat_set_ops = {
|
||||
init:function(){
|
||||
this.eventBind();
|
||||
},
|
||||
eventBind:function(){
|
||||
$(".wrap_cat_set .save").click(function(){
|
||||
var btn_target = $(this);
|
||||
if( btn_target.hasClass("disabled") ){
|
||||
common_ops.alert("正在处理!!请不要重复提交~~");
|
||||
return;
|
||||
}
|
||||
|
||||
var name_target = $(".wrap_cat_set input[name=name]");
|
||||
var name = name_target.val();
|
||||
|
||||
var weight_target = $(".wrap_cat_set input[name=weight]");
|
||||
var weight = weight_target.val();
|
||||
|
||||
if( name.length < 1 ){
|
||||
common_ops.tip( "请输入符合规范的分类名称~~",name_target );
|
||||
return false;
|
||||
}
|
||||
|
||||
if( parseInt( weight ) < 1 ){
|
||||
common_ops.tip( "请输入符合规范的权重,并且至少要大于1~~",weight_target );
|
||||
return false;
|
||||
}
|
||||
|
||||
btn_target.addClass("disabled");
|
||||
|
||||
var data = {
|
||||
name: name,
|
||||
weight: weight,
|
||||
id:$(".wrap_cat_set input[name=id]").val()
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
url:common_ops.buildUrl( "/food/cat-set" ),
|
||||
type:'POST',
|
||||
data:data,
|
||||
dataType:'json',
|
||||
success:function( res ){
|
||||
btn_target.removeClass("disabled");
|
||||
var callback = null;
|
||||
if( res.code == 200 ){
|
||||
callback = function(){
|
||||
window.location.href = common_ops.buildUrl("/food/cat");
|
||||
}
|
||||
}
|
||||
common_ops.alert( res.msg,callback );
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$(document).ready( function(){
|
||||
food_cat_set_ops.init();
|
||||
} );
|
||||
50
web/static/js/furniture/index.js
Normal file
50
web/static/js/furniture/index.js
Normal file
@@ -0,0 +1,50 @@
|
||||
;
|
||||
var food_index_ops = {
|
||||
init:function(){
|
||||
this.eventBind();
|
||||
},
|
||||
eventBind:function(){
|
||||
var that = this;
|
||||
$(".remove").click( function(){
|
||||
that.ops( "remove",$(this).attr("data") )
|
||||
});
|
||||
|
||||
$(".recover").click( function(){
|
||||
that.ops( "recover",$(this).attr("data") )
|
||||
});
|
||||
|
||||
$(".wrap_search .search").click( function(){
|
||||
$(".wrap_search").submit();
|
||||
});
|
||||
},
|
||||
ops:function( act,id ){
|
||||
var callback = {
|
||||
'ok':function(){
|
||||
$.ajax({
|
||||
url:common_ops.buildUrl("/food/ops"),
|
||||
type:'POST',
|
||||
data:{
|
||||
act:act,
|
||||
id:id
|
||||
},
|
||||
dataType:'json',
|
||||
success:function( res ){
|
||||
var callback = null;
|
||||
if( res.code == 200 ){
|
||||
callback = function(){
|
||||
window.location.href = window.location.href;
|
||||
}
|
||||
}
|
||||
common_ops.alert( res.msg,callback );
|
||||
}
|
||||
});
|
||||
},
|
||||
'cancel':null
|
||||
};
|
||||
common_ops.confirm( ( act=="remove" )?"确定删除?":"确定恢复?",callback );
|
||||
}
|
||||
};
|
||||
|
||||
$(document).ready( function(){
|
||||
food_index_ops.init();
|
||||
});
|
||||
173
web/static/js/furniture/set.js
Normal file
173
web/static/js/furniture/set.js
Normal file
@@ -0,0 +1,173 @@
|
||||
;
|
||||
var upload = {
|
||||
error: function (msg) {
|
||||
common_ops.alert(msg);
|
||||
},
|
||||
success: function (file_key) {
|
||||
if (!file_key) {
|
||||
return;
|
||||
}
|
||||
var html = '<img src="' + common_ops.buildPicUrl(file_key) + '"/>'
|
||||
+ '<span class="fa fa-times-circle del del_image" data="' + file_key + '"></span>';
|
||||
|
||||
if ($(".upload_pic_wrap .pic-each").size() > 0) {
|
||||
$(".upload_pic_wrap .pic-each").html(html);
|
||||
} else {
|
||||
$(".upload_pic_wrap").append('<span class="pic-each">' + html + '</span>');
|
||||
}
|
||||
food_set_ops.delete_img();
|
||||
}
|
||||
};
|
||||
var food_set_ops = {
|
||||
init: function () {
|
||||
this.ue = null;
|
||||
this.eventBind();
|
||||
this.initEditor();
|
||||
this.delete_img();
|
||||
},
|
||||
eventBind: function () {
|
||||
var that = this;
|
||||
|
||||
$(".wrap_food_set .upload_pic_wrap input[name=pic]").change(function () {
|
||||
$(".wrap_food_set .upload_pic_wrap").submit();
|
||||
});
|
||||
|
||||
$(".wrap_food_set select[name=cat_id]").select2({
|
||||
language: "zh-CN",
|
||||
width: '100%'
|
||||
});
|
||||
|
||||
$(".wrap_food_set input[name=tags]").tagsInput({
|
||||
width: 'auto',
|
||||
height: 40,
|
||||
onAddTag: function (tag) {
|
||||
},
|
||||
onRemoveTag: function (tag) {
|
||||
}
|
||||
});
|
||||
|
||||
$(".wrap_food_set .save").click(function () {
|
||||
var btn_target = $(this);
|
||||
if (btn_target.hasClass("disabled")) {
|
||||
common_ops.alert("正在处理!!请不要重复提交~~");
|
||||
return;
|
||||
}
|
||||
|
||||
var cat_id_target = $(".wrap_food_set select[name=cat_id]");
|
||||
var cat_id = cat_id_target.val();
|
||||
|
||||
var name_target = $(".wrap_food_set input[name=name]");
|
||||
var name = name_target.val();
|
||||
|
||||
var price_target = $(".wrap_food_set input[name=price]");
|
||||
var price = price_target.val();
|
||||
|
||||
var summary = $.trim(that.ue.getContent());
|
||||
|
||||
var stock_target = $(".wrap_food_set input[name=stock]");
|
||||
var stock = stock_target.val();
|
||||
|
||||
var tags_target = $(".wrap_food_set input[name=tags]");
|
||||
var tags = $.trim(tags_target.val());
|
||||
|
||||
if (parseInt(cat_id) < 1) {
|
||||
common_ops.tip("请选择分类~~", cat_id_target);
|
||||
return;
|
||||
}
|
||||
|
||||
if (name.length < 1) {
|
||||
common_ops.alert("请输入符合规范的名称~~");
|
||||
return;
|
||||
}
|
||||
|
||||
if (parseFloat(price) <= 0) {
|
||||
common_ops.tip("请输入符合规范的售卖价格~~", price_target);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($(".wrap_food_set .pic-each").size() < 1) {
|
||||
common_ops.alert("请上传封面图~~");
|
||||
return;
|
||||
}
|
||||
|
||||
if (summary.length < 10) {
|
||||
common_ops.tip("请输入描述,并不能少于10个字符~~", price_target);
|
||||
return;
|
||||
}
|
||||
|
||||
if (parseInt(stock) < 1) {
|
||||
common_ops.tip("请输入符合规范的库存量~~", stock_target);
|
||||
return;
|
||||
}
|
||||
|
||||
if (tags.length < 1) {
|
||||
common_ops.alert("请输入标签,便于搜索~~");
|
||||
return;
|
||||
}
|
||||
|
||||
btn_target.addClass("disabled");
|
||||
|
||||
var data = {
|
||||
cat_id: cat_id,
|
||||
name: name,
|
||||
price: price,
|
||||
main_image: $(".wrap_food_set .pic-each .del_image").attr("data"),
|
||||
summary: summary,
|
||||
stock: stock,
|
||||
tags: tags,
|
||||
id: $(".wrap_food_set input[name=id]").val()
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
url: common_ops.buildUrl("/food/set"),
|
||||
type: 'POST',
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
success: function (res) {
|
||||
btn_target.removeClass("disabled");
|
||||
var callback = null;
|
||||
if (res.code == 200) {
|
||||
callback = function () {
|
||||
window.location.href = common_ops.buildUrl("/food/index");
|
||||
}
|
||||
}
|
||||
common_ops.alert(res.msg, callback);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
},
|
||||
initEditor: function () {
|
||||
var that = this;
|
||||
that.ue = UE.getEditor('editor', {
|
||||
toolbars: [
|
||||
['undo', 'redo', '|',
|
||||
'bold', 'italic', 'underline', 'strikethrough', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', '|', 'rowspacingtop', 'rowspacingbottom', 'lineheight'],
|
||||
['customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
|
||||
'directionalityltr', 'directionalityrtl', 'indent', '|',
|
||||
'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
|
||||
'link', 'unlink'],
|
||||
['imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
|
||||
'insertimage', 'insertvideo', '|',
|
||||
'horizontal', 'spechars', '|', 'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols']
|
||||
|
||||
],
|
||||
enableAutoSave: true,
|
||||
saveInterval: 60000,
|
||||
elementPathEnabled: false,
|
||||
zIndex: 4,
|
||||
serverUrl: common_ops.buildUrl('/upload/ueditor')
|
||||
});
|
||||
},
|
||||
delete_img: function () {
|
||||
$(".wrap_food_set .del_image").unbind().click(function () {
|
||||
$(this).parent().remove();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$(document).ready(function () {
|
||||
food_set_ops.init();
|
||||
});
|
||||
BIN
web/static/upload/20190812/34c121116c4f42e788636160d29b6e22.jpg
Normal file
BIN
web/static/upload/20190812/34c121116c4f42e788636160d29b6e22.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 57 KiB |
@@ -47,6 +47,10 @@
|
||||
<a href="{{ buildUrl('/stat/index') }}"><i class="fa fa-bar-chart fa-lg"></i> <span
|
||||
class="nav-label">统计管理</span></a>
|
||||
</li>
|
||||
<li class="furniture">
|
||||
<a href="{{ buildUrl('/furniture/index') }}"><i class="fa fa-bar-chart fa-lg"></i> <span
|
||||
class="nav-label">家具管理</span></a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
75
web/templates/furniture/cat.html
Normal file
75
web/templates/furniture/cat.html
Normal file
@@ -0,0 +1,75 @@
|
||||
{% extends "common/layout_main.html" %}
|
||||
{% block content %}
|
||||
{% include "common/tab_food.html" %}
|
||||
<div class="row">tab_food
|
||||
<div class="col-lg-12">
|
||||
<form class="form-inline wrap_search">
|
||||
<div class="row m-t p-w-m">
|
||||
<div class="form-group">
|
||||
<select name="status" class="form-control inline">
|
||||
<option value="-1">请选择状态</option>
|
||||
{% for tmp_key in status_mapping %}
|
||||
<option value="{{ tmp_key }}" {% if tmp_key == search_con['status'] %} selected {% endif %}>{{ status_mapping[ tmp_key ] }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<a class="btn btn-w-m btn-outline btn-primary pull-right"
|
||||
href="{{ buildUrl('/food/cat-set') }}">
|
||||
<i class="fa fa-plus"></i>分类
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
<table class="table table-bordered m-t">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>序号</th>
|
||||
<th>分类名称</th>
|
||||
<th>状态</th>
|
||||
<th>权重</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% if list %}
|
||||
{% for item in list %}
|
||||
<tr>
|
||||
<td>{{ item.id }}</td>
|
||||
<td>{{ item.name }}</td>
|
||||
<td>{{ item.status_desc }}</td>
|
||||
<td>{{ item.weight }}</td>
|
||||
<td>
|
||||
|
||||
{% if item.status == 1 %}
|
||||
<a class="m-l" href="{{ buildUrl('/food/cat-set') }}?id={{ item.id }}">
|
||||
<i class="fa fa-edit fa-lg"></i>
|
||||
</a>
|
||||
|
||||
<a class="m-l remove" href="javascript:void(0);" data="{{ item.id }}">
|
||||
<i class="fa fa-trash fa-lg"></i>
|
||||
</a>
|
||||
{% else %}
|
||||
<a class="m-l recover" href="javascript:void(0);" data="{{ item.id }}">
|
||||
<i class="fa fa-rotate-left fa-lg"></i>
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<tr><td colspan="5">暂无数据</td></tr>
|
||||
{% endif %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% block js %}
|
||||
<script src="{{ buildStaticUrl('/js/food/cat.js') }}"></script>
|
||||
{% endblock %}
|
||||
34
web/templates/furniture/cat_set.html
Normal file
34
web/templates/furniture/cat_set.html
Normal file
@@ -0,0 +1,34 @@
|
||||
{% extends "common/layout_main.html" %}
|
||||
{% block content %}
|
||||
{% include "common/tab_food.html" %}
|
||||
<div class="row m-t wrap_cat_set">
|
||||
<div class="col-lg-12">
|
||||
<h2 class="text-center">分类设置</h2>
|
||||
<div class="form-horizontal m-t m-b">
|
||||
<div class="form-group">
|
||||
<label class="col-lg-2 control-label">分类名称:</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" name="name" class="form-control" placeholder="请输入分类名称~~" value="{{ info.name }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="hr-line-dashed"></div>
|
||||
<div class="form-group">
|
||||
<label class="col-lg-2 control-label">权重:</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" name="weight" class="form-control" placeholder="请输入分类名称~~" value="{% if info and info.weight > 0 %}{{ info.weight }}{% else %}1{% endif%}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="hr-line-dashed"></div>
|
||||
<div class="form-group">
|
||||
<div class="col-lg-4 col-lg-offset-2">
|
||||
<input type="hidden" name="id" value="{{ info.id }}">
|
||||
<button class="btn btn-w-m btn-outline btn-primary save">保存</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% block js %}
|
||||
<script src="{{ buildStaticUrl('/js/food/cat_set.js') }}"></script>
|
||||
{% endblock %}
|
||||
100
web/templates/furniture/index.html
Normal file
100
web/templates/furniture/index.html
Normal file
@@ -0,0 +1,100 @@
|
||||
{% extends "common/layout_main.html" %}
|
||||
{% block content %}
|
||||
{% include "common/tab_food.html" %}
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<form class="form-inline wrap_search">
|
||||
<div class="row m-t p-w-m">
|
||||
<div class="form-group">
|
||||
<select name="status" class="form-control inline">
|
||||
<option value="-1">请选择状态</option>
|
||||
{% for tmp_key in status_mapping %}
|
||||
<option value="{{ tmp_key }}" {% if tmp_key == search_con['status'] %} selected {% endif %}>{{ status_mapping[ tmp_key ] }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<select name="cat_id" class="form-control inline">
|
||||
<option value="0">请选择分类</option>
|
||||
{% for tmp_key in cat_mapping %}
|
||||
<option value="{{ tmp_key }}" {% if tmp_key|string == search_con['cat_id'] %} selected {% endif %} >{{ cat_mapping[ tmp_key].name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<input type="text" name="mix_kw" placeholder="请输入关键字" class="form-control" value="{{ search_con['mix_kw'] }}">
|
||||
<input type="hidden" name="p" value="{{ search_con['p'] }}">
|
||||
<span class="input-group-btn">
|
||||
<button type="button" class="btn btn-primary search">
|
||||
<i class="fa fa-search"></i>搜索
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<a class="btn btn-w-m btn-outline btn-primary pull-right" href="{{ buildUrl('/food/set') }}">
|
||||
<i class="fa fa-plus"></i>家具
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
<table class="table table-bordered m-t">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>家具名</th>
|
||||
<th>分类</th>
|
||||
<th>价格</th>
|
||||
<th>库存</th>
|
||||
<th>标签</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% if list %}
|
||||
{% for item in list %}
|
||||
<tr>
|
||||
<td>{{ item.name }}</td>
|
||||
<td>{{ item.name }}</td>
|
||||
<td>{{ item.price }}</td>
|
||||
<td>{{ item.stock }}</td>
|
||||
<td>{{ item.tags }}</td>
|
||||
<td>
|
||||
<a href="{{ buildUrl('/food/info') }}?id={{ item.id }}">
|
||||
<i class="fa fa-eye fa-lg"></i>
|
||||
</a>
|
||||
{% if item.status == 1 %}
|
||||
<a class="m-l" href="{{ buildUrl('/food/set') }}?id={{ item.id }}">
|
||||
<i class="fa fa-edit fa-lg"></i>
|
||||
</a>
|
||||
|
||||
<a class="m-l remove" href="javascript:void(0);" data="{{ item.id }}">
|
||||
<i class="fa fa-trash fa-lg"></i>
|
||||
</a>
|
||||
{% else %}
|
||||
<a class="m-l recover" href="javascript:void(0);" data="{{ item.id }}">
|
||||
<i class="fa fa-rotate-left fa-lg"></i>
|
||||
</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<tr><td colspan="6">暂无数据~~</td></tr>
|
||||
{% endif %}
|
||||
</tbody>
|
||||
</table>
|
||||
<!--分页代码已被封装到统一模板文件中-->
|
||||
{% include 'common/pagenation.html' %}
|
||||
</div>
|
||||
家具管理界面
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% block js %}
|
||||
<script src="{{ buildStaticUrl('/js/food/index.js') }}"></script>
|
||||
{% endblock %}
|
||||
99
web/templates/furniture/info.html
Normal file
99
web/templates/furniture/info.html
Normal file
@@ -0,0 +1,99 @@
|
||||
{% extends "common/layout_main.html" %}
|
||||
{% block content %}
|
||||
{% include "common/tab_food.html" %}
|
||||
<style type="text/css">
|
||||
.wrap_info img {
|
||||
width: 70%;
|
||||
}
|
||||
</style>
|
||||
<div class="row m-t wrap_info">
|
||||
<div class="col-lg-12">
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="m-b-md">
|
||||
<a class="btn btn-outline btn-primary pull-right" href="{{ buildUrl('/food/set') }}?id={{ info.id }}">
|
||||
<i class="fa fa-pencil"></i>编辑
|
||||
</a>
|
||||
<h2>美食信息</h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<p class="m-t">美食名:{{ info.name }}</p>
|
||||
<p>售价:{{ info.price }}</p>
|
||||
<p>库存总量:{{ info.stock }}</p>
|
||||
<p>图书标签:{{ info.tags }}</p>
|
||||
<p>封面图:<img src="{{ buildImageUrl( info.main_image ) }}" style="width: 50px;height: 50px;"></p>
|
||||
<p>描述:</p>
|
||||
<p>{{ info.summary | safe }}</p>
|
||||
<p></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-t">
|
||||
<div class="col-lg-12">
|
||||
<div class="panel blank-panel">
|
||||
<div class="panel-heading">
|
||||
<div class="panel-options">
|
||||
<ul class="nav nav-tabs">
|
||||
<li class="active">
|
||||
<a href="#tab-1" data-toggle="tab" aria-expanded="false">销售历史</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#tab-2" data-toggle="tab" aria-expanded="true">库存变更</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" id="tab-1">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>会员名称</th>
|
||||
<th>购买数量</th>
|
||||
<th>购买价格</th>
|
||||
<th>订单状态</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="4">暂无销售记录</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="tab-pane" id="tab-2">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>变更</th>
|
||||
<th>备注</th>
|
||||
<th>时间</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% if stock_change_list %}
|
||||
{% for item in stock_change_list %}
|
||||
<tr>
|
||||
<td>{{ item.unit }}</td>
|
||||
<td>{{ item.note }}</td>
|
||||
<td>{{ item.created_time }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<tr><td colspan="3">暂无数据~~</td></tr>
|
||||
{% endif %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
102
web/templates/furniture/set.html
Normal file
102
web/templates/furniture/set.html
Normal file
@@ -0,0 +1,102 @@
|
||||
{% extends "common/layout_main.html" %}
|
||||
{% block content %}
|
||||
{% include "common/tab_food.html" %}
|
||||
<div class="row mg-t20 wrap_food_set" style="">
|
||||
<div class="col-lg-12" style="">
|
||||
<h2 class="text-center">设置</h2>
|
||||
<div class="form-horizontal m-t" style="">
|
||||
<div class="form-group">
|
||||
<label class="col-lg-2 control-label">分类:</label>
|
||||
<div class="col-lg-10">
|
||||
<select name="cat_id" class="form-control select2-hidden-accessible" tabindex="-1"
|
||||
aria-hidden="true">
|
||||
<option value="0">请选择分类</option>
|
||||
{% for item in cat_list %}
|
||||
<option value="{{ item.id }}" {% if item.id == info.cat_id %} selected {% endif %}>{{ item.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="hr-line-dashed"></div>
|
||||
<div class="form-group">
|
||||
<label class="col-lg-2 control-label">名称:</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" placeholder="请输入名称" name="name" value="{{ info.name }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="hr-line-dashed"></div>
|
||||
<div class="form-group">
|
||||
<label class="col-lg-2 control-label">价格:</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" placeholder="请输入售价" name="price" value="{{ info.price }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="hr-line-dashed"></div>
|
||||
<div class="form-group">
|
||||
<label class="col-lg-2 control-label">封面图:</label>
|
||||
<div class="col-lg-10">
|
||||
<form class="upload_pic_wrap" target="upload_file" enctype="multipart/form-data" method="POST" action="{{ buildUrl('/upload/pic') }}">
|
||||
<div class="upload_wrap pull-left">
|
||||
<i class="fa fa-upload fa-2x"></i>
|
||||
<input type="file" name="pic" accept="image/png, image/jpeg, image/jpg,image/gif">
|
||||
</div>
|
||||
{% if info and info.main_image %}
|
||||
<span class="pic-each">
|
||||
<img src="{{ buildImageUrl( info.main_image ) }}"/>
|
||||
<span class="fa fa-times-circle del del_image" data="{{ info.main_image }}"></span>
|
||||
</span>
|
||||
{% endif %}
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="hr-line-dashed"></div>
|
||||
<div class="form-group" style="">
|
||||
<label class="col-lg-2 control-label">描述:</label>
|
||||
<div class="col-lg-10">
|
||||
<textarea id="editor" name="summary" style="height: 300px;">{{ info.summary }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="hr-line-dashed"></div>
|
||||
<div class="form-group">
|
||||
<label class="col-lg-2 control-label">库存:</label>
|
||||
<div class="col-lg-2">
|
||||
<input type="text" name="stock" class="form-control" value="{{ info.stock }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="hr-line-dashed"></div>
|
||||
<div class="form-group">
|
||||
<label class="col-lg-2 control-label">标签:</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="tags" value="{{ info.tags }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="hr-line-dashed"></div>
|
||||
<div class="form-group">
|
||||
<div class="col-lg-4 col-lg-offset-2">
|
||||
<input type="hidden" name="id" value="{{ info.id }}">
|
||||
<button class="btn btn-w-m btn-outline btn-primary save">保存</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<iframe name="upload_file" class="hide"></iframe>
|
||||
{% endblock %}
|
||||
{% block css %}
|
||||
<link href="{{ buildStaticUrl( '/plugins/select2/select2.min.css' ) }}" rel="stylesheet">
|
||||
<link href="{{ buildStaticUrl( '/plugins/tagsinput/jquery.tagsinput.min.css' ) }}" rel="stylesheet">
|
||||
{% endblock %}
|
||||
{% block js %}
|
||||
<script src="{{ buildStaticUrl( '/plugins/ueditor/ueditor.config.js' ) }}"></script>
|
||||
<script src="{{ buildStaticUrl( '/plugins/ueditor/ueditor.all.min.js' ) }}"></script>
|
||||
<script src="{{ buildStaticUrl( '/plugins/ueditor/lang/zh-cn/zh-cn.js' ) }}"></script>
|
||||
|
||||
<script src="{{ buildStaticUrl( '/plugins/select2/select2.pinyin.js' ) }}"></script>
|
||||
<script src="{{ buildStaticUrl( '/plugins/select2/zh-CN.js' ) }}"></script>
|
||||
<script src="{{ buildStaticUrl( '/plugins/select2/pinyin.core.js' ) }}"></script>
|
||||
|
||||
<script src="{{ buildStaticUrl( '/plugins/tagsinput/jquery.tagsinput.min.js' ) }}"></script>
|
||||
|
||||
|
||||
<script src="{{ buildStaticUrl( '/js/food/set.js' ) }}"></script>
|
||||
{% endblock %}
|
||||
2
www.py
2
www.py
@@ -16,6 +16,7 @@ from web.controllers.user.User import route_user
|
||||
from web.controllers.static import route_static
|
||||
|
||||
from web.controllers.food.Food import route_food
|
||||
from web.controllers.furniture.Furniture import route_furniture
|
||||
from web.controllers.account.Account import route_account
|
||||
from web.controllers.member.Member import route_member
|
||||
from web.controllers.finance.Finance import route_finance
|
||||
@@ -28,6 +29,7 @@ app.register_blueprint( route_user,url_prefix = "/user" )
|
||||
app.register_blueprint( route_static,url_prefix = "/static" )
|
||||
app.register_blueprint( route_account,url_prefix = "/account" )
|
||||
app.register_blueprint( route_food,url_prefix = "/food" )
|
||||
app.register_blueprint( route_furniture,url_prefix = "/furniture" )
|
||||
app.register_blueprint( route_member,url_prefix = "/member" )
|
||||
app.register_blueprint( route_finance,url_prefix = "/finance" )
|
||||
app.register_blueprint( route_stat,url_prefix = "/stat" )
|
||||
|
||||
Reference in New Issue
Block a user