Form.cshtml 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. @{
  2. ViewBag.Title = "表具类型管理";
  3. Layout = "~/Views/Shared/_Form.cshtml";
  4. }
  5. <script>
  6. var keyValue = request('keyValue');
  7. $(function () {
  8. initControl();
  9. })
  10. //初始化控件
  11. function initControl() {
  12. //表类型
  13. $("#NBDevManufacturerID").ComboBoxTree({
  14. url: "/NBManage/NBMeterTypeManage/GetDevManufacturer",
  15. id: "ItemValue",
  16. text: "ItemName",
  17. description: "==请选择==",
  18. height: "200px"
  19. });
  20. $("#NBDevManufacturerCodeID").val(keyValue == "" ? "0" : keyValue);
  21. //获取表单
  22. if (!!keyValue) {
  23. $.SetForm({
  24. url: "/NBManage/NBDevManufacturerCodeManage/GetEntity",
  25. param: { keyValue: keyValue },
  26. success: function (data) {
  27. $("#form1").SetWebControls(data);
  28. }
  29. });
  30. }
  31. }
  32. //保存表单
  33. function AcceptClick() {
  34. if (!$('#form1').Validform()) {
  35. return false;
  36. }
  37. var postData = $("#form1").GetWebControls(keyValue);
  38. //postData 格式化 将&nbsp; 替换为 ""
  39. for (var i in postData) {
  40. if (postData[i] == "&nbsp;") {
  41. postData[i] = "";
  42. }
  43. }
  44. $.SaveForm({
  45. url: "/NBManage/NBDevManufacturerCodeManage/SaveForm?keyValue=" + keyValue,
  46. param: { "keyValue": keyValue, "strFrom": JSON.stringify(postData) },
  47. loading: "正在保存数据...",
  48. success: function () {
  49. $.currentIframe().$("#gridTable").resetSelection();
  50. $.currentIframe().$("#gridTable").trigger("reloadGrid");
  51. }
  52. })
  53. }
  54. </script>
  55. <style type="text/css">
  56. .form .formTitle {
  57. width: 100px;
  58. }
  59. </style>
  60. <div style="margin-left: 10px; margin-top: 20px; margin-right: 30px;">
  61. <table class="form">
  62. <tr>
  63. <th class="formTitle">NB设备厂商名称<font face="宋体">*</font></th>
  64. <td class="formValue">
  65. <div id="NBDevManufacturerID" type="select" class="ui-select" isvalid="yes" checkexpession="NotNull" errormsg="请选择设备厂商名称">
  66. </div>
  67. </td>
  68. </tr>
  69. <tr>
  70. <th class="formTitle">NB设备厂商ID<font face="宋体">*</font></th>
  71. <td class="formValue">
  72. <input id="NBDevManufacturerCodeName" type="text" class="form-control" isvalid="yes" checkexpession="NotNull" errormsg="请输入NB设备类型" placeholder="请输入NB设备厂商ID" />
  73. </td>
  74. <input id="NBDevManufacturerCodeID" class="form-control" type="hidden" />
  75. </tr>
  76. </table>
  77. </div>