AddClass.cshtml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. 
  2. @{
  3. ViewBag.Title = "AddClass";
  4. Layout = "~/Views/Shared/_MainLayoutPage.cshtml";
  5. }
  6. <script src="~/Content/Scripts/Common.js"></script>
  7. <div class="easyui-layout" data-options="fit:true">
  8. <table class="layui-table">
  9. <colgroup>
  10. <col width="80">
  11. <col>
  12. </colgroup>
  13. <tr>
  14. <td><label class="layui-form-label"> 类型:</label></td>
  15. <td>
  16. <input class="easyui-combobox" id="LX" style="width:300px;" disabled >
  17. </td>
  18. </tr>
  19. <tr>
  20. <td><label class="layui-form-label">上级分类</label></td>
  21. <td>
  22. <input id="parentid" name="parentid" class="easyui-combotree" data-options="width:300,panelWidth:'300px'" panelheight="200px">
  23. </td>
  24. </tr>
  25. <tr>
  26. <td><label class="layui-form-label">名称</label></td>
  27. <td><input class="easyui-textbox" id="name" name="name" required="required" data-options="prompt:'分类名称',width:300"></td>
  28. </tr>
  29. </table>
  30. <div data-options="region:'south',border:false" style="height:50px;text-align:right; padding:5px">
  31. <button type="button" class="layui-btn layui-btn-normal" id="save">确定</button>
  32. <button type="button" class="layui-btn layui-btn-primary" id="cancel">取消</button>
  33. </div>
  34. <input type="hidden" id="ID" name="ID" value="" />
  35. </div>
  36. <script type="text/javascript">
  37. var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
  38. var ThisUrl = decodeURI(window.location.href);
  39. var id = PublicFun.getQueryValue(ThisUrl, "id");
  40. var type = PublicFun.getQueryValue(ThisUrl, "type");//1新增2修改
  41. var name = PublicFun.getQueryValue(ThisUrl, "name");
  42. var lx = PublicFun.getQueryValue(ThisUrl, "lx");//类型
  43. $(function () {
  44. if (type == 2) {//修改
  45. $('#ID').val(id);
  46. $("#parentid").combotree("setValue", id);
  47. $("#name").textbox('setValue', name);
  48. }
  49. $("#parentid").combotree({
  50. lines: true,
  51. animate: true,
  52. method: "post",
  53. idField: 'id',
  54. treeField: 'text',
  55. url: '/MedicalRecordManager/GetCategory?类型=' + lx,
  56. loadFilter: function (data, parent) {
  57. //无数据则显示为叶子节点
  58. if (parent && data.length == 0) {
  59. var node = $(this).tree("getSelected");
  60. if (node) {
  61. $(this).tree("update", {
  62. target: node.target,
  63. state: "open",
  64. iconCls: "icon-file"
  65. });
  66. }
  67. }
  68. if (data) {
  69. return eval(data);
  70. }
  71. },
  72. onLoadSuccess: function (node, data) {
  73. var tree = $("#parentid").combotree("tree");
  74. var node = tree.tree('getRoot');
  75. if (node.text != "无") {
  76. $(this).tree("insert", {
  77. before: node.target,
  78. data: [{
  79. id: '0',
  80. text: '无',
  81. state: "open",
  82. iconCls: "icon-file"
  83. }]
  84. });
  85. }
  86. $(this).tree("select", node.id);
  87. },
  88. onSelect: function (node) {
  89. if (node) {
  90. var t = $("#parentid").combotree('tree').tree("getSelected");
  91. $("#parentid").combotree("setValue", t.id);
  92. }
  93. }
  94. });
  95. /* $('#parentid').combotree('setValue', { id: id});*/
  96. $('#save').click(function () {
  97. var parentid = $("#parentid").val();
  98. var name = $("#name").val();
  99. var params = { 上级ID: parentid, 名称: name, 类型: $('#LX').combobox('getValue'), type: type };
  100. if (type == 2) //修改
  101. {
  102. params = { 上级ID: parentid, 名称: name, 类型: $('#LX').combobox('getValue'), type: type, ID: id };
  103. }
  104. if (params.名称 == "") {
  105. top.ZLPMS.Msg("名称不能为空");
  106. return
  107. }
  108. $.post("/MedicalRecordManager/AddUpdateCategory", params, function (data) {
  109. if (data.code == 200) {
  110. top.ZLPMS.Msg(data.msg);
  111. ZLPMS.CloseTopWindow(true, index);
  112. }
  113. else {
  114. top.ZLPMS.Msg("添加失败,请联系管理员");
  115. }
  116. })
  117. });
  118. $('#cancel').click(function () {
  119. top.ZLPMS.CloseWindow(index);
  120. });
  121. $("#LX").combobox({
  122. data: [{ ID: "1", MC: "个人" }, { ID: "2", MC: "渠道" }, { ID: "3", MC: "总部" }],
  123. valueField: "ID",
  124. textField: "MC",
  125. onSelect: function (data) {
  126. },
  127. onLoadSuccess: function () {
  128. $('#LX').combobox('setValue', lx);
  129. }
  130. });
  131. })
  132. </script>