adminedit.js
2.72 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
'use strict';
var $ = require('jquery'),
Handlebars = require('yoho.handlebars');
var dropDown=require('../common/dropDown');
var grid=require('../common/grid');
require('../util/jquery.gritter');
exports.init=function(){
new dropDown({el:"#store-name",ajax:"brand"});
new dropDown({el:"#identity-type"});
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();
}
});
setTimeout(function(){
location.href="/supplier/storeadmin/index";
},800)
} else {
$.gritter.add({
title: '提交失败',
class_name: 'growl-danger',
sticky: false,
time: '1000'
});
}
}
});
}
if($('#storelsit').length>0){
$('#store-name option:selected').val($('#shopsId').text());
$('#identity-type option:selected').val($('#identity').text());
$('#manager-name option:selected').val($('#adminPid').text());
}
$('#identity-type').on('change',function(){
$.ajax({
url: '/supplier/storeadmin/managerName',
dataType: "json",
type: 'POST',
data: {
identity: $('#identity-type option:selected').val()
},
success: function(data) {
$.each(data.data.data,function(index){
console.log(data.data.data[index].truename);
$('#manager-name').append("<option value='"+data.data.data[index].pid+"'>"+data.data.data[index].truename+"</option>");
})
}
})
})
$('#amdinAdd').on('click',function(){
var that = this,
shopsId = $('#store-name').val(),
identityType = $('#identity-type').val(),
managerName = $('#manager-name').val();
__ajax({
url: "/supplier/storeadmin/addguanxi",
data:{
shopsId:shopsId,
adminPid:managerName,
identity:identityType
}
},function(){
g.reload();
});
})
}