纽威
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

@{
ViewBag.Title = "Form";
Layout = "~/Views/Shared/_Form.cshtml";
}
<link href="~/Content/css/CommonReport/CommonReport.css" rel="stylesheet" />
<script src="~/Content/js/CommonReport/CommonReport.js"></script>
<link href="~/Content/css/bootstrap/bootstrap-select.css" rel="stylesheet" />
<script src="~/Content/js/bootstrap/bootstrap-select.min.js"></script>
<style>
* {
box-sizing: border-box;
}
</style>
<script>
var MenuID = $.request("MenuID");
var SourceID = "";
$(function () {
GetAllDataBase();
GetMenuSQL();
});
//加载所有DB选项
function GetAllDataBase()
{
$.ajax({
url: "/SystemManage/CommonReport/GetAllDataBase?" + Math.random(),
dataType: "json",
async: false,
success: function (data) {
if (data != false && data != null && data.length > 0) {
$("#Select_DataBase").find("option").remove();
$("#Select_DataBase").append("<option value=''></option>");
for (var i = 0; i < data.length; i++) {
$("#Select_DataBase").append("<option value='" + data[i].DbId + "'>" + data[i].DBSourceDesc + "</option>");
}
}
$('#Select_DataBase').selectpicker('refresh');
$('#Select_DataBase').selectpicker('render');
}
});
}
//加载已存数据
function GetMenuSQL() {
$.ajax({
url: "/SystemManage/CommonReport/GetMenuSQL?MenuID=" + MenuID + "&" + Math.random(),
dataType: "json",
async: false,
success: function (data) {
if (data != false && data != null && data.length > 0) {
SourceID = data[0].SourceID;
$("#DbParameters").val(data[0].DbParameters);
$("#TempName").val(data[0].TempName);
$("#txt_sql").val(data[0].FormatSql);
$("#XCol").val(data[0].XCol);
if (data[0].SysDataSourceFlag == "1") {
$("#chk_CurrentDB")[0].checked = true;
}
if (data[0].SysDataSourceFlag == "0") {
$("#Select_DataBase").selectpicker('val', data[0].DbId);
}
}
}
});
}
function submitForm() {
var rr = "";
var RetuenStr = "OK";
var SysDataSourceFlag = "1";
var DbId = $("#Select_DataBase").val();
var DbParameters = $("#DbParameters").val();
var chk_DB = $("#chk_CurrentDB")[0];
var TempName = $("#TempName").val();
var XCol = $("#XCol").val();
if (!chk_DB.checked)
{
SysDataSourceFlag = "0";
if (DbId == "" || DbId==null)
{
alert("请勾选数据库");
return;
}
}
$.ajax({
url: "/SystemManage/CommonReport/SetDataSource?" + Math.random(),
type: "post",
data: { SysDataSourceFlag: SysDataSourceFlag, FormatSql: $("#txt_sql").val(), DbId: DbId, MenuID: MenuID, DbParameters: DbParameters, SourceID: SourceID, TempName: TempName, XCol: XCol },
async: false,
success: function (data) {
if (data == "操作成功") {
alert(data);
$.modalClose();
}
else { alert(data); rr = "Error"; return rr;}
},
error: function (aa) {
//alert("异常:" + aa.responseText);
$.modalAlertNew("WMS00015", aa.responseText);
}
});
return rr;
}
//条件设置
function btn_Condition() {
$.modalOpen({
id: "Condition",
title: "条件设置",
url: "/SystemManage/CommonReport/Condition?SourceID=" + SourceID + "&" + Math.random(),
width: "1300px",
height: "570px",
btn: ['确认', '关闭'],
callBack: function (iframeId) {
top.frames[iframeId].submitForm();
}
});
}
function btn_Text()
{
var RetuenStr = "OK";
var SysDataSourceFlag = "1";
var DbId = $("#Select_DataBase").val();
var DbParameters = $("#DbParameters").val();
var chk_DB = $("#chk_CurrentDB")[0];
var TempName = $("#TempName").val();
var XCol = $("#XCol").val();
if (!chk_DB.checked) {
SysDataSourceFlag = "0";
if (DbId == "" || DbId == null) {
alert("请勾选数据库");
}
}
$.ajax({
url: "/SystemManage/CommonReport/SetDataSourceText?" + Math.random(),
type: "post",
data: { SysDataSourceFlag: SysDataSourceFlag, FormatSql: $("#txt_sql").val(), DbId: DbId, DbParameters: DbParameters, TempName: TempName, XCol: XCol },
async: false,
success: function (data) {
if (data == "OK") {
alert("测试成功");
}
else { alert(data); }
},
error: function (aa) {
//alert("异常:" + aa.responseText);
$.modalAlertNew("WMS00015", aa.responseText);
}
});
}
</script>
<form id="form1">
<div class="widget-body">
<div style="padding-top: 5px; ">
<div class="step-content" id="wizard-steps" style="border-left: none; border-bottom: none; border-right: none;">
<div class="step-pane active" id="step-1" style="padding-left: 5px; padding-top: 20px; margin-right: 20px;">
<table class="form">
<tr>
<th class="formTitle" style="width:85px">数据库: </th>
<td class="formValue" style="width:170px">
@*<div class="ckbox">
<input type="checkbox" class="form-control" id="chk_CurrentDB" name="chk_CurrentDB" value="Cuurent" />
<label for="chk_CurrentDB">当前系统数据源</label>
</div>*@
<label class="radio-inline">
<input type="checkbox" name="chk_CurrentDB" id="chk_CurrentDB" value="1" /> 当前系统数据源
</label>
</td>
<td class="formValue" style="width:95px">
其他数据源
</td>
<td class="formValue" style="width:175px">
<select id="Select_DataBase" name="Select_DataBase" title="" class="selectpicker" data-width="140px"></select>
</td>
<td class="formValue" style="width:95px">
结果临时表名
</td>
<td class="formValue" style="width:175px">
<input class="form-control" name="TempName" id="TempName" type="text" />
</td>
</tr>
<tr>
<th class="formTitle">数据源SQL: </th>
<td class="formValue" style="height:300px;overflow:auto" colspan="5">
<textarea class="form-control" name="txt_sql" id="txt_sql" style="width: 95%;height:100%" wrap="soft"></textarea>
</td>
</tr>
<tr>
<th class="formTitle">传入参数: </th>
<td class="formValue" style="overflow:auto" colspan="4">
<input class="form-control" name="DbParameters" id="DbParameters" style="width: 95%" />
</td>
<td class="formValue" style="height:45px; ">多个参数用,分隔 </td>
</tr>
<tr>
<th class="formTitle">默认排序: </th>
<td class="formValue" colspan="4">
<input class="form-control" name="XCol" id="XCol" style="width: 95%" />
</td>
</tr>
<tr>
<th class="formTitle">
<a id="NF-Condition" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_Condition()"><i class="fa fa-list-ul"></i>条件设置</a>
</th>
<th class="formTitle">
<a id="NF-Text" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_Text()"><i class="fa fa-list-ul"></i>测试语句</a>
</th>
</tr>
</table>
</div>
</div>
</div>
</div>
</form>