/**
* Created by seeker910 on 2017/7/3.
*/
Rsd.define('Rsd.tool.DataSourceSelector', {
extend: 'Rsd.zen.dialog.BizListDialog',
xtype: 'ds-selector',
requires: [
'Rsd.SellerPartner.stores.ListStore' ,
'Rsd.control.QRCode',
'Rsd.SellerPartner.controls.ComboBoxUnApp'
],
modelType: 'Rsd.UnionApp.Resource.Models.ApiService' ,
titleField: 'Name',
where:[{name:'SiteId',op:'equals',value:Rsd.app.site.Id}],
searchColumns: [
{text: '名 称', name: 'Name',width:350},
],
newButtons:[{text: '刷新数据源', handler:'btn_refesh_ds'}],
gridColumns: [
{
"text": "序号",
"xtype": "index",
"width": 40,
"index": 0
},
{
"name": "Name",
"dataIndex": "Name",
"sortable": false,
"text": "名称",
"index": 22,
"exist": true,
"xtype": "string",
"format":"formatLabels",
"width": 100,
"nobr": true
},
{
"name": "ObjectType",
"dataIndex": "ObjectType",
"sortable": false,
"text": "数据源类型",
"index": 26,
"exist": true,
"xtype": "enum",
"enum": "Rsd.Office.Site.Core.DsObjectType",
"valueMember": "code",
"width": 50,
"nobr": true
},
{
"name": "Api",
"dataIndex": "Api",
"sortable": false,
"text": "API模板",
"index": 28,
"exist": true,
"xtype": "string",
"format":"formatApi",
"width": 150,
"nobr": true
},
{
"name": "Description",
"dataIndex": "Description",
"sortable": false,
"text": "说明",
"index": 30,
"exist": true,
"xtype": "string",
"width": 150,
"nobr": true
}
],
opColumns: [
{
name: 'space',
text: '',
xtype: 'template',
width: 5,
hideable: false,
sortable: false
}
],
/*
*
* */
constructor: function constructor(config) {
config = config || {};
this.apply(config);
},
/**
*
*/
btn_refesh_ds:function btn_refesh_ds() {
Rsd.popup('btn_refesh_ds');
},
/**
*
* @param {*} row
* @returns
*/
formatLabels:function formatLabels(row)
{
var lables = [Rsd.newLine()];
var arr = (row["Labels"]||'').split(',');
for(var i in arr)
{
if(Rsd.isEmpty(arr[i]))
{
continue;
}
lables.push(Rsd.label(arr[i]));
}
return lables;
},
/**
*
*/
formatApi:function formatApi(row)
{
return [Rsd.button('查看数据',function(){
Rsd.request({url:row["Api"],method:"GET"},{error:function(err){alert(err);}},function(resp){
if(resp.success)
{
var _data = Rsd.unescape(resp.data);
Rsd.create('Rsd.zen.dialog.JsonViewDialog',{title:'查看数据['+row['Name']+']'}).showDialog().load(_data);
}
else
{
Rsd.alert(resp.msg);
}
});
})];
}
});