2
13693261870
2022-09-16 653761a31dfeb50dd3d007e892d69c90bf0cdafc
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
/********************************************
 *             后台管理 - 我的订阅            *
 *******************************************/
 
//控制器:ResSubscriptionsController
 
//------------------------------------------
//F1.定义Ext列表实体字段
//F2.获取Ext列表数据
//F3.Ext加载后创建建列表
//F4.获取查询条件
//F5.页面初始化
//F6.查询
//F7.清除
//F8 查看申请理由
//F9 批复意见
//------------------------------------------
 
//F1.定义Ext列表实体字段
Ext.define('ResModel', {
    extend: 'Ext.data.Model',
    fields:[
        'resourceid', 'title', 'appid', 'appuserid', 'applycount', 'auditresult', 'audituserid', 'replycount', 'appdate', 'apptype', 'appusername','appreason','isDangQianYongHu','audittime','lastupdate','syncresult',
        'hangup'
    ],
    idProperty: 'appid'
});
 
//F2.获取Ext列表数据
var ResStore = new Ext.data.Store({
    autoDestroy: true,
    pageSize: 10,
    model: 'ResModel',
    proxy: {
        type: 'ajax',
        url: '/res/manage/subscriptions/getlist',
        reader: {
            root: 'topics',
            totalProperty: 'totalCount'
        },
        simpleSortMode: true
    },
    remoteSort: true
});
 
//F3.Ext加载后创建建列表
var formdata = {};
Ext.onReady(function () {
    Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
    Ext.tip.QuickTipManager.init();
    Ext.Ajax.timeout = 900000;
    Ext.require([
        'Ext.ux.PagingToolbar'
    ]);
    Ext.create('Ext.grid.Panel', {
        id: 'gridexample',
        renderTo: 'grid',
        // width: 2400,
        // height: 420,
        layout: 'fit',
        autoScroll: false,
        //bodyStyle: 'width:100%',
        store: ResStore,
        stateful: false,
        stateId: 'ZYMLZiYuan-Grid',
        viewConfig: {
            forceFit: true,
            enableTextSelection: true //列表数据可复制
        },
        columns: [
            { xtype: 'rownumberer', text: "序号", width: '4%', align: 'center' },
            { text: "资源名称", dataIndex: 'title', width: '31%', sortable: true, align: 'center', filter: { type: 'string' },
                renderer: function (value, p, record) {
                    var ziYuanId = record.getData()["resourceid"];
                    var status = "";
                    var hangup = record.getData()["hangup"];
                    var tit = htmlEncodeByRegExp(value);
                    if(hangup == 1) {
                        status = '<span class="label label-danger" style="margin-left: 10px;">挂起</span>';
                    }
                    return Ext.String.format(
                        '<span style="text-decoration: underline;cursor:pointer;line-height: 25px;" title="{2}" onclick="OpenZiYuan(\'{0}\')" >{2}</span>' + status,
                        ziYuanId, value, tit
                    );
                }
            },
            { text: "申请日期", dataIndex: 'appdate', width: '11%', sortable: true, align: 'center', filter: { type: 'string' } },
            { text: "申请理由", width: '11%', sortable: true, align: 'center' ,
                renderer: function (value, p, record) {
                    var appid = record.getData()["appid"];
                    return Ext.String.format(
                        '<span style="text-decoration: underline;cursor:pointer;" onclick="showAppreason(\'{0}\')" >查看</span>',
                        appid
                    );
                }
            },
            { text: "批复人", dataIndex: 'audituserid', width: '6%', sortable: true, align: 'center', filter: { type: 'string' } },
            { text: "批复日期", dataIndex: 'audittime', width: '9%', sortable: true, align: 'center', filter: { type: 'string' } },
            // { text: "批复意见", width: '10%', sortable: true, align: 'center' ,
            //     renderer: function (value, p, record) {
            //         var appid = record.getData()["appid"];
            //         return Ext.String.format(
            //             '<span style="text-decoration: underline;cursor:pointer;" onclick="showAuditOpinion(\'{0}\')" >查看</span>',
            //             appid
            //         );
            //     }
            // },
            { text: "最后同步时间", dataIndex: 'lastupdate', width: '9%', sortable: true, align: 'center', filter: { type: 'string' } },
            { text: "最后同步状态", dataIndex: 'syncresult', width: '10%', sortable: true, align: 'center', filter: { type: 'string' },
                renderer: function (value, p, record) {
                    var result = "";
                    if(value == 0) {
                        result = "同步成功";
                    }
                    else if(value == 1) {
                        result = "同步失败";
                    }
                    else {
                        result = "暂未同步";
                    }
                    return Ext.String.format('<span>{0}</span>',result);
                }
            },
            { text: "批复结果", dataIndex: 'auditresult', width: '10%', sortable: true, align: 'center', filter: { type: 'string' },
                renderer: function (value, p, record) {
                    if(value == "已通过") {
                        var appid = record.getData()["appid"];
                        return Ext.String.format(
                            '<span style="text-decoration: underline;cursor:pointer;" onclick="showAuditOpinion(\'{0}\')" >{1}</span>',
                            appid, value
                        );
                    }
                    else {
                        return Ext.String.format('<span>{0}</span>',value);
                    }
                }
            }
        ],
        bbar: Ext.create('Ext.ux.PagingToolbar', {
            id: "Page",
            name: "Page",
            store: ResStore,
            displayInfo: true,
            firstText: "首页",
            prevText: "上一页",
            nextText: "下一页",
            lastText: "尾页",
            refreshText: '刷新',
            beforePageText: '第',
            afterPageText: '页,共 {0} 页',
            displayMsg: '显示 {0} - {1} 条,共 {2} 条',
            emptyMsg: "没有数据显示",
            items: [
                {
                    xtype: 'label',
                    text: ''
                }
            ]
        })
    });
    ResStore.on('beforeload', function () {
        GetSearchWhere("SearchForm");
        ResStore.proxy.extraParams = [];
        Ext.apply(ResStore.proxy.extraParams, formdata);
    });
    ResStore.on('load', function (store, records, successful, eOpts) {
        var totalCount = store.totalCount;
        if (totalCount == "") totalCount = "0";
    });
    ResStore.load();
    //添加resize监听防止切换tab或者收起左栏导致grid不自适应宽度
    $(window).resize(function () {
        Ext.getCmp('gridexample').doLayout();//panel重新布局
    });
});
 
