');
return $html;
},
render: function ($component) {
$component[0].dfop = $component[0].dfop || {
title: '单选项',
type: "radio",
table: '',
field: "",
proportion: '1',
dataSourceType: '1', // 1数据字典 2 物理地址
dataSource: '',
dataSourceUrl: ''
};
$component.html(getComponentRowHtml({ name: $component[0].dfop.title, text: "单选项" }));
},
property: function ($component) {
var dfop = $component[0].dfop;
var $html = initComponentPropertyHtml($component);
var html = '';
html += '
数据来源
';
html += '';
html += '
数据字典
';
html += '';
html += '
URL数据源
';
html += '';
$html.append(html);
createDatasource(dfop);
// 数据源地址设置
$html.find('#component_dataSourceUrl').val(dfop.dataSourceUrl);
$html.find('#component_dataSourceUrl').keyup(function () {
var value = $(this).val();
dfop.dataSourceUrl = value;
});
}
},
checkbox: {//多选框
init: function () {
var $html = $('
多选框
');
return $html;
},
render: function ($component) {
$component[0].dfop = $component[0].dfop || {
title: '多选框',
type: "checkbox",
table: '',
field: "",
proportion: '1',
dataSourceType: '1', // 1数据字典 2 物理地址
dataSource: '',
dataSourceUrl: ''
};
$component.html(getComponentRowHtml({ name: $component[0].dfop.title, text: "多选项" }));
},
property: function ($component) {
var dfop = $component[0].dfop;
var $html = initComponentPropertyHtml($component);
var html = '';
html += '
数据来源
';
html += '';
html += '
数据字典
';
html += '';
html += '
URL数据源
';
html += '';
$html.append(html);
createDatasource(dfop);
// 数据源地址设置
$html.find('#component_dataSourceUrl').val(dfop.dataSourceUrl);
$html.find('#component_dataSourceUrl').keyup(function () {
var value = $(this).val();
dfop.dataSourceUrl = value;
});
}
},
combox: {//下拉框
init: function () {
var $html = $('
下拉框
');
return $html;
},
render: function ($component) {
// console.log(JSON.stringify($component));
$component[0].dfop = $component[0].dfop || {
title: '下拉框',
type: "combox",
table: '',
field: "",
proportion: '1',
dataSourceType: '1', // 1数据字典 2 物理地址
dataSource: '',
dataSourceUrl: ''
};
$component.html(getComponentRowHtml({ name: $component[0].dfop.title, text: "下拉框" }));
},
property: function ($component) {
var dfop = $component[0].dfop;
var $html = initComponentPropertyHtml($component);
var html = '';
html += '
数据来源
';
html += '';
html += '
数据字典
';
html += '';
html += '
URL数据源
';
html += '';
$html.append(html);
createDatasource(dfop);
// 数据源地址设置
$html.find('#component_dataSourceUrl').val(dfop.dataSourceUrl);
$html.find('#component_dataSourceUrl').keyup(function () {
var value = $(this).val();
dfop.dataSourceUrl = value;
});
}
},
datetime: {//日期框
init: function () {
var $html = $('
日期框
');
return $html;
},
render: function ($component) {
$component[0].dfop = $component[0].dfop || {
title: '日期框',
type: "datetime",
table: '',
field: "",
proportion: '1',
verify: '',
dateformat: '0'
};
$component.html(getComponentRowHtml({ name: $component[0].dfop.title, text: '日期框' }));
},
property: function ($component) {
var dfop = $component[0].dfop;
var $html = initComponentPropertyHtml($component, verifyDatalist2);
var html = '';
html += '
日期格式
';
html += '';
$html.append(html);
// 日期格式
var $dateformat = $(document).find("#component_dateformat");
$.each(dataformatList, function (index, obj) {
if (dfop.dateformat === obj.id)//设置默认选项
$dateformat.append("");
else
$dateformat.append("");
});
// 日期格式选择
$('#component_dateformat').on('change', function () {
var format = $('#component_dateformat').find("option:selected").val();
dfop.dateformat = format;
});
}
},
girdtable: {
init: function () {
var $html = $('
编辑表格
');
return $html;
},
render: function ($component) {
$component[0].dfop = $component[0].dfop || {
title: '编辑表格',
table: '',
type: "girdtable",
proportion: '1',
icon: "fa fa-table",
minheight: 400, // 表格默认的行数
columns: []//设置的字段数据
};
$component.html(getComponentRowHtml({ name: '编辑表格', text: '编辑表格' }));
},
property: function ($component) {
var $html = initGridTable($component);
}
}
}
// 获取组件行显示html
function getComponentRowHtml(data) {
var html = '
' + data.name + '
' + data.text + '
';
return html;
};
// 设置组件公共属性设置html
function initComponentPropertyHtml($component) {
var dfop = $component[0].dfop;
var $html = $(".z-custmerform-designer-layout-right .mCSB_container");
var html = '';
html += '
绑定表
';
html += '';
html += '
绑定字段
';
html += '';
html += '
组件标题
';
html += '';
html += '
字段验证
';
html += '';
html += '
所占比例
';
html += '';
$html.html(html);
// 标题设置
$html.find('#component_title').val(dfop.title);
$html.find('#component_title').keyup(function () {
var value = $(this).val();
$component.find('.z-compont-title span').text(value);
dfop.title = value;
});
//数据表设置
var $table = $(document).find("#component_table");
var url = "/FormDesigner/FindPrimaryTable?keyValue=" + window.keyValue;
window.$.ajax({
url: url,
type: "get",
dataType: "json",
success: function (data) {
$.each(data, function (index, obj) {
if (dfop.table === obj.Value)//设置默认选项
$table.append("");
else
$table.append("");
});
},
complete: function () {
var table = $('#component_table').find("option:selected").val();
initColumn(table, dfop.field);
dfop.table = table;
}
});
// 验证初始化
var $verify = $(document).find("#component_verify");
$.each(verifyDatalist, function (index, obj) {
if (dfop.verify === obj.id)//设置默认选项
$verify.append("");
else
$verify.append("");
});
// 所占行比例初始化
var $proportion = $(document).find("#component_proportion");
$.each(proportionList, function (index, obj) {
if (dfop.proportion === obj.id)//设置默认选项
$proportion.append("");
else
$proportion.append("");
});
// 数据表选择
$('#component_table').on('change', function () {
var table = $('#component_table').find("option:selected").val();
initColumn(table, dfop.field);
dfop.table = table;
});
// 数据字段选择
$('#component_field').on('change', function () {
var field = $('#component_field').find("option:selected").val();
dfop.field = field;
});
// 字段验证选择
$('#component_verify').on('change', function () {
var verify = $('#component_verify').find("option:selected").val();
dfop.verify = verify;
});
// 所占比例选择
$('#component_proportion').on('change', function () {
var proportion = $('#component_proportion').find("option:selected").val();
dfop.proportion = proportion;
$component.css({ 'width': 100 / parseInt(dfop.proportion) + '%' });
});
return $html;
};
// 数据字典选择初始化、数据源选择初始化
function createDatasource(dfop) {
// 数据源类型
var $sourceType = $(document).find("#component_dataSourceType");
$.each(dataSourceTypeList, function (index, obj) {
if (dfop.dataSourceType === obj.id)//设置默认选项
$sourceType.append("");
else
$sourceType.append("");
});
//根据数据类型展示数据源选项或地址
var sourceType = $("#component_dataSourceType").find("option:selected").val();
if (sourceType === "1") {//数据字典
initDataSource(dfop.dataSource);
$(".dataItemCode").show();
$(".dataItemUrl").hide();
} else {
$(".dataItemCode").hide();
$(".dataItemUrl").show();
}
dfop.dataSourceType = sourceType;
// 数据源选择
$('#component_dataSourceType').on('change', function () {
sourceType = $('#component_dataSourceType').find("option:selected").val();
if (sourceType === "1") {//数据字典
initDataSource(dfop.dataSource);
$(".dataItemCode").show();
$(".dataItemUrl").hide();
} else {
$(".dataItemCode").hide();
$(".dataItemUrl").show();
}
dfop.dataSourceType = sourceType;
});
// 数据字典选择
$("#component_dataSource").on('change', function () {
var dataSource = $('#component_dataSource').find("option:selected").val();
dfop.dataSource = dataSource;
});
}
// 编辑表格初始化
function initGridTable($component) {
var dfop = $component[0].dfop;
var $html = $(".z-custmerform-designer-layout-right .mCSB_container");
var html = '