examine.js
3.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
//商家管理
'use strict';
var $ = require('jquery'),
Handlebars = require('yoho.handlebars');
var dropDown=require('../common/dropDown');
require('../util/jquery.gritter');
var grid=require('../common/grid');
exports.init=function(){
new dropDown({el:"#status"});
new dropDown({el:"#brand-name",ajax:"brand"});
new dropDown({el:"#supplier-name",ajax:"supplier"});
$('#filter-btn').on('click',function(){
g.reload();
});
var g=new grid({
el:'#storeadmin_Tabel',
parms:function(){
var supplierid=!!~$.trim($('#supplier-name').val())?$('#supplier-name').val():"0",
brandId = !!~$.trim($('#brand-name').val())?$('#brand-name').val():"0",
checkStatus = !!~$.trim($('#status').val())?$('#status').val():"0";
return {
"supplierId":supplierid,
"brandId":brandId,
"operationStatus":2,
"checkStatus":checkStatus,
"checkStatusArr":"300,200,900"
};
},
columns:[
{display:"店铺ID",name:"shopsId"},
{display:"店铺名称",name:"shopName"},
{display:"包含品牌",name:"shopRelationList",render:function(item){
var str='';
$.each(item.shopRelationList,function (index,a) {
str+='<p>'+a.brandName+'</p>';
})
return str;
}},
{display:"创建时间",name:"createTime"},
{display:"更新时间",name:"updateTime"},
{display:"状态",name:"status"},
{display:"操作",name:"",render:function(item){
var pushAll =[]
pushAll.push('<a href="/supplier/store/info/'+item.shopsId+'" class="btn btn-info btn-xs">查看</a>');
pushAll.push('<a href="/supplier/store/update/'+item.shopsId+'" class="btn btn-success btn-xs">编辑</a>');
pushAll.push('<input type="hidden" value="'+item.status+'" />');
if(item.status == 0){
pushAll.push('<button data-status="'+item.status+'" data-shopsid="'+item.shopsId+'" class="shopsstatus btn btn-warning btn-xs">开店</button>');
}else{
pushAll.push('<button data-status="'+item.status+'" data-shopsid="'+item.shopsId+'" class="shopsstatus btn btn-danger btn-xs">关店</button>');
}
return pushAll.join('');
}}
]
})
console.log($('#url').val());
g.init($('#url').val());
function __ajax(options,callback){
$.ajax({
type: 'POST',
url: options.url,
dataType: 'json',
data:options.data||{},
success: function(res) {
res=res.data;
if (res.code === 200) {
$.gritter.add({
title: options.msg||"提交成功",
class_name: 'growl-success',
sticky: false,
time: '1000',
after_open: function() {
callback&&callback();
}
});
} else {
$.gritter.add({
title: '提交失败',
class_name: 'growl-danger',
sticky: false,
time: '1000'
});
}
}
});
}
//提交操作
$(document).on('click', '.shopsstatus', function() {
var that = this,
url;
if($(that).data('status')==1){
url = "/supplier/store/closeShops";
}else{
url = "/supplier/store/openShops";
}
__ajax({
url: url,
data:{shopsId:$(that).data("shopsid")}
},function(){
g.reload();
});
});
}