Merge branch 'master' of http://124.222.105.7:3000/dianliang/dl_site_system
This commit is contained in:
commit
02b918182c
@ -0,0 +1,130 @@
|
||||
package com.ruoyi.busi.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.base.service.IBasePicsService;
|
||||
import com.ruoyi.busi.domain.BusiProdNew;
|
||||
import com.ruoyi.busi.service.IBusiProdNewService;
|
||||
import com.ruoyi.busi.vo.ProdNewVO;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static com.ruoyi.constant.DictConstants.FILE_TYPE_PRODUCT;
|
||||
|
||||
/**
|
||||
* 产品Controller
|
||||
*
|
||||
* @author vinjor-m
|
||||
* @date 2025-06-25
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/busi/new")
|
||||
public class BusiNewController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IBusiProdNewService busiProdNewService;
|
||||
@Autowired
|
||||
private IBasePicsService basePicsService;
|
||||
|
||||
/**
|
||||
* 查询产品列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('busi:new:list')")
|
||||
@GetMapping("/list")
|
||||
public AjaxResult list(ProdNewVO busiProdNew,
|
||||
@RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize)
|
||||
{
|
||||
Page<BusiProdNew> page = new Page<>(pageNum, pageSize);
|
||||
IPage<ProdNewVO> list = busiProdNewService.queryListPage(busiProdNew,page);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出产品列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('busi:new:export')")
|
||||
@Log(title = "产品", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, BusiProdNew busiProdNew)
|
||||
{
|
||||
List<BusiProdNew> list = busiProdNewService.list();
|
||||
ExcelUtil<BusiProdNew> util = new ExcelUtil<BusiProdNew>(BusiProdNew.class);
|
||||
util.exportExcel(response, list, "产品、文章数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取产品详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('busi:new:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") String id)
|
||||
{
|
||||
return success(busiProdNewService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取产品表当前最大排序
|
||||
*/
|
||||
@GetMapping(value = "/getMaxSort")
|
||||
public AjaxResult getMaxSort(String tenantId)
|
||||
{
|
||||
return success(busiProdNewService.getMaxSort(tenantId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增产品
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('busi:new:add')")
|
||||
@Log(title = "产品", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody ProdNewVO prodNewVO){
|
||||
busiProdNewService.save(prodNewVO);
|
||||
if(null!=prodNewVO.getFileList() && !prodNewVO.getFileList().isEmpty()){
|
||||
prodNewVO.getFileList().forEach(item->{
|
||||
item.setTenantId(prodNewVO.getTenantId());
|
||||
item.setFileType(FILE_TYPE_PRODUCT);
|
||||
});
|
||||
}
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改产品
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('busi:new:edit')")
|
||||
@Log(title = "产品", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody ProdNewVO prodNewVO){
|
||||
busiProdNewService.updateById(prodNewVO);
|
||||
if(null!=prodNewVO.getFileList() && !prodNewVO.getFileList().isEmpty()){
|
||||
prodNewVO.getFileList().forEach(item->{
|
||||
item.setTenantId(prodNewVO.getTenantId());
|
||||
item.setFileType(FILE_TYPE_PRODUCT);
|
||||
});
|
||||
}
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除产品
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('busi:new:remove')")
|
||||
@Log(title = "产品", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable String[] ids){
|
||||
List<String> list = new ArrayList<>(Arrays.asList(ids));
|
||||
return toAjax(busiProdNewService.removeByIds(list));
|
||||
}
|
||||
}
|
@ -7,7 +7,10 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.base.service.IBasePicsService;
|
||||
import com.ruoyi.busi.domain.BusiProdRandom;
|
||||
import com.ruoyi.busi.service.IBusiProdRandomService;
|
||||
import com.ruoyi.busi.vo.ProdNewVO;
|
||||
import com.ruoyi.busi.vo.ProdRandomVO;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -28,6 +31,7 @@ import com.ruoyi.busi.service.IBusiProdNewService;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
import static com.ruoyi.constant.DictConstants.DATA_TYPE_PRODUCT;
|
||||
import static com.ruoyi.constant.DictConstants.FILE_TYPE_PRODUCT;
|
||||
|
||||
/**
|
||||
@ -44,21 +48,37 @@ public class BusiProdController extends BaseController
|
||||
private IBusiProdNewService busiProdNewService;
|
||||
@Autowired
|
||||
private IBasePicsService basePicsService;
|
||||
@Autowired
|
||||
private IBusiProdRandomService prodRandomService;
|
||||
|
||||
/**
|
||||
* 查询产品列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('busi:prod:list')")
|
||||
@GetMapping("/list")
|
||||
public AjaxResult list(BusiProdNew busiProdNew,
|
||||
public AjaxResult list(ProdNewVO busiProdNew,
|
||||
@RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize)
|
||||
{
|
||||
Page<BusiProdNew> page = new Page<>(pageNum, pageSize);
|
||||
//只查产品
|
||||
busiProdNew.setDataType(DATA_TYPE_PRODUCT);
|
||||
IPage<ProdNewVO> list = busiProdNewService.queryListPage(busiProdNew,page);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查某产品的随机关联产品
|
||||
* @author vinjor-M
|
||||
* @date 16:35 2025/6/27
|
||||
* @return com.ruoyi.common.core.domain.AjaxResult
|
||||
*
|
||||
**/
|
||||
@GetMapping("/randomList")
|
||||
public AjaxResult randomList(BusiProdRandom prodRandom){
|
||||
return success(prodRandomService.randomList(prodRandom));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出产品列表
|
||||
*/
|
||||
@ -98,6 +118,7 @@ public class BusiProdController extends BaseController
|
||||
@Log(title = "产品", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody ProdNewVO prodNewVO){
|
||||
prodNewVO.setDataType(DATA_TYPE_PRODUCT);
|
||||
busiProdNewService.save(prodNewVO);
|
||||
if(null!=prodNewVO.getFileList() && !prodNewVO.getFileList().isEmpty()){
|
||||
prodNewVO.getFileList().forEach(item->{
|
||||
@ -115,6 +136,7 @@ public class BusiProdController extends BaseController
|
||||
@Log(title = "产品", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody ProdNewVO prodNewVO){
|
||||
prodNewVO.setDataType(DATA_TYPE_PRODUCT);
|
||||
busiProdNewService.updateById(prodNewVO);
|
||||
if(null!=prodNewVO.getFileList() && !prodNewVO.getFileList().isEmpty()){
|
||||
prodNewVO.getFileList().forEach(item->{
|
||||
@ -135,4 +157,25 @@ public class BusiProdController extends BaseController
|
||||
List<String> list = new ArrayList<>(Arrays.asList(ids));
|
||||
return toAjax(busiProdNewService.removeByIds(list));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存产品关联的随机产品
|
||||
* @author vinjor-M
|
||||
* @date 17:41 2025/6/27
|
||||
* @param randomVO TODO
|
||||
* @return com.ruoyi.common.core.domain.AjaxResult
|
||||
**/
|
||||
@PostMapping("/saveRandom")
|
||||
public AjaxResult add(@RequestBody ProdRandomVO randomVO){
|
||||
List<BusiProdRandom> randomList = new ArrayList<>();
|
||||
randomVO.getRandomIdList().forEach(item->{
|
||||
BusiProdRandom random = new ProdRandomVO();
|
||||
random.setProdId(randomVO.getProdId());
|
||||
random.setRandomId(item);
|
||||
random.setTenantId(randomVO.getTenantId());
|
||||
randomList.add(random);
|
||||
});
|
||||
prodRandomService.saveBatch(randomList);
|
||||
return success();
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,10 @@ public class BusiProdNew extends DlBaseEntity
|
||||
@Excel(name = "所属栏目id")
|
||||
private String catgId;
|
||||
|
||||
/** 数据类型 */
|
||||
@Excel(name = "数据类型")
|
||||
private String dataType;
|
||||
|
||||
/** 产品名称或文章标题 */
|
||||
@Excel(name = "产品名称或文章标题")
|
||||
private String title;
|
||||
@ -72,11 +76,11 @@ public class BusiProdNew extends DlBaseEntity
|
||||
|
||||
/** 是否首页推荐显示 */
|
||||
@Excel(name = "是否首页推荐显示")
|
||||
private Integer ifReco;
|
||||
private Boolean ifReco;
|
||||
|
||||
/** 是否发布(未发布的在草稿箱) */
|
||||
@Excel(name = "是否发布", readConverterExp = "未=发布的在草稿箱")
|
||||
private Integer ifPublic;
|
||||
private Boolean ifPublic;
|
||||
|
||||
/** 站点唯一编码(租户id) */
|
||||
private String tenantId;
|
||||
|
@ -0,0 +1,43 @@
|
||||
package com.ruoyi.busi.domain;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
import com.ruoyi.common.core.domain.DlBaseEntity;
|
||||
|
||||
/**
|
||||
* 随机产品关联关系对象 dl_busi_prod_random
|
||||
*
|
||||
* @author vinjor-m
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@TableName("dl_busi_prod_random")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class BusiProdRandom extends DlBaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键 */
|
||||
@TableId(type = IdType.ASSIGN_UUID)
|
||||
private String id;
|
||||
|
||||
/** 产品或文章id */
|
||||
@Excel(name = "产品或文章id")
|
||||
private String prodId;
|
||||
|
||||
/** 关联的随机产品id */
|
||||
@Excel(name = "关联的随机产品id")
|
||||
private String randomId;
|
||||
|
||||
/** 站点唯一编码(租户id) */
|
||||
@Excel(name = "站点唯一编码", readConverterExp = "租=户id")
|
||||
private String tenantId;
|
||||
|
||||
}
|
@ -18,7 +18,7 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
@Mapper
|
||||
public interface BusiProdNewMapper extends BaseMapper<BusiProdNew>
|
||||
{
|
||||
IPage<ProdNewVO> queryListPage(@Param("entity") BusiProdNew entity, Page<BusiProdNew> page);
|
||||
IPage<ProdNewVO> queryListPage(@Param("entity") ProdNewVO entity, Page<BusiProdNew> page);
|
||||
|
||||
Long selectMaxSort(@Param("tenantId")String tenantId);
|
||||
}
|
||||
|
@ -0,0 +1,30 @@
|
||||
package com.ruoyi.busi.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.busi.domain.BusiProdRandom;
|
||||
import com.ruoyi.busi.vo.ProdNewVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 随机产品关联关系Mapper接口
|
||||
*
|
||||
* @author vinjor-m
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@Mapper
|
||||
public interface BusiProdRandomMapper extends BaseMapper<BusiProdRandom>
|
||||
{
|
||||
IPage<BusiProdRandom> queryListPage(@Param("entity") BusiProdRandom entity, Page<BusiProdRandom> page);
|
||||
|
||||
/**
|
||||
* 查某产品管理的随机产品
|
||||
* @author vinjor-M
|
||||
* @date 16:36 2025/6/27
|
||||
* @return java.util.List<com.ruoyi.busi.vo.ProdNewVO>
|
||||
**/
|
||||
List<ProdNewVO> selectRandomList(@Param("map") BusiProdRandom prodRandom);
|
||||
}
|
@ -15,7 +15,7 @@ import com.ruoyi.busi.vo.ProdNewVO;
|
||||
*/
|
||||
public interface IBusiProdNewService extends IService<BusiProdNew>
|
||||
{
|
||||
IPage<ProdNewVO> queryListPage(BusiProdNew pageReqVO, Page<BusiProdNew> page);
|
||||
IPage<ProdNewVO> queryListPage(ProdNewVO pageReqVO, Page<BusiProdNew> page);
|
||||
|
||||
/**
|
||||
* 获取产品表当前最大排序
|
||||
|
@ -0,0 +1,27 @@
|
||||
package com.ruoyi.busi.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.busi.domain.BusiProdRandom;
|
||||
import com.ruoyi.busi.vo.ProdNewVO;
|
||||
|
||||
/**
|
||||
* 随机产品关联关系Service接口
|
||||
*
|
||||
* @author vinjor-m
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
public interface IBusiProdRandomService extends IService<BusiProdRandom>
|
||||
{
|
||||
IPage<BusiProdRandom> queryListPage(BusiProdRandom pageReqVO, Page<BusiProdRandom> page);
|
||||
|
||||
/**
|
||||
* 查某产品的随机关联产品
|
||||
* @author vinjor-M
|
||||
* @date 16:35 2025/6/27
|
||||
* @return java.util.List<com.ruoyi.busi.vo.ProdNewVO>
|
||||
**/
|
||||
List<ProdNewVO> randomList(BusiProdRandom prodRandom);
|
||||
}
|
@ -26,8 +26,15 @@ public class BusiProdNewServiceImpl extends ServiceImpl<BusiProdNewMapper,BusiPr
|
||||
private BusiProdNewMapper busiProdNewMapper;
|
||||
|
||||
@Override
|
||||
public IPage<ProdNewVO> queryListPage(BusiProdNew pageReqVO, Page<BusiProdNew> page) {
|
||||
return busiProdNewMapper.queryListPage(pageReqVO, page);
|
||||
public IPage<ProdNewVO> queryListPage(ProdNewVO pageReqVO, Page<BusiProdNew> page) {
|
||||
IPage<ProdNewVO> newVOIPage = busiProdNewMapper.queryListPage(pageReqVO, page);
|
||||
newVOIPage.getRecords().forEach(item->{
|
||||
if(null!=item.getPics() && !item.getPics().isEmpty()){
|
||||
//将附图追加到主图中
|
||||
item.setMainPic(item.getMainPic()+","+item.getPics());
|
||||
}
|
||||
});
|
||||
return newVOIPage;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,44 @@
|
||||
package com.ruoyi.busi.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.busi.vo.ProdNewVO;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.busi.mapper.BusiProdRandomMapper;
|
||||
import com.ruoyi.busi.domain.BusiProdRandom;
|
||||
import com.ruoyi.busi.service.IBusiProdRandomService;
|
||||
|
||||
/**
|
||||
* 随机产品关联关系Service业务层处理
|
||||
*
|
||||
* @author vinjor-m
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@Service
|
||||
public class BusiProdRandomServiceImpl extends ServiceImpl<BusiProdRandomMapper,BusiProdRandom> implements IBusiProdRandomService
|
||||
{
|
||||
@Autowired
|
||||
private BusiProdRandomMapper busiProdRandomMapper;
|
||||
|
||||
@Override
|
||||
public IPage<BusiProdRandom> queryListPage(BusiProdRandom pageReqVO, Page<BusiProdRandom> page) {
|
||||
return busiProdRandomMapper.queryListPage(pageReqVO, page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查某产品的随机关联产品
|
||||
*
|
||||
* @return java.util.List<com.ruoyi.busi.vo.ProdNewVO>
|
||||
* @author vinjor-M
|
||||
* @date 16:35 2025/6/27
|
||||
**/
|
||||
@Override
|
||||
public List<ProdNewVO> randomList(BusiProdRandom prodRandom) {
|
||||
return busiProdRandomMapper.selectRandomList(prodRandom);
|
||||
}
|
||||
}
|
@ -16,6 +16,11 @@ import java.util.List;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class ProdNewVO extends BusiProdNew {
|
||||
/** 查询使用-需要排除的产品id,多个英文逗号隔开 */
|
||||
private String excludeProdId;
|
||||
|
||||
/** 默认不可编辑-表格行内编辑标识 */
|
||||
private Boolean flag;
|
||||
|
||||
/** 所属栏目名称 */
|
||||
@Excel(name = "所属栏目名称")
|
||||
@ -25,6 +30,9 @@ public class ProdNewVO extends BusiProdNew {
|
||||
@Excel(name = "产品发布者")
|
||||
private String userName;
|
||||
|
||||
/** 随机产品数量 */
|
||||
private Integer randomNum;
|
||||
|
||||
/**
|
||||
* 批量传的图片
|
||||
**/
|
||||
|
@ -0,0 +1,14 @@
|
||||
package com.ruoyi.busi.vo;
|
||||
|
||||
import com.ruoyi.busi.domain.BusiProdRandom;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class ProdRandomVO extends BusiProdRandom {
|
||||
/** 新增的关联产品id数组 */
|
||||
private List<String> randomIdList;
|
||||
}
|
@ -29,6 +29,19 @@ public class DictConstants
|
||||
*/
|
||||
public static final String FILE_TYPE_OTHER ="other";
|
||||
|
||||
/**
|
||||
* 数据类型字典-KEY
|
||||
*/
|
||||
public static final String DATA_TYPE_KEY ="data_type";
|
||||
/**
|
||||
* 数据类型字典-产品
|
||||
*/
|
||||
public static final String DATA_TYPE_PRODUCT ="product";
|
||||
/**
|
||||
* 数据类型字典-新闻
|
||||
*/
|
||||
public static final String DATA_TYPE_NEWS ="news";
|
||||
|
||||
|
||||
/**
|
||||
* 是否字典--是
|
||||
|
@ -28,6 +28,8 @@
|
||||
|
||||
<result property="catgName" column="catg_name"/>
|
||||
<result property="userName" column="user_name"/>
|
||||
<result property="flag" column="flag"/>
|
||||
<result property="randomNum" column="randomNum"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectBusiProdNewVo">
|
||||
@ -58,11 +60,15 @@
|
||||
SELECT
|
||||
product.*,
|
||||
su.nick_name AS user_name,
|
||||
dbc.catg_name AS catg_name
|
||||
dbc.catg_name AS catg_name,
|
||||
COUNT( dbpr.random_id ) AS randomNum,
|
||||
0 AS flag
|
||||
FROM
|
||||
dl_busi_prod_new product
|
||||
LEFT JOIN sys_user su ON product.creator = su.user_id
|
||||
LEFT JOIN dl_busi_category dbc ON product.catg_id = dbc.id
|
||||
LEFT JOIN dl_busi_prod_random dbpr ON product.id = dbpr.prod_id
|
||||
AND dbpr.del_flag = '0'
|
||||
<where>
|
||||
product.del_flag = '0'
|
||||
AND product.tenant_id = #{entity.tenantId}
|
||||
@ -75,6 +81,15 @@
|
||||
<if test="entity.catgId != null and entity.catgId != ''">
|
||||
AND product.catg_id = #{entity.catgId}
|
||||
</if>
|
||||
<if test="entity.excludeProdId != null and entity.excludeProdId != ''">
|
||||
AND product.id NOT IN
|
||||
<foreach collection="entity.excludeProdId.split(',')" open="(" separator="," close=")" item="item">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="entity.dataType != null and entity.dataType != ''">
|
||||
AND product.data_type = #{entity.dataType}
|
||||
</if>
|
||||
<if test="entity.title != null and entity.title != ''">
|
||||
AND product.title like concat('%', #{entity.title},
|
||||
'%')
|
||||
@ -84,6 +99,8 @@
|
||||
#{entity.newsFrom}, '%')
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY
|
||||
product.id
|
||||
ORDER BY product.sort DESC
|
||||
</select>
|
||||
<select id="selectMaxSort" resultType="java.lang.Long">
|
||||
|
@ -0,0 +1,45 @@
|
||||
<?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.ruoyi.busi.mapper.BusiProdRandomMapper">
|
||||
|
||||
<resultMap type="BusiProdRandom" id="BusiProdRandomResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="prodId" column="prod_id" />
|
||||
<result property="randomId" column="random_id" />
|
||||
<result property="tenantId" column="tenant_id" />
|
||||
<result property="creator" column="creator" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updater" column="updater" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectBusiProdRandomVo">
|
||||
select id, prod_id, random_id, tenant_id, creator, create_time, updater, update_time, del_flag from dl_busi_prod_random
|
||||
</sql>
|
||||
|
||||
<select id="queryListPage" parameterType="BusiProdRandom" resultMap="BusiProdRandomResult">
|
||||
<include refid="selectBusiProdRandomVo"/>
|
||||
<where>
|
||||
<if test="entity.prodId != null and entity.prodId != ''"> and prod_id = #{entity.prodId}</if>
|
||||
<if test="entity.randomId != null and entity.randomId != ''"> and random_id = #{entity.randomId}</if>
|
||||
<if test="entity.tenantId != null and entity.tenantId != ''"> and tenant_id = #{entity.tenantId}</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="selectRandomList" resultType="com.ruoyi.busi.vo.ProdNewVO">
|
||||
SELECT
|
||||
dbpn.*
|
||||
FROM
|
||||
dl_busi_prod_random dbpr
|
||||
LEFT JOIN dl_busi_prod_new dbpn ON dbpr.random_id = dbpn.id
|
||||
WHERE
|
||||
dbpr.prod_id = #{map.prodId}
|
||||
AND dbpr.tenant_id =#{map.tenantId}
|
||||
AND dbpn.tenant_id =#{map.tenantId}
|
||||
AND dbpr.del_flag = '0'
|
||||
ORDER BY
|
||||
dbpn.sort DESC
|
||||
</select>
|
||||
</mapper>
|
53
dl_vue/src/api/busi/new.js
Normal file
53
dl_vue/src/api/busi/new.js
Normal file
@ -0,0 +1,53 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询产品、文章列表
|
||||
export function listProdNew(query) {
|
||||
return request({
|
||||
url: '/busi/new/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询产品、文章列表
|
||||
export function getMaxSort(query) {
|
||||
return request({
|
||||
url: '/busi/new/getMaxSort',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询产品、文章详细
|
||||
export function getProdNew(id) {
|
||||
return request({
|
||||
url: '/busi/new/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增产品、文章
|
||||
export function addProdNew(data) {
|
||||
return request({
|
||||
url: '/busi/new',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改产品、文章
|
||||
export function updateProdNew(data) {
|
||||
return request({
|
||||
url: '/busi/new',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除产品、文章
|
||||
export function delProdNew(id) {
|
||||
return request({
|
||||
url: '/busi/new/' + id,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
@ -9,6 +9,15 @@ export function listProdNew(query) {
|
||||
})
|
||||
}
|
||||
|
||||
// 查询随机管理产品列表
|
||||
export function listRandomProd(query) {
|
||||
return request({
|
||||
url: '/busi/prod/randomList',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询产品、文章列表
|
||||
export function getMaxSort(query) {
|
||||
return request({
|
||||
@ -51,3 +60,12 @@ export function delProdNew(id) {
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
// 保存产品管理的随机产品
|
||||
export function saveRandom(data) {
|
||||
return request({
|
||||
url: '/busi/prod/saveRandom',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
@ -102,6 +102,20 @@ export const constantRoutes = [
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/new',
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
redirect: 'noredirect',
|
||||
children: [
|
||||
{
|
||||
path: 'newForm',
|
||||
component: () => import('@/views/busi/new/newForm'),
|
||||
name: 'NewForm',
|
||||
meta: { title: '文章详情' }
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/category',
|
||||
component: Layout,
|
||||
|
308
dl_vue/src/views/busi/new/index.vue
Normal file
308
dl_vue/src/views/busi/new/index.vue
Normal file
@ -0,0 +1,308 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="产品名称" prop="title">
|
||||
<el-input
|
||||
v-model="queryParams.title"
|
||||
placeholder="请输入产品名称"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['busi:new:add']"
|
||||
>新增</el-button>
|
||||
</el-col>
|
||||
<!-- <el-col :span="1.5">-->
|
||||
<!-- <el-button-->
|
||||
<!-- type="success"-->
|
||||
<!-- plain-->
|
||||
<!-- icon="el-icon-edit"-->
|
||||
<!-- size="mini"-->
|
||||
<!-- :disabled="single"-->
|
||||
<!-- @click="handleUpdate"-->
|
||||
<!-- v-hasPermi="['busi:new:edit']"-->
|
||||
<!-- >修改</el-button>-->
|
||||
<!-- </el-col>-->
|
||||
<!-- <el-col :span="1.5">-->
|
||||
<!-- <el-button-->
|
||||
<!-- type="danger"-->
|
||||
<!-- plain-->
|
||||
<!-- icon="el-icon-delete"-->
|
||||
<!-- size="mini"-->
|
||||
<!-- :disabled="multiple"-->
|
||||
<!-- @click="handleDelete"-->
|
||||
<!-- v-hasPermi="['busi:new:remove']"-->
|
||||
<!-- >删除</el-button>-->
|
||||
<!-- </el-col>-->
|
||||
<!-- <el-col :span="1.5">-->
|
||||
<!-- <el-button-->
|
||||
<!-- type="warning"-->
|
||||
<!-- plain-->
|
||||
<!-- icon="el-icon-download"-->
|
||||
<!-- size="mini"-->
|
||||
<!-- @click="handleExport"-->
|
||||
<!-- v-hasPermi="['busi:new:export']"-->
|
||||
<!-- >导出</el-button>-->
|
||||
<!-- </el-col>-->
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="prodList" @selection-change="handleSelectionChange" @cell-dblclick="cellClick">
|
||||
<!-- <el-table-column type="selection" width="55" align="center" />-->
|
||||
<el-table-column type="index" width="60" label="序号" align="center"></el-table-column>
|
||||
<el-table-column label="所属栏目" align="center" prop="catgName" width="120" />
|
||||
<el-table-column label="产品名称" align="center" prop="title" width="200" />
|
||||
<el-table-column label="产品图" align="center" prop="mainPic" width="100">
|
||||
<template slot-scope="scope">
|
||||
<image-preview :src="scope.row.mainPic" :width="50" :height="50"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="产品简介" align="center" prop="description" />
|
||||
<el-table-column width="100" label="排序" align="center" prop="sort">
|
||||
<template slot="header" slot-scope="scope">
|
||||
<span>排序</span>
|
||||
<el-tooltip class="item" effect="dark" content="鼠标双击数据可直接修改排序"
|
||||
placement="bottom"
|
||||
>
|
||||
<i class="el-icon-question"></i>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
<template slot-scope="scope">
|
||||
<el-input size="mini" type="number" v-model="scope.row.sort" v-if="scope.row.flag" @blur="inputClick(scope.row)" v-focus></el-input>
|
||||
<span v-if="!scope.row.flag">{{scope.row.sort}}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column width="80" label="首页显示" align="center" prop="ifReco">
|
||||
<template slot-scope="scope">
|
||||
<el-switch
|
||||
v-model="scope.row.ifReco"
|
||||
@change="changeIfReco($event,scope.row)"
|
||||
>
|
||||
</el-switch>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column width="80" label="是否发布" align="center" prop="ifPublic">
|
||||
<template slot-scope="scope">
|
||||
<el-switch
|
||||
v-model="scope.row.ifPublic"
|
||||
@change="changeIfPublic($event,scope.row)"
|
||||
>
|
||||
</el-switch>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column width="120" label="发布人" align="center" prop="userName">
|
||||
</el-table-column>
|
||||
<el-table-column width="100" label="创建时间" align="center" prop="createTime">
|
||||
<template slot-scope="scope">
|
||||
{{scope.row.createTime | formatDate}}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column width="100" label="修改时间" align="center" prop="updateTime">
|
||||
<template slot-scope="scope">
|
||||
{{scope.row.updateTime | formatDate}}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column width="140" label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-edit"
|
||||
@click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['busi:new:edit']"
|
||||
>修改</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['busi:new:remove']"
|
||||
>删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total>0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listProdNew, getProdNew, delProdNew, addProdNew, updateProdNew } from "@/api/busi/new";
|
||||
|
||||
export default {
|
||||
name: "New",
|
||||
dicts: ['sys_yes_no'],
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 产品数据
|
||||
prodList: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
catgId: null,
|
||||
title: null,
|
||||
newsFrom: null,
|
||||
},
|
||||
};
|
||||
},
|
||||
filters:{
|
||||
formatDate(val){
|
||||
if(val){
|
||||
return val.slice(0, 10)
|
||||
}else{
|
||||
return ""
|
||||
}
|
||||
},
|
||||
},
|
||||
directives: {
|
||||
// 注册一个局部的自定义指令 v-focus
|
||||
focus: {
|
||||
// 指令的定义
|
||||
inserted: function (el) {
|
||||
// 聚焦元素
|
||||
el.querySelector('input').focus()
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.getList();
|
||||
},
|
||||
created() {
|
||||
},
|
||||
methods: {
|
||||
/** 查询产品、文章列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listProdNew(this.queryParams).then(response => {
|
||||
this.prodList = response.data.records;
|
||||
this.total = response.data.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.id)
|
||||
this.single = selection.length!==1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.$router.push({path:'/new/newForm'})
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.$router.push({path:'/new/newForm',query:{id:row.id}})
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const ids = row.id || this.ids;
|
||||
this.$modal.confirm('是否确认删除文章?').then(function() {
|
||||
return delProdNew(ids);
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => {});
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
this.download('busi/new/export', {
|
||||
...this.queryParams
|
||||
}, `new_${new Date().getTime()}.xlsx`)
|
||||
},
|
||||
//双击单元格后,显示input,并通过v-focus让input自动获取焦点
|
||||
cellClick(row){
|
||||
row.flag=true
|
||||
},
|
||||
//input框失去焦点事件
|
||||
inputClick(row){
|
||||
row.flag=false
|
||||
let data = {
|
||||
id:row.id,
|
||||
sort:row.sort
|
||||
}
|
||||
this.updateData(data)
|
||||
},
|
||||
/**
|
||||
* 改变是否发布的值
|
||||
* @param e
|
||||
* @param row
|
||||
*/
|
||||
changeIfPublic(e,row){
|
||||
let data = {
|
||||
id:row.id,
|
||||
ifPublic:e
|
||||
}
|
||||
this.updateData(data)
|
||||
},
|
||||
/**
|
||||
* 改变是否首页推荐的值
|
||||
* @param e
|
||||
* @param row
|
||||
*/
|
||||
changeIfReco(e,row){
|
||||
let data = {
|
||||
id:row.id,
|
||||
ifReco:e
|
||||
}
|
||||
this.updateData(data)
|
||||
},
|
||||
/**
|
||||
* 更新数据
|
||||
* @param data
|
||||
*/
|
||||
updateData(data){
|
||||
updateProdNew(data).then(response => {
|
||||
this.$modal.msgSuccess('修改成功')
|
||||
this.getList()
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
226
dl_vue/src/views/busi/new/newForm.vue
Normal file
226
dl_vue/src/views/busi/new/newForm.vue
Normal file
@ -0,0 +1,226 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<el-button @click="back">返 回</el-button>
|
||||
<el-button type="success" @click="submitForm">暂 存</el-button>
|
||||
<el-button type="primary" @click="submitForm">发 布</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-divider></el-divider>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="150px">
|
||||
<el-row>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="产品名称" prop="title">
|
||||
<el-input v-model="form.title" placeholder="请输入产品名称"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="10">
|
||||
<el-form-item label="所属分类" prop="catgId">
|
||||
<div class="dl-flex-column">
|
||||
<el-input v-model="form.catgId" placeholder="请输入产品名称"/>
|
||||
<div class="dl-add-catg">添加产品分类</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item label="排序" prop="sort">
|
||||
<el-input v-model="form.sort" type="number" placeholder="请输入排序"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="产品主图" prop="mainPic">
|
||||
<el-tag style="cursor: pointer">图片库选择</el-tag>
|
||||
<image-upload @uploadedImg="uploadedImg" v-model="form.mainPic" :limit="1"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="16">
|
||||
<el-form-item label="产品图库" prop="pics">
|
||||
<el-tag style="cursor: pointer">图片库选择</el-tag>
|
||||
<image-upload @uploadedImg="uploadedImg" v-model="form.pics" :limit="9"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<!-- <el-form-item label="页面title" prop="prodTitle">-->
|
||||
<!-- <el-input v-model="form.prodTitle" placeholder="请输入页面title"/>-->
|
||||
<!-- </el-form-item>-->
|
||||
<!-- <el-form-item label="页面keyword" prop="prodKeyword">-->
|
||||
<!-- <el-input v-model="form.prodKeyword" type="textarea" placeholder="请输入内容"/>-->
|
||||
<!-- </el-form-item>-->
|
||||
<!-- <el-form-item label="页面description" prop="prodDescription">-->
|
||||
<!-- <el-input v-model="form.prodDescription" type="textarea" placeholder="请输入内容"/>-->
|
||||
<!-- </el-form-item>-->
|
||||
<el-row>
|
||||
<el-col :span="18">
|
||||
<el-form-item label="产品简介" prop="description">
|
||||
<div class="dl-flex-column">
|
||||
<el-input style="width: 80%" ref="descriptionInput" v-model="form.description" type="textarea"
|
||||
placeholder="请输入内容" @blur="handleBlur"
|
||||
/>
|
||||
<el-tag style="cursor: pointer;margin-left: 10px" @click="insertBr">插入换行符</el-tag>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item label="首页推荐" prop="ifReco">
|
||||
<el-switch
|
||||
v-model="form.ifReco"
|
||||
>
|
||||
</el-switch>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-form-item label="产品内容">
|
||||
<editor v-model="form.content" :min-height="192"/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-divider></el-divider>
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<el-button @click="back">返 回</el-button>
|
||||
<el-button type="success" @click="saveTmp">暂 存</el-button>
|
||||
<el-button type="primary" @click="submitForm">发 布</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listProdNew, getProdNew, delProdNew,getMaxSort, addProdNew, updateProdNew } from '@/api/busi/new'
|
||||
|
||||
export default {
|
||||
name: 'newForm',
|
||||
data() {
|
||||
return {
|
||||
//光标位置--简介
|
||||
cursorPos: null,
|
||||
// 表单参数
|
||||
form: {
|
||||
id: null,
|
||||
catgId: null,
|
||||
title: null,
|
||||
prodTitle: null,
|
||||
prodKeyword: null,
|
||||
prodDescription: null,
|
||||
newsFrom: null,
|
||||
mainPic: null,
|
||||
pics: null,
|
||||
description: null,
|
||||
content: null,
|
||||
sort: null,
|
||||
ifReco: 0,
|
||||
ifPublic: 0,
|
||||
tenantId: null,
|
||||
creator: null,
|
||||
createTime: null,
|
||||
updater: null,
|
||||
updateTime: null,
|
||||
delFlag: null,
|
||||
//当前上传的所有图片
|
||||
fileList:[],
|
||||
},
|
||||
// 表单校验
|
||||
rules: {
|
||||
title: [
|
||||
{ required: true, message: '请输入产品名称', trigger: 'blur' }
|
||||
],
|
||||
catgId: [
|
||||
{ required: true, message: '请选择产品分类', trigger: 'blur' }
|
||||
],
|
||||
sort: [
|
||||
{ required: true, message: '请输入排序', trigger: 'blur' }
|
||||
],
|
||||
mainPic: [
|
||||
{ required: true, message: '请上传产品主图', trigger: 'blur' }
|
||||
],
|
||||
description: [
|
||||
{ required: true, message: '请输入产品简介', trigger: 'blur' }
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if(this.$route.query.id){
|
||||
this.getProdInfo(this.$route.query.id)
|
||||
}else{
|
||||
this.initData()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
initData(){
|
||||
getMaxSort({}).then(response => {
|
||||
this.form.sort = response.data
|
||||
})
|
||||
},
|
||||
getProdInfo(id){
|
||||
getProdNew(id).then(response => {
|
||||
this.form= response.data
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 返回上一页
|
||||
*/
|
||||
back() {
|
||||
history.back()
|
||||
},
|
||||
//图片上传回调
|
||||
uploadedImg(fileList){
|
||||
this.form.fileList = this.form.fileList.concat(fileList)
|
||||
},
|
||||
handleBlur(e) {
|
||||
this.cursorPos = e.srcElement.selectionStart
|
||||
},
|
||||
/**
|
||||
* 插入换行符
|
||||
*/
|
||||
insertBr() {
|
||||
let str = '<br/>'
|
||||
if (!this.form.description) {
|
||||
this.form.description = str
|
||||
} else {
|
||||
const start = this.form.description.substring(0, this.cursorPos)
|
||||
const end = this.form.description.substring(this.cursorPos)
|
||||
this.form.description = `${start}${str}${end}`
|
||||
}
|
||||
},
|
||||
/** 暂存 */
|
||||
saveTmp(){
|
||||
if (this.form.id != null) {
|
||||
updateProdNew(this.form).then(response => {
|
||||
this.$modal.msgSuccess('修改成功')
|
||||
setTimeout(()=>{
|
||||
history.back()
|
||||
},1000)
|
||||
})
|
||||
} else {
|
||||
addProdNew(this.form).then(response => {
|
||||
this.$modal.msgSuccess('新增成功')
|
||||
setTimeout(()=>{
|
||||
history.back()
|
||||
},1000)
|
||||
})
|
||||
}
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.$refs['form'].validate(valid => {
|
||||
if (valid) {
|
||||
this.form.ifPublic=1
|
||||
this.saveTmp()
|
||||
}
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.dl-add-catg {
|
||||
cursor: pointer;
|
||||
width: 130px;
|
||||
text-align: center;
|
||||
color: #1890ff;
|
||||
}
|
||||
</style>
|
@ -61,34 +61,75 @@
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="prodList" @selection-change="handleSelectionChange">
|
||||
<el-table v-loading="loading" :data="prodList" @cell-dblclick="cellClick">
|
||||
<!-- <el-table-column type="selection" width="55" align="center" />-->
|
||||
<el-table-column type="index" width="60" label="序号" align="center"></el-table-column>
|
||||
<el-table-column label="所属栏目" align="center" prop="catgName" />
|
||||
<el-table-column label="产品名称" align="center" prop="title" />
|
||||
<el-table-column label="产品主图" align="center" prop="mainPic" width="100">
|
||||
<el-table-column label="所属栏目" align="center" prop="catgName" width="120" />
|
||||
<el-table-column label="产品名称" align="center" prop="title" width="200" />
|
||||
<el-table-column label="产品图" align="center" prop="mainPic" width="100">
|
||||
<template slot-scope="scope">
|
||||
<image-preview :src="scope.row.mainPic" :width="50" :height="50"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="产品图" align="center" prop="pics" width="100">
|
||||
<template slot-scope="scope">
|
||||
<image-preview :src="scope.row.pics" :width="50" :height="50"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="产品简介" align="center" prop="description" />
|
||||
<el-table-column label="是否首页推荐显示" align="center" prop="ifReco">
|
||||
<el-table-column width="100" label="排序" align="center" prop="sort">
|
||||
<template slot="header" slot-scope="scope">
|
||||
<span>排序</span>
|
||||
<el-tooltip class="item" effect="dark" content="鼠标双击数据可直接修改排序"
|
||||
placement="bottom"
|
||||
>
|
||||
<i class="el-icon-question"></i>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.sys_yes_no" :value="scope.row.ifReco"/>
|
||||
<el-input size="mini" type="number" v-model="scope.row.sort" v-if="scope.row.flag" @blur="inputClick(scope.row)" v-focus></el-input>
|
||||
<span v-if="!scope.row.flag">{{scope.row.sort}}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="是否发布" align="center" prop="ifPublic">
|
||||
<el-table-column width="80" label="首页显示" align="center" prop="ifReco">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.sys_yes_no" :value="scope.row.ifPublic"/>
|
||||
<el-switch
|
||||
v-model="scope.row.ifReco"
|
||||
@change="changeIfReco($event,scope.row)"
|
||||
>
|
||||
</el-switch>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<el-table-column width="80" label="是否发布" align="center" prop="ifPublic">
|
||||
<template slot-scope="scope">
|
||||
<el-switch
|
||||
v-model="scope.row.ifPublic"
|
||||
@change="changeIfPublic($event,scope.row)"
|
||||
>
|
||||
</el-switch>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column width="80" label="随机产品" align="center" prop="randomNum">
|
||||
<template slot-scope="scope">
|
||||
<el-tag style="cursor: pointer" @click="managerRandom(scope.row)">{{scope.row.randomNum}}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column width="120" label="发布人" align="center" prop="userName">
|
||||
</el-table-column>
|
||||
<el-table-column width="100" label="创建时间" align="center" prop="createTime">
|
||||
<template slot-scope="scope">
|
||||
{{scope.row.createTime | formatDate}}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column width="100" label="修改时间" align="center" prop="updateTime">
|
||||
<template slot-scope="scope">
|
||||
{{scope.row.updateTime | formatDate}}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column width="200" label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-edit"
|
||||
@click="handleAddSimilar(scope.row.id)"
|
||||
v-hasPermi="['busi:prod:add']"
|
||||
>添加相似</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
@ -114,21 +155,92 @@
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- 随机产品管理对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="randomOpen" width="1000px" append-to-body>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
@click="handleAddNewRandom"
|
||||
>添加</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-table v-loading="randomLoading" :data="randomProdList" >
|
||||
<el-table-column type="index" width="60" label="序号" align="center"></el-table-column>
|
||||
<el-table-column label="产品名称" align="center" prop="title" />
|
||||
<el-table-column label="所属栏目" align="center" prop="catgName" width="160" />
|
||||
<el-table-column label="产品图" align="center" prop="mainPic" width="200">
|
||||
<template slot-scope="scope">
|
||||
<image-preview :src="scope.row.mainPic" :width="50" :height="50"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column width="150" label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
>删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="cancelRandom">关 闭</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 选择产品对话框 -->
|
||||
<el-dialog :title="selectTitle" :visible.sync="selectOpen" width="1000px" append-to-body>
|
||||
<el-table v-loading="selectLoading" :data="selectProdList" @selection-change="handleSelectionChange" >
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column type="index" width="60" label="序号" align="center"></el-table-column>
|
||||
<el-table-column label="产品名称" align="center" prop="title" />
|
||||
<el-table-column label="所属栏目" align="center" prop="catgName" width="160" />
|
||||
<el-table-column label="产品图" align="center" prop="mainPic" width="200">
|
||||
<template slot-scope="scope">
|
||||
<image-preview :src="scope.row.mainPic" :width="50" :height="50"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination
|
||||
v-show="selectTotal>0"
|
||||
:total="selectTotal"
|
||||
:page.sync="selectQueryParams.pageNum"
|
||||
:limit.sync="selectQueryParams.pageSize"
|
||||
@pagination="handleAddNewRandom"
|
||||
/>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitSelect">确 定</el-button>
|
||||
<el-button @click="cancelSelect">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listProdNew, getProdNew, delProdNew, addProdNew, updateProdNew } from "@/api/busi/prod";
|
||||
import { listProdNew, getProdNew, delProdNew, addProdNew, updateProdNew,listRandomProd,saveRandom } from "@/api/busi/prod";
|
||||
|
||||
export default {
|
||||
name: "Prod",
|
||||
dicts: ['sys_yes_no'],
|
||||
data() {
|
||||
return {
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 弹出层标题
|
||||
selectTitle: "添加随机产品",
|
||||
// 是否显示弹出层
|
||||
randomOpen: false,
|
||||
// 是否显示弹出层
|
||||
selectOpen: false,
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
@ -139,8 +251,6 @@ export default {
|
||||
total: 0,
|
||||
// 产品数据
|
||||
prodList: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 查询参数
|
||||
@ -151,10 +261,68 @@ export default {
|
||||
title: null,
|
||||
newsFrom: null,
|
||||
},
|
||||
|
||||
//当前操作的数据id
|
||||
nowDealId:"",
|
||||
// 遮罩层
|
||||
randomLoading: true,
|
||||
//当前产品的随机产品数组
|
||||
randomProdList: [],
|
||||
// 每个产品最多管理10个产品
|
||||
randomMax:10,
|
||||
|
||||
// 遮罩层
|
||||
selectLoading:true,
|
||||
//待选择的产品数组
|
||||
selectProdList: [],
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 总条数
|
||||
selectTotal: 0,
|
||||
// 查询参数
|
||||
selectQueryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
//需要排除的产品id,多个英文逗号隔开
|
||||
excludeProdId:null,
|
||||
//查已发布的
|
||||
ifPublic: true,
|
||||
catgId: null,
|
||||
title: null,
|
||||
},
|
||||
};
|
||||
},
|
||||
created() {
|
||||
filters:{
|
||||
formatDate(val){
|
||||
if(val){
|
||||
return val.slice(0, 10)
|
||||
}else{
|
||||
return ""
|
||||
}
|
||||
},
|
||||
},
|
||||
directives: {
|
||||
// 注册一个局部的自定义指令 v-focus
|
||||
focus: {
|
||||
// 指令的定义
|
||||
inserted: function (el) {
|
||||
// 聚焦元素
|
||||
el.querySelector('input').focus()
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'$route'(to, from) {
|
||||
if (from.path !== to.path) {
|
||||
// 返回上一页时执行的代码
|
||||
this.getList();
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.getList();
|
||||
},
|
||||
created() {
|
||||
},
|
||||
methods: {
|
||||
/** 查询产品、文章列表 */
|
||||
@ -178,6 +346,12 @@ export default {
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
if(selection.length+this.randomProdList.length>this.randomMax){
|
||||
//新选择的+已选择的数量已经大于最大可关联的产品数量
|
||||
this.$modal.msgWarning("请注意,每个产品最多可关联"+this.randomMax+"个随机产品,超出的产品不再追加!");
|
||||
selection = selection.slice(0, -1);
|
||||
}
|
||||
console.log(selection,"selection")
|
||||
this.ids = selection.map(item => item.id)
|
||||
this.single = selection.length!==1
|
||||
this.multiple = !selection.length
|
||||
@ -186,20 +360,18 @@ export default {
|
||||
handleAdd() {
|
||||
this.$router.push({path:'/product/prodForm'})
|
||||
},
|
||||
/** 添加类似操作 */
|
||||
handleAddSimilar(id){
|
||||
this.$router.push({path:'/product/prodForm',query:{id:id,type:"similar"}})
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset();
|
||||
const id = row.id || this.ids
|
||||
getProdNew(id).then(response => {
|
||||
this.form = response.data;
|
||||
this.open = true;
|
||||
this.title = "修改产品、文章";
|
||||
});
|
||||
this.$router.push({path:'/product/prodForm',query:{id:row.id}})
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const ids = row.id || this.ids;
|
||||
this.$modal.confirm('是否确认删除产品、文章编号为"' + ids + '"的数据项?').then(function() {
|
||||
this.$modal.confirm('是否确认删除产品?').then(function() {
|
||||
return delProdNew(ids);
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
@ -210,8 +382,122 @@ export default {
|
||||
handleExport() {
|
||||
this.download('busi/prod/export', {
|
||||
...this.queryParams
|
||||
}, `prodNew_${new Date().getTime()}.xlsx`)
|
||||
}, `prod_${new Date().getTime()}.xlsx`)
|
||||
},
|
||||
//双击单元格后,显示input,并通过v-focus让input自动获取焦点
|
||||
cellClick(row){
|
||||
row.flag=true
|
||||
},
|
||||
//input框失去焦点事件
|
||||
inputClick(row){
|
||||
row.flag=false
|
||||
let data = {
|
||||
id:row.id,
|
||||
sort:row.sort
|
||||
}
|
||||
this.updateData(data)
|
||||
},
|
||||
/**
|
||||
* 改变是否发布的值
|
||||
* @param e
|
||||
* @param row
|
||||
*/
|
||||
changeIfPublic(e,row){
|
||||
let data = {
|
||||
id:row.id,
|
||||
ifPublic:e
|
||||
}
|
||||
this.updateData(data)
|
||||
},
|
||||
/**
|
||||
* 改变是否首页推荐的值
|
||||
* @param e
|
||||
* @param row
|
||||
*/
|
||||
changeIfReco(e,row){
|
||||
let data = {
|
||||
id:row.id,
|
||||
ifReco:e
|
||||
}
|
||||
this.updateData(data)
|
||||
},
|
||||
/**
|
||||
* 更新数据
|
||||
* @param data
|
||||
*/
|
||||
updateData(data){
|
||||
updateProdNew(data).then(response => {
|
||||
this.$modal.msgSuccess('修改成功')
|
||||
this.getList()
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 查看产品随机产品
|
||||
* @param id
|
||||
*/
|
||||
managerRandom(row){
|
||||
this.getRandomList(row.id)
|
||||
this.title=row.title+"-随机产品"
|
||||
this.nowDealId = row.id
|
||||
this.randomOpen = true;
|
||||
},
|
||||
/** 查询管理产品列表 */
|
||||
getRandomList(prodId) {
|
||||
if(!prodId){
|
||||
prodId = this.nowDealId
|
||||
}
|
||||
this.randomLoading = true;
|
||||
listRandomProd({prodId:prodId}).then(response => {
|
||||
this.randomProdList = response.data;
|
||||
this.randomLoading = false;
|
||||
});
|
||||
},
|
||||
// 取消按钮--修改随机产品
|
||||
cancelRandom() {
|
||||
this.randomOpen = false;
|
||||
this.getList()
|
||||
},
|
||||
// 确定按钮--修改随机产品
|
||||
submitRandom(){
|
||||
this.randomOpen = false;
|
||||
},
|
||||
|
||||
/**
|
||||
* 添加随机产品
|
||||
*/
|
||||
handleAddNewRandom(){
|
||||
this.selectOpen=true
|
||||
this.selectLoading = true;
|
||||
//需要排除掉的产品id
|
||||
let excludeProdId = this.nowDealId
|
||||
if(this.randomProdList && this.randomProdList.length>0){
|
||||
excludeProdId =excludeProdId+","+this.randomProdList.map(item => item.id).join(', ');
|
||||
}
|
||||
this.selectQueryParams.excludeProdId = excludeProdId
|
||||
listProdNew(this.selectQueryParams).then(response => {
|
||||
this.selectProdList = response.data.records;
|
||||
this.selectTotal = response.data.total;
|
||||
this.selectLoading = false;
|
||||
});
|
||||
},
|
||||
// 取消按钮--新增随机产品
|
||||
cancelSelect() {
|
||||
this.selectOpen = false;
|
||||
},
|
||||
// 确定按钮--新增随机产品
|
||||
submitSelect(){
|
||||
this.selectOpen = false;
|
||||
if(this.ids.length>0){
|
||||
let dataObj={
|
||||
prodId:this.nowDealId,
|
||||
randomIdList:this.ids
|
||||
}
|
||||
saveRandom(dataObj).then(response => {
|
||||
this.$modal.msgSuccess('新增成功')
|
||||
this.getRandomList()
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -65,14 +65,10 @@
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item label="首页推荐" prop="ifReco">
|
||||
<el-radio-group v-model="form.ifReco">
|
||||
<el-radio
|
||||
v-for="dict in dict.type.true_or_false"
|
||||
:key="dict.value"
|
||||
:label="parseInt(dict.value)"
|
||||
>{{ dict.label }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
<el-switch
|
||||
v-model="form.ifReco"
|
||||
>
|
||||
</el-switch>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
@ -96,7 +92,6 @@ import { listProdNew, getProdNew, delProdNew,getMaxSort, addProdNew, updateProdN
|
||||
|
||||
export default {
|
||||
name: 'prodForm',
|
||||
dicts: ['true_or_false'],
|
||||
data() {
|
||||
return {
|
||||
//光标位置--简介
|
||||
@ -147,7 +142,11 @@ export default {
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if(this.$route.query.id){
|
||||
this.getProdInfo(this.$route.query.id)
|
||||
}else{
|
||||
this.initData()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
initData(){
|
||||
@ -155,6 +154,11 @@ export default {
|
||||
this.form.sort = response.data
|
||||
})
|
||||
},
|
||||
getProdInfo(id){
|
||||
getProdNew(id).then(response => {
|
||||
this.form= response.data
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 返回上一页
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user