add.html 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <!DOCTYPE html>
  2. <html lang="zh" xmlns:th="http://www.thymeleaf.org" >
  3. <head>
  4. <th:block th:include="include :: header('新增开通申请')" />
  5. <th:block th:include="include :: select2-css" />
  6. </head>
  7. <body class="white-bg">
  8. <div class="wrapper wrapper-content animated fadeInRight ibox-content">
  9. <form class="form-horizontal m" id="form-apply-add">
  10. <div class="form-group">
  11. <label class="col-sm-3 control-label is-required">申请人:</label>
  12. <div class="col-sm-8">
  13. <select id="userId" name="userId" class="form-control" required onchange="getLoginName();">
  14. <option value="">请选择</option>
  15. <option th:each="user:${userList}" th:text="${user.userName}" th:value="${user.userId}"></option>
  16. </select>
  17. </div>
  18. </div>
  19. <div class="form-group">
  20. <label class="col-sm-3 control-label is-required">本系统登录名:</label>
  21. <div class="col-sm-8">
  22. <input id="loginName" name="loginName" class="form-control" type="text" required readonly>
  23. </div>
  24. </div>
  25. <div class="form-group">
  26. <label class="col-sm-3 control-label">申请类型:</label>
  27. <div class="col-sm-8">
  28. <select name="applyType" class="form-control m-b" th:with="type=${@dict.getType('sys_apply_type')}">
  29. <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
  30. </select>
  31. </div>
  32. </div>
  33. <h4 class="form-header h4">子系统</h4>
  34. <div class="row">
  35. <input type="hidden" id="childDatas" name="childDatas">
  36. <div class="col-sm-12">
  37. <button type="button" class="btn btn-white btn-sm" onclick="addRow()"><i class="fa fa-plus"> 增加</i></button>
  38. <div class="col-sm-12 select-table table-striped">
  39. <table id="table1" class="table table-bordered table-hover"></table>
  40. </div>
  41. </div>
  42. </div>
  43. </form>
  44. </div>
  45. <th:block th:include="include :: footer" />
  46. <link th:href="@{/ajax/libs/table-edit/bootstrap-table.css}" rel="stylesheet"/>
  47. <link th:href="@{/ajax/libs/table-edit/bootstrap-table.min.css}" rel="stylesheet"/>
  48. <script th:src="@{/ajax/libs/table-edit/bootstrap-table.js}"></script>
  49. <script th:src="@{/ajax/libs/table-edit/bootstrap-table.min.js}"></script>
  50. <script th:src="@{/ajax/libs/table-edit/bootstrap-table-zh-CN.js}"></script>
  51. <script th:src="@{/ajax/libs/table-edit/bootstrap-table-edit.js}"></script>
  52. <script th:src="@{/ajax/libs/table-edit/bootstrap-table-edit.min.js}"></script>
  53. <script th:src="@{/ajax/libs/table-edit/bootstrap-select.js}"></script>
  54. <th:block th:include="include :: select2-js" />
  55. <script th:inline="javascript">
  56. var prefix = ctx + "system/apply";
  57. var danganList =[[${danganList}]];
  58. $("#form-apply-add").validate({
  59. focusCleanup: true
  60. });
  61. function getLoginName(){
  62. var userId= $("#userId").val();
  63. $.ajax({
  64. url: ctx + "/system/user/getUserNameById",
  65. data: {userId:userId},
  66. type: "post",
  67. async: false,
  68. success: function(result) {
  69. $("#loginName").val(result.loginName);
  70. }
  71. })
  72. }
  73. $(function() {
  74. loadEditTable();
  75. });
  76. var bool = false;
  77. function loadEditTable(){
  78. $.modal.alertWarning("此功能暂未开放");
  79. $.modal.close();//关闭当前窗口
  80. return;
  81. $('#table1').bootstrapTable('destroy');
  82. $('#table1').bootstrapTable({
  83. method: 'post',
  84. url: ctx + "system/a/list",
  85. editable:true,//开启编辑模式
  86. clickToSelect: true,
  87. cache : false,
  88. columns: [
  89. {
  90. field: 'danganId',
  91. title: '子系统名称',
  92. align:"center",
  93. edit: {
  94. required: true, editable:false,type: 'select', data: danganList,
  95. valueField: 'danganId',
  96. textField: 'danganName',
  97. onSelect: function (val, rec) {
  98. var data = $("#table1").bootstrapTable('getData');
  99. bool = data.some(item=>item.danganId==val);
  100. }
  101. },
  102. },
  103. {
  104. field: 'loginName',
  105. title: '子系统登录名',
  106. align:"center",
  107. edit:{required:true ,type:'text'}
  108. },
  109. {
  110. title:"操作",
  111. align:"center",
  112. formatter : operateFormatter1,
  113. edit:false
  114. }
  115. ],
  116. onEditableHidden: function(field, row, $el, reason) { // 当编辑状态被隐藏时触发
  117. if(reason === 'save') {
  118. var $td = $el.closest('tr').children();
  119. $td.eq(-1).html((row.price*row.number).toFixed(2));
  120. $el.closest('tr').next().find('.editable').editable('show'); //编辑状态向下一行移动
  121. } else if(reason === 'nochange') {
  122. $el.closest('tr').next().find('.editable').editable('show');
  123. }
  124. },
  125. onEditableSave: function (field, row, oldValue, $el) {
  126. $table = $('#table1').bootstrapTable({});
  127. $table.bootstrapTable('updateRow', {index: row.rowId, row: row});
  128. }
  129. });
  130. }
  131. function operateFormatter1(value, row, index) {
  132. return [
  133. "<a class=\"remove\" href='javascript:removeRow("+index+")' title=\"删除改行\">",
  134. "<i class='glyphicon glyphicon-remove'></i>",
  135. "</a> "
  136. ].join('');
  137. }
  138. $('#table1').on( 'click', 'td:has(.editable)', function (e) {
  139. e.stopPropagation(); // 阻止事件的冒泡行为
  140. $(this).find('.editable').editable('show'); // 打开被点击单元格的编辑状态
  141. } );
  142. function addRow(){
  143. var rows = [];
  144. $('#table1').bootstrapTable('append',rows);
  145. }
  146. //删除指定行
  147. function removeRow(deleteIndex){
  148. $('#table1').bootstrapTable('removeRow', deleteIndex);
  149. }
  150. function submitHandler() {
  151. var tableData = $("#table1").bootstrapTable('getData');
  152. $("#childDatas").val(JSON.stringify(tableData));
  153. if ($.validate.form()) {
  154. if(tableData.length==0){
  155. $.modal.alertWarning("请选择子系统!");
  156. return;
  157. }
  158. for (var i = 0;i<tableData.length;i++){
  159. if(tableData[i].danganId == "" || tableData[i].danganId == null){
  160. $.modal.alertWarning("请选择子系统名称!");
  161. return;
  162. }
  163. if(tableData[i].loginName == "" || tableData[i].loginName == null){
  164. $.modal.alertWarning("请选择子系统登录名!");
  165. return;
  166. }
  167. }
  168. $.operate.save(prefix + "/add", $('#form-apply-add').serialize());
  169. }
  170. }
  171. </script>
  172. </body>
  173. </html>