Authored by wangwei

Merge branch 'dev6.1' into test6.1

Conflicts:
	code/index.js
... ... @@ -66,4 +66,21 @@ module.exports = function (app) {
//清除指定商品
app.post("/coupon/cleanPrdLimit", "CouponList_cleanPrdLimit");
// 更新微信卡券H5链接
app.post("/coupon/updateH5Link", "CouponList_updateH5Link");
app.get("/market/department/index", "marketing.CouponList.DepartmentIndex",function(){
this.$extend={
moduleName:'营销管理',
pageName:'优惠券费用承担部门',
}
});
//新增部门
app.post("/coupon/insertDepartment", "Department_add");
//删除部门
app.post("/coupon/deleteDepartment", "Department_delete");
app.post("/coupon/queryDepartmentList","Department_list");
};
\ No newline at end of file
... ...
/**
* Created by yoho on 2016/6/21.
*/
module.exports = {
namespace: "Department",
apis: {
/************************************部门信息*************************************/
add: {
title: "新增部门",
url: '/coupon/insertDepartment',
params: {
departmentName: {type: String}
}
},
delete: {
title: "删除部门",
url: '/coupon/delDepartment',
params: {
department: {type: Number}
}
},
list:{
title:"列表",
url:"/coupon/queryDepartmentList",
params: {
page: {type: Number},
size: {type: Number},
department: {type: Number}
}
}
}
};
\ No newline at end of file
... ...
<%include '../../../common/views/__ui/header'%>
<%include '../../../common/views/__partail/ListHeader'%>
<div class="contentpanel">
<div class="panel panel-default" style="margin-bottom:10px;">
<div class="panel-body" style="padding-bottom: 0">
<a id="add-btn" href="javascript:;" class="btn btn-success"><i class="fa fa-plus"></i> 添加部门信息</a>
</div>
<div class="panel-body">
<div class="row">
<div class="panel-col" id="departments"></div>
<div class="panel-col">
<a id="filter-btn" href="javascript:;" class="btn btn-info">筛选</a>
<a id="all-btn" href="" class="btn btn-info">全部</a>
</div>
</div>
</div>
</div>
</div>
<div class="panel panel-primary-head">
<div id="basicTable_wrapper" class="dataTables_wrapper no-footer">
<div class="dataTables_length" id="basicTable">
</div>
<nav>
<ul id="pagination" class="pagination pagination-lg"></ul>
</nav>
</div>
</div>
</div>
<script type="text/template" id="template">
<div class="form-group">
<label class="col-sm-2 control-label">部门名称<span style="color: red;"> *</span></label>
<div class="col-sm-10">
<input type="text" value="[[departmentName]]" class="form-control observe" placeholder="部门名称" required="required" data-field="departmentName">
</div>
</div>
</script>
<script type="text/template" id="search-department">
<select id="choose-department" title="" class=" select2-offscreen form-control">
<option value="-1">申请部门</option>
[[each data as item index]]
<option value="[[item.department]]">[[item.departmentName]]</option>
[[/each]]
</select>
</script>
<%include '../../../common/views/__ui/footer'%>
\ No newline at end of file
... ...
'use strict';
var $ = require('jquery');
require('../partials/import_prds');
var common = require('../../../common/common');
var e = new common.edit2("#basicForm");
common.util.__ajax({
url: "/coupon/getAllDepartment",//获取所有部门
data: {size: 1000}
}, function (res) {
var data=res.data;
var newData=data.filter(function(v,i){
if(v.status==1){
return v;
}
});
res.data=newData;
console.log(res);
$("#departments").html(common.util.__template2($("#search-department").html(), res));
new common.dropDown({el: "#choose-department"});
}, true);
var g = new common.grid({
el: '#basicTable',
size: 10,
parms: function () {
return {
department:common.util.__input("choose-department")
};
},
columns: [
{
display: '部门ID',
name: "department"
},
{
display: '部门名称',
name: "departmentName"
},
{
display: '操作',
name: "status",
render: function (items) {
var HtmArr = [];
HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-xs btn-danger info-delete">删除</a>');
return HtmArr.join('');
}
}]
});
g.init('/coupon/queryDepartmentList');
//==================== 按钮点击事件 =====================//
$("#filter-btn").click(function () {
g.reload(1);
});
/**
* 监听输入框变化
*/
$(document).on("change", ".observe", function () {
var $this = $(this);
var name = $this.data("field");
Bll.module = common.util.__buildobj(name, '.', Bll.module, function (obj, name1) {
obj[name1] = $this.val();
});
});
/*验证*/
var edit = new common.edit2(".modal-body");
var Bll = {
module: {
"departmentName":""
},
//弹框
toast: function (module, hint, url) {
var d = new common.dialog({
title: hint + "部门",
content: common.util.__template2($("#template").html(), Bll.module),
width: '40%',
button: [
{
value: "保存",
callback: function () {
if (edit.validate()) {
console.log("Bll.module",Bll.module.departmentName);
common.util.__ajax2({
url: url,
data: Bll.module
}, function (res) {
if (res.code == '200') {
common.util.__tip("添加成功", 'success');
g.reload();
d.close();
}else{
common.util.__tip(res.message, "warning");
}
}, true);
}
return false;
},
css: "btn-primary"
},
{
"value": "取消",
"css": "btn-info"
}
]
});
Bll.__editRender();
},
deleteAction:function(content,department){
common.dialog.confirm("温馨提示",content,function(){
common.util.__ajax({
url:'/coupon/deleteDepartment',
data:{department:department}
},function(){
g.reload();
});
});
},
__editRender: function () {
edit.init();
}
};
/**
* 添加--点击事件
*/
$(document).on('click', '#add-btn', function () {
var item = {
"departmentName": ""
};
Bll.toast(item, "添加", '/coupon/insertDepartment');
});
//删除店铺
$(document).on('click', '.info-delete', function() {
var item=g.rows[$(this).data("index")];
Bll.deleteAction("确定删除该部门吗?",item.department);
});
... ...