Authored by liangyi.chen@yoho.cn

添加推荐商品管理菜单

package com.yoho.ufo.dal;
import com.yoho.ufo.dal.model.ProductRecommend;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface ProductRecommendMapper {
int deleteByPrimaryKey(Integer id);
int insert(ProductRecommend record);
ProductRecommend selectByPrimaryKey(Integer id);
ProductRecommend selectByProductId(Integer productId);
int updateByPrimaryKeySelective(ProductRecommend record);
int selectCount(@Param("productId") Integer productId,
@Param("productName") String productName);
List<ProductRecommend> selectPage(@Param("productId") Integer productId,
@Param("productName") String productName,
@Param("start") Integer start,
@Param("rows") Integer rows);
int batchInsert(List<ProductRecommend> productRecommendList);
List<ProductRecommend> selectByProductIds(@Param("list")List<Integer> ids);
}
\ No newline at end of file
... ...
... ... @@ -33,6 +33,4 @@ public interface Yoho2ufoProductMapper {
int deleteBatchBySkns(@Param("skns")String skns);
int batchInsert(List<Yoho2ufoProduct> yoho2ufoProductList);
}
\ No newline at end of file
... ...
package com.yoho.ufo.dal.model;
import lombok.Data;
@Data
public class ProductRecommend {
private Integer id;
private String productName;
private Integer productId;
private Integer orderBy;
private Integer updateTime;
}
\ No newline at end of file
... ...
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.yoho.ufo.dal.ProductRecommendMapper" >
<resultMap id="BaseResultMap" type="com.yoho.ufo.dal.model.ProductRecommend" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="product_name" property="productName" jdbcType="VARCHAR" />
<result column="product_id" property="productId" jdbcType="INTEGER" />
<result column="order_by" property="orderBy" jdbcType="INTEGER" />
<result column="update_time" property="updateTime" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, product_name, product_id, order_by, update_time
</sql>
<sql id="pageCondition" >
<if test="productId != null and productId > 0">
and product_id like concat('%', #{productId}, '%')
</if>
<if test="productName != null and productName !=''">
and product_name like concat('%', #{productName}, '%')
</if>
</sql>
<select id="selectCount" resultType="java.lang.Integer">
select count(*) from product_recommend where 1=1 <include refid="pageCondition" />
</select>
<select id="selectPage" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from product_recommend
where 1=1 <include refid="pageCondition" /> order by update_time desc limit #{start},#{rows}
</select>
<select id="selectByProductId" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from product_recommend
where product_id = #{productId,jdbcType=INTEGER}
</select>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from product_recommend
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from product_recommend
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.yoho.ufo.dal.model.ProductRecommend" >
insert into product_recommend (id, product_name, product_id,
order_by, update_time)
values (#{id,jdbcType=INTEGER}, #{productName,jdbcType=VARCHAR}, #{productId,jdbcType=INTEGER},
#{orderBy,jdbcType=INTEGER}, #{updateTime,jdbcType=INTEGER})
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yoho.ufo.dal.model.ProductRecommend" >
update product_recommend
<set>
<if test="productName != null" >
product_name = #{productName,jdbcType=VARCHAR},
</if>
<if test="productId != null" >
product_id = #{productId,jdbcType=INTEGER},
</if>
<if test="orderBy != null" >
order_by = #{orderBy,jdbcType=INTEGER},
</if>
<if test="updateTime != null" >
update_time = #{updateTime,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<insert id="batchInsert" parameterType="java.util.List">
insert into product_recommend(product_name,product_id, order_by,update_time) values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.productName,jdbcType=VARCHAR},#{item.productId,jdbcType=INTEGER},
#{item.orderBy,jdbcType=INTEGER},#{item.updateTime,jdbcType=INTEGER})
</foreach>
</insert>
<select id="selectByProductIds" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from product_recommend
where product_id in
<foreach item="item" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -137,13 +137,5 @@
</foreach>
</delete>
<insert id="batchInsert" parameterType="java.util.List">
insert into (id, product_skn, product_name,brand_name, yoho_image, ufo_image,update_time) values
<foreach collection="list" item="item" index="index" separator=",">
(#{id,jdbcType=INTEGER}, #{productSkn,jdbcType=INTEGER}, #{productName,jdbcType=VARCHAR},
#{brandName,jdbcType=VARCHAR}, #{yohoImage,jdbcType=VARCHAR}, #{ufoImage,jdbcType=VARCHAR},
#{updateTime,jdbcType=INTEGER})
</foreach>
</insert>
</mapper>
\ No newline at end of file
... ...
package com.yoho.ufo.controller.product;
import com.yoho.ufo.dal.model.ProductRecommend;
import com.yoho.ufo.service.impl.ProductRecommendService;
import com.yohobuy.ufo.model.common.ApiResponse;
import com.yohobuy.ufo.model.common.PageResponseBO;
import com.yohobuy.ufo.model.request.productrecommend.ProductRecommendReqBo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
@RestController
@RequestMapping(value = "/productRecommend")
public class ProductRecommendController {
private static final Logger LOGGER = LoggerFactory.getLogger(ProductRecommendController.class);
@Resource
private ProductRecommendService productRecommendService;
@RequestMapping(value = "/addOrUpdate" , method = RequestMethod.POST)
public ApiResponse<Void> addOrUpdate(ProductRecommend bo) {
LOGGER.info("productRecommend.addOrUpdate param = {}", bo);
return productRecommendService.addOrUpdate(bo);
}
@RequestMapping(value = "/getProductRecommendById")
public ApiResponse<ProductRecommend> getProductRecommendById(Integer id) {
LOGGER.info("productRecommend.getProductRecommendById id = {}", id);
return productRecommendService.getProductRecommendById(id);
}
@RequestMapping(value = "/list")
public ApiResponse<PageResponseBO<ProductRecommend>> list(ProductRecommendReqBo bo) {
LOGGER.info("productRecommend.list param = {}", bo);
return productRecommendService.list(bo);
}
@RequestMapping(value = "/deleteProductRecommendById")
public ApiResponse<Void> deleteProductRecommendById(Integer id) {
LOGGER.info("productRecommend.deleteProductRecommendById param = {}", id);
return productRecommendService.deleteProductRecommendById(id);
}
@RequestMapping(value = "/insertBatch")
public ApiResponse<Void> insertBatch(String idStr) {
LOGGER.info("productRecommend.insertBatch param = {}", idStr);
return productRecommendService.insertBatch(idStr);
}
}
... ...
... ... @@ -53,12 +53,6 @@ public class Yoho2ufoProductController {
return yoho2ufoProductService.deleteBatchYoho2ufoProduct(skns);
}
@RequestMapping(value = "/insertBatch")
public ApiResponse<Void> insertBatch(String sknStr) {
LOGGER.info("Yoho2ufoProduct.insertBatch param = {}", sknStr);
return yoho2ufoProductService.insertBatch(sknStr);
}
@RequestMapping(value = "/getYoho2ufoProductById")
public ApiResponse<Yoho2ufoProductRespBo> getYoho2ufoProductById(Integer id) {
LOGGER.info("Yoho2ufoProduct.getYoho2ufoProductById id = {}", id);
... ...
... ... @@ -18,8 +18,6 @@ public interface Yoho2ufoProductService {
ApiResponse<Void> addOrUpdate(Yoho2ufoProduct bo);
ApiResponse<Void> insertBatch(String sknStr);
ApiResponse<Yoho2ufoProductRespBo> getYoho2ufoProductById(Integer id);
... ...
package com.yoho.ufo.service.impl;
import com.yoho.ufo.dal.ProductMapper;
import com.yoho.ufo.dal.ProductRecommendMapper;
import com.yoho.ufo.dal.model.Product;
import com.yoho.ufo.dal.model.ProductRecommend;
import com.yohobuy.ufo.model.common.ApiResponse;
import com.yohobuy.ufo.model.common.PageResponseBO;
import com.yohobuy.ufo.model.request.productrecommend.ProductRecommendReqBo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class ProductRecommendService {
@Resource
ProductRecommendMapper productRecommendMapper;
@Resource
ProductMapper productMapper;
private static final int MAX_PRODUCT_RECOMMEND_NUM = 20;//UFO推荐产品ID最大数量
private static final Logger logger = LoggerFactory.getLogger(ProductRecommendService.class);
public ApiResponse<PageResponseBO<ProductRecommend>> list(ProductRecommendReqBo bo) {
int count = productRecommendMapper.selectCount(bo.getProductId(), bo.getProductName());
if (count > 0) {
List<ProductRecommend> productList = productRecommendMapper.selectPage(bo.getProductId(),
bo.getProductName(),
bo.getStartIndex(),
bo.getRows());
PageResponseBO<ProductRecommend> pageBo = new PageResponseBO<>(count, productList, bo.getPage(), bo.getRows());
return new ApiResponse<>(pageBo);
}
return new ApiResponse<>();
}
public ApiResponse<Void> deleteProductRecommendById(Integer id) {
productRecommendMapper.deleteByPrimaryKey(id);
return new ApiResponse<>();
}
public ApiResponse<Void> addOrUpdate(ProductRecommend reqBo) {
Integer productId = reqBo.getProductId();
Product product = productMapper.selectByPrimaryKey(productId);
int count = productRecommendMapper.selectCount(null,null);
if(product != null){
reqBo.setProductName(product.getProductName());
reqBo.setUpdateTime((int) (System.currentTimeMillis() / 1000));
ProductRecommend productRecommendFromDB = productRecommendMapper.selectByProductId(reqBo.getProductId());
if(reqBo.getId() != null && reqBo.getId() > 0){//更新操作
productRecommendMapper.updateByPrimaryKeySelective(reqBo);
}else if(productRecommendFromDB != null){
return new ApiResponse<>(202,"该产品Id数据库已存在");
}else{
if(count >= MAX_PRODUCT_RECOMMEND_NUM){
return new ApiResponse<>(204,"推荐商品数量不能超过上限");
}
productRecommendMapper.insert(reqBo);
}
}else{
return new ApiResponse<>(201,"该产品不存在");
}
return new ApiResponse<>();
}
public ApiResponse<Void> insertBatch(String productIdStr) {
int count = productRecommendMapper.selectCount(null,null);
List<ProductRecommend> ufoProductRecommendList = new ArrayList<>();
String productIds = productIdStr.trim();
String addIds = productIds.replaceAll("\\s*", "");
String[] addIdArray = addIds.split(",");
List<String> idStrList = Arrays.asList(addIdArray);
List<Integer> idList = idStrList.stream().map(Integer::valueOf).collect(Collectors.toList());
List<ProductRecommend> productExsit = productRecommendMapper.selectByProductIds(idList);
if(!CollectionUtils.isEmpty(productExsit)){
List<Integer> exsitProductIds = productExsit.stream().map(ProductRecommend::getProductId)
.collect(Collectors.toList());
idList = idList.stream().filter(item -> !exsitProductIds.contains(item))
.collect(Collectors.toList());
}
if(idList.size() > MAX_PRODUCT_RECOMMEND_NUM - count){
return new ApiResponse<>(204,"推荐商品数量不能超过上限");
}
List<Product> productInfoList = productMapper.selectProductListByIds(idList);
if (productInfoList != null && productInfoList.size() > 0) {
productInfoList.forEach(product -> {
ProductRecommend productRecommend = new ProductRecommend();
productRecommend.setProductId(product.getId());
productRecommend.setProductName(product.getProductName());
productRecommend.setOrderBy(1);//批量新增时默认的order都是1
productRecommend.setUpdateTime((int) (System.currentTimeMillis() / 1000));
ufoProductRecommendList.add(productRecommend);
});
productRecommendMapper.batchInsert(ufoProductRecommendList);
}
return new ApiResponse<>();
}
public ApiResponse<ProductRecommend> getProductRecommendById(Integer id) {
ProductRecommend productRecommend = productRecommendMapper.selectByPrimaryKey(id);
if(productRecommend != null){
return new ApiResponse<>(productRecommend);
}
return new ApiResponse<>();
}
}
... ...
... ... @@ -27,7 +27,6 @@ import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class Yoho2ufoProductServiceImpl implements Yoho2ufoProductService {
... ... @@ -269,42 +268,6 @@ public class Yoho2ufoProductServiceImpl implements Yoho2ufoProductService {
}
@Override
public ApiResponse<Void> insertBatch(String sknStr) {
Map<Integer, YohoProductInfo> productBoMap;
List<Yoho2ufoProduct> yoho2ufoProductList = new ArrayList<>();
String skns = sknStr.trim();
String addskns = skns.replaceAll("\\s*", "");
String[] addSknArray = addskns.split(",");
List<String> sknStrList = Arrays.asList(addSknArray);
List<Integer> sknList = sknStrList.stream().map(Integer::valueOf).collect(Collectors.toList());
List<Yoho2ufoProduct> yoho2ufoProductExsit = yoho2ufoProductMapper.selectByProductSkns(sknList);
if(!CollectionUtils.isEmpty(yoho2ufoProductExsit)){
List<Integer> exsitSkns = yoho2ufoProductExsit.stream().map(Yoho2ufoProduct::getProductSkn)
.collect(Collectors.toList());
sknList = sknList.stream().filter(item -> !exsitSkns.contains(item))
.collect(Collectors.toList());
}
List<YohoProductInfo> productBoList = getProductBoBySknList(sknList);
if (productBoList != null && productBoList.size() > 0) {
productBoMap = CollectionUtil.extractMap
(productBoList, YohoProductInfo::getProductSkn);
sknList.forEach(skn -> {
YohoProductInfo yohoProductBo = productBoMap.get(skn);
Yoho2ufoProduct yoho2ufoProduct = new Yoho2ufoProduct();
yoho2ufoProduct.setProductSkn(skn);
yoho2ufoProduct.setProductName(yohoProductBo.getProductName());
yoho2ufoProduct.setBrandName(yohoProductBo.getBrandName());
yoho2ufoProduct.setYohoImage(yohoProductBo.getImageUrl());
yoho2ufoProduct.setUpdateTime((int) (System.currentTimeMillis() / 1000));
yoho2ufoProductList.add(yoho2ufoProduct);
});
yoho2ufoProductMapper.batchInsert(yoho2ufoProductList);
}
return new ApiResponse<>();
}
@Override
public ApiResponse<Yoho2ufoProductRespBo> getYoho2ufoProductById(Integer id) {
Yoho2ufoProduct yoho2ufoProduct = yoho2ufoProductMapper.selectByPrimaryKey(id);
if(yoho2ufoProduct != null){
... ...
<!DOCTYPE html>
<div id="tt" class="easyui-layout" fit="true" style="overflow-y: scroll">
<form name="productEditForm" id="productEditForm" method="post" enctype="multipart/form-data">
<input type="hidden" name="id" id="id"/>
<div style="margin-top: 20px;margin-left: 30px">
<table border="0" style="width:95%;margin-top:5px;line-height:30px;" id="tab">
<tr style="height: 60px">
<td width="12%">产品ID<span class="requriedInput">*</span></td>
<td width="50%">
<input id="productId" name="productId" class="easyui-numberbox" style="width: 100px"/>
</td>
</tr>
<tr style="height: 60px" id="orderByTR">
<td width="12%">排序值<span class="requriedInput">*</span></td>
<td width="20%">
<input id="orderBy" name="orderBy" class="easyui-numberbox" style="width: 200px;" required="required"/>
</td>
</tr>
</table>
</div>
</form>
</div>
<script>
$(function () {
// 隐藏域赋值
$('#productEditForm #id').val(editId);
if (editId > 0) {
$.post(contextPath + "/productRecommend/getProductRecommendById", {
id: editId
}, function (data) {
$("#productEditForm #productId").numberbox('readonly', true);
$("#productEditForm").form("load", data.data);
});
}
});
</script>
\ No newline at end of file
... ...
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Yoho!Buy运营平台</title>
<script src="/ufoPlatform/js/include.js"></script>
</head>
<body class="easyui-layout" fit="true">
<div id="infoDivId">
<form id="insertBatchForm" name="insertBatchForm" method="post">
<table id="insertBatchTable" border="0" align="center" style="line-height: 30px;width:95%">
<tr id="pageContentTr">
<td>
<textarea id="idStr" name="idStr" style="height:100px;width:280px;" onKeyUp="javascript:this.value=this.value.replace(/[^\r\n0-9\,]/g,'');"/>
<span>&nbsp;(productId,逗号分隔)</span>
</td>
</tr>
<!--<tr id="normalBoostTr" >
<td width="10%" align="right"><span style="font-weight:bold;">score:</span></td>
<td>
<input id="score" name="score" placeholder="请输入百分比" type="text"/>
</td>
</tr>-->
</table>
</form>
</div>
</body>
</html>
\ No newline at end of file
... ...
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>Yoho!Buy运营平台</title>
<script src="/ufoPlatform/js/include.js"></script>
<script src="/ufoPlatform/js/ajaxfileupload.js"></script>
</head>
<body class="easyui-layout" fit="true">
<div region="north" style="height: 230px">
<script>
document.write(addHead('UFO推荐商品配置', ''));
</script>
<style>
.div_search input {
margin-top: 20px;
}
.div_search .textbox {
margin-top: 20px;
}
.div_search .easyui-linkbutton {
margin-top: 20px;
}
</style>
<div style="margin-left: 30px;" class="div_search">
<input id="productId" type="text">
<input id="productName" type="text">
<a id="searchLinkButton" class="easyui-linkbutton btn-info" data-options="iconCls:'icon-search'">筛选</a>
<a id="searchAllLinkButton" class="easyui-linkbutton btn-info" data-options="iconCls:'icon-search'">全部</a>
<a id="addProduct" class="easyui-linkbutton btn-success" data-options="iconCls:'icon-search'">新增</a>
<a id="addProductBatch" class="easyui-linkbutton btn-success" style="margin-left: 50px">批量新增</a>
</div>
</div>
<div region="center">
<div style="margin-left: 30px;margin-top: 20px;height: 660px">
<table id="productRecommendListTable"></table>
</div>
</div>
<script type="text/javascript">
var editId;
function getEditDialog(){
var title="批量新增";
var url = contextPath + "/productRecommend/insertBatch";
var div = $("<div>").appendTo($(window.self.document.body));
window.self.$(div).myDialog({
title: title,
width: "30%",
height: "30%",
resizable:true,
buttons:[{
id : "saveBtn",
text:'保存',
iconCls : "icon-save",
handler:function(){
window.self.$("#insertBatchForm").form("submit", {
url : url,
onSubmit : function(param) {
},
success : function(data) {
$.messager.progress("close");
data = JSON.parse(data);
if (data.code == 200) {
$(div).dialog("close");
$("#productRecommendListTable").myDatagrid("reload");
$.messager.show({
title: "提示",
msg: title + "成功!",
height: 120
});
} else {
$.messager.alert("失败", data.message, "error");
}
}
});
}
},{
id : "closeBtn",
text:'取消',
iconCls : "icon-cancel",
handler:function(){
window.self.$(div).dialog('close');
}
}],
modal: true,
href: contextPath + "/html/productRecommend/productRecommendAddBatch.html",
onOpen : function() {
window.setTimeout(function() {
$("#saveBtn").addClass("btn-success");
$("#closeBtn").addClass("btn-danger");
}, 100);
}
});
}
$(function () {
$("#productId").textbox({
prompt: "商品Id"
});
$("#productName").textbox({
prompt: "商品名称"
});
$('#addProduct').linkbutton({
iconCls: "icon-edit",
onClick: function () {
editRow(0);
}
});
$("#addProductBatch").linkbutton({
text : "批量新增",
iconCls : "icon-del",
onClick : function() {
getEditDialog(null);
}
});
$("#productRecommendListTable").myDatagrid({
fit: true,
fitColumns: true,
nowrap: false,
url: contextPath + "/productRecommend/list",
method: 'POST',
loadFilter: function (data) {
var temp = defaultLoadFilter(data);
temp.rows = temp.list;
return temp;
},
columns: [[{
title: "ID",
field: "id",
align: "center",
hidden: true
}, {
title: "商品Id",
field: "productId",
width: 80,
align: "center"
}, {
title: "商品名称",
field: "productName",
width: 120,
align: "center",
},{
title: "次序",
field: "orderBy",
width: 80,
align: "center"
},{
title: "操作",
field: "operations",
width: 80,
align: "center",
formatter: function (value, rowData) {
var str = "<a role='edit' dataId='" + rowData.id + "' style='margin-left:10px;background-color: #5bc0de'>编辑</a>";
str += "<a role='del' dataId='" + rowData.id + "' style='margin-left:10px;background-color: red'>删除</a>";
return str;
}
}]],
cache: false,
pagination: true,
pageSize: 20,
pageList: [20],
idField: "id",
singleSelect: false,
checkOnSelect: false,
onLoadSuccess: function () {
// 编辑
$(this).myDatagrid("getPanel").find("a[role='edit']").linkbutton({
iconCls: "icon-edit",
onClick: function () {
var id = $(this).attr("dataId");
editRow(id);
}
});
// 删除
$(this).myDatagrid("getPanel").find("a[role='del']").linkbutton({
iconCls: "icon-more",
onClick: function () {
del($(this).attr("dataId"));
}
});
}
});
// 搜索
$("#searchLinkButton").linkbutton({
onClick: function () {
var param = getParams();
$("#productRecommendListTable").myDatagrid("load", param);
}
});
// 搜索全部
$("#searchAllLinkButton").linkbutton({
onClick: function () {
$('#productId').textbox('clear');
$('#productName').textbox('clear');
var param = {};
$("#productRecommendListTable").myDatagrid("load", param);
}
});
/**
* 提取出搜索参数
*/
function getParams() {
// id
var productId = $('#productId').textbox('getText');
// 产品名称
var productName = $('#productName').textbox('getText');
var param = {};
if (undefined !== productId && null !== productId && "" !== productId) {
param.productId = productId;
}
if (undefined !== productName && null !== productName && "" !== productName) {
param.productName = productName;
}
return param;
}
function editRow(id) {
editId = id;
var div = $("<div>").appendTo($(document.body));
var title = "编辑";
var message = "确认修改吗?";
if (id == 0) {
title = "添加";
message = "确认添加吗?";
}
$(div).myDialog({
width: "600px",
height: "400px",
title: title,
href: contextPath + "/html/productRecommend/editProductRecommend.html",
queryParams: {
id: id
},
modal: true,
collapsible: true,
cache: false,
buttons: [{
id: "saveBtn",
text: "保存",
handler: function () {
$.messager.confirm("确认", message, function (flag) {
if (flag) {
var url = contextPath + "/productRecommend/addOrUpdate";
$("#productEditForm").form("submit", {
url: url,
onSubmit: function () {
if (!$("#productEditForm").form("validate")) {
return false;
}
$.messager.progress({
title: "正在执行",
msg: "正在执行,请稍后..."
});
return true;
},
success: function (data) {
$.messager.progress("close");
data = JSON.parse(data);
if (data.code == 200) {
$(div).dialog("close");
$("#productRecommendListTable").myDatagrid("reload");
$.messager.show({
title: "提示",
msg: title + "成功!",
height: 120
});
} else {
$.messager.alert("失败", data.message, "error");
}
}
});
}
});
}
}, {
text: "关闭",
iconCls: "icon-cancel",
handler: function () {
$(div).dialog("close");
}
}]
});
}
function del(id) {
var message = "确定要删除吗?";
var msg = "删除成功";
$.messager.confirm("确认", message, function (flag) {
if (flag) {
$.messager.progress({
title: "正在执行",
msg: "正在执行,请稍后...",
interval: 500,
text: ""
});
$.post(contextPath + "/productRecommend/deleteProductRecommendById", {
"id": id
}, function (data) {
$.messager.progress("close");
if (data.code == 200) {
$("#productRecommendListTable").myDatagrid("reload");
$.messager.show({
title: "提示",
msg: msg,
height: 120
});
} else {
$.messager.alert("失败", data.message, "error");
}
}, "json");
}
});
}
});
</script>
</body>
</html>
\ No newline at end of file
... ...