admin.js 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. $(function(){
  2. //页面白底区块,设置最低高度
  3. if($(".main-wrapper").length>0)
  4. {
  5. $(".main-wrapper").css("min-height",($(window).height()-100)+'px');
  6. }
  7. if($(".main-wrapper-inner").length>0)
  8. {
  9. $(".main-wrapper-inner").css("min-height",($(window).height()-0)+'px');
  10. }
  11. })
  12. //编辑器中的弹框被遮挡了,得做个处理
  13. function fixUeditorLayer()
  14. {
  15. setInterval(function(){
  16. if($('#edui_fixedlayer').length>0)
  17. {
  18. var zindex = $('#edui_fixedlayer').css('z-index');
  19. if(zindex<9000)
  20. {
  21. $('#edui_fixedlayer').css('z-index','9999');
  22. }
  23. }
  24. if($('.edui-editor-toolbarbox').css('position')=='fixed'){
  25. $('.edui-editor-toolbarbox').css('position','absolute');
  26. }
  27. },300);
  28. }
  29. //表单数据转json
  30. $.fn.serializeJson=function(){
  31. var serializeObj={};
  32. var array=this.serializeArray();
  33. // var str=this.serialize();
  34. $(array).each(function(){ // 遍历数组的每个元素
  35. if(serializeObj[this.name]){ // 判断对象中是否已经存在 name,如果存在name
  36. if($.isArray(serializeObj[this.name])){
  37. serializeObj[this.name].push(this.value); // 追加一个值 hobby : ['音乐','体育']
  38. }else{
  39. // 将元素变为 数组 ,hobby : ['音乐','体育']
  40. serializeObj[this.name]=[serializeObj[this.name],this.value];
  41. }
  42. }else{
  43. serializeObj[this.name]=this.value; // 如果元素name不存在,添加一个属性 name:value
  44. }
  45. });
  46. return serializeObj;
  47. };
  48. //美化下拉选择框
  49. $('select.form-select').each(function(){
  50. if(!$(this).hasClass('original')){
  51. dselect(this);
  52. }
  53. })
  54. //删除操作
  55. function delConfirm(url)
  56. {
  57. var url = url;
  58. Swal.fire({
  59. icon: "warning",
  60. title: "确认删除吗?",
  61. html: "<h5>删除后无法恢复!</h5>",
  62. buttonsStyling: false,
  63. showCancelButton: true,
  64. confirmButtonColor: "#556ee6",
  65. cancelButtonColor: '#d33',
  66. width:'28em',
  67. customClass: {
  68. confirmButton: 'btn btn-success mt-2 me-2',
  69. cancelButton: 'btn btn-danger mt-2',
  70. content: 'tex'
  71. },
  72. confirmButtonText: '确定',
  73. cancelButtonText: '取消',
  74. allowOutsideClick: () => !Swal.isLoading(),
  75. showLoaderOnConfirm: true,
  76. preConfirm: () => {
  77. return fetch(url,{method:'get',headers: {"Content-Type": "application/json"}}).then(response => {
  78. return response.json();
  79. }).then(result => {
  80. if(result.error==0){
  81. Swal.fire({
  82. icon: "success",
  83. title: result.msg,
  84. width:'28em',
  85. buttonsStyling: false,
  86. customClass: {
  87. confirmButton: 'btn btn-primary mt-2'
  88. }
  89. }).then(function(oper) {
  90. if (oper.isConfirmed) {
  91. reLoad();
  92. }
  93. })
  94. }else{
  95. Swal.fire({
  96. icon: "error",
  97. title: result.msg,
  98. width:'28em',
  99. buttonsStyling: false,
  100. customClass: {
  101. confirmButton: 'btn btn-primary mt-2'
  102. }
  103. })
  104. }
  105. })
  106. }
  107. }).then(function(result) {
  108. if (result.isConfirmed) {
  109. } else if (result.isDenied) {
  110. //do nothing
  111. }
  112. })
  113. }
  114. //批量删除操作
  115. function multiDelConfirm(url,ids)
  116. {
  117. if(ids.length==0)
  118. {
  119. Swal.fire({
  120. icon: "warning",
  121. title: '您没有选中任何记录',
  122. width:'28em',
  123. buttonsStyling: false,
  124. customClass: {
  125. confirmButton: 'btn btn-primary mt-2'
  126. }
  127. })
  128. return;
  129. }
  130. var url = url;
  131. url = url.split("?");
  132. var params = [];
  133. if(url[1]!='')
  134. {
  135. params = url[1].split("&");
  136. }
  137. params[params.length]="ids="+ids.join(",");
  138. var newUrl = url[0]+'?'+params.join("&");
  139. Swal.fire({
  140. icon: "warning",
  141. title: "确认删除吗?",
  142. html: "<h5>删除后无法恢复!</h5>",
  143. buttonsStyling: false,
  144. showCancelButton: true,
  145. confirmButtonColor: "#556ee6",
  146. cancelButtonColor: '#d33',
  147. width:'28em',
  148. customClass: {
  149. confirmButton: 'btn btn-success mt-2 me-2',
  150. cancelButton: 'btn btn-danger mt-2',
  151. content: 'tex'
  152. },
  153. confirmButtonText: '确定',
  154. cancelButtonText: '取消',
  155. allowOutsideClick: () => !Swal.isLoading(),
  156. showLoaderOnConfirm: true,
  157. preConfirm: () => {
  158. return fetch(newUrl,{method:'get',headers: {"Content-Type": "application/json"}}).then(response => {
  159. return response.json();
  160. }).then(result => {
  161. if(result.error==0){
  162. Swal.fire({
  163. icon: "success",
  164. title: result.msg,
  165. width:'28em',
  166. buttonsStyling: false,
  167. customClass: {
  168. confirmButton: 'btn btn-primary mt-2'
  169. }
  170. }).then(function(oper) {
  171. if (oper.isConfirmed) {
  172. reLoad();
  173. }
  174. })
  175. }else{
  176. Swal.fire({
  177. icon: "error",
  178. title: result.msg,
  179. width:'28em',
  180. buttonsStyling: false,
  181. customClass: {
  182. confirmButton: 'btn btn-primary mt-2'
  183. }
  184. })
  185. }
  186. })
  187. }
  188. }).then(function(result) {
  189. if (result.isConfirmed) {
  190. } else if (result.isDenied) {
  191. //do nothing
  192. }
  193. })
  194. }
  195. //批量操作
  196. function multiOperate(url,ids)
  197. {
  198. if(ids.length==0)
  199. {
  200. Swal.fire({
  201. icon: "warning",
  202. title: '您没有选中任何记录',
  203. width:'28em',
  204. buttonsStyling: false,
  205. customClass: {
  206. confirmButton: 'btn btn-primary mt-2'
  207. }
  208. })
  209. return;
  210. }
  211. var url = url;
  212. url = url.split("?");
  213. var params = [];
  214. if(url[1]!='')
  215. {
  216. params = url[1].split("&");
  217. }
  218. params[params.length]="ids="+ids.join(",");
  219. var newUrl = url[0]+'?'+params.join("&");
  220. Swal.fire({
  221. icon: "warning",
  222. title: "确认执行该操作吗?",
  223. html: "<h5>执行后无法撤回!</h5>",
  224. buttonsStyling: false,
  225. showCancelButton: true,
  226. confirmButtonColor: "#556ee6",
  227. cancelButtonColor: '#d33',
  228. width:'28em',
  229. customClass: {
  230. confirmButton: 'btn btn-success mt-2 me-2',
  231. cancelButton: 'btn btn-danger mt-2',
  232. content: 'tex'
  233. },
  234. confirmButtonText: '确定',
  235. cancelButtonText: '取消',
  236. allowOutsideClick: () => !Swal.isLoading(),
  237. showLoaderOnConfirm: true,
  238. preConfirm: () => {
  239. return fetch(newUrl,{method:'get',headers: {"Content-Type": "application/json"}}).then(response => {
  240. return response.json();
  241. }).then(result => {
  242. if(result.error==0){
  243. Swal.fire({
  244. icon: "success",
  245. title: result.msg,
  246. width:'28em',
  247. buttonsStyling: false,
  248. customClass: {
  249. confirmButton: 'btn btn-primary mt-2'
  250. }
  251. }).then(function(oper) {
  252. if (oper.isConfirmed) {
  253. reLoad();
  254. }
  255. })
  256. }else{
  257. Swal.fire({
  258. icon: "error",
  259. title: result.msg,
  260. width:'28em',
  261. buttonsStyling: false,
  262. customClass: {
  263. confirmButton: 'btn btn-primary mt-2'
  264. }
  265. })
  266. }
  267. })
  268. }
  269. }).then(function(result) {
  270. if (result.isConfirmed) {
  271. } else if (result.isDenied) {
  272. //do nothing
  273. }
  274. })
  275. }