/********************************************
|
* 后台管理 - 资源申请列表 *
|
*******************************************/
|
|
//控制器:ResApplyRecommendController
|
|
//------------------------------------------
|
//F1.定义Ext列表实体字段
|
//F2.获取Ext列表数据
|
//F3.Ext加载后创建建列表
|
//F4.获取查询条件
|
//F5.页面初始化
|
//F6.查询
|
//F7.清除
|
//F8 弹出申请资源树
|
//------------------------------------------
|
|
//F1.定义Ext列表实体字段
|
Ext.define('ZYMLZiYuanModel', {
|
extend: 'Ext.data.Model',
|
fields:[
|
'resourceid','title','mulu','resourceclass', 'pubunitid', 'createuserid','pubdate','appdate','appuserid','auditresult','audit'
|
],
|
idProperty: 'resourceid'
|
});
|
|
//获取地址栏参数
|
var search = window.location.search;
|
var sysid = "";
|
if(search.indexOf("?") > -1){
|
search = search.replace("?", "");
|
sysid = search.split('=')[1];
|
}
|
|
//F2.获取Ext列表数据
|
var ResStore = new Ext.data.Store({
|
autoDestroy: true,
|
pageSize: 10,
|
model: 'ZYMLZiYuanModel',
|
proxy: {
|
type: 'ajax',
|
url: '/res/manage/applyrecommend/getlistbysystem?sysid='+sysid,
|
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',
|
// height: 310,
|
layout: 'fit',
|
autoScroll: false,
|
store: ResStore,
|
stateful: false,
|
stateId: 'ZYMLZiYuan-Grid',
|
viewConfig: {
|
forceFit: true,
|
enableTextSelection: true //列表数据可复制
|
},
|
columns: [
|
// { xtype: 'rownumberer', text: "序号", width: '4%', align: 'center' },
|
{text: "选择项", dataIndex: 'resourceid', width: '5%', sortable: false, align: 'center', filter: { type: 'string' },
|
renderer: function (value, p, record) {
|
var ziYuanId = record.getData()["resourceid"];
|
var audit = record.getData()["audit"];
|
var flag = '<input type="checkbox" disabled="disabled" name="resourceids" value="{0}"/>';
|
if(audit == 1) {
|
flag = '<input type="checkbox" name="resourceids" value="{0}"/>';
|
}
|
return Ext.String.format(
|
flag,
|
ziYuanId
|
);
|
|
}
|
},
|
{
|
text: "资源名称", dataIndex: 'title', width: '26%', flex: 1, sortable: true, align: 'left', filter: { type: 'string' },
|
renderer: function (value, p, record) {
|
var ziYuanId = record.getData()["resourceid"];
|
var tit = htmlEncodeByRegExp(value);
|
return Ext.String.format(
|
'<span style="text-decoration : underline;cursor:pointer;" title="{2}" onclick="OpenZiYuan(\'{0}\')" >{2}</span>',
|
ziYuanId, value,tit
|
);
|
}
|
}, {
|
text: "所属目录", dataIndex: 'mulu', width: '16%', sortable: false, filter: { type: 'string' }, align: 'left',
|
renderer: function (value, p, record) {
|
return Ext.String.format('<span title="{0}" >{0}</span>', value);
|
}
|
},
|
{
|
text: "资源类型", dataIndex: 'resourceclass', width: '8%', sortable: true, align: 'center', filter: { type: 'string' },
|
renderer: function (value, p, record) {
|
var color = "";
|
if (value == "基础底图" || value == "三维影像") {
|
color = "label-success";
|
} else if (value == "业务图层" || value == "接口服务") {
|
color = "label-danger";
|
} else if (value == "空间分析") {
|
color = "label-warning";
|
} else if (value == "专题地图" || value == "三维地形") {
|
color = "label-pink";
|
} else if (value == "专题应用程序" || value == "数据文件") {
|
color = "label-default";
|
} else if (value == "业务集成") {
|
color = "label-info";
|
} else if (value == "文档数据" || value == "数据库表" || value == "三维模型") {
|
color = "label-primary";
|
}
|
return Ext.String.format(
|
'<span class=\"label {0}\" style=\"padding: 0.3em 0.6em; font-size: 12px;font-weight: 300; \">{1}</span>',
|
color, value
|
);
|
}
|
},
|
{ text: "发布时间", dataIndex: 'pubdate', width: '10%', sortable: true, filter: { type: 'string' }, align: 'center' },
|
{
|
text: "发布单位", dataIndex: 'pubunitid', width: '12%', sortable: true, align: 'center', filter: { type: 'string' },
|
renderer: function (value, p, record) {
|
if(value == null || value == "null") {
|
return "";
|
} else {
|
return value;
|
}
|
}
|
},
|
{ text: "申请日期", dataIndex: 'appdate', width: '10%', sortable: true, align: 'center', filter: { type: 'string' } },
|
{ text: "申请人", dataIndex: 'appuserid', width: '8%', sortable: true, align: 'center', filter: { type: 'string' } },
|
{ text: "批复状态", dataIndex: 'auditresult', width: '8%', sortable: true, align: 'center', filter: { type: 'string' }},
|
{ text: "调用情况", dataIndex: 'resourceid', width: '8%', sortable: true, align: 'center', filter: { type: 'string' },
|
renderer: function (value, p, record) {
|
return Ext.String.format('<input type="button" style="padding:3px 6px;margin-left: 5px;" class="btn btn-info" onclick="checkAction({0})" value="查看">', 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'
|
});
|
$("select option").each(function () { //遍历所有option
|
var txt = $(this).val().substring(0, 3); //获取option值
|
var isKJ = $(this).text();
|
if (txt == "KJ_") {
|
if (isKJ != "空间服务") {
|
$(this).html("-- " + isKJ);
|
}
|
}
|
});
|
});
|
|
//F6.查询
|
function Search() {
|
Ext.getCmp('gridexample').dockedItems.items[1].store.currentPage = 1;
|
ResStore.load();
|
}
|
|
//F7.清除
|
function Clear() {
|
document.getElementById("SearchForm").reset();
|
}
|
var zTree;
|
|
//F9 保存申请
|
function SaveApply(){
|
var nodes = zTree.getCheckedNodes();
|
console.log(nodes);
|
var idStr = "";
|
for(var i = 0; i < nodes.length; i++) {
|
if(nodes[i].isParent == false) {
|
if(idStr != "") idStr+= ",";
|
idStr += nodes[i].id.replace("ZiYuan_","");
|
}
|
}
|
window.open("/res/manage/applyrecommend/ziyuanapply?ids="+idStr+"&sysid="+sysid);
|
}
|
|
//F8 弹出申请资源树
|
function ApplyTree(){
|
/**
|
* zTree配置
|
*/
|
var setting = {
|
view: {
|
selectedMulti: false,
|
showTitle : true
|
},
|
check: {
|
enable: false
|
},
|
data: {
|
simpleData: {
|
enable: true
|
},
|
key: {
|
title:"title"//1 json中要有一个key是 title就可以了
|
},
|
},
|
check: {
|
enable: true,
|
chkStyle: "checkbox",
|
},
|
// async: {
|
// enable: true,
|
// url: "/res/manage/applyrecommend/getSelectZiYuan",
|
// autoParam: ["id=parentid"],
|
// otherParam:{
|
// sysid:sysid
|
// }
|
// },
|
// callback: {
|
// //onClick: ztreeonClick
|
// }
|
};
|
var data = "";
|
$.ajax({
|
type: "GET",
|
url: "/res/manage/applyrecommend/getSelectZiYuan",
|
dataType: 'text',
|
data: {parentid: 0, sysid:sysid},
|
success: function (r) {
|
data = eval('(' + r + ')');
|
var zNodes = {
|
id: 0,
|
name: "资源目录",
|
pId: -1,
|
isParent: true,
|
open:true,
|
title:"",iconOpen:"/image/classicons/folderOpen.png",//update:dsh(2018/12/05)
|
iconClose:"/image/classicons/folder.png", "children": data
|
};
|
zTree = $.fn.zTree.init($("#menuTree"), setting, zNodes); //初始化zTree"
|
}
|
});
|
|
// zTree.reAsyncChildNodes(zTree.getNodes()[0], "refresh", false); //强行异步加载父节点的子节点。
|
layer.open({
|
type: 1,
|
title: "选择资源",
|
shadeClose: true,
|
area: ["600px", "450px"],
|
content: jQuery("#zydiv"),
|
cancel: function(index, layero){
|
layer.close(index);
|
$("#zydiv").hide();
|
}
|
});
|
}
|
|
//F9 填写系统地址
|
function SystemUrl() {
|
layer.open({
|
type: 1,
|
title: "系统地址",
|
shadeClose: true,
|
area: ["420px", "270px"],
|
content: jQuery("#sysurl"),
|
cancel: function(index, layero){
|
layer.close(index);
|
$("#sysurl").hide();
|
}
|
});
|
}
|
|
//关闭窗口
|
function closeLayer(){
|
$(".layui-layer-close1").click();
|
}
|
|
//F10 批量获取资源地址
|
function GetResourceUrl() {
|
var resourceids = "";
|
var sysUrl = $("#systemUrl").text();
|
$("input[name='resourceids']:checked").each(function (i) {
|
if(i != 0) resourceids += ",";
|
resourceids += $(this).val();
|
});
|
if(resourceids != "") {
|
//提示获取
|
layer.msg('获取中…',{icon: 16,shade: 0.5});
|
$.ajax({
|
type: 'GET',
|
url: '/res/manage/applyrecommend/getResourcesUrl',
|
data: {resourceids: resourceids, sysUrl: sysUrl, appid: sysid},
|
success: function (response) {
|
//获取成功关闭提示框
|
layer.closeAll('loading');
|
closeLayer();
|
window.open(response);
|
},
|
error: function (e) {
|
//获取失败关闭提示框
|
layer.closeAll('loading');
|
alert(e.message);
|
}
|
})
|
}
|
else {
|
alert("请选择所要获取地址的资源!");
|
}
|
}
|
|
function checkAction(resourceid) {
|
layer.open({
|
type: 2,
|
title: "资源调用情况",
|
shadeClose: true,
|
area: ["600px", "500px"],
|
content: '/res/manage/actionrecord/appcount?resourceid='+ resourceid
|
});
|
}
|