index.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. ;
  2. layui.config({
  3. base: "../../js/layuiPlugins/"
  4. }).use(['form', 'layer', 'jquery', 'table', 'laytpl'], function () {
  5. var form = layui.form,
  6. layer = layui.layer,
  7. $ = layui.jquery,
  8. table = layui.table;
  9. var funcName = "org";
  10. form.verify({
  11. namelength: [
  12. /^.{0,12}$/,
  13. "长度限制在0-12个字符噢"
  14. ]
  15. });
  16. //工具条处理
  17. function toolOperating(obj) {
  18. var data = obj.data;
  19. if (obj.event === 'del') {
  20. layer.confirm('真的删除吗?', function (index) {
  21. layer.close(index);
  22. var index1 = layer.msg('删除中,请稍候', {
  23. icon: 16,
  24. time: false,
  25. shade: 0.8
  26. });
  27. $.ajax({
  28. type: "get",
  29. url: 'delete_' + funcName + '?guid=' + obj.data.guid,
  30. success: function (res) {
  31. layer.close(index1);
  32. if (!(res.code - 0)) {
  33. obj.del();
  34. table.reload(funcName);
  35. }
  36. }
  37. });
  38. });
  39. } else if (obj.event === 'edit') { //修改
  40. layer.open({
  41. type: 2,
  42. anim: 0,
  43. title: "修改",
  44. area: ['800px', '470px'],
  45. fixed: true,
  46. scrollbar: true,
  47. maxmin: true,
  48. content: 'add_change.html?event=edit&guid=' + data.guid,
  49. end: function () {
  50. table.reload(funcName); //重新载入表格
  51. }
  52. });
  53. } else if (obj.event === 'view') { //查看
  54. layer.open({
  55. type: 2,
  56. anim: 0,
  57. title: "查看",
  58. area: ['800px', '470px'],
  59. fixed: true,
  60. scrollbar: true,
  61. maxmin: true,
  62. content: 'add_change.html?event=view&guid=' + data.guid,
  63. end: function () { }
  64. });
  65. } else if (obj.event === 'disauth') { //授权
  66. layer.open({
  67. type: 2,
  68. anim: 0,
  69. title: "功能授权",
  70. area: ['500px', '520px'],
  71. fixed: true,
  72. scrollbar: true,
  73. maxmin: true,
  74. content: 'auth.html?guid=' + data.guid,
  75. end: function () { }
  76. });
  77. }
  78. }
  79. //列表
  80. var DataList = {
  81. id: funcName,
  82. elem: '#DataTable',
  83. url: funcName + 'List',
  84. page: true,
  85. method: "post",
  86. contentType: 'application/json',
  87. loading: true,
  88. cellMinWidth: 80,
  89. cols: [
  90. [{
  91. title: '选择',
  92. type: 'radio'
  93. }, {
  94. field: 'orgCode',
  95. title: '企业代码',
  96. align: 'left',
  97. }, {
  98. field: 'orgName',
  99. title: '企业名称',
  100. align: 'left',
  101. }, {
  102. field: 'principals',
  103. title: '法人',
  104. align: 'left',
  105. }, {
  106. field: 'tel',
  107. title: '电话号码',
  108. align: 'center'
  109. }, {
  110. field: 'orgAddress',
  111. title: '地址',
  112. align: 'center'
  113. }, {
  114. field: 'operating',
  115. title: '操作',
  116. toolbar: '#operatingTool',
  117. align: 'center',
  118. fixed: 'right',
  119. width: 240
  120. }]
  121. ] //设置表头
  122. ,
  123. done: function (res) {
  124. resetButton(layui.sessionData(window.hywa.sessionTable.tableName).userData.menus.subMenuList, $);
  125. }
  126. };
  127. //执行默认渲染表格
  128. table.render(DataList);
  129. //监听产品工具事件条
  130. table.on('tool(DataTable)', function (obj) {
  131. toolOperating(obj);
  132. });
  133. //搜索响应函数
  134. var infoSearch = function (obj) {
  135. table.reload(funcName, { //执行重载
  136. where: obj.field
  137. });
  138. return false;
  139. };
  140. //监听搜索表单事件
  141. form.on("submit(DataSearch)", infoSearch);
  142. $("#addBtn").on("click", function () {
  143. layer.open({
  144. type: 2,
  145. anim: 0,
  146. title: "新增",
  147. area: ['800px', '470px'],
  148. fixed: true,
  149. scrollbar: true,
  150. maxmin: true,
  151. content: 'add_change.html',
  152. end: function () {
  153. table.reload(funcName);
  154. }
  155. });
  156. });
  157. //新增管理用户
  158. $("#addBtnUser").on("click", function () {
  159. var checkStatus = table.checkStatus(funcName); //idTest 即为基础参数 id 对应的值
  160. if (checkStatus.data.length) {
  161. layer.open({
  162. type: 2,
  163. anim: 0,
  164. title: "新增",
  165. area: ['800px', '470px'],
  166. fixed: true,
  167. scrollbar: true,
  168. maxmin: true,
  169. content: 'addFirmUser.html?fkOrgGuid=' + checkStatus.data[0].guid + '&orgName=' + checkStatus.data[0].orgName,
  170. end: function () {
  171. table.reload(funcName);
  172. }
  173. });
  174. } else {
  175. layer.msg('必须选择一个企业进行新增操作', {
  176. time: 4000,
  177. icon: 2
  178. });
  179. }
  180. });
  181. });