mkstoreprom.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. $(function () {
  2. // $('#promBegTime').datepicker({
  3. // format : 'yyyy-mm-dd HH:mm:ss',
  4. // language : 'zh-CN',
  5. // autoclose : true,
  6. // clearBtn : true,
  7. // todayHighlight : true,
  8. // endDate : new Date()
  9. // });
  10. $("#jqGrid").jqGrid({
  11. url: '../mkstoreprom/list',
  12. datatype: "json",
  13. colModel: [
  14. {label: '活动状态', name: 'isFinished', index: 'is_finished', width: 40, align: 'center',
  15. formatter: function (value) {
  16. if (value == '0') {
  17. return '<span style="font-weight: bolder;background: #B2AEBC;color: white;">已结束</span>';
  18. } else if (value == '1') {
  19. return '<span style="font-weight: bolder;background: #58d44d;color: white">进行中</span>';
  20. } else if (value == '2') {
  21. return '<span style="font-weight: bolder;background: red;color: white">未开始</span>';
  22. }
  23. return '';
  24. }},
  25. {
  26. label: '活动图片', name: 'promPicUrl', index: 'promPicUrl', width: 40, align: 'center',
  27. formatter: function (value) {
  28. return transImg(value);
  29. }
  30. },
  31. {label: '推广信息', name: 'promInfo', width: 160, align: 'left'},
  32. {label: '推广ID', name: 'promId', index: 'prom_id', key: true, width: 40, align: 'center'},
  33. {label: '所属门店', name: 'storeName', index: 'storeName', width: 70, align: 'center'},
  34. {label: '推广分类', name: 'promType', index: 'prom_type', width: 80, align: 'center',
  35. formatter: function (value) {
  36. if (value == '00') {
  37. return '活动链接';
  38. } else if (value == '10') {
  39. return '商品链接';
  40. }
  41. return '';
  42. }},
  43. {label: '推广渠道', name: 'promChnName', index: 'promChnName', width: 80, align: 'center'},
  44. {label: '统计', name: 'promStat', index: 'promStat', width: 130, align: 'center'},
  45. {
  46. label: '操作', width: 120, align: 'center', sortable: false, formatter: function (value, col, row) {
  47. let htmlStr = '';
  48. if (row.isFinished == '0') {//已结束
  49. htmlStr = "<button class='btn btn-outline btn-primary' " +
  50. "onclick='vm.showInfo(" + row.promId + ")'><i class='fa fa-qrcode'></i>查看</button>&nbsp;&nbsp;&nbsp;&nbsp;" +
  51. "<button class='btn btn-outline btn-primary' " +
  52. "onclick='vm.delById(" + row.promId + ")'><i class='fa fa-qrcode'></i>删除</button>";
  53. }
  54. if (row.isFinished == '1') {//进行中
  55. htmlStr = "<button class='btn btn-outline btn-primary' " +
  56. "onclick='vm.putOn(" + row.promId + ")'><i class='fa fa-qrcode'></i>投放</button>&nbsp;&nbsp;&nbsp;&nbsp;" +
  57. "<button class='btn btn-outline btn-primary' " +
  58. "onclick='vm.updateFinished(" + row.promId + ")'><i class='fa fa-qrcode'></i>立即结束</button>&nbsp;&nbsp;&nbsp;&nbsp;" +
  59. "<button class='btn btn-outline btn-primary' " +
  60. "onclick='vm.updateById(" + row.promId + ")'><i class='fa fa-qrcode'></i>编辑</button>";
  61. }
  62. if (row.isFinished == '2') {//未开始
  63. htmlStr = "<button class='btn btn-outline btn-primary' " +
  64. "onclick='vm.updateStarted(" + row.promId + ")'><i class='fa fa-qrcode'></i>立即开始</button>&nbsp;&nbsp;&nbsp;&nbsp;" +
  65. "<button class='btn btn-outline btn-primary' " +
  66. "onclick='vm.updateById(" + row.promId + ")'><i class='fa fa-qrcode'></i>编辑</button>";
  67. }
  68. return htmlStr;
  69. }}
  70. // {label: '推广商品', name: 'goodsName', index: 'goodsName', width: 80, align: 'center'},
  71. // {label: '活动分类', name: 'promTypeId', index: 'prom_type_id', width: 80},
  72. // {label: '活动ID', name: 'storeTopicId', index: 'store_topic_id', width: 80},
  73. // {label: '推广url', name: 'promUrl', index: 'prom_url', width: 80},
  74. // {label: '是否投放', name: 'isPut', index: 'is_put', width: 80, align: 'center',
  75. // formatter: function (value) {
  76. // if (value == '0') {
  77. // return '是';
  78. // } else if (value == '1') {
  79. // return '否';
  80. // }
  81. // return '';
  82. // }},
  83. // {label: '浏览量', name: 'browseNum', index: 'browseNum', width: 80, align: 'center'},
  84. // {label: '支付单数', name: 'payOrderNum', index: 'payOrderNum', width: 80, align: 'center'},
  85. // {label: '应收金额', name: 'receivMoney', index: 'receivMoney', width: 80, align: 'center'},
  86. // {label: '是否有效', name: 'isValid', index: 'is_valid', width: 80,
  87. // formatter: function (value) {
  88. // if (value == '0') {
  89. // return '有效';
  90. // } else if (value == '1') {
  91. // return '无效';
  92. // }
  93. // return '';
  94. // }},
  95. // {label: '备注', name: 'note', index: 'note', width: 80},
  96. // {label: '创建人编号', name: 'createrSn', index: 'creater_sn', width: 80},
  97. // {label: '创建时间', name: 'createTime', index: 'create_time', width: 80,
  98. // formatter: function (value) {
  99. // return transDate(value, 'yyyy-MM-dd hh:mm:ss');
  100. // }},
  101. // {label: '修改人编号', name: 'moderSn', index: 'moder_sn', width: 80},
  102. // {label: '修改时间', name: 'modTime', index: 'mod_time', width: 80,
  103. // formatter: function (value) {
  104. // return transDate(value, 'yyyy-MM-dd hh:mm:ss');
  105. // }}
  106. ],
  107. viewrecords: true,
  108. height: 580,
  109. rowNum: 10,
  110. rowList: [10, 30, 50],
  111. rownumbers: true,
  112. rownumWidth: 25,
  113. autowidth: true,
  114. multiselect: false,
  115. pager: "#jqGridPager",
  116. jsonReader: {
  117. root: "page.list",
  118. page: "page.currPage",
  119. total: "page.totalPage",
  120. records: "page.totalCount"
  121. },
  122. prmNames: {
  123. page: "page",
  124. rows: "limit",
  125. order: "order"
  126. },
  127. gridComplete: function () {
  128. $("#jqGrid").closest(".ui-jqgrid-bdiv").css({"overflow-x": "hidden"});
  129. }
  130. });
  131. });
  132. let vm = new Vue({
  133. el: '#rrapp',
  134. data: {
  135. showList: true,
  136. title: null,
  137. mkStoreProm: {},
  138. ruleValidate: {
  139. name: [
  140. {required: true, message: '名称不能为空', trigger: 'blur'}
  141. ]
  142. },
  143. chnlRuleValidate: {
  144. name: [
  145. {required: true, message: '名称不能为空', trigger: 'blur'}
  146. ]
  147. },
  148. q: {
  149. promName: '',
  150. promType: '',
  151. isFinished:'',
  152. storeId:'',
  153. goodsId:''
  154. },
  155. thirdMerchantBizList: [],
  156. goodsList: [],
  157. storeList: [],
  158. isPomTypeBy00: false,
  159. isPomTypeBy10: false,
  160. storeTopicList: [],
  161. promChnlList: [],
  162. mkStorePromChnl: {isValid:0},
  163. showChnlList: true,
  164. storeId: "",
  165. isOperatorShow: false,
  166. showViewList: false,
  167. showInfoList: true,
  168. queryGoodsList:[],
  169. queryStoreList:[]
  170. },
  171. methods: {
  172. query: function () {
  173. vm.reload();
  174. },
  175. add: function () {
  176. vm.showList = false;
  177. vm.showViewList = true;
  178. vm.showInfoList = true;
  179. vm.showChnlList = true;
  180. vm.title = "新增";
  181. vm.thirdMerchantBizList = [];
  182. vm.storeList = [];
  183. vm.goodsList = [];
  184. vm.mkStoreProm = {isPut:1};
  185. vm.isOperatorShow = false;
  186. vm.getThirdMerchantBizList();
  187. },
  188. update: function (event) {
  189. let promId = getSelectedRow();
  190. if (promId == null) {
  191. return;
  192. }
  193. vm.showList = false;
  194. vm.showViewList = true;
  195. vm.showInfoList = true;
  196. vm.showChnlList = true;
  197. vm.title = "修改";
  198. vm.isOperatorShow = true;
  199. vm.getThirdMerchantBizList();
  200. vm.getInfo(promId)
  201. },
  202. saveOrUpdate: function (event) {
  203. let url = vm.mkStoreProm.promId == null ? "../mkstoreprom/save" : "../mkstoreprom/update";
  204. $.ajax({
  205. type: "POST",
  206. url: url,
  207. contentType: "application/json",
  208. data: JSON.stringify(vm.mkStoreProm),
  209. success: function (r) {
  210. if (r.code === 0) {
  211. alert('操作成功', function (index) {
  212. vm.reload();
  213. });
  214. } else {
  215. alert(r.msg);
  216. }
  217. }
  218. });
  219. },
  220. del: function (event) {
  221. let promIds = getSelectedRows();
  222. if (promIds == null){
  223. return;
  224. }
  225. confirm('确定要删除选中的记录?', function () {
  226. $.ajax({
  227. type: "POST",
  228. url: "../mkstoreprom/delete",
  229. contentType: "application/json",
  230. data: JSON.stringify(promIds),
  231. success: function (r) {
  232. if (r.code == 0) {
  233. alert('操作成功', function (index) {
  234. $("#jqGrid").trigger("reloadGrid");
  235. });
  236. } else {
  237. alert(r.msg);
  238. }
  239. }
  240. });
  241. });
  242. },
  243. addPromChnl:function () {
  244. if(vm.mkStoreProm.storeId){
  245. vm.showList = true;
  246. vm.showViewList = true;
  247. vm.showInfoList = true;
  248. vm.showChnlList = false;
  249. vm.title = "新增推广渠道";
  250. vm.mkStorePromChnl = {isValid:0};
  251. vm.getThirdMerchantBizList();
  252. }else {
  253. alert("请先选择所属第三方商户和门店,再进行操作新增推广渠道");
  254. }
  255. },
  256. updateById: function (promId) {
  257. if (promId == null) {
  258. return;
  259. }
  260. vm.showList = false;
  261. vm.showViewList = true;
  262. vm.showChnlList = true;
  263. vm.showInfoList = true;
  264. vm.title = "修改";
  265. vm.isOperatorShow = true;
  266. vm.getThirdMerchantBizList();
  267. vm.getInfo(promId)
  268. },
  269. putOn: function (promId) {
  270. if (promId == null) {
  271. return;
  272. }
  273. $("#qrcodeCanvas").html("");
  274. $.get("../mkstoreprom/qrcodeCanvas/" + promId, function (r) {
  275. // console.log(r.url);
  276. var qrcSrc = r.url;
  277. $("#qrcImg .qrcImg").attr("src", qrcSrc);
  278. $("#qrcodeCanvas").html($("#qrcImg").html());
  279. openWindow({
  280. title: "二维码",
  281. area: ['450px', '450px'],
  282. content: jQuery("#qrcode"),
  283. // btn: ["打印"],
  284. btn1: function (index) {
  285. $("#qrcImg").show();
  286. // $("#qrcImg").print({});
  287. $("#qrcImg").hide();
  288. layer.close(index);
  289. }
  290. });
  291. });
  292. $("#qrcImg").hide();
  293. },
  294. delById: function (promId) {
  295. if (promId == null){
  296. return;
  297. }
  298. var promIds = [promId];
  299. confirm('确定要删除该推广?删除后将不能恢复', function () {
  300. $.ajax({
  301. type: "POST",
  302. url: "../mkstoreprom/delete",
  303. contentType: "application/json",
  304. data: JSON.stringify(promIds),
  305. success: function (r) {
  306. if (r.code == 0) {
  307. alert('操作成功', function (index) {
  308. $("#jqGrid").trigger("reloadGrid");
  309. });
  310. } else {
  311. alert(r.msg);
  312. }
  313. }
  314. });
  315. });
  316. },
  317. updateFinished: function (promId) {
  318. if (promId == null){
  319. return;
  320. }
  321. confirm('结束进行中的活动会影响用户正常购买,建议您提前告知或说明,确定要结束活动吗?', function () {
  322. $.ajax({
  323. type: "POST",
  324. url: "../mkstoreprom/updateFinished",
  325. contentType: "application/json",
  326. data: JSON.stringify(promId),
  327. success: function (r) {
  328. if (r.code == 0) {
  329. alert('操作成功', function (index) {
  330. $("#jqGrid").trigger("reloadGrid");
  331. });
  332. } else {
  333. alert(r.msg);
  334. }
  335. }
  336. });
  337. });
  338. },
  339. updateStarted: function (promId) {
  340. if (promId == null){
  341. return;
  342. }
  343. confirm('开始后,活动立即生效,确定要开始活动吗?', function () {
  344. $.ajax({
  345. type: "POST",
  346. url: "../mkstoreprom/updateStarted",
  347. contentType: "application/json",
  348. data: JSON.stringify(promId),
  349. success: function (r) {
  350. if (r.code == 0) {
  351. alert('操作成功', function (index) {
  352. $("#jqGrid").trigger("reloadGrid");
  353. });
  354. } else {
  355. alert(r.msg);
  356. }
  357. }
  358. });
  359. });
  360. },
  361. showInfo: function(promId){
  362. if(promId == null){
  363. return;
  364. }
  365. vm.title = "查看推广渠道信息"
  366. vm.showList = true;
  367. vm.showViewList = true;
  368. vm.showChnlList = true;
  369. vm.showInfoList = false;
  370. vm.getInfo(promId);
  371. },
  372. getInfo: function(promId){
  373. $.get("../mkstoreprom/info/"+promId, function (r) {
  374. vm.mkStoreProm = r.mkStoreProm;
  375. });
  376. },
  377. getThirdMerchantBizList: function() {
  378. $.get("../thirdmerchantbiz/queryAll", function (r) {
  379. vm.thirdMerchantBizList = r.list;
  380. });
  381. },
  382. changeStore: function (option) {
  383. var thirdMerchSn = option.value;
  384. if(thirdMerchSn){
  385. vm.getStoreList(thirdMerchSn);
  386. }
  387. },
  388. getStoreList: function(thirdMerchSn){
  389. $.get("../store/queryAll?thirdMerchSn=" + thirdMerchSn, function (r) {
  390. vm.storeList = r.list;
  391. });
  392. },
  393. changeGoods: function (option) {
  394. var storeId = option.value;
  395. if(storeId){
  396. vm.storeId = storeId;
  397. vm.getGoodsList(storeId);
  398. vm.getStoreTopicList(storeId);
  399. vm.getPromChnlList(storeId);
  400. }
  401. },
  402. getGoodsList: function(storeId){
  403. if(storeId){
  404. $.get("../productstorerela/queryAll?storeId=" + storeId, function (r) {
  405. vm.goodsList = r.list;
  406. });
  407. }
  408. },
  409. getStoreTopicList: function(storeId){
  410. if(storeId){
  411. $.get("../storetopic/queryAll?storeId=" + storeId, function (r) {
  412. vm.storeTopicList = r.list;
  413. });
  414. }
  415. },
  416. getPromChnlList: function(storeId){
  417. if(storeId){
  418. $.get("../mkstorepromchnl/queryAll?storeId=" + storeId, function (r) {
  419. vm.promChnlList = r.list;
  420. });
  421. }
  422. },
  423. changeProm: function (opt) {
  424. var pomType = opt.value;
  425. if(pomType){
  426. if(pomType == '00'){//活动
  427. vm.isPomTypeBy00 = true;
  428. vm.isPomTypeBy10 = false;
  429. }else{//商品
  430. vm.isPomTypeBy10 = true;
  431. vm.isPomTypeBy00 = false;
  432. }
  433. }
  434. },
  435. queryChangeGoodsByStore: function (storeId) {
  436. if(storeId){
  437. $.get("../productstorerela/queryAll?storeId=" + storeId, function (r) {
  438. vm.queryGoodsList = r.list;
  439. });
  440. }
  441. },
  442. reloadSearch: function() {
  443. vm.q = {
  444. promName: '',
  445. promType: '',
  446. isFinished:'',
  447. storeId:'',
  448. goodsId:''
  449. }
  450. vm.reload();
  451. },
  452. reload: function (event) {
  453. vm.showList = true;
  454. vm.showViewList = false;
  455. vm.showChnlList = true;
  456. vm.showInfoList = true;
  457. let page = $("#jqGrid").jqGrid('getGridParam', 'page');
  458. $("#jqGrid").jqGrid('setGridParam', {
  459. postData: {'promName': vm.q.promName,'promType': vm.q.promType,'isFinished':vm.q.isFinished,
  460. 'storeId':vm.q.storeId,
  461. 'goodsId':vm.q.goodsId},
  462. page: page
  463. }).trigger("reloadGrid");
  464. vm.handleReset('formValidate');
  465. },
  466. reloadChnl: function (event) {
  467. vm.showList = false;
  468. vm.showViewList = true;
  469. vm.showChnlList = true;
  470. vm.showInfoList = true;
  471. $.get("../mkstorepromchnl/queryAll?storeId=" + vm.storeId, function (r) {
  472. vm.promChnlList = r.list;
  473. });
  474. },
  475. handleSubmit: function (name) {
  476. handleSubmitValidate(this, name, function () {
  477. vm.saveOrUpdate()
  478. });
  479. },
  480. handleReset: function (name) {
  481. handleResetForm(this, name);
  482. },
  483. chnlHandleSubmit: function (name) {
  484. handleSubmitValidate(this, name, function () {
  485. vm.saveChnlOrUpdate()
  486. });
  487. },
  488. saveChnlOrUpdate: function (event) {
  489. let url = "../mkstorepromchnl/save";
  490. vm.mkStorePromChnl.storeId = vm.mkStoreProm.storeId;
  491. $.ajax({
  492. type: "POST",
  493. url: url,
  494. contentType: "application/json",
  495. data: JSON.stringify(vm.mkStorePromChnl),
  496. success: function (r) {
  497. if (r.code === 0) {
  498. alert('操作成功', function (index) {
  499. vm.showList = false;
  500. vm.showViewList = true;
  501. vm.showChnlList = true;
  502. vm.showInfoList = true;
  503. $.get("../mkstorepromchnl/queryAll?storeId=" + vm.storeId, function (r) {
  504. vm.promChnlList = r.list;
  505. });
  506. });
  507. } else {
  508. alert(r.msg);
  509. }
  510. }
  511. });
  512. }
  513. },
  514. mounted() {
  515. $.get("../store/queryAll", function (r) {
  516. vm.queryStoreList = r.list;
  517. });
  518. }
  519. });