Browse Source

处理bug

master
前端-胡立永 1 month ago
parent
commit
52a1ba607b
4 changed files with 568 additions and 13 deletions
  1. +393
    -0
      admin-pc/src/views/book/comment/CommonBookCommentList.vue
  2. +162
    -0
      admin-pc/src/views/book/comment/modules/CommonBookCommentModal.vue
  3. +12
    -12
      module-common/src/main/java/org/jeecg/modules/commonBookComment/vue/modules/CommonBookCommentModal.vue
  4. +1
    -1
      module-system/src/main/resources/application-dev.yml

+ 393
- 0
admin-pc/src/views/book/comment/CommonBookCommentList.vue View File

@ -0,0 +1,393 @@
<template>
<a-card :bordered="false">
<!-- 查询区域 -->
<div class="table-page-search-wrapper">
<a-form layout="inline" @keyup.enter.native="searchQuery">
<a-row :gutter="24">
<a-col :xl="6" :lg="7" :md="8" :sm="24">
<a-form-item label="书名">
<j-search-select-tag placeholder="请选择书名" v-model="queryParam.bookId" dict="common_shop,name,id"/>
</a-form-item>
</a-col>
<a-col :xl="6" :lg="7" :md="8" :sm="24">
<a-form-item label="用户">
<j-search-select-tag placeholder="请选择用户" v-model="queryParam.userId" dict="han_hai_member,nick_name,id"/>
</a-form-item>
</a-col>
<a-col :xl="6" :lg="7" :md="8" :sm="24">
<span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
<a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
<a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
<a @click="handleToggleSearch" style="margin-left: 8px">
{{ toggleSearchStatus ? '收起' : '展开' }}
<a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
</a>
</span>
</a-col>
</a-row>
</a-form>
</div>
<!-- 查询区域-END -->
<!-- 操作按钮区域 -->
<div class="table-operator">
<a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
<!-- <a-button type="primary" icon="download" @click="handleExportXls('书评管理')">导出</a-button>-->
<!-- <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">-->
<!-- <a-button type="primary" icon="import">导入</a-button>-->
<!-- </a-upload>-->
<!-- 高级查询区域 -->
<!-- <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>-->
<a-dropdown v-if="selectedRowKeys.length > 0">
<a-menu slot="overlay">
<a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
</a-menu>
<a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
</a-dropdown>
</div>
<!-- table区域-begin -->
<div>
<div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
<i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>
<a style="margin-left: 24px" @click="onClearSelected">清空</a>
</div>
<a-table
ref="table"
size="middle"
rowKey="id"
class="j-table-force-nowrap"
:scroll="{x:true}"
:columns="columns"
:dataSource="dataSource"
:pagination="ipagination"
:loading="loading"
:expandedRowKeys="expandedRowKeys"
@change="handleTableChange"
@expand="handleExpand"
v-bind="tableProps">
<template slot="imgSlot" slot-scope="text,record">
<span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
<img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
</template>
<template slot="fileSlot" slot-scope="text">
<span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
<a-button
v-else
:ghost="true"
type="primary"
icon="download"
size="small"
@click="downloadFile(text)">
下载
</a-button>
</template>
<span slot="action" slot-scope="text, record">
<a @click="handleEdit(record)">编辑</a>
<a-divider type="vertical" />
<a-dropdown>
<a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
<a-menu slot="overlay">
<!-- <a-menu-item>-->
<!-- <a @click="handleAddChild(record)">添加下级</a>-->
<!-- </a-menu-item>-->
<a-menu-item>
<a-popconfirm title="确定删除吗?" @confirm="() => handleDeleteNode(record.id)" placement="topLeft">
<a>删除</a>
</a-popconfirm>
</a-menu-item>
</a-menu>
</a-dropdown>
</span>
</a-table>
</div>
<commonBookComment-modal ref="modalForm" @ok="modalFormOk"></commonBookComment-modal>
</a-card>
</template>
<script>
import { getAction, deleteAction } from '@/api/manage'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import CommonBookCommentModal from './modules/CommonBookCommentModal'
import {filterMultiDictText} from '@/components/dict/JDictSelectUtil'
import { filterObj } from '@/utils/util';
export default {
name: "CommonBookCommentList",
mixins:[JeecgListMixin],
components: {
CommonBookCommentModal
},
data () {
return {
description: '书评管理管理页面',
//
columns: [
{
title:'创建日期',
align:"left",
sorter: true,
dataIndex: 'createTime'
},
{
title:'是否已读',
align:"left",
dataIndex: 'isLook',
customRender: (text) => (!text ? "" : (text == "Y" ? "是" : "否"))
},
{
title:'书名',
align:"left",
dataIndex: 'bookId_dictText'
},
{
title:'用户',
align:"left",
dataIndex: 'userId_dictText'
},
{
title:'评论内容',
align:"left",
dataIndex: 'comment'
},
{
title: '操作',
dataIndex: 'action',
align:"center",
fixed:"right",
width:147,
scopedSlots: { customRender: 'action' },
}
],
url: {
list: "/commonBookComment/commonBookComment/rootList",
childList: "/commonBookComment/commonBookComment/childList",
getChildListBatch: "/commonBookComment/commonBookComment/getChildListBatch",
delete: "/commonBookComment/commonBookComment/delete",
deleteBatch: "/commonBookComment/commonBookComment/deleteBatch",
exportXlsUrl: "/commonBookComment/commonBookComment/exportXls",
importExcelUrl: "commonBookComment/commonBookComment/importExcel",
},
expandedRowKeys:[],
hasChildrenField:"hasChild",
pidField:"pid",
dictOptions: {},
loadParent: false,
superFieldList:[],
}
},
created() {
this.getSuperFieldList();
},
computed: {
importExcelUrl(){
return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
},
tableProps() {
let _this = this
return {
//
rowSelection: {
selectedRowKeys: _this.selectedRowKeys,
onChange: (selectedRowKeys) => _this.selectedRowKeys = selectedRowKeys
}
}
}
},
methods: {
loadData(arg){
if(arg==1){
this.ipagination.current=1
}
this.loading = true
let params = this.getQueryParams()
params.hasQuery = 'true'
getAction(this.url.list,params).then(res=>{
if(res.success){
let result = res.result
if(Number(result.total)>0){
this.ipagination.total = Number(result.total)
this.dataSource = this.getDataByResult(res.result.records)
return this.loadDataByExpandedRows(this.dataSource)
}else{
this.ipagination.total=0
this.dataSource=[]
}
}else{
this.$message.warning(res.message)
}
}).finally(()=>{
this.loading = false
})
},
//
loadDataByExpandedRows(dataList) {
if (this.expandedRowKeys.length > 0) {
return getAction(this.url.getChildListBatch,{ parentIds: this.expandedRowKeys.join(',') }).then(res=>{
if (res.success && res.result.records.length>0) {
//
let records = res.result.records
const listMap = new Map();
for (let item of records) {
let pid = item[this.pidField];
if (this.expandedRowKeys.join(',').includes(pid)) {
let mapList = listMap.get(pid);
if (mapList == null) {
mapList = [];
}
mapList.push(item);
listMap.set(pid, mapList);
}
}
let childrenMap = listMap;
let fn = (list) => {
if(list) {
list.forEach(data => {
if (this.expandedRowKeys.includes(data.id)) {
data.children = this.getDataByResult(childrenMap.get(data.id))
fn(data.children)
}
})
}
}
fn(dataList)
}
})
} else {
return Promise.resolve()
}
},
getQueryParams(arg) {
//
let sqp = {}
let param = {}
if(this.superQueryParams){
sqp['superQueryParams']=encodeURI(this.superQueryParams)
sqp['superQueryMatchType'] = this.superQueryMatchType
}
if(arg){
param = Object.assign(sqp, this.isorter ,this.filters);
}else{
param = Object.assign(sqp, this.queryParam, this.isorter ,this.filters);
}
if(JSON.stringify(this.queryParam) === "{}" || arg){
param.hasQuery = 'false'
}else{
param.hasQuery = 'true'
}
param.field = this.getQueryField();
param.pageNo = this.ipagination.current;
param.pageSize = this.ipagination.pageSize;
return filterObj(param);
},
searchReset() {
//
this.expandedRowKeys = []
this.queryParam = {}
this.loadData(1);
},
getDataByResult(result){
if(result){
return result.map(item=>{
//
if(item[this.hasChildrenField]=='1'){
let loadChild = { id: item.id+'_loadChild', name: 'loading...', isLoading: true }
item.children = [loadChild]
}
return item
})
}
},
handleExpand(expanded, record){
//
if (expanded) {
this.expandedRowKeys.push(record.id)
if (record.children.length>0 && record.children[0].isLoading === true) {
let params = this.getQueryParams(1);//
params[this.pidField] = record.id
params.hasQuery = 'false'
params.superQueryParams=""
getAction(this.url.childList,params).then((res)=>{
if(res.success){
if(res.result.records){
record.children = this.getDataByResult(res.result.records)
this.dataSource = [...this.dataSource]
}else{
record.children=''
record.hasChildrenField='0'
}
}else{
this.$message.warning(res.message)
}
})
}
}else{
let keyIndex = this.expandedRowKeys.indexOf(record.id)
if(keyIndex>=0){
this.expandedRowKeys.splice(keyIndex, 1);
}
}
},
handleAddChild(record){
this.loadParent = true
let obj = {}
obj[this.pidField] = record['id']
this.$refs.modalForm.add(obj);
},
handleDeleteNode(id) {
if(!this.url.delete){
this.$message.error("请设置url.delete属性!")
return
}
var that = this;
deleteAction(that.url.delete, {id: id}).then((res) => {
if (res.success) {
that.loadData(1)
} else {
that.$message.warning(res.message);
}
});
},
batchDel(){
if(this.selectedRowKeys.length<=0){
this.$message.warning('请选择一条记录!');
return false;
}else{
let ids = "";
let that = this;
that.selectedRowKeys.forEach(function(val) {
ids+=val+",";
});
that.$confirm({
title:"确认删除",
content:"是否删除选中数据?",
onOk: function(){
that.handleDeleteNode(ids)
that.onClearSelected();
}
});
}
},
getSuperFieldList(){
let fieldList=[];
fieldList.push({type:'datetime',value:'createTime',text:'创建日期'})
fieldList.push({type:'switch',value:'isLook',text:'是否已读'})
fieldList.push({type:'sel_search',value:'bookId',text:'书名',dictTable:"common_shop", dictText:'name', dictCode:'id'})
fieldList.push({type:'sel_search',value:'userId',text:'用户',dictTable:"han_hai_member", dictText:'nick_name', dictCode:'id'})
fieldList.push({type:'Text',value:'comment',text:'评论内容',dictCode:''})
fieldList.push({type:'string',value:'pid',text:'父级节点',dictCode:''})
this.superFieldList = fieldList
}
}
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>

+ 162
- 0
admin-pc/src/views/book/comment/modules/CommonBookCommentModal.vue View File

@ -0,0 +1,162 @@
<template>
<j-modal
:title="title"
:width="width"
:visible="visible"
:confirmLoading="confirmLoading"
switchFullscreen
@ok="handleOk"
@cancel="handleCancel"
cancelText="关闭">
<a-spin :spinning="confirmLoading">
<a-form-model ref="form" :model="model" :rules="validatorRules">
<a-form-model-item label="是否已读" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="isLook">
<j-switch v-model="model.isLook" ></j-switch>
</a-form-model-item>
<a-form-model-item label="书名" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bookId">
<j-search-select-tag v-model="model.bookId" dict="common_shop,name,id" />
</a-form-model-item>
<a-form-model-item label="用户" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="userId">
<j-search-select-tag v-model="model.userId" dict="han_hai_member,nick_name,id" />
</a-form-model-item>
<a-form-model-item label="评论内容" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="comment">
<a-textarea v-model="model.comment" rows="4" placeholder="请输入评论内容" />
</a-form-model-item>
<!-- <a-form-model-item label="父级节点" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="pid">-->
<!-- <j-tree-select-->
<!-- ref="treeSelect"-->
<!-- placeholder="请选择父级节点"-->
<!-- v-model="model.pid"-->
<!-- dict="common_book_comment,book_id,user_id,comment,is_look,create_time,id"-->
<!-- pidField="pid"-->
<!-- pidValue="0"-->
<!-- hasChildField="has_child"-->
<!-- >-->
<!-- </j-tree-select>-->
<!-- </a-form-model-item>-->
</a-form-model>
</a-spin>
</j-modal>
</template>
<script>
import { httpAction } from '@/api/manage'
import { validateDuplicateValue } from '@/utils/util'
export default {
name: "CommonBookCommentModal",
components: {
},
data () {
return {
title:"操作",
width:800,
visible: false,
model:{
},
labelCol: {
xs: { span: 24 },
sm: { span: 5 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 16 },
},
confirmLoading: false,
validatorRules: {
},
url: {
add: "/commonBookComment/commonBookComment/add",
edit: "/commonBookComment/commonBookComment/edit",
},
expandedRowKeys:[],
pidField:"pid"
}
},
created () {
//model
this.modelDefault = JSON.parse(JSON.stringify(this.model));
},
methods: {
add (obj) {
this.modelDefault.pid=''
this.edit(Object.assign(this.modelDefault , obj));
},
edit (record) {
this.model = Object.assign({}, record);
this.visible = true;
},
close () {
this.$emit('close');
this.visible = false;
this.$refs.form.clearValidate()
},
handleOk () {
const that = this;
//
this.$refs.form.validate(valid => {
if (valid) {
that.confirmLoading = true;
let httpurl = '';
let method = '';
if(!this.model.id){
httpurl+=this.url.add;
method = 'post';
}else{
httpurl+=this.url.edit;
method = 'put';
}
if(this.model.id && this.model.id === this.model[this.pidField]){
that.$message.warning("父级节点不能选择自己");
that.confirmLoading = false;
return;
}
httpAction(httpurl,this.model,method).then((res)=>{
if(res.success){
that.$message.success(res.message);
this.$emit('ok');
}else{
that.$message.warning(res.message);
}
}).finally(() => {
that.confirmLoading = false;
that.close();
})
}else{
return false
}
})
},
handleCancel () {
this.close()
},
submitSuccess(formData,flag){
if(!formData.id){
let treeData = this.$refs.treeSelect.getCurrTreeData()
this.expandedRowKeys=[]
this.getExpandKeysByPid(formData[this.pidField],treeData,treeData)
this.$emit('ok',formData,this.expandedRowKeys.reverse());
}else{
this.$emit('ok',formData,flag);
}
},
getExpandKeysByPid(pid,arr,all){
if(pid && arr && arr.length>0){
for(let i=0;i<arr.length;i++){
if(arr[i].key==pid){
this.expandedRowKeys.push(arr[i].key)
this.getExpandKeysByPid(arr[i]['parentId'],all,all)
}else{
this.getExpandKeysByPid(pid,arr[i].children,all)
}
}
}
}
}
}
</script>

+ 12
- 12
module-common/src/main/java/org/jeecg/modules/commonBookComment/vue/modules/CommonBookCommentModal.vue View File

@ -22,18 +22,18 @@
<a-form-model-item label="评论内容" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="comment"> <a-form-model-item label="评论内容" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="comment">
<a-textarea v-model="model.comment" rows="4" placeholder="请输入评论内容" /> <a-textarea v-model="model.comment" rows="4" placeholder="请输入评论内容" />
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="父级节点" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="pid">
<j-tree-select
ref="treeSelect"
placeholder="请选择父级节点"
v-model="model.pid"
dict="common_book_comment,book_id,user_id,comment,is_look,create_time,id"
pidField="pid"
pidValue="0"
hasChildField="has_child"
>
</j-tree-select>
</a-form-model-item>
<!-- <a-form-model-item label="父级节点" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="pid">-->
<!-- <j-tree-select-->
<!-- ref="treeSelect"-->
<!-- placeholder="请选择父级节点"-->
<!-- v-model="model.pid"-->
<!-- dict="common_book_comment,book_id,user_id,comment,is_look,create_time,id"-->
<!-- pidField="pid"-->
<!-- pidValue="0"-->
<!-- hasChildField="has_child"-->
<!-- >-->
<!-- </j-tree-select>-->
<!-- </a-form-model-item>-->
</a-form-model> </a-form-model>
</a-spin> </a-spin>


+ 1
- 1
module-system/src/main/resources/application-dev.yml View File

@ -1,5 +1,5 @@
server: server:
port: 8003
port: 8002
tomcat: tomcat:
max-swallow-size: -1 max-swallow-size: -1
error: error:


Loading…
Cancel
Save