Authored by liuyue

Merge branch 'develop' of http://git.dev.yoho.cn/platform/yohobuy-shops-fe into develop

... ... @@ -2,7 +2,7 @@
var $ = require('jquery'),
common = require('../common/common');
new common.dropDown({el:"#brandId",ajax:"brand",params:function(){
new common.dropDown({el:"#brandId",ajax:"queryBrandByShopId",params:function(){
return {status:1}
}});
... ... @@ -17,8 +17,9 @@ new common.dropDown({el:"#supplierId",ajax:"getjitSup",params:function(){
$('input[type="file"]').after('<div class="file-name btn btn-default">请选择文件</div>');
var loadModal = null;
function batchExport(el, type) {
var loadModal = null;
return {
params: {
... ... @@ -44,16 +45,16 @@ function batchExport(el, type) {
//$(el).parents('td').find('.file-name').text($(el).val().replace("C:\\fakepath\\", ""));
},
onComplete: function(response) {
console.log(response);
console.log("批量接口返回数据",response);
$("#message").html('');
if (response.code == 200&&response.data.taskId) {
__ajaxExeclById(response.data.taskId);
// common.util.__tip(response.message, 'success');
return;
}
if (loadModal) {
loadModal.close();
}
if (response.code == 200&&response.data.failFileReason.length==0) {
common.util.__tip(response.message, 'success');
return;
}
if(response.data&&response.data.failFileReason.length){
$("#message").html(response.data.failFileReason.join('<br/>'));
return false;
... ... @@ -77,3 +78,28 @@ $(document).on("change","#brandId",function(){
}
});
function __ajaxExeclById(unquid){
var params={param:unquid};
common.util.__ajax({
url:'/ajax/queryBatchImportResult',
data:params
},function(res){
if(res.data.length){
//成功操作
if (loadModal) {
loadModal.close();
}
common.util.__tip(res.message, 'success');
}else{
setTimeout(function(){
__ajaxExeclById.call(null,unquid);
},5000);
}
$("#message").html(res.message);
},true);
}
// __ajaxExeclById("batchBasePrd1459835824928");
... ...
'use strict';
var $ = require('jquery'),
common = require('../common/common');
common=require('../common/common');
/*基础商品模型(Model)*/
var RESPONSEDATA = {};
var RESPONSEDATA={};
/*获取基础商品数据*/
var param = location.href.slice(location.href.indexOf("update")).match(/\/\d+/g);
// console.log(param);
if (param && param.length == 2) {
param[0] = param[0].replace(/\//, '');
param[1] = param[1].replace(/\//, '');
if(param&&param.length==2){
param[0]=param[0].replace(/\//,'');
param[1]=param[1].replace(/\//,'');
common.util.__ajax({
url: '/base/goods/getData',
async: false,
data: {
productSkn: param[0],
isAuditing: param[1]
}
}, function(res) {
RESPONSEDATA = res.data;
}, true);
url:'/base/goods/getData',
async:false,
data:{
productSkn:param[0],
isAuditing:param[1]
}
},function(res){
RESPONSEDATA=res.data;
},true);
}
/*货品年,规则从2015年开始,到今年之后的10年*/
RESPONSEDATA.ENUMYEAR = (function() {
var _y = [];
for (var i = 2005; i < (new Date).getFullYear() + 10; i++) {
_y.push({
YEAR: i
});
}
return _y;
})()
RESPONSEDATA.ENUMYEAR=(function(){
var _y=[];
for(var i=2005;i<(new Date).getFullYear()+10;i++){
_y.push({YEAR:i});
}
return _y;
})()
console.log(RESPONSEDATA);
/*根据Model渲染View 基础商品基本信息*/
$("#basicInfo").html(common.util.__template2($("#template2").html(), RESPONSEDATA));
$("#basicInfo").html(common.util.__template2($("#template2").html(),RESPONSEDATA));
/*类目配置*/
var ENUM = {
goodsSizeList: {
"sizeId": "",
"salePrice": $("#salesPriceStr").val(),
"barCode": "",
"isSuppled": "N",
"presaleStorageNum": ""
}
var ENUM={
goodsSizeList:{"sizeId":"","salePrice":$("#salesPriceStr").val(),"barCode":"","isSuppled":"N","presaleStorageNum":""}
}
/*公共模块*/
var Bll = {
var Bll={
/*判断类目级别,如果符合三级四级,返回对应id*/
validateSort: function() {
var id = false;
var select = tabTree.getAddress();
if (select.length > 2) {
if (select[2] && select[2].id) {
id = select[2].id;
validateSort:function(){
var id=false;
var select=tabTree.getAddress();
if(select.length>2){
if(select[2]&&select[2].id){
id=select[2].id;
}
if (select[3] && select[3].id) {
id = select[3].id;
if(select[3]&&select[3].id){
id=select[3].id;
}
}
return id;
},
/*商品名称*/
IsEnter: false,
productNameArr: ['', '', ''],
setProductName: function() {
if (!param) {
if (!Bll.IsEnter) {
IsEnter:false,
productNameArr:['','',''],
setProductName:function(){
if(!param){
if(!Bll.IsEnter){
$("#productName").val(Bll.productNameArr.join(""));
}
}
... ... @@ -120,30 +114,20 @@ var Bll = {
// ag.__edit=new common.edit("#attributeTable");
/*品类初始化*/
var SORTDATA = {
url: "/goods/query/querySortBySmallSort",
datas: [{
id: RESPONSEDATA.maxSortId,
sortName: RESPONSEDATA.maxSortName
}, {
id: RESPONSEDATA.middleSortId,
sortName: RESPONSEDATA.middleSortName
}, {
id: RESPONSEDATA.smallSortId,
sortName: RESPONSEDATA.smallSortName
}, {
id: RESPONSEDATA.sortId,
sortName: RESPONSEDATA.sortName
}],
otherParam: function() {
return {
brandId: $("#brandId").val(),
supplierId: common.util.__input("supplierId")
}
var SORTDATA={
url:"/goods/query/querySortBySmallSort",
datas:[
{id:RESPONSEDATA.maxSortId,sortName:RESPONSEDATA.maxSortName},
{id:RESPONSEDATA.middleSortId,sortName:RESPONSEDATA.middleSortName},
{id:RESPONSEDATA.smallSortId,sortName:RESPONSEDATA.smallSortName},
{id:RESPONSEDATA.sortId,sortName:RESPONSEDATA.sortName}
],
otherParam:function(){
return {brandId:$("#brandId").val(),supplierId:common.util.__input("supplierId")}
},
complete: function(data) {
if (data.length > 2) {
Bll.productNameArr[2] = data[data.length - 1].sortName;
complete:function(data){
if(data.length>2){
Bll.productNameArr[2]=data[data.length-1].sortName;
Bll.setProductName();
/*查出非销售属性*/
// var sorid=Bll.validateSort();
... ... @@ -158,436 +142,381 @@ var SORTDATA = {
// ag.init(res.data);
// },true);
// }
}
}
};
var tabTree = new common.tabTree("#tree", SORTDATA);
var tabTree=new common.tabTree("#tree",SORTDATA);
tabTree.init(SORTDATA.datas);
tabTree.isfeeze = true;
tabTree.isfeeze=true;
/*下拉选择*/
var e = new common.edit("#basicInfo");
var e=new common.edit("#basicInfo");
e.init();
if (RESPONSEDATA.isAuditing != 200) {
if(RESPONSEDATA.isAuditing!=200){
new common.dropDown({
el: "#brandId",
ajax: "brand",
params: function() {
return {
status: 1
}
}
});
new common.dropDown({el:"#brandId",ajax:"queryBrandByShopId",params:function(){
return {status:1}
}});
new common.dropDown({
el: "#shopId",
ajax: "sortbybrand",
params: function() {
return {
brandId: $("#brandId").val()
}
}
});
new common.dropDown({el:"#shopId",ajax:"sortbybrand",params:function(){
return {brandId:$("#brandId").val()}
}});
new common.dropDown({
el: "#supplierId",
ajax: "getjitSup",
params: function() {
return {
brandId: $("#brandId").val()
}
}
});
new common.dropDown({el:"#supplierId",ajax:"getjitSup",params:function(){
return {brandId:$("#brandId").val()}
}});
}
var g = new common.grid({
el: "#basicTable",
columns: [{
display: "分类名称",
render: function(item) {
var html = [];
var txt = item.factoryGoodsName ? item.factoryGoodsName : "";
html.push("<p>名称:<input type='text' class='w-goods-text' data-index=" + item.__index + " value='" + txt + "' placeholder='分类名称' required/><p>");
var g=new common.grid({
el:"#basicTable",
columns:[
{display:"分类名称",render:function(item){
var html=[];
var txt=item.factoryGoodsName?item.factoryGoodsName:"";
html.push("<p>名称:<input type='text' class='w-goods-text' data-index="+item.__index+" value='"+txt+"' placeholder='分类名称' required/><p>");
html.push("<p>色系:" + item.goodsName + "<p>");
html.push('<button type="button" data-index=' + item.__index + ' class="sortdelete btn btn-danger btn-xs">删除</button>');
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) {
//goodsColorImage
return "<input type=file name='goodsColorImage' id='file__" + item.__index + "' value='" + item.goodsColorImage + "' />";
}
}, {
display: "<label class='red'>分类名称,款型编码,选择尺码,默认销售价必填</label>",
render: function(item) {
if (!item.isAdd && !g.__gsm.hasOwnProperty(item.__index)) {
g.__gsm[item.__index] = item.goodsSizeList.length;
}},
{
display:"分类图片",render:function(item){
//goodsColorImage
return "<input type=file name='goodsColorImage' id='file__"+item.__index+"' value='"+item.goodsColorImage+"' />";
}
var html = [];
html.push("<div class='form-group'><div class='col-sm-11 red'><input type=text value='" + item.modelCode + "' data-index=" + item.__index + " class='modelCode form-control' placeholder='款型编码' required/></div></div>");
html.push('<div class="rows" id="rows__' + item.__index + '">');
item.goodsSizeList = item.goodsSizeList || [$.extend({}, ENUM.goodsSizeList)];
var ISXIANGO = (common.util.__input("isAdvance") == "Y" && +RESPONSEDATA.isAuditing == 200) ? true : false;
html.push(common.util.__template2($("#template").html(), {
index: item.__index,
ISXIANGO: ISXIANGO,
goodsSizeList: item.goodsSizeList
}));
html.push('</div>');
return html.join('');
}
}],
complete: function() {
var sort = Bll.validateSort();
if (sort) {
new common.dropDown({
el: ".btn-sort-chima",
ajax: "sortsize2",
params: function() {
return {
"sortId": Bll.validateSort()
};
},
{
display:"<label class='red'>分类名称,款型编码,选择尺码,默认销售价必填</label>",render:function(item){
if(!item.isAdd&&!g.__gsm.hasOwnProperty(item.__index)){
g.__gsm[item.__index]=item.goodsSizeList.length;
}
});
}
g.__e.init();
for (var i in g.__gsm) {
var warp = $("#rows__" + i).children(".form-group").slice(0, g.__gsm[i]);
warp.find("input").prop("readonly", true);
warp.find("select").prop("disabled", true);
warp.find(".btn-sort-remove").remove();
warp.find(".btn-sort-kucun").prop("readonly", false);
}
for (var i = 0; i < g.__length; i++) {
var warp = $("#basicTable").find("tbody").children("tr").eq(i);
warp.find(".w-goods-text").prop("readonly", true).prop("disabled", true);
warp.find("input[name=file]").prop("readonly", true).prop("disabled", true);
warp.find(".modelCode").prop("readonly", true).prop("disabled", true);
// 如果为undefind,则清除require,并且设置为空
if (warp.find(".modelCode").val() == "undefined") {
warp.find(".modelCode").removeAttr("required").val('');
var html=[];
html.push("<div class='form-group'><div class='col-sm-11 red'><input type=text value='"+item.modelCode+"' data-index="+item.__index+" class='modelCode form-control' placeholder='款型编码' required/></div></div>");
html.push('<div class="rows" id="rows__'+item.__index+'">');
item.goodsSizeList=item.goodsSizeList||[$.extend({},ENUM.goodsSizeList)];
var ISXIANGO=(common.util.__input("isAdvance")=="Y"&&+RESPONSEDATA.isAuditing==200)?true:false;
html.push(common.util.__template2($("#template").html(),{index:item.__index,ISXIANGO:ISXIANGO,goodsSizeList:item.goodsSizeList}));
html.push('</div>');
return html.join('');
}
//
warp.find(".sortdelete").remove();
}
],
complete:function(){
var sort=Bll.validateSort();
if(sort){
new common.dropDown({
el: ".btn-sort-chima",
ajax: "sortsize2",
params: function(){
return {
"sortId" : Bll.validateSort()
};
}
});
}
g.__e.init();
for(var i in g.__gsm){
var warp=$("#rows__"+i).children(".form-group").slice(0, g.__gsm[i]);
warp.find("input").prop("readonly",true);
warp.find("select").prop("disabled",true);
warp.find(".btn-sort-remove").remove();
warp.find(".btn-sort-kucun").prop("readonly",false);
}
for(var i=0;i<g.__length;i++){
var warp=$("#basicTable").find("tbody").children("tr").eq(i);
warp.find(".w-goods-text").prop("readonly",true).prop("disabled",true);
warp.find("input[name=file]").prop("readonly",true).prop("disabled",true);
warp.find(".modelCode").prop("readonly",true).prop("disabled",true);
// 如果为undefind,则清除require,并且设置为空
if(warp.find(".modelCode").val()=="undefined"){
warp.find(".modelCode").removeAttr("required").val('');
}
//
warp.find(".sortdelete").remove();
}
}
});
g.__rows = RESPONSEDATA.baseGoodList || [];
g.__gsm = {};
g.__length = g.__rows.length;
g.__e = new common.edit("#basicTable", {
bucket: "goodsimg"
});
g.__rows=RESPONSEDATA.baseGoodList||[];
g.__gsm={};
g.__length=g.__rows.length;
g.__e=new common.edit("#basicTable",{bucket:"goodsimg"});
g.init(g.__rows);
g.__e.on("callback", function(obj) {
if (/^file_onComplete/.test(obj.key)) {
var _index = obj.key.replace(/^file_onComplete_file__/, '');
g.__rows[_index].goodsColorImage = obj.data;
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 (!Bll.validateSort()) {
common.util.__tip("请选择完整的分类目录", "warning");
$(document).on("click",".sortadd",function(){
var text=$(this).text();
if(!Bll.validateSort()){
common.util.__tip("请选择完整的分类目录","warning");
return;
}
if ($.trim($("#salesPriceStr").val()) == "") {
common.util.__tip("请填写销售价", "warning");
if ($.trim($("#salesPriceStr").val())=="") {
common.util.__tip("请填写销售价","warning");
return;
}
if (g.__e.validate()) {
var goodsSizeList = $.extend({}, ENUM.goodsSizeList);
goodsSizeList.salePrice = $("#salesPriceStr").val();
if(g.__e.validate()){
var goodsSizeList=$.extend({},ENUM.goodsSizeList);
goodsSizeList.salePrice=$("#salesPriceStr").val();
g.__rows.push({
"modelCode": "",
"goodsColorImage": "",
goodsName: $(this).text(),
"goodsColorImage": "",
goodsName: $(this).text(),
colorId: (+$(this).data("id")),
goodsSizeList: [goodsSizeList],
isAdd: true
});
goodsSizeList: [goodsSizeList],
isAdd:true
});
g.reload();
// g.__e.init();
}
});
$(document).on("keydown", "#productName", function() {
Bll.IsEnter = true;
$(document).on("keydown","#productName",function(){
Bll.IsEnter=true;
});
$(document).on("change", "#brandId", function() {
var id = $(this).val();
Bll.productNameArr[0] = $(this).find("option[value='" + id + "']").text();
$(document).on("change","#brandId",function(){
var id=$(this).val();
Bll.productNameArr[0]=$(this).find("option[value='"+id+"']").text();
Bll.setProductName();
$("#supplierId").val(-1).trigger("change");
$("#shopId").val(-1).trigger("change");
tabTree.isfeeze = false;
tabTree.init([{
id: "",
sortName: ""
}, {
id: "",
sortName: ""
}, {
id: "",
sortName: ""
}, {
id: "",
sortName: ""
}]);
$("#supplierId").val(-1).trigger("change");
$("#shopId").val(-1).trigger("change");
tabTree.isfeeze=false;
tabTree.init([{id:"",sortName:""},{id:"",sortName:""},{id:"",sortName:""},{id:"",sortName:""}]);
});
$(document).on("change", "#supplierId", function() {
tabTree.isfeeze = false;
tabTree.init([{
id: "",
sortName: ""
}, {
id: "",
sortName: ""
}, {
id: "",
sortName: ""
}, {
id: "",
sortName: ""
}]);
$(document).on("change","#supplierId",function(){
tabTree.isfeeze=false;
tabTree.init([{id:"",sortName:""},{id:"",sortName:""},{id:"",sortName:""},{id:"",sortName:""}]);
});
$(document).on("change", ":radio[name=gender]", function() {
Bll.productNameArr[1] = ["男", "女", "通用"][+$(this).val() - 1];
$(document).on("change",":radio[name=gender]",function(){
Bll.productNameArr[1]=["男","女","通用"][+$(this).val()-1];
Bll.setProductName();
});
$(document).on("change", ":radio[name=isAdvance]", function() {
$(document).on("change",":radio[name=isAdvance]",function(){
g.reload();
$("#stock").val("");
$.each(g.__rows, function(inex, item) {
$.each(item.goodsSizeList, function(inex1, item1) {
item1.presaleStorageNum = "";
$.each(g.__rows,function(inex,item){
$.each(item.goodsSizeList,function(inex1,item1){
item1.presaleStorageNum="";
});
});
if ($(this).val() == "Y") {
$("#expectArrivalTimeStr").attr("required", "required");
if($(this).val()=="Y"){
$("#expectArrivalTimeStr").attr("required","required");
$("#expectArrivalTimeStrTxt").html("预计到货时间<span class='red'>*</span>");
} else {
}else{
$("#expectArrivalTimeStr").removeAttr("required");
$("#expectArrivalTimeStrTxt").html("预计到货时间");
}
});
$(document).on("change", ".salesPriceStr", function() {
ENUM.goodsSizeList.salePrice = $.trim($(this).val());
$(document).on("change",".salesPriceStr",function(){
ENUM.goodsSizeList.salePrice=$.trim($(this).val());
});
$(document).on("click", ".sortdelete", function() {
var that = this;
common.dialog.confirm("温馨提示", "你确定删除吗?", function() {
var index = $(that).data("index");
[].splice.call(g.__rows, index, 1);
$(document).on("click",".sortdelete",function(){
var that=this;
common.dialog.confirm("温馨提示","你确定删除吗?",function(){
var index=$(that).data("index");
[].splice.call(g.__rows,index,1);
g.reload();
});
// g.__e.init();
});
$(document).on("change", ".modelCode", function() {
var item = g.__rows[$(this).data("index")];
item.modelCode = $(this).val();
$(document).on("change",".modelCode",function(){
var item=g.__rows[$(this).data("index")];
item.modelCode=$(this).val();
});
$(document).on("click", ".btn-sort-add", function() {
var item = g.__rows[$(this).data("index")];
var goodsSizeList = $.extend({}, ENUM.goodsSizeList);
goodsSizeList.salePrice = $("#salesPriceStr").val();
$(document).on("click",".btn-sort-add",function(){
var item=g.__rows[$(this).data("index")];
var goodsSizeList=$.extend({},ENUM.goodsSizeList);
goodsSizeList.salePrice=$("#salesPriceStr").val();
item.goodsSizeList.push(goodsSizeList);
g.reload();
// g.__e.init();
});
$(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);
$(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);
g.reload();
// g.__e.init();
});
$(document).on("change", ".btn-sort-chima", function() {
var _index = $(this).data("index");
var _eq = $(this).data("eq");
var item = g.__rows[_index].goodsSizeList[_eq];
item.sizeId = $(this).val();
item.sizeName = $(this).find("option[value='" + item.sizeId + "']").text();
$(document).on("change",".btn-sort-chima",function(){
var _index=$(this).data("index");
var _eq=$(this).data("eq");
var item=g.__rows[_index].goodsSizeList[_eq];
item.sizeId=$(this).val();
item.sizeName=$(this).find("option[value='"+item.sizeId+"']").text();
});
$(document).on("change", ".btn-sort-xiaoshou", function() {
var _index = $(this).data("index");
var _eq = $(this).data("eq");
var item = g.__rows[_index].goodsSizeList[_eq];
item.salePrice = $(this).val();
$(document).on("change",".btn-sort-xiaoshou",function(){
var _index=$(this).data("index");
var _eq=$(this).data("eq");
var item=g.__rows[_index].goodsSizeList[_eq];
item.salePrice=$(this).val();
});
$(document).on("change", ".btn-sort-tiaoma", function() {
var _index = $(this).data("index");
var _eq = $(this).data("eq");
var item = g.__rows[_index].goodsSizeList[_eq];
item.barCode = $(this).val();
$(document).on("change",".btn-sort-tiaoma",function(){
var _index=$(this).data("index");
var _eq=$(this).data("eq");
var item=g.__rows[_index].goodsSizeList[_eq];
item.barCode=$(this).val();
});
$(document).on("change", ".btn-sort-kebu", function() {
var _index = $(this).data("index");
var _eq = $(this).data("eq");
var item = g.__rows[_index].goodsSizeList[_eq];
item.isSuppled = $(this).val();
$(document).on("change",".btn-sort-kebu",function(){
var _index=$(this).data("index");
var _eq=$(this).data("eq");
var item=g.__rows[_index].goodsSizeList[_eq];
item.isSuppled=$(this).val();
});
$(document).on("change", ".btn-sort-kucun", function() {
var _index = $(this).data("index");
var _eq = $(this).data("eq");
var item = g.__rows[_index].goodsSizeList[_eq];
item.presaleStorageNum = $(this).val();
var total = 0;
$.each(g.__rows, function(index, item1) {
$.each(item1.goodsSizeList, function(index, item2) {
total += (+item2.presaleStorageNum);
$(document).on("change",".btn-sort-kucun",function(){
var _index=$(this).data("index");
var _eq=$(this).data("eq");
var item=g.__rows[_index].goodsSizeList[_eq];
item.presaleStorageNum=$(this).val();
var total=0;
$.each(g.__rows,function(index,item1){
$.each(item1.goodsSizeList,function(index,item2){
total+=(+item2.presaleStorageNum);
});
});
$("#stock").val(total);
});
$(document).on("change", ".w-goods-text", function() {
var item = g.__rows[$(this).data("index")];
item.factoryGoodsName = $(this).val();
$(document).on("change",".w-goods-text",function(){
var item=g.__rows[$(this).data("index")];
item.factoryGoodsName=$(this).val();
});
$(document).on("change", ":checkbox[name=ageLevel]", function() {
var value = $(this).val();
var c = $(":checkbox[name=ageLevel]");
if ($(this).is(":checked")) {
if (value == 1) {
c.eq(1).prop("checked", false);
c.eq(2).prop("checked", false);
} else {
c.eq(0).prop("checked", false);
$(document).on("change",":checkbox[name=ageLevel]",function(){
var value=$(this).val();
var c=$(":checkbox[name=ageLevel]");
if($(this).is(":checked")){
if(value==1){
c.eq(1).prop("checked",false);
c.eq(2).prop("checked",false);
}else{
c.eq(0).prop("checked",false);
}
}
var arr = [];
$(":checked[name=ageLevel]").each(function() {
var arr=[];
$(":checked[name=ageLevel]").each(function(){
arr.push($(this).val())
});
$("#ageLevel").val(arr.join('|'));
});
$(document).on("change", ".attr_input", function() {
var item = ag.rows[$(this).data("index")];
item.val = $(this).val();
$(document).on("change",".attr_input",function(){
var item=ag.rows[$(this).data("index")];
item.val=$(this).val();
});
$(document).on("change", ".attr_checkobx_class", function() {
var item = ag.rows[$(this).data("index")];
item.val = $("#attr_" + $(this).data("index")).val();
$(document).on("change",".attr_checkobx_class",function(){
var item=ag.rows[$(this).data("index")];
item.val=$("#attr_"+$(this).data("index")).val();
})
var e = new common.edit("#basicInfo");
e.on("validate", function() {
var e=new common.edit("#basicInfo");
e.on("validate",function(){
return g.__e.validate();
});
e.init();
e.on("validate", function() {
if (Bll.validateSort()) {
e.on("validate",function(){
if(Bll.validateSort()){
return true;
}
return "请选择完整的分类目录";
});
e.on("validate", function() {
e.on("validate",function(){
console.log(g.__gsm);
if (g.__rows.length == 0) {
if(g.__rows.length==0){
return "请添加销售属性";
}
var map = {},
map2 = {},
map3 = [],
_count = 0,
_count1 = 0;
if (g.__rows.length > 0) {
$.each(g.__rows, function(index, item) {
var gname = item.factoryGoodsName;
$.each(item.goodsSizeList, function(index1, item1) {
var key = gname + "_" + item1.sizeId;
if (map.hasOwnProperty(key)) {
var map={},map2={},map3=[],_count=0,_count1=0;
if(g.__rows.length>0){
$.each(g.__rows,function(index,item){
var gname= item.factoryGoodsName;
$.each(item.goodsSizeList,function(index1,item1){
var key=gname+"_"+item1.sizeId;
if(map.hasOwnProperty(key)){
_count++;
return;
}
//RESPONSEDATA.productSkn
console.log("item1.barCode", item1.barCode)
map[gname + "_" + item1.sizeId] = "";
console.log("item1.barCode",item1.barCode)
map[gname+"_"+item1.sizeId]="";
//修改
if (RESPONSEDATA.productSkn) {
if (index1 > g.__gsm[index] - 1) {
if(RESPONSEDATA.productSkn){
if(index1>g.__gsm[index]-1){
//大于原来的计算
if (map2.hasOwnProperty(item1.barCode)) {
if(map2.hasOwnProperty(item1.barCode)){
_count1++;
}
map2[item1.barCode] = "";
console.log("大于原来的计算", item1.barCode + ":" + _count1);
} else {
map2[item1.barCode]="";
console.log("大于原来的计算",item1.barCode+":"+_count1);
}else{
//小于原来,并且有值
if (item1.barCode) {
if (map2.hasOwnProperty(item1.barCode)) {
if(item1.barCode){
if(map2.hasOwnProperty(item1.barCode)){
_count1++;
}
map2[item1.barCode] = "";
console.log("小于原来,并且有值", _count1);
map2[item1.barCode]="";
console.log("小于原来,并且有值",_count1);
}
console.log("没值", _count1);
console.log("没值",_count1);
}
} else {
}else{
//添加时候计算
if (item1.barCode) {
if (map2.hasOwnProperty(item1.barCode)) {
if(item1.barCode){
if(map2.hasOwnProperty(item1.barCode)){
_count1++;
}
map2[item1.barCode] = "";
map2[item1.barCode]="";
}
console.log("添加时候计算", _count1);
console.log("添加时候计算",_count1);
}
if (g.__gsm[index] && index1 < g.__gsm[index]) {
if(g.__gsm[index]&&index1<g.__gsm[index]){
return;
}
map3.push(item1.barCode);
});
});
}
if (_count > 0) {
if(_count>0){
return "同一颜色包含两组相同尺码";
}
if (_count1 > 0) {
if(_count1>0){
return "商品条码不能重复";
} else {
if (map3.length > 0) {
var ispass = true;
if (map3.indexOf("") > -1) {
ispass = "商品条码不能为空";
return ispass;
}
common.util.__ajax2({
url: '/goods/base/checkSkuBarCodeExist',
async: false,
data: {
barCode: map3.join(',')
}
}, function(res) {
if (res.data.length) {
ispass = "商品条码" + res.data.join(',') + "已经存在";
}else{
if(map3.length>0){
var ispass=true;
if(map3.indexOf("")>-1){
ispass="商品条码不能为空";
return ispass;
}
common.util.__ajax2({
url:'/goods/base/checkSkuBarCodeExist',
async:false,
data:{barCode:map3.join(',')}
},function(res){
if(res.data.length){
ispass="商品条码"+res.data.join(',')+"已经存在";
}
}, true);
return ispass;
},true);
return ispass;
}
}
});
e.on("validate", function() {
if ((+$("#salesPriceStr").val()) > (+$("#retailPriceStr").val())) {
e.on("validate",function(){
if((+$("#salesPriceStr").val())>(+$("#retailPriceStr").val())){
return "销售价应该限定小于等于吊牌价";
}
});
... ... @@ -600,31 +529,36 @@ e.on("validate", function() {
// });
$(document).on("click", "#btnReview", function() {
if (e.validate()) {
common.dialog.confirm("温馨提示", "<p>你确定提交吗?</p>", function() {
e.submit($("#basicForm").attr("action"), function(option) {
var select = tabTree.getAddress();
$(document).on("click","#btnReview",function(){
var $this=$(this);
option.data.supplierId = common.util.__input("supplierId") ? $("#supplierId").val() : "0";
option.data.shopId = common.util.__input("shopId") ? $("#shopId").val() : "0";
if(e.validate()){
common.dialog.confirm("温馨提示","<p>你确定提交吗?</p>",function(){
common.util.__disButton.call($this);
option.data.productSkn = param ? param[0] : "";
option.data.maxSortId = select[0] ? select[0].id : "";
option.data.middleSortId = select[1] ? select[1].id : "";
option.data.smallSortId = select[2] ? select[2].id : "";
option.data.sortId = select[3] ? select[3].id : "";
e.submit($("#basicForm").attr("action"),function(option){
var select=tabTree.getAddress();
option.data.supplierId=common.util.__input("supplierId")?$("#supplierId").val():"0";
option.data.shopId=common.util.__input("shopId")?$("#shopId").val():"0";
option.data.productSkn=param?param[0]:"";
option.data.maxSortId=select[0]?select[0].id:"";
option.data.middleSortId=select[1]?select[1].id:"";
option.data.smallSortId=select[2]?select[2].id:"";
option.data.sortId=select[3]?select[3].id:"";
// option.data.shopId=$("#shopId").val();
option.data.brandId = $("#brandId").val();
option.data.brandId=$("#brandId").val();
option.data.isAuditing = RESPONSEDATA.isAuditing ? RESPONSEDATA.isAuditing : "";
option.data.isAuditing=RESPONSEDATA.isAuditing?RESPONSEDATA.isAuditing:"";
option.data.seasons = option.data.seasons ? option.data.seasons.replace(/\|/g, ',') : "";
option.data.seasons=option.data.seasons?option.data.seasons.replace(/\|/g,','):"";
//expectShelfTime
// option.data=new Date(expectShelfTime).getTime();
option.data.baseGoodInfoStr = JSON.stringify(g.__rows);
option.data.baseGoodInfoStr=JSON.stringify(g.__rows);
/*获取非销售属性数据*/
... ... @@ -665,22 +599,22 @@ $(document).on("click", "#btnReview", function() {
// option.debug=true;
// console.log(option.data);
option.success = function(res) {
res = res.data;
if (res.code == "200") {
e.$tip("提交成功", function() {
location.href = "/product/base/index"
}, 'growl-success');
} else {
e.$tip(res.message);
}
},
option.error = function(res) {
e.$tip(res.message);
}
option.success=function(res){
res = res.data;
if(res.code == "200") {
e.$tip("提交成功", function() {
location.href="/product/base/index"
}, 'growl-success');
}else{
e.$tip(res.message);
}
},
option.error=function(res){
e.$tip(res.message);
}
});
})
}
return false;
});
\ No newline at end of file
});
... ...
... ... @@ -88,7 +88,7 @@ new common.dropDown({
});
new common.dropDown({
el: "#brandId",
ajax: "brand",
ajax: "queryBrandByShopId",
hash: true,
params: function() {
return {
... ...
... ... @@ -12,7 +12,7 @@
"spm": {
"main": "index.js",
"dependencies": {
"jquery": "1.9.1",
"jquery": "2.1.4",
"import-style": "1.0.0",
"yoho.handlebars": "3.0.3",
"yoho.bootstrap": "0.0.4"
... ...
... ... @@ -166,7 +166,7 @@ exports.res = [{ //基础商品列表
data: {
pageTitle: "创建基础商品",
action: "/base/goods/ajax/add",
btnText: "提交审核"
btnText:"提交审核"
},
src: '/basegoods/edit'
}, { //添加接口
... ... @@ -266,7 +266,7 @@ exports.res = [{ //基础商品列表
data: {
pageTitle: "修改基础商品",
action: "/base/goods/ajax/update",
btnText: "保存"
btnText:"保存"
}
}, { //删除
route: '/base/goods/ajax/delete',
... ... @@ -444,7 +444,8 @@ exports.res = [{ //基础商品列表
method: 'GET',
view: 'pages/basegoods/info',
src: '/basegoods/goodsInfo'
}, {
},
{
// 获取商品详情数据
route: '/base/goods/getData',
method: 'POST',
... ... @@ -452,9 +453,9 @@ exports.res = [{ //基础商品列表
params: [{
name: 'productSkn',
type: 'Number'
}, {
name: 'isAuditing',
type: 'Number'
},{
name:'isAuditing',
type:'Number'
}]
}, { //获取颜色
route: '/base/goods/queryProductColors',
... ... @@ -500,10 +501,11 @@ exports.res = [{ //基础商品列表
method: 'POST',
url: '/product/queryMaterialList',
params: [{
name: 'categoryId',
type: 'Number'
}]
}, {
name: 'categoryId',
type: 'Number'
}
]
},{
route: '/goods/query/querySortBySmallSort',
method: 'POST',
url: '/product/querySortBySmallSort',
... ... @@ -545,5 +547,12 @@ exports.res = [{ //基础商品列表
name: "barCode",
type: "String"
}]
}, {
route:'/ajax/queryBatchImportResult',
method:'POST',
url:'/product/queryBatchImportResult',
params:[
{name:"param",type:"String"}
]
}
];
\ No newline at end of file
... ...
... ... @@ -13,7 +13,11 @@
</li>
</ul>
<h6>{{pageTitle}}</h6>
<div>
<div style="width: 30%;float: left;">
<h4>{{pageTitle}}</h4>
</div>
</div>
</div>
</div>
</div>
... ...
... ... @@ -13,7 +13,11 @@
</li>
</ul>
<h6>{{pageTitle}}</h6>
<div>
<div style="width: 30%;float: left;">
<h4>{{pageTitle}}</h4>
</div>
</div>
</div>
</div>
</div>
... ...
... ... @@ -9,7 +9,7 @@
<li><a href="#" onclick="javascript:history.go(-1);">商品</a></li>
<li>基础商品</li>
</ul>
<h6>{{pageTitle}}</h6>
<h4>{{pageTitle}}</h4>
</div>
</div><!-- media -->
</div>
... ... @@ -59,7 +59,7 @@
<div class="panel-footer">
<div class="row">
<div class="col-sm-8 col-sm-offset-2">
<a class="btn btn-default" href="/supplier/baseproduct/index">取消</a>
<a class="btn btn-default" href="/product/base/index">取消</a>
<button type="submit" class="btn btn-success mr5" data-loading-text="保存中..." id="btnReview">{{btnText}}</button>
</div>
</div>
... ...
... ... @@ -11,7 +11,7 @@
<li>基础商品</li>
</ul>
<h6>查看详情</h6>
<h4>查看详情</h4>
</div>
</div>
</div>
... ... @@ -93,10 +93,6 @@
</div>
<div class="panel-footer">
[[if isAuditing!="200"&&isAuditing!="300"]]
<button class="btn btn-primary apply-success">通过</button>
<button class="btn btn-primary apply-back">驳回</button>
[[/if]]
<button onclick="history.go(-1);" type="button" class="btn btn-primary btn-info">返回</button>
</div>
</form>
... ...