1
13693261870
2022-09-16 762f2fb45db004618ba099aa3c0bd89dba1eb843
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
$(function () {
    $("#jqGrid").jqGrid({
        url: restServerBaseURL + 'sys/pubnews/list',
        datatype: "json",
        colModel: [
            { label: '资讯标题', name: 'title', index: 'TITLE', width: 120,align:'center',
                formatter:function(value,grid,rows,state){
                    var newsid = rows.newsid,html="";
                    var title=rows.title;
                    html+='<span style="text-decoration : underline;cursor:pointer;" onclick="vm.links(\'' + newsid + '\')">'+title+'</span>'
                        return html;
                }
            },
            { label: 'ID', name: 'newsid', index: 'NEWSID', width: 20, key: true ,hidden:true},
            { label: '资讯类型', name: 'type', index: 'TYPE', width: 20,align:'center' },
            { label: '创建时间', name: 'createdate', index: 'CREATEDATE', width: 20,align:'center', 
                formatter:function(value,grid,rows,state){
                    var dateStr = rows.createdate;
                    if (dateStr != null && dateStr !='') {
                        return dateStr.substring(0,10);
                    }
                    else
                    {
                        return "";
                    }
                }
            },
            { label: '创建人', name: 'createusername', index: 'CREATEUSERNAME', width: 20,align:'center'},
            { label: '操作', width: 30,align:'center',sortable:false,formatter:function(value,grid,rows,state){
                var newsid=rows.newsid,html="";
                if(hasPermission('sys:pubnews:edit')){
                    html += '<input type="button" id="action"  class="btn btn-warning" value="编辑" style="margin-right:5px;padding:3px 6px;" onclick=vm.update("'+newsid+'")>';
                    html += '<input type="button" id="del"  class="btn btn-danger" value="删除" style="padding:3px 6px;" onclick="vm.del(\'' + newsid + '\')">';
                }
                return html;
              }
            }
        ],
        viewrecords: true,
        height: "auto",
        rowNum: 10,
        //rowList : [10,30,50],
        rownumbers: true,
        rownumWidth: 50,
        autowidth:true,
        multiselect: false,
        pager: "#jqGridPager",
        jsonReader : {
            root: "page.list",
            page: "page.currPage",
            total: "page.totalPage",
            records: "page.totalCount"
        },
        prmNames : {
            page:"page",
            rows:"limit",
            order: "order"
        },
        gridComplete:function(){
            //隐藏grid底部滚动条
            $("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" });
        },
        onSortCol:function(index,colindex,sortorder){
            jQuery("#jqGrid").jqGrid('setGridParam',{
                page:$(".ui-pg-input").val()
            });
        }
    });
    $("#jqGrid").jqGrid('setLabel','rn','序号',{'text-align':'left'},'');
    initType();
});
 
function action(appid){
    window.location.href= baseURL + "/admin/modules/sys/resource.html?appid="+appid;
}
 
var vm = new Vue({
    el:'#rapp',
    data:{
        showList: true,
        title: null,
        pubnews: {}
    },
    methods: {
        query: function () {
            vm.pubnews.title=$("#title").val();
            vm.pubnews.type=$("#type").val();
            vm.pubnews.createimeBeg = "";
            vm.pubnews.createtimeEnd = "";
 
            if(!checkDate()) {
                return false;
            }
 
            if($("#createimeBeg").val() != '' && $("#createimeBeg").val().length>0){
                vm.pubnews.createimeBeg = $("#createimeBeg").val()+" 00:00:00";
            }
            if($("#createtimeEnd").val() != '' && $("#createtimeEnd").val().length>0){
                vm.pubnews.createtimeEnd = $("#createtimeEnd").val()+" 23:59:59";
            }
            vm.reload();
        },
        add: function(){
            vm.title = "新增";
            vm.systeminfo = {};
            window.open(baseURL + "admin/modules/sys/pubnews_edit.html", "_blank");
        },
        update: function (id) {
            vm.title = "修改";
            window.open(baseURL + "admin/modules/sys/pubnews_edit.html?newsid=" + id, "_blank");
        },
        del: function (id) {
            confirm('确定要删除选中的记录?', function(){
                $.ajax({
                    type: "POST",
                    url: restServerBaseURL + "sys/pubnews/delete",
                    contentType: "application/json",
                    data: "["+id+"]",
                    success: function(r){
                        if(r.code == 0){
                            alert('操作成功', function(){
                                vm.reload();
                            });
                        }else{
                            alert(r.msg);
                        }
                    }
                });
            });
        },
        links:function (id) {
            window.open(LanCatalogBaseURL + "res/PingTaiMenHu/ZiXunInfo?newsid=" + id, "_blank");
        },
        reload: function () {
            vm.showList = true;
            var page = $("#jqGrid").jqGrid('getGridParam','page');
            //点击查询时,当前页设置为第一页
            $("#jqGrid").jqGrid('setGridParam',{
                postData:{
                        'title':vm.pubnews.title,
                        'type':vm.pubnews.type,
                        'createimeBeg':vm.pubnews.createimeBeg,
                        'createtimeEnd':vm.pubnews.createtimeEnd
                    },
                page: 1
            }).trigger("reloadGrid");
        },
        refresh: function () {
            vm.showList = true;
            window.location.reload();
        }
    }
});
 
//资讯分类 - 初始化下拉框(查询区)
function initType(){
    $.ajax({
        type: "GET",
        url: restServerBaseURL + "sys/fieldvalue/queryListByKey?key=NewsType",
        contentType: "application/json",
        success: function(msg) {
            var sysFieldList = msg.sysFieldList;
            jQuery("#type").append("<option value='' >全部</option>");
            jQuery.each(sysFieldList, function(i, item) {
                jQuery("#type").append("<option value=" + item.vcode + ">" + item.vtext + "</option>");
            });
        }
    });
}
 
function checkDate() {
    var createimeBeg = $("#createimeBeg").val();
    var createtimeEnd = $("#createtimeEnd").val();
    if(createimeBeg != "" && createtimeEnd != ""){
        var pubdatestart = new Date(createimeBeg.replace(/-/g,"/"));
        var pubdateend = new Date(createtimeEnd.replace(/-/g,"/"));
        if(pubdatestart > pubdateend){
            alert("结束时间不能小于开始时间!", function () {
                $("#createtimeEnd").focus();
                $("#createtimeEnd").focus();
            });
            return false;
        }
        else {
            return true;
        }
    }
    else {
        return true;
    }
}