Authored by 张帅

后台发布文章

<!DOCTYPE html>
<div id="tt" class="easyui-layout" fit="true" style="overflow-y: scroll">
<div id="tt" class="easyui-layout" fit="true" style="overflow-y: scroll;height: 80%" >
<form name="publishArticleForm" id="publishArticleForm" method="post" >
<div style="margin-top: 20px;margin-left: 30px">
<table border="0" style="width:95%;margin-top:5px;line-height:30px;" id="tab">
... ... @@ -17,16 +17,17 @@
</table>
</div>
</form>
<table id="labelGroupListTable"></table>
</div>
<div region="center" id="labelGroupList" style="margin-left: 20px">
<table id="labelGroupListTable"></table>
</div>
<script>
$("#searchBtn").linkbutton({
iconCls : "icon-search",
onClick : function() {
checkedItemsObj ={};
$("#labelGroupListTable").datagrid("load", {});
}
});
... ... @@ -38,51 +39,126 @@
fit: true,
fitColumns: true,
striped: true,
/*queryParams: {
rewardName: $("#rewardName1").textbox("getValue"),
status: $("#rewardstatus1").combobox("getValue"),
type: $("#rewardtype1").combobox("getValue")
},*/
// url: "http://admin.portal.yohobuy.com/yohosearch/search",
url: contextPath+"/labelGroupManage/getLabelGroupList",
onCheckAll: addcheckItem,
onCheck: addcheckItem,
onUncheckAll: removeAllItem,
onUncheck: removeSingleItem,
queryParams: {
query: $("#skn").textbox("getValue"),
status: 1,
sales: "Y",
stocknumber: "1",
attribute_not: "2"
},
url: "/yohosearch/search",
// url: contextPath+"/product/queryProductInfoBySkns",
// url: serverContextPath+"/labelGroupManage/getLabelGroupList",
method: 'POST',
loadFilter: function (data) {
var tmp = defaultLoadFilter(data);
tmp.rows = tmp.list;
return tmp;
},
// columns: [[
// {
// title: "ID",
// field: "id",
// width: 15,
// align: "center",
// checkbox:true,
// formatter: function (value, rowData, rowIndex) {
// return value;
// }
// },
//
// {
// title: "标签分组名称",
// field: "groupName",
// width: 30,
// align: "left"
// },
// {
// title: "所属标签数",
// field: "labelAmount",
// width: 20,
// align: "left"
// }, {
// title: "状态",
// field: "status",
// width: 25,
// align: "left",
// formatter: function (value, rowData, rowIndex) {
// if(value == '0'){
// return "关闭";
// }
// if(value == '1'){
// return "开启";
// }
// }
// }
//
// ]],
columns: [[
{
title: "ID",
field: "id",
title: "产品图片",
field: "default_images",
width: 15,
align: "center"
align: "center",
formatter: function (value, rowData, rowIndex) {
var result='';
if (value) {
if(value.indexOf('http://') == 0){
result = item.default_images.split("?")[0];
}else{
var fileMode = value.substring(15, 17);
if(fileMode=='01'){
result= "http://"+"img11.static.yhbimg.com"+"goodsimg"+value;
}
if(fileMode=='02'){
result= "http://"+"img12.static.yhbimg.com"+"goodsimg"+value;
}
}
}
else {
result = ""
}
if (result) {
return "<img width=120 height=60 src='" + result + "?imageMogr2/thumbnail/320x320/extent/320x320/background/d2hpdGU=/position/center/quality/90'/>";
} else {
return "";
}
}
},
{
title: "标签分组名称",
field: "groupName",
title: "产品名称",
field: "product_name",
width: 30,
align: "left"
},
{
title: "所属标签数",
field: "labelAmount",
title: "品牌",
field: "brand_name",
width: 20,
align: "labelAmount"
align: "left"
}, {
title: "状态",
field: "status",
title: "现价",
field: "sales_price",
width: 25,
align: "left",
formatter: function (value, rowData, rowIndex) {
if(value == '0'){
return "关闭";
}
if(value == '1'){
return "开启";
}
}
}, {
title: "吊牌价",
field: "market_price",
width: 25,
align: "left",
}, {
title: "库存",
field: "stock_number",
width: 25,
align: "left"
}
]],
... ... @@ -91,9 +167,14 @@
pageSize: 10,
pageList: [10],
idField: "id",
singleSelect: true,
checkbox:true,
onLoadSuccess: function (data) {
debugger
for (var i=0; i<data.list.length;i++){
var rowdata = data.list[i]
checkedItemsObj[rowdata.id] = rowdata;
}
resetSelectedCheckBox(data);
}
});
... ...
... ... @@ -39,21 +39,20 @@
<tr style="height: 60px">
<td >
<span style="color:red">*</span><label>选择用户</label> <br>
<input id="articleUid" name="articleUid" class="easyui-textbox" style="width: 380px;"/>
<input id="articleUid" name="articleUid" style="width:60% " class="easyui-textbox" />
</td>
</tr>
<tr style="height: 60px">
<td>
<span style="color:red">*</span><label>文字内容</label> <br>
<input id="content" name="content" class="easyui-textbox" style="width: 380px;"/>
</td>
<textarea rows="2" id="content" style="width:60% " name = "content" class="form-control" placeholder="" required="" maxlength="145"></textarea> </td>
</tr>
<tr style="height: 60px">
<td>
<span style="color:red">*</span><label>选择话题</label> <br>
<input id="topic" name="topicId" class="easyui-combobox" style="width: 380px;"/>
<input id="topic" name="topicId" class="easyui-combobox" style="width:60% "/>
</td>
</tr>
<tr style="height: 20px">
... ... @@ -72,17 +71,21 @@
<tr style="height: 60px">
<td>
<span style="color:red">*</span><label>关联商品</label> <br>
<a id="addSkn" class="btn-default" onclick="getEditDialog()" >新增商品+</a>
<a id="addSkn" class="btn-primary" onclick="getEditDialog()" style="font-size: 15px">新增商品+</a>
<input id="skns" name="articleSkns" hidden="hidden"/>
</td>
<td>
<img id="good1" src="" hidden>
<img id="good2" src="" hidden>
</tr>
<tr style="height: 60px">
<td id="goodstd">
<div id="good0" style="float: left;margin-left: 30px">
</div>
</td>
</tr>
<tr>
<td height="50" valign="bottom">
<input class="btn-primary" type="button" onclick="submit()" value="保存"/>
<input class="btn-primary" type="submit" value="保存"/>
</td>
</tr>
</table>
... ... @@ -98,18 +101,15 @@
</body>
<script>
var count = 1;
var checkedItems = [];
var checkedItemsObj = {};
$(function () {
$("#articleUid").textbox({
required: true,
missingMessage: "发布用户不能为空",
prompt: "请输入发布用户"
});
$("#content").textbox({
required: true,
missingMessage: "发布内容不能为空",
prompt: "请输入发布内容"
});
$("#topic").combobox({
prompt: "请选择话题"
});
... ... @@ -121,7 +121,7 @@
realInputName: "url",
url: contextPath + '/fileupload/uploadFile',
queryParams: {
bucket: "activity"
bucket: "grassImg"
},
onBeforeSubmit: function () {
$.messager.progress({
... ... @@ -159,7 +159,7 @@
realInputName: "url",
url: contextPath + '/fileupload/uploadFile',
queryParams: {
bucket: "activity"
bucket: "grassImg"
},
onBeforeSubmit: function () {
$.messager.progress({
... ... @@ -192,39 +192,43 @@
});
function submit(){
$("#publishArticleForm").form("submit",{
url : "http://localhost:8088/platform/grassArticle/publishArticle",
onSubmit : function(param) {
if (!$("#publishArticleForm").form("validate")) {
return false;
$("#publishArticleForm").form("submit",{
url : serverContextPath+"/grassArticle/publishArticle",
onSubmit : function(param) {
debugger
if (!$("#publishArticleForm").form("validate")) {
return false;
}
if($("#articleUid").val() == ''){
return false;
}
var imgs = '';
$("input[name='url']").each(function(j,item){
var url = item.val();
if(imgs == ''){
imgs = url;
}else{
imgs = imgs + ","+url;
}
var imgs = '';
$("input[name='url']").each(function(j,item){
var url = item.val();
if(imgs == ''){
imgs = url;
}else{
imgs = imgs + ","+url;
}
});
$("#imgs").val(imgs);
return true;
},
success : function(data) {
if (data) {
data = $.parseJSON(data);
if (data.code == 200) {
$.messager.alert("保存成功");
} else {
$.messager.alert("保存失败", data.message, "error");
}
});
$("#imgs").val(imgs);
return true;
},
success : function(data) {
if (data) {
data = $.parseJSON(data);
if (data.code == 200) {
$.messager.alert("保存成功");
} else {
$.messager.alert("保存失败", data.message, "error");
}
} else {
$.messager.alert("保存失败", data.message, "error");
}
});
}
}
});
// 编辑分组
function getEditDialog(data){
... ... @@ -244,8 +248,23 @@
text:textVar,
iconCls : "icon-save",
handler:function(){
debugger
// $("input[type='checkbox'][name='id']:checked").each(function (index,$this) {
// buildgood(index,$this)
// });
$("#goodstd").html("<div id=\"good0\" style=\"float: left;\">\n" +
" </div>")
var skns = '';
for (var i = 0; i < checkedItems.length; i++) {
buildgood(i,checkedItems[i])
if( i == checkedItems.length){
skns = skns+ checkedItems[i]
}else{
skns = skns+ checkedItems[i] +","
}
}
$("#skns").val(skns);
$(labelGroupList).dialog("close");
}
}, {
text: "关闭",
... ... @@ -262,5 +281,87 @@
href: contextPath + "/html/grass/article/chooseSkns.html"
});
}
function buildgood(index,obj) {
debugger
var data = checkedItemsObj[obj];
$("#good"+index).html(gooddiv(data));
$div = $("#good"+(index+1));
$("#good"+index).after('<div id="good'+(index+1)+'"style="float: left;margin-left: 30px"> </div>');
}
function gooddiv(data) {
return " <span>商品图:<img width=\"120\" height=\"60\" src="+getImageUrl()+
" </span>" +
"<h5 style=\"margin-top: 0px;margin-bottom: 0px>商品名:"+ data.product_name +"</h5>\n" +
"<h5 style=\"margin-top: 0px;margin-bottom: 0px>价格:"+data.sales_price+"</h5>"
}
function getImageUrl(image) {
var result='';
if (image) {
if(image.indexOf('http://') == 0){
result = image.split("?")[0];
}else{
var fileMode = image.substring(15, 17);
if(fileMode=='01'){
result= "http://"+"img11.static.yhbimg.com"+"goodsimg"+image;
}
if(fileMode=='02'){
result= "http://"+"img12.static.yhbimg.com"+"goodsimg"+image;
}
}
}
else {
result = ""
}
if (result) {
return "<img width=120 height=60 src='" + result + "?imageMogr2/thumbnail/320x320/extent/320x320/background/d2hpdGU=/position/center/quality/90'/>";
} else {
return "";
}
}
function findCheckedItem(ID) {
for (var i = 0; i < checkedItems.length; i++) {
if (checkedItems[i] == ID) return i;
}
return -1;
}
function addcheckItem() {
$("input[type='checkbox'][name='id']:checked").each(function () {
var k = findCheckedItem($(this).val());
if (k == -1) {
checkedItems.push($(this).val());
}
});
}
function removeAllItem(rows) {
$("input[type='checkbox'][name='id']").each(function () {
if (!this.checked) {
var k = findCheckedItem($(this).val());
if (k != -1) {
checkedItems.splice(k, 1);
}
}
});
}
function resetSelectedCheckBox(data){
$("input[type='checkbox'][name='id']").each(function () {
var cb=$(this);
$.each(checkedItems,function(index,value){
if(value==cb.val()){
cb.attr("checked",true);
return false;
}
});
});
}
function removeSingleItem(rowIndex, rowData) {
var k = findCheckedItem(rowData.id);
if (k != -1) {
checkedItems.splice(k, 1);
}
}
</script>
</html>
\ No newline at end of file
... ...
//todo 分解成多个接口,或接受参数的方式,实现加载可配置化,而不是笼统的暴力加载方式,太low
var contextPath = "/pfcms";
var serverContextPath = "/platform";
document.write("<meta charset='UTF-8'>");
//首先加载样式,保证样式先显示
... ...
var contextPath = "/pfcms";
var serverContextPath="/platform";
document.write("<meta charset='UTF-8'>");
document.write("<script src='"+ contextPath +"/js/jquery/jquery-3.1.0.min.js'></script>");
... ...