KqProductRuleSet_Admin.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. var ExcelData,ExcelKind;
  2. function ConfirmImport() {
  3. $.ajax({
  4. type: "POST",
  5. url: "/Admin/KqProductRuleSet/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. //excel导入
  32. excel = layui.excel;
  33. $('#ExcelFile').change(function (e) {
  34. var files = e.target.files;
  35. excel.importExcel(files, { }, function (data) {
  36. ExcelData = data[0].sheet1;
  37. });
  38. });
  39. //监听单元格编辑
  40. table.on('edit(LAY-list-manage)', function(obj){
  41. var value = obj.value //得到修改后的值
  42. ,data = obj.data //得到所在行所有键值
  43. ,field = obj.field; //得到字段
  44. if(field == "Sort"){
  45. $.ajax({
  46. type: "POST",
  47. url: "/Admin/KqProductRuleSet/Sort?r=" + Math.random(1),
  48. data: "Id=" + data.Id + "&Sort=" + value,
  49. dataType: "text",
  50. success: function (data) {
  51. }
  52. });
  53. }
  54. });
  55. //列表数据
  56. table.render({
  57. elem: '#LAY-list-manage'
  58. , url: '/Admin/KqProductRuleSet/IndexData' //模拟接口
  59. , cols: [[
  60. { type: 'checkbox', fixed: 'left' }
  61. , {field:'Id', fixed: 'left', title:'ID', width:80, sort: true, unresize: true}
  62. ,{field:'StatusName', width: 200, title:'状态', sort: true}
  63. ,{field:'Deposit', width: 200, title:'押金', sort: true}
  64. ,{field:'ActiveCount', width: 200, title:'活动政策台数', sort: true}
  65. ,{field:'ActivePrice', width: 200, title:'活动政策价格', sort: true}
  66. ,{field:'MerStaStartDate', width: 200, title:'活动开始时间', sort: true}
  67. ,{field:'MerStaEndDate', width: 200, title:'活动结束时间', sort: true}
  68. ,{field:'MerStaProfit', width: 200, title:'达标奖励', sort: true}
  69. ,{field:'MerStaMonths', width: 200, title:'激活后达标月', sort: true}
  70. ,{field:'MerStaTradeForMonth', width: 200, title:'激活后每月达标交易', sort: true}
  71. ,{field:'ActStartDate', width: 200, title:'活动开始时间', sort: true}
  72. ,{field:'ActEndDate', width: 200, title:'活动结束时间', sort: true}
  73. ,{field:'ActDeposit', width: 200, title:'激活押金', sort: true}
  74. ,{field:'ActFirst', width: 200, title:'激活首刷', sort: true}
  75. ,{field:'ActFirstDeposit', width: 200, title:'激活首刷押金', sort: true}
  76. ,{field:'ActPrize', width: 200, title:'激活奖励金额', sort: true}
  77. ,{field:'ActPosCount', width: 200, title:'激活赠机台数', sort: true}
  78. ,{field:'OpenStartDate', width: 200, title:'活动开始时间', sort: true}
  79. ,{field:'OpenEndDate', width: 200, title:'活动结束时间', sort: true}
  80. ,{field:'OpenStaDays', width: 200, title:'达标天数', sort: true}
  81. ,{field:'OpenStaTrade', width: 200, title:'达标交易', sort: true}
  82. ,{field:'OpenStaPrize', width: 200, title:'达标奖励1', sort: true}
  83. ,{field:'OpenStaPrize2', width: 200, title:'达标奖励2', sort: true}
  84. ,{field:'CycleStartDate', width: 200, title:'活动开始时间', sort: true}
  85. ,{field:'CycleEndDate', width: 200, title:'活动结束时间', sort: true}
  86. ,{field:'CycleIsOtherName', width: 200, title:'是否允许划拨给他人', sort: true}
  87. ,{field:'CyclePosDays', width: 200, title:'领机天数', sort: true}
  88. ,{field:'PullNewStartDate', width: 200, title:'活动开始时间', sort: true}
  89. ,{field:'PullNewEndDate', width: 200, title:'活动结束时间', sort: true}
  90. ,{field:'PullNewExtendDays', width: 200, title:'延长领机天数', sort: true}
  91. ,{field:'BigTotalAmount', width: 200, title:'购买机起始价', sort: true}
  92. ,{field:'BigExtendCycleDays', width: 200, title:'延长循环周期天数', sort: true}
  93. ,{field:'SubsidyStartDate', width: 200, title:'活动开始时间', sort: true}
  94. ,{field:'SubsidyEndDate', width: 200, title:'活动结束时间', sort: true}
  95. ,{field:'FlowCardStartDate', width: 200, title:'活动开始时间', sort: true}
  96. ,{field:'FlowCardEndDate', width: 200, title:'活动结束时间', sort: true}
  97. ,{field:'FlowCardFreeDays', width: 200, title:'免收天数', sort: true}
  98. ,{field:'FlowCardFee', width: 200, title:'费用', sort: true}
  99. ,{field:'FeeOfDays', width: 200, title:'扣费频率(天)', sort: true}
  100. ,{field:'FlowCardDirectProfit', width: 200, title:'直属上级返佣', sort: true}
  101. ,{field:'HelpStartDate', width: 200, title:'活动开始时间', sort: true}
  102. ,{field:'HelpEndDate', width: 200, title:'活动结束时间', sort: true}
  103. ,{field:'HelpMonths', width: 200, title:'计算自然月', sort: true}
  104. ,{field:'HelpFee', width: 200, title:'扶植期费率', sort: true}
  105. ,{field:'HelpSteadyFee', width: 200, title:'稳定期费率', sort: true}
  106. ,{field:'FeeBindDays', width: 200, title:'绑定起天数', sort: true}
  107. ,{field:'FeeFixed', width: 200, title:'固定手续费', sort: true}
  108. ,{field:'FeeRate', width: 200, title:'费率', sort: true}
  109. , {field:'Sort', fixed: 'right', title:'排序', width:80, edit: 'text'}
  110. , { title: '操作', align: 'center', fixed: 'right', toolbar: '#table-list-tools' }
  111. ]]
  112. , where: {
  113. OrgId: OrgId
  114. }
  115. , page: true
  116. , limit: 30
  117. , height: 'full-220'
  118. , text: '对不起,加载出现异常!'
  119. , done: function (res, curr, count) {
  120. $(".layui-none").text("无数据");
  121. }
  122. });
  123. //监听工具条
  124. table.on('tool(LAY-list-manage)', function (obj) {
  125. var data = obj.data;
  126. if (obj.event === 'del') {
  127. var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
  128. $.ajax({
  129. type: "POST",
  130. url: "/Admin/KqProductRuleSet/Delete?r=" + Math.random(1),
  131. data: "Id=" + data.Id,
  132. dataType: "text",
  133. success: function (data) {
  134. if (data == "success") {
  135. obj.del();
  136. layer.close(index);
  137. } else {
  138. parent.layer.msg(data);
  139. }
  140. }
  141. });
  142. });
  143. } else if (obj.event === 'edit') {
  144. var tr = $(obj.tr);
  145. var perContent = layer.open({
  146. type: 2
  147. , title: '产品规则配置-编辑'
  148. , content: 'Edit?Id=' + data.Id + '&OrgId=' + OrgId + ''
  149. , maxmin: true
  150. , area: ['500px', '450px']
  151. , btn: ['确定', '取消']
  152. , yes: function (index, layero) {
  153. var iframeWindow = window['layui-layer-iframe' + index]
  154. , submitID = 'LAY-list-front-submit'
  155. , submit = layero.find('iframe').contents().find('#' + submitID);
  156. setTimeout(function () {
  157. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  158. var errObj = $(this).find('.layui-form-danger');
  159. if (errObj.length > 0) {
  160. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  161. submit.click();
  162. }
  163. });
  164. }, 300);
  165. //监听提交
  166. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  167. var field = data.field; //获取提交的字段
  168. var userdata = "";
  169. for (var prop in field) {
  170. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  171. }
  172. //提交 Ajax 成功后,静态更新表格中的数据
  173. //$.ajax({});
  174. $.ajax({
  175. type: "POST",
  176. url: "/Admin/KqProductRuleSet/Edit?r=" + Math.random(1),
  177. data: userdata,
  178. dataType: "text",
  179. success: function (data) {
  180. layer.close(index); //关闭弹层
  181. if (data == "success") {
  182. table.reload('LAY-list-manage'); //数据刷新
  183. } else {
  184. layer.msg(data);
  185. }
  186. }
  187. });
  188. });
  189. submit.trigger('click');
  190. }
  191. , success: function (layero, index) {
  192. }
  193. });
  194. layer.full(perContent);
  195. }
  196. });
  197. //监听搜索
  198. form.on('submit(LAY-list-front-search)', function (data) {
  199. var field = data.field;
  200. //执行重载
  201. table.reload('LAY-list-manage', {
  202. where: field
  203. });
  204. });
  205. form.on('submit(LAY-list-front-searchall)', function (data) {
  206. table.reload('LAY-list-manage', {
  207. where: null
  208. });
  209. });
  210. //事件
  211. var active = {
  212. batchdel: function () {
  213. var checkStatus = table.checkStatus('LAY-list-manage')
  214. , data = checkStatus.data; //得到选中的数据
  215. if (data.length < 1) {
  216. parent.layer.msg("请选择要删除的项");
  217. } else {
  218. var ids = "";
  219. $.each(data, function (index, value) {
  220. ids += data[index].Id + ",";
  221. });
  222. ids = ids.substring(0, ids.length - 1);
  223. var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
  224. $.ajax({
  225. type: "POST",
  226. url: "/Admin/KqProductRuleSet/Delete?r=" + Math.random(1),
  227. data: "Id=" + ids,
  228. dataType: "text",
  229. success: function (data) {
  230. layer.close(index);
  231. if (data == "success") {
  232. table.reload('LAY-list-manage');
  233. } else {
  234. layer.msg(data);
  235. }
  236. }
  237. });
  238. });
  239. }
  240. }
  241. , add: function () {
  242. var perContent = layer.open({
  243. type: 2
  244. , title: '产品规则配置-添加'
  245. , content: 'Add?OrgId=' + OrgId + ''
  246. , maxmin: true
  247. , area: ['500px', '450px']
  248. , btn: ['确定', '取消']
  249. , yes: function (index, layero) {
  250. var iframeWindow = window['layui-layer-iframe' + index]
  251. , submitID = 'LAY-list-front-submit'
  252. , submit = layero.find('iframe').contents().find('#' + submitID);
  253. setTimeout(function () {
  254. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  255. var errObj = $(this).find('.layui-form-danger');
  256. if (errObj.length > 0) {
  257. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  258. submit.click();
  259. }
  260. });
  261. }, 300);
  262. //监听提交
  263. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  264. var field = data.field; //获取提交的字段
  265. var userdata = "";
  266. for (var prop in field) {
  267. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  268. }
  269. //提交 Ajax 成功后,静态更新表格中的数据
  270. //$.ajax({});
  271. $.ajax({
  272. type: "POST",
  273. url: "/Admin/KqProductRuleSet/Add?r=" + Math.random(1),
  274. data: userdata,
  275. dataType: "text",
  276. success: function (data) {
  277. layer.close(index); //关闭弹层
  278. if (data == "success") {
  279. table.reload('LAY-list-manage'); //数据刷新
  280. } else {
  281. layer.msg(data);
  282. }
  283. }
  284. });
  285. });
  286. submit.trigger('click');
  287. }
  288. });
  289. layer.full(perContent);
  290. }
  291. , ImportData: function () {
  292. ExcelKind = 1;
  293. layer.open({
  294. type: 1,
  295. title: '导入',
  296. maxmin: false,
  297. area: ['460px', '280px'],
  298. content: $('#excelForm'),
  299. cancel: function () {
  300. }
  301. });
  302. $("#excelTemp").html('<a href="/excelfile/模板文件.xlsx">点击下载模板文件</a>');
  303. }
  304. , ExportExcel: function () {
  305. var userdata = '';
  306. $(".layuiadmin-card-header-auto input").each(function (i) {
  307. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  308. });
  309. $(".layuiadmin-card-header-auto select").each(function (i) {
  310. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  311. });
  312. $.ajax({
  313. type: "GET",
  314. url: "/Admin/KqProductRuleSet/ExportExcel?r=" + Math.random(1),
  315. data: userdata,
  316. dataType: "json",
  317. success: function (data) {
  318. data.Obj.unshift(data.Fields);
  319. excel.exportExcel(data.Obj, data.Info, 'xlsx');
  320. }
  321. });
  322. }
  323. , Open: function () {
  324. var checkStatus = table.checkStatus('LAY-list-manage')
  325. , data = checkStatus.data; //得到选中的数据
  326. if(data.length < 1){
  327. parent.layer.msg("请选择要开启的项");
  328. }else{
  329. var ids = "";
  330. $.each(data, function (index, value) {
  331. ids += data[index].Id + ",";
  332. });
  333. ids = ids.substring(0, ids.length - 1);
  334. var index = layer.confirm('确定要开启吗?', function (index) {
  335. $.ajax({
  336. type: "POST",
  337. url: "/Admin/KqProductRuleSet/Open?r=" + Math.random(1),
  338. data: "Id=" + ids,
  339. dataType: "text",
  340. success: function (data) {
  341. layer.close(index);
  342. if (data == "success") {
  343. table.reload('LAY-list-manage');
  344. } else {
  345. layer.msg(data);
  346. }
  347. }
  348. });
  349. });
  350. }
  351. }
  352. , Close: function () {
  353. var checkStatus = table.checkStatus('LAY-list-manage')
  354. , data = checkStatus.data; //得到选中的数据
  355. if(data.length < 1){
  356. parent.layer.msg("请选择要关闭的项");
  357. }else{
  358. var ids = "";
  359. $.each(data, function (index, value) {
  360. ids += data[index].Id + ",";
  361. });
  362. ids = ids.substring(0, ids.length - 1);
  363. var index = layer.confirm('确定要关闭吗?', function (index) {
  364. $.ajax({
  365. type: "POST",
  366. url: "/Admin/KqProductRuleSet/Close?r=" + Math.random(1),
  367. data: "Id=" + ids,
  368. dataType: "text",
  369. success: function (data) {
  370. layer.close(index);
  371. if (data == "success") {
  372. table.reload('LAY-list-manage');
  373. } else {
  374. layer.msg(data);
  375. }
  376. }
  377. });
  378. });
  379. }
  380. }
  381. };
  382. $('.layui-btn').on('click', function () {
  383. var type = $(this).data('type');
  384. active[type] ? active[type].call(this) : '';
  385. });
  386. });