@{
ViewBag.Title = "VpcpIndex";
}
<script src="/js/jquery-2.1.4.min.js" type="text/javascript"></script>
<script src="~/js/external/spreadjs/gcspread.sheets.9.40.20153.0.change.js"></script>
<link href="~/js/external/spreadjs/css/gcspread.sheets.9.40.20153.0.css" rel="stylesheet" />
<div>
<div class="panelBar">
<ul class="toolBar">
<li><a class="add" href="#" id="btnInsertRow"> <span>添加</span></a></li>
<li><a class="delete" href="#" id="btnDeleteRow" @*onclick="javascript: if (confirm('确认删除吗?')) deleteRow();" title="确定要删除吗?" warn="请选择一个用户"*@><span>删除</span></a></li>
<li><a class="icon" href="#" id="btnExport" title="确定要导出这些记录吗?"><span>导出EXCEL</span></a></li>
<li><a class="icon" href="#" id="Save"><span>保存</span></a></li>
</ul>
</div>
<div id="ss" style="width: 98%; border: 1px solid gray;">
</div>
</div>
<script type="text/javascript">
$(document).ready(function () {
var height=$(window).height()-160;
$("#ss").height(height);
initSpread();
});
//初始化 表格
function initSpread() {
var spread = new GcSpread.Sheets.Spread(document.getElementById("ss"), { sheetCount: 1 });
var style = new GcSpread.Sheets.Style(); style.locked = true;
var style2 = new GcSpread.Sheets.Style(); style2.locked = false;
var rowStyle = new GcSpread.Sheets.Style(); rowStyle.locked = true;
$.getJSON('/ControlPlan/GetSheetTitleVP', function(data) {
spread = $('#ss').data('spread');
spread.fromJSON(JSON.parse(data));
//$("#ss").show('fast');
});
var sheet = spread.getSheet(0);
sheet.isPaintSuspended(true);
sheet.getDefaultStyle().locked = false;
sheet.setIsProtected(true);
sheet.protectionOption({
allowSelectUnlockedCells:true,
allowFilter: true,
allowSort: false,
allowResizeRows: true,
allowResizeColumns: true,
allowEditObjects: true
});
var option = sheet.protectionOption();
console.log(JSON.stringify(option, null, 2));
sheet.autoGenerateColumns = false;
sheet.getCell(1,1).locked(true);
///表头锁定部分
sheet.setStyle(0, -1, rowStyle, GcSpread.Sheets.SheetArea.viewport);
sheet.setStyle(1, -1, rowStyle, GcSpread.Sheets.SheetArea.viewport);
sheet.setStyle(2, -1, rowStyle, GcSpread.Sheets.SheetArea.viewport);
//表单内部前五列锁定部分
sheet.setStyle(-1, 0, rowStyle, GcSpread.Sheets.SheetArea.viewport);
sheet.setStyle(-1, 1, rowStyle, GcSpread.Sheets.SheetArea.viewport);
sheet.setStyle(-1, 2, rowStyle, GcSpread.Sheets.SheetArea.viewport);
sheet.setStyle(-1, 3, rowStyle, GcSpread.Sheets.SheetArea.viewport);
sheet.setStyle(-1, 4, rowStyle, GcSpread.Sheets.SheetArea.viewport);
var jsonModel;
$.ajax({
type: "post",
url: "/ControlPlan/GetSheetContentVP/@Html.ViewContext.RouteData.Values["id"]",
async: false,
dataType: "json",
success: function (data) {
jsonModel = data;
}
});
//循环赋值
if (jsonModel!=null) {
for (var i = 0; i < jsonModel.length; i++) {
sheet.setValue(i + 1, 0, jsonModel[i].PartNo).tag(jsonModel[i].MechanismId);
sheet.setValue(i + 1, 1, jsonModel[i].Process).settag(jsonModel[i].FailuremodeId);
sheet.setValue(i + 1, 2, jsonModel[i].Machine);
sheet.setValue(i + 1, 3, jsonModel[i].CharacterNo).tag(jsonModel[i].VpcpinfoId);
sheet.setValue(i + 1, 4, jsonModel[i].CharacterProduct);
sheet.setValue(i + 1, 5, jsonModel[i].CharacterProcess);
sheet.setValue(i + 1, 6, jsonModel[i].SpecialClass);
sheet.setValue(i + 1, 7, jsonModel[i].Specificationtolerance);
sheet.setValue(i + 1, 8, jsonModel[i].Evaluation);
sheet.setValue(i + 1, 9, jsonModel[i].Capacity);
sheet.setValue(i + 1, 10, jsonModel[i].Frequency);
sheet.setValue(i + 1, 11, jsonModel[i].CMethod);
sheet.setValue(i + 1, 12, jsonModel[i].RPlan);
//sheet.setValue(i + 1, 13, jsonModel[i].MechanismId);
//sheet.setValue(i + 1, 14, jsonModel[i].FailuremodeId);
//sheet.setValue(i + 1, 15, jsonModel[i].VpcpinfoId);
//sheet.getColumn(13).visible(false);
//sheet.getColumn(14).visible(false);
//sheet.getColumn(15).visible(false);
sheet.setStyle(i + 1, -1, style);
sheet.autoFitRow(i + 1);
sheet.getRow(i + 1).height(60);
}
}
sheet.setFrozenCount(1,0);
spread.scrollbarShowMax(true);
spread.scrollbarMaxAlign(true);
spread.newTabVisible(false);
spread.tabStripVisible(false);
spread.invalidateLayout();
sheet.isPaintSuspended(false);
}
function createModel(PartNo, Process, Machine, CharacterNo, CharacterProduct, CharacterProcess,
SpecialClass, Specificationtolerance, Evaluation, Capacity, Frequency,
CMethod, RPlan, MechanismId,FailuremodeId,VpcpinfoId) {
this.PartNo = PartNo;
this.Process = Process;
this.Machine = Machine;
this.CharacterNo = CharacterNo;
this.CharacterProduct = CharacterProduct;
this.CharacterProcess = CharacterProcess;
this.SpecialClass = SpecialClass;
this.Specificationtolerance = Specificationtolerance;
this.Evaluation = Evaluation;
this.Capacity = Capacity;
this.Frequency = Frequency;
this.CMethod = CMethod;
this.RPlan = RPlan;
this.MechanismId = MechanismId;
this.FailuremodeId = FailuremodeId;
this.VpcpinfoId = VpcpinfoId;
}
$("#Save").click(function () {
var sheet = $("#ss").data("spread").getSheet(0);
var data = new Array();
var row = 0;
for (var i= 3; true; i++) {
if( sheet.getValue(i,1)!=null)
{
data[row] = new createModel(sheet.getValue(i,0), sheet.getValue(i,1), sheet.getValue(i,2), sheet.getValue(i,3), sheet.getValue(i,4),
sheet.getValue(i,5), sheet.getValue(i,6), sheet.getValue(i,7), sheet.getValue(i,8), sheet.getValue(i,9), sheet.getValue(i,10),
sheet.getValue(i,11), sheet.getValue(i,12), sheet.getTag(i,13),sheet.getTag(i,14)
,sheet.getTag(i,15));
row++;
}
else
{
break;
}
}
$.post("/ControlPlan/SaveSheetContentVP", { "dataList": data,"id" Html.ViewContext.RouteData.Values["id"]} , function (result) {
alert("保存成功!");
});
});
</script>
|