Authored by weiqingting

批量修改

... ... @@ -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;
... ... @@ -79,17 +80,26 @@ $(document).on("change","#brandId",function(){
function __ajaxExeclById(unquid){
var fn=arguments.callee;
var params={param:unquid};
common.util.__ajax({
url:'',
data:{unquid:unquid}
url:'/ajax/queryBatchImportResult',
data:params
},function(res){
if(res.data){
$("#message").html('');
if(res.data.length){
//成功操作
if (loadModal) {
loadModal.close();
}
common.util.__tip(res.message, 'success');
}else{
fn.call(null,unquid);
setTimeout(function(){
__ajaxExeclById.call(null,unquid);
},5000);
}
});
$("#message").html(res.message);
},true);
}
// __ajaxExeclById("batchBasePrd1459835824928");
... ...
... ... @@ -37,7 +37,9 @@ var urlObj = {
'guangCommentGetFilterItems':'/guang/comment/getItems', // 逛-评论列表-获取筛选条件
'guangPlusSatrChannel':'/guang/plustarcategory/getCategoryNames', // 逛-plus star 频道
'queryBrandByShopId': '/query/brandByshopId', //查询店铺下关联品牌
'querySupplierByShopId': '/query/supplierByshopId' //查询店铺下关联供应商
'querySupplierByShopId': '/query/supplierByshopId', //查询店铺下关联供应商
'guangGetSort':'/guang/article/getSortList'//逛-分类
};
var minimumResultsForSearch = ["sortbybrand", "getjitSup", "sortsize2"];
... ...
... ... @@ -203,7 +203,8 @@ var util = {
keys.push(key + "=" + JSON.stringify(source[key]));
}
}
var header = "var result=[]," + keys.join(',') + ";";
var params1=keys.join(',').length?","+keys.join(','):"";
var header = "var result=[]" + params1 + ";";
... ...
var $ = require('jquery'),
common = require('../common/common');
var ENUM={};
// common.util.__ajax({
// url:'EnumListRest/getEnumList',
// async:false
// },function(res){
// ENUM=res.data;
// });
$("#panel-body").html(common.util.__template2($("#tempalte1").html(),{}));
new common.dropDown({el:"#authorId",ajax:"guangGetAuthorList"});
new common.dropDown({el:"#maxSortId",ajax:"guangGetSort",params:function(){
return {pid:0};
}});
new common.dropDown({el:"#minSortId",ajax:"guangGetSort",params:function(){
return {pid:$("#maxSortId").val()};
}});
var g=new common.gird({
el:"grid",
columns:[
{display:"选择","type":"checkbox"},
{display:"标签名",name:"tagName"}
]
});
$(document).on("click","#addUrl",function(){
common.dialog.confirm("添加链接",common.util.__template2($("#template2").html(),{}),function(){
});
});
$(document).on("click","#TagsSelectBtn",function(){
common.dialog.confirm("选择标签","<div id='gird'></div>",function(){
});
g.init('/guang/tags/getList');
});
var e=new common.edit("#panel-body",{});
e.init();
$(document).on("click","#submit",function(){
e.submit($("#panel-body").attr("action"),function(){
});
});
 
