PosMerchantInfoList_Admin.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. var ExcelData;
  2. function ConfirmImport() {
  3. $.ajax({
  4. type: "POST",
  5. url: "/Admin/PosMerchantInfo/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 layCreateDate = laydate.render({
  32. elem: '#CreateDate',
  33. type: 'date',
  34. range: true,
  35. trigger: 'click',
  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. layCreateDate.hint('日期范围请不要超过1个月');
  42. setTimeout(function () {
  43. $(".laydate-btns-confirm").addClass("laydate-disabled");
  44. }, 1);
  45. }
  46. } else {
  47. op = false;
  48. layCreateDate.hint('日期范围请不要超过1个月');
  49. setTimeout(function () {
  50. $(".laydate-btns-confirm").addClass("laydate-disabled");
  51. }, 1);
  52. }
  53. if (op) {
  54. $('#CreateDate').val(value);
  55. }
  56. }
  57. });
  58. var layKqRegTime = laydate.render({
  59. elem: '#KqRegTime',
  60. trigger: 'click',
  61. type: 'date',
  62. range: true,
  63. change: function (value, date, endDate) {
  64. var op = true;
  65. if (date.year == endDate.year && endDate.month - date.month <= 1) {
  66. if (endDate.month - date.month == 1 && endDate.date > date.date) {
  67. op = false;
  68. layKqRegTime.hint('日期范围请不要超过1个月');
  69. setTimeout(function () {
  70. $(".laydate-btns-confirm").addClass("laydate-disabled");
  71. }, 1);
  72. }
  73. } else {
  74. op = false;
  75. layKqRegTime.hint('日期范围请不要超过1个月');
  76. setTimeout(function () {
  77. $(".laydate-btns-confirm").addClass("laydate-disabled");
  78. }, 1);
  79. }
  80. if (op) {
  81. $('#KqRegTime').val(value);
  82. }
  83. }
  84. });
  85. //excel导入
  86. excel = layui.excel;
  87. $('#ExcelFile').change(function (e) {
  88. var files = e.target.files;
  89. excel.importExcel(files, {}, function (data) {
  90. ExcelData = data[0].sheet1;
  91. });
  92. });
  93. //监听单元格编辑
  94. table.on('edit(LAY-list-manage)', function (obj) {
  95. var value = obj.value //得到修改后的值
  96. , data = obj.data //得到所在行所有键值
  97. , field = obj.field; //得到字段
  98. if (field == "Sort") {
  99. $.ajax({
  100. type: "POST",
  101. url: "/Admin/PosMerchantInfo/Sort?r=" + Math.random(1),
  102. data: "Id=" + data.Id + "&Sort=" + value,
  103. dataType: "text",
  104. success: function (data) {
  105. }
  106. });
  107. }
  108. });
  109. //列表数据
  110. table.render({
  111. elem: '#LAY-list-manage'
  112. , url: '/Admin/PosMerchantInfoList/IndexData' //模拟接口
  113. , cols: [[
  114. { type: 'checkbox', fixed: 'left' }
  115. , { field: 'MerchantNo', width: 200, title: '商户编号', sort: true }
  116. , { field: 'MerIdcardNo', width: 200, title: '身份证号', sort: true }
  117. , { field: 'MerchantName', width: 200, title: '商户名称', sort: true }
  118. , { field: 'MerchantMobile', width: 200, title: '商户手机号', sort: true }
  119. , { field: 'KqMerNo', width: 200, title: '快钱商户编码', sort: true }
  120. , { field: 'KqSnNo', width: 200, title: '快钱SN号', sort: true }
  121. , { field: 'SnType', width: 200, title: '机具类型', sort: true }
  122. , { field: 'RebateQual', width: 200, title: '返利资格', sort: true }
  123. , { field: 'ActType', width: 200, title: '激活类型', sort: true }
  124. , { field: 'MerStatus', width: 200, title: '商户状态', sort: true }
  125. , { field: 'ActiveStatus', width: 200, title: '商户激活状态', sort: true }
  126. , { field: 'MerMakerCode', width: 200, title: '商户创客编码', sort: true }
  127. , { field: 'MerRealName', width: 200, title: '商户创客名称', sort: true }
  128. , { field: 'MerUserType', width: 200, title: '商户创客类型', sort: true }
  129. , { field: 'MakerCode', width: 200, title: '直属创客编号', sort: true }
  130. , { field: 'RealName', width: 200, title: '直属创客姓名', sort: true }
  131. , { field: 'StoreNo', width: 200, title: 'SN仓库编号', sort: true }
  132. , { field: 'StoreName', width: 200, title: 'SN仓库名称', sort: true }
  133. , { field: 'SnApplyMakerCode', width: 200, title: '申请创客编号', sort: true }
  134. , { field: 'SnApplyRealName', width: 200, title: '申请创客姓名', sort: true }
  135. , { field: 'KqRegTime', width: 200, title: '注册时间', sort: true }
  136. , { title: '操作', width: 120, align: 'left', toolbar: '#table-list-tools', fixed: 'right' }
  137. ]]
  138. , where: {
  139. }
  140. , page: true
  141. , limit: 30
  142. , height: 'full-' + String($('.layui-card-header').height() + 130)
  143. , text: '对不起,加载出现异常!'
  144. , done: function (res, curr, count) {
  145. $(".layui-none").text("无数据");
  146. }
  147. });
  148. //监听工具条
  149. table.on('tool(LAY-list-manage)', function (obj) {
  150. var data = obj.data;
  151. if (obj.event === 'del') {
  152. var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
  153. $.ajax({
  154. type: "POST",
  155. url: "/Admin/PosMerchantInfo/Delete?r=" + Math.random(1),
  156. data: "Id=" + data.Id,
  157. dataType: "text",
  158. success: function (data) {
  159. if (data == "success") {
  160. obj.del();
  161. layer.close(index);
  162. } else {
  163. parent.layer.msg(data);
  164. }
  165. }
  166. });
  167. });
  168. } else if (obj.event === 'edit') {
  169. var tr = $(obj.tr);
  170. var perContent = layer.open({
  171. type: 2
  172. , title: '商户-编辑'
  173. , content: 'Edit?Id=' + data.Id + ''
  174. , maxmin: true
  175. , area: ['500px', '450px']
  176. , btn: ['确定', '取消']
  177. , yes: function (index, layero) {
  178. var iframeWindow = window['layui-layer-iframe' + index]
  179. , submitID = 'LAY-list-front-submit'
  180. , submit = layero.find('iframe').contents().find('#' + submitID);
  181. setTimeout(function () {
  182. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  183. var errObj = $(this).find('.layui-form-danger');
  184. if (errObj.length > 0) {
  185. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  186. submit.click();
  187. }
  188. });
  189. }, 300);
  190. //监听提交
  191. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  192. var field = data.field; //获取提交的字段
  193. var userdata = "";
  194. for (var prop in field) {
  195. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  196. }
  197. //提交 Ajax 成功后,静态更新表格中的数据
  198. //$.ajax({});
  199. $.ajax({
  200. type: "POST",
  201. url: "/Admin/PosMerchantInfo/Edit?r=" + Math.random(1),
  202. data: userdata,
  203. dataType: "text",
  204. success: function (data) {
  205. layer.close(index); //关闭弹层
  206. if (data == "success") {
  207. table.reload('LAY-list-manage'); //数据刷新
  208. } else {
  209. layer.msg(data);
  210. }
  211. }
  212. });
  213. });
  214. submit.trigger('click');
  215. }
  216. , success: function (layero, index) {
  217. }
  218. });
  219. layer.full(perContent);
  220. } else if (obj.event === 'sycntrade') {
  221. var tr = $(obj.tr);
  222. var perContent = layer.open({
  223. type: 2
  224. , title: '同步交易额'
  225. , content: 'SycnTradeAmount?Id=' + data.Id
  226. , maxmin: false
  227. , area: ['550px', '700px']
  228. , btn: ['确定', '取消']
  229. , yes: function (index, layero) {
  230. var iframeWindow = window['layui-layer-iframe' + index]
  231. , submitID = 'LAY-list-front-submit'
  232. , submit = layero.find('iframe').contents().find('#' + submitID);
  233. //监听提交
  234. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  235. var field = data.field; //获取提交的字段
  236. var userdata = "";
  237. for (var prop in field) {
  238. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  239. }
  240. //提交 Ajax 成功后,静态更新表格中的数据
  241. //$.ajax({});
  242. var loadindex = layer.load(1, {
  243. shade: [0.5, '#000']
  244. });
  245. $.ajax({
  246. type: "POST",
  247. url: "/Admin/PosMerchantInfo/SycnTradeAmountDo?r=" + Math.random(1),
  248. data: userdata,
  249. dataType: "text",
  250. success: function (data) {
  251. layer.close(loadindex); //关闭弹层
  252. layer.close(index); //关闭弹层
  253. if (data == "success") {
  254. layer.alert('重置程序已启动,请稍后核对商户交易额');
  255. } else {
  256. layer.msg(data);
  257. }
  258. }
  259. });
  260. });
  261. submit.trigger('click');
  262. }
  263. , success: function (layero, index) {
  264. }
  265. });
  266. }
  267. });
  268. //监听搜索
  269. form.on('submit(LAY-list-front-search)', function (data) {
  270. var field = data.field;
  271. field.ShowFlag = 1;
  272. if (field.MerIdcardNo == "" && field.MerchantName == "" && field.MerchantMobile == "" && field.PosSn == "") {
  273. layer.alert('请输入查询条件');
  274. }
  275. else {
  276. //执行重载
  277. table.reload('LAY-list-manage', {
  278. where: field,
  279. page: {
  280. curr: 1
  281. }
  282. });
  283. }
  284. });
  285. form.on('submit(LAY-list-front-searchall)', function (data) {
  286. var field = data.field;
  287. field.ShowFlag = 1;
  288. field.MerIdcardNo = "";
  289. field.MerchantName = "";
  290. field.MerchantMobile = "";
  291. field.PosSn = "";
  292. table.reload('LAY-list-manage', {
  293. where: field,
  294. page: {
  295. curr: 1
  296. }
  297. });
  298. });
  299. //事件
  300. var active = {
  301. batchdel: function () {
  302. var checkStatus = table.checkStatus('LAY-list-manage')
  303. , data = checkStatus.data; //得到选中的数据
  304. if (data.length < 1) {
  305. parent.layer.msg("请选择要删除的项");
  306. } else {
  307. var ids = "";
  308. $.each(data, function (index, value) {
  309. ids += data[index].Id + ",";
  310. });
  311. ids = ids.substring(0, ids.length - 1);
  312. var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
  313. $.ajax({
  314. type: "POST",
  315. url: "/Admin/PosMerchantInfo/Delete?r=" + Math.random(1),
  316. data: "Id=" + ids,
  317. dataType: "text",
  318. success: function (data) {
  319. layer.close(index);
  320. if (data == "success") {
  321. table.reload('LAY-list-manage');
  322. } else {
  323. layer.msg(data);
  324. }
  325. }
  326. });
  327. });
  328. }
  329. }
  330. , add: function () {
  331. var perContent = layer.open({
  332. type: 2
  333. , title: '商户-添加'
  334. , content: 'Add'
  335. , maxmin: true
  336. , area: ['500px', '450px']
  337. , btn: ['确定', '取消']
  338. , yes: function (index, layero) {
  339. var iframeWindow = window['layui-layer-iframe' + index]
  340. , submitID = 'LAY-list-front-submit'
  341. , submit = layero.find('iframe').contents().find('#' + submitID);
  342. setTimeout(function () {
  343. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  344. var errObj = $(this).find('.layui-form-danger');
  345. if (errObj.length > 0) {
  346. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  347. submit.click();
  348. }
  349. });
  350. }, 300);
  351. //监听提交
  352. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  353. var field = data.field; //获取提交的字段
  354. var userdata = "";
  355. for (var prop in field) {
  356. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  357. }
  358. //提交 Ajax 成功后,静态更新表格中的数据
  359. //$.ajax({});
  360. $.ajax({
  361. type: "POST",
  362. url: "/Admin/PosMerchantInfo/Add?r=" + Math.random(1),
  363. data: userdata,
  364. dataType: "text",
  365. success: function (data) {
  366. layer.close(index); //关闭弹层
  367. if (data == "success") {
  368. table.reload('LAY-list-manage'); //数据刷新
  369. } else {
  370. layer.msg(data);
  371. }
  372. }
  373. });
  374. });
  375. submit.trigger('click');
  376. }
  377. });
  378. layer.full(perContent);
  379. }
  380. , ImportData: function () {
  381. layer.open({
  382. type: 1,
  383. title: '导入',
  384. maxmin: false,
  385. area: ['460px', '180px'],
  386. content: $('#excelForm'),
  387. cancel: function () {
  388. }
  389. });
  390. }
  391. , ExportExcel: function () {
  392. var userdata = '';
  393. $(".layuiadmin-card-header-auto input").each(function (i) {
  394. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  395. });
  396. $(".layuiadmin-card-header-auto select").each(function (i) {
  397. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  398. });
  399. $.ajax({
  400. type: "GET",
  401. url: "/Admin/PosMerchantInfo/ExportExcel?r=" + Math.random(1),
  402. data: userdata,
  403. dataType: "json",
  404. success: function (data) {
  405. data.Obj.unshift(data.Fields);
  406. excel.exportExcel(data.Obj, data.Info, 'xlsx');
  407. }
  408. });
  409. }
  410. , Open: function () {
  411. var checkStatus = table.checkStatus('LAY-list-manage')
  412. , data = checkStatus.data; //得到选中的数据
  413. if (data.length < 1) {
  414. parent.layer.msg("请选择要开启的项");
  415. } else {
  416. var ids = "";
  417. $.each(data, function (index, value) {
  418. ids += data[index].Id + ",";
  419. });
  420. ids = ids.substring(0, ids.length - 1);
  421. var index = layer.confirm('确定要开启吗?', function (index) {
  422. $.ajax({
  423. type: "POST",
  424. url: "/Admin/PosMerchantInfo/Open?r=" + Math.random(1),
  425. data: "Id=" + ids,
  426. dataType: "text",
  427. success: function (data) {
  428. layer.close(index);
  429. if (data == "success") {
  430. table.reload('LAY-list-manage');
  431. } else {
  432. layer.msg(data);
  433. }
  434. }
  435. });
  436. });
  437. }
  438. }
  439. , Close: function () {
  440. var checkStatus = table.checkStatus('LAY-list-manage')
  441. , data = checkStatus.data; //得到选中的数据
  442. if (data.length < 1) {
  443. parent.layer.msg("请选择要关闭的项");
  444. } else {
  445. var ids = "";
  446. $.each(data, function (index, value) {
  447. ids += data[index].Id + ",";
  448. });
  449. ids = ids.substring(0, ids.length - 1);
  450. var index = layer.confirm('确定要关闭吗?', function (index) {
  451. $.ajax({
  452. type: "POST",
  453. url: "/Admin/PosMerchantInfo/Close?r=" + Math.random(1),
  454. data: "Id=" + ids,
  455. dataType: "text",
  456. success: function (data) {
  457. layer.close(index);
  458. if (data == "success") {
  459. table.reload('LAY-list-manage');
  460. } else {
  461. layer.msg(data);
  462. }
  463. }
  464. });
  465. });
  466. }
  467. }
  468. };
  469. $('.layui-btn').on('click', function () {
  470. var type = $(this).data('type');
  471. active[type] ? active[type].call(this) : '';
  472. });
  473. });