Ext.define('BusinessRefModel', {
|
extend: 'Ext.data.Model',
|
fields:[
|
'resourceid','title','datasources','resourceclass','resrefid','refresourceid'
|
],
|
idProperty: 'resrefid'
|
});
|
var search = window.location.search;
|
var resourceid = "";
|
if(search.indexOf("?") > -1){
|
search = search.replace("?", "");
|
resourceid = search.split('=')[1];
|
}
|
var BusinessRefStore = new Ext.data.Store({
|
autoDestroy: true,
|
pageSize: 10,
|
model: 'BusinessRefModel',
|
proxy: {
|
type: 'ajax',
|
url: '/res/businessref/getResourceSetGLTC?resourceid='+resourceid,
|
reader: {
|
root: 'topics',
|
totalProperty: 'totalCount'
|
},
|
simpleSortMode: true
|
},
|
remoteSort: true
|
});
|
|
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: 540,
|
layout: 'fit',
|
autoScroll: false,
|
//bodyStyle: 'width:100%',
|
store: BusinessRefStore,
|
stateful: false,
|
stateId: 'BusinessRefList-Grid',
|
viewConfig: {
|
forceFit: true,
|
enableTextSelection: true //列表数据可复制
|
},
|
columns: [
|
{ xtype: 'rownumberer', text: "序号", width: '5%', align: 'center' },
|
{text: "资源名称", dataIndex: 'title', width: '30%', flex: 1, sortable: false, align: 'center', filter: { type: 'string' },
|
renderer: function (value, p, record) {
|
var ziYuanId = record.getData()["refresourceid"];
|
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: 'resourceclass', width: '15%', 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: 'datasources', width: '30%', sortable: false, align: 'center', filter: { type: 'string' } },
|
{ text: "操作", dataIndex: 'resrefid', width: '20%', sortable: false, align: 'center',
|
renderer: function (value, p, record) {
|
var resrefid = record.getData()["resrefid"];
|
return Ext.String.format(
|
'<a class="btn btn-primary ltblue" id="btnTG" style="padding: 4px 6px; margin-right: 5px;" data-toggle="modal" href="" data-keyboard="false" data-backdrop="true" onclick="OpenOtherWin({0});">保存其他属性</a> <a class="btn btn-danger" id="btnBTG" style="padding: 3px 6px; margin-right: 5px;" data-toggle="modal" href="" data-keyboard="false" data-backdrop="true" onclick="Delete({0});">删除</a>',
|
resrefid
|
);
|
}
|
}
|
],
|
bbar: Ext.create('Ext.ux.PagingToolbar', {
|
id: "Page",
|
name: "Page",
|
store: BusinessRefStore,
|
displayInfo: true,
|
firstText: "首页",
|
prevText: "上一页",
|
nextText: "下一页",
|
lastText: "尾页",
|
refreshText: '刷新',
|
beforePageText: '第',
|
afterPageText: '页,共 {0} 页',
|
displayMsg: '显示 {0} - {1} 条,共 {2} 条',
|
emptyMsg: "没有数据显示",
|
items: [
|
{
|
xtype: 'label',
|
text: ''
|
}
|
]
|
})
|
});
|
BusinessRefStore.on('beforeload', function () {
|
//GetSearchWhere("SearchForm");
|
BusinessRefStore.proxy.extraParams = [];
|
Ext.apply(BusinessRefStore.proxy.extraParams, formdata);
|
});
|
BusinessRefStore.on('load', function (store, records, successful, eOpts) {
|
|
});
|
BusinessRefStore.load();
|
//添加resize监听防止切换tab或者收起左栏导致grid不自适应宽度
|
$(window).resize(function () {
|
Ext.getCmp('gridexample').doLayout();//panel重新布局
|
});
|
});
|
|
//获取查询条件
|
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 + "");
|
}
|
}
|
|
//删除
|
function Delete(id){
|
if (confirm("确定删除吗?")) {
|
$.ajax({
|
url: '/res/businessref/deleteByPrimaryKey',
|
type: 'post',
|
dataType: "text",
|
data: {'resrefid': id},
|
success: function (data) {
|
if(data == 1){
|
alert("删除成功!");
|
Search();
|
}
|
},
|
error: function (e) {
|
alert(e);
|
}
|
});
|
}
|
}
|
|
//打开保存其它属性窗口
|
function OpenOtherWin(id){
|
$("#resrefid").val(id);
|
layer.open({
|
type: 1,
|
title: '其他属性',
|
shadeClose: false,
|
area: ['500px', '260px'],
|
content: jQuery("#resOtherInfo")
|
});
|
$.ajax({
|
url: '/res/businessref/selectByPrimaryKey',
|
data: {'resrefid': id},
|
type: 'get',
|
success: function (data) {
|
if(data != null){
|
$("#outputparam").val(data.outputparam);
|
$("#inputparam").val(data.inputparam);
|
$("#reftype").val(data.reftype);
|
}
|
},
|
error: function (e) {
|
alert(e);
|
}
|
});
|
}
|
|
//关闭窗口
|
function ColseLayer() {
|
$(".layui-layer-close1").click();
|
}
|
|
//保存其它属性
|
function SaveOther(){
|
$.ajax({
|
url: '/res/businessref/updateByPrimaryKeySelective',
|
type: 'post',
|
dataType: "text",
|
data: {
|
'outputparam': $("#outputparam").val(),
|
'inputparam': $('#inputparam').val(),
|
'reftype': $("#reftype").val(),
|
'resrefid':$("#resrefid").val()
|
},
|
success: function (data) {
|
if(result = 1){
|
alert("保存成功!");
|
ColseLayer();
|
Search();
|
}
|
},
|
error: function (e) {
|
alert(e.message);
|
}
|
});
|
}
|
|
//弹出添加窗口
|
function OpenAddWin() {
|
var search = window.location.search;
|
var resourceid = "";
|
if(search.indexOf("?") > -1) {
|
search = search.replace("?", "");
|
resourceid = search.split('=')[1];
|
}
|
layer.open({
|
type: 2,
|
title: "添加关联",
|
shadeClose: true,
|
area: ["800px", "550px"],
|
content: 'resource_select?flag=gltc&resourceid=' + resourceid
|
});
|
}
|