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
| /**
| * date:
| * author: neeler
| */
|
| //test data start
| // 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'}})
| //test data end
|
| var TYPE = ['mssql', 'oracle']
|
| window.I = {
| save: $('#save'),
| sdv: $('#sysDepart').val()
| }
|
| var Obj = {
| syName: I.sdv,
| syID: '',
| db: '',
| uri: '',
| ip:'',
| port:'',
| dbName:'',
| username: '',
| pwd: '',
| note: '',
| semiRequestURL: '',
| productRequestURL: ''
| }
|
| var ViewModel = function() {
| var self = this;
| self.o = ko.observable(ko.mapping.fromJS(Obj));
| self.tList = ko.observableArray(TYPE);
| }
|
| $(function () {
| window.vm = new ViewModel();
| ko.applyBindings(vm);
| getInfo();
| pageInit();
| });
|
| function pageInit() {
| I.save.click(function (e) {
| e.preventDefault();
| saveInfo();
| });
| }
|
| function getInfo() {
| $.post("/system/erpdbconfig/getInfo.htm", null,
| function (data, textStatus, jqXHR) {
| if (data.code >= 1) {
| // showErrmsg(data.errmsg);
| swal({title:'',text:data.errmsg,type:'error',confirmButtonText:'确定'});
| return;
| }
| if (data.code == 0) {
| if (!$.isEmptyObject(data.item)) {
| vm.o(ko.mapping.fromJS(data.item));
| }
| return;
| }
| },
| "json"
| );
| }
|
| function saveInfo() {
| $.post("/system/erpdbconfig/saveInfo.htm", ko.mapping.toJS(vm.o()),
| function (data, textStatus, jqXHR) {
| if (data.code >= 1) {
| // showErrmsg(data.errmsg);
| swal({title:'',text:data.errmsg,type:'error',confirmButtonText:'确定'});
| return;
| }
| if (data.code == 0) {
| showErrmsg('保存成功!');
| return;
| }
| },
| "json"
| );
| }
|
|