123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086 |
- var s4 = new SM4Util();
- var get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
- var get_userId = $.cookie("GlWorkPlatform-userid");
- var get_formeditid = sp.getUrlName("formeditid");
- var get_routeinfoid = sp.getUrlName("routeinfoid");
- var get_routeid = sp.getUrlName("routeid");
- var get_id = sp.getUrlName("id");
- var get_pagefrom = sp.getUrlName("pagefrom");
- var get_leftActive = sp.getUrlName("leftActive");
- var get_leftActiveType = sp.getUrlName("leftActiveType");
- ////返回按钮事件
- function btnGoBack() {
- if (get_pagefrom == "formManageformlist") {
- window.location.href = "../formManage/formlist.html?leftActive=" + get_leftActive + "&leftActiveType=" + get_leftActiveType;
- } else {
- window.location.href = "viewlist.html";
- }
- };
- ///左侧tab点击切换
- $('#sptabLeftCode').settabs({
- event: 'click'
- });
- var get_userid = "";
- var get_routeid = sp.getUrlName("routeid");
- //////取得权限设置
- function getRole() {
- $.ajax({
- url: 'json/role.txt',
- type: 'get',
- data: { userid: get_userid },
- dataType: "json",
- success: function (res) {
- if (res.success) {
- if (res.message == "addAndEdit") {
- ///新增和编辑权限
- $("#btnSaveHtmlFileSpan").show();
- } else if (res.message == "edit") {
- ///编辑权限可以设计和保存
- $("#btnSaveHtmlFileSpan").show();
- } else if (res.message == "read") {
- ///只读权限,提交按钮删除
- $("#btnSaveHtmlFileSpan").remove();
- } else {
- $("#btnSaveHtmlFileSpan").remove();
- sp.dialog("您好,返回的权限不正确");
- }
- } else {
- sp.dialog("您好,未得到权限设置");
- }
- },
- error: function (returndata) {
- }
- });
- };
- getRole();
- var fbDragVars = {};////声明变量存储要拖拽的左侧字段控件
- var queryDataColsCustom_data = {};///声明变量存储加载到的左侧字段的数据
- /////主表字段构成20180826
- function getFbTableDataFild() {
- queryDataColsCustom_data = {};///声明变量存储加载到的左侧字段的数据
- var fbdataurl = "";///声明数据路径
- if (get_routeid == "23001") {
- fbdataurl = "json.page/fawen/fawen_huiYiJiYao_24.txt?v=" + new Date();////发文--会议纪要--word24
- } else if (get_routeid == "23002") {
- fbdataurl = "json.page/fawen/fawen_dangweizhengshiwen_17.txt?v=" + new Date();////发文--党委正式文--word17
- } else if (get_routeid == "23003") {
- fbdataurl = "json.page/fawen/fawen_dangweiqitawen_13.txt?v=" + new Date();////发文--党委其他文--word13
- } else if (get_routeid == "23003") {
- fbdataurl = "json.page/shouwen/shouwen_lingdaopishidangkouchengbandan_3.txt?v=" + new Date();////收文--领导批示党口承办单--word3
- } else if (get_routeid == "23003") {
- fbdataurl = "json.page/shouwen/shouwen_zhujianweiwenjianchengbandan_4.txt?v=" + new Date();////收文--住建委文件承办单--word4
- } else if (get_routeid == "23991") {
- fbdataurl = "json.page/spandown/spandown_test_1.txt?v=" + new Date();////为了演示
- } else {
- fbdataurl = "json/formdata.txt?v=" + new Date();////为了演示
- }
-
- var postData = {
- "formeditid": get_formeditid,
- "billkey":""
- }
- var postData_post = {
- "data": s4.encryptData_CBC(JSON.stringify(postData))
- }
- $.ajax({
- type: "post",
- //url: fbdataurl,
- url: apiurljs.login + "g2work/formedit/queryDataColsCustom",
- //data: {
- // "data": s4.encryptData_CBC(JSON.stringify(postData))
- //},
- data: JSON.stringify(postData_post),
- dataType: "json",
- contentType: "application/json",
- headers: { Authorization: "Bearer " + get_AccessToken }, ////请求头headers
- success: function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data)).data;
- queryDataColsCustom_data = res;
- //console.log(JSON.stringify(res));
- //遍历主表 20180828
- //console.log(res);
- if (sp.isval(res.TableCols)) {
- $.each(res.TableCols, function (index, item) {
- //console.log(item.showtype);
- if (item.EKIND == "edit") {
- var varname = "fb$_10_0$main$_101_$table$" + index + "_$vars$_$010$_$control";
- fbDragVars[varname] = "<input type='text' data-type='text' data-showtype='" + item.EKIND + "' data-code='" + item.CODE + "' id='" + res.TableName + "_0_0_0_" + item.CODE + "' />";
-
- var fbleftcol = "<span draggable=\"true\" data-type='" + item.EKIND + "' id=\"controlDivPart_fbleftcol_" + index + "\" data-control=\"fb$_10_0$main$_101_$table$" + index + "\" data-controlid=\"" + res.TableName + "_0_0_0_" + item.CODE + "\" class=\"draggable fb-left-col\" title=\"" + item.CNAME + "\">" + item.CNAME + "</span>";
- $("#controlDivPart").append(fbleftcol);
- } else if (item.EKIND == "datetime") {
- var varname = "fb$_10_0$main$_101_$table$" + index + "_$vars$_$010$_$control";
- fbDragVars[varname] = "<input type='text' data-type='date' data-showtype='" + item.EKIND + "' data-code='" + item.CODE + "' id='" + res.TableName + "_0_0_0_" + item.CODE + "' class='laydate-logo' data-format='yyyy-MM-dd' />";
- var fbleftcol = "<span draggable=\"true\" data-type='" + item.EKIND + "' id=\"controlDivPart_fbleftcol_" + index + "\" data-control=\"fb$_10_0$main$_101_$table$" + index + "\" data-controlid=\"" + res.TableName + "_0_0_0_" + item.CODE + "\" class=\"draggable fb-left-col\" title=\"" + item.CNAME + "\">" + item.CNAME + "</span>";
- $("#controlDivPart").append(fbleftcol);
- } else if (item.EKIND == "number") {
- var varname = "fb$_10_0$main$_101_$table$" + index + "_$vars$_$010$_$control";
- fbDragVars[varname] = "<input type='number' data-type='text' data-showtype='" + item.EKIND + "' data-code='" + item.CODE + "' id='" + res.TableName + "_0_0_0_" + item.CODE + "' />";
- var fbleftcol = "<span draggable=\"true\" data-type='" + item.EKIND + "' id=\"controlDivPart_fbleftcol_" + index + "\" data-control=\"fb$_10_0$main$_101_$table$" + index + "\" data-controlid=\"" + res.TableName + "_0_0_0_" + item.CODE + "\" class=\"draggable fb-left-col\" title=\"" + item.CNAME + "\">" + item.CNAME + "</span>";
- $("#controlDivPart").append(fbleftcol);
- } else if (item.EKIND == "decimal") {
- var varname = "fb$_10_0$main$_101_$table$" + index + "_$vars$_$010$_$control";
- fbDragVars[varname] = "<input type='number' data-type='text' data-showtype='" + item.EKIND + "' data-code='" + item.CODE + "' id='" + res.TableName + "_0_0_0_" + item.CODE + "' />";
- var fbleftcol = "<span draggable=\"true\" data-type='" + item.EKIND + "' id=\"controlDivPart_fbleftcol_" + index + "\" data-control=\"fb$_10_0$main$_101_$table$" + index + "\" data-controlid=\"" + res.TableName + "_0_0_0_" + item.CODE + "\" class=\"draggable fb-left-col\" title=\"" + item.CNAME + "\">" + item.CNAME + "</span>";
- $("#controlDivPart").append(fbleftcol);
- } else if (item.EKIND == "text") {
- var varname = "fb$_10_0$main$_101_$table$" + index + "_$vars$_$010$_$control";
- fbDragVars[varname] = "<textarea id='" + res.TableName + "_0_0_0_" + item.CODE + "' data-showtype='" + item.EKIND + "' data-code='" + item.CODE + "' rows='4'></textarea>";
- var fbleftcol = "<span draggable=\"true\" data-type='" + item.EKIND + "' id=\"controlDivPart_fbleftcol_" + index + "\" data-control=\"fb$_10_0$main$_101_$table$" + index + "\" data-controlid=\"" + res.TableName + "_0_0_0_" + item.CODE + "\" class=\"draggable fb-left-col\" title=\"" + item.CNAME + "\">" + item.CNAME + "</span>";
- $("#controlDivPart").append(fbleftcol);
- } else if (item.EKIND == "select") {
- var options = "";
- var varname = "fb$_10_0$main$_101_$table$" + index + "_$vars$_$010$_$control";
-
- options = "<option>选项1</option><option>选项2</option>"
- fbDragVars[varname] = "<select id='" + res.TableName + "_0_0_0_" + item.CODE + "' data-code='" + item.CODE + "' data-showtype='" + item.EKIND + "'>" + options + "</select>";
- var fbleftcol = "<span draggable=\"true\" data-type='" + item.EKIND + "' id=\"controlDivPart_fbleftcol_" + index + "\" data-control=\"fb$_10_0$main$_101_$table$" + index + "\" data-controlid=\"" + res.TableName + "_0_0_0_" + item.CODE + "\" class=\"draggable fb-left-col\" title=\"" + item.CNAME + "\">" + item.CNAME + "</span>";
- $("#controlDivPart").append(fbleftcol);
- } else if (item.EKIND == "radiobox") {
- var control = "";
- var varname = "fb$_10_0$main$_101_$table$" + index + "_$vars$_$010$_$control";
- control = "<label><input type='radio'/>选项1</label><label><input type='radio'/>选项2</label>"
- fbDragVars[varname] = "<div class='fb-radiopart sp-radio-none' data-showtype='" + item.EKIND + "' data-style='sp-radio-none' id='" + res.TableName + "_0_0_0_" + item.CODE + "' data-code='" + item.CODE + "'>" + control + "</div>";
- var fbleftcol = "<span draggable=\"true\" data-type='" + item.EKIND + "' id=\"controlDivPart_fbleftcol_" + index + "\" data-control=\"fb$_10_0$main$_101_$table$" + index + "\" data-controlid=\"" + res.TableName + "_0_0_0_" + item.CODE + "\" class=\"draggable fb-left-col\" title=\"" + item.CNAME + "\">" + item.CNAME + "</span>";
- $("#controlDivPart").append(fbleftcol);
- } else if (item.EKIND == "checkbox") {
- var control = "";
- var varname = "fb$_10_0$main$_101_$table$" + index + "_$vars$_$010$_$control";
-
- control = "<label><input type='checkbox'/>选项1</label><label><input type='checkbox'/>选项2</label>"
- fbDragVars[varname] = "<div class='fb-checkboxpart sp-checkbox-none' data-showtype='" + item.EKIND + "' data-style='sp-checkbox-none' id='" + res.TableName + "_0_0_0_" + item.CODE + "' data-code='" + item.CODE + "'>" + control + "</div>";
- var fbleftcol = "<span draggable=\"true\" data-type='" + item.EKIND + "' id=\"controlDivPart_fbleftcol_" + index + "\" data-control=\"fb$_10_0$main$_101_$table$" + index + "\" data-controlid=\"" + res.TableName + "_0_0_0_" + item.CODE + "\" class=\"draggable fb-left-col\" title=\"" + item.CNAME + "\">" + item.CNAME + "</span>";
- $("#controlDivPart").append(fbleftcol);
- } else if (item.EKIND == "imgupload") {
- var varname = "fb$_10_0$main$_101_$table$" + index + "_$vars$_$010$_$control";
- fbDragVars[varname] = "<span class='sp-upload' id='" + res.TableName + "_0_0_0_" + item.CODE + "' data-code='" + item.CODE + "'><img class='sp-upload-img' data-url='' alt='' style='width: 120px; height: 90px;' /><input type='file' class='sp-upload-file-img' /></span>";
- var fbleftcol = "<span draggable=\"true\" data-type='" + item.EKIND + "' id=\"controlDivPart_fbleftcol_" + index + "\" data-control=\"fb$_10_0$main$_101_$table$" + index + "\" data-controlid=\"" + res.TableName + "_0_0_0_" + item.CODE + "\" class=\"draggable fb-left-col\" title=\"" + item.CNAME + "\">" + item.CNAME + "</span>";
- $("#controlDivPart").append(fbleftcol);
- }
- else if (item.EKIND == "fileupload") {
- var varname = "fb$_10_0$main$_101_$table$" + index + "_$vars$_$010$_$control";
- fbDragVars[varname] = "<div class='sp-upload' id='" + res.TableName + "_0_0_0_" + item.CODE + "' data-code='" + item.CODE + "'><input type='button' class='sp-upload-btn-single' value='上传附件' /><input type='file' class='sp-upload-file-single' multiple='multiple' /><div class='sp-upload-tip'></div></div>";
- var fbleftcol = "<span draggable=\"true\" data-type='" + item.EKIND + "' id=\"controlDivPart_fbleftcol_" + index + "\" data-control=\"fb$_10_0$main$_101_$table$" + index + "\" data-controlid=\"" + res.TableName + "_0_0_0_" + item.CODE + "\" class=\"draggable fb-left-col\" title=\"" + item.CNAME + "\">" + item.CNAME + "</span>";
- $("#controlDivPart").append(fbleftcol);
- } else if (item.EKIND == "popradiobox") {
- ///弹出窗口,单项选择器
- var varname = "fb$_10_0$main$_101_$table$" + index + "_$vars$_$010$_$control";
- fbDragVars[varname] = "<input type='text' data-type='text' data-showtype='" + item.EKIND + "' onclick=\"spbld.layer_popradiobox_open('layer_popradiobox_" + item.CODE + "')\" data-code='" + item.CODE + "' id='" + res.TableName + "_0_0_0_" + item.CODE + "' class='spfb-input-popradiobox' readonly='readonly' data-ccode='' />";
- var fbleftcol = "<span draggable=\"true\" data-type='" + item.EKIND + "' id=\"controlDivPart_fbleftcol_" + index + "\" data-control=\"fb$_10_0$main$_101_$table$" + index + "\" data-controlid=\"" + res.TableName + "_0_0_0_" + item.CODE + "\" data-code='" + item.CODE + "' class=\"draggable fb-left-col\" title=\"" + item.CNAME + "\">" + item.CNAME + "</span>";
- $("#controlDivPart").append(fbleftcol);
- var varname_layer = "fb$_10_0$main$_101_$table$" + index + "_$vars$_$010$_$control_$010$_layer" + item.CODE;
- fbDragVars[varname_layer] = "<div class='sp-layer' id='layer_popradiobox_" + item.CODE + "' data-code='" + item.CODE + "' style='width:700px; max-height:500px;'>" +
- "<div class='sp-layer-head'><span class='sp-layer-title'>选择" + item.CNAME + "</span><span class='sp-layer-close' title='关闭' onclick='sp.layerhide()'>×</span></div>" +
- "<div class='sp-layer-body' style='max-height:410px; overflow-y:auto;'>"+
- "<div class='fb-radiopart sp-radio-blue' data-style='sp-radio-blue'>"+
- "<label><input type='radio' value='' />选项1</label><label><input type='radio' value='' />选项2</label>"+
- "</div>"+
- "</div>"+
- "<div class='sp-layer-foot'>"+
- "<div class='sp-page sp-mt-15'>"+
- "<span class='sp-btn-gray-outline sp-btn-radius' onclick='sp.layerhide()'>关 闭</span>" +
- "<span class='sp-btn-blue sp-btn-radius' onclick=\"spbld.layer_popradiobox_true('layer_popradiobox_" + item.CODE + "','" + res.TableName + "_0_0_0_" + item.CODE + "','" + item.CODE + "')\">确 定</span>" +
- "</div>"+
- "</div>"+
- "</div>";
- } else if (item.EKIND == "popcheckbox") {
- ///弹出窗口,多项选择器
- var varname = "fb$_10_0$main$_101_$table$" + index + "_$vars$_$010$_$control";
- fbDragVars[varname] = "<textarea data-type='popcheckbox' data-showtype='" + item.EKIND + "' id='" + res.TableName + "_0_0_0_" + item.CODE + "' onclick=\"spbld.layer_popcheckbox_open('layer_popcheckbox_" + item.CODE + "')\" class='spfb-textarea-popcheckbox-1' readonly='readonly' data-code='" + item.CODE + "' data-ccode='' rows='4'></textarea>";
- var fbleftcol = "<span draggable=\"true\" data-type='" + item.EKIND + "' id=\"controlDivPart_fbleftcol_" + index + "\" data-control=\"fb$_10_0$main$_101_$table$" + index + "\" data-controlid=\"" + res.TableName + "_0_0_0_" + item.CODE + "\" class=\"draggable fb-left-col\" data-code='" + item.CODE + "' title=\"" + item.CNAME + "\">" + item.CNAME + "</span>";
- $("#controlDivPart").append(fbleftcol);
- var varname_layer = "fb$_10_0$main$_101_$table$" + index + "_$vars$_$010$_$control_$010$_layer" + item.CODE;
- fbDragVars[varname_layer] = "<div class='sp-layer' id='layer_popcheckbox_" + item.CODE + "' data-code='" + item.CODE + "' style='width:700px; max-height:500px;'>" +
- "<div class='sp-layer-head'><span class='sp-layer-title'>选择" + item.CNAME + "</span><span class='sp-layer-close' title='关闭' onclick='sp.layerhide()'>×</span></div>" +
- "<div class='sp-layer-body' style='max-height:410px; overflow-y:auto;'>" +
- "<div class='fb-checkboxpart sp-checkbox-blue' data-style='sp-checkbox-blue'>" +
- "<label><input type='checkbox' value='' />选项1</label><label><input type='checkbox' value='' />选项2</label>" +
- "</div>" +
- "</div>" +
- "<div class='sp-layer-foot'>" +
- "<div class='sp-page sp-mt-15'>" +
- "<span class='sp-btn-gray-outline sp-btn-radius' onclick='sp.layerhide()'>关 闭</span>" +
- "<span class='sp-btn-blue sp-btn-radius' onclick=\"spbld.layer_popcheckbox_true('layer_popcheckbox_" + item.CODE + "','" + res.TableName + "_0_0_0_" + item.CODE + "','" + item.CODE + "')\">确 定</span>" +
- "</div>" +
- "</div>" +
- "</div>";
- } else if (item.EKIND == "optionbox") {
- ///意见控件
- var varname = "fb$_10_0$main$_101_$table$" + index + "_$vars$_$010$_$control";
- fbDragVars[varname] = "<div class='sp-page' data-type='popcheckbox' data-showtype='" + item.EKIND + "' id='" + res.TableName + "_0_0_0_" + item.CODE + "' >"+
-
- "</div>"+
- "<span class='sp-btn-gray-outline spfb-btn-sign' onclick=\"spbld.layer_optionbox_open('" + res.TableName + "_0_0_0_" + item.CODE + "','" + res.TableName + "','" + item.CODE + "')\">签写意见</span>";
- var fbleftcol = "<span draggable=\"true\" data-type='" + item.EKIND + "' id=\"controlDivPart_fbleftcol_" + index + "\" data-control=\"fb$_10_0$main$_101_$table$" + index + "\" data-controlid=\"" + res.TableName + "_0_0_0_" + item.CODE + "\" data-code='" + item.CODE + "' class=\"draggable fb-left-col\" title=\"" + item.CNAME + "\">" + item.CNAME + "</span>";
- $("#controlDivPart").append(fbleftcol);
- var varname_layer = "fb$_10_0$main$_101_$table$" + index + "_$vars$_$010$_$control_$010$_layer_optionbox" + item.CODE;
- fbDragVars[varname_layer] = "<div class='sp-layer' id='layer_optionbox' style='width:600px; max-height:500px;'>" +
- "<div class='sp-layer-head'><span class='sp-layer-title'>签写意见</span><span class='sp-layer-close' title='关闭' onclick='sp.layerhide()'>×</span></div>" +
- "<div class='sp-layer-body' style='max-height:410px; overflow-y:auto;'>" +
- "<div class='sp-tab' id='layer_optionbox_tabs'>" +
- "<ul class='sp-tab-menu'>" +
- "<li data-index='0' class='sp-tab-current'>文字</li>" +
- "<li data-index='1'>手签</li>" +
- "</ul>" +
- "<div class='sp-tab-box' style='padding:10px 0; margin-left:1.5%;'>" +
- "<div class='sp-tab-current'>" +
- "<div class='sp-page'>" +
- "<div class='sp-col-50'>" +
- "<textarea id='layer_optionbox_textarea' class='sp-textarea' style='height:300px;'>" +
- "</textarea>" +
- "</div>" +
- "<div class='sp-col-50' style='border-left:1px solid #dedede; box-sizing:border-box;'>" +
- "<div class='sp-page-title'>常用语</div>" +
- "<div class='sp-line-gray sp-mt-5 sp-mb-5'></div>" +
- "<div class='sp-page' id='layer_optionbox_patterns' style='height:185px; overflow-y:auto;'>" +
- "<span class='sp-lh-20'>常用语1</span>" +
- "<span class='sp-lh-20'>常用语2</span>" +
- "</div>" +
- "<div class='sp-page-title'>新增常用语</div>" +
- "<div class='sp-line-gray sp-mt-5 sp-mb-5'></div>" +
- "<div class='sp-page' style='height:40px; overflow-y:auto;'>" +
- "<div class=sp-col-70><input type='text' class='sp-input' placeholder='请输入关键字' id='layer_optionbox_patterns_input' /></div>" +
- "<div class=sp-col-30><div class='sp-mt-5'><span class='sp-btn-blue sp-btn-md sp-btn-radius' onclick='spbld.layer_optionbox_patterns_add()'>新增</span></div></div>" +
- "</div>" +
- "</div>" +
- "</div>" +
- "</div>" +
- "<div class=' sp-tab-hide'>" +
- "<div class='spfb-optionbox-canvas' id='layer_optionbox_canvas_outpart' style='float:left; width:100%; height:274px; position:relative;'>"+
- "<canvas id='layer_optionbox_canvas' style='width: 100%; height: 100%;'></canvas>" +
- "</div>" +
- "<div class='sp-page sp-mt-10 sp-text-right'><span class='sp-btn-gray-outline sp-btn-radius' onclick='spbld.layer_optionbox_cnavas_clear()'>清 除</span></div>" +
- "</div>" +
- "</div>" +
- "</div>" +
- "</div>" +
- "<div class='sp-layer-foot'>" +
- "<div class='sp-page sp-mt-15'>" +
- "<span class='sp-btn-gray-outline sp-btn-radius' onclick='sp.layerhide()'>关 闭</span>" +
- "<span class='sp-btn-blue sp-btn-radius' id='layer_optionbox_true_btn' onclick='spbld.layer_optionbox_true()'>确 定</span>" +
- "</div>" +
- "</div>" +
- "</div>";
- } else if (item.EKIND == "htmltext") {
- ///HTML编辑控件,
- var varname = "fb$_10_0$main$_101_$table$" + index + "_$vars$_$010$_$control";
- fbDragVars[varname] = "正在开发中..";
- var fbleftcol = "<span draggable=\"true\" data-type='" + item.EKIND + "' id=\"controlDivPart_fbleftcol_" + index + "\" data-control=\"fb$_10_0$main$_101_$table$" + index + "\" data-controlid=\"" + res.TableName + "_0_0_0_" + item.CODE + "\" class=\"draggable fb-left-col\">" + item.CNAME + "</span>";
- $("#controlDivPart").append(fbleftcol);
- } else { return; }
- });
- ////遍历子表json20180828---删除掉了,20230306
-
- ///将此方法放在dom成功之后调用
- setup_draggable();////调用h5的拖拽的方法
- } else {
- sp.dialog("您好," + res.TableName + " 为空表");
- }
- },
- error: function (XMLHttpRequest, textStatus, errorThrown) {
- console.log(errorThrown);
- }
- });
- };
- /////拖拽方法,异步加载json生成左侧的字段时,将此方法放在dom成功之后
- function setup_draggable() {
- var iframeWindow = $('#formBuilderTextarea_ifr')[0].contentWindow;
- $('.draggable').on("dragstart", function (ev) {
- //ondragstart - 用户开始拖动元素时触发
- var dt = ev.originalEvent.dataTransfer;
- //dt.setData('crossIframeDragType', $(this).attr("data-type"));
- dt.setData('crossIframeDragType', $(this).attr("id"));
- dt.effectAllowed = 'move';
- iframeWindow.isCrossIFrameDragging = true;
- }).on("dragend", function (ev) {
- //ondragend - 用户完成元素拖动后触发
- iframeWindow.isCrossIFrameDragging = false;
- });
- /////为iframe中的td添加拖拽进入事件,然后判断isCrossIFrameDragging
- $(iframeWindow.document)
- .on("dragenter", 'td', function (ev) {
- //console.log('dragenter');
- ///说明文档-http://www.runoob.com/jsref/event-ondragstart.html
- ///ondragenter - 当被鼠标拖动的对象进入其容器范围内时触发此事件
- if (iframeWindow.isCrossIFrameDragging) {
- $(ev.target).addClass("hover");
- }
- })
- .on('dragleave', 'td', function (ev) {
- //console.log('dragleave');
- //ondragleave - 当被鼠标拖动的对象离开其容器范围内时触发此事件
- if (iframeWindow.isCrossIFrameDragging) {
- $(ev.target).removeClass('hover');
- //console.log();
- }
- })
- .on("dragover", 'td', function (ev) {
- //console.log('dragover');
- //ondragover-当某被拖动的对象在另一对象容器范围内拖动时触发此事件
- if (iframeWindow.isCrossIFrameDragging) {
- ev.preventDefault();
- ev.originalEvent.dataTransfer.dropEffect = 'move';
- }
- })
- .on("drop", 'td', function (ev) {
- ev.stopPropagation();
- //console.log('drop');
- $(iframeWindow.document).find('td').find("br").remove(); ///将里面含br的去掉
- //ondrop - 在一个拖动过程中,释放鼠标键时触发此事件
- var df = ev.originalEvent.dataTransfer;
-
- var get_crossIframeDragType = df.getData("crossIframeDragType");
-
- if (iframeWindow.isCrossIFrameDragging) {
- //$(ev.target).removeClass('hover').text("丢掉了[" + data + "],好样的,继续!");
- var gettd1html = $(ev.target).html();
-
- $(ev.target).html(gettd1html.replace(/<br>/g, ""));//将里面的<br>换行符去掉
- var get_text = $("#" + get_crossIframeDragType).text();
- var get_control = $("#" + get_crossIframeDragType).attr("data-control");
- var _varcontrol = "fbDragVars." + get_control + "_$vars$_$010$_$control";
- //注释这两行,其业务是当前td放置标题,下一个td放置控件---20230107
- //$(ev.target).removeClass('hover').append(get_text);
- //$(ev.target).next("td").removeClass('hover').append(eval(_varcontrol));
- ///修改成拖动字段只放置控件,标题未录入模式;---20230107
- var get_controid = $("#" + get_crossIframeDragType).attr("data-controlid");
- if ($(iframeWindow.document).find('body').find("#" + get_controid).length <1) {
- //没有重复项
- $(ev.target).removeClass('hover').append(eval(_varcontrol));
- var get_controlType = $("#" + get_crossIframeDragType).attr("data-type");
- if (get_controlType == "popradiobox") {
- var setLayerVarcontrol = "fbDragVars." + get_control + "_$vars$_$010$_$control_$010$_layer" + $("#" + get_crossIframeDragType).attr("data-code");
- $(iframeWindow.document).find(".sp-fb-grid").after(eval(setLayerVarcontrol));
- }
- if (get_controlType == "popcheckbox") {
- var setLayerVarcontrol = "fbDragVars." + get_control + "_$vars$_$010$_$control_$010$_layer" + $("#" + get_crossIframeDragType).attr("data-code");
- $(iframeWindow.document).find(".sp-fb-grid").after(eval(setLayerVarcontrol));
- }
- if (get_controlType == "optionbox") {
- var setLayerVarcontrol = "fbDragVars." + get_control + "_$vars$_$010$_$control_$010$_layer_optionbox" + $("#" + get_crossIframeDragType).attr("data-code");
- //if ($(iframeWindow.document).find("#layer_optionbox").length < 1) {
- // $(iframeWindow.document).find(".sp-fb-grid").after(eval(setLayerVarcontrol));
- //}
- $(iframeWindow.document).find("#layer_optionbox").remove();
- $(iframeWindow.document).find(".sp-fb-grid").after(eval(setLayerVarcontrol));
- }
- setgridControlOperate();/////控件综合设置
- } else {
- sp.dialog("您好,表单中已有 \"" + get_text + "\" 组件!");
- }
-
-
- }
- });
-
- }
- ///根据id判断加载视图中有无先前设计好的表单文件,有则加载到设计区域,无则设计区域为空*********************************************
- function fucGetFile() {
- var postData = {
- "ckey": "",
- "userid": get_userId,
- "formeditid": get_formeditid,
- "directionid": "0",
- "routeinfoid": "0",
- "routeid": "0",
- "id": "0"
- }
-
- //console.log(JSON.stringify(postData));
- var postData_post = {
- "data": s4.encryptData_CBC(JSON.stringify(postData))
- }
- //var postData_post_2 = {
- // "data": JSON.stringify(postData)
- //}
- //console.log(postData_post_2);
- $.ajax({
- type: "post",
- //url: fbdataurl,
- url: apiurljs.login + "g2app/abase/queryDataCustom",
- //data: {
- // "data": s4.encryptData_CBC(JSON.stringify(postData))
- //},
- data: JSON.stringify(postData_post),
- dataType: "json",
- contentType: "application/json",
- headers: { Authorization: "Bearer " + get_AccessToken }, ////请求头headers
- success: function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data)).data;
- //console.log(res);
- //console.log(s4.decryptData_CBC(res.TableData));
- if (sp.isval(res.TableData)) {
- var iframeWindow = $('#formBuilderTextarea_ifr')[0].contentWindow;
- $(iframeWindow.document).find('body').html(s4.decryptData_CBC(res.TableData));
- setgridControlOperate();
- }
-
- },
- //请求执行异常执行的方法
- error: function (XMLHttpRequest, textStatus, errorThrown) {
- alert("您好,表单加载失败");
- }
- });
- }
- ///加载数据,整体设置*********************************************
- function getData() {
- if (get_routeid != "" && get_routeid != null && get_routeid != undefined) {
- fucGetFile();////判断是否有设计过的自定义表单
- getFbTableDataFild();///主子表字段构成
- } else {
- sp.dialog("未得到参数routeid,请确保参数正确!");
- location.href = "viewlist.html";
- }
- }
- //表单设计--点击切换事件
- btnStartDesign = function (obj) {
- $(".sp-list-type-title").removeClass("sp-list-type-active");
- $(obj).addClass("sp-list-type-active");
- $(".sp-form-builder").hide();
- $($(obj).attr("data-href")).show();
- };
- ////清空
- btn_spbldClear = function () {
- if (confirm("您确定要清空表单吗?")) {
- var iframeWindow = $('#formBuilderTextarea_ifr')[0].contentWindow;
- $(iframeWindow.document).find("body").html("");
- $(iframeWindow.document).find("body").text("");
- $(".sp-list-type-title").removeClass("sp-list-type-active");
- $("#btnStartDesign_tab").addClass("sp-list-type-active");
- $(".sp-form-builder").hide();
- $("#formBuilderTextareaPart").show();
- }
- }
- ////表单预览
- btnViewDesign = function (obj) {
- //$(".sp-list-type-title").removeClass("sp-list-type-active");
- //$(obj).addClass("sp-list-type-active");
- //$(".sp-form-builder").hide();
- //$($(obj).attr("data-href")).show();
- sp.layer($(obj).attr("data-href"));
- var iframeWindow = $('#formBuilderTextarea_ifr')[0].contentWindow;
- if ($(iframeWindow.document).find('table').length > 0) {
- $(iframeWindow.document).find('table').removeClass("mce-item-table").removeAttr("data-mce-selected").removeAttr("data-mce-style");
- $(iframeWindow.document).find('td').removeAttr("data-mce-selected").removeAttr("data-mce-style");
- $(iframeWindow.document).find('div').removeAttr("data-mce-selected").removeAttr("data-mce-style");
- $(iframeWindow.document).find(".mce-resizehandle").remove();
- var gettablehtml = $(iframeWindow.document).find('body').html();
- gettablehtml = gettablehtml.replace(/<br("[^"]*"|'[^']*'|[^'">])*>/g, "").replace(/sp-grid-control-checked/g, "");
- ////start---向iframe中跨域传递消息
- var iframeViewID = document.getElementById('iframeViewPart');
- var targetOrigin = '*';
- var func = { name: "formBuilderHtml", arg: gettablehtml };//传输name名称以及html代码
- iframeViewID.contentWindow.postMessage(func, targetOrigin);
- ////end---向iframe中跨域传递消息
- } else {
- ////start---向iframe中跨域传递消息
- var iframeViewID = document.getElementById('iframeViewPart');
- var targetOrigin = '*';
- var func = { name: "formBuilderHtml", arg: 0 };//传输name名称以及html代码
- iframeViewID.contentWindow.postMessage(func, targetOrigin);
- ////end---向iframe中跨域传递消息
- }
- };
- ///表单源码
- btnViewCode = function (obj) {
- $(".sp-list-type-title").removeClass("sp-list-type-active");
- $(obj).addClass("sp-list-type-active");
- $(".sp-form-builder").hide();
- $($(obj).attr("data-href")).show();
- var iframeWindow = $('#formBuilderTextarea_ifr')[0].contentWindow;
-
- if ($(iframeWindow.document).find('table').length > 0 || $(iframeWindow.document).find('div').length > 0) {
- $(iframeWindow.document).find('table').removeClass("mce-item-table").removeAttr("data-mce-selected").removeAttr("data-mce-style");
- //$(iframeWindow.document).find('table').removeAttr("data-mce-selected").removeAttr("data-mce-style");
- $(iframeWindow.document).find('td').removeAttr("data-mce-selected").removeAttr("data-mce-style");
- $(iframeWindow.document).find('div').removeAttr("data-mce-selected").removeAttr("data-mce-style");
- $(iframeWindow.document).find(".mce-resizehandle").remove();
- var gettablehtml = $(iframeWindow.document).find('body').html();
- //gettablehtml = gettablehtml.toString().replace(/<table("[^"]*"|'[^']*'|[^'">])*>/g, '<table class="sp-fb-grid">');
- gettablehtml = gettablehtml.replace(/<br("[^"]*"|'[^']*'|[^'">])*>/g, "").replace(/sp-grid-control-checked/g, "").replace(/\<\/textarea\>/g, "<!--textarea-->");
-
- //gettablehtml = gettablehtml.replace(/sp-grid-control-checked/g, "");///替换选中的class
- //gettablehtml = gettablehtml.replace(/\<\/textarea\>/g, "<!--textarea-->");///替换选中的class
- //gettablehtml = gettablehtml.replace(/data\-click\=('|")laydate('|")/g, "onclick='laydate()'");///替换选中的时间点击事件
- //console.log(gettablehtml);
- var gettablehtml2 = "<textarea class='sp-textarea' id='formBuilderCodeTextarea' name='code' style='min-height:400px;'>" + gettablehtml + "</textarea>";
-
- $($(obj).attr("data-href")).html(html_beautify(gettablehtml2));
- var editor_two = CodeMirror.fromTextArea(document.getElementById("formBuilderCodeTextarea"), {
- lineNumbers: true,
- matchBrackets: true,
- styleActiveLine: true,
- //matchBrackets: true, // 括号匹配
- //mode: "htmlmixed" ///html混合模式
- //theme: "ambiance"
- })
- sp.fitHeight(".CodeMirror", 60);
- ////20230523--zyg
- editor_two.on("change", function () {
- //事件触发后执行事件 alert("change")
- var get_editor_val = editor_two.getValue();///获取编辑器内容
- if (get_editor_val.indexOf(" <!--textarea-->") != -1) {
- ///此处原因是 前面将</textarea>结尾符号,编译为<!--textarea-->; 因而需要再次将其替换过来
- get_editor_val = get_editor_val.toString().replace(/<!--textarea-->/g, " </textarea>");
- }
- //console.log(get_editor_val);
- $(iframeWindow.document).find("body").html("");
- $(iframeWindow.document).find("body").text("");
- $(iframeWindow.document).find("body").html(get_editor_val);
- });
-
- } else {
- var tip = "<div class='sp-table-tip' style='margin-top:-10px;'>您好,暂无表单源码</div>";
- $($(obj).attr("data-href")).html(tip);
- }
-
- };
- /////保存表单
- function btnSaveHtmlFile() {
- if (confirm("您好,您确定要保存此表单吗?")) {
- sp.dialog("正在保存..")
- var iframeWindow = $('#formBuilderTextarea_ifr')[0].contentWindow;
- if ($(iframeWindow.document).find('table').length > 0) {
- $(iframeWindow.document).find('table').removeClass("mce-item-table").removeAttr("data-mce-selected").removeAttr("data-mce-style");
- //$(iframeWindow.document).find('table').removeAttr("data-mce-selected").removeAttr("data-mce-style");
- $(iframeWindow.document).find('td').removeAttr("data-mce-selected").removeAttr("data-mce-style");
- $(iframeWindow.document).find('div').removeAttr("data-mce-selected").removeAttr("data-mce-style");
- $(iframeWindow.document).find(".mce-resizehandle").remove();
- var gettablehtml = $(iframeWindow.document).find('body').html();
- gettablehtml = gettablehtml.replace(/<br("[^"]*"|'[^']*'|[^'">])*>/g, "").replace(/sp-grid-control-checked/g, "");///替换br
- ///20230306编写,获取设计表单中已使用的左侧字段
- var set_hascontrol_tablecols = [];
- if (sp.isval(queryDataColsCustom_data.TableCols)) {
- $.each(queryDataColsCustom_data.TableCols, function (index2, item2) {
- var set_hascontol = queryDataColsCustom_data.TableName + "_0_0_0_" + item2.CODE;
- if ($(iframeWindow.document).find('body').find("#" + set_hascontol).length > 0) {
- set_hascontrol_tablecols.push(item2);
- }
- });
- } else {
- sp.dialog("您好," + queryDataColsCustom_data.TableName + " 为空表");
- }
- if (sp.isval(set_hascontrol_tablecols)) {
- ///判断是否为空表单,不是空表单时可以保存,
- //调用方法生成表单html文件
- var postData = {
- "formeditid": get_formeditid,
- "routeinfoid": "0",
- "routeid": "0",
- "id": "0",
- "tabledata": s4.encryptData_CBC(gettablehtml),
- "data": set_hascontrol_tablecols
- }
-
- var postData_post = {
- "data": s4.encryptData_CBC(JSON.stringify(postData))
- }
- //var postData_post_2 = {
- // "data": JSON.stringify(postData)
- //}
- //console.log(JSON.stringify(postData_post_2));
- $.ajax({
- type: "post",
- //url: fbdataurl,
- url: apiurljs.login + "/g2app/abase/saveDataCustom",
- //data: {
- // "data": s4.encryptData_CBC(JSON.stringify(postData))
- //},
- data: JSON.stringify(postData_post),
- dataType: "json",
- contentType: "application/json",
- headers: { Authorization: "Bearer " + get_AccessToken }, ////请求头headers
- success: function (result) {
-
- var res = strToJson(s4.decryptData_CBC(result.data)); //静态文件路径
- console.log(res);
- if (res.success) {
- fucGetFile();///再次加载
- sp.dialoghide();
- sp.dialog("您好,表单文件保存成功");
- }
- },
- //请求执行异常执行的方法
- error: function (XMLHttpRequest, textStatus, errorThrown) {
- sp.dialog("您好,表单文件生成失败");
- }
- });
- } else {
- sp.dialog("您好,当前为空表单,先设计表单!");
- }
-
- }
- else {
- sp.dialog("你好,暂无表单设计");
- }
- }
- else {
- return;
- }
- }
- ////*******设置点击控件后选中操作及右侧弹出设置区域*********************************************************************************************************
- function clearControlChecked(obj) {
- ///清除表格设计中的控件选中操作--
- obj.find("input").removeClass("sp-grid-control-checked"); ///文本框去掉选中样式
- obj.find("textarea").removeClass("sp-grid-control-checked");///多行文本框去掉选中样式
- obj.find(".fb-radiopart").removeClass("sp-grid-control-checked");//单选区域去掉选中样式
- obj.find(".fb-checkboxpart").removeClass("sp-grid-control-checked");//多选区域去掉选中样式
- obj.find(".sp-upload-img").removeClass("sp-grid-control-checked");//上传图片设置宽高区域
- obj.find("select").removeClass("sp-grid-control-checked");//下拉框去掉选中样式
-
- }
- function setgridControlOperate() {
- var iframeWindow = $('#formBuilderTextarea_ifr')[0].contentWindow;
- $(iframeWindow.document).find("input[data-type='text']").each(function () {
- /////文本框点击
- $(this).click(function () {
- //clearControlChecked($(iframeWindow.document));
- clearControlChecked($(iframeWindow.document));
- operate_textControl(this);
- });
- });
- $(iframeWindow.document).find("textarea").each(function () {
- /////多选框点击
- $(this).click(function () {
- clearControlChecked($(iframeWindow.document));
- operate_textControl(this);
- });
- });
- $(iframeWindow.document).find("input[data-type='date']").each(function () {
- /////日期框点击
- $(this).click(function () {
- clearControlChecked($(iframeWindow.document));
- $(".fb-textbox-part").hide();
- $(".fb-checkbox-part").hide();
- $(".fb-radio-part").hide();
- $(".fb-upload-img").hide(); //图片上传设置宽高区域
- $(".fb-dateset-part").show();
- $(".fb-setStyle-part").show();///设置补充样式
- $(this).addClass("sp-grid-control-checked");
- ///获取其style中的补充样式 -- 补充样式
- $("#trea_setClassBuChong").val($(this).attr("style")).attr("data-setid", $(this).attr("id"));
- ////为删除按钮赋值点中的控件的id--20230114
- $("#btn_delControl").attr("data-setid", $(this).attr("id"));
- var getformat = $(this).attr("data-format"); ///取得其验证格式
- $("#fbdatesetspanpart .sp-checkbox-tabs").removeClass("sp-checkbox-tabs-active")
- if (getformat != "" && getformat != null && getformat != undefined) {
- $("#fbdatesetspanpart span[data-value='" + getformat + "']").addClass("sp-checkbox-tabs-active");
- } else {
- $("#fbdatesetspanpart span[data-value='yyyy-MM-dd']").addClass("sp-checkbox-tabs-active");
- $(this).attr("data-format", 'yyyy-MM-dd');
- };
- ////判断其是否含有必填,含有则加上选中不含有则去掉选中
- if ($(this).hasClass("sp-required-date")) {
- $("#btnDateSetRequire").attr("checked", true).parent("label").addClass("chb-blue-checked");
- } else {
- $("#btnDateSetRequire").removeAttr("checked").parent("label").removeClass("chb-blue-checked");
- }
-
- });
- });
-
- ////单选区域
- $(iframeWindow.document).find(".fb-radiopart").each(function () {
- $(this).click(function () {
- clearControlChecked($(iframeWindow.document));
- $(".fb-textbox-part").hide();
- $(".fb-checkbox-part").hide();
- $(".fb-dateset-part").hide(); ///日期区域
- $(".fb-upload-img").hide(); //图片上传设置宽高区域
- $(".fb-radio-part").show();
- $(".fb-setStyle-part").show();///设置补充样式
- $(this).addClass("sp-grid-control-checked");
- ///获取其style中的补充样式 -- 补充样式
- $("#trea_setClassBuChong").val($(this).attr("style")).attr("data-setid", $(this).attr("id"));
- ////为删除按钮赋值点中的控件的id--20230114
- $("#btn_delControl").attr("data-setid", $(this).attr("id"));
- var get_style = $(this).attr("data-style"); ///取得其风格类别
- if (get_style != "" && get_style != null && get_style != undefined && get_style != "sp-radio-none") {
- $("#chb_selectRadioStyle").attr("checked", true).parent("label").addClass("chb-blue-checked");
- $("#selectRadioStylePart").show();
- $(".fb-radio-part select").val(get_style);
- } else {
- $("#chb_selectRadioStyle").removeAttr("checked").parent("label").removeClass("chb-blue-checked");
- $("#selectRadioStylePart").hide();
- $(".fb-radio-part select").val("sp-radio-none");
- }
- });
- });
- ////多选区域
- $(iframeWindow.document).find(".fb-checkboxpart").each(function () {
- $(this).click(function () {
- clearControlChecked($(iframeWindow.document));
- $(".fb-textbox-part").hide();
- $(".fb-radio-part").hide();
- $(".fb-dateset-part").hide(); ///日期区域
- $(".fb-upload-img").hide(); //图片上传设置宽高区域
- $(".fb-checkbox-part").show();
- $(".fb-setStyle-part").show();///设置补充样式
- $(this).addClass("sp-grid-control-checked");
- ///获取其style中的补充样式 -- 补充样式
- $("#trea_setClassBuChong").val($(this).attr("style")).attr("data-setid", $(this).attr("id"));
- ////为删除按钮赋值点中的控件的id--20230114
- $("#btn_delControl").attr("data-setid", $(this).attr("id"));
- var get_style = $(this).attr("data-style"); ///取得其风格类别
- if (get_style != "" && get_style != null && get_style != undefined && get_style != "sp-checkbox-none") {
- $("#chb_selectCheckboxStyle").attr("checked", true).parent("label").addClass("chb-blue-checked");
- $("#selectCheckboxStylePart").show();
- $(".fb-checkbox-part select").val(get_style);
- } else {
- $("#chb_selectCheckboxStyle").removeAttr("checked").parent("label").removeClass("chb-blue-checked");
- $("#selectCheckboxStylePart").hide();
- $(".fb-checkbox-part select").val("sp-checkbox-none");
- }
- });
- });
- /////上传图片区域
- $(iframeWindow.document).find(".sp-upload-img").each(function () {
- $(this).click(function () {
- clearControlChecked($(iframeWindow.document));
- $(".fb-textbox-part").hide();
- $(".fb-radio-part").hide();
- $(".fb-dateset-part").hide(); ///日期区域
- $(".fb-checkbox-part").hide();
- $(".fb-upload-img").show(); //图片上传设置宽高区域
- $(".fb-setStyle-part").show();///设置补充样式
- $(this).addClass("sp-grid-control-checked");
- ///获取其style中的补充样式 -- 补充样式
- $("#trea_setClassBuChong").val($(this).attr("style")).attr("data-setid", $(this).attr("id"));
- ////为删除按钮赋值点中的控件的id--20230114
- $("#btn_delControl").attr("data-setid", $(this).parent().attr("id"));
- var get_width = $(this).outerWidth();
- var get_height = $(this).outerHeight();
- $("#fbUploadImgWidth").val(get_width);
- $("#fbUploadImgHeight").val(get_height);
- });
- });
- /////下拉框点击--20230110
- $(iframeWindow.document).find("select").each(function () {
- $(this).click(function () {
- clearControlChecked($(iframeWindow.document));
- $(".fb-textbox-part").hide();
- $(".fb-checkbox-part").hide();
- $(".fb-radio-part").hide();
- $(".fb-upload-img").hide(); //图片上传设置宽高区域
- $(".fb-dateset-part").hide();
- $(".fb-setStyle-part").show();///设置补充样式
-
- $(this).addClass("sp-grid-control-checked");
- ///获取其style中的补充样式 -- 补充样式
- $("#trea_setClassBuChong").val($(this).attr("style")).attr("data-setid", $(this).attr("id"));
- ////为删除按钮赋值点中的控件的id--20230114
- $("#btn_delControl").attr("data-setid", $(this).attr("id"));
- });
- });
-
- };
- ///表格设计中输入框控件选中操作
- function operate_textControl(obj) {
- $(".fb-checkbox-part").hide();
- $(".fb-radio-part").hide();
- $(".fb-dateset-part").hide(); ///日期区域
- $(".fb-upload-img").hide(); //图片上传设置宽高区域
- $(".fb-textbox-part").show();
- $(".fb-setStyle-part").show();///设置补充样式
- $(obj).addClass("sp-grid-control-checked").focus();
- ///判断其含有必填,若有则右侧进行选中,无则去掉选种
- if ($(obj).hasClass("sp-required")) {
- $("#fucbtnRequire").attr("checked", true).parent("label").addClass("chb-blue-checked");
- } else {
- $("#fucbtnRequire").removeAttr("checked").parent("label").removeClass("chb-blue-checked");
- }
- ///判断其是否含有正则验证
- var get_regdata = $(obj).attr("data-reg"); ///取得新加的判断正则验证的属性
- if (get_regdata != "" && get_regdata != null && get_regdata != undefined) {
- ///含有正则验证,则赋值选中
- $("#funbtnuseRegular").attr("checked", true).parent("label").addClass("chb-blue-checked");
- $("#regularSelectPart").show();
- $("#regularSelectPart select").val(get_regdata);
- } else {
- ////不含验证则取消选中
- $("#funbtnuseRegular").removeAttr("checked").parent("label").removeClass("chb-blue-checked");
- $("#regularSelectPart").hide();
- $("#regularSelectPart select").val("0");
- }
- ///获取其style中的补充样式 --数值
- $("#trea_setClassBuChong").val($(obj).attr("style")).attr("data-setid", $(obj).attr("id"));
- ////为删除按钮赋值点中的控件的id--20230114
- $("#btn_delControl").attr("data-setid", $(obj).attr("id"));
- };
- ////补充样式改完之后点击确定进行保存--20230110
- function btn_trea_setClassBuChong_submit() {
- $("#btn_trea_setClassBuChong_submit").on("click", function () {
- var get_set_control_id = $("#trea_setClassBuChong").attr("data-setid");
- var get_trea_setClassBuChong_val=$("#trea_setClassBuChong").val();
- if (sp.isval(get_set_control_id)) {
- ///有需要设置的控件id
- var iframeWindow = $('#formBuilderTextarea_ifr')[0].contentWindow;
- $(iframeWindow.document).find("#" + get_set_control_id).attr("style", get_trea_setClassBuChong_val);
- }
- });
- }
- btn_trea_setClassBuChong_submit();
- /////删除图标按钮--操作事件--20230110
- function btn_delControl() {
- $("#btn_delControl").on("click", function () {
- var get_set_control_id = $("#btn_delControl").attr("data-setid");
- if (sp.isval(get_set_control_id)) {
- ///有需要设置的控件id
- var iframeWindow = $('#formBuilderTextarea_ifr')[0].contentWindow;
-
- if ($(iframeWindow.document).find("#" + get_set_control_id).attr("data-showtype") == "popradiobox") {
- ///类型为单项选择器,就将下面的layer弹出层删除掉
- var get_showcode = $(iframeWindow.document).find("#" + get_set_control_id).attr("data-code");
- $(iframeWindow.document).find("#layer_popradiobox_" + get_showcode).remove();
- console.log("#layer_popradiobox_" + get_showcode);
- }
- $(iframeWindow.document).find("#" + get_set_control_id).remove();
- $("#btn_delControl").attr("data-setid","");
- } else {
- sp.dialog("未找到元素控件");
- }
- });
- };
- btn_delControl();
- ///表单主题色调2022-12-25
- function setRedTheme() {
- $("#chb_selectRedTheme").on("click", function () {
- var iframeWindow = $('#formBuilderTextarea_ifr')[0].contentWindow;
- if ($(iframeWindow.document).find(".sp-fb-grid").length < 1 && $(iframeWindow.document).find("p").length < 1 && $(iframeWindow.document).find("h1").length < 1 && $(iframeWindow.document).find("h2").length < 1 && $(iframeWindow.document).find("h3").length < 1) {
- sp.dialog("你好,未查询到表单, 无法设置表单主题色调");
- } else {
- if ($(this).hasClass("sp-checkbox-tabs-active")) {
- $(this).removeClass("sp-checkbox-tabs-active");
- $(iframeWindow.document).find(".sp-fb-grid").removeClass("sp-fb-grid-red");
- $(iframeWindow.document).find("p").removeClass("sp-fb-red");
- $(iframeWindow.document).find("h1").removeClass("sp-fb-red");
- $(iframeWindow.document).find("h2").removeClass("sp-fb-red");
- $(iframeWindow.document).find("h3").removeClass("sp-fb-red");
-
- } else {
- $(this).addClass("sp-checkbox-tabs-active");
- $(iframeWindow.document).find(".sp-fb-grid").removeClass("sp-fb-grid-red").addClass("sp-fb-grid-red");
- $(iframeWindow.document).find("p").removeClass("sp-fb-red").addClass("sp-fb-red");
- $(iframeWindow.document).find("h1").removeClass("sp-fb-red").addClass("sp-fb-red");
- $(iframeWindow.document).find("h2").removeClass("sp-fb-red").addClass("sp-fb-red");
- $(iframeWindow.document).find("h3").removeClass("sp-fb-red").addClass("sp-fb-red");
- }
- }
- });
- ///无外层边框
- $("#chb_selectRedTheme_noneOutLine").on("click", function () {
- var iframeWindow = $('#formBuilderTextarea_ifr')[0].contentWindow;
- if ($(iframeWindow.document).find(".sp-fb-grid").length < 1 ) {
- sp.dialog("你好,未查询到表单, 无法设置表单");
- } else {
- if ($(this).hasClass("sp-checkbox-tabs-active")) {
- $(this).removeClass("sp-checkbox-tabs-active");
- $(iframeWindow.document).find(".sp-fb-grid").removeClass("sp-fb-grid-noneOutLine");
- } else {
- $(this).addClass("sp-checkbox-tabs-active");
- $(iframeWindow.document).find(".sp-fb-grid").removeClass("sp-fb-grid-noneOutLine").addClass("sp-fb-grid-noneOutLine");
- }
- }
- });
- };
- setRedTheme();
- ////必填项设置---文本框、多选框的
- $("#fucbtnRequire").click(function () {
- var iframeWindow = $('#formBuilderTextarea_ifr')[0].contentWindow;
- if ($(this).parent("label").hasClass("chb-blue-checked")) {
- $(iframeWindow.document).find(".sp-grid-control-checked").removeClass("sp-required");
- } else {
- $(iframeWindow.document).find(".sp-grid-control-checked").addClass("sp-required");
- }
- });
- ////必填项设置---时间控件的
- $("#btnDateSetRequire").click(function () {
- var iframeWindow = $('#formBuilderTextarea_ifr')[0].contentWindow;
- if ($(this).parent("label").hasClass("chb-blue-checked")) {
- $(iframeWindow.document).find(".sp-grid-control-checked").removeClass("sp-required-date").addClass("laydate-logo");
- } else {
- $(iframeWindow.document).find(".sp-grid-control-checked").addClass("sp-required-date").removeClass("laydate-logo");
- }
- });
- ////使用正则校验按钮,然后展开下方的select区域
- $("#funbtnuseRegular").click(function () {
- if ($(this).parent("label").hasClass("chb-blue-checked")) {
- $("#regularSelectPart").hide();
- } else {
- $("#regularSelectPart").show();
- }
- });
- ////含有正则验证的select
- $("#regularSelectPart select").change(function () {
- var iframeWindow = $('#formBuilderTextarea_ifr')[0].contentWindow;
- if ($(this).parent("label").hasClass("chb-blue-checked")) {
- $(iframeWindow.document).find(".sp-grid-control-checked").removeClass("sp-required");
- } else {
- $(iframeWindow.document).find(".sp-grid-control-checked").addClass("sp-required");
- }
- var getval = $(this).val(); ///得到select中的value值
- var get_regdata = $(iframeWindow.document).find(".sp-grid-control-checked").attr("data-reg"); ///取得新加的判断正则验证的属性
- if (getval != 0) {
- if (get_regdata != "" && get_regdata != null && get_regdata != undefined) {
- $(iframeWindow.document).find(".sp-grid-control-checked").removeClass(get_regdata);
- $(iframeWindow.document).find(".sp-grid-control-checked").attr("data-reg", getval).addClass(getval);///加上新属性data-reg
- } else {
- $(iframeWindow.document).find(".sp-grid-control-checked").attr("data-reg", getval).addClass(getval);
- }
- } else {
- $(iframeWindow.document).find(".sp-grid-control-checked").removeClass(get_regdata).removeAttr("data-reg");
- }
- });
- ///单选风格select
- $(".fb-radio-part select").change(function () {
- var iframeWindow = $('#formBuilderTextarea_ifr')[0].contentWindow;
- var getval = $(this).val(); ///得到select中的value值
- var get_style = $(iframeWindow.document).find(".sp-grid-control-checked").attr("data-style"); ///取得风格类型
- if (get_style != "" && get_style != null && get_style != undefined) {
- $(iframeWindow.document).find(".sp-grid-control-checked").removeClass(get_style);
- $(iframeWindow.document).find(".sp-grid-control-checked").attr("data-style", getval).addClass(getval);///加上新属性data-style
- } else {
- $(iframeWindow.document).find(".sp-grid-control-checked").attr("data-style", getval).addClass(getval);
- }
- });
- $("#chb_selectRadioStyle").click(function () {
- if ($(this).parent("label").hasClass("chb-blue-checked")) {
- $("#selectRadioStylePart").hide();
- } else {
- $("#selectRadioStylePart").show();
- }
- });
- ////---end
- ///多选风格select---start
- $(".fb-checkbox-part select").change(function () {
- var iframeWindow = $('#formBuilderTextarea_ifr')[0].contentWindow;
- var getval = $(this).val(); ///得到select中的value值
- var get_style = $(iframeWindow.document).find(".sp-grid-control-checked").attr("data-style"); ///取得风格类型
- if (get_style != "" && get_style != null && get_style != undefined) {
- $(iframeWindow.document).find(".sp-grid-control-checked").removeClass(get_style);
- $(iframeWindow.document).find(".sp-grid-control-checked").attr("data-style", getval).addClass(getval);///加上新属性data-style
- } else {
- $(iframeWindow.document).find(".sp-grid-control-checked").attr("data-style", getval).addClass(getval);
- }
- });
- $("#chb_selectCheckboxStyle").click(function () {
- if ($(this).parent("label").hasClass("chb-blue-checked")) {
- $("#selectCheckboxStylePart").hide();
- } else {
- $("#selectCheckboxStylePart").show();
- }
- });
- ////---end
- ////start--时间日期格式化选中
- $("#fbdatesetspanpart .sp-checkbox-tabs").each(function () {
- $(this).click(function () {
- $(this).addClass("sp-checkbox-tabs-active").siblings().removeClass("sp-checkbox-tabs-active");
- var iframeWindow = $('#formBuilderTextarea_ifr')[0].contentWindow;
- var getval = $(this).attr("data-value");
- $(iframeWindow.document).find(".sp-grid-control-checked").attr("data-format", getval);
- });
- });
- ////end--时间日期格式化选中
- ///start--图片上传控件设置宽高
- $("#fbUploadImgWidth").change(function () {
- if ($(this).val() < 60) {
- sp.dialog("宽度最小为60");
- } else if ($(this).val() > 800) {
- sp.dialog("宽度最大为800");
- } else {
- var iframeWindow = $('#formBuilderTextarea_ifr')[0].contentWindow;
- $(iframeWindow.document).find(".sp-grid-control-checked").css({ width: $(this).val() });
- $(iframeWindow.document).find(".sp-grid-control-checked").next("input[type='file']").css({ width: $(this).val() });
- }
- });
- $("#fbUploadImgHeight").change(function () {
- if ($(this).val() < 60) {
- sp.dialog("高度最小为60");
- } else if ($(this).val() > 600) {
- sp.dialog("高度最大为600");
- } else {
- var iframeWindow = $('#formBuilderTextarea_ifr')[0].contentWindow;
- $(iframeWindow.document).find(".sp-grid-control-checked").css({ height: $(this).val() });
- }
- });
- ///end--图片上传控件设置宽高
|