提交 | 用户 | 时间
|
58d006
|
1 |
/** |
A |
2 |
* date: |
|
3 |
* author: neeler |
|
4 |
*/ |
|
5 |
|
|
6 |
//test data start |
|
7 |
// var data_getInfo = Mock.mock('/system/erpdbconfig/getInfo.htm', {code: 0, item: {syName: 'syName', syID: 'syID', db: 'db', uri: 'uri', username: 'username', pwd: 'pwd', note: 'note', semiRequestURL: 'semiRequestURL', productRequestURL: 'productRequestURL'}}) |
|
8 |
//test data end |
|
9 |
|
|
10 |
var TYPE = ['mssql', 'oracle'] |
|
11 |
|
|
12 |
window.I = { |
|
13 |
save: $('#save'), |
|
14 |
sdv: $('#sysDepart').val() |
|
15 |
} |
|
16 |
|
|
17 |
var Obj = { |
|
18 |
syName: I.sdv, |
|
19 |
syID: '', |
|
20 |
db: '', |
|
21 |
uri: '', |
|
22 |
ip:'', |
|
23 |
port:'', |
|
24 |
dbName:'', |
|
25 |
username: '', |
|
26 |
pwd: '', |
|
27 |
note: '', |
|
28 |
semiRequestURL: '', |
|
29 |
productRequestURL: '' |
|
30 |
} |
|
31 |
|
|
32 |
var ViewModel = function() { |
|
33 |
var self = this; |
|
34 |
self.o = ko.observable(ko.mapping.fromJS(Obj)); |
|
35 |
self.tList = ko.observableArray(TYPE); |
|
36 |
} |
|
37 |
|
|
38 |
$(function () { |
|
39 |
window.vm = new ViewModel(); |
|
40 |
ko.applyBindings(vm); |
|
41 |
getInfo(); |
|
42 |
pageInit(); |
|
43 |
}); |
|
44 |
|
|
45 |
function pageInit() { |
|
46 |
I.save.click(function (e) { |
|
47 |
e.preventDefault(); |
|
48 |
saveInfo(); |
|
49 |
}); |
|
50 |
} |
|
51 |
|
|
52 |
function getInfo() { |
|
53 |
$.post("/system/erpdbconfig/getInfo.htm", null, |
|
54 |
function (data, textStatus, jqXHR) { |
|
55 |
if (data.code >= 1) { |
|
56 |
// showErrmsg(data.errmsg); |
|
57 |
swal({title:'',text:data.errmsg,type:'error',confirmButtonText:'确定'}); |
|
58 |
return; |
|
59 |
} |
|
60 |
if (data.code == 0) { |
|
61 |
if (!$.isEmptyObject(data.item)) { |
|
62 |
vm.o(ko.mapping.fromJS(data.item)); |
|
63 |
} |
|
64 |
return; |
|
65 |
} |
|
66 |
}, |
|
67 |
"json" |
|
68 |
); |
|
69 |
} |
|
70 |
|
|
71 |
function saveInfo() { |
|
72 |
$.post("/system/erpdbconfig/saveInfo.htm", ko.mapping.toJS(vm.o()), |
|
73 |
function (data, textStatus, jqXHR) { |
|
74 |
if (data.code >= 1) { |
|
75 |
// showErrmsg(data.errmsg); |
|
76 |
swal({title:'',text:data.errmsg,type:'error',confirmButtonText:'确定'}); |
|
77 |
return; |
|
78 |
} |
|
79 |
if (data.code == 0) { |
|
80 |
showErrmsg('保存成功!'); |
|
81 |
return; |
|
82 |
} |
|
83 |
}, |
|
84 |
"json" |
|
85 |
); |
|
86 |
} |