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

250 lines
9.4 KiB

  1. @{
  2. ViewBag.Title = "Form";
  3. Layout = "~/Views/Shared/_Form.cshtml";
  4. }
  5. <link href="~/Content/css/CommonReport/CommonReport.css" rel="stylesheet" />
  6. <script src="~/Content/js/CommonReport/CommonReport.js"></script>
  7. <link href="~/Content/css/bootstrap/bootstrap-select.css" rel="stylesheet" />
  8. <script src="~/Content/js/bootstrap/bootstrap-select.min.js"></script>
  9. <style>
  10. * {
  11. box-sizing: border-box;
  12. }
  13. </style>
  14. <script>
  15. var MenuID = $.request("MenuID");
  16. var SourceID = "";
  17. $(function () {
  18. GetAllDataBase();
  19. GetMenuSQL();
  20. });
  21. //加载所有DB选项
  22. function GetAllDataBase()
  23. {
  24. $.ajax({
  25. url: "/SystemManage/CommonReport/GetAllDataBase?" + Math.random(),
  26. dataType: "json",
  27. async: false,
  28. success: function (data) {
  29. if (data != false && data != null && data.length > 0) {
  30. $("#Select_DataBase").find("option").remove();
  31. $("#Select_DataBase").append("<option value=''></option>");
  32. for (var i = 0; i < data.length; i++) {
  33. $("#Select_DataBase").append("<option value='" + data[i].DbId + "'>" + data[i].DBSourceDesc + "</option>");
  34. }
  35. }
  36. $('#Select_DataBase').selectpicker('refresh');
  37. $('#Select_DataBase').selectpicker('render');
  38. }
  39. });
  40. }
  41. //加载已存数据
  42. function GetMenuSQL() {
  43. $.ajax({
  44. url: "/SystemManage/CommonReport/GetMenuSQL?MenuID=" + MenuID + "&" + Math.random(),
  45. dataType: "json",
  46. async: false,
  47. success: function (data) {
  48. if (data != false && data != null && data.length > 0) {
  49. SourceID = data[0].SourceID;
  50. $("#DbParameters").val(data[0].DbParameters);
  51. $("#TempName").val(data[0].TempName);
  52. $("#txt_sql").val(data[0].FormatSql);
  53. $("#XCol").val(data[0].XCol);
  54. if (data[0].SysDataSourceFlag == "1") {
  55. $("#chk_CurrentDB")[0].checked = true;
  56. }
  57. if (data[0].SysDataSourceFlag == "0") {
  58. $("#Select_DataBase").selectpicker('val', data[0].DbId);
  59. }
  60. }
  61. }
  62. });
  63. }
  64. function submitForm() {
  65. var rr = "";
  66. var RetuenStr = "OK";
  67. var SysDataSourceFlag = "1";
  68. var DbId = $("#Select_DataBase").val();
  69. var DbParameters = $("#DbParameters").val();
  70. var chk_DB = $("#chk_CurrentDB")[0];
  71. var TempName = $("#TempName").val();
  72. var XCol = $("#XCol").val();
  73. if (!chk_DB.checked)
  74. {
  75. SysDataSourceFlag = "0";
  76. if (DbId == "" || DbId==null)
  77. {
  78. alert("请勾选数据库");
  79. return;
  80. }
  81. }
  82. $.ajax({
  83. url: "/SystemManage/CommonReport/SetDataSource?" + Math.random(),
  84. type: "post",
  85. data: { SysDataSourceFlag: SysDataSourceFlag, FormatSql: $("#txt_sql").val(), DbId: DbId, MenuID: MenuID, DbParameters: DbParameters, SourceID: SourceID, TempName: TempName, XCol: XCol },
  86. async: false,
  87. success: function (data) {
  88. if (data == "操作成功") {
  89. alert(data);
  90. $.modalClose();
  91. }
  92. else { alert(data); rr = "Error"; return rr;}
  93. },
  94. error: function (aa) {
  95. //alert("异常:" + aa.responseText);
  96. $.modalAlertNew("WMS00015", aa.responseText);
  97. }
  98. });
  99. return rr;
  100. }
  101. //条件设置
  102. function btn_Condition() {
  103. $.modalOpen({
  104. id: "Condition",
  105. title: "条件设置",
  106. url: "/SystemManage/CommonReport/Condition?SourceID=" + SourceID + "&" + Math.random(),
  107. width: "1300px",
  108. height: "570px",
  109. btn: ['确认', '关闭'],
  110. callBack: function (iframeId) {
  111. top.frames[iframeId].submitForm();
  112. }
  113. });
  114. }
  115. function btn_Text()
  116. {
  117. var RetuenStr = "OK";
  118. var SysDataSourceFlag = "1";
  119. var DbId = $("#Select_DataBase").val();
  120. var DbParameters = $("#DbParameters").val();
  121. var chk_DB = $("#chk_CurrentDB")[0];
  122. var TempName = $("#TempName").val();
  123. var XCol = $("#XCol").val();
  124. if (!chk_DB.checked) {
  125. SysDataSourceFlag = "0";
  126. if (DbId == "" || DbId == null) {
  127. alert("请勾选数据库");
  128. }
  129. }
  130. $.ajax({
  131. url: "/SystemManage/CommonReport/SetDataSourceText?" + Math.random(),
  132. type: "post",
  133. data: { SysDataSourceFlag: SysDataSourceFlag, FormatSql: $("#txt_sql").val(), DbId: DbId, DbParameters: DbParameters, TempName: TempName, XCol: XCol },
  134. async: false,
  135. success: function (data) {
  136. if (data == "OK") {
  137. alert("测试成功");
  138. }
  139. else { alert(data); }
  140. },
  141. error: function (aa) {
  142. //alert("异常:" + aa.responseText);
  143. $.modalAlertNew("WMS00015", aa.responseText);
  144. }
  145. });
  146. }
  147. </script>
  148. <form id="form1">
  149. <div class="widget-body">
  150. <div style="padding-top: 5px; ">
  151. <div class="step-content" id="wizard-steps" style="border-left: none; border-bottom: none; border-right: none;">
  152. <div class="step-pane active" id="step-1" style="padding-left: 5px; padding-top: 20px; margin-right: 20px;">
  153. <table class="form">
  154. <tr>
  155. <th class="formTitle" style="width:85px">数据库: </th>
  156. <td class="formValue" style="width:170px">
  157. @*<div class="ckbox">
  158. <input type="checkbox" class="form-control" id="chk_CurrentDB" name="chk_CurrentDB" value="Cuurent" />
  159. <label for="chk_CurrentDB">当前系统数据源</label>
  160. </div>*@
  161. <label class="radio-inline">
  162. <input type="checkbox" name="chk_CurrentDB" id="chk_CurrentDB" value="1" /> 当前系统数据源
  163. </label>
  164. </td>
  165. <td class="formValue" style="width:95px">
  166. 其他数据源
  167. </td>
  168. <td class="formValue" style="width:175px">
  169. <select id="Select_DataBase" name="Select_DataBase" title="" class="selectpicker" data-width="140px"></select>
  170. </td>
  171. <td class="formValue" style="width:95px">
  172. 结果临时表名
  173. </td>
  174. <td class="formValue" style="width:175px">
  175. <input class="form-control" name="TempName" id="TempName" type="text" />
  176. </td>
  177. </tr>
  178. <tr>
  179. <th class="formTitle">数据源SQL: </th>
  180. <td class="formValue" style="height:300px;overflow:auto" colspan="5">
  181. <textarea class="form-control" name="txt_sql" id="txt_sql" style="width: 95%;height:100%" wrap="soft"></textarea>
  182. </td>
  183. </tr>
  184. <tr>
  185. <th class="formTitle">传入参数: </th>
  186. <td class="formValue" style="overflow:auto" colspan="4">
  187. <input class="form-control" name="DbParameters" id="DbParameters" style="width: 95%" />
  188. </td>
  189. <td class="formValue" style="height:45px; ">多个参数用,分隔 </td>
  190. </tr>
  191. <tr>
  192. <th class="formTitle">默认排序: </th>
  193. <td class="formValue" colspan="4">
  194. <input class="form-control" name="XCol" id="XCol" style="width: 95%" />
  195. </td>
  196. </tr>
  197. <tr>
  198. <th class="formTitle">
  199. <a id="NF-Condition" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_Condition()"><i class="fa fa-list-ul"></i>条件设置</a>
  200. </th>
  201. <th class="formTitle">
  202. <a id="NF-Text" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_Text()"><i class="fa fa-list-ul"></i>测试语句</a>
  203. </th>
  204. </tr>
  205. </table>
  206. </div>
  207. </div>
  208. </div>
  209. </div>
  210. </form>