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

模板加入完成

上级 3fbe28d2
......@@ -1115,6 +1115,15 @@ function showDataUseHandlebars(id, source, data){
layui.$("#" + id).html(html);
}
function getDataUseHandlebars(source, data){
//预编译模板
var template = Handlebars.compile(source);
//匹配json内容
var html = template(data);
//输入模板
return html;
}
......
var params = '';
layui.config({
base: basePath,
version: skyeyeVersion
......@@ -16,7 +18,7 @@ layui.config({
form.render('select');
form.on('select(tableColumn)', function(data){
console.log(1);
returnResult();
});
form.on('select(showModel)', function(data){
......@@ -35,7 +37,7 @@ layui.config({
jsSuccessEditor.setOption('mode', mode);
}
jsModelEditor.setValue(json.bean.jsContent);
returnResult();
}else{
top.winui.window.msg(json.returnMessage, {icon: 2,time: 2000});
}
......@@ -43,7 +45,7 @@ layui.config({
});
form.on('checkbox(checkboxLimit)', function(data){
console.log(2);
returnResult();
});
//展现形式
......@@ -127,16 +129,80 @@ layui.config({
form.on('submit(formAddBean)', function (data) {
//表单验证
if (winui.verifyForm(data.elem)) {
var result = {
formermation: params.require,
aftermation: params.aftermation,
htmlContent: htmlSuccessEditor.getValue(),
jsContent: jsSuccessEditor.getValue(),
};
parent.result = result;
parent.layer.close(index);
parent.refreshCode = '0';
}
return false;
});
$("body").on("keyup", "#placeholderName", function(e){
returnResult();
});
$("body").on("keyup", "#valueName", function(e){
returnResult();
})
function returnResult(){
var tableColumn = $("#tableColumn").val();
var labelName = "", id = "", name = "", formermation = "", aftermation = "";
if(!isNull(tableColumn)){
labelName = tableColumn.split('--')[0];
id = replaceUnderLineAndUpperCase(tableColumn.split('--')[1]);
name = replaceUnderLineAndUpperCase(tableColumn.split('--')[1]);
}
if(!isNull(htmlModelEditor.getValue())){
$.each($('input:checkbox:checked'),function(){
formermation = formermation + $(this).attr("formermation") + "|";
aftermation = aftermation + $(this).attr("aftermation") + ",";
});
params = {
labelContent: labelName,
id: id,
name: name,
require: formermation,
aftermation: aftermation,
value: $("#valueName").val(),
placeholder: $("#placeholderName").val(),
};
htmlSuccessEditor.setValue(getDataUseHandlebars(htmlModelEditor.getValue(), params));
if(!isNull(jsModelEditor.getValue())){
jsSuccessEditor.setValue(getDataUseHandlebars(jsModelEditor.getValue(), params));
}
}
}
//取消
$("body").on("click", "#cancle", function(){
parent.layer.close(index);
});
/**
* 将字段转为Java经常使用的名字,如code_model转codeModel
*/
function replaceUnderLineAndUpperCase(str){
str = str.split("");
var count = str.indexOf("_");
while (count != 0) {
var num = str.indexOf("_", count);
count = num + 1;
if (num != -1) {
var ss = str[count];
var ia = ss.toUpperCase();
str.splice(count, 1, ia);
}
}
return str.join("").replace(/[_]/g, "");
}
});
});
\ No newline at end of file
var tableColumn = '';//数据库表中的列
var result = '';//html/xml/js添加的内容项
layui.config({
base: basePath,
version: skyeyeVersion
......@@ -195,7 +197,7 @@ layui.config({
pageId: "addcontenttohtmlorjs",
callBack: function(refreshCode){
if (refreshCode == '0') {
console.log(result);
} else if (refreshCode == '-9999') {
top.winui.window.msg("操作失败", {icon: 2,time: 2000});
}
......
......@@ -32,6 +32,18 @@
<div class="layui-input-block" id="limitRequire">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">文本提示<i class="red">*</i></label>
<div class="layui-input-block">
<input type="text" id="placeholderName" name="placeholderName" placeholder="请输入文本提示" class="layui-input" maxlength="20"/>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">默认值<i class="red">*</i></label>
<div class="layui-input-block">
<input type="text" id="valueName" name="valueName" placeholder="请输入默认值" class="layui-input" maxlength="20"/>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">HTML模板展示</label>
<div class="layui-input-block">
......@@ -59,7 +71,7 @@
<div class="layui-form-item">
<div class="layui-input-block">
<button class="winui-btn" id="cancle">取消</button>
<button class="winui-btn" lay-submit lay-filter="formAddBean">保存</button>
<button class="winui-btn" lay-submit lay-filter="formAddBean">加入模板</button>
</div>
</div>
</form>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册