user.ftl 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. <#assign title="用户管理">
  2. <#include "/admin/head.ftl">
  3. <section class="vbox">
  4. <section class="scrollable wrapper">
  5. <div class="panel panel-default">
  6. <div class="panel-body">
  7. <form id="theform" name="theform" onsubmit="return false;" style="padding-bottom: 15px;">
  8. <div id="toolbar">
  9. <button id="addUser" type="button" class="btn btn-success btn-s-xs">添加角色</button>
  10. <button id="addBind" type="button" class="btn btn-primary btn-s-xs">添加一级分销</button>
  11. </div>
  12. </form>
  13. <table id="thetable"></table>
  14. </div>
  15. </div>
  16. </section>
  17. </section>
  18. <!-- Modal -->
  19. <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  20. <div class="modal-dialog" role="document">
  21. <div class="modal-content">
  22. <div class="modal-header">
  23. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
  24. </button>
  25. <h4 class="modal-title" id="myModalLabel"></h4>
  26. </div>
  27. <div class="modal-body">
  28. <form class="form-horizontal">
  29. <div class="panel-body">
  30. <input type="hidden" name="userId"/>
  31. <input type="hidden" name="beActive"/>
  32. <div class="form-group">
  33. <label for="loginName" class="col-sm-2 control-label">登录名</label>
  34. <div class="col-sm-10">
  35. <input type="text" id="loginName" name="loginName" class="form-control"
  36. autocomplete="off"/>
  37. </div>
  38. </div>
  39. <div class="form-group">
  40. <label for="staffName" class="col-sm-2 control-label">姓名</label>
  41. <div class="col-sm-10">
  42. <input type="text" id="staffName" name="staffName" class="form-control"
  43. autocomplete="off"/>
  44. </div>
  45. </div>
  46. <div class="form-group">
  47. <label for="userType" class="col-sm-2 control-label">角色</label>
  48. <div class="col-sm-10">
  49. <select id="userType" name="userType" class="form-control">
  50. <option value="">请选择</option>
  51. <option value="1">一级分销</option>
  52. <option value="2">二级分销</option>
  53. <option value="C">收银员</option>
  54. <option value="A">管理员</option>
  55. </select>
  56. </div>
  57. </div>
  58. <div class="form-group">
  59. <label for="placeId" class="col-sm-2 control-label">场地</label>
  60. <div class="col-sm-10">
  61. <select id="placeId" name="placeId" class="form-control">
  62. <option value="">请选择</option>
  63. <option value="1">场地一</option>
  64. <option value="2">场地二</option>
  65. </select>
  66. </div>
  67. </div>
  68. </div>
  69. </form>
  70. </div>
  71. <div class="modal-footer">
  72. <button type="button" class="btn btn-primary" onclick="saveForm();">保存</button>
  73. <button type="button" class="btn btn-warning" onclick="saveForm();">重置密码</button>
  74. <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
  75. </div>
  76. </div>
  77. </div>
  78. </div>
  79. <!-- Modal -->
  80. <div class="modal fade" id="bindModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  81. <div class="modal-dialog" role="document">
  82. <div class="modal-content">
  83. <div class="modal-header">
  84. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
  85. </button>
  86. <h4 class="modal-title" id="myModalLabel"></h4>
  87. </div>
  88. <div class="modal-body">
  89. <form class="form-horizontal">
  90. <div class="panel-body">
  91. <input type="hidden" name="userId"/>
  92. <input type="hidden" name="loginName"/>
  93. <input type="hidden" name="beActive"/>
  94. <div class="form-group">
  95. <label for="placeId1" class="col-sm-2 control-label">场地</label>
  96. <div class="col-sm-10">
  97. <select id="placeId1" name="placeId1" class="form-control">
  98. <option value="">请选择</option>
  99. <option value="1">场地一</option>
  100. <option value="2">场地二</option>
  101. </select>
  102. </div>
  103. </div>
  104. </div>
  105. </form>
  106. </div>
  107. <div class="modal-footer">
  108. <button type="button" class="btn btn-primary" onclick="choosedPlace();">确定</button>
  109. <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
  110. </div>
  111. </div>
  112. </div>
  113. </div>
  114. <#include "/admin/foot.ftl">
  115. <script>
  116. $(function () {
  117. //获取场地 角色
  118. getPlaceAndRole();
  119. initTable();
  120. $('#addUser').click(function () {
  121. $('#myModal').find('h4').html('添加用户');
  122. $('#myModal').find('form').formClear();
  123. $('#myModal').modal('toggle');
  124. });
  125. $('#addBind').click(function () {
  126. userBind();
  127. });
  128. });
  129. function responseHandler(root) {
  130. return { "total": root.pagination.count, "rows": root.data };
  131. }
  132. function openIdDelete(userId) {
  133. // $.ajax({
  134. // url: '/admin/deleteOpenId.json',
  135. // data: { userId: userId },
  136. // type: 'post',
  137. // success: function (data) {
  138. // if (data.success) {
  139. // layer.msg("删除成功");
  140. // initTable();
  141. // $('#myModal').modal('toggle');
  142. //
  143. // } else {
  144. // layer.msg(data.msg);
  145. // }
  146. // },
  147. // error: function () {
  148. // layer.msg("网络异常");
  149. // }
  150. // });
  151. }
  152. function userBind() {
  153. $('#bindModal').find('h4').html('选择场地');
  154. $('#bindModal').find('form').formClear();
  155. $('#bindModal').modal('toggle');
  156. }
  157. function choosedPlace() {
  158. // var data = $('#bindModal').find('form').formGet();
  159. // top.layer.open({
  160. // type: 2,
  161. // title: '绑定二维码',
  162. // shadeClose: false,
  163. // resize: true,
  164. // anim: 0,
  165. // skin: 'layer-class',
  166. // area: ['264px', '308px'],
  167. // content: '/admin/user_bind_qr_png?placeId=' + data.placeId1
  168. // });
  169. }
  170. function saveForm() {
  171. var data = $('#myModal').find('form').formGet();
  172. if (!data.loginName) {
  173. layer.msg('登录名不能为空');
  174. return;
  175. }
  176. if (!data.userType) {
  177. layer.msg('请选择角色');
  178. return;
  179. }
  180. if (!data.placeId) {
  181. layer.msg('请选择场地');
  182. return;
  183. }
  184. if (!data.loginName) {
  185. data.loginName = data.phone;
  186. }
  187. var url;
  188. if ($('#myModal').find('h4').html() === '编辑用户') {
  189. url = '/admin/user_edit.json';
  190. } else {
  191. //添加
  192. url = '/admin/user_addnew.json';
  193. }
  194. // $.ajax({
  195. // url: url,
  196. // contentType: "application/json; charset=utf-8",
  197. // data: JSON.stringify(data),
  198. // type: 'post',
  199. // success: function (data) {
  200. // if (data.success) {
  201. // layer.msg("保存成功");
  202. // initTable();
  203. // $('#myModal').modal('toggle');
  204. //
  205. // } else {
  206. // layer.msg(data.msg);
  207. // }
  208. // },
  209. // error: function () {
  210. // layer.msg("网络异常");
  211. // }
  212. // });
  213. }
  214. function userEdit(row) {
  215. $('#myModal').find('form').formSet(row);
  216. $('#myModal').find('h4').html('编辑用户');
  217. $('#myModal').modal('toggle');
  218. }
  219. function userResetPwd(row) {
  220. }
  221. function userDisable(row) {
  222. var data = row;
  223. if (row.beActive === 'Y' || row.beActive === 'N') {
  224. if (row.beActive === 'Y') {
  225. data.beActive = 'N';
  226. } else if (row.beActive === 'N') {
  227. data.beActive = 'Y';
  228. }
  229. // $.ajax({
  230. // url: '/admin/user_edit.json',
  231. // contentType: "application/json; charset=utf-8",
  232. // data: JSON.stringify(data),
  233. // type: 'post',
  234. // success: function (data) {
  235. // if (data.success) {
  236. // if (row.beActive === 'Y') {
  237. // layer.msg('已启用当前角色');
  238. // } else if (row.beActive === 'N') {
  239. // layer.msg('已禁用当前角色');
  240. // }
  241. // initTable();
  242. //
  243. // } else {
  244. // layer.msg(data.msg);
  245. // }
  246. // },
  247. // error: function () {
  248. // layer.msg("网络异常");
  249. // }
  250. // });
  251. }
  252. }
  253. function initTable() {
  254. // $('#thetable').bootstrapTable('destroy').bootstrapTable({
  255. // url: '/admin/user.json',
  256. // method: 'get',
  257. // queryParams: function (params) {
  258. // $('#theform').serializeArray().forEach(function fn(v) {
  259. // params[v.name] = v.value;
  260. // });
  261. // return params;
  262. // },
  263. // responseHandler: responseHandler,
  264. // idField: 'user_id',
  265. // exportDataType: 'all',
  266. // exportTypes: ['txt', 'excel'],
  267. // dataShowExport: true,
  268. // search: false,
  269. // sortStable: false,
  270. // sidePagination: 'server',
  271. // pagination: true,
  272. // columns: [
  273. // {
  274. // field: 'userId',
  275. // title: '操作',
  276. // width: '50px',
  277. // formatter: function (v, row) {
  278. // row.sense_id = 'select';
  279. // var ts = [];
  280. // if (row.userType === 'A' || row.userType === 'C') {
  281. // ts.push('<button class="btn btn-sm btn-default" onclick=\'userEdit(' + JSON.stringify(row) + ')\'>编辑</button>');
  282. //
  283. // } else {
  284. // ts.push('<button class="btn btn-sm btn-dark" onclick="openIdDelete(\'' + row.userId + '\')">删除</button>');
  285. // }
  286. // return ts.join('\n');
  287. // }
  288. // }, {
  289. // field: 'loginName',
  290. // title: '登录名'
  291. // }, {
  292. // field: 'staffName',
  293. // title: '员工姓名'
  294. // }, {
  295. // field: 'phone',
  296. // title: '手机'
  297. // }, {
  298. // field: 'placeName',
  299. // title: '场地名称'
  300. // }, {
  301. // field: 'userType',
  302. // title: '角色',
  303. // formatter: function (v, row) {
  304. // if (v === 'A') {
  305. // return '管理员';
  306. // } else if (v === 'C') {
  307. // return '收银员';
  308. // } else if (v === '1') {
  309. // return '一级分销';
  310. // } else if (v === '2') {
  311. // return '二级分销';
  312. // }
  313. // return v;
  314. // }
  315. // }, {
  316. // field: 'beActive',
  317. // title: '状态',
  318. // formatter: function (v, row) {
  319. // var ts = [];
  320. // if (row.userType === 'A' || row.userType === 'C') {
  321. // if (row.beActive === 'Y') {
  322. // ts.push('<button class="btn btn-sm btn-default" onclick=\'userDisable(' + JSON.stringify(row) + ')\'>启用中</button>');
  323. // } else if (row.beActive === 'N') {
  324. // ts.push('<button class="btn btn-sm btn-dark" onclick=\'userDisable(' + JSON.stringify(row) + ')\'>已禁用</button>');
  325. // }
  326. // return ts.join('\n');
  327. // }
  328. // return '启用中';
  329. // }
  330. // }, {
  331. // field: 'loginCount',
  332. // title: '登录次数'
  333. // }
  334. // ]
  335. // });
  336. }
  337. function getPlaceAndRole() {
  338. // $.ajax({
  339. // url: '/admin/get_place_role.json',
  340. // contentType: "application/json; charset=utf-8",
  341. // type: 'get',
  342. // success: function (data) {
  343. // if (data.success) {
  344. //
  345. // $('#placeId').empty();
  346. // $('#placeId').append($('<option value="">请选择</option>'));
  347. //
  348. // data.data.place.forEach(function (p) {
  349. // $('#placeId').append($('<option value="' + p.placeId + '">' + p.placeName + '</option>'));
  350. // });
  351. //
  352. // $('#placeId1').empty();
  353. // $('#placeId1').append($('<option value="">请选择</option>'));
  354. //
  355. // data.data.place.forEach(function (p) {
  356. // $('#placeId1').append($('<option value="' + p.placeId + '">' + p.placeName + '</option>'));
  357. // });
  358. //
  359. // $('#userType').empty();
  360. // $('#userType').append($('<option value="">请选择</option>'));
  361. // data.data.role.forEach(function (p) {
  362. // $('#userType').append($('<option value="' + p.role + '">' + p.roleName + '</option>'));
  363. // });
  364. //
  365. // } else {
  366. // layer.msg(data.msg);
  367. // }
  368. // },
  369. // error: function () {
  370. // layer.msg("网络异常");
  371. // }
  372. // });
  373. }
  374. </script>