Authored by weiqingting

基础商品

alert();
\ No newline at end of file
'use strict';
var $ = require('jquery'),
common=require('../common/common');
var ENUM={
goodsSizeList:{"factoryCode":"","sizeId":"","salePrice":""}
}
//baseTable
var g=new common.grid({
el:"#basicTable",
columns:[
{display:"分类名称",render:function(item){
var html=[];
html.push("<p>色系:"+item.goodsName+"<p>");
html.push('<button type="button" data-index='+item.__index+' class="sortdelete btn btn-danger btn-xs">删除</button>');
return html.join("");
}},
{
display:"分类图片",render:function(item){
return "<input type=file name='goodsColorImage' id='file__"+item.__index+"' value='"+item.goodsColorImage+"' />";
}
},
{
display:"<label class='red'>款型编码,xxx,xxx必填</label>",render:function(item){
var html=[];
html.push("<div class='form-group'><div class='col-sm-11 red'><input type=text value='"+item.factoryCode+"' data-index="+item.__index+" class='factoryCode form-control' placeholder='款型编码' required/></div></div>");
html.push('<div class="rows" id="rows__'+item.__index+'">');
html.push(common.util.__template($("#template").html(),{index:item.__index}));
html.push('</div>');
return html.join('');
}
}
]
});
g.__rows=[];
g.__e=new common.edit("#basicTable");
g.init(g.__rows);
g.__e.init();
g.__e.on("callback", function(obj) {
console.log(obj);
if(/^file_onComplete/.test(obj.key)){
var _index=obj.key.replace(/^file_onComplete_file__/,'');
g.__rows[_index].goodsColorImage=obj.data;
}
});
$(document).on("click",".sortadd",function(){
var text=$(this).text();
if(g.__e.validate()){
g.__rows.push({
"factoryCode": "",
"goodsColorImage": "",
goodsName: $(this).text(),
colorId: (+$(this).data("id")),
goodsSizeList: [ENUM.goodsSizeList]
});
g.reload();
g.__e.init();
}
});
$(document).on("click",".sortdelete",function(){
var index=$(this).data("index");
[].splice.call(g.__rows,index,1);
g.reload();
g.__e.init();
});
$(document).on("change",".factoryCode",function(){
var item=g.__rows[$(this).data("index")];
item.factoryCode=$(this).val();
});
$(document).on("click",".btn-sort-add",function(){
var item=g.__rows[$(this).data("index")];
item.goodsSizeList.push(ENUM.goodsSizeList);
var __index=item.goodsSizeList.length;
$("#rows__"+$(this).data("index")).append(common.util.__template($("#template").html(),{index:item.__index,__index:__index}));
});
$(document).on("click",".btn-sort-remove",function(){
var item=g.__rows[$(this).data("index")];
var __index=$(this).data("eq");
[].splice.call(item.goodsSizeList,__index,1);
$(this).parent("div").parent(".form-group").remove();
alert($(this).data("index"));
$(".btn-sort-remove","#rows__"+$(this).data("index")).each(function(index){
console.log(index);
$(this).data("eq",''+index);
});
console.log(item.goodsSizeList);
});
\ No newline at end of file
... ...
... ... @@ -7,6 +7,11 @@ var ENUM={
tips:{"0":0,"1":0,"2":0,"3":0,"4":0,"all":0}
}
/*下拉选择*/
new common.dropDown({el:"#store",ajax:"queryShop"});
new common.dropDown({el:"#brand",ajax:"queryBrand"});
new common.dropDown({el:"#createor",ajax:"querySupplier"});
var t = new common.tab({
el:"#basicTab",
click:function(){
... ...
... ... @@ -228,6 +228,7 @@ edit.prototype={
.add("textarea",that.el)
.each(function() {
var id = $(this).attr("id");
var name = $(this).attr("name");
var value =$.trim($(this).val());
if($(this).attr("type")=="file"){
value=!!$(this).attr("value")?$(this).attr("value"):$(this).val();
... ... @@ -235,8 +236,8 @@ edit.prototype={
var name=$(this).attr("placeholder")&&!(/^\d+$/.test($(this).attr("placeholder")))?$(this).attr("placeholder").replace(/请填写/g,''):$(this).parents(".form-group").find("label").text().replace(/\*/g,'');
// var rule = [];
if (id&&$(this).attr("required")) {
new Validator.init(document.getElementById(id),{
if ((id||name)&&$(this).attr("required")) {
new Validator.init($(this)[0],{
rules:{required:true}
}).validate(function(obj){
err.push("<p>"+name+"不可为空</p>");
... ...
... ... @@ -203,7 +203,7 @@ grid.prototype = {
g.__bodyClomun(data.list);
// setpage(res);
},
complete: function() {
complete: function(res) {
console.log("complete~~");
},
error: function() {
... ...
... ... @@ -91,9 +91,9 @@ var util={
}
}
return result;
},
__input:function(id){
return !!~$.trim($('#'+id).val())?$('#'+id).val():""
}
},
__input:function(id){
return !!~$.trim($('#'+id).val())?$('#'+id).val():""
}
}
module.exports=util;
\ No newline at end of file
... ...
... ... @@ -220,7 +220,7 @@ $('#export-btn').on('click', function() {
});
common.util.__ajax({
url: '/limit/batch/export',
url: '/ajax/down',
data: {
queryConf: '2016022517335568',
type: 'limitProductReminder'
... ...
... ... @@ -12,8 +12,8 @@
box-sizing: border-box;
cursor: pointer;
display: block;
height: 40px;
line-height: 40px;
height: 39px;
line-height: 39px;
user-select: none;
-webkit-user-select: none;
}
... ...
... ... @@ -2,10 +2,13 @@ exports.domain = require('../config/common.js').domain;
exports.res = [
{//基础商品列表
route:'/base/goods/index',
route:'/supplier/baseproduct/index',
method:'GET',
view:'pages/basegoods/index',
src: '/basegoods/index'
src: '/basegoods/index',
data:{
iscreate:true
}
},
{//ajax列表数据
route:'/base/goods/ajax/index',
... ... @@ -23,7 +26,8 @@ exports.res = [
view:'pages/basegoods/edit',
data:{
data:{}
}
},
src:'/basegoods/edit'
},
{//添加接口
route:'/base/goods/ajax/add',
... ...
var authService = require('../service/auth');
var uploader=require('../service/upload');
var down=require('../service/down');
module.exports = {
'/auth_bak':function(req, res){
... ... @@ -73,5 +74,8 @@ module.exports = {
},
'/ajax/upload':function(req,res){
uploader.uploadFile(req,res);
},
'/ajax/down':function(req,res){
down.downFile(req,res);
}
}
\ No newline at end of file
... ...
var request = require('request');
var _ = require('lodash');
var fs = require('fs');
var ipaddr = require('ipaddr.js');
var domain = "http://172.16.6.162:8088/platform";//require('../../config/common.js').domain;
exports.downFile = function(req, res) {
request
.post({
url:'http://172.16.6.240:8088/platform/batch/export',
headers: { 'content-type': 'application/json' },
json: true,
formData: { queryConf: '2016030711350185', type: 'limitProductReminder' },//req.body
})
.on('response', function(response) {
var status=response.statusCode;
if(status>=200&&status<300||status==304){
console.log("下载成功");
}else{
console.log("下载失败");
}
})
.on('error', function(err) {
var msg= typeof err==='object'?err.message:err;
console.log("error");
console.log(msg.error);
})
.pipe(res);
}
\ No newline at end of file
... ...
... ... @@ -31,21 +31,23 @@
<div class="row">
<div class="form-group">
<label class="col-sm-2 control-label">商品 <span class="red">*</span></label>
<label class="col-sm-2 control-label">店铺 <span class="red">*</span></label>
<div class="col-sm-2">
<select class="form-control">
<option value="-1">商品</option>
<select id="shopId" class="form-control">
<option value="-1">店铺</option>
</select>
</div>
<label class="col-sm-1 control-label">店铺 <span class="red">*</span></label>
<label class="col-sm-1 control-label">品牌 <span class="red">*</span></label>
<div class="col-sm-2">
<select class="form-control">
<option value="-1">店铺</option>
<select id="brandId" class="form-control">
<option value="-1">品牌</option>
</select>
</div>
<label class="col-sm-1 control-label">供应商 <span class="red">*</span></label>
<div class="col-sm-2">
<select class="form-control">
<select id="supplierId" class="form-control">
<option value="-1">供应商</option>
</select>
</div>
... ... @@ -57,47 +59,63 @@
</div>
<label class="col-sm-1 control-label">厂家编号</label>
<div class="col-sm-1">
<input type="text" id="productName" class="form-control" />
<input type="text" id="factoryCode" class="form-control" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">货品年<span class="red">*</span></label>
<div class="col-sm-1">
<input type="text" id="productName" class="form-control" />
<select id="goodsYears" class="form-control">
<option value="2015">2015</option>
</select>
</div>
<label class="col-sm-1 control-label">货品季<span class="red">*</span></label>
<div class="col-sm-1">
<input type="text" id="productName" class="form-control" />
<select id="goodsSeason" class="form-control">
<option value="春"></option>
<option value="夏"></option>
<option value="秋"></option>
<option value="冬"></option>
<option value="春夏">春夏</option>
<option value="秋冬">秋冬</option>
</select>
</div>
<label class="col-sm-1 control-label">商品类型<span class="red">*</span></label>
<label class="col-sm-1 control-label">商品属性<span class="red">*</span></label>
<div class="col-sm-1">
<input type="text" id="productName" class="form-control" />
<select id="attribute" class="form-control">
<option value="1">普通商品</option>
<option value="2">赠品</option>
<option value="3">虚拟商品</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">商品话题<span class="red">*</span></label>
<label class="col-sm-2 control-label">商品话题</label>
<div class="col-sm-5">
<input type="text" id="productName" class="form-control" />
<input type="text" id="productTag" class="form-control" />
</div>
</div>
<div class="form-group">
<!-- 【年龄层】默认 成人 ,成人和大童小童互斥,如果是童装,年龄层必填,并且大童小童可以复选。 -->
<label class="col-sm-2 control-label">年龄层<span class="red">*</span></label>
<div class="col-sm-2">
<label class="radio-inline">
<input type="checkbox" name="brandLevel" value="KA">成人</label>
<input type="checkbox" name="brandLevel" checked="checked" value="1">成人</label>
<label class="radio-inline">
<input type="checkbox" name="brandLevel" value="KA">大童</label>
<input type="checkbox" name="brandLevel" value="2">大童</label>
<label class="radio-inline">
<input type="checkbox" name="brandLevel" value="KA">小童</label>
<input type="checkbox" name="brandLevel" value="3">小童</label>
<input type="hidden" id="ageLevel" name="ageLevel" value="{{ageLevel}}" for="checkbox" />
</div>
<label class="col-sm-1 control-label">性别<span class="red">*</span></label>
<div class="col-sm-2">
<label class="radio-inline">
<input type="checkbox" name="brandLevel" value="KA"></label>
<input type="radio" name="gender" value="1" checked="checked"></label>
<label class="radio-inline">
<input type="checkbox" name="brandLevel" value="KA"></label>
<input type="radio" name="gender" value="2"></label>
<label class="radio-inline">
<input type="checkbox" name="brandLevel" value="KA">通用</label>
<input type="radio" name="gender" value="3">通用</label>
<input type="hidden" id="gender" name="gender" value="{{gender}}" for="radio" />
</div>
</div>
<div class="form-group">
... ... @@ -105,58 +123,62 @@
<label class="col-sm-1 control-label">重点款<span class="red">*</span></label>
<div class="col-sm-2">
<label class="radio-inline">
<input type="checkbox" name="brandLevel" value="1"></label>
<input type="radio" name="brandLevel" value="1"></label>
<label class="radio-inline">
<input type="checkbox" name="brandLevel" value="0"></label>
<input type="radio" name="brandLevel" value="0"></label>
</div>
<input type="hidden" id="grade" value="{{grade}}" for="radio" />
</div>
<div class="form-group">
<label class="col-sm-2 control-label">促销礼品<span class="red">*</span></label>
<label class="col-sm-2 control-label">促销礼品</label>
<div class="col-sm-2">
<label class="radio-inline">
<input type="checkbox" name="brandLevel" value="1"></label>
<input type="radio" name="brandLevel" value="Y"></label>
<label class="radio-inline">
<input type="checkbox" name="brandLevel" value="0"></label>
<input type="radio" name="brandLevel" value="N"></label>
<input id="isPromotionalGifts" type="hidden" value="{{isPromotionalGifts}}" for="radio" />
</div>
<label class="col-sm-1 control-label">限量款<span class="red">*</span></label>
<label class="col-sm-1 control-label">限量款</label>
<div class="col-sm-2">
<label class="radio-inline">
<input type="checkbox" name="brandLevel" value="1"></label>
<label class="radio-inline">
<input type="checkbox" name="brandLevel" value="0"></label>
</div>
<input id="isLimited" type="hidden" value="{{isLimited}}" for="radio" />
</div>
<div class="form-group">
<label class="col-sm-2 control-label">是否限购<span class="red">*</span></label>
<label class="col-sm-2 control-label">是否限购</label>
<div class="col-sm-2">
<label class="radio-inline">
<input type="checkbox" name="brandLevel" value="1"></label>
<input type="radio" name="brandLevel" value="Y"></label>
<label class="radio-inline">
<input type="checkbox" name="brandLevel" value="0"></label>
<input type="radio" name="brandLevel" value="N"></label>
</div>
<input type="hidden" id="isLimitbuy" value="{{isLimitbuy}}" for="radio" />
</div>
<div class="form-group">
<label class="col-sm-2 control-label">吊牌价<span class="red">*</span></label>
<div class="col-sm-2">
<input type="text" id="productName" class="form-control" />
<input type="text" id="retailPrice" class="form-control" required value="{{retailPrice}}" />
</div>
<label class="col-sm-1 control-label">销售价<span class="red">*</span></label>
<div class="col-sm-2">
<input type="text" id="productName" class="form-control" />
<input type="text" id="salesPrice" class="form-control" required value="{{salesPrice}}" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">预计上架时间<span class="red">*</span></label>
<div class="col-sm-2">
<input type="text" id="productName" class="form-control" />
<input type="text" id="expectShelfTime" jsaction="time" value="{{expectShelfTime}}" required class="form-control" />
</div>
<label class="col-sm-1 control-label">预计到货时间<span class="red">*</span></label>
<label class="col-sm-1 control-label">预计到货时间</label>
<div class="col-sm-2">
<input type="text" id="productName" class="form-control" />
<input type="text" id="{{expectArrivalTime}}" jsaction="time" value="{{expectArrivalTime}}" class="form-control" />
</div>
</div>
... ... @@ -170,7 +192,23 @@
<div class="row">
<div class="form-group">
<label class="col-sm-2 control-label">颜色分类 <span class="red">*</span></label>
<p>
<button type="button" class="btn btn-default sortadd btn-xs" data-id="1">红色(+)</button>
</p>
</div>
<div id="basicTable"></div>
<!-- <div class="form-group">
<div class="col-sm-3">
<p>色系:粉红色</p>
<button type="button" class="btn btn-default btn-xs">删除</button>
</div>
<div class="col-sm-3">
<input type="file" id="filename" name="filename" />
</div>
<div class="col-sm-6">
</div>
</div> -->
</div>
</div>
... ... @@ -191,4 +229,37 @@
</form>
</div>
</div>
</div>
\ No newline at end of file
</div>
<script type="text/template" id="template">
<div class="form-group">
<!-- <label class="col-sm-1 red">*</label> -->
<div class="col-sm-2">
<select class="form-control" data-index={index} class="btn-sort-chima">
<option value="-1">选择尺码</option>
<option value="XS">XS</option>
<option value="S">S</option>
<option value="M">M</option>
<option value="L">L</option>
<option value="ML">ML</option>
</select>
</div>
<div class="col-sm-2">
<input class="form-control" class="btn-sort-xiaoshou" placeholder="默认销售价" data-index={index}></input>
</div>
<div class="col-sm-2">
<input class="form-control" class="btn-sort-tiaoma" placeholder="条码" data-index={index}></input>
</div>
<div class="col-sm-2">
<select class="form-control" class="btn-sort-kebu">
<option value="-1">能否补货</option>
<option value="1">可补货</option>
<option value="2">不可补货</option>
</select>
</div>
<div class="col-sm-2">
<button type="button" class="btn btn-info btn-xs btn-sort-add" data-index={index}>+</button>
<button type="button" class="btn btn-info btn-xs btn-sort-remove" data-index={index} data-eq={__index}>-</button>
</div>
</div>
</script>
\ No newline at end of file
... ...
... ... @@ -45,7 +45,7 @@
</select>
</div>
<div class="panel-col">
<select id="brandId" class="form-control">
<select id="brand" class="form-control">
<option value="-1">请选择品牌</option>
</select>
</div>
... ... @@ -115,4 +115,5 @@
</div>
</div>
</div>
</script>
\ No newline at end of file
</script>
... ...