Form.cshtml 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. @{
  2. ViewBag.Title = "Form";
  3. Layout = "~/Views/Shared/_Form.cshtml";
  4. }
  5. <script type="text/javascript">
  6. var parentId = request('parentId');
  7. var moduleButtonId = request('moduleButtonId');
  8. var moduleId = request('moduleId');
  9. $(function () {
  10. initControl();
  11. })
  12. var dataJson = top.Form.buttonJson;
  13. //初始化控件
  14. function initControl() {
  15. //上级
  16. $("#ParentId").ComboBoxTree({
  17. url: "../../AuthorizeManage/ModuleButton/ListToTreeJson",
  18. param: { moduleButtonJson: JSON.stringify(dataJson) },
  19. method: "post",
  20. description: "==请选择==",
  21. height: "150px"
  22. });
  23. if (!!moduleButtonId) {
  24. $.each(dataJson, function (i) {
  25. var row = dataJson[i];
  26. if (row.ModuleButtonId == moduleButtonId) {
  27. $("#form1").SetWebControls(row);
  28. }
  29. });
  30. } else {
  31. $("#ModuleId").val(moduleId);
  32. if (!!parentId) {
  33. $("#ParentId").ComboBoxTreeSetValue(parentId);
  34. } else {
  35. $("#ParentId").ComboBoxTreeSetValue(0);
  36. }
  37. }
  38. }
  39. //保存表单
  40. function AcceptClick(callback) {
  41. if (!$('#form1').Validform()) {
  42. return false;
  43. }
  44. var data = $("#form1").GetWebControls(moduleButtonId);
  45. if (data["ParentId"] == "") {
  46. data["ParentId"] = 0;
  47. }
  48. callback(data);
  49. dialogClose();
  50. }
  51. </script>
  52. <div style="margin-top: 10px; margin-right: 30px;">
  53. <input id="ModuleButtonId" type="hidden" value="@Guid.NewGuid().ToString()" />
  54. <input id="ModuleId" type="hidden" />
  55. <table class="form">
  56. <tr>
  57. <th class="formTitle">上级</th>
  58. <td class="formValue">
  59. <div id="ParentId" type="selectTree" class="ui-select">
  60. </div>
  61. </td>
  62. </tr>
  63. <tr>
  64. <th class="formTitle">编号<font face="宋体">*</font></th>
  65. <td class="formValue">
  66. <input id="EnCode" type="text" class="form-control" placeholder="请输入编号" isvalid="yes" checkexpession="NotNull" />
  67. </td>
  68. </tr>
  69. <tr>
  70. <th class="formTitle">名称<font face="宋体">*</font></th>
  71. <td class="formValue">
  72. <input id="FullName" type="text" class="form-control" placeholder="请输入名称" isvalid="yes" checkexpession="NotNull" />
  73. </td>
  74. </tr>
  75. <tr>
  76. <th class="formTitle">排序<font face="宋体">*</font></th>
  77. <td class="formValue">
  78. <input id="SortCode" type="text" class="form-control" placeholder="请输入排序" isvalid="yes" checkexpession="Num" />
  79. </td>
  80. </tr>
  81. <tr>
  82. <th class="formTitle">地址</th>
  83. <td class="formValue">
  84. <input id="ActionAddress" type="text" class="form-control" />
  85. </td>
  86. </tr>
  87. </table>
  88. </div>