brokerlist.html 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <div class="layui-fluid">
  2. <div class="layui-card">
  3. <div class="layui-form layui-form-pane layui-card-header layuiadmin-card-header-auto" lay-filter="LAY-broker-brokerlist-search">
  4. <div class="layui-form-item">
  5. <div class="layui-inline">
  6. <label class="layui-form-label">名称</label>
  7. <div class="layui-input-block">
  8. <input type="text" name="keywords" placeholder="请输入" autocomplete="off" class="layui-input">
  9. </div>
  10. </div>
  11. <div class="layui-inline">
  12. <label class="layui-form-label">劳务公司</label>
  13. <div class="layui-input-block">
  14. <select name="workerid" lay-search>
  15. <option value="">全部公司(可搜索)</option>
  16. {volist name="workerlist" id="vo"}
  17. <option value="{$vo['id']}">{$vo['title']}</option>
  18. {/volist}
  19. </select>
  20. </div>
  21. </div>
  22. <div class="layui-inline">
  23. <label class="layui-form-label">状态</label>
  24. <div class="layui-input-block">
  25. <select name="status">
  26. <option value="">全部状态</option>
  27. <option value="1">正常</option>
  28. <option value="2">禁用</option>
  29. </select>
  30. </div>
  31. </div>
  32. <div class="layui-inline">
  33. <button class="layui-btn" lay-submit lay-filter="LAY-broker-brokerlist-btn">
  34. <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
  35. </button>
  36. </div>
  37. </div>
  38. </div>
  39. <div class="layui-card-body">
  40. <div style="padding-bottom: 10px;">
  41. <button class="layui-btn layuiadmin-btn" data-type="batchdel">删除</button>
  42. <button class="layui-btn layuiadmin-btn" data-type="add">添加</button>
  43. <button class="layui-btn layuiadmin-btn" data-type="default">默认经纪人</button>
  44. </div>
  45. <table id="LAY-broker-brokerlist-table" lay-filter="LAY-broker-brokerlist-table"></table>
  46. <script type="text/html" id="address">
  47. {{d.town}} - {{d.village}}
  48. </script>
  49. <script type="text/html" id="muserTpl">
  50. {{# if(d.userid != 0){ }}
  51. {{d.muser.realname}} - {{d.muser.mobile}}
  52. {{# } }}
  53. </script>
  54. <script type="text/html" id="workertitleTpl">
  55. {{d.worker.title}}
  56. </script>
  57. <script type="text/html" id="agenttitleTpl">
  58. {{d.agent.title}}
  59. </script>
  60. <script type="text/html" id="usercountTpl">
  61. {{d.user_count}}
  62. </script>
  63. <script type="text/html" id="setTpl">
  64. <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
  65. <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>
  66. </script>
  67. </div>
  68. </div>
  69. </div>
  70. <script>
  71. layui.config({
  72. base: '/static/echoui/' //静态资源所在路径
  73. }).extend({
  74. index: 'lib/index' //主入口模块
  75. }).use(['index', 'form', 'set', 'table'], function() {
  76. var $ = layui.$,
  77. setter = layui.setter,
  78. admin = layui.admin,
  79. form = layui.form,
  80. table = layui.table;
  81. form.render();
  82. table.render({
  83. elem: '#LAY-broker-brokerlist-table',
  84. url: setter.baseAdminUrl + 'broker/listbroker',
  85. cols: [
  86. [
  87. { type: 'checkbox', fixed: 'left' },
  88. { field: 'id', width: 80, title: '表ID', sort: true },
  89. { field: 'title', title: '姓名', edit: 'text' },
  90. { field: 'mobile', title: '手机号' },
  91. { field: 'muser', title: '关联的用户(姓名-手机号)', templet: '#muserTpl', minWidth: 250, align: 'left' },
  92. { field: 'type_text', title: '类型', width: 100, align: 'center' },
  93. { field: 'address', title: '镇街', templet: '#address' },
  94. { field: 'region', title: '区域' },
  95. { field: 'workertitle', title: '劳务公司', templet: '#workertitleTpl' },
  96. { field: 'agenttitle', title: '代理门店', templet: '#agenttitleTpl' },
  97. { field: 'usercount', title: '用户邀请数', templet: '#usercountTpl', width: 100, align: 'center' },
  98. { field: 'status_text', title: '状态', width: 100, align: 'center' },
  99. { field: 'powerreport_text', title: '报备权限', width: 100, align: 'center' },
  100. { field: 'createtime', title: '创建时间', width: 170 },
  101. { title: '操作', width: 150, align: 'center', fixed: 'right', toolbar: '#setTpl' }
  102. ]
  103. ],
  104. page: true,
  105. limit: 50,
  106. cellMinWidth: 150,
  107. text: '对不起,加载出现异常!'
  108. });
  109. form.on('submit(LAY-broker-brokerlist-btn)', function(data) {
  110. table.reload('LAY-broker-brokerlist-table', {
  111. where: data.field,
  112. page: {
  113. curr: 1
  114. }
  115. });
  116. });
  117. table.on('edit(LAY-broker-brokerlist-table)', function(obj) {
  118. var id = obj.data.id,
  119. field = obj.field,
  120. value = obj.value;
  121. admin.req({
  122. url: setter.baseAdminUrl + 'broker/fieldbroker',
  123. data: { id: id, field: field, value: value },
  124. done: function(res) {
  125. layer.msg('修改成功');
  126. layui.table.reload('LAY-broker-brokerlist-table');
  127. }
  128. });
  129. });
  130. var active = {
  131. batchdel: function() {
  132. var checkStatus = table.checkStatus('LAY-broker-brokerlist-table'),
  133. checkData = checkStatus.data; //得到选中的数据
  134. if (checkData.length === 0) {
  135. return layer.msg('请选择数据');
  136. }
  137. var idarr = [];
  138. for (var i = 0; i < checkData.length; i++) {
  139. idarr.push(checkData[i].id);
  140. }
  141. layer.prompt({
  142. formType: 1,
  143. title: '敏感操作,请验证密码'
  144. }, function(value, index) {
  145. layer.close(index);
  146. layer.confirm('确定删除此经纪人吗?', function(index) {
  147. admin.req({
  148. url: setter.baseAdminUrl + 'broker/delbroker',
  149. data: {
  150. password: value,
  151. idarr: idarr
  152. },
  153. done: function(res) {
  154. table.reload('LAY-broker-brokerlist-table');
  155. layer.msg('已删除');
  156. }
  157. });
  158. layer.close(index);
  159. });
  160. });
  161. },
  162. add: function() {
  163. var index = layer.open({
  164. type: 2,
  165. title: '添加经纪人',
  166. content: 'brokerform.html?id=0',
  167. maxmin: true,
  168. area: ['750px', '480px']
  169. });
  170. layer.full(index);
  171. },
  172. default: function () {
  173. var index = layer.open({
  174. type: 2,
  175. title: '默认经纪人',
  176. content: 'brokerdefault.html',
  177. maxmin: true,
  178. area: ['750px', '480px']
  179. });
  180. layer.full(index);
  181. }
  182. };
  183. table.on('tool(LAY-broker-brokerlist-table)', function(obj) {
  184. var data = obj.data;
  185. if (obj.event === 'del') {
  186. layer.prompt({
  187. formType: 1,
  188. title: '敏感操作,请验证密码'
  189. }, function(value, index) {
  190. layer.close(index);
  191. layer.confirm('确定删除此经纪人吗?', function(index) {
  192. admin.req({
  193. url: setter.baseAdminUrl + 'broker/delbroker',
  194. data: {
  195. password: value,
  196. idarr: [data.id]
  197. },
  198. done: function(res) {
  199. obj.del();
  200. layer.msg('已删除');
  201. }
  202. });
  203. layer.close(index);
  204. });
  205. });
  206. } else if (obj.event === 'edit') {
  207. var index = layer.open({
  208. type: 2,
  209. title: '编辑经纪人',
  210. content: 'brokerform.html?id=' + data.id,
  211. maxmin: true,
  212. area: ['750px', '480px']
  213. });
  214. layer.full(index);
  215. }
  216. });
  217. $('.layui-btn.layuiadmin-btn').on('click', function() {
  218. var type = $(this).data('type');
  219. active[type] ? active[type].call(this) : '';
  220. });
  221. });
  222. </script>