Browse Source

修复设计器在有多个SQL类型数据集的情况下参数重复显示的BUG

master
jacky6024 7 years ago
parent
commit
dda7bd586c
  1. 14
      ureport2-js/src/Utils.js
  2. 13
      ureport2-js/src/dialog/ParameterTable.js
  3. 6
      ureport2-js/src/dialog/SqlDatasetDialog.js
  4. 3
      ureport2-js/src/tree/BuildinTree.js
  5. 2
      ureport2-js/src/tree/DatabaseTree.js

14
ureport2-js/src/Utils.js

@ -143,6 +143,20 @@ export function tableToXml(context){
} }
} }
if(value.type==='dataset'){ if(value.type==='dataset'){
let msg=null;
if(!value.datasetName){
msg=`${cellName}单元格数据集属性不能为空!`;
}
if(!msg && !value.property){
msg=`${cellName}单元格属性不能为空!`;
}
if(!msg && !value.aggregate){
msg=`${cellName}单元格聚合方式属性不能为空!`;
}
if(msg){
alert(msg);
throw msg;
}
cellXml+=`<dataset-value dataset-name="${encode(value.datasetName)}" aggregate="${value.aggregate}" property="${value.property}" order="${value.order}">`; cellXml+=`<dataset-value dataset-name="${encode(value.datasetName)}" aggregate="${value.aggregate}" property="${value.property}" order="${value.order}">`;
cellXml+=buildConditions(value.conditions); cellXml+=buildConditions(value.conditions);
if(value.aggregate==='customgroup'){ if(value.aggregate==='customgroup'){

13
ureport2-js/src/dialog/ParameterTable.js

@ -18,11 +18,11 @@ export default class ParameterTable{
table.append(this.body); table.append(this.body);
this._buildParameters(); this._buildParameters();
container.append(table); container.append(table);
const parameterDialog=new ParameterDialog(data); this.parameterDialog=new ParameterDialog(this.data);
addButton.click(function(){ addButton.click(function(){
parameterDialog.show(function(name,type,defaultValue){ _this.parameterDialog.show(function(name,type,defaultValue){
const obj={name,type,defaultValue}; const obj={name,type,defaultValue};
data.push(obj); _this.data.push(obj);
const newTr=$(`<tr style="height: 35px;"><td style="vertical-align: middle">${name}</td><td style="vertical-align: middle">${type}</td><td style="vertical-align: middle">${defaultValue}</td></tr>`); const newTr=$(`<tr style="height: 35px;"><td style="vertical-align: middle">${name}</td><td style="vertical-align: middle">${type}</td><td style="vertical-align: middle">${defaultValue}</td></tr>`);
const removeTd=$(`<td style="vertical-align: middle"></td>`); const removeTd=$(`<td style="vertical-align: middle"></td>`);
const removeSpan=$(`<span><a href="###"><i class="glyphicon glyphicon-trash" style="font-size: 12pt;color: #d30a16;"></a></span>`); const removeSpan=$(`<span><a href="###"><i class="glyphicon glyphicon-trash" style="font-size: 12pt;color: #d30a16;"></a></span>`);
@ -30,15 +30,16 @@ export default class ParameterTable{
newTr.append(removeTd); newTr.append(removeTd);
_this.body.append(newTr); _this.body.append(newTr);
removeSpan.click(function(){ removeSpan.click(function(){
let index=data.indexOf(obj); let index=_this.data.indexOf(obj);
data.splice(index,1); _this.data.splice(index,1);
newTr.remove(); newTr.remove();
}) });
}) })
}); });
} }
refreshData(){ refreshData(){
this.body.empty(); this.body.empty();
this.parameterDialog.data=this.data;
this._buildParameters(); this._buildParameters();
} }
_buildParameters(){ _buildParameters(){

6
ureport2-js/src/dialog/SqlDatasetDialog.js

@ -112,8 +112,12 @@ export default class SqlDatasetDialog{
}); });
} }
show(onSave){ show(onSave,parameters){
this.onSave=onSave; this.onSave=onSave;
if(parameters){
this.data=parameters;
this.parameterTable.data=this.data.parameters;
}
this.dialog.modal('show'); this.dialog.modal('show');
this.oldName=this.data.name; this.oldName=this.data.name;
this.nameEditor.val(this.data.name); this.nameEditor.val(this.data.name);

3
ureport2-js/src/tree/BuildinTree.js

@ -52,7 +52,7 @@ export default class BuildinTree extends BaseTree{
_this.datasets.push(dataset); _this.datasets.push(dataset);
const fieldsUL=_this.addDataset(dataset); const fieldsUL=_this.addDataset(dataset);
_this.buildFileds(dataset,fieldsUL); _this.buildFileds(dataset,fieldsUL);
}); },{parameters:[]});
}else if(key==='delete'){ }else if(key==='delete'){
confirm("真的要删除当前数据源["+_this.name+"]?",function(){ confirm("真的要删除当前数据源["+_this.name+"]?",function(){
let index=-1; let index=-1;
@ -157,6 +157,7 @@ export default class BuildinTree extends BaseTree{
} }
$.ajax({ $.ajax({
url:window._server+"/datasource/buildFields", url:window._server+"/datasource/buildFields",
type:'POST',
data: { data: {
sql: dataset.sql, sql: dataset.sql,
parameters: JSON.stringify(dataset.parameters), parameters: JSON.stringify(dataset.parameters),

2
ureport2-js/src/tree/DatabaseTree.js

@ -57,7 +57,7 @@ export default class DatabaseTree extends BaseTree{
_this.datasets.push(dataset); _this.datasets.push(dataset);
const fieldsUL=_this.addDataset(dataset); const fieldsUL=_this.addDataset(dataset);
_this.buildFileds(dataset,fieldsUL); _this.buildFileds(dataset,fieldsUL);
}); },{parameters:[]});
}else if(key==='delete'){ }else if(key==='delete'){
confirm("真的要删除当前数据源["+_this.name+"]?",function(){ confirm("真的要删除当前数据源["+_this.name+"]?",function(){
let index=-1; let index=-1;

Loading…
Cancel
Save