Authored by wangwei

部门

... ... @@ -73,14 +73,16 @@ module.exports = function (app) {
app.get("/market/department/index", "marketing.CouponList.DepartmentIndex",function(){
this.$extend={
moduleName:'营销管理',
pageName:'优惠券费用承担部门',
pageName:'费用承担部门管理',
}
});
//新增部门
app.post("/coupon/insertDepartment", "Department_add");
//删除部门
app.post("/coupon/deleteDepartment", "Department_delete");
//修改部门
app.post("/coupon/updateDepartment", "Department_update");
app.post("/coupon/queryDepartmentList","Department_list");
app.post("/coupon/queryDepartmentById","Department_queryById");
};
\ No newline at end of file
... ...
... ... @@ -13,11 +13,12 @@ module.exports = {
departmentName: {type: String}
}
},
delete: {
title: "删除部门",
url: '/coupon/delDepartment',
update: {
title: "编辑部门",
url: '/coupon/updateDepartment',
params: {
department: {type: Number}
department: {type: Number},
departmentName: {type: String}
}
},
list:{
... ... @@ -26,6 +27,14 @@ module.exports = {
params: {
page: {type: Number},
size: {type: Number},
department: {type: Number},
departmentSel:{type:Number}
}
},
queryById: {
title: "查询信息",
url: '/coupon/selectByDepartmentId',
params: {
department: {type: Number}
}
}
... ...
... ... @@ -5,13 +5,15 @@
<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>
<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">
<input type="number" id="sel-departmentId" class="form-control" placeholder="请输入部门ID" style="height: 39px;"/>
</div>
<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>
... ... @@ -32,10 +34,11 @@
</div>
<script type="text/template" id="template">
<input type="hidden" name="department" value="[[department]]" id="department" class="form-control observe" data-field="department">
<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">
<input type="text" id="departmentName" value="[[departmentName]]" class="form-control observe" placeholder="部门名称" required="required" data-field="departmentName" >
</div>
</div>
... ...
... ... @@ -25,7 +25,8 @@ var g = new common.grid({
size: 10,
parms: function () {
return {
department:common.util.__input("choose-department")
department:common.util.__input("choose-department"),
departmentSel:common.util.__input("sel-departmentId")
};
},
columns: [
... ... @@ -42,7 +43,7 @@ var g = new common.grid({
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>');
HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-primary btn-xs info-modify">编辑</a>');
return HtmArr.join('');
}
}]
... ... @@ -69,11 +70,10 @@ $(document).on("change", ".observe", function () {
/*验证*/
var edit = new common.edit2(".modal-body");
var Bll = {
module: {
"departmentName":""
},
module: null,
//弹框
toast: function (module, hint, url) {
Bll.module = module;
var d = new common.dialog({
title: hint + "部门",
content: common.util.__template2($("#template").html(), Bll.module),
... ... @@ -83,16 +83,20 @@ var Bll = {
value: "保存",
callback: function () {
if (edit.validate()) {
console.log("Bll.module",Bll.module.departmentName);
common.util.__ajax2({
var departmentName = $("#departmentName").val();
if(departmentName.length>20){
common.util.__tip("部门名称不能超过20字符", "warning");
return false;
}
common.util.__ajax({
url: url,
data: Bll.module
}, function (res) {
if (res.code == '200') {
common.util.__tip("添加成功", 'success');
g.reload();
d.close();
}else{
}
else {
common.util.__tip(res.message, "warning");
}
}, true);
... ... @@ -109,16 +113,6 @@ var Bll = {
});
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();
}
... ... @@ -139,3 +133,16 @@ $(document).on('click', '.info-delete', function() {
var item=g.rows[$(this).data("index")];
Bll.deleteAction("确定删除该部门吗?",item.department);
});
/**
* 编辑--点击事件
*/
$(document).on('click', '.info-modify', function () {
var item = g.rows[$(this).data("index")];
console.log("id:",item.id);
common.util.__ajax({
url: "/coupon/queryDepartmentById",
data: {department: item.department}
}, function (res) {
Bll.toast(res.data, "修改", '/coupon/updateDepartment');
}, true);
});
\ No newline at end of file
... ...