//F4.获取查询条件
function GetSearchWhere(formId) {
    var form = document.forms[formId];
    for (var i = 0; i < form.elements.length; i++) {
        var strID = form.elements[i].id;
        var value = form.elements[i].value;
        if (form.elements[i].type == "checkbox") {
            if (form.elements[i].checked == true)
                value = "on";
            else
                value = "";
        }
        if (form.elements[i].type == "radio") {
            if (form.elements[i].checked == true) {
                strID = form.elements[i].name;
                value = form.elements[i].value;
            }
        }
        formdata[strID] = (value == "全部" || value == "None" ? "" : value + "");
    }
}
 
//F5.页面初始化
$(function () {
    $(".date-picker").datepicker({
        language: 'zh-CN',
        format: 'yyyy-mm-dd'
    });
});
 
//F6.查询
function Search() {
    if(!checkDate2()) {
        $("#appdateEnd").focus();
        $("#appdateEnd").focus();
        return false;
    }
    Ext.getCmp('gridexample').dockedItems.items[1].store.currentPage = 1;
    ResStore.load();
}
 
//F7.清除
function Clear() {
    document.getElementById("SearchForm").reset();
}
 
//F8 查看申请理由
function showAppreason (id) {
    layer.open({
        type: 2,
        title: "申请理由",
        shadeClose: true,
        area: ["600px", "250px"],
        content: 'content?appid='+id
    });
}
 
//F9 批复意见
function showAuditOpinion(id){
    layer.open({
        type: 2,
        title: "批复意见",
        shadeClose: true,
        area: ["600px", "250px"],
        content: 'opinion?appid='+id
    });
}