Authored by 王钱钧

添加【品牌优惠券】功能

  1 +/**
  2 + * Created by Arthur on 16/5/26.
  3 + * 品牌发券管理
  4 + */
  5 +
  6 +var $ = require('jquery');
  7 +common = require('../common/common');
  8 +
  9 +
  10 +var ENUM = {
  11 + StatusEnum: {
  12 + 1:'失效',
  13 + 2:'有效',
  14 + }
  15 +
  16 +};
  17 +
  18 +//下拉框
  19 +new common.dropDown({
  20 + el: "#sel-status"
  21 +});
  22 +
  23 +new common.dropDown({
  24 + el: "#sel-brandName",
  25 + ajax: 'brand',
  26 +
  27 +});
  28 +
  29 +
  30 +var g = new common.grid({
  31 + el: '#basicTable',
  32 + size: 10,
  33 + parms: function () {
  34 +
  35 + return {
  36 + brandId: common.util.__input('sel-brandName'),
  37 + status: common.util.__input('sel-status'),
  38 + couponsId: common.util.__input('sel-couponsId')
  39 + };
  40 + },
  41 + columns: [
  42 + {
  43 + display: '品牌名称',
  44 + name: "brandName"
  45 + },
  46 +
  47 + {
  48 + display: '优惠券ID',
  49 + name: "couponsId"
  50 + }, {
  51 + display: '状态',
  52 + render: function (item) {
  53 + return "<p>" + ENUM.StatusEnum[item.status] + "</p>";
  54 + }
  55 + }, {
  56 + display: "创建时间",
  57 +
  58 + render: function (item) {
  59 + if (item.createTime && item.createTime !== 0) {
  60 + var t = new Date(item.createTime * 1000);
  61 + var formatted = common.util.__dateFormat(t, "yyyy-MM-dd hh:mm");
  62 + return "<p>" + formatted + "</p>";
  63 + }
  64 + else {
  65 + return "";
  66 + }
  67 +
  68 + }
  69 + },{
  70 + display: "修改时间",
  71 +
  72 + render: function (item) {
  73 + if (item.updateTime && item.updateTime !== 0) {
  74 + var t = new Date(item.updateTime * 1000);
  75 + var formatted = common.util.__dateFormat(t, "yyyy-MM-dd hh:mm");
  76 + return "<p>" + formatted + "</p>";
  77 + }
  78 + else {
  79 + return "";
  80 + }
  81 +
  82 + }
  83 + }, {
  84 + display: '操作',
  85 + //}
  86 + name: "status",
  87 + render: function (items) {
  88 + var HtmArr = [];
  89 +
  90 + HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-primary btn-xs info-modify">编辑</a>');
  91 + //HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-danger btn-xs info-del">删除</a>');
  92 +
  93 + return HtmArr.join('');
  94 + }
  95 + }]
  96 +});
  97 +g.init('/brandCoupon/queryList');
  98 +
  99 +//==================== 按钮点击事件 =====================//
  100 +
  101 +$("#filter-btn").click(function() {
  102 + g.reload(1);
  103 +});
  104 +
  105 +//添加
  106 +$(document).on('click', '#add-btn', function() {
  107 + articleCategoryOP("新增", '/brandCoupon/add', {});
  108 +
  109 +});
  110 +
  111 +//编辑
  112 +$(document).on('click', '.info-modify', function() {
  113 + var item = g.rows[$(this).data("index")];
  114 + articleCategoryOP("修改", '/brandCoupon/update', item);
  115 +});
  116 +
  117 +////删除
  118 +//$(document).on('click', '.info-del', function() {
  119 +// var item = g.rows[$(this).data("index")];
  120 +//
  121 +// common.dialog.confirm("温馨提示","确定要删除该标签?" , function() {
  122 +// common.util.__ajax({
  123 +// url: '/guang/tags/delTag',
  124 +// data: {
  125 +// id: item.id,
  126 +// }
  127 +// }, function(res) {
  128 +// if (res.code == 200) {
  129 +// g.reload();
  130 +// }
  131 +// });
  132 +// });
  133 +//});
  134 +
  135 +
  136 +function articleCategoryOP(prefix, url, item) {
  137 +
  138 + var a =new common.edit(".confirm");
  139 +
  140 + common.dialog.confirm(prefix+'标签', common.util.__template2($("#template").html(), item), function () {
  141 +
  142 + //
  143 + return a.submit(url,function(option){
  144 +
  145 + var _brandName = $('#brandId').find("option[value='"+option.data.brandId+"']").text();
  146 + option.data.brandName = _brandName;
  147 + option.success=function(res){
  148 + res=res.data;
  149 + if(res.code=="200"){
  150 + a.$tip("提交成功", function() {
  151 + g.reload();
  152 + }, 'growl-success');
  153 + }else{
  154 + a.$tip(res.message);
  155 + }
  156 + return false;
  157 + },
  158 + option.error=function(res){
  159 + a.$tip(res.message);
  160 + }
  161 + });
  162 +
  163 + });
  164 +
  165 + a.init();
  166 +
  167 +
  168 + new common.dropDown({
  169 + el: "#brandId",
  170 + ajax: 'brand'
  171 +
  172 + //el: "#classifyId",
  173 + //ajax: 'guangGetTagCategoryByStatus',
  174 +
  175 +
  176 + });
  177 +
  178 +
  179 +}
