/**
|
* date: 2016-12-20
|
* author: neeler
|
*/
|
|
//test data start
|
// var data_getSysConfig = Mock.mock('/system/getSysConfig.htm', {code: 0, errmsg: '获取失败!', item: {isSendSMSCode: true, isVisitorCheck: true}})
|
// var data_setSysConfig = Mock.mock('/system/setSysConfig.htm', {code: 0, errmsg: '设置失败!', value: true})
|
//test data end
|
|
window.I = {
|
save: $('#save')
|
}
|
|
var ViewModel = function() {
|
var self = this;
|
self.sklimit=ko.observable();
|
self.mustloading=ko.observable();
|
self.ingotpounds=ko.observable();
|
self.qtpounds=ko.observable();
|
self.fbout=ko.observable();
|
}
|
|
$(function () {
|
window.vm = new ViewModel();
|
ko.applyBindings(vm);
|
getSysConfig();
|
pageInit();
|
|
// $('.confi').blur(function(event) {
|
// var $this=$(this);
|
// var name=$this.attr("name");
|
// var value=$this.val();
|
// setSysConfig(name,value);
|
// });
|
});
|
|
function pageInit() {
|
I.save.click(function (e) {
|
e.preventDefault();
|
setAllSysConfig();
|
});
|
}
|
|
function getSysConfig() {
|
$.post('/system/configs.htm', null, function(data, textStatus, xhr) {
|
jQuery.each(data, function(index, val) {
|
if(val.name=='sklimit'){
|
vm.sklimit(val.value);
|
}else if(val.name=='mustloading'){
|
vm.mustloading(val.value);
|
}else if(val.name=='ingotpounds'){
|
vm.ingotpounds(val.value);
|
}else if(val.name=='qtpounds'){
|
vm.qtpounds(val.value);
|
}else if(val.name=='fbout'){
|
vm.fbout(val.value);
|
}
|
});
|
}, 'json');
|
}
|
|
function setSysConfig(name, value) {
|
$.post('/system/setSysConfig.htm', {name: name, value: value}, function(data, textStatus, xhr) {
|
if (data.code >= 1) {
|
//showErrmsg(data.errmsg);
|
swal({title:'',text:data.errmsg,type:'error',confirmButtonText:'确定'});
|
return;
|
}
|
if (data.code == 0) {
|
if(name=='sklimit'){
|
vm.sklimit(value);
|
}else if(name=='mustloading'){
|
vm.mustloading(value);
|
}else if(name=='ingotpounds'){
|
vm.ingotpounds(value);
|
}else if(name=='qtpounds'){
|
vm.qtpounds(value);
|
}else if(name=='fbout'){
|
vm.fbout(value);
|
}
|
showErrmsg("配置"+name+"已经设置成功");
|
return;
|
}
|
}, 'json');
|
}
|
|
function setAllSysConfig() {
|
$.post("/system/setallSysConfig.htm", {
|
sklimit: vm.sklimit(),
|
mustloading: vm.mustloading(),
|
ingotpounds: vm.ingotpounds(),
|
qtpounds: vm.qtpounds(),
|
fbout: vm.fbout()
|
},
|
function (data, textStatus, jqXHR) {
|
if (data.code >= 1) {
|
showErrmsg(data.errmsg);
|
return;
|
}
|
if (data.code == 0) {
|
showErrmsg('保存成功!');
|
return;
|
}
|
},
|
"json"
|
);
|
}
|