产品、新闻完成

This commit is contained in:
Vinjor 2025-07-01 17:30:19 +08:00
parent 702ccbc768
commit cf5fd216fe
16 changed files with 711 additions and 264 deletions

View File

@ -4,8 +4,11 @@ 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.domain.BusiProdRandom;
import com.ruoyi.busi.service.IBusiProdNewService;
import com.ruoyi.busi.service.IBusiProdRandomService;
import com.ruoyi.busi.vo.ProdNewVO;
import com.ruoyi.busi.vo.ProdRandomVO;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
@ -20,10 +23,10 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static com.ruoyi.constant.DictConstants.FILE_TYPE_PRODUCT;
import static com.ruoyi.constant.DictConstants.*;
/**
* 产品Controller
* 新闻Controller
*
* @author vinjor-m
* @date 2025-06-25
@ -36,9 +39,11 @@ public class BusiNewController extends BaseController
private IBusiProdNewService busiProdNewService;
@Autowired
private IBasePicsService basePicsService;
@Autowired
private IBusiProdRandomService prodRandomService;
/**
* 查询产品列表
* 查询新闻列表
*/
@PreAuthorize("@ss.hasPermi('busi:new:list')")
@GetMapping("/list")
@ -47,25 +52,39 @@ public class BusiNewController extends BaseController
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize)
{
Page<BusiProdNew> page = new Page<>(pageNum, pageSize);
//只查新闻
busiProdNew.setDataType(DATA_TYPE_NEWS);
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));
}
/**
* 导出新闻列表
*/
@PreAuthorize("@ss.hasPermi('busi:new:export')")
@Log(title = "产品", businessType = BusinessType.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, "产品、文章数据");
util.exportExcel(response, list, "文章数据");
}
/**
* 获取产品详细信息
* 获取新闻详细信息
*/
@PreAuthorize("@ss.hasPermi('busi:new:query')")
@GetMapping(value = "/{id}")
@ -75,56 +94,95 @@ public class BusiNewController extends BaseController
}
/**
* 获取产品表当前最大排序
* 获取新闻表当前最大排序
*/
@GetMapping(value = "/getMaxSort")
public AjaxResult getMaxSort(String tenantId)
{
return success(busiProdNewService.getMaxSort(tenantId));
return success(busiProdNewService.getMaxSort(tenantId,DATA_TYPE_NEWS));
}
/**
* 新增产品
* 新增新闻
*/
@PreAuthorize("@ss.hasPermi('busi:new:add')")
@Log(title = "产品", businessType = BusinessType.INSERT)
@Log(title = "新闻", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody ProdNewVO prodNewVO){
prodNewVO.setDataType(DATA_TYPE_NEWS);
busiProdNewService.save(prodNewVO);
if(null!=prodNewVO.getFileList() && !prodNewVO.getFileList().isEmpty()){
prodNewVO.getFileList().forEach(item->{
item.setTenantId(prodNewVO.getTenantId());
item.setFileType(FILE_TYPE_PRODUCT);
item.setFileType(FILE_TYPE_NEWS);
});
}
busiProdNewService.setAmount(prodNewVO.getTenantId());
return success();
}
/**
* 修改产品
* 修改新闻
*/
@PreAuthorize("@ss.hasPermi('busi:new:edit')")
@Log(title = "产品", businessType = BusinessType.UPDATE)
@Log(title = "新闻", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody ProdNewVO prodNewVO){
prodNewVO.setDataType(DATA_TYPE_NEWS);
busiProdNewService.updateById(prodNewVO);
if(null!=prodNewVO.getFileList() && !prodNewVO.getFileList().isEmpty()){
prodNewVO.getFileList().forEach(item->{
item.setTenantId(prodNewVO.getTenantId());
item.setFileType(FILE_TYPE_PRODUCT);
item.setFileType(FILE_TYPE_NEWS);
});
}
return success();
}
/**
* 删除产品
* 删除新闻
*/
@PreAuthorize("@ss.hasPermi('busi:new:remove')")
@Log(title = "产品", businessType = BusinessType.DELETE)
@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));
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();
}
}

View File