@@ -22,9 +22,9 @@ var config = { @@ -22,9 +22,9 @@ var config = {
22 // domain: 'http://172.16.6.146:8088/platform', //玛丽 22 // domain: 'http://172.16.6.146:8088/platform', //玛丽
23 //domain:'http://172.16.6.157:8080/yohobuy-platform-web',//葛超 23 //domain:'http://172.16.6.157:8080/yohobuy-platform-web',//葛超
24 // domain: 'http://192.168.102.216:8086/platform', 24 // domain: 'http://192.168.102.216:8086/platform',
25 - domain: 'http://192.168.102.202:8088/platform', 25 + //domain: 'http://192.168.102.202:8088/platform',
26 //domain: 'http://172.16.6.146:8088/platform', 26 //domain: 'http://172.16.6.146:8088/platform',
27 - //domain:'http://172.16.6.120:8088/platform',//曹艳 27 + domain:'http://172.16.6.120:8080/platform',//曹艳
28 //domain:'http://172.16.6.231:8080/platform',//王伟 28 //domain:'http://172.16.6.231:8080/platform',//王伟
29 //domain: 'http://172.16.6.239:8080', //孙杰翔 29 //domain: 'http://172.16.6.239:8080', //孙杰翔
30 //domain:'http://172.16.6.189:8088/platform', //李健1 30 //domain:'http://172.16.6.189:8088/platform', //李健1
  1 +/**
  2 + * Created by Arthur on 16/5/26.
  3 + */
  4 +exports.domain = require('../config/common.js').domain;
  5 +exports.res = [
  6 + {// 品牌发券空白页
  7 + route: '/brandCoupons/index',
  8 + method: 'GET',
  9 + view: 'pages/operations/brandCoupon',
  10 + src: '/operations/brandCoupon',
  11 + data: {
  12 + iscreate: true
  13 + }
  14 + }, {
  15 +
  16 + // 列表数据
  17 + route: '/brandCoupon/queryList',
  18 + method: 'POST',
  19 + url: '/brandCoupon/queryList',
  20 + params: [
  21 + {name: 'brandId', type: 'String'},
  22 + {name: 'status', type: 'Number'},
  23 + {name: 'couponsId', type: 'Number'},
  24 + {name: 'page', type: 'Number'},
  25 + {name: 'size', type: 'Number'}
  26 + ]
  27 + }, {
  28 + // 新增
  29 + route: '/brandCoupon/add',
  30 + method: 'POST',
  31 + url: '/brandCoupon/add',
  32 + params: [
  33 + {name: 'brandName', type: 'String'},
  34 + {name: 'status', type: 'Number'},
  35 + {name: 'brandId', type: 'Number'},
  36 + {name: 'couponsId', type: 'Number'},
  37 + ]
  38 + }, {
  39 + // 删除
  40 + route: '/brandCoupon/delete',
  41 + method: 'POST',
  42 + url: '/brandCoupon/delete',
  43 + params: [
  44 + {name: 'id', type: 'Number'},
  45 + ]
  46 + },{
  47 + // 修改
  48 + route: '/brandCoupon/update',
  49 + method: 'POST',
  50 + url: '/brandCoupon/update',
  51 + params: [
  52 + {name: 'brandName', type: 'String'},
  53 + {name: 'status', type: 'Number'},
  54 + {name: 'id', type: 'Number'},
  55 + {name: 'brandId', type: 'Number'},
  56 + {name: 'couponsId', type: 'Number'},
  57 + ]
  58 + }
  59 +];
  1 +<div class="pageheader">
  2 + <div class="media">
  3 + <div class="pageicon pull-left">
  4 + <i class="fa fa-th-list"></i>
  5 + </div>
  6 + <div class="media-body">
  7 + <ul class="breadcrumb">
  8 + <li><a href=""><i class="glyphicon glyphicon-home"></i></a></li>
  9 + <li><a href="">运营管理</a></li>
  10 + <li>品牌发券管理</li>
  11 + </ul>
  12 +
  13 + <div>
  14 + <div style="width: 30%;float: left;">
  15 + <h4>品牌发券列表</h4>
  16 + </div>
  17 + </div>
  18 + </div>
  19 + </div>
  20 +</div>
  21 +
  22 +<div class="contentpanel">
  23 + <div class="panel panel-default" style="margin-bottom:10px;">
  24 + <div class="panel-body">
  25 + <a id="add-btn" href="javascript:;" class="btn btn-info">添加优惠券</a>
  26 + </div>
  27 + <div class="panel-body">
  28 +
  29 +
  30 + <div class="row">
  31 +
  32 +
  33 + <div class="panel-col">
  34 + <select id="sel-brandName" class="form-control" >
  35 + <option value="-1">选择品牌名称</option>
  36 + </select>
  37 + </div>
  38 +
  39 + <!--<div class="panel-col">-->
  40 + <!--<select id="sel-status" class="form-control" >-->
  41 + <!--<option value="-1">选择状态</option>-->
  42 + <!--</select>-->
  43 + <!--</div>-->
  44 +
  45 + <div class="panel-col">
  46 + <select id="sel-status" class="form-control">
  47 + <option value="-1">选择状态</option>
  48 + <option value="1">失效</option>
  49 + <option value="2">有效</option>
  50 + </select>
  51 + </div>
  52 +
  53 + <div class="panel-col">
  54 + <input type="text" id="sel-couponsId" class="form-control" placeholder="输入优惠券ID" style="height: 39px;"/>
  55 + </div>
  56 +
  57 +
  58 + <div class="panel-col">
  59 + <a id="filter-btn" href="javascript:;" class="btn btn-info">筛选</a>
  60 + <a id="all-btn" href="" class="btn btn-info">全部</a>
  61 + </div>
  62 +
  63 + </div>
  64 + </div>
  65 + </div>
  66 + <div class="panel panel-primary-head">
  67 + <div id="basicTable_wrapper" class="dataTables_wrapper no-footer">
  68 + <div class="dataTables_length" id="basicTable">
  69 + </div>
  70 + <nav>
  71 + <ul id="pagination" class="pagination pagination-lg"></ul>
  72 + </nav>
  73 + </div>
  74 + </div>
  75 +</div>
  76 +
  77 +
  78 +<script type="text/template" id="template">
  79 + <div class="form-group">
  80 + <label for="couponsId" class="col-sm-2 control-label">优惠券ID<span style="color: red;"> *</span>:</label>
  81 + <div class="col-sm-10">
  82 + <input type="text" value="[[couponsId]]" name="content" id="couponsId" placeholder="优惠券ID" required="required" class="form-control">
  83 + </div>
  84 + </div>
  85 + <!--<div class="form-group" id="maxsord">-->
  86 + <!--<label for="brandId" class="col-sm-2 control-label">品牌<span style="color: red;"> *</span>:</label>-->
  87 + <!--<div class="col-sm-10">-->
  88 + <!--<input type="hidden" name="" value="[[id]]" id="id" required="required" class="form-control" pattern="" title="">-->
  89 + <!--<select id="brandId" value="[[brandId]]" required="required" class="form-control">-->
  90 + <!--&lt;!&ndash;<option value="-1">请选择分类</option>&ndash;&gt;-->
  91 + <!--<option value="[[brandId||-1]]">[[brandName||"请选择品牌"]]</option>-->
  92 + <!--</select>-->
  93 + <!--</div>-->
  94 + <!--</div>-->
  95 +
  96 + <div class="form-group" id="maxsord">
  97 + <label for="brandId" class="col-sm-2 control-label">品牌<span style="color: red;"> *</span>:</label>
  98 + <div class="col-sm-10">
  99 + <input type="hidden" name="" value="[[id]]" id="id" class="form-control" pattern="" title="">
  100 + <select id="brandId" value="[[brandId]]" required="required" class="form-control">
  101 + <!--<option value="-1">请选择分类</option>-->
  102 + <option value="[[brandId||-1]]">[[brandName||"请选择品牌"]]</option>
  103 + </select>
  104 + </div>
  105 + </div>
  106 +
  107 + <div class="form-group">
  108 + <label for="status" class="col-sm-2 control-label">是否热门<span style="color: red;"> *</span>:</label>
  109 + <div class="radio">
  110 + <label><input type="radio" value="1" name="status" kl_vkbd_parsed="true">失效</label>
  111 + <label><input type="radio" value="2" name="status" kl_vkbd_parsed="true">有效</label>
  112 + </div>
  113 + <input id="status" type="hidden" required="required" value="[[status]]" for="radio" kl_vkbd_parsed="true">
  114 + </div>
  115 +
  116 +
  117 +</script>