itemsets.tpl 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7. <title>项目空间管理 - Powered by MinDoc</title>
  8. <!-- Bootstrap -->
  9. <link href="{{cdncss "/static/bootstrap/css/bootstrap.min.css"}}" rel="stylesheet" type="text/css">
  10. <link href="{{cdncss "/static/font-awesome/css/font-awesome.min.css"}}" rel="stylesheet" type="text/css">
  11. <link href="{{cdncss "/static/css/main.css" "version"}}" rel="stylesheet">
  12. </head>
  13. <body>
  14. <div class="manual-reader">
  15. {{template "widgets/header.tpl" .}}
  16. <div class="container manual-body">
  17. <div class="row">
  18. {{template "manager/widgets.tpl" "itemsets"}}
  19. <div class="page-right">
  20. <div class="m-box">
  21. <div class="box-head">
  22. <strong class="box-title">项目空间管理</strong>
  23. {{if eq .Member.Role 0}}
  24. <button type="button" class="btn btn-success btn-sm pull-right" data-toggle="modal" data-target="#addItemsetsDialogModal"><i class="fa fa-plus" aria-hidden="true"></i> 创建项目空间</button>
  25. {{end}}
  26. </div>
  27. </div>
  28. <div class="box-body">
  29. <div class="attach-list" id="ItemsetsList">
  30. <table class="table">
  31. <thead>
  32. <tr>
  33. <th width="10%">#</th>
  34. <th width="30%">项目空间名称</th>
  35. <th width="20%">项目空间标识</th>
  36. <th width="20%">项目数量</th>
  37. <th>操作</th>
  38. </tr>
  39. </thead>
  40. <tbody>
  41. {{range $index,$item := .Lists}}
  42. <tr>
  43. <td>{{$item.ItemId}}</td>
  44. <td>{{$item.ItemName}}</td>
  45. <td>{{$item.ItemKey}}</td>
  46. <td>{{$item.BookNumber}}</td>
  47. <td>
  48. <button type="button" class="btn btn-sm btn-default" data-id="{{$item.ItemId}}" data-method="edit" data-name="{{$item.ItemName}}" data-key="{{$item.ItemKey}}">编辑</button>
  49. {{if ne $item.ItemId 1}}
  50. <button type="button" data-method="delete" class="btn btn-danger btn-sm" data-id="{{$item.ItemId}}" data-loading-text="删除中...">删除</button>
  51. {{end}}
  52. <a href="{{urlfor "ItemsetsController.List" ":key" $item.ItemKey}}" class="btn btn-success btn-sm" target="_blank">详情</a>
  53. </td>
  54. </tr>
  55. {{else}}
  56. <tr><td class="text-center" colspan="6">暂无数据</td></tr>
  57. {{end}}
  58. </tbody>
  59. </table>
  60. <nav class="pagination-container">
  61. {{.PageHtml}}
  62. </nav>
  63. </div>
  64. </div>
  65. </div>
  66. </div>
  67. </div>
  68. {{template "widgets/footer.tpl" .}}
  69. </div>
  70. <!-- Modal -->
  71. <div class="modal fade" id="addItemsetsDialogModal" tabindex="-1" role="dialog" aria-labelledby="addItemsetsDialogModalLabel">
  72. <div class="modal-dialog">
  73. <form method="post" autocomplete="off" class="form-horizontal" action="{{urlfor "ManagerController.ItemsetsEdit"}}" id="addItemsetsDialogForm">
  74. <div class="modal-content">
  75. <div class="modal-header">
  76. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  77. <h4 class="modal-title" id="myModalLabel">创建项目空间</h4>
  78. </div>
  79. <div class="modal-body">
  80. <div class="form-group">
  81. <label class="col-sm-3 control-label" for="account">项目空间名称<span class="error-message">*</span></label>
  82. <div class="col-sm-9">
  83. <input type="text" name="itemName" class="form-control" placeholder="项目空间名称" id="itemName" maxlength="50">
  84. </div>
  85. </div>
  86. <div class="form-group">
  87. <label class="col-sm-3 control-label" for="itemKey">项目空间标识<span class="error-message">*</span></label>
  88. <div class="col-sm-9">
  89. <input type="text" name="itemKey" id="itemKey" class="form-control" placeholder="项目空间标识" maxlength="50">
  90. <p class="text">项目空间标识只能由字母和数字组成且在2-100字符之间</p>
  91. </div>
  92. </div>
  93. <div class="clearfix"></div>
  94. </div>
  95. <div class="modal-footer">
  96. <span id="create-form-error-message"></span>
  97. <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
  98. <button type="submit" class="btn btn-success" data-loading-text="保存中..." id="btnAddItemsets">保存
  99. </button>
  100. </div>
  101. </div>
  102. </form>
  103. </div>
  104. </div><!--END Modal-->
  105. <div class="modal fade" id="editItemsetsDialogModal" tabindex="-1" role="dialog" aria-labelledby="editItemsetsDialogModalLabel">
  106. <div class="modal-dialog" role="document">
  107. <form method="post" autocomplete="off" class="form-horizontal" action="{{urlfor "ManagerController.ItemsetsEdit"}}" id="editItemsetsDialogForm">
  108. <input type="hidden" name="itemId" value="">
  109. <div class="modal-content">
  110. <div class="modal-header">
  111. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  112. <h4 class="modal-title" id="myModalLabel">编辑项目空间</h4>
  113. </div>
  114. <div class="modal-body">
  115. <div class="form-group">
  116. <label class="col-sm-3 control-label" for="itemName">项目空间名称<span class="error-message">*</span></label>
  117. <div class="col-sm-9">
  118. <input type="text" name="itemName" id="itemName" class="form-control" placeholder="项目空间名称" maxlength="50">
  119. </div>
  120. </div>
  121. <div class="form-group">
  122. <label class="col-sm-3 control-label" for="itemKey">项目空间标识<span class="error-message">*</span></label>
  123. <div class="col-sm-9">
  124. <input type="text" name="itemKey" id="itemKey" class="form-control" placeholder="项目空间标识" maxlength="50">
  125. </div>
  126. </div>
  127. <div class="clearfix"></div>
  128. </div>
  129. <div class="modal-footer">
  130. <span id="edit-form-error-message"></span>
  131. <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
  132. <button type="submit" class="btn btn-success" data-loading-text="保存中..." id="btnEditItemsets">保存
  133. </button>
  134. </div>
  135. </div>
  136. </form>
  137. </div>
  138. </div><!--END Modal-->
  139. <script src="{{cdnjs "/static/jquery/1.12.4/jquery.min.js"}}"></script>
  140. <script src="{{cdnjs "/static/bootstrap/js/bootstrap.min.js"}}"></script>
  141. <script src="{{cdnjs "/static/js/jquery.form.js"}}" type="text/javascript"></script>
  142. <script src="{{cdnjs "/static/layer/layer.js" }}" type="text/javascript"></script>
  143. <script src="{{cdnjs "/static/js/main.js"}}" type="text/javascript"></script>
  144. <script type="text/javascript">
  145. $(function () {
  146. var editItemsetsDialogModal = $("#editItemsetsDialogModal");
  147. var addItemsetsDialogForm = $("#addItemsetsDialogForm");
  148. var editItemsetsDialogForm = $("#editItemsetsDialogForm");
  149. editItemsetsDialogModal.on("shown.bs.modal",function () {
  150. editItemsetsDialogModal.find("input[name='itemName']").focus();
  151. });
  152. $("#addItemsetsDialogModal").on("show.bs.modal", function () {
  153. window.addItemsetsDialogModalHtml = $(this).find("form").html();
  154. }).on("hidden.bs.modal", function () {
  155. $(this).find("form").html(window.addItemsetsDialogModalHtml);
  156. });
  157. addItemsetsDialogForm.ajaxForm({
  158. beforeSubmit: function () {
  159. var $itemName = addItemsetsDialogForm.find("input[name='itemName']").val();
  160. var $itemKey = addItemsetsDialogForm.find("input[name='itemKey']").val();
  161. if ($itemName == "") {
  162. showError("项目空间名称不能为空","#create-form-error-message");
  163. }
  164. if ($itemKey == "") {
  165. showError("项目空间标识不能为空","#create-form-error-message");
  166. }
  167. $("#btnAddItemsets").button("loading");
  168. showError("","#create-form-error-message");
  169. return true;
  170. },
  171. success: function ($res) {
  172. if ($res.errcode === 0) {
  173. window.location = window.document.location;
  174. } else {
  175. showError($res.message,"#create-form-error-message");
  176. }
  177. },
  178. error: function () {
  179. showError("服务器异常","#create-form-error-message");
  180. },
  181. complete: function () {
  182. $("#btnAddItemsets").button("reset");
  183. }
  184. });
  185. editItemsetsDialogForm.ajaxForm({
  186. beforeSubmit: function () {
  187. var $itemName = editItemsetsDialogForm.find("input[name='itemName']").val();
  188. var $itemKey = editItemsetsDialogForm.find("input[name='itemKey']").val();
  189. if ($itemName == "") {
  190. showError("项目空间名称不能为空","#edit-form-error-message");
  191. }
  192. if ($itemKey == "") {
  193. showError("项目空间标识不能为空","#edit-form-error-message");
  194. }
  195. $("#btnEditItemsets").button("loading");
  196. showError("","#edit-form-error-message");
  197. return true;
  198. } ,
  199. success : function ($res) {
  200. if ($res.errcode === 0) {
  201. window.location = window.document.location;
  202. } else {
  203. showError($res.message,"#edit-form-error-message");
  204. }
  205. },
  206. error: function () {
  207. showError("服务器异常","#edit-form-error-message");
  208. },
  209. complete: function () {
  210. $("#btnEditItemsets").button("reset");
  211. }
  212. });
  213. $("#ItemsetsList").on("click","button[data-method='delete']",function () {
  214. var id = $(this).attr("data-id");
  215. var $this = $(this);
  216. $(this).button("loading");
  217. $.ajax({
  218. url : "{{urlfor "ManagerController.ItemsetsDelete" ":id" ""}}" + id,
  219. type : "post",
  220. dataType : "json",
  221. success : function (res) {
  222. if(res.errcode === 0){
  223. $this.closest("tr").remove().empty();
  224. }else {
  225. layer.msg(res.message);
  226. }
  227. },
  228. error : function () {
  229. layer.msg("服务器异常");
  230. },
  231. complete : function () {
  232. $this.button("reset");
  233. }
  234. });
  235. }).on("click","button[data-method='edit']",function () {
  236. var $itemId = $(this).attr("data-id");
  237. var $itemName = $(this).attr("data-name");
  238. var $itemKey = $(this).attr("data-key");
  239. editItemsetsDialogModal.find("input[name='itemId']").val($itemId);
  240. editItemsetsDialogModal.find("input[name='itemName']").val($itemName);
  241. editItemsetsDialogModal.find("input[name='itemKey']").val($itemKey);
  242. editItemsetsDialogModal.modal("show");
  243. });
  244. });
  245. </script>
  246. </body>
  247. </html>