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

表单加载组件修改,解决handlebar传递对象的问题

上级 1543900e
......@@ -10,7 +10,6 @@ layui.config({
var index = parent.layer.getFrameIndex(window.name);
var $ = layui.$,
textool = layui.textool;
var selOption = getFileContent('tpl/template/select-option.tpl');
showGrid({
id: "showForm",
......
......@@ -121,7 +121,7 @@ function setRequestHeaders(xmlhttp) {
// 编辑加载自定义的js文件
layui.each(customerJS, function(key, jsPath){
if(jsPath.lastIndexOf(".js") >=0){
if (jsPath.lastIndexOf(".js") >= 0) {
document.write('<script type="text/javascript" src="' + jsPath + '?v=' + skyeyeVersion + '"></script>');
} else {
document.write('<link rel="stylesheet" type="text/css" href="' + jsPath + '?v=' + skyeyeVersion + '"/>');
......
......@@ -134,6 +134,9 @@ var dsFormUtil = {
* @param content
*/
loadComponent: function (boxId, content) {
if (!dsFormUtil.checkLoadHandlebar) {
dsFormUtil.loadHandlebar();
}
var component = content.dsFormComponent;
if (component.linkedData == 1) {
// 关联数据
......@@ -145,8 +148,6 @@ var dsFormUtil = {
}
var jsonStr = {bean: content};
// 对象的传递转换,用于组件使用,组件中需要使用 {{{attrDefinitionJson}}} 接收
jsonStr.bean.attrDefinitionJson = JSON.stringify(jsonStr.bean.attrDefinition);
var html = getDataUseHandlebars('{{#bean}}' + component.htmlContent + '{{/bean}}', jsonStr);
var html_js = getDataUseHandlebars('{{#bean}}' + component.jsContent + '{{/bean}}', jsonStr);
var jsCon = `<script>${html_js}</script>`;
......@@ -159,6 +160,15 @@ var dsFormUtil = {
return content;
},
checkLoadHandlebar: false,
loadHandlebar: function () {
dsFormUtil.checkLoadHandlebar = true;
// 加载json对象
Handlebars.registerHelper('json', function(context) {
return JSON.stringify(context);
});
},
getLable: function (content) {
var attr = content.attrDefinition;
if (!isNull(attr) && !$.isEmptyObject(attr)) {
......
......@@ -413,7 +413,7 @@ layui.define(["jquery"], function(exports) {
if (["avi", "wmv", "mpeg", "mp4", "mov", "mkv", "flv", "f4v", "m4v", "rmvb", "rm", "3gp", "dat", "ts", "mts", "vob"].indexOf(i) >= 0) {
return '<svg xmlns="http://www.w3.org/2000/svg" class="icon" version="1" viewBox="0 0 1024 1024"><path fill="#8095FF" d="M80 34h864v960H80z"/><path fill="#FFF" d="M136 112a40 40 0 1 0 80 0 40 40 0 1 0-80 0zM136 272a40 40 0 1 0 80 0 40 40 0 1 0-80 0zM136 432a40 40 0 1 0 80 0 40 40 0 1 0-80 0zM136 592a40 40 0 1 0 80 0 40 40 0 1 0-80 0zM136 752a40 40 0 1 0 80 0 40 40 0 1 0-80 0zM136 912a40 40 0 1 0 80 0 40 40 0 1 0-80 0zM824 112a40 40 0 1 0 80 0 40 40 0 1 0-80 0zM824 272a40 40 0 1 0 80 0 40 40 0 1 0-80 0zM824 432a40 40 0 1 0 80 0 40 40 0 1 0-80 0zM824 592a40 40 0 1 0 80 0 40 40 0 1 0-80 0zM824 752a40 40 0 1 0 80 0 40 40 0 1 0-80 0zM824 912a40 40 0 1 0 80 0 40 40 0 1 0-80 0zM648 508L436 362c-5-3-11-4-17 0-5 3-9 8-9 14v290c0 6 4 12 9 15 6 3 12 2 17-1l212-146c5-3 7-8 7-13s-3-10-7-13z"/></svg>'
}
if (["gif", "jpg", "jpeg", "png", "bmp"].indexOf(i) >= 0) {
if (imageType.indexOf(i) >= 0) {
return '<svg xmlns="http://www.w3.org/2000/svg" class="icon" version="1" viewBox="0 0 1024 1024"><defs/><path fill="#FF5562" d="M160 32a49 49 0 0 0-48 48v864c0 12 5 25 14 34 10 9 22 14 34 14h704c12 0 25-5 34-14 9-10 14-22 14-34V304L640 32H160z"/><path fill="#FFBBC0" d="M912 304H688c-12 0-25-5-34-14s-14-22-14-34V32l272 272z"/><path fill="#FFF" d="M758 706L658 550c-3-4-8-7-13-7s-11 3-14 7l-53 84-120-195c-4-5-8-7-14-7s-10 3-14 7L266 706c-4 4-4 11 0 16 3 5 8 8 13 8h466c5 0 11-4 14-8 3-6 3-12-1-16zM622 412a40 40 0 1 0 80 0 40 40 0 1 0-80 0z"/></svg>'
}
return '<svg xmlns="http://www.w3.org/2000/svg" class="icon" version="1" viewBox="0 0 1024 1024"><path fill="#E5E5E5" d="M160 32a49 49 0 0 0-48 48v864c0 12 5 25 14 34 10 9 22 14 34 14h704c12 0 25-5 34-14 9-10 14-22 14-34V304L640 32H160z"/><path fill="#CCC" d="M912 304H688c-12 0-25-5-34-14s-14-22-14-34V32l272 272z"/></svg>'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册