Merge branch 'master' of http://124.222.105.7:3000/dianliang/dl_site_system
This commit is contained in:
commit
5a0819ff9a
@ -4,8 +4,11 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.ruoyi.base.service.IBasePicsService;
|
import com.ruoyi.base.service.IBasePicsService;
|
||||||
import com.ruoyi.busi.domain.BusiProdNew;
|
import com.ruoyi.busi.domain.BusiProdNew;
|
||||||
|
import com.ruoyi.busi.domain.BusiProdRandom;
|
||||||
import com.ruoyi.busi.service.IBusiProdNewService;
|
import com.ruoyi.busi.service.IBusiProdNewService;
|
||||||
|
import com.ruoyi.busi.service.IBusiProdRandomService;
|
||||||
import com.ruoyi.busi.vo.ProdNewVO;
|
import com.ruoyi.busi.vo.ProdNewVO;
|
||||||
|
import com.ruoyi.busi.vo.ProdRandomVO;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
@ -20,10 +23,10 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static com.ruoyi.constant.DictConstants.FILE_TYPE_PRODUCT;
|
import static com.ruoyi.constant.DictConstants.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 产品Controller
|
* 新闻Controller
|
||||||
*
|
*
|
||||||
* @author vinjor-m
|
* @author vinjor-m
|
||||||
* @date 2025-06-25
|
* @date 2025-06-25
|
||||||
@ -36,9 +39,11 @@ public class BusiNewController extends BaseController
|
|||||||
private IBusiProdNewService busiProdNewService;
|
private IBusiProdNewService busiProdNewService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private IBasePicsService basePicsService;
|
private IBasePicsService basePicsService;
|
||||||
|
@Autowired
|
||||||
|
private IBusiProdRandomService prodRandomService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询产品列表
|
* 查询新闻列表
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('busi:new:list')")
|
@PreAuthorize("@ss.hasPermi('busi:new:list')")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
@ -47,25 +52,39 @@ public class BusiNewController extends BaseController
|
|||||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize)
|
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize)
|
||||||
{
|
{
|
||||||
Page<BusiProdNew> page = new Page<>(pageNum, pageSize);
|
Page<BusiProdNew> page = new Page<>(pageNum, pageSize);
|
||||||
|
//只查新闻
|
||||||
|
busiProdNew.setDataType(DATA_TYPE_NEWS);
|
||||||
IPage<ProdNewVO> list = busiProdNewService.queryListPage(busiProdNew,page);
|
IPage<ProdNewVO> list = busiProdNewService.queryListPage(busiProdNew,page);
|
||||||
return success(list);
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出新闻列表
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('busi:new:export')")
|
@PreAuthorize("@ss.hasPermi('busi:new:export')")
|
||||||
@Log(title = "产品", businessType = BusinessType.EXPORT)
|
@Log(title = "新闻", businessType = BusinessType.EXPORT)
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(HttpServletResponse response, BusiProdNew busiProdNew)
|
public void export(HttpServletResponse response, BusiProdNew busiProdNew)
|
||||||
{
|
{
|
||||||
List<BusiProdNew> list = busiProdNewService.list();
|
List<BusiProdNew> list = busiProdNewService.list();
|
||||||
ExcelUtil<BusiProdNew> util = new ExcelUtil<BusiProdNew>(BusiProdNew.class);
|
ExcelUtil<BusiProdNew> util = new ExcelUtil<BusiProdNew>(BusiProdNew.class);
|
||||||
util.exportExcel(response, list, "产品、文章数据");
|
util.exportExcel(response, list, "文章数据");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取产品详细信息
|
* 获取新闻详细信息
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('busi:new:query')")
|
@PreAuthorize("@ss.hasPermi('busi:new:query')")
|
||||||
@GetMapping(value = "/{id}")
|
@GetMapping(value = "/{id}")
|
||||||
@ -75,56 +94,95 @@ public class BusiNewController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取产品表当前最大排序
|
* 获取新闻表当前最大排序
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/getMaxSort")
|
@GetMapping(value = "/getMaxSort")
|
||||||
public AjaxResult getMaxSort(String tenantId)
|
public AjaxResult getMaxSort(String tenantId)
|
||||||
{
|
{
|
||||||
return success(busiProdNewService.getMaxSort(tenantId));
|
return success(busiProdNewService.getMaxSort(tenantId,DATA_TYPE_NEWS));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增产品
|
* 新增新闻
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('busi:new:add')")
|
@PreAuthorize("@ss.hasPermi('busi:new:add')")
|
||||||
@Log(title = "产品", businessType = BusinessType.INSERT)
|
@Log(title = "新闻", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@RequestBody ProdNewVO prodNewVO){
|
public AjaxResult add(@RequestBody ProdNewVO prodNewVO){
|
||||||
|
prodNewVO.setDataType(DATA_TYPE_NEWS);
|
||||||
busiProdNewService.save(prodNewVO);
|
busiProdNewService.save(prodNewVO);
|
||||||
if(null!=prodNewVO.getFileList() && !prodNewVO.getFileList().isEmpty()){
|
if(null!=prodNewVO.getFileList() && !prodNewVO.getFileList().isEmpty()){
|
||||||
prodNewVO.getFileList().forEach(item->{
|
prodNewVO.getFileList().forEach(item->{
|
||||||
item.setTenantId(prodNewVO.getTenantId());
|
item.setTenantId(prodNewVO.getTenantId());
|
||||||
item.setFileType(FILE_TYPE_PRODUCT);
|
item.setFileType(FILE_TYPE_NEWS);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
busiProdNewService.setAmount(prodNewVO.getTenantId());
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改产品
|
* 修改新闻
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('busi:new:edit')")
|
@PreAuthorize("@ss.hasPermi('busi:new:edit')")
|
||||||
@Log(title = "产品", businessType = BusinessType.UPDATE)
|
@Log(title = "新闻", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@RequestBody ProdNewVO prodNewVO){
|
public AjaxResult edit(@RequestBody ProdNewVO prodNewVO){
|
||||||
|
prodNewVO.setDataType(DATA_TYPE_NEWS);
|
||||||
busiProdNewService.updateById(prodNewVO);
|
busiProdNewService.updateById(prodNewVO);
|
||||||
if(null!=prodNewVO.getFileList() && !prodNewVO.getFileList().isEmpty()){
|
if(null!=prodNewVO.getFileList() && !prodNewVO.getFileList().isEmpty()){
|
||||||
prodNewVO.getFileList().forEach(item->{
|
prodNewVO.getFileList().forEach(item->{
|
||||||
item.setTenantId(prodNewVO.getTenantId());
|
item.setTenantId(prodNewVO.getTenantId());
|
||||||
item.setFileType(FILE_TYPE_PRODUCT);
|
item.setFileType(FILE_TYPE_NEWS);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除产品
|
* 删除新闻
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('busi:new:remove')")
|
@PreAuthorize("@ss.hasPermi('busi:new:remove')")
|
||||||
@Log(title = "产品", businessType = BusinessType.DELETE)
|
@Log(title = "新闻", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{ids}")
|
@DeleteMapping("/{ids}")
|
||||||
public AjaxResult remove(@PathVariable String[] ids){
|
public AjaxResult remove(@PathVariable String[] ids){
|
||||||
List<String> list = new ArrayList<>(Arrays.asList(ids));
|
List<String> list = new ArrayList<>(Arrays.asList(ids));
|
||||||
return toAjax(busiProdNewService.removeByIds(list));
|
BusiProdNew prodNew = busiProdNewService.getById(list.get(0));
|
||||||
|
busiProdNewService.removeByIds(list);
|
||||||
|
busiProdNewService.setAmount(prodNew.getTenantId());
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存新闻关联的随机产品
|
||||||
|
* @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();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除新闻关联的随机产品
|
||||||
|
* @author vinjor-M
|
||||||
|
* @date 9:38 2025/6/30
|
||||||
|
* @return com.ruoyi.common.core.domain.AjaxResult
|
||||||
|
**/
|
||||||
|
@PostMapping("/delProdRandom")
|
||||||
|
public AjaxResult delProdRandom(@RequestBody ProdRandomVO randomVO){
|
||||||
|
prodRandomService.delProdRandom(randomVO.getProdId(),randomVO.getRandomId(),randomVO.getTenantId());
|
||||||
|
return success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,8 +31,7 @@ import com.ruoyi.busi.service.IBusiProdNewService;
|
|||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
|
|
||||||
import static com.ruoyi.constant.DictConstants.DATA_TYPE_PRODUCT;
|
import static com.ruoyi.constant.DictConstants.*;
|
||||||
import static com.ruoyi.constant.DictConstants.FILE_TYPE_PRODUCT;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 产品Controller
|
* 产品Controller
|
||||||
@ -108,7 +107,7 @@ public class BusiProdController extends BaseController
|
|||||||
@GetMapping(value = "/getMaxSort")
|
@GetMapping(value = "/getMaxSort")
|
||||||
public AjaxResult getMaxSort(String tenantId)
|
public AjaxResult getMaxSort(String tenantId)
|
||||||
{
|
{
|
||||||
return success(busiProdNewService.getMaxSort(tenantId));
|
return success(busiProdNewService.getMaxSort(tenantId,DATA_TYPE_PRODUCT));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -7,6 +7,8 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
|||||||
import lombok.*;
|
import lombok.*;
|
||||||
import com.ruoyi.common.core.domain.DlBaseEntity;
|
import com.ruoyi.common.core.domain.DlBaseEntity;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 产品、文章对象 dl_busi_prod_new
|
* 产品、文章对象 dl_busi_prod_new
|
||||||
*
|
*
|
||||||
@ -55,6 +57,9 @@ public class BusiProdNew extends DlBaseEntity
|
|||||||
/** 文章来源 */
|
/** 文章来源 */
|
||||||
@Excel(name = "文章来源")
|
@Excel(name = "文章来源")
|
||||||
private String newsFrom;
|
private String newsFrom;
|
||||||
|
/** 文章发布日期 */
|
||||||
|
@Excel(name = "文章发布日期")
|
||||||
|
private Date publicDate;
|
||||||
|
|
||||||
/** 产品主图或文章图片 */
|
/** 产品主图或文章图片 */
|
||||||
@Excel(name = "产品主图或文章图片")
|
@Excel(name = "产品主图或文章图片")
|
||||||
|
|||||||
@ -20,7 +20,7 @@ public interface BusiProdNewMapper extends BaseMapper<BusiProdNew>
|
|||||||
{
|
{
|
||||||
IPage<ProdNewVO> queryListPage(@Param("entity") ProdNewVO entity, Page<BusiProdNew> page);
|
IPage<ProdNewVO> queryListPage(@Param("entity") ProdNewVO entity, Page<BusiProdNew> page);
|
||||||
|
|
||||||
Long selectMaxSort(@Param("tenantId")String tenantId);
|
Long selectMaxSort(@Param("tenantId")String tenantId,@Param("dataType")String dataType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 统计分类下产品数量
|
* 统计分类下产品数量
|
||||||
|
|||||||
@ -24,7 +24,7 @@ public interface IBusiProdNewService extends IService<BusiProdNew>
|
|||||||
* @param tenantId 站点id
|
* @param tenantId 站点id
|
||||||
* @return java.lang.Long
|
* @return java.lang.Long
|
||||||
**/
|
**/
|
||||||
Long getMaxSort(String tenantId);
|
Long getMaxSort(String tenantId,String dataType);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -49,8 +49,8 @@ public class BusiProdNewServiceImpl extends ServiceImpl<BusiProdNewMapper,BusiPr
|
|||||||
* @date 16:15 2025/6/25
|
* @date 16:15 2025/6/25
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
public Long getMaxSort(String tenantId) {
|
public Long getMaxSort(String tenantId,String dataType) {
|
||||||
Long sort = busiProdNewMapper.selectMaxSort(tenantId);
|
Long sort = busiProdNewMapper.selectMaxSort(tenantId,dataType);
|
||||||
return null==sort?1:sort+1;
|
return null==sort?1:sort+1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -12,6 +12,7 @@
|
|||||||
<result property="prodKeyword" column="prod_keyword"/>
|
<result property="prodKeyword" column="prod_keyword"/>
|
||||||
<result property="prodDescription" column="prod_description"/>
|
<result property="prodDescription" column="prod_description"/>
|
||||||
<result property="newsFrom" column="news_from"/>
|
<result property="newsFrom" column="news_from"/>
|
||||||
|
<result property="publicDate" column="public_date"/>
|
||||||
<result property="mainPic" column="main_pic"/>
|
<result property="mainPic" column="main_pic"/>
|
||||||
<result property="pics" column="pics"/>
|
<result property="pics" column="pics"/>
|
||||||
<result property="description" column="description"/>
|
<result property="description" column="description"/>
|
||||||
@ -42,6 +43,7 @@
|
|||||||
prod_keyword,
|
prod_keyword,
|
||||||
prod_description,
|
prod_description,
|
||||||
news_from,
|
news_from,
|
||||||
|
public_date,
|
||||||
main_pic,
|
main_pic,
|
||||||
pics,
|
pics,
|
||||||
description,
|
description,
|
||||||
@ -117,6 +119,7 @@
|
|||||||
WHERE
|
WHERE
|
||||||
del_flag = '0'
|
del_flag = '0'
|
||||||
AND tenant_id = #{tenantId}
|
AND tenant_id = #{tenantId}
|
||||||
|
AND data_type=#{dataType}
|
||||||
</select>
|
</select>
|
||||||
<select id="getCatgAmount" resultType="com.ruoyi.busi.vo.ProdNewVO">
|
<select id="getCatgAmount" resultType="com.ruoyi.busi.vo.ProdNewVO">
|
||||||
SELECT
|
SELECT
|
||||||
|
|||||||
@ -30,10 +30,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</select>
|
</select>
|
||||||
<select id="selectRandomList" resultType="com.ruoyi.busi.vo.ProdNewVO">
|
<select id="selectRandomList" resultType="com.ruoyi.busi.vo.ProdNewVO">
|
||||||
SELECT
|
SELECT
|
||||||
dbpn.*
|
dbpn.*,
|
||||||
|
dbc.catg_name AS catgName
|
||||||
FROM
|
FROM
|
||||||
dl_busi_prod_random dbpr
|
dl_busi_prod_random dbpr
|
||||||
LEFT JOIN dl_busi_prod_new dbpn ON dbpr.random_id = dbpn.id
|
LEFT JOIN dl_busi_prod_new dbpn ON dbpr.random_id = dbpn.id
|
||||||
|
LEFT JOIN dl_busi_category dbc ON dbpn.catg_id = dbc.id
|
||||||
WHERE
|
WHERE
|
||||||
dbpr.prod_id = #{map.prodId}
|
dbpr.prod_id = #{map.prodId}
|
||||||
AND dbpr.tenant_id =#{map.tenantId}
|
AND dbpr.tenant_id =#{map.tenantId}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import request from '@/utils/request'
|
import request from '@/utils/request'
|
||||||
|
|
||||||
// 查询产品、文章列表
|
// 查询文章列表
|
||||||
export function listProdNew(query) {
|
export function listProdNew(query) {
|
||||||
return request({
|
return request({
|
||||||
url: '/busi/new/list',
|
url: '/busi/new/list',
|
||||||
@ -9,8 +9,17 @@ export function listProdNew(query) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询产品、文章列表
|
// 查询随机管关联产品列表
|
||||||
export function getMaxSort(query) {
|
export function listRandomProd(query) {
|
||||||
|
return request({
|
||||||
|
url: '/busi/new/randomList',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询文章最大排序
|
||||||
|
export function getMaxNewSort(query) {
|
||||||
return request({
|
return request({
|
||||||
url: '/busi/new/getMaxSort',
|
url: '/busi/new/getMaxSort',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
@ -18,7 +27,7 @@ export function getMaxSort(query) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询产品、文章详细
|
// 查询文章详细
|
||||||
export function getProdNew(id) {
|
export function getProdNew(id) {
|
||||||
return request({
|
return request({
|
||||||
url: '/busi/new/' + id,
|
url: '/busi/new/' + id,
|
||||||
@ -26,7 +35,7 @@ export function getProdNew(id) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 新增产品、文章
|
// 新增文章
|
||||||
export function addProdNew(data) {
|
export function addProdNew(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/busi/new',
|
url: '/busi/new',
|
||||||
@ -35,7 +44,7 @@ export function addProdNew(data) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改产品、文章
|
// 修改文章
|
||||||
export function updateProdNew(data) {
|
export function updateProdNew(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/busi/new',
|
url: '/busi/new',
|
||||||
@ -44,10 +53,28 @@ export function updateProdNew(data) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除产品、文章
|
// 删除文章
|
||||||
export function delProdNew(id) {
|
export function delProdNew(id) {
|
||||||
return request({
|
return request({
|
||||||
url: '/busi/new/' + id,
|
url: '/busi/new/' + id,
|
||||||
method: 'delete'
|
method: 'delete'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 保存文章关联的随机产品
|
||||||
|
export function saveRandom(data) {
|
||||||
|
return request({
|
||||||
|
url: '/busi/new/saveRandom',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除关联产品
|
||||||
|
export function delProdRandom(data) {
|
||||||
|
return request({
|
||||||
|
url: '/busi/new/delProdRandom',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@ -69,6 +69,11 @@ import { listPics} from "@/api/base/pics";
|
|||||||
export default {
|
export default {
|
||||||
dicts: ['file_type'],
|
dicts: ['file_type'],
|
||||||
props: {
|
props: {
|
||||||
|
//默认选中的新闻类型
|
||||||
|
fileType: {
|
||||||
|
type: String,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@ -97,6 +102,7 @@ export default {
|
|||||||
show(num) {
|
show(num) {
|
||||||
this.num=num
|
this.num=num
|
||||||
this.canChooseNum = num
|
this.canChooseNum = num
|
||||||
|
this.queryParams.fileType = this.fileType
|
||||||
this.getList();
|
this.getList();
|
||||||
this.visible = true;
|
this.visible = true;
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,10 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
<el-form-item label="产品名称" prop="title">
|
<el-form-item label="分类" prop="catgId">
|
||||||
|
<treeselect style="width: 200px" v-model="queryParams.catgId" :options="catgOptions" :normalizer="normalizer" :noResultsText="'暂无数据'" placeholder="选择分类" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="新闻标题" prop="title">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="queryParams.title"
|
v-model="queryParams.title"
|
||||||
placeholder="请输入产品名称"
|
placeholder="请输入新闻标题"
|
||||||
clearable
|
clearable
|
||||||
@keyup.enter.native="handleQuery"
|
@keyup.enter.native="handleQuery"
|
||||||
/>
|
/>
|
||||||
@ -61,17 +64,18 @@
|
|||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<el-table v-loading="loading" :data="prodList" @selection-change="handleSelectionChange" @cell-dblclick="cellClick">
|
<el-table v-loading="loading" :data="prodList" @cell-dblclick="cellClick">
|
||||||
<!-- <el-table-column type="selection" width="55" align="center" />-->
|
<!-- <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 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="catgName" width="120" />
|
||||||
<el-table-column label="产品名称" align="center" prop="title" width="200" />
|
<el-table-column label="新闻标题" align="center" prop="title" width="200" />
|
||||||
<el-table-column label="产品图" align="center" prop="mainPic" width="100">
|
<el-table-column label="新闻图" align="center" prop="mainPic" width="100">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<image-preview :src="scope.row.mainPic" :width="50" :height="50"/>
|
<image-preview :src="scope.row.mainPic" :width="50" :height="50"/>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="产品简介" align="center" prop="description" />
|
<el-table-column label="新闻负责人" align="center" prop="leaderName" />
|
||||||
|
<!-- <el-table-column label="产品简介" align="center" prop="description" />-->
|
||||||
<el-table-column width="100" label="排序" align="center" prop="sort">
|
<el-table-column width="100" label="排序" align="center" prop="sort">
|
||||||
<template slot="header" slot-scope="scope">
|
<template slot="header" slot-scope="scope">
|
||||||
<span>排序</span>
|
<span>排序</span>
|
||||||
@ -104,6 +108,19 @@
|
|||||||
</el-switch>
|
</el-switch>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
<el-table-column width="90" label="随机产品" align="center" prop="randomNum">
|
||||||
|
<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-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 width="120" label="发布人" align="center" prop="userName">
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column width="100" label="创建时间" align="center" prop="createTime">
|
<el-table-column width="100" label="创建时间" align="center" prop="createTime">
|
||||||
@ -116,8 +133,15 @@
|
|||||||
{{scope.row.updateTime | formatDate}}
|
{{scope.row.updateTime | formatDate}}
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column width="140" label="操作" align="center" class-name="small-padding fixed-width">
|
<el-table-column width="200" label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
|
<el-button
|
||||||
|
size="mini"
|
||||||
|
type="text"
|
||||||
|
icon="el-icon-edit"
|
||||||
|
@click="handleAddSimilar(scope.row.id)"
|
||||||
|
v-hasPermi="['busi:new:add']"
|
||||||
|
>添加相似</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
size="mini"
|
size="mini"
|
||||||
type="text"
|
type="text"
|
||||||
@ -125,13 +149,13 @@
|
|||||||
@click="handleUpdate(scope.row)"
|
@click="handleUpdate(scope.row)"
|
||||||
v-hasPermi="['busi:new:edit']"
|
v-hasPermi="['busi:new:edit']"
|
||||||
>修改</el-button>
|
>修改</el-button>
|
||||||
<el-button
|
<el-dropdown size="mini" @command="(command) => handleCommand(command, scope.row)" v-hasPermi="['busi:new:remove', 'busi:relation:add']">
|
||||||
size="mini"
|
<el-button size="mini" type="text" icon="el-icon-d-arrow-right">更多</el-button>
|
||||||
type="text"
|
<el-dropdown-menu slot="dropdown">
|
||||||
icon="el-icon-delete"
|
<el-dropdown-item command="handleDelete" icon="el-icon-delete" v-hasPermi="['busi:new:remove']">删除</el-dropdown-item>
|
||||||
@click="handleDelete(scope.row)"
|
<el-dropdown-item command="handleSetRelation" icon="el-icon-key" v-hasPermi="['busi:relation:add']">分配负责人</el-dropdown-item>
|
||||||
v-hasPermi="['busi:new:remove']"
|
</el-dropdown-menu>
|
||||||
>删除</el-button>
|
</el-dropdown>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
@ -143,21 +167,38 @@
|
|||||||
:limit.sync="queryParams.pageSize"
|
:limit.sync="queryParams.pageSize"
|
||||||
@pagination="getList"
|
@pagination="getList"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<!-- 随机产品管理对话框 -->
|
||||||
|
<random-product ref="randomProduct" @refresh="getList" @ok="handleSuccess" @add="handleAddNewRandom"></random-product>
|
||||||
|
<!-- 选择产品组件-->
|
||||||
|
<select-product ref="selectProduct" :randomProdList="randomProdList" @ok="submitSelect"></select-product>
|
||||||
|
|
||||||
|
<!-- 选择用户组件-->
|
||||||
|
<select-all-user ref="select" @ok="chooseUserFun" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { listProdNew, getProdNew, delProdNew, addProdNew, updateProdNew } from "@/api/busi/new";
|
import { listCategory } from "@/api/busi/category";
|
||||||
|
import { listProdNew, getProdNew, delProdNew, addProdNew,delProdRandom, updateProdNew,listRandomProd,saveRandom } from "@/api/busi/new";
|
||||||
|
import { addRelation } from "@/api/busi/relation";
|
||||||
|
import selectAllUser from "@/views/system/user/selectAllUser";
|
||||||
|
import selectProduct from "@/views/busi/prod/selectProduct";
|
||||||
|
import randomProduct from "@/views/busi/prod/randomProduct";
|
||||||
|
import Treeselect from "@riophae/vue-treeselect";
|
||||||
|
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "New",
|
name: "New",
|
||||||
dicts: ['sys_yes_no'],
|
dicts: ['sys_yes_no'],
|
||||||
|
components: { selectAllUser,selectProduct,randomProduct ,Treeselect},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
// 遮罩层
|
// 遮罩层
|
||||||
loading: true,
|
loading: true,
|
||||||
// 选中数组
|
//栏目分类
|
||||||
ids: [],
|
catgOptions:[],
|
||||||
|
|
||||||
// 非单个禁用
|
// 非单个禁用
|
||||||
single: true,
|
single: true,
|
||||||
// 非多个禁用
|
// 非多个禁用
|
||||||
@ -168,8 +209,6 @@ export default {
|
|||||||
total: 0,
|
total: 0,
|
||||||
// 产品数据
|
// 产品数据
|
||||||
prodList: [],
|
prodList: [],
|
||||||
// 弹出层标题
|
|
||||||
title: "",
|
|
||||||
// 是否显示弹出层
|
// 是否显示弹出层
|
||||||
open: false,
|
open: false,
|
||||||
// 查询参数
|
// 查询参数
|
||||||
@ -180,6 +219,10 @@ export default {
|
|||||||
title: null,
|
title: null,
|
||||||
newsFrom: null,
|
newsFrom: null,
|
||||||
},
|
},
|
||||||
|
//当前操作的数据id
|
||||||
|
nowDealId:"",
|
||||||
|
//当前产品的随机产品数组
|
||||||
|
randomProdList: [],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
filters:{
|
filters:{
|
||||||
@ -201,15 +244,54 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
'$route'(to, from) {
|
||||||
|
if (from.path !== to.path) {
|
||||||
|
// 返回上一页时执行的代码
|
||||||
|
this.getList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.getList();
|
this.getList();
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
// 更多操作触发
|
||||||
|
handleCommand(command, row) {
|
||||||
|
switch (command) {
|
||||||
|
case "handleDelete":
|
||||||
|
this.handleDelete(row)
|
||||||
|
break;
|
||||||
|
case "handleSetRelation":
|
||||||
|
this.handleSetRelation(row);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/** 转换部门数据结构 */
|
||||||
|
normalizer(node) {
|
||||||
|
if (node.children && !node.children.length) {
|
||||||
|
delete node.children;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
id: node.id,
|
||||||
|
label: node.label,
|
||||||
|
children: node.children
|
||||||
|
};
|
||||||
|
},
|
||||||
/** 查询产品、文章列表 */
|
/** 查询产品、文章列表 */
|
||||||
getList() {
|
getList() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
|
//查文章栏目
|
||||||
|
listCategory({catgType:"wz"}).then(response => {
|
||||||
|
response.data.map((item)=>{
|
||||||
|
item.parentId=0
|
||||||
|
})
|
||||||
|
this.catgOptions = response.data
|
||||||
|
});
|
||||||
listProdNew(this.queryParams).then(response => {
|
listProdNew(this.queryParams).then(response => {
|
||||||
this.prodList = response.data.records;
|
this.prodList = response.data.records;
|
||||||
this.total = response.data.total;
|
this.total = response.data.total;
|
||||||
@ -226,16 +308,14 @@ export default {
|
|||||||
this.resetForm("queryForm");
|
this.resetForm("queryForm");
|
||||||
this.handleQuery();
|
this.handleQuery();
|
||||||
},
|
},
|
||||||
// 多选框选中数据
|
|
||||||
handleSelectionChange(selection) {
|
|
||||||
this.ids = selection.map(item => item.id)
|
|
||||||
this.single = selection.length!==1
|
|
||||||
this.multiple = !selection.length
|
|
||||||
},
|
|
||||||
/** 新增按钮操作 */
|
/** 新增按钮操作 */
|
||||||
handleAdd() {
|
handleAdd() {
|
||||||
this.$router.push({path:'/new/newForm'})
|
this.$router.push({path:'/new/newForm'})
|
||||||
},
|
},
|
||||||
|
/** 添加类似操作 */
|
||||||
|
handleAddSimilar(id){
|
||||||
|
this.$router.push({path:'/new/newForm',query:{id:id,type:"similar"}})
|
||||||
|
},
|
||||||
/** 修改按钮操作 */
|
/** 修改按钮操作 */
|
||||||
handleUpdate(row) {
|
handleUpdate(row) {
|
||||||
this.$router.push({path:'/new/newForm',query:{id:row.id}})
|
this.$router.push({path:'/new/newForm',query:{id:row.id}})
|
||||||
@ -254,7 +334,7 @@ export default {
|
|||||||
handleExport() {
|
handleExport() {
|
||||||
this.download('busi/new/export', {
|
this.download('busi/new/export', {
|
||||||
...this.queryParams
|
...this.queryParams
|
||||||
}, `new_${new Date().getTime()}.xlsx`)
|
}, `news_${new Date().getTime()}.xlsx`)
|
||||||
},
|
},
|
||||||
//双击单元格后,显示input,并通过v-focus让input自动获取焦点
|
//双击单元格后,显示input,并通过v-focus让input自动获取焦点
|
||||||
cellClick(row){
|
cellClick(row){
|
||||||
@ -302,6 +382,60 @@ export default {
|
|||||||
this.$modal.msgSuccess('修改成功')
|
this.$modal.msgSuccess('修改成功')
|
||||||
this.getList()
|
this.getList()
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 查看产品随机产品
|
||||||
|
* @param row
|
||||||
|
*/
|
||||||
|
managerRandom(row){
|
||||||
|
this.nowDealId = row.id
|
||||||
|
this.$refs.randomProduct.show(row.id,row.title+"-随机产品")
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 已有随机产品列表回调
|
||||||
|
*/
|
||||||
|
handleSuccess(dataArray){
|
||||||
|
this.randomProdList = dataArray
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 添加随机产品
|
||||||
|
*/
|
||||||
|
handleAddNewRandom(){
|
||||||
|
this.$refs.selectProduct.show(this.nowDealId)
|
||||||
|
},
|
||||||
|
// 确定按钮--新增随机产品
|
||||||
|
submitSelect(ids){
|
||||||
|
let dataObj = {
|
||||||
|
prodId: this.nowDealId,
|
||||||
|
randomIdList: ids
|
||||||
|
}
|
||||||
|
saveRandom(dataObj).then(response => {
|
||||||
|
this.$modal.msgSuccess('新增成功')
|
||||||
|
this.$refs.randomProduct.getRandomList()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 分配负责员工
|
||||||
|
* @param row
|
||||||
|
*/
|
||||||
|
handleSetRelation(row){
|
||||||
|
this.nowDealId = row.id
|
||||||
|
this.$refs.select.show(row.leaderId);
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 确定选中的用户
|
||||||
|
* @param userIds
|
||||||
|
*/
|
||||||
|
chooseUserFun(userIds){
|
||||||
|
let dataObj={
|
||||||
|
prodId:this.nowDealId,
|
||||||
|
leaderId:userIds
|
||||||
|
}
|
||||||
|
addRelation(dataObj).then(response => {
|
||||||
|
this.$modal.msgSuccess('分配成功')
|
||||||
|
this.getList()
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -11,15 +11,15 @@
|
|||||||
<el-form ref="form" :model="form" :rules="rules" label-width="150px">
|
<el-form ref="form" :model="form" :rules="rules" label-width="150px">
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="8">
|
<el-col :span="8">
|
||||||
<el-form-item label="产品名称" prop="title">
|
<el-form-item label="新闻标题" prop="title">
|
||||||
<el-input v-model="form.title" placeholder="请输入产品名称"/>
|
<el-input v-model="form.title" placeholder="请输入新闻标题"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="10">
|
<el-col :span="10">
|
||||||
<el-form-item label="所属分类" prop="catgId">
|
<el-form-item label="所属分类" prop="catgId">
|
||||||
<div class="dl-flex-column">
|
<div class="dl-flex-column">
|
||||||
<el-input v-model="form.catgId" placeholder="请输入产品名称"/>
|
<treeselect style="width: 200px" v-model="form.catgId" :options="catgOptions" :normalizer="normalizer" :noResultsText="'暂无数据'" placeholder="请选择新闻分类" />
|
||||||
<div class="dl-add-catg">添加产品分类</div>
|
<div class="dl-add-catg" @click="goCatgView">添加新闻分类</div>
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
@ -31,15 +31,41 @@
|
|||||||
</el-row>
|
</el-row>
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="8">
|
<el-col :span="8">
|
||||||
<el-form-item label="产品主图" prop="mainPic">
|
<el-form-item label="文章来源" prop="newsFrom">
|
||||||
<el-tag style="cursor: pointer">图片库选择</el-tag>
|
<el-input v-model="form.newsFrom" placeholder="请输入文章来源"/>
|
||||||
<image-upload @uploadedImg="uploadedImg" v-model="form.mainPic" :limit="1"/>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="16">
|
<el-col :span="10">
|
||||||
<el-form-item label="产品图库" prop="pics">
|
<el-form-item label="发布日期" prop="publicDate">
|
||||||
<el-tag style="cursor: pointer">图片库选择</el-tag>
|
<el-date-picker
|
||||||
<image-upload @uploadedImg="uploadedImg" v-model="form.pics" :limit="9"/>
|
v-model="form.publicDate"
|
||||||
|
type="date"
|
||||||
|
placeholder="选择日期">
|
||||||
|
</el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="6">
|
||||||
|
<el-form-item label="首页显示" prop="ifReco">
|
||||||
|
<template v-slot:label>
|
||||||
|
<span>首页显示</span>
|
||||||
|
<el-tooltip class="item" effect="dark" content="开启后将在首页优先显示"
|
||||||
|
placement="bottom"
|
||||||
|
>
|
||||||
|
<i class="el-icon-question"></i>
|
||||||
|
</el-tooltip>
|
||||||
|
</template>
|
||||||
|
<el-switch
|
||||||
|
v-model="form.ifReco"
|
||||||
|
>
|
||||||
|
</el-switch>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="新闻图" prop="mainPic">
|
||||||
|
<el-tag v-if="!form.mainPic" style="cursor: pointer" @click="choosePic('mainPic',1)">图片库选择</el-tag>
|
||||||
|
<image-upload @uploadedImg="uploadedImg" v-model="form.mainPic" :limit="1"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
@ -54,7 +80,7 @@
|
|||||||
<!-- </el-form-item>-->
|
<!-- </el-form-item>-->
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="18">
|
<el-col :span="18">
|
||||||
<el-form-item label="产品简介" prop="description">
|
<el-form-item label="新闻简介" prop="description">
|
||||||
<div class="dl-flex-column">
|
<div class="dl-flex-column">
|
||||||
<el-input style="width: 80%" ref="descriptionInput" v-model="form.description" type="textarea"
|
<el-input style="width: 80%" ref="descriptionInput" v-model="form.description" type="textarea"
|
||||||
placeholder="请输入内容" @blur="handleBlur"
|
placeholder="请输入内容" @blur="handleBlur"
|
||||||
@ -63,16 +89,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</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-row>
|
||||||
<el-form-item label="产品内容">
|
<el-form-item label="新闻内容">
|
||||||
<editor v-model="form.content" :min-height="192"/>
|
<editor v-model="form.content" :min-height="192"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
@ -84,18 +102,34 @@
|
|||||||
<el-button type="primary" @click="submitForm">发 布</el-button>
|
<el-button type="primary" @click="submitForm">发 布</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
|
<select-pic fileType="news" ref="selectPic" @ok="chooseFun" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { listProdNew, getProdNew, delProdNew,getMaxSort, addProdNew, updateProdNew } from '@/api/busi/new'
|
import { listCategory } from "@/api/busi/category";
|
||||||
|
import { listProdNew, getProdNew, delProdNew,getMaxNewSort, addProdNew, updateProdNew } from '@/api/busi/new'
|
||||||
|
import selectPic from "@/views/base/pics/selectPic";
|
||||||
|
|
||||||
|
|
||||||
|
import Treeselect from "@riophae/vue-treeselect";
|
||||||
|
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
||||||
export default {
|
export default {
|
||||||
name: 'newForm',
|
name: 'newForm',
|
||||||
|
components: { Treeselect,selectPic},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
//光标位置--简介
|
//光标位置--简介
|
||||||
cursorPos: null,
|
cursorPos: null,
|
||||||
|
//栏目分类
|
||||||
|
catgOptions:[],
|
||||||
|
//当前选择图片的字段
|
||||||
|
nowChooseStr:null,
|
||||||
|
//图片库数量
|
||||||
|
picsNum:9,
|
||||||
|
//还可以上传图片库的数量
|
||||||
|
canPicsNum:9,
|
||||||
// 表单参数
|
// 表单参数
|
||||||
form: {
|
form: {
|
||||||
id: null,
|
id: null,
|
||||||
@ -105,6 +139,7 @@ export default {
|
|||||||
prodKeyword: null,
|
prodKeyword: null,
|
||||||
prodDescription: null,
|
prodDescription: null,
|
||||||
newsFrom: null,
|
newsFrom: null,
|
||||||
|
publicDate:null,
|
||||||
mainPic: null,
|
mainPic: null,
|
||||||
pics: null,
|
pics: null,
|
||||||
description: null,
|
description: null,
|
||||||
@ -124,46 +159,92 @@ export default {
|
|||||||
// 表单校验
|
// 表单校验
|
||||||
rules: {
|
rules: {
|
||||||
title: [
|
title: [
|
||||||
{ required: true, message: '请输入产品名称', trigger: 'blur' }
|
{ required: true, message: '请输入新闻标题', trigger: 'blur' }
|
||||||
],
|
],
|
||||||
catgId: [
|
catgId: [
|
||||||
{ required: true, message: '请选择产品分类', trigger: 'blur' }
|
{ required: true, message: '请选择所属分类', trigger: 'blur' }
|
||||||
],
|
],
|
||||||
sort: [
|
sort: [
|
||||||
{ required: true, message: '请输入排序', trigger: 'blur' }
|
{ required: true, message: '请输入排序', trigger: 'blur' }
|
||||||
],
|
],
|
||||||
|
newsFrom: [
|
||||||
|
{ required: true, message: '请输入文章来源', trigger: 'blur' }
|
||||||
|
],
|
||||||
|
publicDate: [
|
||||||
|
{ required: true, message: '请选择发布日期', trigger: 'blur' }
|
||||||
|
],
|
||||||
mainPic: [
|
mainPic: [
|
||||||
{ required: true, message: '请上传产品主图', trigger: 'blur' }
|
{ required: true, message: '请上传新闻图', trigger: 'blur' }
|
||||||
],
|
],
|
||||||
description: [
|
description: [
|
||||||
{ required: true, message: '请输入产品简介', trigger: 'blur' }
|
{ required: true, message: '请输入新闻简介', trigger: 'blur' }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
this.initCatg()
|
||||||
if(this.$route.query.id){
|
if(this.$route.query.id){
|
||||||
this.getProdInfo(this.$route.query.id)
|
if(this.$route.query.type){
|
||||||
|
//添加类似
|
||||||
|
this.getProdInfo(this.$route.query.id,this.$route.query.type)
|
||||||
|
}else{
|
||||||
|
//修改
|
||||||
|
this.getProdInfo(this.$route.query.id)
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
this.initData()
|
this.initData()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
goCatgView(){
|
||||||
|
this.$router.push({path:'/busi/category'})
|
||||||
|
},
|
||||||
|
initCatg(){
|
||||||
|
//查产品栏目
|
||||||
|
listCategory({catgType:"wz"}).then(response => {
|
||||||
|
response.data.map((item)=>{
|
||||||
|
item.parentId=0
|
||||||
|
})
|
||||||
|
this.catgOptions = response.data
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 转换树形数据结构 */
|
||||||
|
normalizer(node) {
|
||||||
|
if (node.children && !node.children.length) {
|
||||||
|
delete node.children;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
id: node.id,
|
||||||
|
label: node.label,
|
||||||
|
children: node.children
|
||||||
|
};
|
||||||
|
},
|
||||||
initData(){
|
initData(){
|
||||||
getMaxSort({}).then(response => {
|
getMaxNewSort({}).then(response => {
|
||||||
this.form.sort = response.data
|
this.form.sort = response.data
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
getProdInfo(id){
|
getProdInfo(id,type){
|
||||||
getProdNew(id).then(response => {
|
getProdNew(id).then(response => {
|
||||||
this.form= response.data
|
this.form= response.data
|
||||||
|
if(this.form.pics && this.form.pics.length>0){
|
||||||
|
this.canPicsNum = this.picsNum-this.form.pics.split(",").length
|
||||||
|
}
|
||||||
|
if(type){
|
||||||
|
this.form.id=null
|
||||||
|
this.initData()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* 返回上一页
|
* 返回上一页
|
||||||
*/
|
*/
|
||||||
back() {
|
back() {
|
||||||
history.back()
|
//关闭当前页面
|
||||||
|
this.$store.dispatch("tagsView/delView", this.$route);
|
||||||
|
// 调用全局挂载的方法,关闭当前页
|
||||||
|
this.$router.go(-1)
|
||||||
},
|
},
|
||||||
//图片上传回调
|
//图片上传回调
|
||||||
uploadedImg(fileList){
|
uploadedImg(fileList){
|
||||||
@ -187,6 +268,7 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 暂存 */
|
/** 暂存 */
|
||||||
saveTmp(){
|
saveTmp(){
|
||||||
|
this.form.ifPublic=0
|
||||||
if (this.form.id != null) {
|
if (this.form.id != null) {
|
||||||
updateProdNew(this.form).then(response => {
|
updateProdNew(this.form).then(response => {
|
||||||
this.$modal.msgSuccess('修改成功')
|
this.$modal.msgSuccess('修改成功')
|
||||||
@ -212,11 +294,46 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* 图片库上传
|
||||||
|
*/
|
||||||
|
choosePic(str,num){
|
||||||
|
this.nowChooseStr = str
|
||||||
|
this.$refs.selectPic.show(num)
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 图片库选择图片回调
|
||||||
|
* @param picUrls
|
||||||
|
*/
|
||||||
|
chooseFun(picUrls){
|
||||||
|
if(this.form[this.nowChooseStr]){
|
||||||
|
if(this.form[this.nowChooseStr].length>0){
|
||||||
|
this.form[this.nowChooseStr]+=","+picUrls
|
||||||
|
}else{
|
||||||
|
this.form[this.nowChooseStr] = picUrls
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
this.form[this.nowChooseStr] = picUrls
|
||||||
|
}
|
||||||
|
if(this.nowChooseStr=="pics"){
|
||||||
|
//图片库,计算剩余可上传的图片数量
|
||||||
|
this.listenerPicNum()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 监听图片库数量
|
||||||
|
*/
|
||||||
|
listenerPicNum(){
|
||||||
|
this.canPicsNum = this.picsNum-this.form.pics.split(",").length
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
/deep/.vue-treeselect__input{
|
||||||
|
vertical-align: middle !important;
|
||||||
|
}
|
||||||
.dl-add-catg {
|
.dl-add-catg {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
width: 130px;
|
width: 130px;
|
||||||
|
|||||||
@ -74,7 +74,7 @@
|
|||||||
<image-preview :src="scope.row.mainPic" :width="50" :height="50"/>
|
<image-preview :src="scope.row.mainPic" :width="50" :height="50"/>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="产品负责人" align="center" prop="leaderName" />
|
<el-table-column label="产品负责人" align="center" prop="leaderName" :min-width="200" />
|
||||||
<!-- <el-table-column label="产品简介" align="center" prop="description" />-->
|
<!-- <el-table-column label="产品简介" align="center" prop="description" />-->
|
||||||
<el-table-column width="100" label="排序" align="center" prop="sort">
|
<el-table-column width="100" label="排序" align="center" prop="sort">
|
||||||
<template slot="header" slot-scope="scope">
|
<template slot="header" slot-scope="scope">
|
||||||
@ -169,69 +169,11 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- 随机产品管理对话框 -->
|
<!-- 随机产品管理对话框 -->
|
||||||
<el-dialog :title="title" :visible.sync="randomOpen" width="1000px" append-to-body>
|
<random-product ref="randomProduct" @refresh="getList" @ok="handleSuccess" @add="handleAddNewRandom"></random-product>
|
||||||
<el-row :gutter="10" class="mb8">
|
<!-- 选择产品组件-->
|
||||||
<el-col :span="1.5">
|
<select-product ref="selectProduct" :randomProdList="randomProdList" @ok="submitSelect"></select-product>
|
||||||
<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="handleDeleteRandom(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>
|
|
||||||
|
|
||||||
|
<!-- 选择用户组件-->
|
||||||
<select-all-user ref="select" @ok="chooseUserFun" />
|
<select-all-user ref="select" @ok="chooseUserFun" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -241,23 +183,17 @@ import { listCategory } from "@/api/busi/category";
|
|||||||
import { listProdNew, getProdNew, delProdNew, addProdNew,delProdRandom, updateProdNew,listRandomProd,saveRandom } from "@/api/busi/prod";
|
import { listProdNew, getProdNew, delProdNew, addProdNew,delProdRandom, updateProdNew,listRandomProd,saveRandom } from "@/api/busi/prod";
|
||||||
import { addRelation } from "@/api/busi/relation";
|
import { addRelation } from "@/api/busi/relation";
|
||||||
import selectAllUser from "@/views/system/user/selectAllUser";
|
import selectAllUser from "@/views/system/user/selectAllUser";
|
||||||
|
import selectProduct from "@/views/busi/prod/selectProduct";
|
||||||
|
import randomProduct from "@/views/busi/prod/randomProduct";
|
||||||
import Treeselect from "@riophae/vue-treeselect";
|
import Treeselect from "@riophae/vue-treeselect";
|
||||||
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Prod",
|
name: "Prod",
|
||||||
dicts: ['sys_yes_no'],
|
dicts: ['sys_yes_no'],
|
||||||
components: { selectAllUser ,Treeselect},
|
components: { selectAllUser ,selectProduct,randomProduct,Treeselect},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
// 弹出层标题
|
|
||||||
title: "",
|
|
||||||
// 弹出层标题
|
|
||||||
selectTitle: "添加随机产品",
|
|
||||||
// 是否显示弹出层
|
|
||||||
randomOpen: false,
|
|
||||||
// 是否显示弹出层
|
|
||||||
selectOpen: false,
|
|
||||||
// 遮罩层
|
// 遮罩层
|
||||||
loading: true,
|
loading: true,
|
||||||
//栏目分类
|
//栏目分类
|
||||||
@ -286,32 +222,10 @@ export default {
|
|||||||
|
|
||||||
//当前操作的数据id
|
//当前操作的数据id
|
||||||
nowDealId:"",
|
nowDealId:"",
|
||||||
// 遮罩层
|
|
||||||
randomLoading: true,
|
|
||||||
//当前产品的随机产品数组
|
//当前产品的随机产品数组
|
||||||
randomProdList: [],
|
randomProdList: [],
|
||||||
// 每个产品最多管理10个产品
|
|
||||||
randomMax:10,
|
|
||||||
|
|
||||||
// 遮罩层
|
|
||||||
selectLoading:true,
|
|
||||||
//待选择的产品数组
|
|
||||||
selectProdList: [],
|
|
||||||
// 选中数组
|
|
||||||
ids: [],
|
|
||||||
// 总条数
|
|
||||||
selectTotal: 0,
|
|
||||||
// 查询参数
|
|
||||||
selectQueryParams: {
|
|
||||||
pageNum: 1,
|
|
||||||
pageSize: 10,
|
|
||||||
//需要排除的产品id,多个英文逗号隔开
|
|
||||||
excludeProdId:null,
|
|
||||||
//查已发布的
|
|
||||||
ifPublic: true,
|
|
||||||
catgId: null,
|
|
||||||
title: null,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
filters:{
|
filters:{
|
||||||
@ -397,18 +311,7 @@ export default {
|
|||||||
this.resetForm("queryForm");
|
this.resetForm("queryForm");
|
||||||
this.handleQuery();
|
this.handleQuery();
|
||||||
},
|
},
|
||||||
// 多选框选中数据
|
|
||||||
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
|
|
||||||
},
|
|
||||||
/** 新增按钮操作 */
|
/** 新增按钮操作 */
|
||||||
handleAdd() {
|
handleAdd() {
|
||||||
this.$router.push({path:'/product/prodForm'})
|
this.$router.push({path:'/product/prodForm'})
|
||||||
@ -486,82 +389,39 @@ export default {
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* 查看产品随机产品
|
* 查看产品随机产品
|
||||||
* @param id
|
* @param row
|
||||||
*/
|
*/
|
||||||
managerRandom(row){
|
managerRandom(row){
|
||||||
this.getRandomList(row.id)
|
|
||||||
this.title=row.title+"-随机产品"
|
|
||||||
this.nowDealId = row.id
|
this.nowDealId = row.id
|
||||||
this.randomOpen = true;
|
this.$refs.randomProduct.show(row.id,row.title+"-随机产品")
|
||||||
},
|
},
|
||||||
/** 查询管理产品列表 */
|
/**
|
||||||
getRandomList(prodId) {
|
* 已有随机产品列表回调
|
||||||
if(!prodId){
|
*/
|
||||||
prodId = this.nowDealId
|
handleSuccess(dataArray){
|
||||||
}
|
this.randomProdList = dataArray
|
||||||
this.randomLoading = true;
|
|
||||||
listRandomProd({prodId:prodId}).then(response => {
|
|
||||||
this.randomProdList = response.data;
|
|
||||||
this.randomLoading = false;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
// 取消按钮--修改随机产品
|
|
||||||
cancelRandom() {
|
|
||||||
this.getList()
|
|
||||||
this.randomOpen = false;
|
|
||||||
},
|
|
||||||
// 删除随机产品
|
|
||||||
handleDeleteRandom(row){
|
|
||||||
let data = {
|
|
||||||
prodId:this.nowDealId,
|
|
||||||
randomId:row.id
|
|
||||||
}
|
|
||||||
this.$modal.confirm('是否确认删除关联的随机产品?').then(function() {
|
|
||||||
return delProdRandom(data);
|
|
||||||
}).then(() => {
|
|
||||||
this.getRandomList()
|
|
||||||
this.getList()
|
|
||||||
this.$modal.msgSuccess("删除成功");
|
|
||||||
this.randomOpen = false;
|
|
||||||
}).catch(() => {});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加随机产品
|
* 添加随机产品--打开选择产品的弹出框
|
||||||
*/
|
*/
|
||||||
handleAddNewRandom(){
|
handleAddNewRandom(){
|
||||||
this.selectOpen=true
|
this.$refs.selectProduct.show(this.nowDealId)
|
||||||
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(){
|
submitSelect(ids) {
|
||||||
this.selectOpen = false;
|
let dataObj = {
|
||||||
if(this.ids.length>0){
|
prodId: this.nowDealId,
|
||||||
let dataObj={
|
randomIdList: ids
|
||||||
prodId:this.nowDealId,
|
|
||||||
randomIdList:this.ids
|
|
||||||
}
|
|
||||||
saveRandom(dataObj).then(response => {
|
|
||||||
this.$modal.msgSuccess('新增成功')
|
|
||||||
this.getRandomList()
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
saveRandom(dataObj).then(response => {
|
||||||
|
this.$modal.msgSuccess('新增成功')
|
||||||
|
this.$refs.randomProduct.getRandomList()
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分配负责员工
|
* 分配负责员工
|
||||||
* @param row
|
* @param row
|
||||||
|
|||||||
@ -93,7 +93,7 @@
|
|||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<select-pic ref="selectPic" @ok="chooseFun" />
|
<select-pic fileType="product" ref="selectPic" @ok="chooseFun" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -168,9 +168,9 @@ export default {
|
|||||||
mounted() {
|
mounted() {
|
||||||
this.initCatg()
|
this.initCatg()
|
||||||
if(this.$route.query.id){
|
if(this.$route.query.id){
|
||||||
if(this.$route.query.similar){
|
if(this.$route.query.type){
|
||||||
//添加类似
|
//添加类似
|
||||||
this.getProdInfo(this.$route.query.id,this.$route.query.similar)
|
this.getProdInfo(this.$route.query.id,this.$route.query.type)
|
||||||
}else{
|
}else{
|
||||||
//修改
|
//修改
|
||||||
this.getProdInfo(this.$route.query.id)
|
this.getProdInfo(this.$route.query.id)
|
||||||
@ -208,13 +208,13 @@ export default {
|
|||||||
this.form.sort = response.data
|
this.form.sort = response.data
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
getProdInfo(id,similar){
|
getProdInfo(id,type){
|
||||||
getProdNew(id).then(response => {
|
getProdNew(id).then(response => {
|
||||||
this.form= response.data
|
this.form= response.data
|
||||||
if(this.form.pics && this.form.pics.length>0){
|
if(this.form.pics && this.form.pics.length>0){
|
||||||
this.canPicsNum = this.picsNum-this.form.pics.split(",").length
|
this.canPicsNum = this.picsNum-this.form.pics.split(",").length
|
||||||
}
|
}
|
||||||
if(similar){
|
if(type){
|
||||||
this.form.id=null
|
this.form.id=null
|
||||||
this.initData()
|
this.initData()
|
||||||
}
|
}
|
||||||
|
|||||||
111
dl_vue/src/views/busi/prod/randomProduct.vue
Normal file
111
dl_vue/src/views/busi/prod/randomProduct.vue
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
<template>
|
||||||
|
<!-- 当前产品的随机产品对话框 -->
|
||||||
|
<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="handleDeleteRandom(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>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { listProdNew, getProdNew, delProdNew, addProdNew,delProdRandom, updateProdNew,listRandomProd,saveRandom } from "@/api/busi/prod";
|
||||||
|
export default {
|
||||||
|
name: 'randomProduct',
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
// 弹出层标题
|
||||||
|
title: "",
|
||||||
|
// 是否显示弹出层
|
||||||
|
randomOpen: false,
|
||||||
|
// 遮罩层
|
||||||
|
randomLoading: true,
|
||||||
|
//当前操作的数据id
|
||||||
|
nowDealId:"",
|
||||||
|
//当前产品的随机产品数组
|
||||||
|
randomProdList:[]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
},
|
||||||
|
methods:{
|
||||||
|
/**
|
||||||
|
* 组件显示
|
||||||
|
*/
|
||||||
|
show(nowDealId,title){
|
||||||
|
this.randomOpen=true
|
||||||
|
this.nowDealId = nowDealId
|
||||||
|
this.title = title?title:"随机产品列表"
|
||||||
|
this.getRandomList()
|
||||||
|
},
|
||||||
|
// 删除随机产品
|
||||||
|
handleDeleteRandom(row){
|
||||||
|
let data = {
|
||||||
|
prodId:this.nowDealId,
|
||||||
|
randomId:row.id
|
||||||
|
}
|
||||||
|
this.$modal.confirm('是否确认删除关联的随机产品?').then(function() {
|
||||||
|
return delProdRandom(data);
|
||||||
|
}).then(() => {
|
||||||
|
this.$modal.msgSuccess("删除成功");
|
||||||
|
this.$emit("refresh")
|
||||||
|
this.getRandomList()
|
||||||
|
}).catch(() => {});
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 添加随机产品
|
||||||
|
*/
|
||||||
|
handleAddNewRandom(){
|
||||||
|
this.$emit("add")
|
||||||
|
},
|
||||||
|
// 取消按钮
|
||||||
|
cancelRandom() {
|
||||||
|
this.randomOpen = false;
|
||||||
|
this.$emit("refresh")
|
||||||
|
},
|
||||||
|
/** 查询管理产品列表 */
|
||||||
|
getRandomList() {
|
||||||
|
this.randomLoading = true;
|
||||||
|
listRandomProd({prodId:this.nowDealId}).then(response => {
|
||||||
|
this.randomProdList = response.data;
|
||||||
|
this.randomLoading = false;
|
||||||
|
this.$emit("ok",this.randomProdList)
|
||||||
|
});
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
||||||
125
dl_vue/src/views/busi/prod/selectProduct.vue
Normal file
125
dl_vue/src/views/busi/prod/selectProduct.vue
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
<template>
|
||||||
|
<!-- 选择产品对话框 -->
|
||||||
|
<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="loadData"
|
||||||
|
/>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="submitSelect">确 定</el-button>
|
||||||
|
<el-button @click="cancelSelect">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { listProdNew, getProdNew, delProdNew, addProdNew,delProdRandom, updateProdNew,listRandomProd,saveRandom } from "@/api/busi/prod";
|
||||||
|
export default {
|
||||||
|
name: 'selectProduct',
|
||||||
|
props: {
|
||||||
|
//当前产品的随机产品数组
|
||||||
|
randomProdList: {
|
||||||
|
type: Array,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
// 弹出层标题
|
||||||
|
selectTitle: "",
|
||||||
|
// 是否显示弹出层
|
||||||
|
selectOpen: false,
|
||||||
|
// 遮罩层
|
||||||
|
selectLoading:true,
|
||||||
|
//待选择的产品数组
|
||||||
|
selectProdList: [],
|
||||||
|
// 选中数组
|
||||||
|
ids: [],
|
||||||
|
// 总条数
|
||||||
|
selectTotal: 0,
|
||||||
|
// 查询参数
|
||||||
|
selectQueryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
//需要排除的产品id,多个英文逗号隔开
|
||||||
|
excludeProdId:null,
|
||||||
|
//查已发布的
|
||||||
|
ifPublic: true,
|
||||||
|
catgId: null,
|
||||||
|
title: null,
|
||||||
|
},
|
||||||
|
// 每个产品最多管理10个产品
|
||||||
|
randomMax:10,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
},
|
||||||
|
methods:{
|
||||||
|
/**
|
||||||
|
* 组件显示
|
||||||
|
*/
|
||||||
|
show(nowDealId,title){
|
||||||
|
this.selectTitle = title?title:"产品列表"
|
||||||
|
this.selectOpen=true
|
||||||
|
this.selectLoading = true;
|
||||||
|
//需要排除掉的产品id
|
||||||
|
let excludeProdId = nowDealId
|
||||||
|
if(this.randomProdList && this.randomProdList.length>0){
|
||||||
|
excludeProdId =excludeProdId+","+this.randomProdList.map(item => item.id).join(', ');
|
||||||
|
}
|
||||||
|
this.selectQueryParams.excludeProdId = excludeProdId
|
||||||
|
this.loadData()
|
||||||
|
},
|
||||||
|
// 多选框选中数据
|
||||||
|
handleSelectionChange(selection) {
|
||||||
|
if(selection.length+this.randomProdList.length>this.randomMax){
|
||||||
|
//新选择的+已选择的数量已经大于最大可关联的产品数量
|
||||||
|
this.$modal.msgWarning("请注意,每个产品最多可关联"+this.randomMax+"个随机产品,超出的产品不再追加!");
|
||||||
|
selection = selection.slice(0, (this.randomMax-this.randomProdList.length));
|
||||||
|
}
|
||||||
|
console.log(selection,"selection")
|
||||||
|
this.ids = selection.map(item => item.id)
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 加载数据
|
||||||
|
*/
|
||||||
|
loadData(){
|
||||||
|
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){
|
||||||
|
this.$modal.msgError("请选择产品");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$emit("ok",this.ids)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
||||||
Loading…
Reference in New Issue
Block a user