\ No newline at end of file
... ...
... ... @@ -251,3 +251,27 @@ input[type=date], input[type=time], input[type=datetime-local], input[type=month
max-width: 100%;
}
}
.tagwrap{
padding: 10px;
}
span.tag{
display: block;
float: left;
padding: 2px 5px;
text-decoration: none;
background: #1caf9a;
color: #fff;
margin-right: 5px;
margin-bottom: 5px;
font-size: 13px;
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
border-radius: 2px;
}
span.tag a {
font-weight: bold;
color: #fff;
opacity: 0.5;
text-decoration: none;
font-size: 11px;
}
\ No newline at end of file
... ...
... ... @@ -15,11 +15,11 @@ var config = {
// domain:'http://192.168.102.216:8080/platform',
// domain: 'http://172.16.6.240:8088/platform',
// domain:'http://172.16.6.240:8088/platform',// 王书生
// domain: 'http://172.16.6.124:8088/platform',//陈超
domain: 'http://172.16.6.214:8088/platform',//陈超
//http://172.16.6.124:8088/platform/product/queryAllProductAttr
// domain: 'http://172.16.6.227:8088/platform', //玛丽
//domain:'http://172.16.6.197:8080/yohobuy-platform-web',//葛超
domain: 'http://192.168.102.202:8088/platform',
// domain:'http://172.16.6.157:8080/yohobuy-platform-web',//葛超
// domain: 'http://192.168.102.202:8088/platform',
//domain: 'http://172.16.6.239:8080', //孙杰翔
loggers: {
api: {
... ...
... ... @@ -547,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
... ...
... ... @@ -140,6 +140,13 @@ exports.res = [
params:[
{name:"brandId",type:"Number"}
]
},{
route:'/guang/article/getSortList',
method:'POST',
url:'/guang/article/getSortList',
params:[
{name:"pid",type:"Number"}
]
}
]
\ No newline at end of file
... ...
... ... @@ -526,6 +526,16 @@ exports.res = [
method:'GET',
view:'pages/guang/contentEdit',
src:'/guang/contentEdit'
},
{
route:'/guang/article/getEnumList',
method:'POST',
url:'EnumListRest/getEnumList'
},
{
route:'/guang/tags/getList',
method:'POST',
url:'/guang/tags/getList'
}
];
... ...
var authService = require('../service/auth');
var uploader=require('../service/upload');
var down=require('../service/down');
var ueditor=require('../service/ueditor');
var link=require('../service/link');
module.exports = {
'/auth_bak':function(req, res){
... ... @@ -78,12 +75,12 @@ module.exports = {
uploader.uploadFile(req,res);
},
'/ajax/down':function(req,res){
down.downFile(req,res);
uploader.downFile(req,res);
},
'/ajax/ueditor':function(req,res){
ueditor.uploadFile(req,res);
uploader.ueditor(req,res);
},
'/ajax/link/:name':function(req,res){
link.linkFile(req,res);
uploader.linkFile(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 = require('../../config/common.js').domain;
//var domain = 'http://172.16.6.227:8088/platform'; //马力
// var domain = 'http://172.16.6.227:8083/yohobuy-platform-web';
exports.downFile = function(req, res) {
var options = {
method: 'POST',
url: domain + '/batch/export',
headers: {
'content-type': 'application/json'
},
body: req.query,
json: true
};
request(options).pipe(res);
}
\ No newline at end of file
var request = require('request');
var _ = require('lodash');
var fs = require('fs');
var path=require('path');
var domain = require('../../config/common.js').domain;
exports.linkFile = function(req, res) {
request.get(domain+"/common/"+req.params.name+".xlsx").pipe(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 = require('../../config/common.js').domain;
//var domain = 'http://172.16.6.227:8083/yohobuy-platform-web'; //马力
// var domain = 'http://172.16.6.162:8088/platform';
//var domain = 'http://172.16.6.240:8088/platform';
exports.uploadFile = function(req, res) {
var headers = {};
if (req.session && req.session.user) {
var ipObject = ipaddr.process(req.ip).octets
var ip = ipObject ? ipObject.join('.') : req.ip;
headers = {
'x-user-id': req.session.user.auth.pid,
'x-user-name': req.session.user.auth.account,
'x-site-type': 1,
'x-client-ip': ip
};
}else{
res.json({
code: "501",
message: "用户失效,请重新登录"
});
}
console.log(req.files);
if (req.is("multipart/form-data")) {
req.body.file = fs.createReadStream(req.files.upfile.path);
req.body.bucket="goodsimg";
request.post({
url: domain + '/fileupload/upload',
formData: req.body
}, function optionalCallback(error, httpResponse, body) {
// {"code":200,"data":"http://img12.static.yhbimg.com/goodsimg/2016/03/10/20/0258a569ab956e81339c7212bb23767c2d.jpg","message":"上传成功","status":true}
// {"originalName":"demo.jpg","name":"demo.jpg","url":"upload\/demo.jpg","size":"99697","type":".jpg","state":"SUCCESS"}
// {"originalName":"018da7232374448d10a565fdfe6211d078.jpg","name":"","url":"","type":".jpg","state":"SUCCESS"}
if (!error && httpResponse.statusCode == 200) {
var json = JSON.parse(body);
var result={};
result.originalName=json.data.substring(json.data.lastIndexOf('/')+1);
result.name=result.originalName;
result.url=json.data;
result.type=json.data.substring(json.data.lastIndexOf('.'));
result.state=json.message=="上传成功"?"SUCCESS":"FAIL";
res.send(JSON.stringify(result));
}else{
res.send({code:"500",message:"接口异常"});
}
});
} else {
res.json({
code: "500",
message: "请求类型错误"
});
}
}
\ No newline at end of file
... ... @@ -48,8 +48,7 @@ exports.uploadFile = function(req, res) {
request.post({
url: domain + '/batch/import?'+url.join("&"),
formData: req.body,
headers: headers,
timeout: 300000
headers: headers
}, function optionalCallback(error, httpResponse, body) {
if (error) {
return console.error('upload failed:', error);
... ... @@ -129,3 +128,94 @@ function joinimg(url) {
return 'http://img12.'+ url;
}
}
// exports.getSaveState=function(req,res){
// console.log("6666666");
// request.post({
// url: domain + '/product/queryBatchImportResult',
// formData: req.body
// }, function optionalCallback(error, httpResponse, body) {
// console.log(body);
// if (error) {
// return console.error('upload failed:', error);
// }
// if (!error && httpResponse.statusCode == 200) {
// var json = JSON.parse(body);
// json.status = true;
// // console.log(json);
// res.json(json);
// } else {
// res.json(errBackMsg);
// }
// });
// }
exports.ueditor = function(req, res) {
var headers = {};
if (req.session && req.session.user) {
var ipObject = ipaddr.process(req.ip).octets
var ip = ipObject ? ipObject.join('.') : req.ip;
headers = {
'x-user-id': req.session.user.auth.pid,
'x-user-name': req.session.user.auth.account,
'x-site-type': 1,
'x-client-ip': ip
};
}else{
res.json({
code: "501",
message: "用户失效,请重新登录"
});
}
console.log(req.files);
if (req.is("multipart/form-data")) {
req.body.file = fs.createReadStream(req.files.upfile.path);
req.body.bucket="goodsimg";
request.post({
url: domain + '/fileupload/upload',
formData: req.body
}, function optionalCallback(error, httpResponse, body) {
// {"code":200,"data":"http://img12.static.yhbimg.com/goodsimg/2016/03/10/20/0258a569ab956e81339c7212bb23767c2d.jpg","message":"上传成功","status":true}
// {"originalName":"demo.jpg","name":"demo.jpg","url":"upload\/demo.jpg","size":"99697","type":".jpg","state":"SUCCESS"}
// {"originalName":"018da7232374448d10a565fdfe6211d078.jpg","name":"","url":"","type":".jpg","state":"SUCCESS"}
if (!error && httpResponse.statusCode == 200) {
var json = JSON.parse(body);
var result={};
result.originalName=json.data.substring(json.data.lastIndexOf('/')+1);
result.name=result.originalName;
result.url=json.data;
result.type=json.data.substring(json.data.lastIndexOf('.'));
result.state=json.message=="上传成功"?"SUCCESS":"FAIL";
res.send(JSON.stringify(result));
}else{
res.send({code:"500",message:"接口异常"});
}
});
} else {
res.json({
code: "500",
message: "请求类型错误"
});
}
}
exports.linkFile = function(req, res) {
request.get(domain+"/common/"+req.params.name+".xlsx").pipe(res);
}
exports.downFile = function(req, res) {
var options = {
method: 'POST',
url: domain + '/batch/export',
headers: {
'content-type': 'application/json'
},
body: req.query,
json: true
};
request(options).pipe(res);
}
\ No newline at end of file
... ...
... ... @@ -11,13 +11,8 @@
</ul>
<div>
<div style="width: 30%;float: left;">
<h4>添加文章</h4>
</div>
<div style="width: 70%;float: right;">
</div>
</div>
</div>
</div><!-- media -->
</div>
... ... @@ -29,14 +24,13 @@
<div class="panel-heading">
<h4 class="panel-title">添加文章</h4>
</div>
<div class="panel-body">
<div class="panel-body form-horizontal" id="panel-body" action="{{action}}">
</div>
<div class="panel-footer">
<div class="row">
<div class="col-sm-9 col-sm-offset-3">
<input type="hidden" name="id" value="41968">
<button type="submit" data-loading-text="保存中..." class="btn btn-primary mr5">保存</button>
<button type="submit" id="submit" class="btn btn-primary mr5">保存</button>
</div>
</div>
</div>
... ... @@ -46,20 +40,30 @@
</div>
<script type="text/tempalte" id="tempalte1">
<div class="rows">
<div class="row" id="baseform">
<div class="form-group">
<label class="col-sm-1 control-label">文章标题</label>
<div class="col-sm-9">
<label class="col-sm-2 control-label">文章标题:</label>
<div class="col-sm-8">
<input type="text" id="articleTitle" class="form-control" placeholder="文章标题" required="" value="[[articleTitle]]">
</div>
</div>
<div class="form-group">
<label class="col-sm-1 control-label">文章分类</label>
<label class="col-sm-2 control-label">文章分类:</label>
<!--文章分类-->
<div class="col-sm-2">
<select class="form-control" id="maxSortId">
<option value="[[maxSortId||'-1']]">[[maxSortName||'请选择一级分类']]</option>
</select>
</div>
<div class="col-sm-2">
<select class="form-control" id="minSortId">
<option value="[[minSortId||'-1']]">[[minSortName||'请选择二级分类']]</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-1 control-label">性别</label>
<div class="col-sm-9">
<label class="col-sm-2 control-label">性别:</label>
<div class="col-sm-8">
<input type="radio" value="1" name="articleGender">
<label></label>
<input type="radio" value="2" name="articleGender">
... ... @@ -70,30 +74,30 @@
</div>
</div>
<div class="form-group">
<label class="col-sm-1 control-label">选择作者</label>
<div class="col-sm-9">
<label class="col-sm-2 control-label">选择作者:</label>
<div class="col-sm-8">
<select class="form-control" id="authorId">
<option value="[[authorId||'']]">[[authorName||'请选择']]</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-1 control-label">文章摘要</label>
<div class="col-sm-9">
<label class="col-sm-2 control-label">文章摘要:</label>
<div class="col-sm-8">
<textarea rows="2" id="articleSummary" class="form-control" placeholder="文章摘要" >
[[articleSummary]]
</textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-1 control-label">封面图</label>
<div class="col-sm-9">
<label class="col-sm-2 control-label">封面图:</label>
<div class="col-sm-8">
<input type="file" name="coverImage" id="coverImage" value="[[coverImage]]" />
</div>
</div>
<div class="form-group">
<label class="col-sm-1 control-label">图片类型</label>
<div class="col-sm-9">
<label class="col-sm-2 control-label">图片类型:</label>
<div class="col-sm-8">
<input type="radio" value="1" name="coverImageType">
<label>方形</label>
<input type="radio" value="2" name="coverImageType" checked="">
... ... @@ -103,8 +107,8 @@
</div>
<div class="form-group">
<label class="col-sm-1 control-label">文章类型</label>
<div class="col-sm-9">
<label class="col-sm-2 control-label">文章类型:</label>
<div class="col-sm-8">
<select class="form-control" value="[[articleType]]" id="articleType">
<option value="1">普通文章</option>
<option value="2">广告</option>
... ... @@ -112,8 +116,8 @@
</div>
</div>
<div class="form-group">
<label class="col-sm-1 control-label">广告尺寸</label>
<div class="col-sm-9">
<label class="col-sm-2 control-label">广告尺寸:</label>
<div class="col-sm-8">
<select class="form-control" value="[[adsImgSize]]" id="adsImgSize">
<option value="">请选择广告图片尺寸</option>
<option value="10881088">1088X1088</option>
... ... @@ -123,31 +127,115 @@
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<label class="col-sm-1 control-label">链接</label>
<div class="col-sm-9">
<input type="text" name="url" id="url" value="" class="form-control" placeholder="请输入内容链接" readonly="true" required=""> <button type="button" class="btn btn-info" id="addUrl">添加链接</button>
<label class="col-sm-2 control-label">链接:</label>
<div class="col-sm-7">
<input type="text" name="url" id="url" value="" class="form-control" placeholder="请输入内容链接" readonly="true" required="">
<p style="color:#999">注:链接中不能有英文单引号</p>
</div>
<div class="col-sm-1">
<button type="button" class="btn btn-info" id="addUrl">添加链接</button>
</div>
</div>
<div class="form-group">
<label class="col-sm-1 control-label">文章内容</label>
<div class="col-sm-9">
<label class="col-sm-2 control-label">文章内容:</label>
<div class="col-sm-8">
<select class="form-control"></select>
</div>
</div>
<div class="form-group">
<label class="col-sm-1 control-label">添加品牌</label>
<div class="col-sm-9">
<select class="form-control"></select>
<label class="col-sm-2 control-label">添加品牌:</label>
<div class="col-sm-8">
<ul class="cover-image-list col-sm-10" id="addPic" style="padding: 0;margin: 0;">
<li class="cover-image-item fileinput-button">
<div class="goods-img">
<a class="fileinput-button-icon" href="javascript:void(0);">+</a>
<input type="file" class="goods-img-upload picfile" name="picfile" required="required" placeholder="图片">
</div>
</li>
</ul>
</div>
</div>
<div class="form-group">
<label class="col-sm-1 control-label">选择标签</label>
<div class="col-sm-9">
<select class="form-control"></select>
<label class="col-sm-2 control-label">选择标签:</label>
<div class="col-sm-6">
<div id="taglist" class="tagwrap">
<span class="tag"><span>街头&nbsp;&nbsp;</span><a href="#" title="Removing tag">x</a></span>
</div>
</div>
<div class="col-sm-1">
<button class="btn btn-info" type="button" id="TagsSelectBtn">选择标签</button>
</div>
</div>
</div>
</script>
<script type="text/tempalte" id="template2">
<div class="rows">
<div class="form-group">
<label class="col-sm-2 control-label">选择跳转目的地:</label>
<div class="col-sm-8">
<select name="goTo" class="form-control">
<option value="">选择跳转目的</option>
<option value="brand">品牌列表页</option>
<option value="productDetail">商品详情页</option>
<option value="coupon">优惠券页</option>
<option value="fav">收藏列表页</option>
<option value="mine">我的页面</option>
<option value="list">列表或搜索页</option>
<option value="attention">关注页</option>
<option value="plus">plus</option>
<option value="star">star</option>
<option value="new">新品到着页</option>
<option value="sale">折扣页</option>
<option value="h5">h5网页</option>
<option value="guangchannel">逛频道</option>
<option value="gender">男女首页</option>
<option value="activity">app活动页</option>
<option value="home" selected="selected">频道首页</option>
<option value="yohood">YOHOOD</option>
<option value="top100">热销排行</option>
<option value="activitytemplate">活动模板</option>
<option value="globalpurchase">全球购</option>
<option value="subchannel">二级频道</option>
<option value="guangchannel">逛频道或SHOW晒单页</option>
<option value="showgoods">去晒单</option>
<option value="limitpurchase">尖货频道</option>
<option value="vippro">会员商品</option>
<option value="shortsize">断码页</option>
<option value="discountmarket">折扣专区</option>
<option value="discountmarketpro">折扣专区详情页</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">跳转地址:</label>
<div class="col-sm-8">
<textarea rows="2" id="articleSummary" class="form-control" placeholder="文章摘要" ></textarea>
</div>
</div>
</div>
</script>
<script type="text/template" id="template3">
[[each aa as index]]
<li class="cover-image-item image-list" data-index="2">
<div class="goods-img">
<a class="fileinput-button-icon" href="javascript:void(0);">
<img src="http://img11.static.yhbimg.com\goodsimg/2016/04/05/08/018a152691c03886bb23fc3eabb8ebafbf.jpg?imageView/2/w/100/h/100">
</a>
<i class="remove-item-btn remove1 glyphicon glyphicon-remove-circle" data-index="2"></i>
</div>
</li>
[[/each]]
</script>
\ No newline at end of file
... ...