提交 9657a0f0 编写于 作者: Skyeye云's avatar Skyeye云

表单组件新增适用范围属性

上级 dad93486
......@@ -4,7 +4,7 @@ layui.config({
version: skyeyeVersion
}).extend({
window: 'js/winui.window'
}).define(['window', 'table', 'jquery', 'winui'].concat(dsFormUtil.mastHaveImport), function (exports) {
}).define(['window', 'table', 'jquery', 'winui', 'eleTree'].concat(dsFormUtil.mastHaveImport), function (exports) {
winui.renderColor();
var index = parent.layer.getFrameIndex(window.name);
var $ = layui.$,
......@@ -21,6 +21,8 @@ layui.config({
skyeyeClassEnumUtil.showEnumDataListByClassName("dsFormShowType", 'select', "showType", '', form);
// 组件关联属性
skyeyeClassEnumUtil.showEnumDataListByClassName("componentAttr", 'verificationSelect', "attrKeys", '', form);
// 组件适用范围
skyeyeClassEnumUtil.showEnumDataListByClassName("componentApplyRange", 'radio', "applyRange", '', form);
// 根据类型获取部分功能的使用说明
systemCommonUtil.queryExplainMationByType(2, function(json) {
......@@ -34,6 +36,19 @@ layui.config({
$(data.elem).val(data.elem.checked);
});
$("#applyObjectBox").hide();
form.on('radio(applyRangeFilter)', function (data) {
if (data.value == 1) {
$("#applyObjectBox").hide();
} else {
$("#applyObjectBox").show();
AjaxPostUtil.request({url: reqBasePath + "queryServiceClassForTree", params: {}, type: 'json', method: 'GET', callback: function(json) {
json.treeRows = json.rows;
dataShowType.showData(json, 'checkboxTree', 'applyObject', '', form);
}});
}
});
var htmlEditor = CodeMirror.fromTextArea(document.getElementById("htmlContent"), codeUtil.getConfig('xml'));
var htmlDataFromEditor = CodeMirror.fromTextArea(document.getElementById("htmlDataFrom"), codeUtil.getConfig('xml'));
var jsEditor = CodeMirror.fromTextArea(document.getElementById("jsContent"), codeUtil.getConfig('text/javascript'));
......@@ -61,6 +76,8 @@ layui.config({
typeId: $("#dsFormContentType").val(),
showType: $("#showType").val(),
attrKeys: $('#attrKeys').attr('value'),
applyRange: $("#applyRange input:radio:checked").val(),
applyObject: $("#applyObject").attr("chooseId"),
linkedData: '2'
};
if ($("#linkedData").val() == 'true') {
......
......@@ -49,6 +49,8 @@ layui.config({
// 组件关联属性
var attrKeys = isNull(json.bean.attrKeys) ? '' : json.bean.attrKeys.toString();
skyeyeClassEnumUtil.showEnumDataListByClassName("componentAttr", 'verificationSelect', "attrKeys", attrKeys, form);
// 组件适用范围
skyeyeClassEnumUtil.showEnumDataListByClassName("componentApplyRange", 'radio', "applyRange", json.bean.applyRange, form);
// 根据类型获取部分功能的使用说明
systemCommonUtil.queryExplainMationByType(2, function (json) {
......@@ -69,6 +71,11 @@ layui.config({
$(data.elem).val(data.elem.checked);
});
loadRange(json.bean.applyRange, json.bean.applyObject);
form.on('radio(applyRangeFilter)', function (data) {
loadRange(data.value, null);
});
matchingLanguage();
form.render();
form.on('submit(formEditBean)', function (data) {
......@@ -89,6 +96,8 @@ layui.config({
showType: $("#showType").val(),
linkedData: '2',
attrKeys: $('#attrKeys').attr('value'),
applyRange: $("#applyRange input:radio:checked").val(),
applyObject: $("#applyObject").attr("chooseId"),
id: parent.rowId
};
if ($("#linkedData").val() == 'true') {
......@@ -113,6 +122,18 @@ layui.config({
}
});
function loadRange(type, defaultValue) {
if (type == 1) {
$("#applyObjectBox").hide();
} else {
$("#applyObjectBox").show();
AjaxPostUtil.request({url: reqBasePath + "queryServiceClassForTree", params: {}, type: 'json', method: 'GET', callback: function(json) {
json.treeRows = json.rows;
dataShowType.showData(json, 'checkboxTree', 'applyObject', JSON.stringify(defaultValue), form);
}});
}
}
// 取消
$("body").on("click", "#cancle", function() {
parent.layer.close(index);
......
......@@ -55,6 +55,17 @@
</select>
</div>
</div>
<div class="layui-form-item layui-col-xs6">
<label class="layui-form-label">适用范围<i class="red">*</i></label>
<div class="layui-input-block" id="applyRange">
</div>
</div>
<div class="layui-form-item layui-col-xs6" id="applyObjectBox">
<label class="layui-form-label">适用对象<i class="red">*</i></label>
<div class="layui-input-block" id="applyObject">
</div>
</div>
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">HTML脚本<i class="red">*</i></label>
<div class="layui-input-block">
......
......@@ -61,6 +61,17 @@
</select>
</div>
</div>
<div class="layui-form-item layui-col-xs6">
<label class="layui-form-label">适用范围<i class="red">*</i></label>
<div class="layui-input-block" id="applyRange">
</div>
</div>
<div class="layui-form-item layui-col-xs6" id="applyObjectBox">
<label class="layui-form-label">适用对象<i class="red">*</i></label>
<div class="layui-input-block" id="applyObject">
</div>
</div>
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">HTML脚本<i class="red">*</i></label>
<div class="layui-input-block">
......
......@@ -1026,8 +1026,8 @@ var dataShowType = {
form.render('checkbox');
} else if (showType == 'radio') {
// 单选框
$("#" + showBoxId).html(getDataUseHandlebars('{{#each rows}}<input type="radio" name="' + showBoxId + 'Name" value="{{id}}" title="{{name}}" />{{/each}}', json));
if (!isNull(defaultId) || defaultId == 0) {
$("#" + showBoxId).html(getDataUseHandlebars(`{{#each rows}}<input type="radio" name="${showBoxId}Name" lay-filter="${showBoxId}Filter" value="{{id}}" title="{{name}}" />{{/each}}`, json));
if (!isNull(defaultId) || defaultId + '' == '0') {
$("#" + showBoxId + " input:radio[name=" + showBoxId + "Name][value=" + defaultId + "]").attr("checked", true);
} else {
$.each(json.rows, function (i, item) {
......@@ -1106,8 +1106,8 @@ var dataShowType = {
}
});
});
} else if (showType == 'radioTree') {
// 单选框树
} else if (showType == 'radioTree' || showType == 'checkboxTree') {
// 单选框树/多选框树
var _html = sysDictDataUtil.getShowTteeHtml(showBoxId, '0');
var _js = `<script>
layui.define(["jquery", 'fsTree'], function(exports) {
......@@ -1120,12 +1120,21 @@ var dataShowType = {
simpleData: '` + JSON.stringify(json.treeRows) + `',
checkEnable: true,
loadEnable: false,
chkStyle: "radio",
chkStyle: '${showType}' == 'radioTree' ? "radio" : "checkbox",
showLine: false,
showIcon: true,
expandSpeed: 'fast',
onCheck: function (event, treeId, treeNode) {
$('#${showBoxId}').attr('chooseId', treeNode.id);
if ('${showType}' == 'checkboxTree') {
var zTree = ${showBoxId}Object.getCheckedNodes(true);
var ids = [];
$.each(zTree, function(i, item) {
ids.push(item.id);
});
$('#${showBoxId}').attr('chooseId', JSON.stringify(ids));
} else {
$('#${showBoxId}').attr('chooseId', treeNode.id);
}
}
}, function(id) {
${showBoxId}Object = $.fn.zTree.getZTreeObj(id);
......@@ -1134,11 +1143,20 @@ var dataShowType = {
if (` + !isNull(defaultId) + `) {
var zTree = ${showBoxId}Object.getCheckedNodes(false);
for (var i = 0; i < zTree.length; i++) {
if(zTree[i].id == '` + defaultId + `'){
${showBoxId}Object.checkNode(zTree[i], true, true);
$('#${showBoxId}').attr('chooseId', zTree[i].id);
if ('${showType}' == 'checkboxTree') {
if($.inArray(zTree[i].id, ${defaultId}) >= 0){
${showBoxId}Object.checkNode(zTree[i], true, true);
}
} else {
if(zTree[i].id == '` + defaultId + `'){
${showBoxId}Object.checkNode(zTree[i], true, true);
$('#${showBoxId}').attr('chooseId', zTree[i].id);
}
}
}
if ('${showType}' == 'checkboxTree') {
$('#${showBoxId}').attr('chooseId', JSON.stringify(` + defaultId + `));
}
}
})(jQuery);});
</script>`;
......
......@@ -40,6 +40,7 @@
"dsFormPageType": {"name": "表单布局类型", "className": "skyeye-pro#com.skyeye.dsform.classenum.DsFormPageType"},
"attrKeyDataType": {"name": "表单布局里面的组件关联的数据类型", "className": "skyeye-pro#com.skyeye.attr.classenum.AttrKeyDataType"},
"componentAttr": {"name": "组件关联的属性", "className": "skyeye-pro#com.skyeye.dsform.classenum.ComponentAttr"},
"componentApplyRange": {"name": "组件适用范围类型", "className": "skyeye-pro#com.skyeye.dsform.classenum.ComponentApplyRange"},
"buttonColorType": {"name": "操作按钮颜色", "className": "skyeye-pro#com.skyeye.attr.classenum.ButtonColorType"},
"eventType": {"name": "操作按钮事件类型", "className": "skyeye-pro#com.skyeye.operate.classenum.EventType"},
"operatePosition": {"name": "操作按钮展示位置", "className": "skyeye-pro#com.skyeye.operate.classenum.OperatePosition"}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册