Browse Source

【修改】自定义表单设计:多选框、单选框增加条件验证选择;发起流程-保存草稿:增加表单数据验证;表单设计-查看历史记录:预览模板修改为预览选中记录的表单;

金隅分支
dyy 3 years ago
parent
commit
199b80a437
5 changed files with 121 additions and 58 deletions
  1. +2
    -1
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_FormModule/Views/Custmerform/HistoryForm.js
  2. +10
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_NewWorkFlow/Views/NWFProcess/NWFContainerForm.js
  3. +40
    -40
      Learun.Framework.Ultimate V7/Learun.Application.Web/Views/LR_Content/plugin/custmerform/lr-formcomponts.js
  4. +58
    -16
      Learun.Framework.Ultimate V7/Learun.Application.Web/Views/LR_Content/plugin/custmerform/lr-formrender.js
  5. +11
    -1
      Learun.Framework.Ultimate V7/Learun.Application.Web/Views/LR_Content/script/lr-validator.js

+ 2
- 1
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_FormModule/Views/Custmerform/HistoryForm.js View File

@@ -32,7 +32,8 @@ var bootstrap = function ($, learun) {
learun.layerForm({
id: 'custmerForm_PreviewForm',
title: '预览当前表单',
url: top.$.rootUrl + '/LR_FormModule/Custmerform/PreviewForm?schemeInfoId=' + keyValue,
//url: top.$.rootUrl + '/LR_FormModule/Custmerform/PreviewForm?schemeInfoId=' + keyValue,//预览当前版本表单
url: top.$.rootUrl + '/LR_FormModule/Custmerform/PreviewForm?schemeId=' + schemeId,//预览选中表单
width: 800,
height: 600,
maxmin: true,


+ 10
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_NewWorkFlow/Views/NWFProcess/NWFContainerForm.js View File

@@ -309,6 +309,11 @@ var bootstrap = function ($, learun) {
//$('#savedraft').show();
$('#savedraft').showBtn();
$('#savedraft').on('click', function () {
// 验证表单数据完整性
if (!custmerForm.validForm('create'))// create创建流程
{
return false;
}
tabProcessId = nwflow.processId;
// 保存表单数据
custmerForm.save(nwflow.processId, nwflow.currentNode.wfForms, function () {
@@ -490,6 +495,11 @@ var bootstrap = function ($, learun) {
//$('#savedraft').show();
$('#savedraft').showBtn();
$('#savedraft').on('click', function () {
// 验证表单数据完整性
if (!custmerForm.validForm('create'))// create创建流程
{
return false;
}
tabProcessId = nwflow.processId;
// 保存表单数据
custmerForm.save(nwflow.processId, nwflow.currentNode.wfForms, function () {


+ 40
- 40
Learun.Framework.Ultimate V7/Learun.Application.Web/Views/LR_Content/plugin/custmerform/lr-formcomponts.js View File

@@ -137,7 +137,7 @@
type: "html",
proportion: '1',
};
$component.html(getComponentRowHtml({ name: "富文本" , text: "富文本" }));
$component.html(getComponentRowHtml({ name: "富文本", text: "富文本" }));
},
property: function ($component) {
var dfop = $component[0].dfop;
@@ -421,6 +421,7 @@
table: '',
field: "",
proportion: '1',
verify: '',

dataSource: '0', // 0数据字典1数据源
dataSourceId: '',
@@ -431,7 +432,7 @@
},
property: function ($component) {
var dfop = $component[0].dfop;
var $html = setComponentPropertyHtml($component);
var $html = setComponentPropertyHtml($component,verifyDatalist2);
var _html = '';
_html += '<div class="lr-component-title">数据来源</div>';
_html += '<div class="lr-component-control"><div id="lr_component_dataSource"></div></div>';
@@ -459,7 +460,7 @@
setDatasource(dfop);
},
renderTable: function (compont, $row) {//使用表单的时候渲染成table
var $compont = $('<div class="radio"></div>');
var $compont = $('<div id="' + compont.id + '" class="radio"></div>');
/*获取数据字典或者数据源数据*/
if (compont.dataSource == '0') {
learun.clientdata.getAllAsync('dataItem', {
@@ -488,7 +489,7 @@
return $compont;
},
renderQuery: function (compont, $row) {
var $compont = $('<div class="radio"></div>');
var $compont = $('<div id="' + compont.id + '" class="radio"></div>');
/*获取数据字典或者数据源数据*/
if (compont.dataSource == '0') {
learun.clientdata.getAllAsync('dataItem', {
@@ -530,17 +531,18 @@
table: '',
field: "",
proportion: '1',
verify: '',

dataSource: '0', // 0数据字典1数据源
dataSourceId: '',
itemCode:'',
itemCode: '',
dfvalue: '' // 默认值
};
$component.html(getComponentRowHtml({ name: $component[0].dfop.title, text: "多选项" }));
},
property: function ($component) {
var dfop = $component[0].dfop;
var $html = setComponentPropertyHtml($component);
var $html = setComponentPropertyHtml($component, verifyDatalist2);
var _html = '';
_html += '<div class="lr-component-title">数据来源</div>';
_html += '<div class="lr-component-control"><div id="lr_component_dataSource"></div></div>';
@@ -567,7 +569,7 @@
setDatasource(dfop);
},
renderTable: function (compont, $row) {//使用表单的时候渲染成table
var $compont = $('<div class="checkbox"></div>');
var $compont = $('<div id="' + compont.id + '" class="checkbox"></div>');
/*获取数据字典或者数据源数据*/
if (compont.dataSource == '0') {
learun.clientdata.getAllAsync('dataItem', {
@@ -597,7 +599,7 @@
return $compont;
},
renderQuery: function (compont, $row) {
var $compont = $('<div class="checkbox"></div>');
var $compont = $('<div id="' + compont.id + '" class="checkbox"></div>');
/*获取数据字典或者数据源数据*/
if (compont.dataSource == '0') {
learun.clientdata.getAllAsync('dataItem', {
@@ -643,7 +645,7 @@

dataSource: '0', // 0数据字典1数据源
dataSourceId: '',
itemCode:'',
itemCode: '',
dfvalue: '' // 默认值
};
$component.html(getComponentRowHtml({ name: $component[0].dfop.title, text: "下拉框" }));
@@ -1000,7 +1002,7 @@

_html += '<div class="lr-component-title lrrelation">单位组织控件级联-上一级</div>';
_html += '<div class="lr-component-control lrrelation"><div id="lr_component_relation"></div></div>';
$html.append(_html);
// 设置多语言
$html.find('.lr-component-title').each(function () {
@@ -1024,11 +1026,11 @@
data: organizes,
value: 'id',
text: 'text',
select: function (item,type) {
select: function (item, type) {
if (!!item) {
dfop.relation = item.id;
}
else if (type !== 'refresh'){
else if (type !== 'refresh') {
dfop.relation = '';
}
}
@@ -1148,7 +1150,7 @@
url: top.$.rootUrl + '/LR_OrganizationModule/Department/GetTree',
param: {}
});
}
}
break;
case "company"://公司
$compont.lrCompanySelect({});
@@ -1337,7 +1339,7 @@
}
}

if (compont.isHide == '1') {
$row.hide();
}
@@ -1350,18 +1352,18 @@
$row.append($compont);

switch (compont.dataType) {
case 'company':
$compont.lrCompanySelect({ type: 'multiple' })
break;
case 'department':
$compont.lrDepartmentSelect();
break;
case 'user':
$compont.lrUserSelect({ type: '1' })
break;
case 'role':
$compont.lrPostSelect({ type: 'treemultiple' });
break;
case 'company':
$compont.lrCompanySelect({ type: 'multiple' })
break;
case 'department':
$compont.lrDepartmentSelect();
break;
case 'user':
$compont.lrUserSelect({ type: '1' })
break;
case 'role':
$compont.lrPostSelect({ type: 'treemultiple' });
break;
}
if (compont.isHide == '1') {
$row.hide();
@@ -1633,7 +1635,7 @@
var $compont = $('<div id="' + compont.id + '"></div>');
$row.append($compont);
compont.hideData = [];
var headData = toGirdheadData(compont.fieldsData, compont.hideData, $compont);
if (!!compont.preloadDb && !!compont.preloadTable) {
$compont.jfGrid({
@@ -1783,8 +1785,7 @@
}
}
});
if (!!designerDfop.dbTable && designerDfop.dbTable.length > 0)
{
if (!!designerDfop.dbTable && designerDfop.dbTable.length > 0) {
$('#lr_component_table').lrselectSet(dfop.table || designerDfop.dbTable[0].name);
}
// 标题设置
@@ -1851,7 +1852,7 @@
};
// 数据字典选择初始化、数据源选择初始化
function setDatasource(dfop) {
$('#lr_component_dfvalue').lrselect({
$('#lr_component_dfvalue').lrselect({
allowSearch: true,
select: function (item) {
if (!!item) {
@@ -1872,7 +1873,7 @@
allowSearch: true,
url: top.$.rootUrl + '/LR_SystemModule/DataItem/GetClassifyTree',
type: 'tree',
value:'value',
value: 'value',
select: function (item) {
if (!!item) {
if (dfop.dataSourceId != item.id) {
@@ -1918,7 +1919,7 @@
vlist[1] = item.value;
dfop.dataSourceId = String(vlist);
if (vlist[2] != '') {
learun.clientdata.getAllAsync('sourceData', {
code: vlist[0],
callback: function (dataes) {
@@ -1972,12 +1973,12 @@
url: top.$.rootUrl + '/LR_SystemModule/DataSource/GetList',
value: 'F_Code',
text: 'F_Name',
title:'F_Name',
title: 'F_Name',
select: function (item) {
if (item) {
if (dfop.dataSourceId != '') {
var vlist = dfop.dataSourceId.split(',');
if (vlist.length <3 || vlist[0] != item.F_Code) {
if (vlist.length < 3 || vlist[0] != item.F_Code) {
vlist[1] = '';
vlist[2] = '';
dfop.dataSourceId = item.F_Code + ',,';
@@ -1989,7 +1990,7 @@
dfop.dfvalue = '';
}
//$('#lr_component_dfvalue').lrselectRefresh({ url: '', data: [] });

//获取字段数据
learun.httpAsync('GET', top.$.rootUrl + '/LR_SystemModule/DataSource/GetDataColName', { code: item.F_Code }, function (data) {
@@ -2009,7 +2010,7 @@
data: fieldData,
placeholder: false
});
$('#lr_component_dataSourceId2').lrselectSet(vlist[2] ||fieldData[0].value);
$('#lr_component_dataSourceId2').lrselectSet(vlist[2] || fieldData[0].value);
});
}
else {
@@ -2034,7 +2035,7 @@
$('#lr_component_dataItemCode').lrselectSet(dfop.itemCode);
}
else {
var valuelist = dfop.dataSourceId.split(',');
var valuelist = dfop.dataSourceId.split(',');
$('#lr_component_dataSourceId').lrselectSet(valuelist[0]);
}

@@ -2191,7 +2192,7 @@
delete pIds[item['id']];
}
}
});
for (var id in pIds) {
_fn(resdata, id);
@@ -2213,8 +2214,7 @@
return resdata;
}
// html编码
function htmlEncode(text)
{
function htmlEncode(text) {
text = text || "";
text = text.replace(/%/g, "{@bai@}");
text = text.replace(/ /g, "{@kong@}");


+ 58
- 16
Learun.Framework.Ultimate V7/Learun.Application.Web/Views/LR_Content/plugin/custmerform/lr-formrender.js View File

@@ -70,21 +70,21 @@
compontsMap[compont.table + compont.field.toLowerCase()] = compont.id;
}
//验证表单字段权限
// if (compont.id in authorizeField || compont.type == 'guid') {
var $row = $('<div class="col-xs-' + (12 / parseInt(compont.proportion)) + ' lr-form-item" ></div>');
var $title = $(' <div class="lr-form-item-title">' + compont.title + getFontHtml(compont.verify) + '</div>');
if (compont.title != '') {
$row.append($title);
}
$content.append($row);
var $compont = $.lrFormComponents[compont.type].renderTable(compont, $row);
if (!!$compont && !!compont.verify && compont.verify != "") {
$compont.attr('isvalid', 'yes').attr('checkexpession', compont.verify);
}
if (compont.type == 'girdtable') {
girdCompontMap[compont.table] = compont;
}
// }
// if (compont.id in authorizeField || compont.type == 'guid') {
var $row = $('<div class="col-xs-' + (12 / parseInt(compont.proportion)) + ' lr-form-item" ></div>');
var $title = $(' <div class="lr-form-item-title">' + compont.title + getFontHtml(compont.verify) + '</div>');
if (compont.title != '') {
$row.append($title);
}
$content.append($row);
var $compont = $.lrFormComponents[compont.type].renderTable(compont, $row);
if (!!$compont && !!compont.verify && compont.verify != "") {
$compont.attr('isvalid', 'yes').attr('checkexpession', compont.verify);
}
if (compont.type == 'girdtable') {
girdCompontMap[compont.table] = compont;
}
// }
}


@@ -106,6 +106,7 @@
$.lrValidCustmerform = function () {
var validateflag = true;
var validHelper = learun.validator;
$('body').find("[isvalid=yes]").each(function () {
var $this = $(this);
if ($this.parent().find('.lr-field-error-info').length > 0) {
@@ -126,7 +127,27 @@
value = $this.lrformselectGet();
}
else {
value = $this.val();
if ($this.hasClass("checkbox")) {//多选框
var checkedList = $this.find("input[name='" + $this.attr('id') + "']:checked");
if (checkedList.length > 0) {
value = '';
$.each(checkedList, function (i, item) {
if (value != '' && value != undefined) {
value += ',';
}
value += $(item).val();
});
}
}
else if ($this.hasClass("radio")) {//单选框
var checkedList = $this.find("input[name='" + $this.attr('id') + "']:checked");
if (checkedList.length > 0) {
value = checkedList.val();
}
}
else {
value = $this.val();
}
}
var r = { code: true, msg: '' };
if (checkexpession == 'LenNum' || checkexpession == 'LenNumOrNull' || checkexpession == 'LenStr' || checkexpession == 'LenStrOrNull') {
@@ -236,6 +257,12 @@
if ($obj.hasClass("lr-input-wdatepicker")) {
type = "datepicker";
}
else if ($obj.hasClass("checkbox")) {
type = "checkbox";
}
else if ($obj.hasClass("radio")) {
type = "radio";
}
switch (type) {
case "lrselect":
$obj.lrselectSet(value);
@@ -243,6 +270,21 @@
case "formselect":
$obj.lrformselectSet(value);
break;
case "checkbox":
$obj.find('input[name="' + id + '"]:checked').trigger('click');
if (value != null && value != undefined && value != '') {
vs = value.split(',');
for (var i = 0; i < vs.length; i++) {
$obj.find('input[name="' + id + '"][value="' + vs[i] + '"]').trigger('click');
}
}
break;
case "radio":
$obj.find('input[name="' + id + '"]:checked').trigger('click');
if (value != null && value != undefined && value != '') {
$obj.find('input[name="' + id + '"][value="' + value + '"]').trigger('click');
}
break;
case "datepicker":
if ($obj.attr('dateformat') == "0") {
$obj.val(learun.formatDate(value, 'yyyy-MM-dd'));


+ 11
- 1
Learun.Framework.Ultimate V7/Learun.Application.Web/Views/LR_Content/script/lr-validator.js View File

@@ -12,7 +12,7 @@
/*错误处理*/
$this.addClass('lr-field-error');
$this.parent().append('<div class="lr-field-error-info" title="' + errormsg + '!"><i class="fa fa-info-circle"></i></div>');
var validatemsg = $this.parent().find('.form-item-title').text() + ' ' + errormsg;
var validatemsg = $this.parent().find('.lr-form-item-title').text() + ' ' + errormsg;
learun.alert.error('表单信息输入有误,请检查!</br>' + validatemsg);
if ($this.attr('type') == 'lrselect') {
$this.on('change', function () {
@@ -32,6 +32,16 @@
}
});
}
else if ($this.hasClass('checkbox')) {
$this.on('change', function () {
removeErrorMessage($(this));
});
}
else if ($this.hasClass('radio')) {
$this.on('change', function () {
removeErrorMessage($(this));
});
}
else {
$this.on('input propertychange', function () {
var $input = $(this);


Loading…
Cancel
Save