detail.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. var get_userid = "7ac641ab-8940-4a50-8a0e-afe1b6d1cda1";
  2. var get_mainTableName = sp.getUrlName("mainTableName");
  3. var get_routeid = sp.getUrlName("routeid");
  4. var get_routeinfoid = sp.getUrlName("routeinfoid");
  5. var get_role = sp.getUrlName("role");
  6. var get_AccessToken = "";
  7. function gethtmldata() {
  8. $.ajax({
  9. url: "json/fileurl.txt", //这里是静态页的地址
  10. type: "get", //静态页用get方法,否则服务器会抛出405错误
  11. data: { mainTableName: get_mainTableName, routeid: get_routeid },
  12. dataType: "json",
  13. success: function (res) {
  14. var get_fileurl = "";
  15. if (get_routeid == "31378") {
  16. get_fileurl = res.Item.htmlurl;
  17. } else if (get_routeid == "30574") {
  18. get_fileurl = "HTML/2018/201810/20181022174234084500002.html";
  19. } else if (get_routeid == "29468") {
  20. get_fileurl = "HTML/2018/201810/20181022174717032900081.html";
  21. } else if (get_routeid == "23991") {
  22. ///下拉、单选、多选-修改--测试01
  23. get_fileurl = "HTML/2023/202302/20230207112103084800086.html";
  24. } else if (get_routeid == "23992") {
  25. ///带有意见控件--测试01
  26. //get_fileurl = "HTML/2023/202302/20230212084437007400051.html";
  27. get_fileurl = "HTML/2023/202303/20230304221322009700038.html";
  28. } else {
  29. get_fileurl = "";
  30. }
  31. /////加载html
  32. if (get_fileurl != "" && get_fileurl != null && get_fileurl != undefined) {
  33. $.ajax({
  34. url: get_fileurl, //这里是静态页的地址
  35. type: "get", //静态页用get方法,否则服务器会抛出405错误
  36. cache: false,
  37. async: false,
  38. success: function (result) {
  39. /////console.log(result);
  40. /////含有body标签,得到里面的内容
  41. if (result.indexOf("body") != -1) {
  42. var bodyDataCode = result.substring(result.indexOf("<body>") + 6, result.indexOf("</body>"));//截取body中内容
  43. //console.log(bodyDataCode);
  44. $("#viewPart").html(bodyDataCode);
  45. if (get_routeid == "0") {
  46. /////此时是新建
  47. sp.radio();///单选
  48. sp.checkbox();///多选
  49. spvld.getValidate();///开始正则校验组件
  50. spbld.laydate();////操作日期控件组件
  51. spbld.subtable();///操作子表按钮组件
  52. sp.uploadimg("http://103.233.7.57:8080/GoldFile/image/upload");////图片上传组件
  53. sp.uploadfile("http://103.233.7.57:8080/GoldFile/stream/upload");///附件上传组件,
  54. } else {
  55. ////此时是编辑
  56. var get_viewData_json = "";
  57. if (get_routeid == "23991" || get_routeid == "23992") {
  58. ///下拉、单选、多选-修改--测试01
  59. get_viewData_json = "json.page/detail/spandown_test_1.txt?ctime="+new Date();
  60. } else {
  61. get_viewData_json = "json/viewData.txt?ctime=" + new Date();
  62. }
  63. $.ajax({
  64. url: get_viewData_json, //这里是静态页的地址
  65. type: "get", //静态页用get方法,否则服务器会抛出405错误
  66. data: { userid:get_userid, mainTableName: get_mainTableName, routeid: get_routeid },
  67. dataType: "json",
  68. success: function (res) {
  69. //console.log(res);
  70. ////调用给表单赋值组件
  71. spbld.fbAssignValueToTable(JSON.stringify(res), get_userid, get_routeinfoid, get_AccessToken);
  72. if (get_role == "read") {
  73. ///只读状态将表单中全部设置为只读状态,不可录入编辑删除
  74. $("body").find("button").attr("disabled", "disabled");
  75. $("body").find("input").attr("disabled", "disabled");
  76. $("body").find("select").attr("disabled", "disabled");
  77. $("body").find("textarea").attr("disabled", "disabled");
  78. $("body").find(".sp-upload-tip-close").hide(); ////附件列表的删除按钮去掉
  79. }
  80. sp.radio();///单选
  81. sp.checkbox();///多选
  82. spvld.getValidate();///开始正则校验组件
  83. spbld.laydate();////操作日期控件组件
  84. spbld.subtable();///操作子表按钮组件
  85. sp.uploadimg("http://103.233.7.57:8080/GoldFile/image/upload");////图片上传组件
  86. sp.uploadfile("http://103.233.7.57:8080/GoldFile/stream/upload");///附件上传组件,
  87. ///////测试端口,正式端口http://103.233.7.38:8080/GoldFile/stream/upload
  88. },
  89. //请求执行异常执行的方法
  90. error: function (XMLHttpRequest, textStatus, errorThrown) {
  91. console.log("您好,文件数据加载失败");
  92. }
  93. });
  94. }
  95. }
  96. },
  97. //请求执行异常执行的方法
  98. error: function (XMLHttpRequest, textStatus, errorThrown) {
  99. console.log("您好,文件数据加载失败");
  100. }
  101. });
  102. } else {
  103. console.log("您好,未找到表单文件的路径");
  104. }
  105. },
  106. //请求执行异常执行的方法
  107. error: function (XMLHttpRequest, textStatus, errorThrown) {
  108. console.log("您好,文件数据加载失败");
  109. }
  110. });
  111. };
  112. if (get_mainTableName == undefined || get_mainTableName == null) {
  113. sp.dialog("您好,未找到主表名,请确保参数正确");
  114. } else {
  115. gethtmldata();
  116. };
  117. ////上部提交按钮
  118. function btnSubmitData() {
  119. if (spvld.submit("#viewPart")) {
  120. var getTableJsonStr = spbld.fbFrtTableJson("#viewPart", "mainTableName", "mainTableColumnsID");
  121. console.log(getTableJsonStr);
  122. ////ajax传给后端
  123. $.ajax({
  124. type: "get",
  125. url: "json/message.txt",
  126. data: { userid: get_userid, routeid: get_routeid, mainTableName: get_mainTableName, frtJson: getTableJsonStr },
  127. //data: { "allJson": getTableJsonStr },
  128. dataType: "json",
  129. success: function (res) {
  130. if (res.success) {
  131. ///成功后,重新调用赋值方法,
  132. gethtmldata();
  133. }
  134. },
  135. error: function (XMLHttpRequest, textStatus, errorThrown) {
  136. console.log(errorThrown);
  137. }
  138. });
  139. };
  140. };
  141. //子表提交按钮事件
  142. function fbSubTableSubmitData(obj) {
  143. //var $currentTr = $(obj).closest("tr");
  144. //提交数据
  145. /*ajax*/
  146. setTimeout(function () {
  147. //$(obj).hide();
  148. //$currentTr.find('.fb-edit-data').css('display', 'inline-block');
  149. //$currentTr.find('input').attr('disabled', 'disabled');
  150. //$currentTr.find('select').attr('disabled', 'disabled');
  151. //$currentTr.find('textarea').attr('disabled', 'disabled');
  152. ///子表每次都提交整体数据,原因是为了保持更改数据的实时性,有时会出现,子表数据求合计的情况
  153. btnSubmitData(); ///子表的提交再次调用提交事件,
  154. }, 100);
  155. }
  156. //子表删除按钮
  157. function fbSubTableDelData(obj) {
  158. ////子表删除功能需要
  159. if (confirm("您好,删除后不可恢复,您确认要删除吗")) {// 先查找并隐藏当前点击行
  160. //$(obj).closest('tr').hide();
  161. var get_subTableName = $(obj).parents(".sp-subgrid-job").attr("data-subtablename");
  162. var get_subTableColumnsID = $(obj).closest("tr").find("td:first").attr("data-index");
  163. if (get_subTableColumnsID==0) {
  164. alert("您好,为了保证预览效果,第一行禁止删除");
  165. }else{
  166. $.ajax({
  167. type: "get",
  168. url: "json/message.txt",
  169. data: { "userid": get_userid, "mainTableName": get_mainTableName, "routeid": get_routeid, "subTableName": get_mainTableName, "subTableColumnsID": get_subTableColumnsID },
  170. //data: { "allJson": getTableJsonStr },
  171. dataType: "json",
  172. success: function (res) {
  173. if (res.success) {
  174. ///成功后,重新调用赋值方法,
  175. gethtmldata();
  176. }
  177. },
  178. error: function (XMLHttpRequest, textStatus, errorThrown) {
  179. console.log(errorThrown);
  180. }
  181. });
  182. }
  183. }
  184. else {
  185. return;
  186. }
  187. };