郑许地铁

dictionarylist.js 8.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. 
  2. layui.use(['table', 'jquery'], function () {
  3. var table = layui.table;
  4. var form = layui.form,
  5. layer = parent.layer === undefined ? layui.layer : parent.layer,
  6. $ = layui.jquery;
  7. //监听表格复选框选择
  8. table.on('checkbox(demo)', function (obj) {
  9. console.log(obj)
  10. });
  11. //监听工具条
  12. table.on('tool(demo)', function (obj) {
  13. var data = obj.data;
  14. if (obj.event === 'edit') {
  15. var parentId = $("#selectTypeId").val();
  16. if (parentId == "0") {
  17. layer.open({
  18. type: 2,
  19. anim: 4,
  20. scrollbar: false,
  21. content: '/SystemManage/DictionaryBaseEdit/?dicCode=' + data.F_DictionaryFlag + "&editType=2",
  22. area: ['800px', '450px'],
  23. id: 'DepartmentEdit',
  24. title: $("#selectTypeName").val()
  25. , end: function () {
  26. refushTreeAndData();
  27. }
  28. });
  29. }
  30. else {
  31. layer.open({
  32. type: 2,
  33. anim: 4,
  34. scrollbar: false,
  35. content: '/SystemManage/DictionaryValueEdit/?valueId=' + data.F_DictionaryValueId + '&parentCode=' + parentId + "&editType=2",
  36. area: ['800px', '450px'],
  37. id: 'DepartmentEdit',
  38. title: $("#selectTypeName").val()
  39. , end: function () {
  40. refushTreeAndData();
  41. }
  42. });
  43. }
  44. }
  45. else if (obj.event === 'delete') {
  46. var parentId = $("#selectTypeId").val();
  47. //layer.msg('ID:' + data.ProjectKey + ' 的查看操作');
  48. if (parentId == "0") {
  49. layer.confirm('确认要删除该行数据么?', function (index) {
  50. $.ajax({
  51. url: "/SystemManage/DeleteBaseData",
  52. type: "get",
  53. async: false,//同步请求
  54. contentType: "application/json",
  55. dataType: "text",
  56. cache: false,
  57. data: "baseCode=" + data.F_DictionaryFlag,
  58. success: function (thisResult, result) {
  59. if (thisResult == "True") {
  60. layer.open({
  61. content: '删除成功'
  62. , icon: 1
  63. , btn: ['确定']
  64. , yes: function (index, layero) {
  65. layer.close(index);
  66. refushTreeAndData();
  67. }
  68. });
  69. } else {
  70. layui.layer.alert("删除失败!", {
  71. icon: 2
  72. });
  73. }
  74. },
  75. error: function (error) {
  76. return false;
  77. }
  78. });
  79. layer.close(index);
  80. });
  81. }
  82. else {
  83. layer.confirm('确认要删除该行数据么?', function (index) {
  84. $.ajax({
  85. url: "/SystemManage/DeleteValueData",
  86. type: "get",
  87. async: false,//同步请求
  88. contentType: "application/json",
  89. dataType: "text",
  90. cache: false,
  91. data: "id=" + data.F_DictionaryValueId,
  92. success: function (thisResult, result) {
  93. if (thisResult == "True") {
  94. layer.open({
  95. content: '删除成功'
  96. , icon: 1
  97. , btn: ['确定']
  98. , yes: function (index, layero) {
  99. layer.close(index);
  100. refushTreeAndData();
  101. }
  102. });
  103. } else {
  104. layui.layer.alert("删除失败!", {
  105. icon: 2
  106. });
  107. }
  108. },
  109. error: function (error) {
  110. return false;
  111. }
  112. });
  113. layer.close(index);
  114. });
  115. }
  116. }
  117. });
  118. var $ = layui.$, active = {
  119. //新增
  120. rowAdd: function () {
  121. var parentId = $("#selectTypeId").val();
  122. if (parentId != null && parentId != "") {
  123. if (parentId == "0") {
  124. layer.open({
  125. type: 2,
  126. anim: 4,
  127. scrollbar: false,
  128. content: '/SystemManage/DictionaryBaseEdit/?dicCode=' + 0 + "&editType=1",
  129. area: ['800px', '450px'],
  130. id: 'DictionaryBaseEdit',
  131. title: $("#selectTypeName").val()
  132. , end: function () {
  133. refushTreeAndData();
  134. }
  135. });
  136. }
  137. else {
  138. layer.open({
  139. type: 2,
  140. anim: 4,
  141. scrollbar: false,
  142. content: '/SystemManage/DictionaryValueEdit/?parentCode=' + parentId + "&editType=1",
  143. area: ['800px', '450px'],
  144. id: 'DictionaryValueEdit',
  145. title: $("#selectTypeName").val()
  146. , end: function () {
  147. refushTreeAndData();
  148. }
  149. });
  150. }
  151. }
  152. else {
  153. layui.layer.alert("请先选择左侧树节点!", {
  154. icon: 2
  155. });
  156. }
  157. }
  158. };
  159. $('.layui-btn-group .layui-btn').on('click', function () {
  160. var type = $(this).data('type');
  161. active[type] ? active[type].call(this) : '';
  162. });
  163. //单击左侧数列表时
  164. function zTreeOnClick(event, treeId, treeNode) {
  165. $("#selectTypeName").val(treeNode.name);
  166. $("#selectTypeId").val(treeNode.code);
  167. selectNode = treeNode;
  168. //执行重载
  169. table.reload('recordtable', {
  170. page: {
  171. curr: 1 //重新从第 1 页开始
  172. }
  173. , where: {
  174. NowDateTime: new Date(),
  175. dictionaryFlag: treeNode.code
  176. }
  177. });
  178. };
  179. var zTreeObj;
  180. var selectNode;
  181. // zTree 的参数配置,深入使用请参考 API 文档(setting 配置详解)
  182. var setting = {
  183. check:
  184. {
  185. enable: false,
  186. chkStyle: "checkbox",
  187. chkboxType: { "Y": "ps", "N": "ps" }
  188. },
  189. callback: {
  190. onClick: zTreeOnClick
  191. }
  192. };
  193. var treeNodes;
  194. $(document).ready(function () {
  195. $.ajax({
  196. url: "/SystemManage/GetDictionaryJsonModel",
  197. type: "get",
  198. contentType: "application/json",
  199. dataType: "text",
  200. cache: false,
  201. async: false,
  202. data: { "parentId": 0 },
  203. success: function (result, status) {
  204. treeNodes = eval('(' + result + ')');
  205. }
  206. });
  207. zTreeObj = $.fn.zTree.init($("#ztree"), setting, treeNodes);
  208. });
  209. function refushTreeAndData() {
  210. //执行重载
  211. table.reload('recordtable', {
  212. page: {
  213. curr: $(".layui-laypage-em").next().html() //重新从第 1 页开始
  214. }
  215. , where: {
  216. NowDateTime: new Date(),
  217. dictionaryFlag: $("#selectTypeId").val()
  218. }
  219. });
  220. $.ajax({
  221. url: "/SystemManage/GetDictionaryJsonModel",
  222. type: "get",
  223. contentType: "application/json",
  224. dataType: "text",
  225. cache: false,
  226. async: false,
  227. data: { "parentId": 0 },
  228. success: function (result, status) {
  229. treeNodes = eval('(' + result + ')');
  230. }
  231. });
  232. zTreeObj = $.fn.zTree.init($("#ztree"), setting, treeNodes);
  233. zTreeObj.selectNode(selectNode, true, true);
  234. }
  235. });