|
|
'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);
|
|
|
}); |
...
|
...
|
|