mkstoreticketdiscount.js 42 KB

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