提交 a7c79f12 编写于 作者: doc_wei's avatar doc_wei

动态表单模块迁移到基础模块

上级 54ed26c9
......@@ -39,7 +39,12 @@ layui.config({
{ field: 'attrKey', title: '属性', align: 'left', width: 150 },
{ field: 'name', title: '名称', align: 'left', width: 120 },
{ field: 'attrType', title: '类型', align: 'left', width: 120 },
{ field: 'remark', title: '备注', align: 'left', width: 150 },
{ field: 'componentName', title: '关联组件', align: 'left', width: 140, templet: function (d) {
if (!isNull(d.dsFormComponent)) {
return d.dsFormComponent.name;
}
return '';
}},
{ field: 'required', title: '限制条件', align: 'left', width: 140 },
{ field: 'modelAttribute', title: '是否模型属性', align: 'center', width: 100, templet: function (d) {
if (d.modelAttribute) {
......@@ -53,6 +58,7 @@ layui.config({
}
return '';
}},
{ field: 'remark', title: '备注', align: 'left', width: 150 },
{ title: systemLanguage["com.skyeye.operation"][languageType], fixed: 'right', align: 'center', width: 120, toolbar: '#tableBar' }
]],
done: function(json) {
......
......@@ -4,7 +4,7 @@ layui.config({
version: skyeyeVersion
}).extend({
window: 'js/winui.window'
}).define(['window', 'jquery', 'winui', 'form', 'textool'], function (exports) {
}).define(['window', 'jquery', 'winui', 'form', 'textool', 'eleTree'], function (exports) {
winui.renderColor();
var index = parent.layer.getFrameIndex(window.name);
var $ = layui.$,
......@@ -18,6 +18,19 @@ layui.config({
$("#showForm").html(getDataUseHandlebars($("#beanTemplate").html(), json));
textool.init({eleId: 'remark', maxlength: 200});
// 加载组件信息
treeSelectUtil.init({
eleTree: layui.eleTree,
elem: 'componentId',
url: reqBasePath + "queryAllDsFormComponentList",
defaultId: json.bean.componentId
});
// 如果不是入参属性,则不能设置特定的一些值
if (!json.bean.attrDefinition.whetherInputParams) {
$('.inputParams').hide();
}
var id = isNull(json.bean.id) ? '' : json.bean.id;
matchingLanguage();
form.render();
......@@ -27,6 +40,9 @@ layui.config({
className: className,
attrKey: attrKey,
name: $("#name").val(),
componentId: isNull($("#componentId").val()) ? "" : $("#componentId").attr("componentId"),
minLength: $("#minLength").val(),
maxLength: $("#maxLength").val(),
remark: $("#remark").val(),
id: id
};
......
......@@ -27,7 +27,27 @@
<div class="layui-form-item layui-col-xs6">
<label class="layui-form-label">名称<i class="red">*</i></label>
<div class="layui-input-block">
<input type="text" id="name" name="name" win-verify="required" placeholder="请输入名称" class="layui-input" maxlength="10" value="{{name}}"/>
<input type="text" id="name" name="name" win-verify="required" placeholder="请输入名称" class="layui-input" maxlength="100" value="{{name}}"/>
</div>
</div>
<div class="inputParams">
<div class="layui-form-item layui-col-xs6">
<label class="layui-form-label">组件</label>
<div class="layui-input-block">
<input type="text" id="componentId" name="componentId" placeholder="请选择组件" class="layui-input" readonly="readonly" componentId=""/>
</div>
</div>
<div class="layui-form-item layui-col-xs6">
<label class="layui-form-label">最小长度</label>
<div class="layui-input-block">
<input type="text" id="minLength" name="minLength" win-verify="number" placeholder="请输入最小长度" class="layui-input" value="{{minLength}}"/>
</div>
</div>
<div class="layui-form-item layui-col-xs6">
<label class="layui-form-label">最大长度</label>
<div class="layui-input-block">
<input type="text" id="maxLength" name="maxLength" win-verify="number" placeholder="请输入最大长度" class="layui-input" value="{{maxLength}}"/>
</div>
</div>
</div>
<div class="layui-form-item layui-col-xs12">
......
......@@ -48,7 +48,7 @@ layui.config({
initDatatpl = true;
showGrid({
id: "displayTemplateId",
url: flowableBasePath + "dsformdisplaytemplate006",
url: reqBasePath + "dsformdisplaytemplate006",
params: {},
pagination: false,
method: 'GET',
......@@ -68,9 +68,9 @@ layui.config({
} else {
$.each(jsonStr, function(i, item) {
if (displayTemplateValue == item.id) {
var str = '<textarea class="layui-textarea" readonly>' + item.templateContent + '</textarea>';
var str = '<textarea class="layui-textarea" readonly>' + item.content + '</textarea>';
$("#templateContent").html(str);
tplContentVal = strMatchAllByTwo(item.templateContent, '{{','}}');//取出数据模板中用{{}}包裹的词
tplContentVal = strMatchAllByTwo(item.content, '{{','}}');//取出数据模板中用{{}}包裹的词
removeByValue(tplContentVal, "#each this");
removeByValue(tplContentVal, "/each");
return false;
......@@ -138,7 +138,7 @@ layui.config({
if (!params["iconChooseResult"]) {
return false;
}
AjaxPostUtil.request({url: flowableBasePath + "writeDsFormComponent", params: params, type: 'json', method: 'POST', callback: function(json) {
AjaxPostUtil.request({url: reqBasePath + "writeDsFormComponent", params: params, type: 'json', method: 'POST', callback: function(json) {
parent.layer.close(index);
parent.refreshCode = '0';
}});
......
......@@ -16,7 +16,7 @@ layui.config({
showGrid({
id: "showForm",
url: flowableBasePath + "queryDsFormComponentMationById",
url: reqBasePath + "queryDsFormComponentMationById",
params: {id: parent.rowId},
pagination: false,
method: 'GET',
......@@ -66,9 +66,9 @@ layui.config({
if (json.bean.linkedData == 1) {
$(".dataTpl").removeClass("layui-hide");
initDisplayTemplate(json.bean.displayTemplateId);//初始化关联的数据类型
var str = '<textarea class="layui-textarea" readonly>' + json.bean.templateContent + '</textarea>';
var str = '<textarea class="layui-textarea" readonly>' + json.bean.dsFormDisplayTemplate.content + '</textarea>';
$("#templateContent").html(str);
tplContentVal = strMatchAllByTwo(json.bean.templateContent, '{{', '}}');//取出数据模板中用{{}}包裹的词
tplContentVal = strMatchAllByTwo(json.bean.dsFormDisplayTemplate.content, '{{', '}}');//取出数据模板中用{{}}包裹的词
removeByValue(tplContentVal, "#each this");
removeByValue(tplContentVal, "/each");
}
......@@ -93,7 +93,7 @@ layui.config({
initDatatpl = true;
showGrid({
id: "displayTemplateId",
url: flowableBasePath + "dsformdisplaytemplate006",
url: reqBasePath + "dsformdisplaytemplate006",
params: {},
pagination: false,
method: 'GET',
......@@ -114,9 +114,9 @@ layui.config({
} else {
$.each(jsonStr, function(i, item) {
if (displayTemplateValue == item.id) {
var str = '<textarea class="layui-textarea" readonly>' + item.templateContent + '</textarea>';
var str = '<textarea class="layui-textarea" readonly>' + item.content + '</textarea>';
$("#templateContent").html(str);
tplContentVal = strMatchAllByTwo(item.templateContent, '{{','}}');//取出数据模板中用{{}}包裹的词
tplContentVal = strMatchAllByTwo(item.content, '{{','}}');//取出数据模板中用{{}}包裹的词
removeByValue(tplContentVal, "#each this");
removeByValue(tplContentVal, "/each");
return false;
......@@ -180,7 +180,7 @@ layui.config({
return false;
}
AjaxPostUtil.request({url: flowableBasePath + "writeDsFormComponent", params: params, type: 'json', method: 'POST', callback: function (json) {
AjaxPostUtil.request({url: reqBasePath + "writeDsFormComponent", params: params, type: 'json', method: 'POST', callback: function (json) {
parent.layer.close(index);
parent.refreshCode = '0';
}});
......
......@@ -18,7 +18,7 @@ layui.config({
id: 'messageTable',
elem: '#messageTable',
method: 'post',
url: flowableBasePath + 'queryDsFormComponentList',
url: reqBasePath + 'queryDsFormComponentList',
where: getTableParams(),
even: true,
page: true,
......@@ -65,7 +65,7 @@ layui.config({
function del(data, obj) {
layer.confirm(systemLanguage["com.skyeye.deleteOperationMsg"][languageType], {icon: 3, title: systemLanguage["com.skyeye.deleteOperation"][languageType]}, function (index) {
layer.close(index);
AjaxPostUtil.request({url: flowableBasePath + "deleteDsFormComponentMationById", params: {id: data.id}, type: 'json', method: 'DELETE', callback: function (json) {
AjaxPostUtil.request({url: reqBasePath + "deleteDsFormComponentMationById", params: {id: data.id}, type: 'json', method: 'DELETE', callback: function (json) {
winui.window.msg(systemLanguage["com.skyeye.deleteOperationSuccessMsg"][languageType], {icon: 1, time: 2000});
loadTable();
}});
......
......@@ -39,7 +39,7 @@ layui.config({
name: $("#name").val(),
content: encodeURIComponent(content.getValue())
};
AjaxPostUtil.request({url: flowableBasePath + "writeDsFormDisplayTemplate", params: params, type: 'json', method: 'POST', callback: function (json) {
AjaxPostUtil.request({url: reqBasePath + "writeDsFormDisplayTemplate", params: params, type: 'json', method: 'POST', callback: function (json) {
parent.layer.close(index);
parent.refreshCode = '0';
}});
......
......@@ -13,7 +13,7 @@ layui.config({
showGrid({
id: "showForm",
url: flowableBasePath + "dsformdisplaytemplate004",
url: reqBasePath + "dsformdisplaytemplate004",
params: {id: parent.rowId},
pagination: false,
method: 'GET',
......@@ -52,7 +52,7 @@ layui.config({
content: encodeURIComponent(content.getValue()),
id: parent.rowId
};
AjaxPostUtil.request({url: flowableBasePath + "writeDsFormDisplayTemplate", params: params, type: 'json', method: 'POST', callback: function (json) {
AjaxPostUtil.request({url: reqBasePath + "writeDsFormDisplayTemplate", params: params, type: 'json', method: 'POST', callback: function (json) {
parent.layer.close(index);
parent.refreshCode = '0';
}});
......
......@@ -31,7 +31,7 @@ layui.config({
id: 'messageTable',
elem: '#messageTable',
method: 'post',
url: flowableBasePath + 'dsformdisplaytemplate001',
url: reqBasePath + 'dsformdisplaytemplate001',
where: getTableParams(),
even: true,
page: true,
......@@ -85,7 +85,7 @@ layui.config({
function del(data, obj) {
layer.confirm(systemLanguage["com.skyeye.deleteOperationMsg"][languageType], {icon: 3, title: systemLanguage["com.skyeye.deleteOperation"][languageType]}, function (index) {
layer.close(index);
AjaxPostUtil.request({url: flowableBasePath + "dsformdisplaytemplate003", params: {id: data.id}, type: 'json', method: 'DELETE', callback: function (json) {
AjaxPostUtil.request({url: reqBasePath + "dsformdisplaytemplate003", params: {id: data.id}, type: 'json', method: 'DELETE', callback: function (json) {
winui.window.msg(systemLanguage["com.skyeye.deleteOperationSuccessMsg"][languageType], {icon: 1, time: 2000});
loadTable();
}});
......
......@@ -19,7 +19,7 @@ layui.config({
authBtn('1567732055673');//保存控件
AjaxPostUtil.request({url: flowableBasePath + "dsformpage004", params: {pageId: parent.rowId}, type: 'json', method: 'GET', callback: function (json) {
AjaxPostUtil.request({url: reqBasePath + "dsformpage004", params: {pageId: parent.rowId}, type: 'json', method: 'GET', callback: function (json) {
// 加载表单控件
loadLeftBoxItem();
// 加载拖拽
......@@ -37,7 +37,7 @@ layui.config({
}
item.context = getDataUseHandlebars(item.dsFormComponent.templateContent, obj);
} else if (item.associatedDataTypes == 2) {//接口
AjaxPostUtil.request({url: flowableBasePath + "dsformpage011", params: {interfa: item.aData}, type: 'json', callback: function(j){
AjaxPostUtil.request({url: reqBasePath + "dsformpage011", params: {interfa: item.aData}, type: 'json', callback: function(j){
var obj = JSON.parse(j.bean.aData);
item.context = getDataUseHandlebars(item.dsFormComponent.templateContent, obj);
}, async: false});
......@@ -83,7 +83,7 @@ layui.config({
function loadLeftBoxItem(){
showGrid({
id: "btnBox",
url: flowableBasePath + "queryDsFormComponentMationToShow",
url: reqBasePath + "queryAllDsFormComponentList",
params: {},
pagination: false,
method: 'GET',
......@@ -179,7 +179,7 @@ layui.config({
// 保存“新增控件”
function reqSaveData(params, templateContent){
AjaxPostUtil.request({url: flowableBasePath + "dsformpage003", params: params, type: 'json', callback: function (json) {
AjaxPostUtil.request({url: reqBasePath + "dsformpage003", params: params, type: 'json', callback: function (json) {
winui.window.msg(systemLanguage["com.skyeye.successfulOperation"][languageType], {icon: 1, time: 2000});
loadNewControl(json.bean);
loadFormItemDrop();
......@@ -382,7 +382,7 @@ layui.config({
winui.window.msg('保存页面不能为空!', {icon: 2, time: 2000});
return;
}
AjaxPostUtil.request({url: flowableBasePath + "dsformpage009", params: {formedit: JSON.stringify(jsonArray)}, type: 'json', callback: function (json) {
AjaxPostUtil.request({url: reqBasePath + "dsformpage009", params: {formedit: JSON.stringify(jsonArray)}, type: 'json', callback: function (json) {
winui.window.msg("保存成功", {icon: 1, time: 2000});
parent.refreshCode = '0';
}});
......
......@@ -39,7 +39,7 @@ layui.config({
id: 'messageTable',
elem: '#messageTable',
method: 'post',
url: flowableBasePath + 'dsformpage001',
url: reqBasePath + 'dsformpage001',
where: getTableParams(),
even: true,
page: true,
......
......@@ -18,7 +18,7 @@ layui.config({
name: $("#name").val(),
remark: $("#remark").val()
};
AjaxPostUtil.request({url: flowableBasePath + "writeDsFormPage", params: params, type: 'json', method: "POST", callback: function (json) {
AjaxPostUtil.request({url: reqBasePath + "writeDsFormPage", params: params, type: 'json', method: "POST", callback: function (json) {
parent.layer.close(index);
parent.refreshCode = '0';
}});
......
......@@ -12,7 +12,7 @@ layui.config({
showGrid({
id: "showForm",
url: flowableBasePath + "dsformpage006",
url: reqBasePath + "dsformpage006",
params: {id: parent.rowId},
pagination: false,
method: "GET",
......@@ -28,7 +28,7 @@ layui.config({
name: $("#name").val(),
remark: $("#remark").val()
};
AjaxPostUtil.request({url: flowableBasePath + "writeDsFormPage", params: params, type: 'json', method: "POST", callback: function (json) {
AjaxPostUtil.request({url: reqBasePath + "writeDsFormPage", params: params, type: 'json', method: "POST", callback: function (json) {
parent.layer.close(index);
parent.refreshCode = '0';
}});
......
......@@ -17,7 +17,7 @@ layui.config({
id: 'messageTable',
elem: '#messageTable',
method: 'post',
url: flowableBasePath + 'dsformpage001',
url: reqBasePath + 'dsformpage001',
where: getTableParams(),
even: true,
page: true,
......@@ -83,7 +83,7 @@ layui.config({
function delet(data) {
layer.confirm(systemLanguage["com.skyeye.deleteOperationMsg"][languageType], {icon: 3, title: systemLanguage["com.skyeye.deleteOperation"][languageType]}, function (index) {
layer.close(index);
AjaxPostUtil.request({url: flowableBasePath + "deleteDsFormPage", params: {id: data.id}, type: 'json', method: "DELETE", callback: function (json) {
AjaxPostUtil.request({url: reqBasePath + "deleteDsFormPage", params: {id: data.id}, type: 'json', method: "DELETE", callback: function (json) {
winui.window.msg(systemLanguage["com.skyeye.deleteOperationSuccessMsg"][languageType], {icon: 1, time: 2000});
loadTable();
}});
......
......@@ -72,7 +72,7 @@
<div class="layui-form-item layui-col-xs12 TypeIsTwo layui-hide">
<label class="layui-form-label">接口<i class="red">*</i></label>
<div class="layui-input-block">
<input type="text" id="interfa" name="interfa" class="layui-input" placeholder="例如:http://localhost:8081/queryDsFormComponentMationToShow"/>
<input type="text" id="interfa" name="interfa" class="layui-input" placeholder="例如:http://localhost:8081/queryAllDsFormComponentList"/>
</div>
</div>
</div>
......
......@@ -89,7 +89,7 @@ layui.config({
//展现形式
showGrid({
id: "dsFormContentId",
url: flowableBasePath + "queryDsFormComponentMationToShow",
url: reqBasePath + "queryAllDsFormComponentList",
params: {},
pagination: false,
method: 'GET',
......
......@@ -140,7 +140,7 @@ layui.config({
//展现形式
showGrid({
id: "dsFormContentId",
url: flowableBasePath + "queryDsFormComponentMationToShow",
url: reqBasePath + "queryAllDsFormComponentList",
params: {},
pagination: false,
method: 'GET',
......
......@@ -140,7 +140,7 @@ layui.config({
//展现形式
showGrid({
id: "dsFormContentId",
url: flowableBasePath + "queryDsFormComponentMationToShow",
url: reqBasePath + "queryAllDsFormComponentList",
params: {},
pagination: false,
method: 'GET',
......
......@@ -967,3 +967,153 @@ var treeSelectUtil = {
};
// 数据展示方式
var dataShowType = {
/**
* 展示数据
*
* @param json 数据
* @param showType 展示类型
* @param showBoxId 展示位置
* @param defaultId 默认回显值
* @param form form对象
* @param callback 回调函数
* @param chooseCallback 如果是提供选择的树插件类型,则具备点击节点的回调事件
*/
showData: function (json, showType, showBoxId, defaultId, form, callback, chooseCallback) {
if (showType == 'select') {
// 下拉框
$("#" + showBoxId).html(getDataUseHandlebars(getFileContent('tpl/template/select-option.tpl'), json));
if (!isNull(defaultId)) {
$("#" + showBoxId).val(defaultId);
} else {
$.each(json.rows, function (i, item) {
if (item.isDefault) {
$("#" + showBoxId).val(item.id);
}
});
}
form.render('select');
} else if (showType == 'checkbox') {
// 多选框
$("#" + showBoxId).html(getDataUseHandlebars(getFileContent('tpl/template/checkbox-property.tpl'), json));
if (!isNull(defaultId)) {
var arr = defaultId.split(",");
for(var i = 0; i < arr.length; i++){
$('input:checkbox[rowId="' + arr[i] + '"]').attr("checked", true);
}
} else {
$.each(json.rows, function (i, item) {
if (item.isDefault) {
$('input:checkbox[rowId="' + item.id + '"]').attr("checked", true);
}
});
}
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)) {
$("#" + showBoxId + " input:radio[name=" + showBoxId + "Name][value=" + defaultId + "]").attr("checked", true);
} else {
$.each(json.rows, function (i, item) {
if (item.isDefault) {
$("#" + showBoxId + " input:radio[name=" + showBoxId + "Name][value=" + item.id + "]").attr("checked", true);
}
});
}
form.render('radio');
} else if (showType == 'verificationSelect') {
// 多选下拉框
var str = `<option value="">全部</option>{{#each rows}}<option value="{{formerRequirement}}">{{name}}</option>{{/each}}`;
$("#" + showBoxId).html(getDataUseHandlebars(str, json));
if (!isNull(defaultId)) {
$("#" + showBoxId).val(defaultId.split(","));
}
form.render('select');
} else if (showType == 'radioTree') {
// 单选框树
var _html = sysDictDataUtil.getShowTteeHtml(showBoxId, '0');
var _js = `<script>
layui.define(["jquery", 'fsTree'], function(exports) {
var jQuery = layui.jquery,
fsTree = layui.fsTree;
(function($) {
var ${showBoxId}Object;
fsTree.render({
id: "${showBoxId}Tree",
simpleData: '` + JSON.stringify(json.treeRows) + `',
checkEnable: true,
loadEnable: false,
chkStyle: "radio",
showLine: false,
showIcon: true,
expandSpeed: 'fast',
onCheck: function (event, treeId, treeNode) {
$('#${showBoxId}').attr('chooseId', treeNode.id);
}
}, function(id) {
${showBoxId}Object = $.fn.zTree.getZTreeObj(id);
fuzzySearch(id, '#${showBoxId}Name', null, true);
});
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);
}
}
}
})(jQuery);});
</script>`;
$("#" + showBoxId).append(_html + _js);
} else if (showType == 'selectTree') {
// 提供选择的树插件
var _html = sysDictDataUtil.getShowTteeHtml(showBoxId, '1');
_html += `<link href="../../assets/lib/winui/css/customer/ztree/common-tree.css" rel="stylesheet" />`;
var _js = `<script>
layui.define(["jquery", 'fsTree'], function(exports) {
var jQuery = layui.jquery,
fsTree = layui.fsTree;
(function($) {
fsTree.render({
id: "${showBoxId}Tree",
simpleData: '` + JSON.stringify(json.treeRows) + `',
checkEnable: false,
loadEnable: false,
showLine: false,
showIcon: true,
expandSpeed: 'fast',
addDiyDom: ztreeUtil.addDiyDom,
clickCallback: onClickTree,
onDblClick: onClickTree
}, function(id) {
fuzzySearch(id, '#${showBoxId}Name', null, true);
ztreeUtil.initEventListener(id);
});
function onClickTree(event, treeId, treeNode) {
var chooseId;
if (treeNode == undefined || treeNode.id == 0) {
chooseId = "";
} else {
chooseId = treeNode.id;
}
$('#${showBoxId}Choose').val(chooseId).change();
}
})(jQuery);});
</script>`;
$("#" + showBoxId).append(_html + _js);
$("#" + showBoxId + "Choose").on("change", function() {
if (typeof (chooseCallback) == "function") {
chooseCallback($(this).val());
}
});
}
if (typeof (callback) == "function") {
callback(json);
}
}
};
\ No newline at end of file
// 枚举类相关的工具类
var skyeyeClassEnumUtil = {
classEnumMap: {},
......@@ -15,56 +16,7 @@ var skyeyeClassEnumUtil = {
*/
showEnumDataListByClassName: function (code, showType, showBoxId, defaultId, form, callback) {
var json = skyeyeClassEnumUtil.getEnumDataListByClassName(code);
if (showType == 'select') {
$("#" + showBoxId).html(getDataUseHandlebars(getFileContent('tpl/template/select-option.tpl'), json));
if (!isNull(defaultId)) {
$("#" + showBoxId).val(defaultId);
} else {
$.each(json.rows, function (i, item) {
if (item.isDefault) {
$("#" + showBoxId).val(item.id);
}
});
}
form.render('select');
} else if (showType == 'checkbox') {
$("#" + showBoxId).html(getDataUseHandlebars(getFileContent('tpl/template/checkbox-property.tpl'), json));
if (!isNull(defaultId)) {
var arr = defaultId.split(",");
for(var i = 0; i < arr.length; i++){
$('input:checkbox[rowId="' + arr[i] + '"]').attr("checked", true);
}
} else {
$.each(json.rows, function (i, item) {
if (item.isDefault) {
$('input:checkbox[rowId="' + item.id + '"]').attr("checked", true);
}
});
}
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)) {
$("#" + showBoxId + " input:radio[name=" + showBoxId + "Name][value=" + defaultId + "]").attr("checked", true);
} else {
$.each(json.rows, function (i, item) {
if (item.isDefault) {
$("#" + showBoxId + " input:radio[name=" + showBoxId + "Name][value=" + item.id + "]").attr("checked", true);
}
});
}
form.render('radio');
} else if (showType == 'verificationSelect') {
var str = `<option value="">全部</option>{{#each rows}}<option value="{{formerRequirement}}">{{name}}</option>{{/each}}`;
$("#" + showBoxId).html(getDataUseHandlebars(str, json));
if (!isNull(defaultId)) {
$("#" + showBoxId).val(defaultId.split(","));
}
form.render('select');
}
if (typeof (callback) == "function") {
callback(json);
}
dataShowType.showData(json, showType, showBoxId, defaultId, form, callback);
},
getEnumDataNameByClassName: function (code, key, value, getKey) {
......
......@@ -29,113 +29,7 @@ var sysDictDataUtil = {
*/
showDictDataListByDictTypeCode: function (dictTypeCode, showType, showBoxId, defaultId, form, callback, chooseCallback) {
sysDictDataUtil.queryDictDataListByDictTypeCode(dictTypeCode, function (json) {
if (showType == 'select') {
$("#" + showBoxId).html(getDataUseHandlebars(getFileContent('tpl/template/select-option.tpl'), json));
if (!isNull(defaultId)) {
$("#" + showBoxId).val(defaultId);
} else {
$.each(json.rows, function (i, item) {
if (item.isDefault == 1) {
$("#" + showBoxId).val(item.id);
}
});
}
form.render('select');
} else if (showType == 'checkbox') {
$("#" + showBoxId).html(getDataUseHandlebars(getFileContent('tpl/template/checkbox-property.tpl'), json));
if (!isNull(defaultId)) {
var arr = defaultId.split(",");
for(var i = 0; i < arr.length; i++) {
$('input:checkbox[rowId="' + arr[i] + '"]').attr("checked", true);
}
} else {
$.each(json.rows, function (i, item) {
if (item.isDefault == 1) {
$('input:checkbox[rowId="' + item.id + '"]').attr("checked", true);
}
});
}
form.render('checkbox');
} else if (showType == 'radioTree') {
var _html = sysDictDataUtil.getShowTteeHtml(showBoxId, '0');
var _js = `<script>
layui.define(["jquery", 'fsTree'], function(exports) {
var jQuery = layui.jquery,
fsTree = layui.fsTree;
(function($) {
var ${showBoxId}Object;
fsTree.render({
id: "${showBoxId}Tree",
simpleData: '` + JSON.stringify(json.treeRows) + `',
checkEnable: true,
loadEnable: false,
chkStyle: "radio",
showLine: false,
showIcon: true,
expandSpeed: 'fast',
onCheck: function (event, treeId, treeNode) {
$('#${showBoxId}').attr('chooseId', treeNode.id);
}
}, function(id) {
${showBoxId}Object = $.fn.zTree.getZTreeObj(id);
fuzzySearch(id, '#${showBoxId}Name', null, true);
});
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);
}
}
}
})(jQuery);});
</script>`;
$("#" + showBoxId).append(_html + _js);
} else if (showType == 'selectTree') {
var _html = sysDictDataUtil.getShowTteeHtml(showBoxId, '1');
_html += `<link href="../../assets/lib/winui/css/customer/ztree/common-tree.css" rel="stylesheet" />`;
var _js = `<script>
layui.define(["jquery", 'fsTree'], function(exports) {
var jQuery = layui.jquery,
fsTree = layui.fsTree;
(function($) {
fsTree.render({
id: "${showBoxId}Tree",
simpleData: '` + JSON.stringify(json.treeRows) + `',
checkEnable: false,
loadEnable: false,
showLine: false,
showIcon: true,
expandSpeed: 'fast',
addDiyDom: ztreeUtil.addDiyDom,
clickCallback: onClickTree,
onDblClick: onClickTree
}, function(id) {
fuzzySearch(id, '#${showBoxId}Name', null, true);
ztreeUtil.initEventListener(id);
});
function onClickTree(event, treeId, treeNode) {
var chooseId;
if (treeNode == undefined || treeNode.id == 0) {
chooseId = "";
} else {
chooseId = treeNode.id;
}
$('#${showBoxId}Choose').val(chooseId).change();
}
})(jQuery);});
</script>`;
$("#" + showBoxId).append(_html + _js);
$("#" + showBoxId + "Choose").on("change", function() {
if (typeof (chooseCallback) == "function") {
chooseCallback($(this).val());
}
});
}
if (typeof (callback) == "function") {
callback(json);
}
dataShowType.showData(json, showType, showBoxId, defaultId, form, callback, chooseCallback);
});
},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册