@ -31,8 +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;
import static com.ruoyi.constant.DictConstants.*;
/**
* 产品Controller
@ -108,7 +107,7 @@ public class BusiProdController extends BaseController
@GetMapping(value = "/getMaxSort")
public AjaxResult getMaxSort(String tenantId)
{
return success(busiProdNewService.getMaxSort(tenantId));
return success(busiProdNewService.getMaxSort(tenantId,DATA_TYPE_PRODUCT));
}
/**

View File

@ -7,6 +7,8 @@ import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
import com.ruoyi.common.core.domain.DlBaseEntity;
import java.util.Date;
/**
* 产品文章对象 dl_busi_prod_new
*
@ -55,6 +57,9 @@ public class BusiProdNew extends DlBaseEntity
/** 文章来源 */
@Excel(name = "文章来源")
private String newsFrom;
/** 文章发布日期 */
@Excel(name = "文章发布日期")
private Date publicDate;
/** 产品主图或文章图片 */
@Excel(name = "产品主图或文章图片")

View File

@ -20,7 +20,7 @@ public interface BusiProdNewMapper extends BaseMapper<BusiProdNew>
{
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);
/**
* 统计分类下产品数量

View File

@ -24,7 +24,7 @@ public interface IBusiProdNewService extends IService<BusiProdNew>
* @param tenantId 站点id
* @return java.lang.Long
**/
Long getMaxSort(String tenantId);
Long getMaxSort(String tenantId,String dataType);
/**

View File

@ -49,8 +49,8 @@ public class BusiProdNewServiceImpl extends ServiceImpl<BusiProdNewMapper,BusiPr
* @date 16:15 2025/6/25
**/
@Override
public Long getMaxSort(String tenantId) {
Long sort = busiProdNewMapper.selectMaxSort(tenantId);
public Long getMaxSort(String tenantId,String dataType) {
Long sort = busiProdNewMapper.selectMaxSort(tenantId,dataType);
return null==sort?1:sort+1;
}

View File

@ -12,6 +12,7 @@
<result property="prodKeyword" column="prod_keyword"/>
<result property="prodDescription" column="prod_description"/>
<result property="newsFrom" column="news_from"/>
<result property="publicDate" column="public_date"/>
<result property="mainPic" column="main_pic"/>
<result property="pics" column="pics"/>
<result property="description" column="description"/>
@ -42,6 +43,7 @@
prod_keyword,
prod_description,
news_from,
public_date,
main_pic,
pics,
description,
@ -117,6 +119,7 @@
WHERE
del_flag = '0'
AND tenant_id = #{tenantId}
AND data_type=#{dataType}
</select>
<select id="getCatgAmount" resultType="com.ruoyi.busi.vo.ProdNewVO">
SELECT

View File

@ -30,10 +30,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectRandomList" resultType="com.ruoyi.busi.vo.ProdNewVO">
SELECT
dbpn.*
dbpn.*,
dbc.catg_name AS catgName
FROM
dl_busi_prod_random dbpr
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
dbpr.prod_id = #{map.prodId}
AND dbpr.tenant_id =#{map.tenantId}

View File

@ -1,6 +1,6 @@
import request from '@/utils/request'
// 查询产品、文章列表
// 查询文章列表
export function listProdNew(query) {
return request({
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({
url: '/busi/new/getMaxSort',
method: 'get',
@ -18,7 +27,7 @@ export function getMaxSort(query) {
})
}
// 查询产品、文章详细
// 查询文章详细
export function getProdNew(id) {
return request({
url: '/busi/new/' + id,
@ -26,7 +35,7 @@ export function getProdNew(id) {
})
}
// 新增产品、文章
// 新增文章
export function addProdNew(data) {
return request({
url: '/busi/new',
@ -35,7 +44,7 @@ export function addProdNew(data) {
})
}
// 修改产品、文章
// 修改文章
export function updateProdNew(data) {
return request({
url: '/busi/new',
@ -44,10 +53,28 @@ export function updateProdNew(data) {
})
}
// 删除产品、文章
// 删除文章
export function delProdNew(id) {
return request({
url: '/busi/new/' + id,
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
})
}

View File

@ -69,6 +69,11 @@ import { listPics} from "@/api/base/pics";
export default {
dicts: ['file_type'],
props: {
//
fileType: {
type: String,
default: null,
},
},
data() {
return {
@ -97,6 +102,7 @@ export default {
show(num) {
this.num=num
this.canChooseNum = num
this.queryParams.fileType = this.fileType
this.getList();
this.visible = true;
},

View File

@ -1,10 +1,13 @@
<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-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
v-model="queryParams.title"
placeholder="请输入产品名称"
placeholder="请输入新闻标题"
clearable
@keyup.enter.native="handleQuery"
/>
@ -61,17 +64,18 @@
<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 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" width="120" />
<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="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 label="新闻负责人" align="center" prop="leaderName" />
<!-- <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>
@ -104,6 +108,19 @@
</el-switch>
</template>
</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>
<el-table-column width="100" label="创建时间" align="center" prop="createTime">
@ -116,8 +133,15 @@
{{scope.row.updateTime | formatDate}}
</template>
</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">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleAddSimilar(scope.row.id)"
v-hasPermi="['busi:new:add']"
>添加相似</el-button>
<el-button
size="mini"
type="text"
@ -125,13 +149,13 @@
@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>
<el-dropdown size="mini" @command="(command) => handleCommand(command, scope.row)" v-hasPermi="['busi:new:remove', 'busi:relation:add']">
<el-button size="mini" type="text" icon="el-icon-d-arrow-right">更多</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="handleDelete" icon="el-icon-delete" v-hasPermi="['busi:new:remove']">删除</el-dropdown-item>
<el-dropdown-item command="handleSetRelation" icon="el-icon-key" v-hasPermi="['busi:relation:add']">分配负责人</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
</el-table-column>
</el-table>
@ -143,21 +167,38 @@
:limit.sync="queryParams.pageSize"
@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>
</template>
<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 {
name: "New",
dicts: ['sys_yes_no'],
components: { selectAllUser,selectProduct,randomProduct ,Treeselect},
data() {
return {
//
loading: true,
//
ids: [],
//
catgOptions:[],
//
single: true,
//
@ -168,8 +209,6 @@ export default {
total: 0,
//
prodList: [],
//
title: "",
//
open: false,
//
@ -180,6 +219,10 @@ export default {
title: null,
newsFrom: null,
},
//id
nowDealId:"",
//
randomProdList: [],
};
},
filters:{
@ -201,15 +244,54 @@ export default {
}
}
},
watch: {
'$route'(to, from) {
if (from.path !== to.path) {
//
this.getList();
}
}
},
mounted() {
this.getList();
},
created() {
},
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() {
this.loading = true;
//
listCategory({catgType:"wz"}).then(response => {
response.data.map((item)=>{
item.parentId=0
})
this.catgOptions = response.data
});
listProdNew(this.queryParams).then(response => {
this.prodList = response.data.records;
this.total = response.data.total;
@ -226,16 +308,14 @@ export default {
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'})
},
/** 添加类似操作 */
handleAddSimilar(id){
this.$router.push({path:'/new/newForm',query:{id:id,type:"similar"}})
},
/** 修改按钮操作 */
handleUpdate(row) {
this.$router.push({path:'/new/newForm',query:{id:row.id}})
@ -254,7 +334,7 @@ export default {
handleExport() {
this.download('busi/new/export', {
...this.queryParams
}, `new_${new Date().getTime()}.xlsx`)
}, `news_${new Date().getTime()}.xlsx`)
},
//inputv-focusinput
cellClick(row){
@ -302,6 +382,60 @@ export default {
this.$modal.msgSuccess('修改成功')
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()
})
}
}
};

View File

@ -11,15 +11,15 @@
<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 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>
<treeselect style="width: 200px" v-model="form.catgId" :options="catgOptions" :normalizer="normalizer" :noResultsText="'暂无数据'" placeholder="请选择新闻分类" />
<div class="dl-add-catg" @click="goCatgView">添加新闻分类</div>
</div>
</el-form-item>
</el-col>
@ -31,15 +31,41 @@
</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 label="文章来源" prop="newsFrom">
<el-input v-model="form.newsFrom" placeholder="请输入文章来源"/>
</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-col :span="10">
<el-form-item label="发布日期" prop="publicDate">
<el-date-picker
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-col>
</el-row>
@ -54,7 +80,7 @@
<!-- </el-form-item>-->
<el-row>
<el-col :span="18">
<el-form-item label="产品简介" prop="description">
<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"
@ -63,16 +89,8 @@
</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="产品内容">
<el-form-item label="新闻内容">
<editor v-model="form.content" :min-height="192"/>
</el-form-item>
</el-form>
@ -84,18 +102,34 @@
<el-button type="primary" @click="submitForm"> </el-button>
</el-col>
</el-row>
<select-pic fileType="news" ref="selectPic" @ok="chooseFun" />
</div>
</template>
<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 {
name: 'newForm',
components: { Treeselect,selectPic},
data() {
return {
//--
cursorPos: null,
//
catgOptions:[],
//
nowChooseStr:null,
//
picsNum:9,
//
canPicsNum:9,
//
form: {
id: null,
@ -105,6 +139,7 @@ export default {
prodKeyword: null,
prodDescription: null,
newsFrom: null,
publicDate:null,
mainPic: null,
pics: null,
description: null,
@ -124,46 +159,92 @@ export default {
//
rules: {
title: [
{ required: true, message: '请输入产品名称', trigger: 'blur' }
{ required: true, message: '请输入新闻标题', trigger: 'blur' }
],
catgId: [
{ required: true, message: '请选择产品分类', trigger: 'blur' }
{ required: true, message: '请选择所属分类', trigger: 'blur' }
],
sort: [
{ required: true, message: '请输入排序', trigger: 'blur' }
],
newsFrom: [
{ required: true, message: '请输入文章来源', trigger: 'blur' }
],
publicDate: [
{ required: true, message: '请选择发布日期', trigger: 'blur' }
],
mainPic: [
{ required: true, message: '请上传产品主图', trigger: 'blur' }
{ required: true, message: '请上传新闻图', trigger: 'blur' }
],
description: [
{ required: true, message: '请输入产品简介', trigger: 'blur' }
{ required: true, message: '请输入新闻简介', trigger: 'blur' }
]
}
}
},
mounted() {
this.initCatg()
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{
this.initData()
}
},
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(){
getMaxSort({}).then(response => {
getMaxNewSort({}).then(response => {
this.form.sort = response.data
})
},
getProdInfo(id){
getProdInfo(id,type){
getProdNew(id).then(response => {
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() {
history.back()
//
this.$store.dispatch("tagsView/delView", this.$route);
//
this.$router.go(-1)
},
//
uploadedImg(fileList){
@ -187,6 +268,7 @@ export default {
},
/** 暂存 */
saveTmp(){
this.form.ifPublic=0
if (this.form.id != null) {
updateProdNew(this.form).then(response => {
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>
<style scoped>
/deep/.vue-treeselect__input{
vertical-align: middle !important;
}
.dl-add-catg {
cursor: pointer;
width: 130px;

View File

@ -74,7 +74,7 @@
<image-preview :src="scope.row.mainPic" :width="50" :height="50"/>
</template>
</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 width="100" label="排序" align="center" prop="sort">
<template slot="header" slot-scope="scope">
@ -169,69 +169,11 @@
/>
<!-- 随机产品管理对话框 -->
<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>
<!-- 选择产品对话框 -->
<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>
<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>
</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 { 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 {
name: "Prod",
dicts: ['sys_yes_no'],
components: { selectAllUser ,Treeselect},
components: { selectAllUser ,selectProduct,randomProduct,Treeselect},
data() {
return {
//
title: "",
//
selectTitle: "添加随机产品",
//
randomOpen: false,
//
selectOpen: false,
//
loading: true,
//
@ -286,32 +222,10 @@ export default {
//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,
},
};
},
filters:{
@ -397,18 +311,7 @@ export default {
this.resetForm("queryForm");
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() {
this.$router.push({path:'/product/prodForm'})
@ -486,82 +389,39 @@ export default {
},
/**
* 查看产品随机产品
* @param id
* @param row
*/
managerRandom(row){
this.getRandomList(row.id)
this.title=row.title+"-随机产品"
this.nowDealId = row.id
this.randomOpen = true;
this.$refs.randomProduct.show(row.id,row.title+"-随机产品")
},
/** 查询管理产品列表 */
getRandomList(prodId) {
if(!prodId){
prodId = this.nowDealId
}
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(() => {});
/**
* 已有随机产品列表回调
*/
handleSuccess(dataArray){
this.randomProdList = dataArray
},
/**
* 添加随机产品
* 添加随机产品--打开选择产品的弹出框
*/
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;
this.$refs.selectProduct.show(this.nowDealId)
},
// --
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()
})
submitSelect(ids) {
let dataObj = {
prodId: this.nowDealId,
randomIdList: ids
}
saveRandom(dataObj).then(response => {
this.$modal.msgSuccess('新增成功')
this.$refs.randomProduct.getRandomList()
})
},
/**
* 分配负责员工
* @param row

View File

@ -93,7 +93,7 @@
</el-col>
</el-row>
<select-pic ref="selectPic" @ok="chooseFun" />
<select-pic fileType="product" ref="selectPic" @ok="chooseFun" />
</div>
</template>
@ -168,9 +168,9 @@ export default {
mounted() {
this.initCatg()
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{
//
this.getProdInfo(this.$route.query.id)
@ -208,13 +208,13 @@ export default {
this.form.sort = response.data
})
},
getProdInfo(id,similar){
getProdInfo(id,type){
getProdNew(id).then(response => {
this.form= response.data
if(this.form.pics && this.form.pics.length>0){
this.canPicsNum = this.picsNum-this.form.pics.split(",").length
}
if(similar){
if(type){
this.form.id=null
this.initData()
}

View 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>

View 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>