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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
| /**
| * date:
| * author: neeler
| */
|
| //test data start
| // var data_getList = Mock.mock('/log/card/getList.htm', {code: 0, 'list|1-20': [{cardno: 'cn47877878', type: '门岗用卡', fkname: '发卡人名', stime: '2015-05-05', ptype: '身份证', paperNo: '410103199010287984', phone: '13898927337', numberplates: '豫A12345', name: '万亚伶', vcompany: '光影交错', isreturn: false, iswhite: false, position: false, departname: '高精板带', sdate: '2016-01-01', edate: '2016-12-31',}], pages: 12})
| //test data end
|
| var Obj = {
| cardno: '',
| type: '',
| fkname: '',
| stime: '',
| ptype: '',
| paperno: '',
| phone: '',
| numberplates: '',
| name: '',
| vcompany: '',
| isreturn: '',
| iswhite: '',
| position: '',
| departname: '',
| sdate: '',
| edate: '',
| }
|
| window.I = {
| PZ: 50,
| keyword: $('#keyword'),
| searchBtn: $('.searchBtn'),
| moreSearchCondition: $('#moreSearchCondition'),
| searchBox: $('#searchBox'),
| sDate: $('#sDate'),
| eDate: $('#eDate'),
| cardnoValue: $('#cardno').val(),
| modal: $('#modal')
| }
|
| var ViewModel = function() {
| var self = this;
| self.o = ko.observable(ko.mapping.fromJS(Obj));
| self.keyword = ko.observable(I.cardnoValue);
| self.list = ko.observableArray();
|
| self.details = function(item) {
| showDetails(item);
| }
| }
|
| $(function () {
| window.vm = new ViewModel();
| ko.applyBindings(vm);
| if (I.cardnoValue) {
| doSearch();
| }
| pageInit();
| });
|
| function showDetails(item) {
| vm.o(ko.mapping.fromJS(item));
| I.modal.modal('show');
| }
|
| function pageInit() {
| I.moreSearchCondition.click(function(event) {
| if ($(this).hasClass('active')) {
| I._complexSearch = false;
| $(this).removeClass('active');
| $('i', $(this)).addClass('fa-chevron-down').removeClass('fa-chevron-up');
| I.searchBox.slideUp();
| } else {
| I._complexSearch = true;
| $(this).addClass('active');
| $('i', $(this)).removeClass('fa-chevron-down').addClass('fa-chevron-up');
| I.searchBox.slideDown();
| }
| });
| I.searchBtn.click(function(event) {
| doSearch();
| });
| I.keyword.on(ISIE ? 'keydown' : 'keyup', function (event) {
| if (event.keyCode == 13) {
| doSearch();
| }
| });
| }
|
| function doSearch() {
| if (!!I._complexSearch) {
| getList(vm.keyword(), I.sDate.val(), I.eDate.val(), 0, 1, I.PZ);
| } else {
| getList(vm.keyword(), null, null, 0, 1, I.PZ);
| }
| }
|
| function getList(keyword, sdate, edate, page, pagesize, pages) {
| $.post('/log/card/getList.htm', {
| keyword: keyword,
| sdate: sdate,
| edate: edate,
| page: page,
| pagesize: pagesize,
| pages: pages
| }, function(data, textStatus, xhr) {
| vm.list.removeAll();
| if (data.code >= 1) {
| // parent.showErrmsg(data.errmsg);
| swal({title:'',text:data.errmsg,type:'error',confirmButtonText:'确定'});
| return;
| }
| if (data.code == 0) {
| if (isList(data.list)) {
| $.each(data.list, function(index, val) {
| vm.list.push(val);
| });
| }
| if (!!pages) {
| pages = data.pages;
| $('#pagdiv').unbind('page').empty();
| if (pages > 1) {
| $('#pagdiv').bootpag({total: pages, maxVisible: 10, page: page + 1}).on('page',function(event,num){
| getList(keyword, sdate, edate, num - 1, pagesize, pages);
| });
| }
| }
| return;
| }
| }, 'json');
| }
|
|