mkstoreticketdiscount.js 42 KB

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