Authored by chenchao

add new js & html

... ... @@ -17,14 +17,14 @@
<label class="col-sm-2 control-label">促销名称&nbsp;&nbsp;<span class="red">*</span></label>
<div class="col-sm-10">
<input type="text" id="title" class="form-control" value="<%data.title%>" placeholder="促销名称" required/>
<input type="text" id="title" class="form-control" value="" placeholder="促销名称" required/>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">促销描述 </label>
<div class="col-sm-10">
<textarea style="width: 400px; height: 90px;" name="description" id="description"><%data.description%></textarea>
<textarea style="width: 400px; height: 90px;" name="description" id="description"></textarea>
</div>
</div>
... ... @@ -32,12 +32,12 @@
<label class="col-sm-2 control-label">渠道</label>
<div class="col-sm-3">
<label class="radio-inline" style="padding-left: 0">
<input type="checkbox" name="fit_channel" value="1">有货官网</label>
<input type="checkbox" name="fitChannel" value="1">有货官网</label>
<label class="radio-inline">
<input type="checkbox" name="fit_channel" value="2">iphone</label>
<input type="checkbox" name="fitChannel" value="2">iphone</label>
<label class="radio-inline">
<input type="checkbox" name="fit_channel" value="3">android</label>
<input type="hidden" id="fit_channel" name="fit_channel" value="<%data.fit_channel%>" for="checkbox" placeholder="渠道" />
<input type="checkbox" name="fitChannel" value="3">android</label>
<input type="hidden" id="fitChannel" name="fitChannel" value="" for="checkbox" placeholder="渠道" />
</div>
</div>
... ... @@ -45,7 +45,7 @@
<label class="col-sm-2 control-label">起始时间&nbsp;&nbsp;<span class="red">*</span></label>
<div class="col-sm-4">
<input id="startTime" class="form-control" jsaction="time:end:endTime" type="text" placeholder="预售上架时间"
value="<%data.startTime%>" readonly required/>
value="" readonly required/>
</div>
</div>
... ... @@ -53,14 +53,14 @@
<label class="col-sm-2 control-label">结束时间&nbsp;&nbsp;<span class="red">*</span></label>
<div class="col-sm-4">
<input id="endTime" class="form-control" jsaction="time:start:startTime" type="text" placeholder="预售下架时间"
value="<%data.endTime%>" readonly required/>
value="" readonly required/>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">优先级&nbsp;&nbsp;<span class="red">*</span></label>
<div class="col-sm-10">
<input type="text" id="priority" name='priority' class="form-control" value="<%data.priority%>" required/>
<input type="text" id="priority" name='priority' class="form-control" value="" required/>
</div>
</div>
... ... @@ -71,13 +71,12 @@
<input type="radio" name="status" value="1">启用</label>
<label class="radio-inline">
<input type="radio" name="status" value="0" selected="selected">不启用</label>
<input type="hidden" id="status" name="status" value="<%data.status||'0'%>" for="radio" required />
<input type="hidden" id="status" name="status" value="" for="radio" required />
</div>
</div>
</div>
</div>
<input type="hidden" id="id" value="<%data.id%>">
<div class="panel-footer">
<button class="btn btn-primary" id="save">保存</button>
... ...
... ... @@ -4,7 +4,7 @@
<div class="contentpanel">
<div class="panel panel-default" style="margin-bottom:10px">
<div class="panel-body" style="padding-bottom: 0">
<a href="/promotionInfo/addNew" class="btn btn-success "><i class="fa fa-plus"></i> 添加促销</a>
<a href="javascript:;" id="save" class="btn btn-success "><i class="fa fa-plus"></i> 添加促销</a>
</div>
<div class="panel-body">
<div class="row">
... ... @@ -53,5 +53,7 @@
</div>
</div>
</div>
<script id="template_save" type="text/template">
<%include './Add'%>
</script>
<%include '../../../common/views/__ui/footer'%>
\ No newline at end of file
... ...
... ... @@ -21,12 +21,12 @@
<label class="col-sm-2 control-label">渠道</label>
<div class="col-sm-3">
<label class="radio-inline" style="padding-left: 0">
<input type="checkbox" name="fit_channel" value="1">有货官网</label>
<input type="checkbox" name="fitChannel" value="1">有货官网</label>
<label class="radio-inline">
<input type="checkbox" name="fit_channel" value="2">iphone</label>
<input type="checkbox" name="fitChannel" value="2">iphone</label>
<label class="radio-inline">
<input type="checkbox" name="fit_channel" value="3">android</label>
<input type="hidden" id="fit_channel" name="fit_channel" value="<%data.fit_channel%>" for="checkbox" placeholder="渠道" />
<input type="checkbox" name="fitChannel" value="3">android</label>
<input type="hidden" id="fitChannel" name="fitChannel" value="<%data.fitChannel%>" for="checkbox" placeholder="渠道" />
</div>
</div>
... ...
'use strict';
var $ = require('jquery'),
common = require('../../../common/common');
var saveConfig={
formId:"basicForm",
_btnId:"save",
reloadUrl:"/promotionInfo/index",
tempId:"template_save"
}
$(document).on('click', '#'+saveConfig._btnId, function () {
var _title=common.util.__input("title");
var _description=$("#description").text();
var _fitChannel=$("#fitChannel").val();
var _startTime=common.util.__input("startTime");
var _endTime=common.util.__input("endTime");
var _priority=common.util.__input("priority");
var check=true;
if (_title === '' || $.trim(_title) === ''){
common.util.__tip("名称不能为空", "warning");
check=false;
}
if (_startTime===''||$.trim(_startTime)===''||_startTime<1){
common.util.__tip("开始时间不能为空", "warning");
check= false;
}
if (_endTime===''||$.trim(_endTime)===''||_endTime<1){
common.util.__tip("结束时间不能为空", "warning");
check= false;
}
var _form_data={
title:_title,
description:_description,
fitChannel:_fitChannel,
startTime:_startTime,
endTime:_endTime,
priority:_priority
};
common.dialog.confirm("新增促销",
common.util.__template2($("#"+tempId).html(),_form_data)
, function () {
if(check){
common.util.__ajax({
url: $("#"+saveConfig.formId).attr("action"),
data: _form_data
}, function () {
location.href = saveConfig.reloadUrl
});
}else {
return false;
}
});
});
\ No newline at end of file
... ...
'use strict';
var $ = require('jquery'),
common = require('../../../common/common');
var rejectPromotions={
batchIds:[],
buildCheckboxHtml:function(_class,_data_index,_checked){
var _checkBox="<input type='checkbox'";
var _end="/>";
if(_class){
_checkBox+=" class='"+_class+"'";
}
if(_data_index){
_checkBox+=" data-index='"+_data_index+"'";
}
if(_checked){
_checkBox+=" checked='"+_checked+"'";
}
_checkBox+=_end;
return _checkBox;
},
getParam:function(){
var g=this;
/*
var _buildCheckboxHtml = function (_class,_data_index,_checked) {
return this.buildCheckboxHtml(_class,_data_index,_checked);
};*/
var param={
el: '#basicTable_promotion',
size: 10,
parms: function() {
return {
startTime: common.util.__input('startTime'),
endTime:common.util.__input("endTime")
};
},
columns: [
{
display: '',
type: 'checkbox',
_class:"all",
render: function (item) {
var htmlContent = "";
var _class="promotion_checkbox";
if(g.batchIds.length === 0 ){
//htmlContent = "<input type='checkbox' class='wqt_checkbox' data-index='"+item.__index+"'>";
htmlContent = g.buildCheckboxHtml(_class,item.__index);
}else{
$.each(g.batchIds,function(n,value) {
if(item.id == value){
//htmlContent = "<input type='checkbox' checked='checked' class='wqt_checkbox' data-index='"+item.__index+"'>";
htmlContent = g.buildCheckboxHtml(_class,item.__index,"checked");
return false
}else{
htmlContent = "<input type='checkbox' class='wqt_checkbox' data-index='"+item.__index+"'>";
htmlContent = g.buildCheckboxHtml(_class,item.__index);
}
})
}
return htmlContent;
}
},{
display: "ID",
name: "id"
}, {
display: "促销名称",
name: "title"
}, {
display: '优先级',
name: "priority"
}, {
display: '开始时间',
name: "startTime",
render: function(item) {
var date = new Date(item.startTime * 1000);
return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds();
}
}, {
display: '结束时间',
name: "endTime",
render: function(item) {
var date = new Date(item.endTime * 1000);
return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds();
}
}, {
display: '是否启用',
name: "status",
render: function(item) {
if(item.status==1){
var name ="已启用" ;
}else {
var name ="未启用" ;
}
return name;
}
}, {
display: '优惠券限制使用',
name: "status",
render: function(item) {
if(item.status==1){
var name ="是" ;
}else {
var name ="否" ;
}
return name;
}
}]
};
return param;
},
bindGrid: function(param){
return new common.grid(param);
},
grid: undefined,
init: function(){
var g=this,
_param=this.getParam();
this.grid=g.bindGrid(_param);
this.grid.init("/promotionInfo/list");
this.bindEvent();
},
reload:function(){
var g=this,
_grid=this.grid;
_grid.reload(1);
},
bindEvent: function() {
var g = this.grid,
p = this.options,
_batchIds=this.batchIds;
$(g.grid).on("change", ".all", function() {
var selected = $(".all").prop("checked");
$(".promotion_checkbox").prop("checked", selected);
g.selected.length = 0;
$(".promotion_checkbox").each(function() {
var checked = $(this).prop("checked");
var index = $(this).data("index");
if (checked) {
/**************业务控制 特殊情况**************/
if(_batchIds){
if($.inArray(g.rows[index]['id'], _batchIds) == -1 ){
_batchIds.push(g.rows[index]['id']);
}
}
/*********************************************/
g.selected.push(g.rows[index]);
}else{
/**************业务控制 特殊情况**************/
var _index = $.inArray(g.rows[index]['id'], _batchIds);
if(_batchIds && _index != -1 ){
_batchIds.splice(_index,1);
}
/********************************************/
}
});
}); //g.selected
//$(".promotion_checkbox").prop("checked",true);
$(g.grid).on("change", ".promotion_checkbox", function() {
$(".all").prop("checked", false);
g.selected.length = 0;
var selected = true;
/************业务控制 特殊情况****************/
if(_batchIds){
if($(this).prop("checked")){
if($.inArray(g.rows[$(this).attr("data-index")]['id'], _batchIds) == -1 ){
_batchIds.push(g.rows[$(this).attr("data-index")]['id']);
}
}else{
var _index = $.inArray(g.rows[$(this).attr("data-index")]['id'], _batchIds);
if(_index != -1 ){
_batchIds.splice(_index,1);
}
}
}
/********************************************/
$(".promotion_checkbox").each(function() {
var checked = $(this).prop("checked");
var index = $(this).data("index");
if (checked) {
g.selected.push(g.rows[index]);
} else {
selected = false;
}
});
$(".all").prop("checked", selected);
});
$(g.grid).on("change",".t_size",function(){
p.size=$(this).val();
g.reload(1);
})
}
}
common = require('../../../common/common'),
rejectPromotions=require('./partials/edit_reject');
/*
* 获取业务数据
... ... @@ -240,7 +46,7 @@ var t = new common.tab2({
active: 6,
click: function () {
var columnname = t.options.columns[t.options.active].name;
var default_html="<a href='#'>维护中。。。</a>";
var default_html="<a href='#'>bad error</a>";
if (columnname === ENUM.tabName[0].en) {//baseinfo
var html_baseinfo=$("#fm_baseInfo").html();
$("#tab_body").html(html_baseinfo);
... ...