TeamOfferApply_Admin.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. var ExcelData,ExcelKind;
  2. function ConfirmImport() {
  3. $.ajax({
  4. type: "POST",
  5. url: "/Admin/TeamOfferApply/Import?r=" + Math.random(1),
  6. data: "ExcelData=" + encodeURIComponent(JSON.stringify(ExcelData)),
  7. dataType: "text",
  8. success: function (data) {
  9. if (data == "success") {
  10. layer.msg("导入成功", { time: 2000 }, function () {
  11. window.location.reload();
  12. });
  13. } else {
  14. layer.msg(data);
  15. }
  16. }
  17. });
  18. }
  19. var excel;
  20. layui.config({
  21. base: '/layuiadmin/' //静态资源所在路径
  22. }).extend({
  23. myexcel: 'layui/lay/modules/excel',
  24. index: 'lib/index' //主入口模块
  25. }).use(['index', 'table', 'excel', 'laydate'], function () {
  26. var $ = layui.$
  27. , form = layui.form
  28. , table = layui.table;
  29. //- 筛选条件-日期
  30. var laydate = layui.laydate;
  31. var layEnterDate = laydate.render({
  32. elem: '#EnterDate',
  33. trigger: 'click',
  34. type: 'date',
  35. range: true,
  36. change: function (value, date, endDate) {
  37. var op = true;
  38. if (date.year == endDate.year && endDate.month - date.month <= 1) {
  39. if (endDate.month - date.month == 1 && endDate.date > date.date) {
  40. op = false;
  41. layEnterDate.hint('日期范围请不要超过1个月');
  42. setTimeout(function () {
  43. $(".laydate-btns-confirm").addClass("laydate-disabled");
  44. }, 1);
  45. }
  46. } else {
  47. op = false;
  48. layEnterDate.hint('日期范围请不要超过1个月');
  49. setTimeout(function () {
  50. $(".laydate-btns-confirm").addClass("laydate-disabled");
  51. }, 1);
  52. }
  53. if (op) {
  54. $('#EnterDate').val(value);
  55. }
  56. }
  57. });
  58. //excel导入
  59. excel = layui.excel;
  60. $('#ExcelFile').change(function (e) {
  61. var files = e.target.files;
  62. excel.importExcel(files, { }, function (data) {
  63. ExcelData = data[0].sheet1;
  64. });
  65. });
  66. //监听单元格编辑
  67. table.on('edit(LAY-list-manage)', function(obj){
  68. var value = obj.value //得到修改后的值
  69. ,data = obj.data //得到所在行所有键值
  70. ,field = obj.field; //得到字段
  71. if(field == "Sort"){
  72. $.ajax({
  73. type: "POST",
  74. url: "/Admin/TeamOfferApply/Sort?r=" + Math.random(1),
  75. data: "Id=" + data.Id + "&Sort=" + value,
  76. dataType: "text",
  77. success: function (data) {
  78. }
  79. });
  80. }
  81. });
  82. var cols = [];
  83. if (Status == '1') {
  84. cols = [[
  85. { type: 'checkbox', fixed: 'left' }
  86. , { field: 'UserIdMakerCode', width: 200, title: '创客编号', sort: true }
  87. , { field: 'UserIdRealName', width: 200, title: '创客姓名', sort: true }
  88. , { field: 'TeamIdTeamNo', width: 200, title: '团队队伍编码', sort: true }
  89. , { field: 'TeamIdTeamName', width: 200, title: '团队队伍名称', sort: true }
  90. , { field: 'TeamLeaderMakerCode', width: 200, title: '队长创客编号', sort: true }
  91. , { field: 'TeamLeaderRealName', width: 200, title: '队长真实姓名', sort: true }
  92. , { field: 'TopUserIdMakerCode', width: 200, title: '顶级创客创客编号', sort: true }
  93. , { field: 'TopUserIdRealName', width: 200, title: '顶级创客真实姓名', sort: true }
  94. , { field: 'Areas', width: 200, title: '特训营所在地区', sort: true }
  95. , { field: 'EffectStartDate', width: 200, title: '活动开始时间', sort: true }
  96. , { field: 'EffectEndDate ', width: 200, title: '活动结束时间', sort: true }
  97. , { field: 'EnterDate', width: 200, title: '报名时间', sort: true }
  98. , { field: 'TeamApplyStatusName', width: 200, title: '组队申请状态', sort: true }
  99. ]];
  100. } else {
  101. cols = [[
  102. { type: 'checkbox', fixed: 'left' }
  103. , { field: 'UserIdMakerCode', width: 200, title: '创客编号', sort: true }
  104. , { field: 'UserIdRealName', width: 200, title: '创客姓名', sort: true }
  105. , { field: 'TeamIdTeamNo', width: 200, title: '团队队伍编码', sort: true }
  106. , { field: 'TeamIdTeamName', width: 200, title: '团队队伍名称', sort: true }
  107. , { field: 'TeamLeaderMakerCode', width: 200, title: '队长创客编号', sort: true }
  108. , { field: 'TeamLeaderRealName', width: 200, title: '队长真实姓名', sort: true }
  109. , { field: 'TopUserIdMakerCode', width: 200, title: '顶级创客创客编号', sort: true }
  110. , { field: 'TopUserIdRealName', width: 200, title: '顶级创客真实姓名', sort: true }
  111. , { field: 'Areas', width: 200, title: '特训营所在地区', sort: true }
  112. , { field: 'EffectStartDate', width: 200, title: '活动开始时间', sort: true }
  113. , { field: 'EffectEndDate ', width: 200, title: '活动结束时间', sort: true }
  114. , { field: 'EnterDate', width: 200, title: '报名时间', sort: true }
  115. , { field: 'AuditTime', width: 200, title: '审核时间', sort: true }
  116. , { field: 'TeamStatus', width: 200, title: '状态', sort: true }
  117. , { field: 'TeamApplyStatusName', width: 200, title: '组队申请状态', sort: true }
  118. , { field: 'AuditResult', width: 200, title: '审核结果', sort: true }
  119. , { field: 'AuditRemark', width: 200, title: '审核备注', sort: true }
  120. , { field: 'NotifyFlag', width: 200, title: '提醒标识', sort: true }
  121. , { title: '操作', width: 100, align: 'center', fixed: 'right', toolbar: '#table-list-tools' }
  122. ]];
  123. }
  124. //列表数据
  125. table.render({
  126. elem: '#LAY-list-manage'
  127. , url: '/Admin/TeamOfferApply/IndexData' //模拟接口
  128. , cols: cols
  129. , where: {
  130. Status: Status
  131. }
  132. , page: true
  133. , limit: 30
  134. , height: 'full-' + String($('.layui-card-header').height() + 130)
  135. , text: '对不起,加载出现异常!'
  136. , done: function (res, curr, count) {
  137. $(".layui-none").text("无数据");
  138. }
  139. });
  140. //监听工具条
  141. table.on('tool(LAY-list-manage)', function (obj) {
  142. var data = obj.data;
  143. if (obj.event === 'del') {
  144. var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
  145. $.ajax({
  146. type: "POST",
  147. url: "/Admin/TeamOfferApply/Delete?r=" + Math.random(1),
  148. data: "Id=" + data.Id,
  149. dataType: "text",
  150. success: function (data) {
  151. if (data == "success") {
  152. obj.del();
  153. layer.close(index);
  154. } else {
  155. parent.layer.msg(data);
  156. }
  157. }
  158. });
  159. });
  160. } else if (obj.event === 'edit') {
  161. var tr = $(obj.tr);
  162. var perContent = layer.open({
  163. type: 2
  164. , title: '参团申请-编辑'
  165. , content: 'Edit?Id=' + data.Id + ''
  166. , maxmin: true
  167. , area: ['500px', '450px']
  168. , btn: ['确定', '取消']
  169. , yes: function (index, layero) {
  170. var iframeWindow = window['layui-layer-iframe' + index]
  171. , submitID = 'LAY-list-front-submit'
  172. , submit = layero.find('iframe').contents().find('#' + submitID);
  173. setTimeout(function () {
  174. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  175. var errObj = $(this).find('.layui-form-danger');
  176. if (errObj.length > 0) {
  177. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  178. submit.click();
  179. }
  180. });
  181. }, 300);
  182. //监听提交
  183. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  184. var field = data.field; //获取提交的字段
  185. var userdata = "";
  186. for (var prop in field) {
  187. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  188. }
  189. //提交 Ajax 成功后,静态更新表格中的数据
  190. //$.ajax({});
  191. $.ajax({
  192. type: "POST",
  193. url: "/Admin/TeamOfferApply/Edit?r=" + Math.random(1),
  194. data: userdata,
  195. dataType: "text",
  196. success: function (data) {
  197. layer.close(index); //关闭弹层
  198. if (data == "success") {
  199. table.reload('LAY-list-manage'); //数据刷新
  200. } else {
  201. layer.msg(data);
  202. }
  203. }
  204. });
  205. });
  206. submit.trigger('click');
  207. }
  208. , success: function (layero, index) {
  209. }
  210. });
  211. layer.full(perContent);
  212. } else if (obj.event === 'audit') {
  213. var tr = $(obj.tr);
  214. var perContent = layer.open({
  215. type: 2
  216. , title: '审核'
  217. , content: 'Audit?Id=' + data.Id + ''
  218. , maxmin: true
  219. , area: ['500px', '450px']
  220. , btn: ['确定', '取消']
  221. , yes: function (index, layero) {
  222. var iframeWindow = window['layui-layer-iframe' + index]
  223. , submitID = 'LAY-list-front-submit'
  224. , submit = layero.find('iframe').contents().find('#' + submitID);
  225. setTimeout(function () {
  226. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  227. var errObj = $(this).find('.layui-form-danger');
  228. if (errObj.length > 0) {
  229. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  230. submit.click();
  231. }
  232. });
  233. }, 300);
  234. //监听提交
  235. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  236. var field = data.field; //获取提交的字段
  237. var userdata = "";
  238. for (var prop in field) {
  239. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  240. }
  241. //提交 Ajax 成功后,静态更新表格中的数据
  242. //$.ajax({});
  243. $.ajax({
  244. type: "POST",
  245. url: "/Admin/TeamOfferApply/Audit?r=" + Math.random(1),
  246. data: userdata,
  247. dataType: "text",
  248. success: function (data) {
  249. if (data == "success") {
  250. layer.close(index); //关闭弹层
  251. layer.msg('提交成功', { time: 1500 }, function () {
  252. table.reload('LAY-list-manage'); //数据刷新
  253. });
  254. } else {
  255. layer.msg(data);
  256. }
  257. }
  258. });
  259. });
  260. submit.trigger('click');
  261. }
  262. , success: function (layero, index) {
  263. }
  264. });
  265. }
  266. });
  267. //监听搜索
  268. form.on('submit(LAY-list-front-search)', function (data) {
  269. var field = data.field;
  270. //执行重载
  271. table.reload('LAY-list-manage', {
  272. where: field
  273. });
  274. });
  275. form.on('submit(LAY-list-front-searchall)', function (data) {
  276. table.reload('LAY-list-manage', {
  277. where: {
  278. Status: Status
  279. }
  280. });
  281. });
  282. //事件
  283. var active = {
  284. batchdel: function () {
  285. var checkStatus = table.checkStatus('LAY-list-manage')
  286. , data = checkStatus.data; //得到选中的数据
  287. if (data.length < 1) {
  288. parent.layer.msg("请选择要删除的项");
  289. } else {
  290. var ids = "";
  291. $.each(data, function (index, value) {
  292. ids += data[index].Id + ",";
  293. });
  294. ids = ids.substring(0, ids.length - 1);
  295. var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
  296. $.ajax({
  297. type: "POST",
  298. url: "/Admin/TeamOfferApply/Delete?r=" + Math.random(1),
  299. data: "Id=" + ids,
  300. dataType: "text",
  301. success: function (data) {
  302. layer.close(index);
  303. if (data == "success") {
  304. table.reload('LAY-list-manage');
  305. } else {
  306. layer.msg(data);
  307. }
  308. }
  309. });
  310. });
  311. }
  312. }
  313. , add: function () {
  314. var perContent = layer.open({
  315. type: 2
  316. , title: '参团申请-添加'
  317. , content: 'Add'
  318. , maxmin: true
  319. , area: ['500px', '450px']
  320. , btn: ['确定', '取消']
  321. , yes: function (index, layero) {
  322. var iframeWindow = window['layui-layer-iframe' + index]
  323. , submitID = 'LAY-list-front-submit'
  324. , submit = layero.find('iframe').contents().find('#' + submitID);
  325. setTimeout(function () {
  326. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  327. var errObj = $(this).find('.layui-form-danger');
  328. if (errObj.length > 0) {
  329. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  330. submit.click();
  331. }
  332. });
  333. }, 300);
  334. //监听提交
  335. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  336. var field = data.field; //获取提交的字段
  337. var userdata = "";
  338. for (var prop in field) {
  339. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  340. }
  341. //提交 Ajax 成功后,静态更新表格中的数据
  342. //$.ajax({});
  343. $.ajax({
  344. type: "POST",
  345. url: "/Admin/TeamOfferApply/Add?r=" + Math.random(1),
  346. data: userdata,
  347. dataType: "text",
  348. success: function (data) {
  349. layer.close(index); //关闭弹层
  350. if (data == "success") {
  351. table.reload('LAY-list-manage'); //数据刷新
  352. } else {
  353. layer.msg(data);
  354. }
  355. }
  356. });
  357. });
  358. submit.trigger('click');
  359. }
  360. });
  361. layer.full(perContent);
  362. }
  363. , ImportData: function () {
  364. ExcelKind = 1;
  365. layer.open({
  366. type: 1,
  367. title: '导入',
  368. maxmin: false,
  369. area: ['460px', '280px'],
  370. content: $('#excelForm'),
  371. cancel: function () {
  372. }
  373. });
  374. $("#excelTemp").html('<a href="/excelfile/模板文件.xlsx">点击下载模板文件</a>');
  375. }
  376. , ExportExcel: function () {
  377. var userdata = '';
  378. $(".layuiadmin-card-header-auto input").each(function (i) {
  379. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  380. });
  381. $(".layuiadmin-card-header-auto select").each(function (i) {
  382. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  383. });
  384. $.ajax({
  385. type: "GET",
  386. url: "/Admin/TeamOfferApply/ExportExcel?r=" + Math.random(1),
  387. data: userdata,
  388. dataType: "json",
  389. success: function (data) {
  390. data.Obj.unshift(data.Fields);
  391. excel.exportExcel(data.Obj, data.Info, 'xlsx');
  392. }
  393. });
  394. }
  395. , Open: function () {
  396. var checkStatus = table.checkStatus('LAY-list-manage')
  397. , data = checkStatus.data; //得到选中的数据
  398. if(data.length < 1){
  399. parent.layer.msg("请选择要开启的项");
  400. }else{
  401. var ids = "";
  402. $.each(data, function (index, value) {
  403. ids += data[index].Id + ",";
  404. });
  405. ids = ids.substring(0, ids.length - 1);
  406. var index = layer.confirm('确定要开启吗?', function (index) {
  407. $.ajax({
  408. type: "POST",
  409. url: "/Admin/TeamOfferApply/Open?r=" + Math.random(1),
  410. data: "Id=" + ids,
  411. dataType: "text",
  412. success: function (data) {
  413. layer.close(index);
  414. if (data == "success") {
  415. table.reload('LAY-list-manage');
  416. } else {
  417. layer.msg(data);
  418. }
  419. }
  420. });
  421. });
  422. }
  423. }
  424. , Close: function () {
  425. var checkStatus = table.checkStatus('LAY-list-manage')
  426. , data = checkStatus.data; //得到选中的数据
  427. if(data.length < 1){
  428. parent.layer.msg("请选择要关闭的项");
  429. }else{
  430. var ids = "";
  431. $.each(data, function (index, value) {
  432. ids += data[index].Id + ",";
  433. });
  434. ids = ids.substring(0, ids.length - 1);
  435. var index = layer.confirm('确定要关闭吗?', function (index) {
  436. $.ajax({
  437. type: "POST",
  438. url: "/Admin/TeamOfferApply/Close?r=" + Math.random(1),
  439. data: "Id=" + ids,
  440. dataType: "text",
  441. success: function (data) {
  442. layer.close(index);
  443. if (data == "success") {
  444. table.reload('LAY-list-manage');
  445. } else {
  446. layer.msg(data);
  447. }
  448. }
  449. });
  450. });
  451. }
  452. }
  453. };
  454. $('.layui-btn').on('click', function () {
  455. var type = $(this).data('type');
  456. active[type] ? active[type].call(this) : '';
  457. });
  458. });