TbColumn.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /// <reference path="../../easyui/jquery.min.js" />
  2. jQuery.ajaxSetup({
  3. complete: function (data) {
  4. //对返回的数据data做判断,
  5. //session过期的话,就location到一个页面
  6. if (data.responseText == 'TimeOut') {
  7. //alert("登录超时,请重新登录!");
  8. top.location.href = '../Default.aspx';
  9. }
  10. }
  11. });
  12. function initAddTb() {
  13. $("#hid_UserType").val("add");
  14. $('#TextTableId').val("");
  15. $('#TextColumnId').val("");
  16. $("#CheckBoxIsVisable").attr("checked", true);
  17. $('#ChkBoxPrimaryKey').attr("checked",false);
  18. $('#TextDataType').val("");
  19. $("#CheckBoxAutoGen").attr("checked", false);
  20. $("#TextColDesc").val("");
  21. $("#CheckBoxAllowNull").attr("checked", false);
  22. $("#TextColumnName").val("");
  23. $("#TextWidth").val("");
  24. $("#TextCharNum").val("");
  25. $("#TextDefValue").val("");
  26. $("#TextSequence").val("");
  27. $("#TextDisplayValue").val("");
  28. $("#TextRelationColumns").val('');
  29. //$("#ExpirationDate").datebox('setValue', myformatter(new Date(rows[0].Expiration)));
  30. $('#winSetTbInfo').window('open');
  31. }
  32. function myformatter(date) {
  33. var y = date.getFullYear();
  34. var m = date.getMonth() + 1;
  35. var d = date.getDate();
  36. return y + '-' + (m < 10 ? ('0' + m) : m) + '-' + (d < 10 ? ('0' + d) : d);
  37. }
  38. function initEditTb(row) {
  39. $("#hid_UserType").val("modify");
  40. $('#TextTableId').val(row.TableId);
  41. $('#TextColumnId').val(row.ColumnId);
  42. $("#CheckBoxIsVisable").attr("checked", row.IsVisable=='Y'?true:false);
  43. $('#ChkBoxPrimaryKey').attr("checked", row.PrimaryKey == 'Y' ? true : false);
  44. $('#TextDataType').val(row.DataType);
  45. $("#CheckBoxAutoGen").attr("checked", row.AutoGen=='Y'?true:false);
  46. $("#TextColDesc").val(row.ColDesc);
  47. $("#CheckBoxAllowNull").attr("checked", row.AllowNull=="Y"?true:false);
  48. $("#TextColumnName").val(row.ColumnName);
  49. $("#TextWidth").val(row.Width);
  50. $("#TextCharNum").val(row.CharNum);
  51. $("#TextDefValue").val(row.DefValue);
  52. $("#TextSequence").val(row.Sequence);
  53. $("#TextDisplayValue").val(row.DisplayValue);
  54. $("#TextRelationColumns").val(row.RelationColumns);
  55. $('#winSetTbInfo').window('open');
  56. }
  57. function submit() {
  58. if (!$('#TextTableId').val().trim()) {
  59. $.messager.alert('提醒', '表名称不能为空', 'error');
  60. return;
  61. }
  62. if (!$('#TextColumnId').val().trim()) {
  63. $.messager.alert('提醒', '列不能为空', 'error');
  64. return;
  65. }
  66. // var TableId;
  67. // var ColumnId;
  68. // if($("#hid_UserType").val() == "modify") {
  69. // var rows = $('#dg').datagrid('getSelections');
  70. // var row = rows[0];
  71. // TableId = row.TableId;
  72. // ColumnId = row.ColumnId;
  73. // }
  74. $.post("../SystemModuleAjax/TbEditAjax.aspx", { TableId: $('#TextTableId').val().trim(), type: $('#hid_UserType').val(), ColumnId: $('#TextColumnId').val(),
  75. IsVisable: $('#CheckBoxIsVisable').is(':checked') ? "Y" : "N", isPrimaryKey: $('#ChkBoxPrimaryKey').is(':checked') ? "Y" : "N", isAutoGen: $('#CheckBoxAutoGen').is(':checked') ? "Y" : "N", isAllowNull: $('#CheckBoxAllowNull').is(':checked') ? "Y" : "N",
  76. DataType: $('#TextDataType').val(), ColDesc: $('#TextColDesc').val(), ColumnName: $("#TextColumnName").val(),Width:$("#TextWidth").val(), CharNum:$("#TextCharNum").val(),
  77. DefValue: $('#TextDefValue').val(), Sequence: $("#TextSequence").val(), DisplayValue: $("#TextDisplayValue").val(), RelationColumns: $("#TextRelationColumns").val()
  78. }, function (msg) {
  79. if (msg == "true") {
  80. $.messager.alert('提示', '操作成功!');
  81. //flashTable();
  82. f_submit();
  83. $('#winSetTbInfo').window('close');
  84. } else {
  85. $.messager.alert('提示', msg, 'error');
  86. }
  87. })
  88. }