Form.cshtml 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  1. @{
  2. ViewBag.Title = "Form";
  3. Layout = "~/Views/Shared/_Form.cshtml";
  4. }
  5. <!--jqgrid表格组件start-->
  6. <link href="~/Content/scripts/plugins/jqgrid/jqgrid.css" rel="stylesheet" />
  7. <script src="~/Content/scripts/plugins/jqgrid/grid.locale-cn.js"></script>
  8. <script src="~/Content/scripts/plugins/jqgrid/jqgrid.min.js"></script>
  9. <!--表格组件end-->
  10. <script type="text/javascript">
  11. var keyValue = request('keyValue');
  12. var parentId = request('parentId');
  13. $(function () {
  14. initialPage();
  15. buttonOperation();
  16. getGridButton();
  17. getGridView();
  18. })
  19. //初始化页面
  20. function initialPage() {
  21. //加载导向
  22. $('#wizard').wizard().on('change', function (e, data) {
  23. var $finish = $("#btn_finish");
  24. var $next = $("#btn_next");
  25. if (data.direction == "next") {
  26. if (data.step == 2) {
  27. $finish.removeAttr('disabled');
  28. $next.attr('disabled', 'disabled');
  29. } else {
  30. $finish.attr('disabled', 'disabled');
  31. }
  32. } else {
  33. $finish.attr('disabled', 'disabled');
  34. $next.removeAttr('disabled');
  35. }
  36. });
  37. initControl();
  38. }
  39. //初始化控件
  40. function initControl() {
  41. //目标
  42. $("#Target").ComboBox({
  43. description: "==请选择==",
  44. height: "200px"
  45. });
  46. //上级
  47. $("#ParentId").ComboBoxTree({
  48. url: "../../AuthorizeManage/Module/GetTreeJson",
  49. description: "==请选择==",
  50. height: "195px",
  51. allowSearch: true
  52. });
  53. //获取表单
  54. if (!!keyValue) {
  55. $.SetForm({
  56. url: "../../AuthorizeManage/Module/GetFormJson",
  57. param: { keyValue: keyValue },
  58. success: function (data) {
  59. $("#form1").SetWebControls(data);
  60. if (data.IsMenu == 1) {
  61. $("#btn_next").removeAttr('disabled');
  62. $("#btn_finish").attr('disabled', 'disabled');
  63. }
  64. }
  65. });
  66. } else {
  67. $("#ParentId").ComboBoxTreeSetValue(parentId);
  68. }
  69. }
  70. //选取图标
  71. function SelectIcon() {
  72. dialogOpen({
  73. id: "SelectIcon",
  74. title: '选取图标',
  75. url: '/AuthorizeManage/Module/Icon?ControlId=Icon',
  76. width: "1000px",
  77. height: "600px",
  78. btn: false
  79. })
  80. }
  81. //保存表单
  82. function AcceptClick() {
  83. if (!$('#form1').Validform()) {
  84. return false;
  85. }
  86. var postData = $("#form1").GetWebControls(keyValue);
  87. if (postData["ParentId"] == "") {
  88. postData["ParentId"] = 0;
  89. }
  90. postData["moduleButtonListJson"] = JSON.stringify(buttonJson);
  91. postData["moduleColumnListJson"] = JSON.stringify(columnJson);
  92. $.SaveForm({
  93. url: "../../AuthorizeManage/Module/SaveForm?keyValue=" + keyValue,
  94. param: postData,
  95. loading: "正在保存数据...",
  96. success: function () {
  97. $.currentIframe().$("#gridTable").trigger("reloadGrid");
  98. }
  99. })
  100. }
  101. //按钮操作(上一步、下一步、完成、关闭)
  102. function buttonOperation() {
  103. var $last = $("#btn_last");
  104. var $next = $("#btn_next");
  105. var $finish = $("#btn_finish");
  106. //如果是菜单,开启 上一步、下一步
  107. $("#IsMenu").click(function () {
  108. if (!$(this).attr("checked")) {
  109. $(this).attr("checked", true)
  110. $next.removeAttr('disabled');
  111. $finish.attr('disabled', 'disabled');
  112. } else {
  113. $(this).attr("checked", false)
  114. $next.attr('disabled', 'disabled');
  115. $finish.removeAttr('disabled');
  116. }
  117. });
  118. //完成提交保存
  119. $finish.click(function () {
  120. AcceptClick();
  121. })
  122. }
  123. /*系统按钮being==================================*/
  124. var buttonJson = "";
  125. function getGridButton() {
  126. var moduleId = $("#ModuleId").val();
  127. $.ajax({
  128. url: "../../AuthorizeManage/ModuleButton/GetListJson?moduleId=" + escape(moduleId),
  129. type: "get",
  130. dataType: "json",
  131. success: function (data) {
  132. buttonJson = data;
  133. },
  134. });
  135. var $grid = $("#gridTable-button");
  136. $grid.jqGrid({
  137. unwritten: false,
  138. url: "../../AuthorizeManage/ModuleButton/GetTreeListJson?moduleId=" + escape(moduleId),
  139. datatype: "json",
  140. height: $(window).height() - 165,
  141. width: $(window).width() - 11,
  142. colModel: [
  143. { label: "主键", name: "ModuleButtonId", hidden: true },
  144. { label: "名称", name: "FullName", width: 140, align: "left", sortable: false },
  145. { label: "编号", name: "EnCode", width: 140, align: "left", sortable: false },
  146. { label: "地址", name: "ActionAddress", width: 500, align: "left", sortable: false },
  147. ],
  148. treeGrid: true,
  149. treeGridModel: "nested",
  150. ExpandColumn: "EnCode",
  151. rowNum: "all",
  152. rownumbers: true
  153. });
  154. //处理Json
  155. function ButtonListToListTreeJson(buttonJson) {
  156. $.ajax({
  157. url: "../../AuthorizeManage/ModuleButton/ListToListTreeJson",
  158. data: { moduleButtonJson: JSON.stringify(buttonJson) },
  159. type: "post",
  160. dataType: "json",
  161. success: function (data) {
  162. $grid.clearGridData();
  163. $grid[0].addJSONData(data);
  164. },
  165. });
  166. }
  167. //新增
  168. $("#lr-add-button").click(function () {
  169. var parentId = $("#gridTable-button").jqGridRowValue("ModuleButtonId");
  170. dialogOpen({
  171. id: "buttonForm",
  172. title: '添加按钮',
  173. url: '/AuthorizeManage/ModuleButton/Form?parentId=' + parentId + "&moduleId=" + escape(moduleId),
  174. width: "450px",
  175. height: "300px",
  176. callBack: function (iframeId) {
  177. top.frames[iframeId].AcceptClick(function (data) {
  178. buttonJson.push(data);
  179. ButtonListToListTreeJson(buttonJson);
  180. });
  181. }
  182. });
  183. })
  184. //编辑
  185. $("#lr-edit-button").click(function () {
  186. var moduleButtonId = $("#gridTable-button").jqGridRowValue("ModuleButtonId");
  187. if (checkedRow(moduleButtonId)) {
  188. dialogOpen({
  189. id: "buttonForm",
  190. title: '编辑按钮',
  191. url: '/AuthorizeManage/ModuleButton/Form?moduleButtonId=' + moduleButtonId + "&moduleId=" + escape(moduleId),
  192. width: "450px",
  193. height: "300px",
  194. callBack: function (iframeId) {
  195. top.frames[iframeId].AcceptClick(function (data) {
  196. $.each(buttonJson, function (i) {
  197. if (buttonJson[i].ModuleButtonId == moduleButtonId) {
  198. buttonJson[i] = data;
  199. }
  200. });
  201. ButtonListToListTreeJson(buttonJson);
  202. });
  203. }
  204. });
  205. }
  206. })
  207. //删除
  208. $("#lr-delete-button").click(function () {
  209. var moduleButtonId = $("#gridTable-button").jqGridRowValue("ModuleButtonId");
  210. if (checkedRow(moduleButtonId)) {
  211. $.each(buttonJson, function (i) {
  212. if (buttonJson[i].ModuleButtonId == moduleButtonId) {
  213. buttonJson.splice(i, 1);
  214. ButtonListToListTreeJson(buttonJson);
  215. return false;
  216. }
  217. });
  218. }
  219. });
  220. //复制
  221. $("#lr-copy-button").click(function () {
  222. var moduleButtonId = $("#gridTable-button").jqGridRowValue("ModuleButtonId");
  223. if (checkedRow(moduleButtonId)) {
  224. dialogOpen({
  225. id: "OptionModule",
  226. title: '将按钮复制到指定功能里面',
  227. url: '/AuthorizeManage/ModuleButton/OptionModule?keyValue=' + moduleButtonId,
  228. width: "500px",
  229. height: "500px",
  230. callBack: function (iframeId) {
  231. top.frames[iframeId].AcceptClick();
  232. }
  233. });
  234. }
  235. });
  236. }
  237. /*系统按钮end====================================*/
  238. /*系统视图being==================================*/
  239. var columnJson = "";
  240. function getGridView() {
  241. var moduleId = $("#ModuleId").val();
  242. $.ajax({
  243. url: "../../AuthorizeManage/ModuleColumn/GetListJson?moduleId=" + escape(moduleId),
  244. type: "get",
  245. dataType: "json",
  246. success: function (data) {
  247. columnJson = data;
  248. },
  249. });
  250. var $grid = $("#gridTable-view");
  251. $grid.jqGrid({
  252. unwritten: false,
  253. url: "../../AuthorizeManage/ModuleColumn/GetTreeListJson?moduleId=" + escape(moduleId),
  254. datatype: "json",
  255. height: $(window).height() - 165,
  256. width: $(window).width() - 11,
  257. colModel: [
  258. { label: "主键", name: "ModuleColumnId", index: "ModuleColumnId", hidden: true },
  259. { label: "名称", name: "FullName", index: "FullName", width: 140, align: "left", sortable: false, },
  260. { label: "编号", name: "EnCode", index: "EnCode", width: 140, align: "left", sortable: false },
  261. { label: "描述", name: "Description", index: "Description", width: 500, align: "left", sortable: false }
  262. ],
  263. rowNum: 1000,
  264. rownumbers: true
  265. });
  266. //处理Json
  267. function ViewListToListTreeJson(columnJson) {
  268. $.ajax({
  269. url: "../../AuthorizeManage/ModuleColumn/ListToListTreeJson",
  270. data: { moduleColumnJson: JSON.stringify(columnJson) },
  271. type: "post",
  272. dataType: "json",
  273. success: function (data) {
  274. $grid.clearGridData();
  275. $grid[0].addJSONData(data);
  276. },
  277. });
  278. }
  279. //新增
  280. $("#lr-add-view").click(function () {
  281. dialogOpen({
  282. id: "viewForm",
  283. title: '添加视图',
  284. url: '/AuthorizeManage/ModuleColumn/Form?moduleId=' + escape(moduleId),
  285. width: "450px",
  286. height: "260px",
  287. callBack: function (iframeId) {
  288. top.frames[iframeId].AcceptClick(function (data) {
  289. columnJson.push(data);
  290. ViewListToListTreeJson(columnJson);
  291. });
  292. }
  293. });
  294. })
  295. //编辑
  296. $("#lr-edit-view").click(function () {
  297. var moduleColumnId = $("#gridTable-view").jqGridRowValue("ModuleColumnId");
  298. if (checkedRow(moduleColumnId)) {
  299. dialogOpen({
  300. id: "viewForm",
  301. title: '编辑视图',
  302. url: '/AuthorizeManage/ModuleColumn/Form?moduleColumnId=' + moduleColumnId + "&moduleId=" + escape(moduleId),
  303. width: "450px",
  304. height: "260px",
  305. callBack: function (iframeId) {
  306. top.frames[iframeId].AcceptClick(function (data) {
  307. $.each(columnJson, function (i) {
  308. if (columnJson[i].ModuleColumnId == moduleColumnId) {
  309. columnJson[i] = data;
  310. }
  311. });
  312. ViewListToListTreeJson(columnJson);
  313. });
  314. }
  315. });
  316. }
  317. })
  318. //删除
  319. $("#lr-delete-view").click(function () {
  320. var moduleColumnId = $("#gridTable-view").jqGridRowValue("ModuleColumnId");
  321. if (checkedRow(moduleColumnId)) {
  322. $.each(columnJson, function (i) {
  323. if (columnJson[i].ModuleColumnId == moduleColumnId) {
  324. columnJson.splice(i, 1);
  325. ViewListToListTreeJson(columnJson);
  326. return false;
  327. }
  328. });
  329. }
  330. });
  331. //批量添加
  332. $("#lr-batch-addview").click(function () {
  333. dialogOpen({
  334. id: "viewForm",
  335. title: '批量添加视图',
  336. url: '/AuthorizeManage/ModuleColumn/BatchAdd?moduleId=' + escape(moduleId),
  337. width: "450px",
  338. height: "300px",
  339. callBack: function (iframeId) {
  340. top.frames[iframeId].AcceptClick(function (data) {
  341. columnJson = data;
  342. ViewListToListTreeJson(data);
  343. });
  344. }
  345. });
  346. })
  347. }
  348. /*系统视图end====================================*/
  349. </script>
  350. <div class="widget-body">
  351. <div id="wizard" class="wizard" data-target="#wizard-steps" style="border-left: none; border-top: none; border-right: none;">
  352. <ul class="steps">
  353. <li data-target="#step-1" class="active"><span class="step">1</span>系统功能<span class="chevron"></span></li>
  354. <li data-target="#step-2"><span class="step">2</span>系统按钮<span class="chevron"></span></li>
  355. <li data-target="#step-3"><span class="step">3</span>系统视图<span class="chevron"></span></li>
  356. </ul>
  357. </div>
  358. <div class="step-content" id="wizard-steps" style="border-left: none; border-bottom: none; border-right: none;">
  359. <div class="step-pane active" id="step-1" style="margin-left: 0px; margin-top: 15px; margin-right: 30px;">
  360. <input id="ModuleId" type="hidden" value="@ViewBag.ModuleId" />
  361. <table class="form">
  362. <tr>
  363. <th class="formTitle">编号<font face="宋体">*</font></th>
  364. <td class="formValue">
  365. <input id="EnCode" type="text" class="form-control" placeholder="请输入编号" isvalid="yes" checkexpession="NotNull" />
  366. </td>
  367. <th class="formTitle">名称<font face="宋体">*</font></th>
  368. <td class="formValue">
  369. <input id="FullName" type="text" class="form-control" placeholder="请输入名称" isvalid="yes" checkexpession="NotNull" />
  370. </td>
  371. </tr>
  372. <tr>
  373. <th class="formTitle">上级</th>
  374. <td class="formValue">
  375. <div id="ParentId" type="selectTree" class="ui-select">
  376. </div>
  377. </td>
  378. <th class="formTitle">图标</th>
  379. <td class="formValue">
  380. <input id="Icon" type="text" class="form-control" />
  381. <span class="input-button" onclick="SelectIcon()" title="选取图标">...</span>
  382. </td>
  383. </tr>
  384. <tr>
  385. <th class="formTitle">目标<font face="宋体">*</font></th>
  386. <td class="formValue">
  387. <div id="Target" type="select" class="ui-select" isvalid="yes" checkexpession="NotNull">
  388. <ul>
  389. <li data-value="expand">expand</li>
  390. <li data-value="iframe">iframe</li>
  391. <li data-value="open">open</li>
  392. <li data-value="href">href</li>
  393. <li data-value="blank">blank</li>
  394. </ul>
  395. </div>
  396. </td>
  397. <th class="formTitle">排序<font face="宋体">*</font></th>
  398. <td class="formValue">
  399. <input id="SortCode" type="text" class="form-control" isvalid="yes" checkexpession="Num" />
  400. </td>
  401. </tr>
  402. <tr>
  403. <th class="formTitle">地址</th>
  404. <td class="formValue" colspan="3">
  405. <input id="UrlAddress" type="text" class="form-control" />
  406. </td>
  407. </tr>
  408. <tr>
  409. <th class="formTitle" style="height: 37px;">选项</th>
  410. <td class="formValue">
  411. <div class="checkbox user-select">
  412. <label>
  413. <input id="IsMenu" type="checkbox" />
  414. 菜单
  415. </label>
  416. <label>
  417. <input id="IsPublic" type="checkbox" />
  418. 公共
  419. </label>
  420. <label>
  421. <input id="AllowExpand" type="checkbox" />
  422. 展开
  423. </label>
  424. <label>
  425. <input id="EnabledMark" type="checkbox" checked="checked" />
  426. 有效
  427. </label>
  428. <label>
  429. <input id="IsClient" type="checkbox" />
  430. 客户端
  431. </label>
  432. </div>
  433. </td>
  434. </tr>
  435. <tr>
  436. <th class="formTitle" valign="top" style="padding-top: 4px;">描述
  437. </th>
  438. <td class="formValue" colspan="3">
  439. <textarea id="Description" class="form-control" style="height: 70px;"></textarea>
  440. </td>
  441. </tr>
  442. </table>
  443. </div>
  444. <div class="step-pane" id="step-2" style="margin: 5px;">
  445. <div style="height: 40px; line-height: 33px; text-align: right;">
  446. <div class="btn-group">
  447. <a id="lr-add-button" class="btn btn-default"><i class="fa fa-plus"></i>&nbsp;新增</a>
  448. <a id="lr-edit-button" class="btn btn-default"><i class="fa fa-pencil-square-o"></i>&nbsp;编辑</a>
  449. <a id="lr-delete-button" class="btn btn-default"><i class="fa fa-trash-o"></i>&nbsp;删除</a>
  450. </div>
  451. <div class="btn-group">
  452. <a id="lr-copy-button" class="btn btn-default"><i class="fa fa-copy"></i>&nbsp;复制</a>
  453. </div>
  454. </div>
  455. <table id="gridTable-button"></table>
  456. </div>
  457. <div class="step-pane" id="step-3" style="margin: 5px;">
  458. <div style="height: 40px; line-height: 33px; text-align: right;">
  459. <div class="btn-group">
  460. <a id="lr-add-view" class="btn btn-default"><i class="fa fa-plus"></i>&nbsp;新增</a>
  461. <a id="lr-edit-view" class="btn btn-default"><i class="fa fa-pencil-square-o"></i>&nbsp;编辑</a>
  462. <a id="lr-delete-view" class="btn btn-default"><i class="fa fa-trash-o"></i>&nbsp;删除</a>
  463. </div>
  464. <div class="btn-group">
  465. <a id="lr-batch-addview" class="btn btn-default"><i class="fa fa-sign-in"></i>&nbsp;批量添加</a>
  466. </div>
  467. </div>
  468. <table id="gridTable-view"></table>
  469. </div>
  470. </div>
  471. </div>
  472. <div class="form-button" id="wizard-actions">
  473. <a id="btn_last" disabled class="btn btn-default btn-prev">上一步</a>
  474. <a id="btn_next" disabled class="btn btn-default btn-next">下一步</a>
  475. <a id="btn_finish" class="btn btn-success">完成</a>
  476. </div>