123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- var get_userid = "7ac641ab-8940-4a50-8a0e-afe1b6d1cda1";
- var get_mainTableName = sp.getUrlName("mainTableName");
- var get_routeid = sp.getUrlName("routeid");
- var get_routeinfoid = sp.getUrlName("routeinfoid");
- var get_role = sp.getUrlName("role");
- var get_AccessToken = "";
- function gethtmldata() {
- $.ajax({
- url: "json/fileurl.txt", //这里是静态页的地址
- type: "get", //静态页用get方法,否则服务器会抛出405错误
- data: { mainTableName: get_mainTableName, routeid: get_routeid },
- dataType: "json",
- success: function (res) {
- var get_fileurl = "";
- if (get_routeid == "31378") {
- get_fileurl = res.Item.htmlurl;
- } else if (get_routeid == "30574") {
- get_fileurl = "HTML/2018/201810/20181022174234084500002.html";
- } else if (get_routeid == "29468") {
- get_fileurl = "HTML/2018/201810/20181022174717032900081.html";
- } else if (get_routeid == "23991") {
- ///下拉、单选、多选-修改--测试01
- get_fileurl = "HTML/2023/202302/20230207112103084800086.html";
- } else if (get_routeid == "23992") {
- ///带有意见控件--测试01
- //get_fileurl = "HTML/2023/202302/20230212084437007400051.html";
- get_fileurl = "HTML/2023/202303/20230304221322009700038.html";
- } else {
- get_fileurl = "";
- }
- /////加载html
- if (get_fileurl != "" && get_fileurl != null && get_fileurl != undefined) {
- $.ajax({
- url: get_fileurl, //这里是静态页的地址
- type: "get", //静态页用get方法,否则服务器会抛出405错误
- cache: false,
- async: false,
- success: function (result) {
- /////console.log(result);
- /////含有body标签,得到里面的内容
- if (result.indexOf("body") != -1) {
- var bodyDataCode = result.substring(result.indexOf("<body>") + 6, result.indexOf("</body>"));//截取body中内容
- //console.log(bodyDataCode);
- $("#viewPart").html(bodyDataCode);
-
-
- if (get_routeid == "0") {
- /////此时是新建
- sp.radio();///单选
- sp.checkbox();///多选
- spvld.getValidate();///开始正则校验组件
- spbld.laydate();////操作日期控件组件
- spbld.subtable();///操作子表按钮组件
- sp.uploadimg("http://103.233.7.57:8080/GoldFile/image/upload");////图片上传组件
- sp.uploadfile("http://103.233.7.57:8080/GoldFile/stream/upload");///附件上传组件,
- } else {
- ////此时是编辑
- var get_viewData_json = "";
- if (get_routeid == "23991" || get_routeid == "23992") {
- ///下拉、单选、多选-修改--测试01
- get_viewData_json = "json.page/detail/spandown_test_1.txt?ctime="+new Date();
-
- } else {
- get_viewData_json = "json/viewData.txt?ctime=" + new Date();
- }
- $.ajax({
- url: get_viewData_json, //这里是静态页的地址
- type: "get", //静态页用get方法,否则服务器会抛出405错误
- data: { userid:get_userid, mainTableName: get_mainTableName, routeid: get_routeid },
- dataType: "json",
- success: function (res) {
- //console.log(res);
- ////调用给表单赋值组件
- spbld.fbAssignValueToTable(JSON.stringify(res), get_userid, get_routeinfoid, get_AccessToken);
- if (get_role == "read") {
- ///只读状态将表单中全部设置为只读状态,不可录入编辑删除
- $("body").find("button").attr("disabled", "disabled");
- $("body").find("input").attr("disabled", "disabled");
- $("body").find("select").attr("disabled", "disabled");
- $("body").find("textarea").attr("disabled", "disabled");
- $("body").find(".sp-upload-tip-close").hide(); ////附件列表的删除按钮去掉
- }
- sp.radio();///单选
- sp.checkbox();///多选
- spvld.getValidate();///开始正则校验组件
- spbld.laydate();////操作日期控件组件
- spbld.subtable();///操作子表按钮组件
- sp.uploadimg("http://103.233.7.57:8080/GoldFile/image/upload");////图片上传组件
- sp.uploadfile("http://103.233.7.57:8080/GoldFile/stream/upload");///附件上传组件,
- ///////测试端口,正式端口http://103.233.7.38:8080/GoldFile/stream/upload
-
- },
- //请求执行异常执行的方法
- error: function (XMLHttpRequest, textStatus, errorThrown) {
- console.log("您好,文件数据加载失败");
- }
- });
- }
-
- }
- },
- //请求执行异常执行的方法
- error: function (XMLHttpRequest, textStatus, errorThrown) {
- console.log("您好,文件数据加载失败");
- }
- });
- } else {
- console.log("您好,未找到表单文件的路径");
- }
- },
- //请求执行异常执行的方法
- error: function (XMLHttpRequest, textStatus, errorThrown) {
- console.log("您好,文件数据加载失败");
- }
- });
- };
- if (get_mainTableName == undefined || get_mainTableName == null) {
- sp.dialog("您好,未找到主表名,请确保参数正确");
- } else {
- gethtmldata();
- };
- ////上部提交按钮
- function btnSubmitData() {
- if (spvld.submit("#viewPart")) {
- var getTableJsonStr = spbld.fbFrtTableJson("#viewPart", "mainTableName", "mainTableColumnsID");
- console.log(getTableJsonStr);
- ////ajax传给后端
- $.ajax({
- type: "get",
- url: "json/message.txt",
- data: { userid: get_userid, routeid: get_routeid, mainTableName: get_mainTableName, frtJson: getTableJsonStr },
- //data: { "allJson": getTableJsonStr },
- dataType: "json",
- success: function (res) {
- if (res.success) {
- ///成功后,重新调用赋值方法,
- gethtmldata();
- }
- },
- error: function (XMLHttpRequest, textStatus, errorThrown) {
- console.log(errorThrown);
- }
- });
- };
- };
- //子表提交按钮事件
- function fbSubTableSubmitData(obj) {
- //var $currentTr = $(obj).closest("tr");
- //提交数据
- /*ajax*/
- setTimeout(function () {
- //$(obj).hide();
- //$currentTr.find('.fb-edit-data').css('display', 'inline-block');
- //$currentTr.find('input').attr('disabled', 'disabled');
- //$currentTr.find('select').attr('disabled', 'disabled');
- //$currentTr.find('textarea').attr('disabled', 'disabled');
- ///子表每次都提交整体数据,原因是为了保持更改数据的实时性,有时会出现,子表数据求合计的情况
- btnSubmitData(); ///子表的提交再次调用提交事件,
- }, 100);
- }
- //子表删除按钮
- function fbSubTableDelData(obj) {
- ////子表删除功能需要
- if (confirm("您好,删除后不可恢复,您确认要删除吗")) {// 先查找并隐藏当前点击行
- //$(obj).closest('tr').hide();
- var get_subTableName = $(obj).parents(".sp-subgrid-job").attr("data-subtablename");
- var get_subTableColumnsID = $(obj).closest("tr").find("td:first").attr("data-index");
- if (get_subTableColumnsID==0) {
- alert("您好,为了保证预览效果,第一行禁止删除");
- }else{
- $.ajax({
- type: "get",
- url: "json/message.txt",
- data: { "userid": get_userid, "mainTableName": get_mainTableName, "routeid": get_routeid, "subTableName": get_mainTableName, "subTableColumnsID": get_subTableColumnsID },
- //data: { "allJson": getTableJsonStr },
- dataType: "json",
- success: function (res) {
- if (res.success) {
- ///成功后,重新调用赋值方法,
- gethtmldata();
- }
- },
- error: function (XMLHttpRequest, textStatus, errorThrown) {
- console.log(errorThrown);
- }
- });
- }
-
- }
- else {
- return;
- }
- };
|