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
| window.I = {}
| var basic=getpath();
| var modelview=function() {
| var self=this;
| self.opers=ko.observableArray();
| self.oper=ko.observable({
| id:ko.observable(0),
| title:ko.observable(),
| name:ko.observable(),
| exp:ko.observable(0),
| value:ko.observable(0)
| });
| self.rm=function(item){
| jQuery.post(basic+'/admin/opercon/rm.htm', {id:item.id}, function(data, textStatus, xhr) {
| if(data==null)
| return;
| if(data.code==0)
| {
| self.opers.remove(item);
| }else{
| alert(data.errmsg);
| }
| },'json');
| };
| self.edit=function(item){
| self.oper(item);
| $('#modal1').modal('show');
| };
| }
| jQuery(document).ready(function($) {
| window.mtype=$('#mtype').val();
| var md=window.md=new modelview();
| ko.applyBindings(md);
| var pagesize=15;
| opers();
| var fm1=$('#fm1');
| fm1.validate({
| rules:{
| title:{
| required:true
| },
| name:{
| required:true
| }
| },
| messages:{
| title:{
| required:'不能为空'
| },
| name:{
| required:'不能为空'
| }
| }
| });
| $('#ctbtn').click(function(){
| md.oper({
| id:ko.observable(0),
| title:ko.observable(),
| name:ko.observable(),
| exp:ko.observable(0),
| value:ko.observable(0)
| });
| $('#modal1').modal('show');
| });
| $('#tjbtn').click(function(){
| if(fm1.valid()==false)
| return;
| if(window.save==1)
| return;
| window.save=1;
| var tt=md.oper();
| var oper=ko.mapping.toJS(md.oper());
| jQuery.post(basic+'/admin/opercon/save.htm', oper, function(data, textStatus, xhr) {
| $('#modal1').modal('hide');
| window.save=0;
| if(data==null)
| return;
| if(data.code==1)
| {
| alert("无法保存!");
| }else{
| if(oper.id==0)
| {
| window.md.opers.push(ko.mapping.fromJS(data.oper));
| }
| }
| },'json');
| });
| });
| function opers()
| {
| jQuery.post(basic+'/admin/opercon/opers.htm', {}, function(data, textStatus, xhr) {
| if(data==null)
| return;
| window.md.opers.removeAll();
| if(data.items!=null)
| {
| jQuery.each(data.items, function(index, val) {
| var oper=ko.mapping.fromJS(val);
| window.md.opers.push(oper);
| });
| }
| },'json');
| }
|
|