You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1368 lines
58 KiB
Plaintext

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<!DOCTYPE html>
<html lang="cn">
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link href="../Comm/fonts/font-icons.min.css" rel="stylesheet" />
<title>正在加载请稍候...</title>
<script src="../Scripts/jquery-1.11.0.min.js" type="text/javascript"></script>
<!--表单样式-->
<link href="../Admin/CSS/FoolFrmBody.css" rel="stylesheet" />
<link href="../../DataUser/Style/FoolFrmStyle/Default.css" rel="stylesheet" />
<!-- layui -->
<link rel="stylesheet" type="text/css" href="../../WF/Portal/icons/font-icons.min.css">
<link rel="stylesheet" type="text/css" href="../../WF/Portal/icons/icons.css">
<link rel="stylesheet" type="text/css" href="../../WF/Portal/layui/css/layui.css">
<link rel="stylesheet" type="text/css" href="../../WF/Portal/layui/css/customer.css">
<link href="../Scripts/layui/layui/css/layui.css" rel="stylesheet" />
<link href="../Scripts/layui/style/admin.css" rel="stylesheet" />
<link href="../Scripts/layui/layui/css/autocomplete.css" rel="stylesheet" />
<script src="../Scripts/layui/LayuiDialog.js" type="text/javascript"></script>
<script src="../Scripts/jquery-form.js" type="text/javascript"></script>
<!--通用的JS-->
<script src="../Scripts/config.js" type="text/javascript"></script>
<script src="../Comm/Gener.js" type="text/javascript"></script>
<script src="../Scripts/QueryString.js" type="text/javascript"></script>
<script src="./JS/tinymce/tinymce.min.js"></script>
<script src="JS/jquery.mousewheel.min.js"></script>
<script src="ChapterFrmGener.js"></script>
<script src="../Scripts/Tools/jsPdf.debug.js"></script>
<script src="../Scripts/Tools/html2canvas.js"></script>
<script src="../../WF/CCForm/FrmFool.js"></script>
<script src="../../WF/CCForm/FrmEnd.js"></script>
<script src="../Comm/JScript.js"></script>
<script src="../../WF/Portal/layui/layui.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
var frmID = null;
var oid = null;
var key = null;
var logInde;
var eleDom = null;
var eleOneDom = null;
let OId = null;
var nodeRates = null;
var Tree = null;
var groupFields = null;
var attrs = null;
var treeClick = null;
var isReadonly = 0; //是否只读?
var hideGroup;//存储隐藏的章节
var hideAttrs;//存储隐藏的字段
var pageData = {};
var form = layui.form;
var data;//表单内容信息,包括各种章节,字段,下拉列表值等
layui.use(['tree', 'jquery', 'laypage', 'form'], function () {
var tree = layui.tree, $ = layui.jquery;
var name = null;
var treelist = null;
var Tip = null;
var Tree_set = null;
var firstLeafID = "";
//页面启动函数.
$(function () {
isReadonly = GetQueryString("IsReadonly");
if (isReadonly == null) {
isReadonly = 0;
pageData.IsReadonly = 0;
}
frmID = GetQueryString("FrmID");
if (frmID == null)
frmID = GetQueryString("FK_MapData");
if (frmID == null)
frmID = "Frm_ZhangJieBiaoDAN";
oid = GetQueryString("OID");
if (oid == null)
oid = GetQueryString("WorkID");
if (oid == null)
oid = GetQueryString("PKVal");
if (oid == null)
oid = 100;
var handler = new HttpHandler("BP.WF.HttpHandler.WF_CCForm");
handler.AddPara("FrmID", frmID);
handler.AddPara("OID", oid);
data = handler.DoMethodReturnJSON("ChapterFrm_Init");
console.log("获取的表单内容信息:", data);
groupFields = data["GroupFields"];//章.
attrs = data["Sys_MapAttr"];//节.
//获取显示状态信息
var en = new Entity(frmID, oid);
console.log("获取的表单设置信息:", en);
//存储显示状态
hideGroup = en.GetPara("HideGroup") || "";
if (hideGroup == "")
hideGroup = [];
else hideGroup = hideGroup.split(',');
hideAttrs = en.GetPara("HideAttrs")||"";
if (hideAttrs == "")
hideAttrs = [];
else hideAttrs = hideAttrs.split(',');
console.log("hideGroup", typeof en.GetPara("HideGroup"), "hideAttrs:", typeof en.GetPara("HideAttrs"));
console.log("显示隐藏配置:", hideGroup, hideAttrs);
var group = [];
var i = 0;
//形成树形数据
groupFields.forEach((item) => {
if (item.ParentOID === "" || item.ParentOID == null) {
var child = {
id: item.OID.toString(),
title: item.Lab == "封面" ? item.Lab:(i + 1) +"、"+item.Lab,
children: [],
spread: true,
logType: "chapter",//是章节还是字段
...item,
};
if ( hideGroup.indexOf(child.id) == -1) {//不隐藏才添加
if (item.CtrlType === "Attr") {//Attr控件将其下的字段值放在attrChildren 中方便解析
child.attrChildren = getAttrChildren(item.OID.toString(), item.CtrlType, (i + 1) + "." );
} else {
child.children = [...getChildren(item.OID.toString(), (i + 1) + "."), ...getAttrChildren(item.OID.toString(), item.CtrlType, (i + 1) + ".")];
};
group.push(child);
if (item.Lab != "封面")
i++;
};
}
});
console.log(group)
function tinyInit() {
tinymce.init({
selector: '#mytextarea',
language: 'zh-Hans',
plugins: [
'advlist', 'saveBtn',
'lists', 'image', 'charmap', 'searchreplace', 'visualblocks',
'table',
],
statusbar: false,
branding: false,
image_advtab: false,
image_description: false,
image_dimensions: false,
toolbar: 'undo redo | formatpainter casechange blocks | bold italic backcolor | ' +
'alignleft aligncenter alignright alignjustify | ' +
'bullist numlist checklist outdent indent | removeformat | saveBtn ',
images_upload_handler: function (blobInfo) {
try {
var handler = new HttpHandler("BP.WF.HttpHandler.WF_Comm_Sys");
handler.AddPara("Files", blobInfo.blob());
handler.AddPara("FrmID", frmID)
handler.AddPara("OID", oid)
var data = handler.DoMethodReturnJSON("RichUploadFile");
var serverPath = window.location.origin + "/" + data.data
return Promise.resolve(serverPath)
} catch (e) {
return Promise.reject(e)
}
},
paste_data_images: true,
init_instance_callback: function (editor) {
editor.on('ExecCommand', function (e) {
if (e.command === "mceInsertContent") {
if (e.value.content.includes("file:///")) {
layer.msg("检测到本地文件,请右键图片替换")
}
}
});
var sdata = ChapterFrmShow(key);
editor.setContent(sdata);
},
});
}
function IniAttr(group) {
var handler = new HttpHandler("BP.WF.HttpHandler.WF_CCForm");
handler.AddPara("FK_MapData", frmID);
handler.AddPara("OID", GetQueryString("WorkID"));
var result = handler.DoMethodReturnString("ChapterFrm_AttrInit");
if (result.indexOf('err@') == -1) {
result = replaceAll(result, '\\\\\\"', '\\\\"');
data.MainTable[0] = JSON.parse(result);
}
var attrhtm = "";
var thisAttrData = {//改造数据主要是Sys_MapAttr的字段显示与隐藏
...data,
Sys_MapAttr: group.attrChildren,
}
console.log(thisAttrData)
attrhtm += '<div id="Group_' + group.OID + '">';
var tableCol = data.Sys_MapData[0].TableCol === 0 ? 4 : 6;
attrhtm += InitMapAttr(thisAttrData, tableCol, group.OID);
attrhtm += '</div>';
$("#divCCForm").html(attrhtm);
//占一行的元素标签靠左
var hang = $(".layui-col-sm12.layui-col-md12.layui-col-xm12.FoolFrmFieldLabel>.layui-form-label");
$.each(hang, function (index, item) {
$(item).attr("style", "text-align:left");
})
//装载表单数据与修改表单元素风格.
LoadFrmDataAndChangeEleStyle(thisAttrData);
//渲染表单
form.render();
form.render('checkbox');
//解析表单的扩展功能
AfterBindEn_DealMapExt(thisAttrData);
$.each($(".ccdate"), function (i, item) {
var format = $(item).attr("data-info");
var type = $(item).attr("data-type");
if (format.indexOf("HH") != -1) {
layui.laydate.render({
elem: '#' + item.id,
format: $(item).attr("data-info"), //可任意组合
type: type,
trigger: 'click',
ready: function (date) {
var now = new Date();
var mm = "";
if (now.getMinutes() < 10)
mm = "0" + now.getMinutes();
else
mm = now.getMinutes();
var ss = "";
if (now.getSeconds() < 10)
ss = "0" + now.getSeconds();
else
ss = now.getSeconds();
this.dateTime.hours = now.getHours();
this.dateTime.minutes = mm;
this.dateTime.seconds = ss;
},
change: function (value, date, endDate) {
$('.laydate-btns-confirm').click();
},
done: function (value, date, endDate) {
var data = $(this.elem).data();
$(this.elem).val(value);
if (data && data.ReqDay != null && data.ReqDay != undefined)
ReqDays(data.ReqDay);
}
});
} else {
layui.laydate.render({
elem: '#' + item.id,
format: $(item).attr("data-info"), //可任意组合
type: type,
done: function (value, date, endDate) {
var data = $(this.elem).data();
$(this.elem).val(value);
if (data && data.ReqDay != null && data.ReqDay != undefined)
ReqDays(data.ReqDay);
}
});
}
})
$.each($(".layui-attr-btn"), function (idx, item) {
$(this).on("click", function () {
var keyOfEn = item.id.substring(4);
var mapAttr = $.grep(thisAttrData.Sys_MapAttr, function (attr) {
return attr.KeyOfEn == keyOfEn;
})[0];
var tag = mapAttr.Tag || "";
if (tag != "") {
tag = DealExp(tag);
if (mapAttr.UIIsEnable == 1) {
//执行js
DBAccess.RunUrlReturnString(tag);
}
if (mapAttr.UIIsEnable == 2)
DBAccess.RunFunctionReturnStr(tag);
}
if (mapAttr.UIIsEnable != 0 && isReadonly != true)
FullIt("", mapAttr.MyPK + "_FullData", "Btn_" + mapAttr.KeyOfEn, 0);
})
})
$("#toIframe").hide();
$("#textRea").hide();
$("#divCCForm").show();
$("#welcome").hide();
}
function iframeFun(id, url, OId, item, checked) {
console.log(url);
var myframe = document.getElementById(id).contentWindow;
if (myframe.Save != undefined) {
myframe.Save();
//if (checked)
//CheckGroupFieldStr(OId, item);
}
if (myframe.SaveAll != undefined) {
myframe.SaveAll();
//if (checked)
//CheckGroupFieldStr(OId, item);
}
$("#toIframe").show();
$("#toIframe").attr("src", url);
$("#textRea").hide();
$("#divCCForm").hide();
}
// tree 点击事件
treeClick = (obj) => {
$("#welcome").hide();
$("#textRea").hide();
$('.layui-tree-set').removeClass("tree-txt-active");
if (!obj.data.children) {
Save();//点击文本框字段时保存Attr表单
tinyInit();
$("#toIframe").hide();
$("#divCCForm").hide();
$("#textRea").show();
if (name !== obj.data.Name) {
Tip = obj.data.Tip;//提示信息
name = obj.data.Name;//右边的title
getContent(obj.data.KeyOfEn);
eleDom = $(obj.elem[0]).find(".rate");//打对号
}
$(obj.elem[0]).addClass("tree-txt-active");
Savetab(OId, eleOneDom);
} else {
$("#welcome").hide();
getContent(key);
Save();
var url = '';
//如果点击章.
if (obj.data.CtrlType == "Dtl") {
url = Ele_Dtl_Chapter(obj.data.CtrlID);
}
if (obj.data.CtrlType == "Attr") {
IniAttr(obj.data);
}
if (obj.data.CtrlType == "Ath") {
url = basePath + "/WF/CCForm/Ath.htm?1=1&AthPK=" + obj.data.CtrlID + "&OID=" + oid + "&FK_MapData=" + frmID + "&FK_Node=" + GetQueryString("FK_Node");
}
if (obj.data.CtrlType == "ChapterFrmLinkFrm") {//表单
url = basePath + "/WF/CCForm/Frm.htm?1=1&FrmID=" + obj.data.CtrlID + "&OID=" + oid + "&FK_MapData=" + obj.data.CtrlID + "&FK_Node=" + GetQueryString("FK_Node");
}
if (obj.data.CtrlType == "ChapterFrmSelfUrl") {//自定义URL
if (obj.data.CtrlID.indexOf('http') == 0)
if (obj.data.CtrlID.indexOf('?') > -1) {
url = obj.data.CtrlID + "&OID=" + oid + "&FK_MapData=" + frmID + "&FK_Node=" + GetQueryString("FK_Node");
} else {
url = obj.data.CtrlID + "?" + "OID=" + oid + "&FK_MapData=" + frmID + "&FK_Node=" + GetQueryString("FK_Node");
}
else {//引用当前项目里的页面
if (obj.data.CtrlID.indexOf('?') > -1) {
url = basePath + "/" + obj.data.CtrlID + "&OID=" + oid + "&FK_MapData=" + frmID + "&FK_Node=" + GetQueryString("FK_Node");
} else {
url = basePath + "/" + obj.data.CtrlID + "?" + "OID=" + oid + "&FK_MapData=" + frmID + "&FK_Node=" + GetQueryString("FK_Node");
}
}
}
if (obj.data.CtrlType == '') {
return;
}
eleOneDom = obj.elem;
OId = obj.data.OID;
var logChecked;//是否检查打勾
if (obj.data.CtrlType != "Attr") {
if ((obj.data.CtrlType == "" || obj.data.CtrlType == null) && obj.data.children.length == 0) {
logChecked = false;
} else {
logChecked = true;
}
iframeFun("toIframe", url, OId, eleOneDom, logChecked);
} else {
//CheckGroupFieldStr(OId, eleOneDom);
}
$('.layui-tree-set').removeClass("tree-txt-active");
$(obj.elem[0]).addClass("tree-txt-active");
}
}
Tree = tree.render({
elem: '#test1',//容器id
data: group,//数据源
id: 'treeId',//树的id
click: function (obj) {//树节点的点击函数
treeClick(obj)
}
});
//按钮展开折叠点节点 expandAll
$("#shrink").click(function () {
treeExpand(group);
function treeExpand(list) {
//var isSpread = true;
$.each(list, function (index, item) {
if (item.logType == "chapter" && item.spread == true) {
item.spread = false;
$('#shrink > #icon').attr("class","icon-plus")
} else{
item.spread = true;
$('#shrink > #icon').attr("class", "icon-minus")
}
if (Array.isArray(item.children) && item.children.length > 0) {
treeExpand(item.children);
}
})
}
tree.reload('treeId',{
data: group,
});
});
//$("#foldAll").click(function () {
// treeFold(group);
// function treeFold(list) {
// $.each(list, function (index, item) {
// if (item.logType == "chapter") {
// item.spread = false;
// }
// if (Array.isArray(item.children) && item.children.length > 0) {
// treeFold(item.children);
// }
// })
// }
// tree.reload('treeId', {
// data: group,
// });
//});
// 判断第一项是否有子集 并选中状态 跳转iframe页面
function treeSet() {
treelist = document.querySelectorAll('.layui-tree-pack >.layui-tree-set');
treelist.forEach((item, index) => {
db.push({
"attrKey": item.dataset.id,
"vals": '',
});
})
Tree_set = document.querySelectorAll('.layui-tree>.layui-tree-set');
Tree_set.forEach((item, index) => {
$(item).attr("title", group[index].title);
$(item).attr("id", "Pnode" + group[index].OID);
var main = $(item).find('.layui-tree-pack ');
var h = `<i class="icon-check rate"></i>`;
$(item).find(".layui-tree-main").append(h);
//替换 tree icon
if (item.childNodes.length == 2) {
var sclass = $(item).find('.layui-tree-iconClick');
//$(sclass).empty();
//$(sclass).each(function () {
// $(this).html('');
// if (group[index].CtrlType == "Dir") {
// let i = `<i class="icon-folder"></i>`
// $(this).html(i);
// return;
// }
// if (group[index].CtrlType == "Dtl") {
// let i = `<i class="icon-folder"></i>`
// $(this).html(i);
// return;
// }
// if (group[index].CtrlType == "Attr") {
// let i = `<i class="icon-folder"></i>`
// $(this).html(i);
// return;
// }
// if (group[index].CtrlType == "Ath") {
// let i = `<i class="icon-paper-clip"></i>`
// $(this).html(i);
// return;
// }
// if (group[index].CtrlType == "ChapterFrmLinkFrm") {
// let i = `<i class="icon-folder"></i>`
// $(this).html(i);
// return;
// }
// if (group[index].CtrlType == "ChapterFrmSelfUrl") {
// let i = `<i class="icon-folder"></i>`
// $(this).html(i);
// return;
// }
//})
} else {
var sclass = $(item).find('.layui-tree-iconClick');
$(sclass).empty();
$(sclass).removeClass("layui-tree-icon")
let i = `<i class="icon-folder"></i>`
$(sclass).html(i);
}
//默认第一个选中
if (index == 0) {
var newGroup = group[index];
if (main.length == 0) {
setFirstSelect(newGroup);
$('.layui-tree-set').removeClass("tree-txt-active");
$(item).addClass("tree-txt-active");
$("#Title").html(newGroup.Name);
} else {
newGroup = newGroup.children[0];
if (newGroup.children.length == 0) {
setFirstSelect(newGroup);
item.children[index].checked = true;
key = item.children[index].KeyOfEn;
treelist[index].classList.add("tree-txt-active");
name = group[index].children[index].Name;
$("#Title").html(name)
}
}
item.checked = true;
}
})
showType(group, Tree_set)
}
function setFirstSelect(newGroup) {
$("#welcome").hide();
getContent(key);
var url = '';
//如果点击章.
if (newGroup.CtrlType == "Dtl") {
url = Ele_Dtl_Chapter(newGroup.CtrlID);
}
if (newGroup.CtrlType == "Attr") {
IniAttr(newGroup);
return;
}
if (newGroup.CtrlType == "Ath") {
url = basePath + "/WF/CCForm/Ath.htm?1=1&AthPK=" + newGroup.CtrlID + "&OID=" + oid + "&FK_MapData=" + frmID + "&FK_Node=" + GetQueryString("FK_Node");
}
if (newGroup.CtrlType == "ChapterFrmLinkFrm") {//表单
url = basePath + "/WF/CCForm/Frm.htm?1=1&FrmID=" + newGroup.CtrlID + "&OID=" + oid + "&FK_MapData=" + newGroup.CtrlID + "&FK_Node=" + GetQueryString("FK_Node");
}
if (newGroup.CtrlType == "ChapterFrmSelfUrl") {//自定义URL
if (newGroup.CtrlID.indexOf('http') == 0)
if (newGroup.CtrlID.indexOf('?') > -1) {
url = newGroup.CtrlID + "&OID=" + oid + "&FK_MapData=" + frmID + "&FK_Node=" + GetQueryString("FK_Node");
} else {
url = newGroup.CtrlID + "?" + "OID=" + oid + "&FK_MapData=" + frmID + "&FK_Node=" + GetQueryString("FK_Node");
}
else {//引用当前项目里的页面
if (newGroup.CtrlID.indexOf('?') > -1) {
url = basePath + "/" + newGroup.CtrlID + "&OID=" + oid + "&FK_MapData=" + frmID + "&FK_Node=" + GetQueryString("FK_Node");
} else {
url = basePath + "/" + newGroup.CtrlID + "?" + "OID=" + oid + "&FK_MapData=" + frmID + "&FK_Node=" + GetQueryString("FK_Node");
}
}
}
if (newGroup.CtrlType == '') {
return;
}
OId = newGroup.OID;
iframeFun("toIframe", url, OId, eleOneDom, false);
}
treeSet();
$("#tips").click(function () {
openDialog(Tip, key);
})
//IsAtPara(attrs, treelist);
//IsAtParaKey(group, Tree_set);
var isShows = true;
$("#menu").toggle();
$("#menuShow").click(function () {
$("#menu").toggle();
if (isShows) {
$("#scrollDiv").addClass("Card_body")
isShows = false
} else {
$("#scrollDiv").removeClass("Card_body")
isShows = true
}
})
});
//递归构造章节树形结构获取parentId的孩子
function getChildren(parentId,parentXuHao) {
var children = [];
var i = 1;
groupFields.forEach((item) => {
if (item.ParentOID === parentId) {
var child = {
id: item.OID.toString(),
title: parentXuHao+i+"、"+item.Lab,
children: [],
attrChildren: [],
spread: true,
logType: "chapter",
...item,
};
if ( hideGroup.indexOf(child.id) == -1) {//不隐藏才添加
if (item.CtrlType === "Attr") {
child.attrChildren = getAttrChildren(item.OID.toString(), item.CtrlType);
if (idx == 0)
firstLeafID = child.id
} else {
child.children = [...getChildren(item.OID.toString(), parentXuHao + i+"."), ...getAttrChildren(item.OID.toString(), item.CtrlType)];
};
children.push(child);
i++;
};
}
});
return children;
}
//获取本章节下的attr字段groupId下的字段
function getAttrChildren(groupId, ctrlType) {
var attrList = [];
//非Attr型控件非默认控件不显示其下字段
if (ctrlType != "Attr" && ctrlType != "" && ctrlType != null)
return [];
for (var i = 0; i < attrs.length; i++) {
var attr = attrs[i];
if (attr.MyDataType != 1 && ctrlType == "")
continue;
if (attr.GroupID === groupId && attr.UIVisible === 1) {//只显示可见的字段
var attr = {
id: attr.KeyOfEn,
title: attr.Name,
logType: "attr",
...attr,
};
if (attr.UIContralType == 1) {//如果是下拉框,存储下拉列表值
if (attr.MyDataType == 2)//枚举下拉
attr.DDLlist = $.grep(data['Sys_Enum'], function (item, index) {
return item.EnumKey == attr.KeyOfEn;
});
else if (attr.MyDataType == 1)//下拉单选
attr.DDLlist = data[attr.KeyOfEn];
}
else if (attr.UIContralType == 3 && attr.MyDataType == 2) {//枚举单选 radio
attr.DDLlist = $.grep(data['Sys_Enum'], function (item, index) {
return item.EnumKey == attr.KeyOfEn;
});
}
if (hideAttrs.indexOf(attr.KeyOfEn) == -1) {//看是否设置显示
if ((ctrlType === "" || ctrlType == null) && attr.TextModel != 1) {//默认型控件,只显示文本字段
if (attr.MyDataType == 1 && attr.UIContralType == 0) {
attrList.push(attr);
};
} else if (ctrlType === "Attr") {//Attr控件所有类型的字段都显示
attrList.push(attr);
};
};
};
};
return attrList;
}
function showType(group, Tree_set) {
let n = 0;
group.forEach((item, index) => {
if (item.ShowType == 2) {
n = n + 1;
const Id = Tree_set[index].dataset.id;
console.log($(`#Pnode${Id}`))
$(`#Pnode${Id}`).hide()
}
})
if (n == group.length) {
$("#menuShow").hide()
}
}
// 解析
function analysis(Tip) {
let tipArr = Tip.split("@");
let tempul = `<ul class="tipsul">
${tipArr.map(item => {
if (item.includes('###')) {
return `<li class="m-1"><h3>${item.split("###").join('')}</h3></li>`
} else if (item.includes(')')) {
return `<li class="m-1"><small>${item.split("###").join('')}</small></li>`
} else {
return `<li class="m-1">${item.split("###").join('')}</li>`
}
}).join('')}
</ul>`
Tip = tempul;
return Tip;
}
tinymce.PluginManager.add('saveBtn', function (editor, url) {
// 注册一个保存按钮名称
editor.ui.registry.addButton("saveBtn", {
text: '保存',
icon: 'save',
onAction: function () {
var vals = tinymce.activeEditor.getContent();
if (key == undefined || key == '') {
layer.msg('请先选择子节点', { icon: 6 });
return;
} else {
ChapterFrmSave(key, vals)
}
}
})
});
tinymce.PluginManager.add('helpBtn', function (editor, url) {
editor.ui.registry.addButton('helpBtn', {
text: '提示',
icon: 'help',
onAction: function () {
openDialog(editor);
}
});
});
var keylist = [];
function IsAtPara(attrs, list) {
attrs.forEach(item => {
if (item.AtPara != null && item.AtPara != "") {
if (item.AtPara.includes('@IsStar')) {
keylist.push(item.KeyOfEn);
}
}
})
showRate(list)
}
function showRate(list) {
list.forEach(item => {
var keyId = $(item).data("id");
if (keylist.includes(keyId)) {
var rate = $(item).find(".rate");
$(rate).show()
}
})
}
var Kylist = [];
function IsAtParaKey(attr, list) {
attr.forEach(item => {
if (item.AtPara != null) {
if (item.AtPara.includes('@IsStar')) {
Kylist.push(item.title);
}
}
})
keyshowRate(list)
}
function keyshowRate(list) {
list.forEach(item => {
var title = item.title;
if (Kylist.includes(title)) {
if (item.children.length == 1) {
var rate = $(item).find(".rate");
$(rate).show()
} else {
var rate = $(item.children[0]).find(".rate");
$(rate).show()
}
}
})
}
function openDialog(tip, keyOfEn) {
if (tip == null || tip == '') {
var mypk = "FieldNameLink_" + frmID + "_" + keyOfEn;
var mapExt = new Entity("BP.Sys.MapExt");
mapExt.MyPK = mypk;
var i = mapExt.RetrieveFromDBSources();
if (i == 0) {
alert('没有设置帮助.');
return;
}
tip = TransbrString(mapExt.Doc);
var tips = `<div style="padding:30px">${tip}</div>`;
layer.open({
type: 1,
title: '填报提示',
area: ['1000px', '400px'],
shade: 0.4,
content: tips,
})
} else {
tip = analysis(tip);
var tips = `${tip}`;
layer.open({
type: 1,
title: '填报提示',
area: ['500px', '300px'],
shade: 0.4,
content: tips,
})
}
}
//获得从表的url.
function Ele_Dtl(frmID) {
var frmDtl = new Entity("BP.Sys.MapDtl", frmID);
var src = "";
var href = GetHrefUrl();
var urlParam = href.substring(href.indexOf('?') + 1, href.length);
urlParam = urlParam.replace('&DoType=', '&DoTypeDel=xx');
var ensName = frmDtl.No;
if (ensName == undefined) {
layer.alert('系统错误,请找管理员联系');
return;
}
var currentURL = GetHrefUrl();
var baseUrl = "./";
if (currentURL.indexOf("AdminFrm.htm") != -1)
baseUrl = "../../CCForm/";
if (currentURL.indexOf("MyBill.htm") != -1 || currentURL.indexOf("MyDict.htm") != -1)
baseUrl = "../CCForm/";
if (currentURL.indexOf("FrmGener.htm") != -1 || currentURL.indexOf("FrmDBVer.htm") != -1 || currentURL.indexOf("DtlFrm.htm") != -1)
baseUrl = "./";
//表格模式
if (frmDtl.ListShowModel == "0")
src = baseUrl + "Dtl2017.htm?1=1";
if (frmDtl.ListShowModel == "1")
src = baseUrl + "DtlCard.htm?1=1";
if (frmDtl.ListShowModel == "2") {
if (frmDtl.UrlDtl == null || frmDtl.UrlDtl == undefined || frmDtl.UrlDtl == "")
return "从表" + frmDtl.Name + "没有设置URL,请在" + frmDtl.FK_MapData + "_Self.js中解析";
src = basePath + "/" + frmDtl.UrlDtl;
if (src.indexOf("?") == -1)
src += "?1=1";
}
src += "&IsShowVerBtn=1&EnsName=" + frmDtl.No + "&RefPKVal=" + oid + "&FK_MapData=" + frmID + "&IsReadonly=" + (isReadonly == true ? 1 : 0) + "&" + urlParam + "&Version=1&FrmType=0";
return src;
}
var currData = null;
function ChapterFrmShow(attrKey) {
if (attrKey == null || attrKey == "") {
//alert("字段值为空.");
return;
}
var handler = new HttpHandler("BP.WF.HttpHandler.WF_CCForm");
handler.AddPara("FrmID", frmID);
handler.AddPara("OID", oid);
handler.AddPara("KeyOfEn", attrKey);
var data = handler.DoMethodReturnString("ChapterFrm_InitOneField");
// tinymce.activeEditor.setContent(data)
currData = data; //记录当前的变量.
return data;
}
/**
* 节的数据保存..
* @param attrKey
* @param vals
*/
function ChapterFrmSave(attrKey, vals) {
if (attrKey == null || attrKey == "") {
return;
}
//if (vals == currData) return;
var oldVal = getOldVal(attrKey);
//判断内存的值是否更新
var oldvals = TransferString(oldVal.vals);
if (Object.is(vals, oldvals))
return; //数据没有变化.
var loading = layer.msg('正在保存中', { icon: 16, shade: 0.3 });
var handler = new HttpHandler("BP.WF.HttpHandler.WF_CCForm");
handler.AddPara("FrmID", frmID);
handler.AddPara("OID", oid);
handler.AddPara("KeyOfEn", attrKey);
handler.AddPara("Vals", vals);
const data = handler.DoMethodReturnString("ChapterFrm_SaveOneField");
if (data.indexOf('err@') == 0) {
alert(data);
return;
}
console.log(data);
//if (data == "1") {
// $(eleDom).show(); //显示star.
//} else {
// $(eleDom).hide(); //隐藏star.
//}
layer.close(loading);
// 更新内存的值.
changeDBval(vals, attrKey);
//设置父级star.
//SetParentStar(attrKey);
}
function SetParentStar(attrKey) {
var groupID = null;
for (var i = 0; i < attrs.length; i++) {
var attr = attrs[i];
if (attr.KeyOfEn == attrKey) {
groupID = attr.GroupID;
break;
}
}
var PraEle = $(`#Pnode${groupID}>.layui-tree-entry`);
var raEle = $(PraEle).find(".rate");
var pack = $(`#Pnode${groupID}>.layui-tree-pack`);
nodeRates = $(pack).find(".rate");
//获得节点集合.
var isHaveBlank = false;
var listnode = [];
for (var i = 0; i < nodeRates.length; i++) {
var BleaStr = nodeRates[i].style.display == "inline";
if (BleaStr) {
listnode.push(nodeRates[i])
}
}
if (listnode.length !== nodeRates.length) {
isHaveBlank = true;
}
//给父节点加star.
//if (isHaveBlank == false) {
// $(raEle).show();
//} else {
// $(raEle).hide();
//}
}
$('#View').click(function () {
var url = "ChapterFrmView.htm?FrmID=" + frmID + "&OID=" + oid + "&IsReadonly=1" + "&FK_Flow=" + GetQueryString("FK_Flow") + "&WorkID=" + GetQueryString("WorkID") + "&FK_Node=" + GetQueryString("FK_Node");
//WinOpenFull(url);
OpenLayuiDialog(url, '查看表单', '1200', '', '', false)
})
$('#Exp').click(function () {
var url = "ChapterFrmExp.htm?FrmID=" + frmID + "&OID=" + oid + "&attrKey=" + key;
// WinOpenFull(url);
OpenLayuiDialog(url, '', '1200', '', '', false);
layer.load(0, {
shade: [0.6, '#fff'],
content: '下载中...',
success: function (layero) {
layero.find('.layui-layer-content').css({
'padding-top': '35px',
'text-align': 'center',
'z-index': '19891016'
});
}
});
})
//富文本编辑器
function getContent(KeyOfEn) {
//var cdata = ChapterFrmShow(KeyOfEn);
//changeDBval(cdata, KeyOfEn);
//var Cdata = tinymce.activeEditor.getContent();
//ChapterFrmSave(key, Cdata);
//key = KeyOfEn;
//var Data = ChapterFrmShow(key);
//tinymce.activeEditor.setContent(Data);
var cdata = ChapterFrmShow(KeyOfEn);
changeDBval(cdata, KeyOfEn);
var Cdata = '';
if (tinymce.activeEditor !== null) {
Cdata = tinymce.activeEditor.getContent();
}
ChapterFrmSave(key, Cdata);
key = KeyOfEn;
var Data = ChapterFrmShow(key);
if (tinymce.activeEditor !== null) {
tinymce.activeEditor.setContent(Data);
}
}
//保存当前打开的最后一个章节方法
function Savetab(OId, eleOneDom) {
var iframe = $("#toIframe");
//IFrame的内容
if (iframe.is(":hidden") == true) {
var myframe = iframe[0].contentWindow;
if (myframe && myframe.Save != undefined && typeof (myframe.Save) == "function") {
var flag = myframe.Save();
//CheckGroupFieldStr(OId, eleOneDom)
if (flag == false)
return false;
}
if (myframe && myframe.SaveAll != undefined && typeof (myframe.SaveAll) == "function") {
myframe.SaveAll();
//CheckGroupFieldStr(OId, eleOneDom)
return true;
}
}
return true;
}
});
function SaveAttr() {
var groupDiv = $('#divCCForm div[id^=Group_]');
if (groupDiv.length == 0)
return true;
var groupId = groupDiv[0].id.replace("Group_", "");
var loading = layer.msg('正在保存中', { icon: 16, shade: 0.3 });
if (checkBlanks() == false) {
//layer.alert("检查必填项出现错误,边框变红颜色的是否填写完整?");
return false;
}
if (CheckReg() == false) {
layer.alert("保存错误:请检查字段边框变红颜色的是否填写完整?");
return false;
}
var handler = new HttpHandler("BP.WF.HttpHandler.WF_CCForm");
handler.AddPara("OID", oid);
var params = getTreeFormData(true, true);
handler.AddUrlData();
handler.AddJson(params);//params:{}
handler.AddPara("GroupID", groupId);
console.log("attr表单数据", params);
var data = handler.DoMethodReturnString("ChapterFrm_SaveAttr");
layer.close(loading);
if (data.indexOf('err@') == 0) {
layer.alert(data);
return false;
}
var en = new Entity(frmID, oid);
//if (hideGroup.length != 0)
en.SetPara("HideGroup", hideGroup.join(','));
//if (hideAttrs.length != 0)
en.SetPara("HideAttrs", hideAttrs.join(','));
en.Update();
return true;
}
//保存当前打开的最后一个章节
function Save() {
var textA = $("#textRea");
var iframe = $("#toIframe");
var ccForm = $("#divCCForm");
//保存富文本框的内容
if (textA.is(":hidden") == false) {
var cdata = tinymce.activeEditor.getContent();
if (key == null || key == "") {
return;
}
var handler = new HttpHandler("BP.WF.HttpHandler.WF_CCForm");
handler.AddPara("FrmID", frmID);
handler.AddPara("OID", oid);
handler.AddPara("KeyOfEn", key);
handler.AddPara("Vals", cdata);
handler.DoMethodReturnString("ChapterFrm_SaveOneField");
return;
}
//IFrame的内容
if (iframe.is(":hidden") == false) {
var myframe = iframe[0].contentWindow;
if (myframe && myframe.Save != undefined && typeof (myframe.Save) == "function") {
var flag = myframe.Save();
if (flag == false)
return false;
}
if (myframe && myframe.SaveAll != undefined && typeof (myframe.SaveAll) == "function") {
myframe.SaveAll();
return true;
}
}
if (ccForm.is(":hidden") == false) {
return SaveAttr();
}
return true;
}
//打开设置弹窗
function openSetting() {
var url = 'ChapterSetting.htm?FrmID=' + frmID + '&OID=' + oid;
OpenLayuiDialog(url, '设置', 1000, 100, "auto", true, true, true, modalOkFunc);
}
//弹窗确认函数
function modalOkFunc() {
var hideGroupRes = $(window.frames["dlg"]).find("iframe")[0].contentWindow.hideGroupRes;
var hideAttrRes = $(window.frames["dlg"]).find("iframe")[0].contentWindow.hideAttrRes;
console.log('弹窗', hideGroupRes, hideAttrRes);
var en = new Entity(frmID, oid);
//if (hideGroupRes.length != 0)
en.SetPara("HideGroup", hideGroupRes.join(','));
//if (hideAttrRes.length != 0)
en.SetPara("HideAttrs", hideAttrRes.join(','));
en.Update();
}
</script>
<style type="text/css">
html, body {
height: 100%;
}
.app {
height: 100%;
width: 100%;
display: flex;
}
.btn_shrink {
display: flex;
justify-content: center;
align-items: center;
padding: 0 15px;
height: 25px;
font-size: 18px;
}
.border_1 {
border: 1px solid #ccc;
height: 100%;
}
.padding-5 {
padding: 10px;
}
.tree-txt-active {
background: #dcdcdc;
}
.layui-tree-entry .layui-tree-txt {
font-weight: 600;
}
.layui-tree-pack .layui-tree-txt {
font-weight: 300;
}
.layui-tab-title {
text-align: center
}
.layui-tab-content {
padding: 0;
}
.h-100 {
height: 100vh;
overflow: auto;
}
#textRea {
height: 100%;
}
#toIframe {
display: none;
width: 100%;
border: none;
height: 94.5vh !important;
}
.tipsul {
padding: 20px;
}
.tipsul h3 {
font-weight: bold !important;
margin-bottom: 5px !important;
}
.tipsul li {
font-size: 18px;
}
.tipsul small {
font-size: 16px !important;
margin-left: 20px !important;
}
.labelTitle {
height: 40px;
text-align: center;
padding-right: 28px;
line-height: 40px;
background: #fff;
}
.labelTitle #Title {
font-size: 18px;
font-weight: bold;
}
.layui-right {
float: right;
margin-top: 5px;
}
.layui-row {
/*height: 100vh;*/
}
.tox-tinymce {
height: calc(100% - 40px) !important;
}
::-webkit-scrollbar-thumb {
border-radius: 10px;
-webkit-box-shadow: inset 0 0 6px #999;
background-color: #999;
}
::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 6px #ddd;
border-radius: 10px;
background-color: #F5F5F5;
}
::-webkit-scrollbar {
width: 4px;
height: 0px;
background-color: #F5F5F5;
}
.rate {
color: green;
font-size: 12px;
display: none;
margin-left: 5px;
}
#menu {
display: none;
width: 30%;
}
#scrollDiv {
width: 100%
}
.Card_body {
width: 70%;
}
.welcome {
height: calc(100% - 120px);
background-color: white;
display: flex;
justify-content: center;
align-items: flex-start;
color: #2396e5;
font-size:30px;
}
.layui-form-label {
width: calc(100% - 48px);
}
</style>
</head>
<body>
<div class="layui-row app">
<div id="menu" data-anim="layui-anim-downbit" style="background-color:white;">
<div class="layui-tab layui-tab-brief" lay-filter="docTabBrief">
<div class="layui-tab-content">
<div class="layui-tab-item layui-show">
<!--demo-tree demo-tree-box-->
<button class="layui-btn layui-btn-primary layui-btn-sm btn_shrink" id="shrink"><i id="icon" class="icon-minus"></i></button>
<!--<button class="layui-btn layui-btn-primary layui-btn-sm" id="foldAll">全部折叠</button>-->
<div id="test1" class="" style="height: calc(100vh - 30px); overflow-x: auto "></div>
</div>
</div>
</div>
</div>
<div class="h-100" id="scrollDiv" style="overflow-y:hidden">
<div class="layui-tab-title" style="display:flex;justify-content:end;background:#fff">
<div id="elemPage"></div>
<button class="layui-btn layui-btn-primary layui-btn-sm" id="View">查看</button>
<button class="layui-btn layui-btn-primary layui-btn-sm" id="menuShow">目录</button>
<button class="layui-btn layui-btn-primary layui-btn-sm" id="setting" onclick="openSetting()">设置</button>
<button class="layui-btn layui-btn-sm" style="background: #5053f1" id="tips">填报提示</button>
<!--<button class="layui-btn layui-btn-primary layui-btn-sm" onclick="tabChange('up')">上一节</button>-->
<!--<button class="layui-btn layui-btn-primary layui-btn-sm" onclick="tabChange('down')">下一节</button>-->
</div>
<!--富文本编辑器-->
<div class="layui-form" id="textRea">
<!--<div class="labelTitle">
<span id="Title"></span>
<button class="layui-right layui-btn layui-btn-sm" id="tips">填报提示</button>
</div>-->
<div id="welcome" class="welcome">
<div>
<!--<img src="../../DataUser/ICON/ccbp" width="240"/>
<div>欢迎使用章节表单</div>-->
</div>
</div>
<textarea id="mytextarea"></textarea>
</div>
<!--iframe页面 Dtl Ath ChapterFrmLinkFrm ChapterFrmSelfUrl-->
<div class="layui-form">
<iframe id="toIframe" frameborder="0" style="width:100%;"></iframe>
</div>
<!--Attr表单内部信息-->
<div class="layui-fluid fluid">
<div class="layui-row layui-col-space15" id="ContentDiv">
<!-- 内容主体区域 -->
<div class="layui-col-md12">
<div class="layui-card">
<div class="layui-card-body">
<form id="divCCForm" class="layui-form">
<!--加载表单的信息-->
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>