|
|
@{ 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 SourceID = $.request("SourceID"); var LogString_Num = new Array(); var LogString_Str = new Array(); var LogString_Date = new Array(); var LogString_Bool = new Array();
var DataTypeString = new Array(); var AllDataBase = new Array(); var NewLine = 0; var MaxPaiXu = 0; var FirstShow = 0;
$(function () { GetAllDataBase(); LogString_Num = GetLogString("数值型"); LogString_Str = GetLogString("字符型"); LogString_Date = GetLogString("日期型"); LogString_Bool = GetLogString("布尔值"); DataTypeString = GetDataTypeString(); gridList(); $(window).resize(function () {
$("#gridList").setGridWidth($(window).width() * 0.99); $("#gridList").setGridWidth(document.body.clientWidth * 0.99); $("#gridList").setGridHeight($(window).height() - 96); $("#gridList").setGridHeight(document.body.clientHeight - 96); });
});
//加载所有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) { AllDataBase = new Array(); for (var i = 0; i < data.length; i++) { var obj = { DbId: data[i].DbId, DBSourceDesc: data[i].DBSourceDesc, } AllDataBase.push(obj); } } } }); }
function gridList() {
var $gridList = $("#gridList"); $gridList.dataGrid({ url: "/SystemManage/CommonReport/GetCondition?" + Math.random(), postData: { SourceID: SourceID }, height: $(window).height() - 96, colModel: [//IDStr 排序 必填 条件名称 字段名称 替代符号 数据类型 默认逻辑符号 默认值 //参照选择, 参照语句, 其他数据源, 本系统数据源, 返回字段 { label: 'IDStr', name: 'IDStr', width: 80, align: 'left', sortable: false, }, { label: 'IsNew', name: 'IsNew', width: 80, align: 'left', sortable: false, },
{ label: '排序', name: '排序', width: 80, align: 'left', sortable: false, formatter: function (cellvalue, options, rowObject) { if (parseInt(cellvalue) > MaxPaiXu) { MaxPaiXu = parseInt(cellvalue); } var str_retrun = '<input type="text" class="form-control" id="PaiXu_' + rowObject.IDStr + '" style="width:50px" value="' + cellvalue + '" />'; return cellvalue = str_retrun; }, }, { label: '必填', name: '必填', width: 60, align: 'left', sortable: false, formatter: function (cellvalue, options, rowObject) { var str_retrun = ""; if (cellvalue == "1") { str_retrun = '<input type="checkbox" id="Radio_' + rowObject.IDStr + '" checked="checked"/>'; } else { str_retrun = '<input type="checkbox" id="Radio_' + rowObject.IDStr + '" />'; } return cellvalue = str_retrun; }, }, { label: '条件名称', name: '条件名称', width: 150, align: 'left', sortable: false, formatter: function (cellvalue, options, rowObject) { var str_retrun = '<input type="text" class="form-control" id="Caption_' + rowObject.IDStr + '" value="' + cellvalue + '" />'; return cellvalue = str_retrun; }, },
{ label: '字段名称', name: '字段名称', width: 150, align: 'left', sortable: false, formatter: function (cellvalue, options, rowObject) { var str_retrun = '<input type="text" class="form-control" id="FiledName_' + rowObject.IDStr + '" value="' + cellvalue + '" />'; return cellvalue = str_retrun; }, }, { label: '替代符号', name: '替代符号', width: 150, align: 'left', sortable: false, formatter: function (cellvalue, options, rowObject) { var str_retrun = '<input type="text" class="form-control" id="Index_' + rowObject.IDStr + '" value="' + cellvalue + '" />'; return cellvalue = str_retrun; }, }, { label: '数据类型Data', name: '数据类型Data', width: 150, align: 'left', sortable: false, }, { label: '数据类型', name: '数据类型', width: 150, align: 'left', sortable: false, formatter: function (cellvalue, options, rowObject) {
var str_retrun = '<select class="selectpicker" id="selDataType_' + rowObject.IDStr + '" Title="" onchange="ChangeSel(\'' + rowObject.IDStr + '\')" data-width="100px" > '; str_retrun += "<option value=''></option>"; for (var i = 0; i < DataTypeString.length; i++) { str_retrun += "<option value=\"" + DataTypeString[i].value + "\">" + DataTypeString[i].Str + "</option>"; } str_retrun += '</select>'; return cellvalue = str_retrun;
} }, { label: '默认逻辑符号Data', name: '默认逻辑符号Data', width: 150, align: 'left', sortable: false, }, { label: '默认逻辑符号', name: '默认逻辑符号', width: 150, align: 'left', sortable: false, formatter: function (cellvalue, options, rowObject) {
var str_retrun = '<select class="selectpicker" id="selLogString_' + rowObject.IDStr + '" Title="" data-width="100px" > '; str_retrun += "<option value=''></option>"; for (var i = 0; i < LogString_Str.length; i++) { str_retrun += "<option value=\"" + LogString_Str[i].value + "\">" + LogString_Str[i].Str + "</option>"; } str_retrun += '</select>'; return cellvalue = str_retrun;
} }, { label: '默认值', name: '默认值', width: 150, align: 'left', sortable: false, formatter: function (cellvalue, options, rowObject) { var str_retrun = '<input type="text" class="form-control" id="DefaultValue_' + rowObject.IDStr + '" value="' + cellvalue + '" />'; return cellvalue = str_retrun; }, }, //参照选择, 参照语句, 其他数据源, 本系统数据源, 返回字段 { label: '参照选择', name: '参照选择', width: 80, align: 'left', sortable: false, formatter: function (cellvalue, options, rowObject) { var str_retrun = ""; if (cellvalue == "1") { str_retrun = '<input type="checkbox" id="CSelectFlag_' + rowObject.IDStr + '" checked="checked"/>'; } else { str_retrun = '<input type="checkbox" id="CSelectFlag_' + rowObject.IDStr + '" />'; } return cellvalue = str_retrun; }, }, { label: '参照语句', name: '参照语句', width: 200, align: 'left', sortable: false, formatter: function (cellvalue, options, rowObject) { var str_retrun = '<input type="text" class="form-control" id="CSelectSqlTxt_' + rowObject.IDStr + '" value="' + cellvalue + '" />'; return cellvalue = str_retrun; }, }, { label: '本系统数据源', name: '本系统数据源', width: 110, align: 'left', sortable: false, formatter: function (cellvalue, options, rowObject) { var str_retrun = ""; if (cellvalue == "1") { str_retrun = '<input type="checkbox" id="SysDataSourceFlag_' + rowObject.IDStr + '" checked="checked"/>'; } else { str_retrun = '<input type="checkbox" id="SysDataSourceFlag_' + rowObject.IDStr + '" />'; } return cellvalue = str_retrun; }, },
{ label: '其他数据源Data', name: '其他数据源Data', width: 80, align: 'left', sortable: false, }, { label: '其他数据源', name: '其他数据源', width: 150, align: 'left', sortable: false, formatter: function (cellvalue, options, rowObject) {
var str_retrun = '<select class="selectpicker" id="CSelectSourceId_' + rowObject.IDStr + '" Title="" data-width="100px" > '; str_retrun += "<option value=''></option>"; for (var i = 0; i < AllDataBase.length; i++) { str_retrun += "<option value=\"" + AllDataBase[i].DbId + "\">" + AllDataBase[i].DBSourceDesc + "</option>"; } str_retrun += '</select>'; return cellvalue = str_retrun;
} }, { label: '返回字段', name: '返回字段', width: 70, align: 'left', sortable: false, formatter: function (cellvalue, options, rowObject) { var str_retrun = '<input type="text" class="form-control" id="ReturnCol_' + rowObject.IDStr + '" value="' + cellvalue + '" />'; return cellvalue = str_retrun; }, },
],
viewrecords: true, rownumbers: true, multiselect: true, rowNum: 500, // cellEdit: false, // multiboxonly: true, // multikey:'shiftKey', gridComplete: function () { $("#gridList").setGridParam().hideCol("IDStr");//隐藏ID列 $("#gridList").setGridParam().hideCol("IsNew"); $("#gridList").setGridParam().hideCol("数据类型Data"); $("#gridList").setGridParam().hideCol("默认逻辑符号Data"); $("#gridList").setGridParam().hideCol("其他数据源Data"); var strIds = $("#gridList").jqGrid("getDataIDs"); if (FirstShow == 0) { for (var i = 0; i < strIds.length; i++) { var IDStr = $("#gridList").jqGrid("getCell", strIds[i], "IDStr"); var selDataType = $("#gridList").jqGrid("getCell", strIds[i], "数据类型Data"); $("#selDataType_" + IDStr).selectpicker('refresh'); $("#selDataType_" + IDStr).selectpicker('val', selDataType); var selLogString = $("#gridList").jqGrid("getCell", strIds[i], "默认逻辑符号Data"); $("#selLogString_" + IDStr).selectpicker('refresh'); $("#selLogString_" + IDStr).selectpicker('val', selLogString); var CSelectSourceId = $("#gridList").jqGrid("getCell", strIds[i], "其他数据源Data"); $("#CSelectSourceId_" + IDStr).selectpicker('refresh'); $("#CSelectSourceId_" + IDStr).selectpicker('val', CSelectSourceId);
} FirstShow = 1; } NewLine = strIds.length;
$("#gridList").jqGrid('hideCol', 'cb');//隐藏勾选框 //勾选框选中的时候 与行选中有异常,所以隐藏 },
}); }
function SHowcols(colname) { $("#gridList").setGridParam().showCol(colname);
}
function Hiddencols(colname) { $("#gridList").setGridParam().hideCol(colname);
}
//修改字符类型 ->逻辑符号修改 function ChangeSel(ColsName) { var datatype = $("#selDataType_" + ColsName).find("option:selected").text(); var $LogString = $("#selLogString_" + ColsName); switch (datatype) { case "日期型":
$LogString.find("option").remove(); $LogString.append("<option value=''></option>"); for (var i = 0; i < LogString_Date.length; i++) { $LogString.append("<option value='" + LogString_Date[i].value + "'>" + LogString_Date[i].Str + "</option>"); } break; case "字符型":
$LogString.find("option").remove(); $LogString.append("<option value=''></option>"); for (var i = 0; i < LogString_Str.length; i++) { $LogString.append("<option value='" + LogString_Str[i].value + "'>" + LogString_Str[i].Str + "</option>"); } break; case "数值型":
$LogString.find("option").remove(); $LogString.append("<option value=''></option>"); for (var i = 0; i < LogString_Num.length; i++) { $LogString.append("<option value='" + LogString_Num[i].value + "'>" + LogString_Num[i].Str + "</option>"); } break; case "布尔值":
$LogString.find("option").remove(); $LogString.append("<option value=''></option>"); for (var i = 0; i < LogString_Bool.length; i++) { $LogString.append("<option value='" + LogString_Bool[i].value + "'>" + LogString_Bool[i].Str + "</option>"); } break; } $LogString.selectpicker('refresh'); $LogString.selectpicker('render');
}
//新增一行 function btn_ADD() { NewLine = NewLine + 1; MaxPaiXu = MaxPaiXu + 1; var ids = jQuery("#gridList").jqGrid('getDataIDs'); if (ids.length == 0) { ids = [0]; } //获得当前最大行号(数据编号) var rowid = Math.max.apply(Math, ids); //获得新添加行的行号(数据编号) var newrowid = rowid + 1;
$("#gridList").addRowData(newrowid, {//排序 必填 条件名称 字段名称 替代符号 数据类型 默认逻辑符号 默认值 "IDStr": NewLine.toString(), "IsNew":"1", "排序": MaxPaiXu, "必填": "0", "条件名称": "", "字段名称": "", "替代符号": "1=1", "数据类型Data": "", "数据类型": "", "默认逻辑符号Data": "", "默认逻辑符号": "", "默认值": "", "参照选择": "0", "参照语句": "", "其他数据源Data": "", "其他数据源": "", "本系统数据源": "0", "返回字段": "", }, "last");
var unwritten = document.getElementsByClassName("unwritten")[0]; if (unwritten != null && unwritten != 'undefined') { unwritten.style.display = "none"; // $(".unwritten").attr("display", "none"); }
var strIds = $("#gridList").jqGrid("getDataIDs"); var rr = strIds.length - 1;
var IDStr = $("#gridList").jqGrid("getCell", strIds[rr], "IDStr"); var selDataType = $("#gridList").jqGrid("getCell", strIds[rr], "数据类型Data"); $("#selDataType_" + IDStr).selectpicker('refresh'); $("#selDataType_" + IDStr).selectpicker('val', selDataType); var selLogString = $("#gridList").jqGrid("getCell", strIds[rr], "默认逻辑符号Data"); $("#selLogString_" + IDStr).selectpicker('refresh'); $("#selLogString_" + IDStr).selectpicker('val', selLogString); var CSelectSourceId = $("#gridList").jqGrid("getCell", strIds[rr], "其他数据源Data"); $("#CSelectSourceId_" + IDStr).selectpicker('refresh'); $("#CSelectSourceId_" + IDStr).selectpicker('val', CSelectSourceId);
}
//删除选中行 function btn_Del() {
var selectedRowIds = $("#gridList").jqGrid("getGridParam", "selarrrow"); var len = selectedRowIds.length; for (var i = 0; i < len ; i++) { $("#gridList").jqGrid("delRowData", selectedRowIds[i]); }
var selectedRowIds = $("#gridList").jqGrid("getGridParam", "selarrrow"); var len = selectedRowIds.length; for (var i = 0; i < len ; i++) { $("#gridList").jqGrid("delRowData", selectedRowIds[i]); } }
function submitForm() { var SubmitLine = new Array(); var strIds = $("#gridList").jqGrid("getDataIDs"); for (var i = 0; i < strIds.length; i++) { //IDStr 排序 必填 条件名称 字段名称 替代符号 数据类型 默认逻辑符号 默认值 // NotNullFlag CCaption CFiledName CIndex CLogString CDefaultLogStirng CDataType CDefaultValue CSortSeq var ID = ""; var IDStr = $("#gridList").jqGrid("getCell", strIds[i], "IDStr");
var IsNew = $("#gridList").jqGrid("getCell", strIds[i], "IsNew");//是新增:“1” ,修改:“0” if(IsNew == "0") { ID = IDStr; } var CSortSeq = $("#PaiXu_" + IDStr).val(); var NotNullFlagStr = $("#Radio_" + IDStr)[0].checked; var NotNullFlag = "0"; if (NotNullFlagStr) { NotNullFlag = "1"; } var CCaption = $("#Caption_" + IDStr).val(); var CFiledName = $("#FiledName_" + IDStr).val(); var CIndex = $("#Index_" + IDStr).val(); var CDataType = $("#selDataType_" + IDStr).val(); var CDefaultLogStirng = $("#selLogString_" + IDStr).val(); var CDefaultValue = $("#DefaultValue_" + IDStr).val(); var CSelectFlagStr = $("#CSelectFlag_" + IDStr)[0].checked; var CSelectFlag = "0"; if (CSelectFlagStr) { CSelectFlag = "1"; } var CSelectSqlTxt = $("#CSelectSqlTxt_" + IDStr).val(); var CSelectSourceId = $("#CSelectSourceId_" + IDStr).val(); var SysDataSourceFlagStr = $("#SysDataSourceFlag_" + IDStr)[0].checked; var SysDataSourceFlag = "0"; if (SysDataSourceFlagStr) { SysDataSourceFlag = "1"; } var ReturnCol = $("#ReturnCol_" + IDStr).val();
var obj = { ID: ID, CSortSeq: CSortSeq, NotNullFlag: NotNullFlag, CCaption: CCaption, CFiledName: CFiledName, CIndex: CIndex, CDataType: CDataType, CDefaultLogStirng: CDefaultLogStirng, CDefaultValue: CDefaultValue, CLogString: GetCLogString(CDataType), CSelectFlag: CSelectFlag, CSelectSqlTxt: CSelectSqlTxt, CSelectSourceId: CSelectSourceId, SysDataSourceFlag: SysDataSourceFlag, ReturnCol: ReturnCol, } SubmitLine.push(obj); }
$.ajax({ url: "/SystemManage/CommonReport/SetCondition" + "?" + Math.random(), type: "post", data: { SourceID: SourceID, List_Condition: JSON.stringify(SubmitLine), }, async: false, success: function (data) { alert(data); $.modalClose(); }, error: function (aa) { //alert("异常:" + aa.responseText); $.modalAlertNew("WMS00015", aa.responseText);
} }); }
</script>
<form id="form1"> <div style="margin-top: 10px; margin-left: 10px; margin-right: 10px;"> <div class="form-group" style="height:40px;margin-bottom:5px">
<div class="btn-group"> <a id="Btn_ADD" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_ADD()"><i class="fa fa-plus"></i>新增</a> <a id="Btn_Del" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_Del()"><i class="fa fa-minus"></i>删除</a>
</div>
</div> <div class="gridPanel"> <table id="gridList"></table> @*<div id="gridPager"></div>*@ </div> </div> </form>
|