mkstoreticketdiscount.js 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051
  1. $(function () {
  2. $("#jqGrid").jqGrid({
  3. url: '../mkstoreticketdiscount/list',
  4. datatype: "json",
  5. colModel: [
  6. {label: 'tickDiscId', name: 'tickDiscId', index: 'tick_disc_id', key: true, hidden: true},
  7. {label: '优惠券名称', name: 'name', index: 'name', width: 80, align: 'center'},
  8. // {label: '优惠券副标题', name: 'tickDiscSubTitle', index: 'tick_disc_sub_title', width: 80},
  9. {label: '优惠类型', name: 'tickDiscType', index: 'tick_disc_type', width: 60, align: 'center',
  10. formatter: function (value) {
  11. if (value == '00') {
  12. return '代金券';
  13. } else if (value == '01') {
  14. return '折扣券';
  15. } else if (value == '02') {
  16. return '兑换券';
  17. }
  18. return '';
  19. }},
  20. // {label: '商户编号', name: 'merchSn', index: 'merch_sn', width: 80},
  21. // {label: '第三方商户id', name: 'thirdMerchSn', index: 'third_merch_sn', width: 80},
  22. {label: '所属门店', name: 'storeName', index: 'storeName', width: 80, align: 'center'},
  23. // {label: '活动id', name: 'storeTopicId', index: 'store_topic_id', width: 80},
  24. // {label: '代金券减免金额(元)', name: 'voucherMoney', index: 'voucher_money', width: 80},
  25. // {label: '代金券使用条件(元)', name: 'voucherCond', index: 'voucher_cond', width: 80},
  26. // {label: '折扣券折扣(折)', name: 'discRatio', index: 'disc_ratio', width: 80},
  27. // {label: '折扣券使用条件(元)', name: 'discCond', index: 'disc_cond', width: 80},
  28. // {label: '兑换券使用条件(元)', name: 'exchCond', index: 'exch_cond', width: 80},
  29. // {label: '生效时间类型', name: 'effectTimeType', index: 'effect_time_type', width: 80, align: 'center',
  30. // formatter: function (value) {
  31. // if (value == '00') {
  32. // return '固定时间';
  33. // } else if (value == '01') {
  34. // return '领取后生效';
  35. // }
  36. // return '';
  37. // }},
  38. {label: '有效时间', name: 'inValidTime', index: 'inValidTime', width: 120, align: 'center'},
  39. {label: '状态', name: 'isPast', index: 'isPast', width: 60, align: 'center',
  40. formatter: function (value) {
  41. if (value == '0') {
  42. return '<span style="font-weight: bolder;background: #58d44d;color: white">进行中</span>';
  43. } else if (value == '1') {
  44. return '<span style="font-weight: bolder;background: #B2AEBC;color: white;">已结束</span>';
  45. } else if (value == '2') {
  46. return '<span style="font-weight: bolder;background: red;color: white">未开始</span>';
  47. }
  48. return '';
  49. }},
  50. // {label: '固定开始时间', name: 'fixBegTime', index: 'fix_beg_time', width: 80},
  51. // {label: '固定结束时间', name: 'fixEndTime', index: 'fix_end_time', width: 80},
  52. // {label: '领券延期生效天数(天)', name: 'postponeNum', index: 'postpone_num', width: 80},
  53. // {label: '领券使用有效天数(天)', name: 'validDayNum', index: 'valid_day_num', width: 80},
  54. {label: '库存', name: 'ticketNum', index: 'ticket_num', width: 60, align: 'center'},
  55. // {label: '适用类型', name: 'applyType', index: 'apply_type', width: 80, align: 'center',
  56. // formatter: function (value) {
  57. // if (value == '00') {
  58. // return '全部商品参与';
  59. // } else if (value == '01') {
  60. // return '指定商品参与';
  61. // } else if (value == '02') {
  62. // return '指定商品不参与';
  63. // }
  64. // return '';
  65. // }},
  66. {label: '是否有效', name: 'isValid', index: 'is_valid', width: 60, align: 'center',
  67. formatter: function (value) {
  68. if (value == '0') {
  69. return '有效';
  70. } else if (value == '1') {
  71. return '无效';
  72. }
  73. return '';
  74. }},
  75. {
  76. label: '操作', width: 180, align: 'center', sortable: false, formatter: function (value, col, row) {
  77. let htmlStr = "";
  78. // if (hasPermission('order:refund')) {}
  79. if(row.isPast != 1 && row.isValid == 0){
  80. htmlStr = "<button class='btn btn-outline btn-primary' " +
  81. "onclick='vm.showInfo(" + row.tickDiscId + ")'><i class='fa fa-qrcode'></i>详情</button>&nbsp;&nbsp;&nbsp;&nbsp;" +
  82. "<button class='btn btn-outline btn-primary' " +
  83. "onclick='vm.updateById(" + row.tickDiscId + ")'><i class='fa fa-qrcode'></i>修改</button>&nbsp;&nbsp;&nbsp;&nbsp;"/* +
  84. TODO req_hidden_20200610
  85. "<button class='btn btn-outline btn-primary' " +
  86. "onclick='vm.putOn(" + row.tickDiscId + ")'><i class='fa fa-qrcode'></i>投放</button>&nbsp;&nbsp;&nbsp;&nbsp;" +
  87. "<button class='btn btn-outline btn-primary' " +
  88. "onclick='vm.getUserCoupon(" + row.tickDiscId + ")'><i class='fa fa-qrcode'></i>码库</button>"*/;
  89. }
  90. if(row.isPast == 1 || row.isValid == 1){
  91. htmlStr = "<button class='btn btn-outline btn-primary' " +
  92. "onclick='vm.showInfo(" + row.tickDiscId + ")'><i class='fa fa-qrcode'></i>详情</button>&nbsp;&nbsp;&nbsp;&nbsp;"/*+
  93. TODO req_hidden_20200610
  94. "<button class='btn btn-outline btn-primary' " +
  95. "onclick='vm.getUserCoupon(" + row.tickDiscId + ")'><i class='fa fa-qrcode'></i>码库</button>"*/;
  96. }
  97. return htmlStr;
  98. }}
  99. // {label: '领取入口,格式:1,2,...,n,【get_enter,1:商品详情页/购物车等商城页面】', name: 'getEnter', index: 'get_enter', width: 80},
  100. // {label: '能否分享领取', name: 'canShareGet', index: 'can_share_get', width: 80, align: 'center',
  101. // formatter: function (value) {
  102. // if (value == '0') {
  103. // return '能';
  104. // } else if (value == '1') {
  105. // return '否';
  106. // }
  107. // return '';
  108. // }},
  109. // {label: '每人限领数', name: 'limitNum', index: 'limit_num', width: 80},
  110. // {label: '活动图片url(小图)', name: 'advImgUrl', index: 'adv_img_url', width: 80},
  111. // {label: '门店logo图url', name: 'storeLogoUrl', index: 'store_logo_url', width: 80},
  112. // {label: '门店名称', name: 'storeName', index: 'store_name', width: 80},
  113. // {label: '券面颜色,如:#ababab', name: 'ticketColor', index: 'ticket_color', width: 80},
  114. // {label: '操作说明', name: 'optDecl', index: 'opt_decl', width: 80},
  115. // {label: '优惠说明', name: 'discDecl', index: 'disc_decl', width: 80},
  116. // {label: '使用须知', name: 'useNoti', index: 'use_noti', width: 80},
  117. // {label: '客服电话,手机或固话', name: 'svrTel', index: 'svr_tel', width: 80},
  118. // {label: '备注', name: 'note', index: 'note', width: 80},
  119. // {label: '创建人编号', name: 'createrSn', index: 'creater_sn', width: 80},
  120. // {label: '创建时间', name: 'createTime', index: 'create_time', width: 80},
  121. // {label: '修改人编号', name: 'moderSn', index: 'moder_sn', width: 80},
  122. // {label: '修改时间', name: 'modTime', index: 'mod_time', width: 80},
  123. // {label: '时间戳', name: 'tstm', index: 'tstm', width: 80},
  124. // {label: '发放方式 0:按订单发放 1:按用户发放(通用优惠券,用户点击领取) 2:商品转发送券 3:按商品发放 4:新用户注册 5:线下发放 6评价好评红包(固定或随机红包) 7包邮(不入会员优惠券表)', name: 'sendType', index: 'send_type', width: 80}
  125. ],
  126. viewrecords: true,
  127. height: 580,
  128. rowNum: 10,
  129. rowList: [10, 30, 50],
  130. rownumbers: true,
  131. rownumWidth: 25,
  132. autowidth: true,
  133. multiselect: true,
  134. pager: "#jqGridPager",
  135. jsonReader: {
  136. root: "page.list",
  137. page: "page.currPage",
  138. total: "page.totalPage",
  139. records: "page.totalCount"
  140. },
  141. prmNames: {
  142. page: "page",
  143. rows: "limit",
  144. order: "order"
  145. },
  146. gridComplete: function () {
  147. $("#jqGrid").closest(".ui-jqgrid-bdiv").css({"overflow-x": "hidden"});
  148. }
  149. });
  150. $("#jqGridOrder").jqGrid({
  151. url: '../usercoupon/getUserCouponByDiscIdList',
  152. datatype: "json",
  153. colModel: [
  154. {label: '所属门店', name: 'storeName', index: 'storeName', width: 80, align: 'center'},
  155. {label: '优惠券码', name: 'couponNumber', index: 'couponNumber', width: 80, align: 'center'},
  156. {label: '领取人', name: 'nickname', index: 'nickname', width: 60, align: 'center'},
  157. {label: '领取时间', name: 'addTime', index: 'add_time', width: 120, align: 'center',
  158. formatter: function (value) {
  159. // console.log(value);
  160. return transDate(value, 'yyyy-MM-dd hh:mm:ss');
  161. }
  162. },
  163. {label: '生效时间', name: 'validTime', index: 'validTime', width: 120, align: 'center',
  164. formatter: function (value) {
  165. // console.log(value);
  166. return transDate(value, 'yyyy-MM-dd hh:mm:ss');
  167. }
  168. },
  169. {label: '更新时间', name: 'modTime', index: 'modTime', width: 120, align: 'center',
  170. formatter: function (value) {
  171. // console.log(value);
  172. return transDate(value, 'yyyy-MM-dd hh:mm:ss');
  173. }
  174. },
  175. {label: '失效时间', name: 'endTime', index: 'endTime', width: 120, align: 'center',
  176. formatter: function (value) {
  177. // console.log(value);
  178. return transDate(value, 'yyyy-MM-dd hh:mm:ss');
  179. }
  180. },
  181. {label: '状态', name: 'isUsed', index: 'isUsed', width: 60, align: 'center',
  182. formatter: function (value) {
  183. if (value == '0') {
  184. return '未使用';
  185. } else if (value == '1') {
  186. return '已使用';
  187. }
  188. return value;
  189. }
  190. }
  191. ],
  192. viewrecords: true,
  193. height: 400,
  194. width:1600,
  195. rowNum: 10,
  196. rowList: [10, 30, 50],
  197. rownumbers: true,
  198. rownumWidth: 25,
  199. autowidth: false,
  200. multiselect: true,
  201. pager: "#jqGridPagerOrder",
  202. jsonReader: {
  203. root: "page.list",
  204. page: "page.currPage",
  205. total: "page.totalPage",
  206. records: "page.totalCount"
  207. },
  208. prmNames: {
  209. page: "page",
  210. rows: "limit",
  211. order: "order"
  212. },
  213. gridComplete: function () {
  214. $("#jqGridOrder").closest(".ui-jqgrid-bdiv").css({"overflow-x": "hidden"});
  215. }
  216. });
  217. });
  218. let vm = new Vue({
  219. el: '#rrapp',
  220. data: {
  221. title: null,
  222. mkStoreTicketDiscount: {advImgUrl: '', storeLogoUrl: ''},
  223. ruleValidate: {
  224. name: [
  225. {required: true, message: '名称不能为空', trigger: 'blur'}
  226. ]
  227. },
  228. q: {
  229. name: ''
  230. },
  231. g: {
  232. goodsName: ''
  233. },
  234. thirdMerchantBizList: [],
  235. goodsList: [],
  236. storeList: [],
  237. isVoucher: true,//代金券
  238. isDisc: false,//折扣券
  239. isExch: false,//兑换券
  240. isEffectTimeType00:true,//固定时间
  241. isEffectTimeType01: false,//领取后生效
  242. isApplyType: false,//商品是否显示
  243. storeId: '',
  244. value3: false,
  245. productStoreRela: {},
  246. currentPage: 1,
  247. limit:16,
  248. totalPage:'',
  249. totalCount:'',
  250. checkGoodsByHtmlList:[],//选择商品前端储存的数组
  251. mkStoreTicketDiscountGoods:{checkGoodsList:[]},
  252. applyType:'',
  253. checkGoodsDataList:[],//选择完商品后查询的商品列表
  254. checkGoodsTotalCount: 0,
  255. checkGoodsLimit: 6,
  256. checkGoodsCurrentPage:1,
  257. tid:'',//唯一id
  258. ticketColor: '',
  259. queryColorList:[{color:'00CC00',back:'g'},{color:'009900',back:'g'},{color:'66CCCC',back:'g'},{color:'009999',back:'g'},
  260. {color:'FF9966',back:'r'},{color:'FF0066',back:'r'},{color:'CC00FF',back:'r'},{color:'CC0000',back:'r'}],
  261. colorList:[],
  262. isOperatorShow: false,
  263. showList: true,
  264. showViewList: false,
  265. showInfoList: true,
  266. showOrderList: true,
  267. tickDiscId:'',
  268. macros: [],
  269. goodsBizType:'',
  270. c:{
  271. isUsed: ''
  272. },
  273. tickDiscType:''
  274. },
  275. methods: {
  276. getColor: function (value,isColor) {
  277. vm.ticketColor = '#'+value;
  278. var classValue = 'tick-color-g';
  279. if(isColor == 'g'){
  280. classValue = 'tick-color-g';
  281. }else {
  282. classValue = 'tick-color-r';
  283. }
  284. if($("#"+value).attr('name')=='noCheck') {
  285. $("#" + value).attr("class", classValue);
  286. $("#" + value).attr("name", "check");
  287. vm.colorList.push(value);
  288. for (var g = 0; g < vm.queryColorList.length; g++) {
  289. if (value != vm.queryColorList[g].color) {
  290. $("#" + vm.queryColorList[g].color).attr("class", "");
  291. vm.colorList.remove(vm.queryColorList[g].color);
  292. $("#"+ vm.queryColorList[g].color).attr("name","noCheck");
  293. }else{
  294. $("#"+ vm.queryColorList[g].color).attr("name","check");
  295. }
  296. }
  297. }else{
  298. $("#"+value).attr("class","");
  299. $("#"+value).attr("name","noCheck");
  300. // console.log(vm.colorList);
  301. for (var g = 0; g < vm.colorList.length; g++) {
  302. if(value == vm.colorList[g]){
  303. vm.colorList.remove(vm.colorList[g]);
  304. }
  305. }
  306. }
  307. // console.log(value);
  308. // console.log(vm.colorList);
  309. if(vm.colorList.length > 0){
  310. vm.ticketColor = "#"+vm.colorList[0];
  311. }else{
  312. vm.ticketColor = "";
  313. }
  314. },
  315. query: function () {
  316. vm.reload();
  317. },
  318. /**
  319. * 生成唯一id
  320. * @returns {string}
  321. */
  322. guid: function () {
  323. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
  324. var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
  325. return v.toString(16);
  326. });
  327. },
  328. /**
  329. * 选择指定商品ok按钮
  330. */
  331. ok : function () {
  332. // this.$Message.info('Clicked ok');
  333. vm.checkGoodsDataList =[];
  334. vm.mkStoreTicketDiscountGoods.checkGoodsList = vm.checkGoodsByHtmlList;
  335. vm.mkStoreTicketDiscountGoods.guid = vm.tid;
  336. vm.mkStoreTicketDiscountGoods.isSubmit = 0;//ok按钮提交的数据则为0
  337. $.ajax({
  338. type: "POST",
  339. url: '../mkstoreticketgoodstemp/batchSaveDiscountGoods',
  340. contentType: "application/json",
  341. data: JSON.stringify(vm.mkStoreTicketDiscountGoods),
  342. success: function (r) {
  343. if (r.code === 0) {
  344. vm.getCheckGoodsList(vm.storeId);
  345. } else {
  346. alert(r.msg);
  347. }
  348. }
  349. });
  350. },
  351. /**
  352. * 选择指定商品cancel按钮
  353. */
  354. cancel: function () {
  355. vm.checkGoodsByHtmlList =[];
  356. // console.log(vm.checkGoodsByHtmlList);
  357. //点击取消按钮如有分页记录的数据就删除
  358. vm.mkStoreTicketDiscountGoods.checkGoodsList=vm.checkGoodsByHtmlList;
  359. vm.mkStoreTicketDiscountGoods.guid=vm.tid;
  360. vm.mkStoreTicketDiscountGoods.isSubmit = 1;//cancel按钮提交的数据则为1
  361. $.ajax({
  362. type: "POST",
  363. url: '../mkstoreticketgoodstemp/batchSaveDiscountGoods',
  364. contentType: "application/json",
  365. data: JSON.stringify(vm.mkStoreTicketDiscountGoods),
  366. success: function (r) {
  367. if (r.code === 0) {
  368. } else {
  369. alert(r.msg);
  370. }
  371. }
  372. });
  373. },
  374. /**
  375. * 指定商品分页
  376. */
  377. loadGoodsDataByPage: function (value) {
  378. vm.currentPage = value;
  379. vm.mkStoreTicketDiscountGoods.checkGoodsList=vm.checkGoodsByHtmlList;
  380. vm.mkStoreTicketDiscountGoods.guid=vm.tid;
  381. vm.mkStoreTicketDiscountGoods.isSubmit = 1;//分页记录的数据则为1
  382. $.ajax({
  383. type: "POST",
  384. url: '../mkstoreticketgoodstemp/batchSaveDiscountGoods',
  385. contentType: "application/json",
  386. data: JSON.stringify(vm.mkStoreTicketDiscountGoods),
  387. success: function (r) {
  388. if (r.code === 0) {
  389. } else {
  390. alert(r.msg);
  391. }
  392. }
  393. });
  394. vm.getGoodsList(vm.storeId);
  395. },
  396. handlePageSize: function (value) {
  397. vm.limit = value;
  398. vm.currentPage = 1;
  399. vm.getGoodsList(vm.storeId);
  400. },
  401. /**
  402. * 已选中商品分页
  403. * @param value
  404. */
  405. loadCheckGoodsDataByPage: function (value) {
  406. vm.checkGoodsCurrentPage = value;
  407. vm.getCheckGoodsList(vm.storeId);
  408. },
  409. /**
  410. * 已选中商品分页
  411. * @param value
  412. */
  413. handleCheckGoodsPageSize: function (value) {
  414. vm.checkGoodsLimit = value;
  415. vm.checkGoodsCurrentPage = 1;
  416. vm.getCheckGoodsList(vm.storeId);
  417. },
  418. /**
  419. * 获取已选中商品
  420. * @param storeId
  421. */
  422. getCheckGoodsList: function(storeId){
  423. if(storeId){
  424. $.get("../mkstoreticketgoodstemp/queryAllDiscountByStoreId?storeId=" + vm.storeId+"&guid="+vm.tid+"&page="+vm.checkGoodsCurrentPage+"&limit="+vm.checkGoodsLimit, function (r) {
  425. if(r.code == 0){
  426. vm.checkGoodsDataList = r.page.list;
  427. // vm.totalPage = r.page.totalPage;
  428. vm.checkGoodsTotalCount = r.page.totalCount;
  429. vm.checkGoodsCurrentPage = r.page.currPage;
  430. vm.checkGoodsLimit = r.page.pageSize;
  431. }
  432. });
  433. }
  434. },
  435. /**
  436. * 删除已选中商品
  437. * @param discGoodTempId
  438. * @param goodsId
  439. */
  440. delCheckGoods: function (discGoodTempId,goodsId) {
  441. var checkGoodsIds = [discGoodTempId];
  442. $.ajax({
  443. type: "POST",
  444. url: "../mkstoreticketgoodstemp/updateIsValidById",
  445. contentType: "application/json",
  446. data: JSON.stringify(checkGoodsIds),
  447. success: function (r) {
  448. if (r.code == 0) {
  449. vm.getCheckGoodsList(vm.storeId);
  450. for (var g = 0; g < vm.checkGoodsByHtmlList.length; g++) {
  451. if(goodsId == vm.checkGoodsByHtmlList[g].goodsId){
  452. vm.checkGoodsByHtmlList.remove(vm.checkGoodsByHtmlList[g]);
  453. }
  454. }
  455. } else {
  456. alert(r.msg);
  457. }
  458. }
  459. });
  460. },
  461. /**
  462. * 生效时间类型联动
  463. * @param value
  464. */
  465. changeEffectTimeType: function (value) {
  466. if(value == '00'){
  467. vm.isEffectTimeType00 = true;
  468. vm.isEffectTimeType01 = false;
  469. }else if(value == '01'){
  470. vm.isEffectTimeType00 = false;
  471. vm.isEffectTimeType01 = true;
  472. }
  473. },
  474. /**
  475. * 适用商品联动
  476. * @param value
  477. */
  478. changeApplyType: function (value) {
  479. // vm.storeId = '8';
  480. console.log(vm.goodsBizType)
  481. if(value == '00'){
  482. vm.isApplyType = false;
  483. }else if(value == '01'){
  484. console.log(vm.storeId=='')
  485. if(vm.storeId==''){
  486. alert("请先在基本属性中选择所属门店");
  487. vm.mkStoreTicketDiscount.applyType = '00';
  488. }else if(vm.goodsBizType==''){
  489. alert("请先在基本属性中选择所属商品业务类型");
  490. vm.mkStoreTicketDiscount.applyType = '00';
  491. }else if(vm.storeId && vm.goodsBizType){
  492. vm.isApplyType = true;
  493. vm.applyType ='01';
  494. // vm.getCheckGoodsList(vm.storeId);
  495. }
  496. }else if(value == '02'){
  497. if(vm.storeId == ''){
  498. alert("请先在基本属性中选择所属门店");
  499. vm.mkStoreTicketDiscount.applyType = '00';
  500. }
  501. if(vm.goodsBizType == ''){
  502. alert("请先在基本属性中选择所属商品业务类型");
  503. vm.mkStoreTicketDiscount.applyType = '00';
  504. }
  505. if(vm.storeId && vm.goodsBizType){
  506. vm.isApplyType = true;
  507. vm.applyType ='02';
  508. }
  509. }
  510. },
  511. /**
  512. * 选择商品弹框按钮
  513. */
  514. checkGoods: function () {
  515. vm.value3 = true;
  516. vm.limit = 16;
  517. vm.getGoodsList(vm.storeId,vm.goodsBizType);
  518. },
  519. /**
  520. * 选择商品参数查询
  521. */
  522. reloadGoodsByStore: function (){
  523. if(vm.storeId){
  524. vm.getGoodsList(vm.storeId,vm.goodsBizType);
  525. }else{
  526. alert("请先在基本属性中选择所属门店");
  527. }
  528. },
  529. /**
  530. * 选择商品重置参数查询
  531. */
  532. reloadGoodsSearch: function (){
  533. if(vm.storeId){
  534. vm.g.goodsName='';
  535. vm.getGoodsList(vm.storeId,vm.goodsBizType);
  536. }else{
  537. alert("请先在基本属性中选择所属门店");
  538. }
  539. },
  540. /**
  541. * 查询选择商品分页
  542. * @param storeId
  543. */
  544. getGoodsList: function(storeId,goodsBizType){
  545. if(storeId){
  546. $.get("../productstorerela/queryGoodsRealListByDiscountTid?storeId=" + storeId+"&goodsName="+vm.g.goodsName+"&guid="+vm.tid+"&applyType="+vm.applyType+"&goodsBizType="+goodsBizType
  547. +"&promTypeId="+6+"&page="+1+"&limit="+vm.limit, function (r) {
  548. // console.log(r)
  549. if(r.code == 0){
  550. vm.goodsList = r.page.list;
  551. vm.totalPage = r.page.totalPage;
  552. vm.totalCount = r.page.totalCount;
  553. vm.currentPage = r.page.currPage;
  554. vm.limit = r.page.pageSize;
  555. }
  556. });
  557. }
  558. },
  559. /**
  560. * 商品选中
  561. * @param item 商品信息
  562. */
  563. selectThisGoods: function (item) {
  564. // $.get("../mkstoreticketgoodstemp/queryGoodsTempByGuidAndSubmit?storeId="+vm.storeId+"&guid="+vm.tid+"&applyType="+vm.applyType, function (r) {
  565. // for(var j=0;j<r.list.length;j++){
  566. // vm.checkGoodsByHtmlList.push(r.list[j]);
  567. // }
  568. // });
  569. if(item.isCheck==0){
  570. for(var i = 0; i < vm.goodsList.length; i++){
  571. if(vm.goodsList[i].goodsId == item.goodsId){
  572. vm.goodsList[i].isCheck = 1;
  573. }
  574. }
  575. vm.checkGoodsByHtmlList.push({goodsId: item.goodsId, storeRealId: item.id, goodsName: item.goodsName, applyType: vm.applyType, guid:vm.tid, discGoodTempId:item.discGoodTempId});
  576. }else{
  577. for(var i = 0; i < vm.goodsList.length; i++){
  578. if(vm.goodsList[i].goodsId == item.goodsId){
  579. vm.goodsList[i].isCheck = 0;
  580. }
  581. }
  582. for (var g = 0; g < vm.checkGoodsByHtmlList.length; g++) {
  583. if(item.goodsId == vm.checkGoodsByHtmlList[g].goodsId){
  584. vm.checkGoodsByHtmlList.remove(vm.checkGoodsByHtmlList[g]);
  585. }
  586. }
  587. //删除取消选中的商品
  588. vm.mkStoreTicketDiscountGoods.storeRelaId=item.id;
  589. vm.mkStoreTicketDiscountGoods.guid=vm.tid;
  590. $.ajax({
  591. type: "POST",
  592. url: '../mkstoreticketgoodstemp/updateTempByIsValid',
  593. contentType: "application/json",
  594. data: JSON.stringify(vm.mkStoreTicketDiscountGoods),
  595. success: function (r) {
  596. }
  597. });
  598. }
  599. },
  600. add: function () {
  601. vm.tid = vm.guid();
  602. vm.storeId = '';
  603. vm.tickDiscId = '';
  604. vm.goodsBizType = '';
  605. vm.applyType = '';
  606. vm.isApplyType = false;
  607. vm.showList = false;
  608. vm.showViewList = true;
  609. vm.showInfoList = true;
  610. vm.showOrderList = true;
  611. vm.title = "新增";
  612. vm.thirdMerchantBizList = [];
  613. vm.storeList = [];
  614. vm.goodsList = [];
  615. // vm.macros = [];
  616. vm.checkGoodsDataList = [];
  617. vm.checkGoodsByHtmlList = [];
  618. vm.checkGoodsTotalCount = 0;
  619. vm.mkStoreTicketDiscount = {tickDiscType:'00',effectTimeType:'00',applyType:'00',getEnter:'1',isValid:'0',isStoreShow:'0', advImgUrl: '', storeLogoUrl: '',limitNum:'',discDecl:'',useNoti:'',
  620. fixBegTime:'',fixEndTime:'',thirdMerchSn:'',storeId:''};
  621. vm.getThirdMerchantBizList();
  622. vm.isOperatorShow = false;
  623. vm.getColor('00CC00','g');
  624. },
  625. update: function (event) {
  626. let tickDiscId = getSelectedRow();
  627. if (tickDiscId == null) {
  628. return;
  629. }
  630. vm.showList = false;
  631. vm.showViewList = true;
  632. vm.showInfoList = true;
  633. vm.showOrderList = true;
  634. vm.title = "修改";
  635. vm.getThirdMerchantBizList();
  636. vm.getInfo(tickDiscId);
  637. vm.isOperatorShow = true;
  638. },
  639. updateById: function (tickDiscId) {
  640. if (tickDiscId == null) {
  641. return;
  642. }
  643. vm.showList = false;
  644. vm.showViewList = true;
  645. vm.showInfoList = true;
  646. vm.showOrderList = true;
  647. vm.title = "修改";
  648. vm.getThirdMerchantBizList();
  649. vm.getInfo(tickDiscId);
  650. vm.isOperatorShow = true;
  651. },
  652. showInfo: function(tickDiscId){
  653. if(tickDiscId == null){
  654. return;
  655. }
  656. vm.title = "查看优惠券信息";
  657. vm.showList = true;
  658. vm.showViewList = true;
  659. vm.showOrderList = true;
  660. vm.showInfoList = false;
  661. vm.getShowInfo(tickDiscId);
  662. },
  663. putOn: function (tickDiscId) {
  664. if (tickDiscId == null) {
  665. return;
  666. }
  667. $("#qrcodeCanvas").html("");
  668. $.get("../mkstoreticketdiscount/qrcodeCanvasByTickDiscId/" + tickDiscId, function (r) {
  669. // console.log(r.url);
  670. var qrcSrc = r.url;
  671. $("#qrcImg .qrcImg").attr("src", qrcSrc);
  672. $("#qrcodeCanvas").html($("#qrcImg").html());
  673. openWindow({
  674. title: "二维码",
  675. area: ['450px', '450px'],
  676. content: jQuery("#qrcode"),
  677. // btn: ["打印"],
  678. btn1: function (index) {
  679. $("#qrcImg").show();
  680. // $("#qrcImg").print({});
  681. $("#qrcImg").hide();
  682. layer.close(index);
  683. }
  684. });
  685. });
  686. $("#qrcImg").hide();
  687. },
  688. getUserCoupon: function (tickDiscId) {
  689. if (tickDiscId == null) {
  690. return;
  691. }
  692. $.get("../mkstoreticketdiscount/info/"+tickDiscId, function (r) {
  693. vm.title = r.mkStoreTicketDiscount.name+"码库";
  694. vm.showList = true;
  695. vm.showViewList = true;
  696. vm.showInfoList = true;
  697. vm.tickDiscId = tickDiscId;
  698. vm.showOrderList = false;
  699. let page = $("#jqGridOrder").jqGrid('getGridParam', 'page');
  700. $("#jqGridOrder").jqGrid('setGridParam', {
  701. postData: {'isUsed': vm.c.isUsed, 'tickDiscId': tickDiscId},
  702. page: page
  703. }).trigger("reloadGrid");
  704. });
  705. },
  706. queryOrder: function () {
  707. vm.reloadOrder();
  708. },
  709. reloadOrderSearch: function() {
  710. vm.c = {
  711. isUsed: ''
  712. }
  713. vm.reloadOrder();
  714. },
  715. reloadOrder: function () {
  716. let page = $("#jqGridOrder").jqGrid('getGridParam', 'page');
  717. $("#jqGridOrder").jqGrid('setGridParam', {
  718. postData: {'isUsed': vm.c.isUsed, 'tickDiscId': vm.tickDiscId},
  719. page: page
  720. }).trigger("reloadGrid");
  721. },
  722. saveOrUpdate: function (event) {
  723. let url = vm.mkStoreTicketDiscount.tickDiscId == null ? "../mkstoreticketdiscount/save" : "../mkstoreticketdiscount/update";
  724. if(vm.ticketColor != '' && vm.ticketColor != null){
  725. vm.mkStoreTicketDiscount.ticketColor = vm.ticketColor;
  726. }else{
  727. vm.mkStoreTicketDiscount.ticketColor = "#00CC00";
  728. }
  729. vm.mkStoreTicketDiscount.guid = vm.tid;
  730. $.ajax({
  731. type: "POST",
  732. url: url,
  733. contentType: "application/json",
  734. data: JSON.stringify(vm.mkStoreTicketDiscount),
  735. success: function (r) {
  736. if (r.code === 0) {
  737. alert('操作成功', function (index) {
  738. vm.reload();
  739. });
  740. } else {
  741. alert(r.msg);
  742. }
  743. }
  744. });
  745. },
  746. del: function (event) {
  747. let tickDiscIds = getSelectedRows();
  748. if (tickDiscIds == null){
  749. return;
  750. }
  751. confirm('确定要删除选中的记录?', function () {
  752. $.ajax({
  753. type: "POST",
  754. url: "../mkstoreticketdiscount/delete",
  755. contentType: "application/json",
  756. data: JSON.stringify(tickDiscIds),
  757. success: function (r) {
  758. if (r.code == 0) {
  759. alert('操作成功', function (index) {
  760. $("#jqGrid").trigger("reloadGrid");
  761. });
  762. } else {
  763. alert(r.msg);
  764. }
  765. }
  766. });
  767. });
  768. },
  769. getInfo: function(tickDiscId){
  770. $.get("../mkstoreticketdiscount/info/"+tickDiscId, function (r) {
  771. vm.mkStoreTicketDiscount = r.mkStoreTicketDiscount;
  772. vm.storeId = r.mkStoreTicketDiscount.storeId;
  773. vm.tid = r.mkStoreTicketDiscount.guid;
  774. vm.tickDiscId = r.mkStoreTicketDiscount.tickDiscId;
  775. vm.goodsBizType = r.mkStoreTicketDiscount.goodsBizType;
  776. vm.changeApplyType(r.mkStoreTicketDiscount.applyType);
  777. vm.changeEffectTimeType(r.mkStoreTicketDiscount.effectTimeType);
  778. vm.getCheckGoodsList(r.mkStoreTicketDiscount.storeId);
  779. var ticketColor = r.mkStoreTicketDiscount.ticketColor.substring(1, r.mkStoreTicketDiscount.ticketColor.length);
  780. var back = '';
  781. for (var g = 0; g < vm.queryColorList.length; g++) {
  782. if (ticketColor == vm.queryColorList[g].color) {
  783. back = vm.queryColorList[g].back;
  784. }
  785. }
  786. vm.getColor(ticketColor, back);
  787. });
  788. },
  789. getShowInfo: function(tickDiscId){
  790. $.get("../mkstoreticketdiscount/info/"+tickDiscId, function (r) {
  791. vm.mkStoreTicketDiscount = r.mkStoreTicketDiscount;
  792. vm.storeId = r.mkStoreTicketDiscount.storeId;
  793. vm.tid = r.mkStoreTicketDiscount.guid;
  794. vm.goodsBizType = r.mkStoreTicketDiscount.goodsBizType;
  795. vm.changeApplyType(r.mkStoreTicketDiscount.applyType);
  796. vm.getCheckGoodsList(r.mkStoreTicketDiscount.storeId);
  797. var ticketColor = r.mkStoreTicketDiscount.ticketColor.substring(1, r.mkStoreTicketDiscount.ticketColor.length);
  798. var back = '';
  799. for (var g = 0; g < vm.queryColorList.length; g++) {
  800. if (ticketColor == vm.queryColorList[g].color) {
  801. back = vm.queryColorList[g].back;
  802. }
  803. }
  804. $("#ticketColorId").css("background-color", r.mkStoreTicketDiscount.ticketColor);
  805. if(back == 'g'){
  806. $("#ticketColorId").attr("class", 'tick-color-g');
  807. }else{
  808. $("#ticketColorId").attr("class", 'tick-color-r');
  809. }
  810. vm.changeEffectTimeType(r.mkStoreTicketDiscount.effectTimeType);
  811. });
  812. },
  813. getThirdMerchantBizList: function() {
  814. $.get("../thirdmerchantbiz/queryAll", function (r) {
  815. vm.thirdMerchantBizList = r.list;
  816. });
  817. },
  818. changeStore: function (option) {
  819. var thirdMerchSn = option.value;
  820. if(thirdMerchSn){
  821. vm.getStoreList(thirdMerchSn);
  822. }
  823. },
  824. getStoreList: function(thirdMerchSn){
  825. $.get("../store/queryAll?thirdMerchSn=" + thirdMerchSn, function (r) {
  826. vm.storeList = r.list;
  827. });
  828. },
  829. changeGoods: function (option) {
  830. var storeId = option.value;
  831. if(storeId){
  832. vm.storeId = storeId;
  833. }
  834. },
  835. changeGoodsBizType: function(opt) {
  836. var goodsBizType = opt.value;
  837. if(goodsBizType){
  838. vm.goodsBizType = goodsBizType;
  839. }
  840. },
  841. chanTick: function (value) {
  842. if(value == '00'){
  843. vm.isVoucher = true;
  844. vm.isDisc = false;
  845. vm.isExch = false;
  846. vm.tickDiscType = '00';
  847. }else if(value == '01'){
  848. vm.isVoucher = false;
  849. vm.isDisc = true;
  850. vm.isExch = false;
  851. vm.tickDiscType = '01';
  852. }else if(value == '02'){
  853. vm.isVoucher = false;
  854. vm.isDisc = false;
  855. vm.isExch = true;
  856. vm.tickDiscType = '02';
  857. }
  858. },
  859. tabsClick:function (value) {
  860. if(value == 'name3') {
  861. var limitNum = vm.mkStoreTicketDiscount.limitNum;
  862. if(!limitNum){
  863. limitNum = 1;
  864. }
  865. vm.mkStoreTicketDiscount.useNoti = "每人限领"+limitNum+"张,不可转赠好友,仅限商城下单使用";
  866. var applyTypeName = "";
  867. if(vm.mkStoreTicketDiscount.applyType === '00'){
  868. applyTypeName = '全部商品可用';
  869. }
  870. if (vm.mkStoreTicketDiscount.applyType === '01'){
  871. applyTypeName = '部分商品可用';
  872. }
  873. if (vm.mkStoreTicketDiscount.applyType === '02'){
  874. applyTypeName = '部分商品不可用';
  875. }
  876. var voucherCoud = 0;
  877. var voucherMoney = 0;
  878. var discCond = 0;
  879. var discRatio = 0;
  880. var discDecl = "";
  881. if(vm.mkStoreTicketDiscount.tickDiscType === '00'){
  882. if(vm.mkStoreTicketDiscount.voucherCond){
  883. voucherCoud = vm.mkStoreTicketDiscount.voucherCond;
  884. }
  885. if(vm.mkStoreTicketDiscount.voucherMoney){
  886. voucherMoney = vm.mkStoreTicketDiscount.voucherMoney;
  887. }
  888. discDecl="满"+voucherCoud +"元,减"+voucherMoney+"元,"+applyTypeName;
  889. }
  890. if(vm.mkStoreTicketDiscount.tickDiscType === '01'){
  891. if(vm.mkStoreTicketDiscount.discCond){
  892. discCond = vm.mkStoreTicketDiscount.discCond;
  893. }
  894. if(vm.mkStoreTicketDiscount.discRatio){
  895. discRatio = vm.mkStoreTicketDiscount.discRatio;
  896. }
  897. discDecl="满" + discCond + "元," + discRatio + "折," + applyTypeName;
  898. }
  899. vm.mkStoreTicketDiscount.discDecl = discDecl;
  900. }
  901. },
  902. reloadSearch: function() {
  903. vm.q = {
  904. name: ''
  905. }
  906. vm.reload();
  907. },
  908. reload: function (event) {
  909. vm.showList = true;
  910. vm.showViewList = false;
  911. vm.showInfoList = true;
  912. vm.showOrderList = true;
  913. let page = $("#jqGrid").jqGrid('getGridParam', 'page');
  914. $("#jqGrid").jqGrid('setGridParam', {
  915. postData: {'name': vm.q.name},
  916. page: page
  917. }).trigger("reloadGrid");
  918. vm.handleReset('formValidate');
  919. for (var g = 0; g < vm.queryColorList.length; g++) {
  920. $("#" + vm.queryColorList[g].color).attr("class", "");
  921. vm.colorList.remove(vm.queryColorList[g].color);
  922. $("#"+ vm.queryColorList[g].color).attr("name","noCheck");
  923. }
  924. },
  925. /**
  926. * 详情页返回
  927. * @param event
  928. */
  929. reloadInfoBack: function (event) {
  930. vm.showList = true;
  931. vm.showViewList = false;
  932. vm.showInfoList = true;
  933. vm.showOrderList = true;
  934. let page = $("#jqGrid").jqGrid('getGridParam', 'page');
  935. $("#jqGrid").jqGrid('setGridParam', {
  936. postData: {'name': vm.q.name},
  937. page: page
  938. }).trigger("reloadGrid");
  939. },
  940. /**
  941. * 修改页返回
  942. * @param event
  943. */
  944. reloadBack: function (event) {
  945. vm.showList = true;
  946. vm.showViewList = false;
  947. vm.showInfoList = true;
  948. vm.showOrderList = true;
  949. let page = $("#jqGrid").jqGrid('getGridParam', 'page');
  950. $("#jqGrid").jqGrid('setGridParam', {
  951. postData: {'name': vm.q.name},
  952. page: page
  953. }).trigger("reloadGrid");
  954. vm.handleReset('formValidate');
  955. for (var g = 0; g < vm.queryColorList.length; g++) {
  956. $("#" + vm.queryColorList[g].color).attr("class", "");
  957. vm.colorList.remove(vm.queryColorList[g].color);
  958. $("#"+ vm.queryColorList[g].color).attr("name","noCheck");
  959. }
  960. console.log(vm.isOperatorShow);
  961. if(vm.isOperatorShow){
  962. //触发返回按钮时,将失效的商品还原为有效
  963. var tempObj = {tickDiscId:vm.tickDiscId};
  964. $.ajax({
  965. type: "POST",
  966. url: "../mkstoreticketgoodstemp/resetIsValidByTemp",
  967. contentType: "application/json",
  968. data: JSON.stringify(tempObj),
  969. success: function (r) {
  970. if (r.code == 0) {
  971. } else {
  972. alert(r.msg);
  973. }
  974. }
  975. });
  976. }else{
  977. //新增页面触发返回按钮时,将临时数据删除
  978. var tempObj = {guid:vm.tid};
  979. $.ajax({
  980. type: "POST",
  981. url: "../mkstoreticketgoodstemp/resetIsValidByTemp",
  982. contentType: "application/json",
  983. data: JSON.stringify(tempObj),
  984. success: function (r) {
  985. if (r.code == 0) {
  986. } else {
  987. alert(r.msg);
  988. }
  989. }
  990. });
  991. }
  992. },
  993. handleSubmit: function (name) {
  994. handleSubmitValidate(this, name, function () {
  995. vm.saveOrUpdate()
  996. });
  997. },
  998. handleReset: function (name) {
  999. handleResetForm(this, name);
  1000. },
  1001. handleSuccessAdvImgUrl: function (res, file) {
  1002. vm.mkStoreTicketDiscount.advImgUrl = file.response.url;
  1003. },
  1004. handleFormatError: function (file) {
  1005. this.$Notice.warning({
  1006. title: '文件格式不正确',
  1007. desc: '文件 ' + file.name + ' 格式不正确,请上传 jpg 或 png 格式的图片。'
  1008. });
  1009. },
  1010. handleMaxSize: function (file) {
  1011. this.$Notice.warning({
  1012. title: '超出文件大小限制',
  1013. desc: '文件 ' + file.name + ' 太大,不能超过 100K。'
  1014. });
  1015. },
  1016. eyeImageAdvImgUrl: function () {
  1017. var url = vm.mkStoreTicketDiscount.advImgUrl;
  1018. eyeImage(url);
  1019. },
  1020. handleSuccessStoreLogoUrl: function (res, file) {
  1021. vm.mkStoreTicketDiscount.storeLogoUrl = res.url;
  1022. },
  1023. eyeImageStoreLogoUrl: function () {
  1024. var url = vm.mkStoreTicketDiscount.storeLogoUrl;
  1025. eyeImage(url);
  1026. },
  1027. },
  1028. mounted() {
  1029. $.get("../sys/macro/queryMacrosByValue?value=goodsBizType", function (r) {
  1030. vm.macros = r.list;
  1031. });
  1032. }
  1033. });