1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216 |
- ///全称spbuilder
- var spbld = window.NameSpace || {};
- ////遍历日期控件data-type='date',根据其data-formate属性然后为其调用不同的laydate.js的方法
- ///样例:<input type="text" data-type="date" id="PrjTable_0_0_0_projectdate" class="laydate-logo" data-format="yyyy-MM-dd" placeholder="请选择时间">
- //根据元素 data-formate 属性然后为其调用不同的laydate.js的方法
- spbld.laydateRender = function (obj) {
- var getid = $(obj).attr("id");
- var getformat = $(obj).attr("data-format");
- if (getformat == "yyyy-MM-dd" || getformat == "MM-dd" || getformat == "dd") {
- laydate.render({ elem: '#' + getid + '', type: 'date', format: '' + getformat + '', theme: '#009f95' });
- } else if (getformat == "yyyy-MM") {
- laydate.render({ elem: '#' + getid + '', type: 'month', format: 'yyyy-MM', theme: '#009f95' });
- } else if (getformat == "yyyy-MM-dd HH:mm:ss" || getformat == "yyyy-MM-dd HH:mm") {
- laydate.render({ elem: '#' + getid + '', type: 'datetime', format: '' + getformat + '', theme: '#009f95' });
- } else if (getformat == "MM") {
- laydate.render({ elem: '#' + getid + '', type: 'month', format: 'MM', theme: '#009f95' });
- } else if (getformat == "yyyy") {
- laydate.render({ elem: '#' + getid + '', type: 'year', format: 'yyyy', theme: '#009f95' });
- } else if (getformat == "HH:mm:ss" || getformat == "HH:mm") {
- laydate.render({ elem: '#' + getid + '', type: 'time', format: '' + getformat + '', theme: '#009f95' });
- } else { return; }
- }
- spbld.laydate = function () {
- if ($("body").find("input[data-type='date']").length > 0) {
- $("body").find("input[data-type='date']").each(function () {
- spbld.laydateRender(this);
- });
- };
- };
- ////子表按钮操作
- spbld.subtable = function () {
- //初始化 禁用子表中所有表单
- var $subTable = $('.fb-subtable-control');
- if ($subTable.length > 0) {
- $subTable.find('input').attr('disabled', 'disabled');
- $subTable.find('select').attr('disabled', 'disabled');
- $subTable.find('textarea').attr('disabled', 'disabled');
- } else {
- return;
- }
- //添加按钮
- $('.fb-add-data').click(function (e) {
- // 点击一次添加后 隐藏 添加按钮
- $(this).attr('disabled', 'disabled');
- // 向上查找到当前点击的table
- var $currentTable = $(e.target).closest('table');
- // 当前表的最后一行
- var $currentTableLastTr = $currentTable.find('tr:last');
- if ($currentTableLastTr.find('td:first').attr('data-index') == '0') {
- //解除禁用
- $currentTableLastTr.find('input').removeAttr('disabled');
- $currentTableLastTr.find('select').removeAttr('disabled');
- $currentTableLastTr.find('textarea').removeAttr('disabled');
- $currentTableLastTr.find('.fb-edit-data').removeAttr('disabled');
- $currentTableLastTr.find('.fb-delete-data').removeAttr('disabled');
- $currentTableLastTr.find('.fb-submit-data').removeAttr('disabled');
- // 禁用其他行按钮
- $currentTableLastTr.siblings().find('.fb-submit-data').attr('disabled', 'disabled');
- $currentTableLastTr.siblings().find('.fb-delete-data').attr('disabled', 'disabled');
- $currentTableLastTr.siblings().find('.fb-edit-data').attr('disabled', 'disabled');
- $currentTableLastTr.find('.fb-edit-data').hide();
- $currentTableLastTr.find('.fb-submit-data').show();
- $currentTableLastTr.find('input[type=text]:eq(0)').focus();
- } else {
- // 克隆tbody中最后一行数据
- var cloneTr = $currentTable.find('tbody>tr:last').clone(true);
- // 获取第一个td中的数字并+1
- var index = +cloneTr.find('td:first').html() + 1;
- // 将新的序号填入克隆的当前行,新建所以其data-index均置为0
- cloneTr.find('td:first').attr('data-index', 0).html(index);
- // 清空内容
- cloneTr.find('input[type=text]').val('');
- cloneTr.find('input[type=number]').val('');
- cloneTr.find('select').val('');
- cloneTr.find('textarea').val('');
- if (cloneTr.find(".fb-checkboxpart").length>0) {
- ////多选框组件清空
- cloneTr.find(".fb-checkboxpart").find("input[type='checkbox']").removeAttr("checked");
- var get_style = cloneTr.find(".fb-checkboxpart").attr("data-style");
- if (get_style == "sp-checkbox-none") {
- cloneTr.find(".fb-checkboxpart").find("label").removeClass("chb-none-checked");
- } else if (get_style == "sp-checkbox-gray") {
- cloneTr.find(".fb-checkboxpart").find("label").removeClass("chb-gray-checked");
- } else if (get_style == "sp-checkbox-blue") {
- cloneTr.find(".fb-checkboxpart").find("label").removeClass("chb-blue-checked");
- } else if (get_style == "sp-checkbox-orange") {
- cloneTr.find(".fb-checkboxpart").find("label").removeClass("chb-orange-checked");
- } else { return;}
- }
- if (cloneTr.find(".sp-upload").length > 0) {
- ////上传组件清空
- cloneTr.find(".sp-upload").find(".sp-upload-img").attr("src", "");
- cloneTr.find(".sp-upload").find(".sp-upload-tip").hide();
- cloneTr.find(".sp-upload").find(".sp-upload-tip-lh").remove();
- }
- // 再执行laydareRender
- if (cloneTr.find('input[data-type=date]')) {
- var cloneLayDateInput = cloneTr.find('input[data-type=date]');
- cloneLayDateInput.each(function () {
- // 生产随机数 用于id
- var randNum = Math.floor(Math.random() * 90000) + 10000;
- $(this).attr('id', $(this).attr('id') + randNum).removeAttr('lay-key');
- })
- }
- //插入到dom中
- $currentTable.find('tbody').append(cloneTr);
- // 再执行laydareRender
- if (cloneTr.find('input[data-type=date]')) {
- var cloneLayDateInput = cloneTr.find('input[data-type=date]');
- cloneLayDateInput.each(function () {
- spbld.laydateRender(this);
- })
- }
- // 禁用其他行按钮
- cloneTr.siblings().find('.fb-edit-data').attr('disabled', 'disabled');
- cloneTr.siblings().find('.fb-submit-data').attr('disabled', 'disabled');
- cloneTr.siblings().find('.fb-delete-data').attr('disabled', 'disabled');
- cloneTr.find('input').removeAttr('disabled');
- cloneTr.find('select').removeAttr('disabled');
- cloneTr.find('textarea').removeAttr('disabled');
- cloneTr.find('.fb-edit-data').removeAttr('disabled');
- cloneTr.find('.fb-delete-data').removeAttr('disabled');
- cloneTr.find('.fb-submit-data').removeAttr('disabled');
- cloneTr.find('.fb-edit-data').hide();
- cloneTr.find('.fb-submit-data').show();
- cloneTr.find('input[type=text]:eq(0)').focus();
- }
- })
- //编辑按钮 解除表里表单的禁用
- $('.fb-edit-data').click(function (e) {
- //获取点击按钮的所在行
- var $currentTr = $(e.target).closest('tr');
- // 点击一次编辑后 隐藏 添加按钮
- $(e.target).closest('table').find('.fb-add-data').attr('disabled', 'disabled');
- //隐藏当前按钮
- $(this).hide();
- //显示提交( √ )按钮
- $currentTr.find('.fb-submit-data').show().removeAttr('disabled');
- //解除禁用
- $currentTr.find('input').removeAttr('disabled');
- $currentTr.find('select').removeAttr('disabled');
- $currentTr.find('textarea').removeAttr('disabled');
- $currentTr.find('input[type=text]:eq(0)').focus();
- // 禁用其他行按钮
- $currentTr.siblings().find('.fb-submit-data').attr('disabled', 'disabled');
- $currentTr.siblings().find('.fb-delete-data').attr('disabled', 'disabled');
- $currentTr.siblings().find('.fb-edit-data').attr('disabled', 'disabled');
- })
- };
- ///给自定义表单的table赋值,AssignValueToTable
- ///jsonStr字符串
- var spbld_userid = ""; var spbld_routeinfoid = ""; var spbld_routeid = ""; var spbld_postAccessToken = "";
- spbld.fbAssignValueToTable = function (jsonStr, userid, routeinfoid, routeid, postAccessToken) {
-
- spbld_userid = userid;
- spbld_routeinfoid = routeinfoid;
- spbld_routeid = routeid;
- spbld_postAccessToken = postAccessToken;
-
- var res = JSON.parse(jsonStr);
- //console.log(jsonStr);
- ///1.对主表的字段进行遍历
- var get_mainTableName = res.TableName;
- if (sp.isval(res.TableCols)) {
- $.each(res.TableCols, function (index, item) {
- var controlIndex = $("#" + get_mainTableName + "_0_0_0_" + item.CODE); ////控件id
- if (item.EKIND == "edit" || item.EKIND == "number" || item.EKIND == "decimal") {
- ///此时用的都是单行文本框
- if ($("body").find(controlIndex).length > 0) {
- controlIndex.val(item.VALUE);
- }
- } else if (item.EKIND == "datetime") {///日期格式时,需要先为其格式化
- if ($("body").find(controlIndex).length > 0) {
- var get_format = controlIndex.attr("data-format");
- var formateDate = sp.datefmt(get_format, item.VALUE);
- controlIndex.val(formateDate);
- }
- } else if (item.EKIND == "text") {///多行文本时
- if ($("body").find(controlIndex).length > 0) {
- controlIndex.val(item.VALUE);
- }
- } else if (item.EKIND == "select") {///下拉选择框
- if ($("body").find(controlIndex).length > 0) {
- //controlIndex.val(item.VALUE);
- if (sp.isval(item.TCHILD_DATA)) {
- controlIndex.html(""); ///清空里面组件,重新赋值
- var set_control = "";
- $.each(item.TCHILD_DATA, function (index2, item2) {
- if (item2.CODE == item.VALUE) {
- item2.CHECKED = true;
- set_control += "<option value='" + item2.CODE + "' selected = 'selected' >" + item2.CNAME + "</option>";
- } else {
- set_control += "<option value='" + item2.CODE + "'>" + item2.CNAME + "</option>";
- }
- });
- controlIndex.html(set_control);
- } else {
- ///不请空还是原来默认2项数据
- return;
- }
- }
- } else if (item.EKIND == "radiobox") {///单选按钮
- if ($("body").find(controlIndex).length > 0) {
- var get_radioStyle = controlIndex.attr("data-style");
- if (sp.isval(item.TCHILD_DATA)) {
- controlIndex.html(""); ///清空里面组件,重新赋值
- var set_control = "";
- $.each(item.TCHILD_DATA, function (index2, item2) {
- if (item2.checked) {
- var set_label_class = "";
- if (get_radioStyle == "sp-radio-default") {
- set_label_class = "rd-default-checked";
- } else if (get_radioStyle == "sp-radio-blue") {
- set_label_class = "rd-blue-checked";
- } else if (get_radioStyle == "sp-radio-orange") {
- set_label_class = "rd-orange-checked";
- } else if (get_radioStyle == "sp-radio-none") {
- set_label_class = "rd-none-checked";
- } else { return; }
- set_control += "<label class='" + set_label_class + "'><input type='radio' value='" + item2.ccode + "' checked='checked' />" + item2.cname + "</label>";
- } else {
- set_control += "<label><input type='radio' value='" + item2.ccode + "' />" + item2.cname + "</label>";
- }
- });
- controlIndex.html(set_control);
- } else {
- ///不请空还是原来默认2项数据
- return;
- }
- }
- } else if (item.EKIND == "popradiobox") {
- ///单向选择器
- if ($("body").find(controlIndex).length > 0) {
- if (sp.isval(item.TCHILD_DATA)) {
- controlIndex.val(""); ///控件清空val值
- controlIndex.attr("data-ccode", "");///控件清空ccode值
- var set_control = "", set_control_val = "", set_control_ccode = "";
- $.each(item.TCHILD_DATA, function (index2, item2) {
- if (item2.checked) {
- set_control += "<label class='rd-blue-checked'><input type='radio' value='" + item2.ccode + "' checked='checked' />" + item2.cname + "</label>";
- set_control_val += item2.cname + ",";
- set_control_ccode += item2.ccode + ",";
- } else {
- set_control += "<label><input type='radio' value='" + item2.ccode + "' />" + item2.cname + "</label>";
- }
- });
- if (sp.isval(set_control_val) && sp.isval(set_control_ccode)) {
- controlIndex.val(sp.cutlast(set_control_val));///控件显示val值
- controlIndex.attr("data-ccode", sp.cutlast(set_control_ccode));///控件赋值ccode值
- }
- $("#layer_popradiobox_" + item.CODE).find(".fb-radiopart").html(set_control);
- } else {
- ///不请空还是原来默认2项数据
- return;
- }
- }
- } else if (item.EKIND == "checkbox") {///多选按钮
- if ($("body").find(controlIndex).length > 0) {
- var get_checkboxStyle = controlIndex.attr("data-style");
- if (sp.isval(item.TCHILD_DATA)) {
- controlIndex.html(""); ///清空里面组件,重新赋值
- var set_control = "";
- $.each(item.TCHILD_DATA, function (index2, item2) {
- if (item2.checked) {
- var set_label_class = "";
- if (get_checkboxStyle == "sp-checkbox-gray") {
- set_label_class = "chb-gray-checked";
- } else if (get_checkboxStyle == "sp-checkbox-blue") {
- set_label_class = "chb-blue-checked";
- } else if (get_checkboxStyle == "sp-checkbox-orange") {
- set_label_class = "chb-orange-checked";
- } else if (get_checkboxStyle == "sp-checkbox-none") {
- set_label_class = "chb-none-checked";
- } else { return; }
- set_control += "<label class='" + set_label_class + "'><input type='checkbox' value='" + item2.ccode + "' checked='checked' />" + item2.cname + "</label>"
- } else {
- set_control += "<label><input type='checkbox' value='" + item2.ccode + "' />" + item2.cname + "</label>";
- }
- });
- controlIndex.html(set_control);
- } else {
- ///不请空还是原来默认2项数据
- return;
- }
- }
- } else if (item.EKIND == "popcheckbox") {
- ///多向选择器
- if ($("body").find(controlIndex).length > 0) {
- if (sp.isval(item.TCHILD_DATA)) {
- controlIndex.val(""); ///控件清空val值
- controlIndex.attr("data-ccode", "");///控件清空ccode值
- var set_control = "", set_control_val = "", set_control_ccode = "";
- $.each(item.TCHILD_DATA, function (index2, item2) {
- if (item2.checked) {
- set_control += "<label class='chb-blue-checked'><input type='checkbox' value='" + item2.ccode + "' checked='checked' />" + item2.cname + "</label>";
- set_control_val += item2.cname + ",";
- set_control_ccode += item2.ccode + ",";
- } else {
- set_control += "<label><input type='checkbox' value='" + item2.ccode + "' />" + item2.cname + "</label>";
- }
- });
- if (sp.isval(set_control_val) && sp.isval(set_control_ccode)) {
- controlIndex.val(sp.cutlast(set_control_val));///控件显示val值
- controlIndex.attr("data-ccode", sp.cutlast(set_control_ccode));///控件赋值ccode值
- }
- $("#layer_popcheckbox_" + item.CODE).find(".fb-checkboxpart").html(set_control);
- } else {
- ///不请空还是原来默认2项数据
- return;
- }
- }
- } else if (item.EKIND == "optionbox") {
-
- ////签写意见
- if ($("body").find(controlIndex).length > 0) {
- spbld.getOptionboxData(controlIndex, get_mainTableName, item.CODE, userid, routeinfoid, routeid, postAccessToken);
- }
- } else if (item.EKIND == "imgupload") {
- ///图片上传
- if ($("body").find(controlIndex).length > 0) {
- controlIndex.find(".sp-upload-img").attr("src", item.VALUE);
- }
- } else if (item.EKIND == "fileupload") {///附件上传
- if ($("body").find(controlIndex).length > 0) {
- $.each(item.VALUE, function (index2, item2) {
- var fileSize = 0;
- if (item2.size > 1024 * 1024) {
- fileSize = (Math.round(item2.size * 100 / (1024 * 1024)) / 100).toString() + 'MB';
- }
- else {
- fileSize = (Math.round(item2.size * 100 / 1024) / 100).toString() + 'KB';
- }
- var settiplh = "<div class='sp-upload-tip-lh' data-url='" + item2.url + "' data-name='" + item2.name + "' data-size='" + item2.size + "'><div class='sp-upload-tip-info' style='display:block'><a href='" + item2.url + "'>" + item2.name + "(" + fileSize + ")</a><i class='fa fa-close sp-upload-tip-close'> 删除</i></div></div>";
- controlIndex.find(".sp-upload-tip").show().append(settiplh);
- });
- }
- } else { return; }
- });
- }
-
- ////************************************************************************************************************
- ////2.对子表字段进行遍历subTable,会有多子表结构
- if (sp.isval(res.subTable)) {
- $.each(res.subTable, function (index, item) {
- if ($("body").find($("#subTable_0_0_0_" + item.subTableName)).length > 0) {
- var cloneTr = $("#subTable_0_0_0_" + item.subTableName + " tbody>tr:first").clone(true);
- for (var j = 1; j < item.subTableColumns.length; j++) {
- cloneTr.find('td:first').attr('data-index', j + 1).html(j + 1);
- if (cloneTr.find('input[data-type=date]')) {
- var cloneLayDateInput = cloneTr.find('input[data-type=date]');
- cloneLayDateInput.each(function () {
- var randNum = Math.floor(Math.random() * 90000) + 10000;
- $(this).attr('id', $(this).attr('id') + randNum);
- })
- }
- $("#subTable_0_0_0_" + item.subTableName + " tbody").append(cloneTr);
- }
- for (var i = 0; i < item.subTableColumns.length; i++) {
- $.each(item.subTableColumns[i], function (index2, item2) {
- var tbodyTRindex = $("#subTable_0_0_0_" + item.subTableName + " tbody tr:eq(" + i + ")"); ///第几行
- if (item2.showcode == "ID") {
- tbodyTRindex.find('td:first').attr("data-index", item2.showvalue);
- }
- if (item2.showtype == "edit" || item2.showtype == "number" || item2.showtype == "decimal") {
- //console.log($("#subTable_0_0_0_" + item.subTableName + " tbody tr:eq(" + i + ")").length);
- ///判断子表中,每行中是否存在与json字段对应的input,如果存在给其赋值
- if (tbodyTRindex.find("input[data-code='" + item2.showcode + "']").length > 0) {
- tbodyTRindex.find("input[data-code='" + item2.showcode + "']").val(item2.showvalue);
- };
- } else if (item2.showtype == "datetime") {///日期格式时,需要先为其格式化
- if (tbodyTRindex.find("input[data-code='" + item2.showcode + "']").length > 0) {
- var get_format = tbodyTRindex.find("input[data-code='" + item2.showcode + "']").attr("data-format");
- var formateDate = sp.datefmt(get_format, item2.showvalue);
- tbodyTRindex.find("input[data-code='" + item2.showcode + "']").val(formateDate);
- };
- } else if (item2.showtype == "text") {
- if (tbodyTRindex.find("textarea[data-code='" + item2.showcode + "']").length > 0) {
- tbodyTRindex.find("textarea[data-code='" + item2.showcode + "']").val(item2.showvalue);
- };
- } else if (item2.showtype == "select") {
- if (tbodyTRindex.find("select[data-code='" + item2.showcode + "']").length > 0) {
- tbodyTRindex.find("select[data-code='" + item2.showcode + "']").val(item2.showvalue);
- };
- } else if (item2.showtype == "radio") {
- //console.log($("div[data-code='sex']").length)
- if (tbodyTRindex.find("div[data-code='" + item2.showcode + "']").length > 0) {
- var get_radioStyle = tbodyTRindex.find("div[data-code='" + item2.showcode + "']").attr("data-style");
- tbodyTRindex.find("div[data-code='" + item2.showcode + "']").find("input[type='radio']").each(function () {
- if ($(this).val() == item2.showvalue) {
- ///此处radio选中,其他的radio去掉选中
- $(this).attr("checked", "checked");
- $(this).parent("label").siblings().children("input[type='radio']").removeAttr("checked");
- ///此处radio的label加上选中样式,其他的label去掉选中样式
- if (get_radioStyle == "sp-radio-default") {
- $(this).parent("label").addClass("rd-default-checked");
- $(this).parent("label").siblings().removeClass("rd-default-checked");
- } else if (get_radioStyle == "sp-radio-blue") {
- $(this).parent("label").addClass("rd-blue-checked");
- $(this).parent("label").siblings().removeClass("rd-blue-checked");
- } else if (get_radioStyle == "sp-radio-orange") {
- $(this).parent("label").addClass("rd-orange-checked");
- $(this).parent("label").siblings().removeClass("rd-orange-checked");
- } else if (get_radioStyle == "sp-radio-none") {
- $(this).parent("label").addClass("rd-none-checked");
- $(this).parent("label").siblings().removeClass("rd-none-checked");
- } else { return; }
- }
- });
- };
- } else if (item2.showtype == "checkbox") {
- if (tbodyTRindex.find("div[data-code='" + item2.showcode + "']").length > 0) {
- var get_checkboxStyle = tbodyTRindex.find("div[data-code='" + item2.showcode + "']").attr("data-style");
- var get_checkboxvalue = item2.showvalue.split(",");
- for (var kk = 0; kk < get_checkboxvalue.length; kk++) {
- tbodyTRindex.find("div[data-code='" + item2.showcode + "']").find("input[type='checkbox']").each(function () {
- if ($(this).val() == get_checkboxvalue[kk]) {
- ///此处checkbox选中
- $(this).attr("checked", "checked");
- ///此处checkbox的label加上选中样式
- if (get_checkboxStyle == "sp-checkbox-gray") {
- $(this).parent("label").addClass("chb-gray-checked");
- } else if (get_checkboxStyle == "sp-checkbox-blue") {
- $(this).parent("label").addClass("chb-blue-checked");
- } else if (get_checkboxStyle == "sp-checkbox-orange") {
- $(this).parent("label").addClass("chb-orange-checked");
- } else if (get_checkboxStyle == "sp-checkbox-none") {
- $(this).parent("label").addClass("chb-none-checked");
- } else { return; }
- }
- });
- };
- };
- } else if (item2.showtype == "img") {
- if (tbodyTRindex.find("div[data-code='" + item2.showcode + "']").length > 0) {
- tbodyTRindex.find("div[data-code='" + item2.showcode + "']").find(".sp-upload-img").attr("src", item2.showvalue);
- };
- } else if (item2.showtype == "file") {
- if (tbodyTRindex.find("div[data-code='" + item2.showcode + "']").length > 0) {
- $.each(item2.showvalue, function (index3, item3) {
- var fileSize = 0;
- if (item3.size > 1024 * 1024) {
- fileSize = (Math.round(item3.size * 100 / (1024 * 1024)) / 100).toString() + 'MB';
- }
- else {
- fileSize = (Math.round(item3.size * 100 / 1024) / 100).toString() + 'KB';
- }
- var settiplh = "<div class='sp-upload-tip-lh' data-url='" + item3.url + "' data-name='" + item3.name + "' data-size='" + item3.size + "'><div class='sp-upload-tip-info' style='display:block'><a href='" + item3.url + "'>" + item3.name + "(" + fileSize + ")</a><i class='fa fa-close sp-upload-tip-close'> 删除</i></div></div>";
- tbodyTRindex.find("div[data-code='" + item2.showcode + "']").find(".sp-upload-tip").show().append(settiplh);
- });
- };
- } else { return; }
- });
- };
- };
- });
- }
-
- };
- ///格式化自定义表单的table组成json字符串,
- ///partID是指定的表单table外层div的id
- spbld.fbFrtTableJson = function (partID, TableName) {
- var mainTableColumns = [];///声明主表列的数组
- var fb_json_str = "";
- ///遍历主表中的控件组成json
- if ($(partID).children(".sp-fb-grid").length > 0) {
- if ($(partID + " .sp-fb-grid>tbody>tr>td>input[type='text']").length > 0) {
- $(partID + " .sp-fb-grid>tbody>tr>td>input[type='text']").each(function () {
- //console.log($(this).attr("data-code"));
- if ($(this).attr("data-type") == "text") {
- var set_str = "\"" + $(this).attr("data-code") + "\":\"" + $(this).val() + "\"" + ",";
- fb_json_str += set_str;
- } else if ($(this).attr("data-type") == "date") {
- var set_str = "\"" + $(this).attr("data-code") + "\":\"" + $(this).val() + "\"" + ",";
- fb_json_str += set_str;
- } else { return; }
- });
- }
- if ($(partID + " .sp-fb-grid>tbody>tr>td>input[type='number']").length > 0) {
- $(partID + " .sp-fb-grid>tbody>tr>td>input[type='number']").each(function () {
- var set_str = "\"" + $(this).attr("data-code") + "\":\"" + $(this).val() + "\"" + ",";
- fb_json_str += set_str;
- });
- }
- if ($(partID + " .sp-fb-grid>tbody>tr>td>textarea").length > 0) {
- $(partID + " .sp-fb-grid>tbody>tr>td>textarea").each(function () {
- var set_str = "\"" + $(this).attr("data-code") + "\":\"" + $(this).val() + "\"" + ",";
- fb_json_str += set_str;
- });
- }
- if ($(partID + " .sp-fb-grid>tbody>tr>td>select").length > 0) {
- $(partID + " .sp-fb-grid>tbody>tr>td>select").each(function () {
- var set_str = "\"" + $(this).attr("data-code") + "\":\"" + $(this).val() + "\"" + ",";
- fb_json_str += set_str;
- });
- }
- if ($(partID + " .sp-fb-grid>tbody>tr>td>.fb-radiopart").length > 0) {
- $(partID + " .sp-fb-grid>tbody>tr>td>.fb-radiopart").each(function () {
- var getchecked = $(this).find("input[type='radio']:checked").val();
- var setjson = "{\"showcode\":\"" + $(this).attr("data-code") + "\", \"showtype\":\"radio\", \"showvalue\":\"" + getchecked + "\"}";
- mainTableColumns.push(JSON.parse(setjson));
- });
- }
- if ($(partID + " .sp-fb-grid>tbody>tr>td>.fb-checkboxpart").length > 0) {
- $(partID + " .sp-fb-grid>tbody>tr>td>.fb-checkboxpart").each(function () {
- var getchecked = "";
- $(this).find("input[type='checkbox']").each(function () {
- if ($(this).is(":checked")) {
- getchecked += $(this).val() + ",";
- }
- });
- var setjson = "{\"showcode\":\"" + $(this).attr("data-code") + "\", \"showtype\":\"checkbox\", \"showvalue\":\"" + sp.cutlast(getchecked) + "\"}";
- mainTableColumns.push(JSON.parse(setjson));
- });
- }
- if ($(partID + " .sp-fb-grid>tbody>tr>td>.sp-upload").length > 0) {
- $(partID + " .sp-fb-grid>tbody>tr>td>.sp-upload").each(function () {
- var get_showtype = "";
- var get_showvalue = "";
- if ($(this).children(".sp-upload-img").length > 0) {
- get_showtype = "img";
- get_showvalue = $(".sp-upload-img", this).attr("src");
- var setjson = "{\"showcode\":\"" + $(this).attr("data-code") + "\", \"showtype\":\"" + get_showtype + "\", \"showvalue\":\"" + get_showvalue + "\"}";
- mainTableColumns.push(JSON.parse(setjson));
- } else if ($(this).children(".sp-upload-file-single").length > 0) {
- get_showtype = "file";
- $(".sp-upload-tip-lh", this).each(function () {
- get_showvalue += "{\"name\":\"" + $(this).attr("data-name") + "\", \"url\":\"" + $(this).attr("data-url") + "\", \"size\":" + $(this).attr("data-size") + "},";
- });
- //console.log(sp.cutlast(get_showvalue));
- var loc = "[" + sp.cutlast(get_showvalue) + "]";
- var setjson = "{\"showcode\":\"" + $(this).attr("data-code") + "\", \"showtype\":\"" + get_showtype + "\", \"showvalue\":" + loc + "}";
- mainTableColumns.push(JSON.parse(setjson));
- }
- });
- }
- //console.log(JSON.stringify(mainTableColumns));
- };
- ////***********************************
- ///遍历子表
- var subTableAllArray = [];///声明子表数组集合变量
- if ($(partID).find(".sp-subgrid-job").length > 0) {
- $(partID + " .sp-subgrid-job").each(function (index, item) {
- var subTableColumnsArray = [];
- $("tbody tr", this).each(function (index2, item2) {
- ////加上判断该行是不是都为空
- var hasval = 0;///声明行中控件都为空的标志hasval =0
- if ($(this).find("input[type='text']").length > 0) {
- $(this).find("input[type='text']").each(function () {
- if ($(this).val() != "" && $(this).val() != null) {
- hasval = 1;
- }
- });
- }
- if ($(this).find("input[type='number']").length > 0) {
- $(this).find("input[type='number']").each(function () {
- if ($(this).val() != "" && $(this).val() != null) {
- hasval = 1;
- }
- });
- }
- if ($(this).find("textarea").length > 0) {
- $(this).find("textarea").each(function () {
- if ($(this).val() != "" && $(this).val() != null) {
- hasval = 1;
- }
- });
- }
- if ($(this).find(".fb-checkboxpart").length > 0) {
- $(this).find(".fb-checkboxpart").each(function () {
- $(this).find("input[type='checkbox']").each(function () {
- if ($(this).is(":checked")) {
- hasval = 1;
- }
- });
- });
- }
- if ($(this).find(".sp-upload").length > 0) {
- $(this).find(".sp-upload").each(function () {
- if ($(this).children(".sp-upload-img").length > 0) {
- var get_showvalue = $(".sp-upload-img", this).attr("src");
- if (get_showvalue != "" && get_showvalue != null) {
- hasval = 1;
- }
- } else if ($(this).children(".sp-upload-file-single").length > 0) {
- if ($(this).find(".sp-upload-tip-lh").length > 0) {
- hasval = 1;
- }
- }
- });
- }
- ///*************************************************************************************
- ///此处是得到该行控件不都为空,则将其遍历组成json
- if (hasval == 1) {
- var subTableColumnsSub = [];
- var getID = $(this).find('td:first').attr("data-index");
- var setjsonID = "{\"showcode\":\"ID\", \"showtype\":\"number\", \"showvalue\":\"" + getID + "\"}";
- subTableColumnsSub.push(JSON.parse(setjsonID));
- if ($(this).find("input[type='text']").length > 0) {
- $(this).find("input[type='text']").each(function () {
- if ($(this).attr("data-type") == "text") {
- var setjson = "{\"showcode\":\"" + $(this).attr("data-code") + "\", \"showtype\":\"edit\", \"showvalue\":\"" + $(this).val() + "\"}";
- subTableColumnsSub.push(JSON.parse(setjson));
- } else if ($(this).attr("data-type") == "date") {
- var setjson = "{\"showcode\":\"" + $(this).attr("data-code") + "\", \"showtype\":\"datetime\", \"showvalue\":\"" + $(this).val() + "\"}";
- subTableColumnsSub.push(JSON.parse(setjson));
- } else { return; }
- });
- }
- if ($(this).find("input[type='number']").length > 0) {
- $(this).find("input[type='number']").each(function () {
- var setjson = "{\"showcode\":\"" + $(this).attr("data-code") + "\", \"showtype\":\"number\", \"showvalue\":\"" + $(this).val() + "\"}";
- subTableColumnsSub.push(JSON.parse(setjson));
- });
- }
- if ($(this).find("textarea").length > 0) {
- $(this).find("textarea").each(function () {
- var setjson = "{\"showcode\":\"" + $(this).attr("data-code") + "\", \"showtype\":\"text\", \"showvalue\":\"" + $(this).val() + "\"}";
- subTableColumnsSub.push(JSON.parse(setjson));
- });
- }
- if ($(this).find("select").length > 0) {
- $(this).find("select").each(function () {
- var setjson = "{\"showcode\":\"" + $(this).attr("data-code") + "\", \"showtype\":\"select\", \"showvalue\":\"" + $(this).val() + "\"}";
- subTableColumnsSub.push(JSON.parse(setjson));
- });
- }
- if ($(this).find(".fb-radiopart").length > 0) {
- $(this).find(".fb-radiopart").each(function () {
- var getchecked = $(this).find("input[type='radio']:checked").val();
- var setjson = "{\"showcode\":\"" + $(this).attr("data-code") + "\", \"showtype\":\"radio\", \"showvalue\":\"" + getchecked + "\"}";
- subTableColumnsSub.push(JSON.parse(setjson));
- });
- }
- if ($(this).find(".fb-checkboxpart").length > 0) {
- $(this).find(".fb-checkboxpart").each(function () {
- var getchecked = "";
- $(this).find("input[type='checkbox']").each(function () {
- if ($(this).is(":checked")) {
- getchecked += $(this).val() + ",";
- }
- });
- var setjson = "{\"showcode\":\"" + $(this).attr("data-code") + "\", \"showtype\":\"checkbox\", \"showvalue\":\"" + sp.cutlast(getchecked) + "\"}";
- subTableColumnsSub.push(JSON.parse(setjson));
- });
- }
- if ($(this).find(".sp-upload").length > 0) {
- $(this).find(".sp-upload").each(function () {
- var get_showtype = "";
- var get_showvalue = "";
- if ($(this).children(".sp-upload-img").length > 0) {
- get_showtype = "img";
- get_showvalue = $(".sp-upload-img", this).attr("src");
- var setjson = "{\"showcode\":\"" + $(this).attr("data-code") + "\", \"showtype\":\"" + get_showtype + "\", \"showvalue\":\"" + get_showvalue + "\"}";
- subTableColumnsSub.push(JSON.parse(setjson));
- } else if ($(this).children(".sp-upload-file-single").length > 0) {
- get_showtype = "file";
- $(".sp-upload-tip-lh", this).each(function () {
- get_showvalue += "{\"name\":\"" + $(this).attr("data-name") + "\", \"url\":\"" + $(this).attr("data-url") + "\", \"size\":" + $(this).attr("data-size") + "},";
- });
- //console.log(sp.cutlast(get_showvalue));
- var loc = "[" + sp.cutlast(get_showvalue) + "]";
- var setjson = "{\"showcode\":\"" + $(this).attr("data-code") + "\", \"showtype\":\"" + get_showtype + "\", \"showvalue\":" + loc + "}";
- subTableColumnsSub.push(JSON.parse(setjson));
- }
- });
- }
- subTableColumnsArray.push(subTableColumnsSub);
- }
- });
- //console.log(JSON.stringify(subTableColumnsArray));
- var subTableArray = "{\"subTableName\":\"" + $(this).attr("data-subtablename") + "\", \"subTableColumns\":" + JSON.stringify(subTableColumnsArray) + "}";
- //console.log(subTableArray);
- subTableAllArray.push(JSON.parse(subTableArray));
- });
- };
- //console.log(JSON.stringify(subTableAllArray));
- //var frtJson = "";///整体json串
- //if ($(partID).children(".sp-fb-grid").length > 0 && $(partID).find(".sp-subgrid-job").length > 0) {
- // //主表和子表都有
- // frtJson = "{\"TableName\":\"" + TableName + "\", \"mainTableColumns\":" + JSON.stringify(mainTableColumns) + ", \"subTable\":" + JSON.stringify(subTableAllArray) + "}";
- //} else if ($(partID).children(".sp-fb-grid").length > 0 && $(partID).find(".sp-subgrid-job").length == 0) {
- // //只有主表没有子表
- // frtJson = "{\"TableName\":\"" + TableName + "\", \"mainTableColumns\":" + JSON.stringify(mainTableColumns) + "}";
- //} else { return; }
- ////console.log(frtJson);
- //return frtJson;
- if (sp.isval(fb_json_str)) {
- var set_json = "{" + sp.cutlast(fb_json_str) + "}";
- //console.log(set_json);
- return set_json;
- } else {
- return fb_json_str;
- }
-
- };
- ////单选选择器--打开事件
- spbld.layer_popradiobox_open = function (layerid) {
- sp.layer("#" + layerid);
- }
- ////单选选择器---确定事件
- spbld.layer_popradiobox_true = function (layerid,controlid,showcode) {
- var get_inputRadioChecked=$("#" + layerid).find(".fb-radiopart").find("input[type='radio']:checked");
- $("#" + controlid).val(get_inputRadioChecked.parent().text());
- $("#" + controlid).attr("data-ccode", get_inputRadioChecked.val());
- sp.layerhide();
- }
- ///多项选择器
- spbld.layer_popcheckbox_open = function (layerid) {
- sp.layer("#" + layerid);
- }
- ////多项选择器---确定事件
- spbld.layer_popcheckbox_true = function (layerid, controlid, showcode) {
- var get_inputChecboxChecked = $("#" + layerid).find(".fb-checkboxpart").find("input[type='checkbox']:checked");
- var set_control_val = "", set_control_ccode = "";
- get_inputChecboxChecked.each(function (item2,index2) {
- set_control_val += $(this).parent().text()+ ",";
- set_control_ccode += $(this).val() + ",";
- })
- $("#" + controlid).val(sp.cutlast(set_control_val));
- $("#" + controlid).attr("data-ccode", sp.cutlast(set_control_ccode));
- sp.layerhide();
- }
- ////**签写意见业务操作--start********************************************************************************
- spbld.getOptionboxData = function (controlIndex, get_mainTableName, colname, userid, routeinfoid, routeid, postAccessToken) {
-
- ////加载数据
- var postData = {
- "cmanid": userid,///签字人ID
- "routeinfoid": routeinfoid,///流程实例ID
- "routeid": routeid,//流程流转ID
- "tableid": get_mainTableName,//表单名称
- "colid": colname//列名称
- }
- var postData_2 = {
- data: s4.encryptData_CBC(JSON.stringify(postData))
- }
- //var yijianJson = "";
- //if (colname == "yijiancontrol") {
- // yijianJson = 'json.page/optionbox/optionbox_1.txt?v=' + new Date();
- //} else {
- // yijianJson = 'json.page/optionbox/optionbox_2.txt?v=' + new Date();
- //}
- $.ajax({
- //////g2app/abase/queryDataOpinion
- //url: yijianJson,
- //type:'get',
- url: apiurljs.login + "g2app/abase/queryDataOpinion",
- type: 'post',
- data: JSON.stringify(postData_2),
- dataType: "json",
- contentType: "application/json",
- headers: { Authorization: "Bearer " + postAccessToken }, ////请求头headers
- success: function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- //console.log(JSON.stringify(res));
- controlIndex.html("");
- if (sp.isval(res.data)) {
- $.each(res.data, function (index2, item2) {
- var set_text_or_img = "";
- if (sp.isval(item2.OPINION)) {
- set_text_or_img = "<div class='sp-lh-20'>" + item2.OPINION + "</div>";
- } else if (sp.isval(item2.OPINIONIMAGE)) {
- set_text_or_img = "<img class='sp-pull-left' src='" + item2.OPINIONIMAGE + "' style='max-width: 50%;max-height: 85px;' />"
- } else { set_text_or_img = ""; }
- var set_btn_html = "";
- if (routeid == item2.ROUTEID) {
- set_btn_html = "<div class='sp-page sp-mt-5'><span class='sp-btn-red-outline sp-btn-radius' onclick=\"spbld.layer_optionbox_delete(this,'" + get_mainTableName + "_0_0_0_" + colname + "','" + get_mainTableName + "','" + colname + "','" + item2.USERID + "','" + item2.ROUTEINFOID + "','" + item2.ROUTEID + "')\">删除</span></div>" +
- "<div class='sp-page sp-mt-10'><span class='sp-btn-blue-outline sp-btn-radius' onclick=\"spbld.layer_optionbox_edit('" + get_mainTableName + "_0_0_0_" + colname + "','" + get_mainTableName + "','" + colname + "','" + item2.OPINION + "','" + item2.OPINIONIMAGE + "','" + item2.USERID + "','" + item2.ROUTEINFOID + "','" + item2.ROUTEID + "')\">修改</span></div>"
- }
- var setHtml = "<div class='sp-page-mgn sp-border-bottom sp-pb-20 sp-color-black'>" +
- "<div class='sp-page-col' style='width: calc(100% - 220px);'>" +
- set_text_or_img +
- "</div>" +
- "<div class='sp-page-col sp-text-right' style='width:120px;'>" +
- "<div class='sp-page sp-mt-20'>" + item2.CMANNAME + "</div>" +
- "<div class='sp-page'>" + sp.format(item2.CDATE) + "</div>" +
- "</div>" +
- "<div class='sp-page-col sp-text-center' style='width:100px;'>"
- + set_btn_html +
- "</div>" +
- "</div>";
- controlIndex.append(setHtml);
- //console.log(controlIndex.next());
- //console.log(routeid + "、" + item2.ROUTEID);
- if (routeid == item2.ROUTEID) {
- ///已有数据且流程流转ID相同时,签写意见按钮隐藏;
- controlIndex.next().hide();
- } else {
- controlIndex.next().show();
- }
- });
- controlIndex.children(".sp-page-mgn:last-child").removeClass("sp-border-bottom").removeClass("sp-pb-20");
- } else {
- controlIndex.next().show();
- }
- },
- error: function (returndata) {
- console.log(JSON.stringify(returndata));
- }
- });
- }
- ///打开签写意见弹出层
- spbld.layer_optionbox_open = function (idstr, mainTableName, showcode) {
- ////为tabs选项框赋值点击切换事件
- sp.layer("#layer_optionbox");
- $("#layer_optionbox_textarea").val("");
- $("#layer_optionbox_true_btn").attr("data-mainTableName", mainTableName).attr("data-colname", showcode).attr("data-userid", spbld_userid).attr("data-routeinfoid", spbld_routeinfoid).attr("data-routeid", spbld_routeid);///往确定按钮中赋值属性
- spbld.layer_optionbox_tabs(0);///传0默认打开第一层
- ///常用语检索数据--2023-zyg
- spbld.layer_optionbox_queryDataPatterns(mainTableName, showcode, spbld_userid);
- }
- ///签写意见--tabs切换
- spbld.layer_optionbox_tabs = function (indexSet) {
-
- indexSet = indexSet || 0;
- ///初始设置
- $("#layer_optionbox_tabs .sp-tab-menu li").removeClass("sp-tab-current");
- $("#layer_optionbox_tabs .sp-tab-menu li:eq(" + indexSet + ")").addClass("sp-tab-current");
- $("#layer_optionbox_tabs .sp-tab-box").children('div').addClass("sp-tab-hide");
- $("#layer_optionbox_tabs .sp-tab-box").children('div:eq(' + indexSet + ')').removeClass("sp-tab-hide");
- if (indexSet == 1) {
- setTimeout(function () {
- ///延时1秒加载canvas划线,js否则得不到canvas外层的宽度高度
- spbld.lineCanvas();
- }, 10)
- }
- ////点击事件设置
- $("#layer_optionbox_tabs .sp-tab-menu li").click(function () {
- $(this).addClass("sp-tab-current").siblings().removeClass("sp-tab-current");
- var get_index = $(this).attr("data-index");
-
- $("#layer_optionbox_tabs .sp-tab-box").children('div').addClass("sp-tab-hide");
- $("#layer_optionbox_tabs .sp-tab-box").children('div:eq(' + get_index + ')').removeClass("sp-tab-hide");
- if (get_index == 1) {
- setTimeout(function () {
- ///延时1秒加载canvas划线,js否则得不到canvas外层的宽度高度
- spbld.lineCanvas();
- }, 10)
- }
- })
- };
- ///清空canvas
- spbld.layer_optionbox_cnavas_clear = function () {
- let canvas = document.getElementById('layer_optionbox_canvas');///canvas签字区域
- var cxt = canvas.getContext("2d");
- cxt.clearRect(0, 0, canvas.width, canvas.height);
- };
- //canvas画布签字
- spbld.lineCanvas = function () {
- let canvasBody = document.getElementById('layer_optionbox_canvas_outpart');///canvas的外层区域
- //console.log(canvasBody);
- //console.log("clientWidth:"+canvasBody.clientWidth);
- //console.log("clientHeight:" + canvasBody.clientHeight);
- let canvas = document.getElementById('layer_optionbox_canvas');///canvas签字区域
-
- canvas.width = canvasBody.clientWidth;
- canvas.height = canvasBody.clientHeight;
-
- let ctx = canvas.getContext('2d');
- ctx.lineWidth = 4;
- ctx.strokeStyle = '#333';
- ctx.lineCap = 'round';
- ctx.lineJoin = 'round';
- let isDrawing = false;
- let dataURL = '';
- let initX;
- let initY;
- // 事件监听--开始绘制
-
- canvas.addEventListener("mousedown", function (e) {
- isDrawing = true;
- initX = e.offsetX;
- initY = e.offsetY
- });
- canvas.addEventListener('mousemove', draw);
- canvas.addEventListener("mouseup", function () {
- isDrawing = false
- });
- canvas.addEventListener("mouseout", function () {
- isDrawing = false
- });
- // 绘制中...
- function draw(e) {
-
- if (!isDrawing) return
- ctx.beginPath();
- // 起点
- ctx.moveTo(initX, initY);
- // 终点
- ctx.lineTo(e.offsetX, e.offsetY);
- ctx.stroke();
- initX = e.offsetX;
- initY = e.offsetY;
- }
- };
- ///删除意见
- spbld.layer_optionbox_delete = function (obj, controlIndex, maintable, colname, userid, routeinfoid, routeid) {
- if (confirm("您确定要删除吗?")) {
- var postData = {
- cmanid: userid,
- routeid: routeid,
- tableid: maintable,
- colid: colname
- }
- var postData_2 = {
- data: s4.encryptData_CBC(JSON.stringify(postData))
- }
- /////g2app/abase/deleteDataOpinion
- $.ajax({
- //url: 'json.page/optionbox/optionbox_delete.txt?v='+ new Date(),
- //type: 'get',
- url: apiurljs.login + "g2app/abase/deleteDataOpinion",
- type: 'post',
- data: JSON.stringify(postData_2),
- dataType: "json",
- contentType: "application/json",
- headers: { Authorization: "Bearer " + spbld_postAccessToken }, ////请求头headers
- success: function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.success) {
- //alert(obj);
- spbld.getOptionboxData($("#" + controlIndex), maintable, colname, userid, routeinfoid, routeid, spbld_postAccessToken);
- }
- },
- error: function (returndata) {
- sp.dialog("意见删除失败!")
- }
- });
- }
- }
- ////修改意见
- spbld.layer_optionbox_edit = function (idstr, maintable, colname, OPINION, OPINIONIMAGE, userid, routeinfoid, routeid) {
- $("#layer_optionbox_true_btn").attr("data-mainTableName", maintable).attr("data-colname", colname).attr("data-userid", userid).attr("data-routeinfoid", routeinfoid).attr("data-routeid", routeid);///往确定按钮中赋值属性
- if (sp.isval(OPINION)) {
- sp.layer("#layer_optionbox");
- spbld.layer_optionbox_tabs(0);
- ///常用语检索数据--2023-zyg
- spbld.layer_optionbox_queryDataPatterns(maintable, colname, userid);
- setTimeout(function () {
- $("#layer_optionbox_textarea").val(OPINION);
- }, 10);
- } else {
- sp.layer("#layer_optionbox");
- spbld.layer_optionbox_tabs(1);
- setTimeout(function () {
- ///把base64格式图片画到canvas画布上
- let canvas = document.getElementById('layer_optionbox_canvas');///canvas签字区域
- var cxt = canvas.getContext("2d");
- let img = new Image();
- img.src = OPINIONIMAGE;
- img.onload = function () {
- cxt.drawImage(this, 0, 0, canvas.width, canvas.height);
- }
- }, 20);
- }
- }
- ///签写意见------确认按钮保存事件
- spbld.layer_optionbox_true = function () {
- var get_tabsIndex = $("#layer_optionbox_tabs").find(".sp-tab-current").attr("data-index");
- if (get_tabsIndex == 0) {
- ///为文字
- var get_txtval = $("#layer_optionbox_textarea").val();
- if (sp.isval(get_txtval)) {
- spbld.layer_optionbox_true_submitData(get_tabsIndex, get_txtval);
- } else {
- alert("文字内容不能为空");
- }
- } else {
- ///1时为手签
- //PNG 算法,判断canvas内容是否为空
- let canvas = document.getElementById('layer_optionbox_canvas');///canvas签字区域
- var blank = document.createElement('canvas');
- blank.width = canvas.width;
- blank.height = canvas.height;
- if (canvas.toDataURL() == blank.toDataURL()) {
- alert("手签内容不能为空");
- } else {
- //console.log(canvas.toDataURL());
- spbld.layer_optionbox_true_submitData(get_tabsIndex, canvas.toDataURL());
- }
- }
- };
- spbld.layer_optionbox_true_submitData = function (get_tabsIndex,cval) {
- var get_mainTabmeName = $("#layer_optionbox_true_btn").attr("data-maintablename");
- var get_colName = $("#layer_optionbox_true_btn").attr("data-colname");
- var get_userid = $("#layer_optionbox_true_btn").attr("data-userid");
- var get_routeinfoid = $("#layer_optionbox_true_btn").attr("data-routeinfoid");
- var get_routeid = $("#layer_optionbox_true_btn").attr("data-routeid");
- var set_opinion = "";
- var set_opinionimage = "";
- if (get_tabsIndex == 0) {
- set_opinion = cval;
- set_opinionimage = "";
- } else {
- set_opinion = "";
- set_opinionimage = cval;
- }
- var postData = {
- "cmanid": get_userid,//签字人ID
- "routeinfoid": get_routeinfoid,//流程实例ID
- "routeid": get_routeid,//流程流转ID
- "tableid": get_mainTabmeName,//表单名称
- "colid": get_colName,//列名称
- "opiniontype": get_tabsIndex,//签字类别 0-正常文字 1-语音转文字(配话筒) 2-手写签字(配手写板)
- "cresult": "",//意见判定 可以为空,也可以设为同意、不同意、通过、不通过等
- "opinion": set_opinion,//签字意见
- "opinionimage": set_opinionimage//签字图片 存图片的BASE64字符串
- }
- //console.log(postData);
- var postData_2 = {
- data: s4.encryptData_CBC(JSON.stringify(postData))
- }
- /////g2app/abase/saveDataOpinion
- $.ajax({
- //url: 'json.page/optionbox/optionbox_save.txt?v=' + new Date(),
- //type: 'get',
- url: apiurljs.login + "g2app/abase/saveDataOpinion",
- type: 'post',
- data: JSON.stringify(postData_2),
- dataType: "json",
- contentType: "application/json",
- headers: { Authorization: "Bearer " + spbld_postAccessToken }, ////请求头headers
- success: function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.success) {
- sp.layerhide();
- setTimeout(function () {
- spbld.getOptionboxData($("#" + get_mainTabmeName + "_0_0_0_" + get_colName), get_mainTabmeName, get_colName, get_userid, get_routeinfoid, get_routeid, spbld_postAccessToken);
- }, 200);
- }
- },
- error: function (returndata) {
- }
- });
- };
- ///常用语操作---检索数据--2023-zyg
- spbld.layer_optionbox_queryDataPatterns = function (get_mainTabmeName, get_colName, userid) {
- var postData = {
- "cmanid": userid,//签字人ID
- "tableid": get_mainTabmeName,//表单名称
- "colid": get_colName//列名称
- }
- var postData_2 = {
- data: s4.encryptData_CBC(JSON.stringify(postData))
- }
- //////g2app/abase/queryDataPatterns 检索指定列的意见列表
- $.ajax({
- //url: 'json.page/optionbox/queryDataPatterns.txt?v=' + new Date(),
- //type: 'get',
- url: apiurljs.login + "g2app/abase/queryDataPatterns",
- type: 'post',
- data: JSON.stringify(postData_2),
- dataType: "json",
- contentType: "application/json",
- headers: { Authorization: "Bearer " + spbld_postAccessToken }, ////请求头headers
- success: function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- console.log(JSON.stringify(res));
- ////{"code":0,"data":[{"TABLEID":"FW_ZSWPXXW","ID":"1110264415638523904","COLID":"WLDQFL","CONTENTS":"办理"},{"TABLEID":"FW_ZBWWHQ","ID":"1090645648408920065","COLID":"GPJZSC","CONTENTS":"可以"},{"TABLEID":"FW_DJGZDT","ID":"1090236997412823040","COLID":"HQBMFZRSH","CONTENTS":"同意"}],"message":"数据检索成功。","success":true}
- if (sp.isval(res.data)) {
- $("#layer_optionbox_patterns").html("");
- $.each(res.data, function (index2, item2) {
- var setHtml = "<span class='sp-lh-20'><span class='sp-page-col' style='width: calc(100% - 60px);'>" + item2.CONTENTS + "</span><span class='sp-page-col sp-text-center' style='width:60px;'><span onclick=\"spbld.layer_optionbox_queryDataPatterns_add('" + item2.CONTENTS + "')\" class='sp-logo-add' title='选中'></span><span class='sp-logo-delete' title='删除' onclick=\"spbld.layer_optionbox_queryDataPatterns_delete('" + get_mainTabmeName + "','" + get_colName + "','" + item2.ID + "')\" style='margin-left:10px;'></span></span></span>";
- $("#layer_optionbox_patterns").append(setHtml);
- });
- }
- },
- error: function (returndata) {
- }
- });
- };
- spbld.layer_optionbox_queryDataPatterns_add = function (cval) {
- //常用语操作---添加到左侧意见textarea中
- $("#layer_optionbox_textarea").val(cval);
- };
- spbld.layer_optionbox_queryDataPatterns_delete = function (get_mainTabmeName, get_colName, idnum) {
- if (confirm("您确定要删除吗?")) {
- //常用语操作---删除
- var postData = {
- "id": idnum//常用语id
- }
- var postData_2 = {
- data: s4.encryptData_CBC(JSON.stringify(postData))
- }
- //////g2app/abase/deleteDataOpinion 删除指定列的意见
- $.ajax({
- //url: 'json.page/optionbox/deleteDataOpinion.txt?v=' + new Date(),
- //type: 'get',
- url: apiurljs.login + "g2app/abase/deleteDataPatterns",
- type: 'post',
- data: JSON.stringify(postData_2),
- dataType: "json",
- contentType: "application/json",
- headers: { Authorization: "Bearer " + spbld_postAccessToken }, ////请求头headers
- success: function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- //console.log(JSON.stringify(res));
- if (res.success) {
- //console.log(spbld_userid)
- spbld.layer_optionbox_queryDataPatterns(get_mainTabmeName, get_colName, spbld_userid);///重新检索常用语
- }
- },
- error: function (returndata) {
- }
- });
- }
- };
- spbld.layer_optionbox_patterns_add = function () {
- /////常用语操作---新增
- var get_phraseText = $("#layer_optionbox_patterns_input").val();
- if (sp.isval(get_phraseText)) {
- var get_mainTabmeName = $("#layer_optionbox_true_btn").attr("data-maintablename");
- var get_colName = $("#layer_optionbox_true_btn").attr("data-colname");
- var postData = {
- cmanid: spbld_userid,
- tableid: get_mainTabmeName,
- colid: get_colName,
- contents: get_phraseText
- }
- //console.log(postData);
- var postData_2 = {
- data: s4.encryptData_CBC(JSON.stringify(postData))
- }
- //////g2app/abase/insertDataPatterns 添加常用语到常用语库
- $.ajax({
- url: apiurljs.login + "g2app/abase/insertDataPatterns",
- type: 'post',
- data: JSON.stringify(postData_2),
- dataType: "json",
- contentType: "application/json",
- headers: { Authorization: "Bearer " + spbld_postAccessToken }, ////请求头headers
- success: function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- //console.log(JSON.stringify(res));
- if (res.success) {
- //console.log(spbld_userid)
- spbld.layer_optionbox_queryDataPatterns(get_mainTabmeName, get_colName, spbld_userid);///重新检索常用语
- }
- },
- error: function (returndata) {
- }
- });
- } else {
- alert("常用语不能为空!");
- }
- };
- ////**签写意见业务操作--end********************************************************************************
|