添加功能

This commit is contained in:
yangjun 2024-05-20 18:19:08 +08:00
parent 09530e076b
commit 9ce25b825e
16 changed files with 1563 additions and 2 deletions

View File

@ -199,6 +199,14 @@ const site: AppRouteModule = {
title: '选择课程', title: '选择课程',
}, },
}, },
{
path: 'dqkcTlqjh',
name: 'dqkcTlqjh',
component: () => import('/@/views/zy/zyTlq/TlqJiaohuList.vue'),
meta: {
title: '讨论区',
},
},
], ],
}; };

View File

@ -87,6 +87,14 @@ const zuoye: AppRouteModule = {
title: '调查问卷', title: '调查问卷',
}, },
}, },
{
path: 'dqkcTlq',
name: 'dqkcTlq',
component: () => import('/@/views/zy/zyTlq/ZyTlqList.vue'),
meta: {
title: '讨论区',
},
},
] ]
} }

View File

@ -17,8 +17,8 @@ export const getFileAccessHttpUrl = (fileUrl, prefix = 'http') => {
//判断是否是数组格式 //判断是否是数组格式
let isArray = fileUrl.indexOf('[') != -1; let isArray = fileUrl.indexOf('[') != -1;
if (!isArray) { if (!isArray) {
// let prefix = `${baseApiUrl}/sys/common/static/`; let prefix = `${baseApiUrl}/sys/common/static/`;
let prefix = `${baseApiUrl}/zyk/zykInfo/static/`; // let prefix = `${baseApiUrl}/zyk/zykInfo/static/`;
// 判断是否已包含前缀 // 判断是否已包含前缀
if (!fileUrl.startsWith(prefix)) { if (!fileUrl.startsWith(prefix)) {
result = `${prefix}${fileUrl}`; result = `${prefix}${fileUrl}`;

View File

@ -26,6 +26,9 @@
<a-menu-item key="sub4"> <a-menu-item key="sub4">
<span>教学资源库</span> <span>教学资源库</span>
</a-menu-item> </a-menu-item>
<a-menu-item key="sub5">
<span @click="getGzt('tlq')">讨论区</span>
</a-menu-item>
<!-- <a-menu-item key="sub3"> <!-- <a-menu-item key="sub3">
<span @click="getGzt('dqwj')">问卷调查</span> <span @click="getGzt('dqwj')">问卷调查</span>
</a-menu-item> --> </a-menu-item> -->
@ -82,6 +85,8 @@
href = "/zy/ceshiWenjuan"; href = "/zy/ceshiWenjuan";
}else if(zytype=='gongju'){ }else if(zytype=='gongju'){
href = "/zy/dqkcGongju"; href = "/zy/dqkcGongju";
}else if(zytype=='tlq'){
href = "/zy/dqkcTlq";
} }
router.push({path:href,query: {rwbh,xqxn,type}}); router.push({path:href,query: {rwbh,xqxn,type}});

View File

@ -0,0 +1,206 @@
<template>
<div id="siteMain">
<div id="maxSite">
<a-layout style="height: calc(100vh - 30px)">
<headerPage/>
<div style="margin-top:10px;background:#fff;">
<div style="padding: 20px;width: 98%;">
<a-row>
<a-col :span="24"><span style="line-height:20px;font-size:18px;font-weight:bold;">{{tlqInfo.title}}</span></a-col>
<a-col :span="24" v-if="tlqInfo.picPath" style="margin-top:20px;">
<j-upload v-model:value="tlqInfo.picPath" fileType="image" :isImageMode="false" :maxCount="1" :buttonVisible="false" disabled="true" style="width:300px;"></j-upload>
</a-col>
<a-col :span="24" v-if="tlqInfo.filePath" style="margin-top:20px;">
<j-upload v-model:value="tlqInfo.filePath" :maxCount="1" :buttonVisible="false" disabled="true"></j-upload>
</a-col>
</a-row>
<a-divider style="border-color: #7cb305" dashed />
</div>
<div style="width:98%;" v-for="index in 0">
<a-comment style="padding: 20px;">
<template #author>Han Solo</template>
<template #datetime>
<span>{{dayjs().format('YYYY-MM-DD HH:mm:ss')}}</span>
</template>
<template #content>
<p>
We supply a series of design principles, practical patterns and high quality design
resources (Sketch and Axure), to help people create their product prototypes beautifully and
efficiently.
</p>
</template>
</a-comment>
<a-divider style="border-color: #7cb305" dashed />
</div>
<div style="padding: 20px;background: #fafafa">
<a-row>
<a-col :span="24">
<div style="font-size: 18px;font-weight: 700;">发表内容</div>
<div><a-textarea v-model:value="formData.content" style="height: 100px"></a-textarea></div>
</a-col>
<a-col :span="12">
<div style="font-size: 18px;font-weight: 700;">图片</div>
<div>
<j-upload v-model:value="formData.picPath" fileType="image" :maxCount="9" ></j-upload>
</div>
</a-col>
<a-col :span="12">
<div style="font-size: 18px;font-weight: 700;">附件</div>
<div><j-upload v-model:value="formData.picPath" :maxCount="9" ></j-upload></div>
</a-col>
<a-col :span="24">
<a-button type="primary">发表</a-button>
</a-col>
</a-row>
</div>
</div>
<footerPage style="margin-top:10px;"/>
</a-layout>
</div>
</div>
</template>
<script lang="ts" name="zyTlq-zyTlq" setup>
import { ref, reactive, onMounted, unref ,defineComponent } from 'vue';
import { Pagination, Empty } from 'ant-design-vue';
import { defHttp } from '/@/utils/http/axios';
import { useRouter } from 'vue-router';
import { LikeFilled, LikeOutlined, DislikeFilled, DislikeOutlined } from '@ant-design/icons-vue';
import headerPage from '/@/views/site/common/header.vue';
import footerPage from '/@/views/site/common/footer.vue';
import JUpload from '/@/components/Form/src/jeecg/components/JUpload/JUpload.vue';
import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';
import { Comment } from 'ant-design-vue';
dayjs.extend(relativeTime);
const queryParam = ref<any>({});
const toggleSearchStatus = ref<boolean>(false);
const registerModal = ref();
const dataSource = ref<any>([]);
const tlqInfo = ref<any>({});
const formData = ref<any>({});
const current = ref<number>(0);
const total = ref<number>(0);
const pageNo = ref<number>(0);
const pageSize = ref<number>(50);
const APagination = Pagination;
const AComment = Comment;
const { currentRoute } = useRouter();
const { query } = unref(currentRoute);
const { id } = query;//
const labelCol = reactive({
xs: { span: 24 },
sm: { span: 7 },
});
const wrapperCol = reactive({
xs: { span: 24 },
sm: { span: 4 },
});
const likes = ref<number>(0);
const dislikes = ref<number>(0);
const action = ref<string>();
const like = () => {
likes.value = 1;
dislikes.value = 0;
action.value = 'liked';
};
const dislike = () => {
likes.value = 0;
dislikes.value = 1;
action.value = 'disliked';
};
//
function handlePageChange(page: number) {
loadData(page);
}
async function getTlqInfo(){
await defHttp.get({ url: '/zyTlq/zyTlq/queryById', params: { id:id }}).then((res) => {
console.log(`🚀 ~ awaitdefHttp.get ~ res:`, res)
tlqInfo.value = res;
});
// loadData(1)
}
async function loadData(arg){
await defHttp.get({ url: '/zyTlqContent/zyTlqContent/list', params: { pageSize: pageSize,pageNo:arg, mainId:id,column:'createTime',order:'desc' } }).then((res) => {
console.log(`🚀 ~ defHttp.get ~ res:`, res)
dataSource.value = res.records;
total.value = res.total;
});
}
//
onMounted(() => {
getTlqInfo();
});
</script>
<style lang="less" scoped>
#siteMain {
// font-size: ;
// height: 100%;
background: #f3f3f4;
#maxSite {
//
max-width: 1070px;
min-height: calc(100vh);
//
margin: 0 auto;
.rowGutter{
margin-top: 1rem;
margin-bottom: 1rem;
}
.ant-layout-header {
color: #fff;
background: #1ab394;
}
.ant-layout-footer {
line-height: 1.5;
background: #FFF;
}
.ant-layout-sider {
color: #fff;
line-height: 120px;
background: #3ba0e9;
}
.ant-layout-content {
min-height: 120px;
color: #000;
line-height: 120px;
background: #f3f3f4;
}
}
}
.jeecg-basic-table-form-container {
.table-page-search-submitButtons {
display: block;
margin-bottom: 24px;
white-space: nowrap;
}
.query-group-cust{
width: calc(50% - 15px);
min-width: 100px !important;
}
.query-group-split-cust{
width: 30px;
display: inline-block;
text-align: center
}
}
/deep/.ant-upload-list-picture-card-container {
display: inline-block;
width: 80px;
height: 80px;
margin: 0 8px 8px 0;
vertical-align: top;
}
</style>

View File

@ -0,0 +1,72 @@
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from "/@/hooks/web/useMessage";
const { createConfirm } = useMessage();
enum Api {
list = '/zyTlq/zyTlq/list',
save='/zyTlq/zyTlq/add',
edit='/zyTlq/zyTlq/edit',
deleteOne = '/zyTlq/zyTlq/delete',
deleteBatch = '/zyTlq/zyTlq/deleteBatch',
importExcel = '/zyTlq/zyTlq/importExcel',
exportXls = '/zyTlq/zyTlq/exportXls',
}
/**
* api
* @param params
*/
export const getExportUrl = Api.exportXls;
/**
* api
*/
export const getImportUrl = Api.importExcel;
/**
*
* @param params
*/
export const list = (params) => defHttp.get({ url: Api.list, params });
/**
*
* @param params
* @param handleSuccess
*/
export const deleteOne = (params,handleSuccess) => {
return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => {
handleSuccess();
});
}
/**
*
* @param params
* @param handleSuccess
*/
export const batchDelete = (params, handleSuccess) => {
createConfirm({
iconType: 'warning',
title: '确认删除',
content: '是否删除选中数据',
okText: '确认',
cancelText: '取消',
onOk: () => {
return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
handleSuccess();
});
}
});
}
/**
*
* @param params
* @param isUpdate
*/
export const saveOrUpdate = (params, isUpdate) => {
let url = isUpdate ? Api.edit : Api.save;
return defHttp.post({ url: url, params }, { isTransformResponse: false });
}

View File

@ -0,0 +1,42 @@
import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
{
title: 'mainId',
align: "center",
dataIndex: 'mainId'
},
{
title: '标题',
align: "center",
dataIndex: 'title'
},
];
//查询数据
export const searchFormSchema: FormSchema[] = [
];
//表单数据
export const formSchema: FormSchema[] = [
{
label: 'mainId',
field: 'mainId',
component: 'Input',
},
{
label: '标题',
field: 'title',
component: 'Input',
},
// TODO 主键隐藏字段目前写死为ID
{
label: '',
field: 'id',
component: 'Input',
show: false,
},
];

View File

@ -0,0 +1,215 @@
<template>
<div>
<!--查询区域-->
<div class="jeecg-basic-table-form-container">
<a-form @keyup.enter.native="searchQuery" :model="queryParam" :label-col="labelCol" :wrapper-col="wrapperCol">
<a-row :gutter="24">
</a-row>
</a-form>
</div>
<!--引用表格-->
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<!--插槽:table标题-->
<template #tableTitle>
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
<j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
<a-dropdown v-if="selectedRowKeys.length > 0">
<template #overlay>
<a-menu>
<a-menu-item key="1" @click="batchHandleDelete">
<Icon icon="ant-design:delete-outlined"></Icon>
删除
</a-menu-item>
</a-menu>
</template>
<a-button>批量操作
<Icon icon="mdi:chevron-down"></Icon>
</a-button>
</a-dropdown>
</template>
<!--操作栏-->
<template #action="{ record }">
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)"/>
</template>
<!--字段回显插槽-->
<template #htmlSlot="{text}">
<div v-html="text"></div>
</template>
<!--省市区字段回显插槽-->
<!--<template #pcaSlot="{text}">
{{ getAreaTextByCode(text) }}
</template>-->
<template #fileSlot="{text}">
<span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
<a-button v-else :ghost="true" type="primary" preIcon="ant-design:download-outlined" size="small" @click="downloadFile(text)">下载</a-button>
</template>
</BasicTable>
<!-- 表单区域 -->
<ZyTlqModal ref="registerModal" @success="handleSuccess"></ZyTlqModal>
</div>
</template>
<script lang="ts" name="zyTlq-zyTlq" setup>
import { ref, reactive } from 'vue';
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { useListPage } from '/@/hooks/system/useListPage';
import { columns } from './ZyTlq.data';
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './ZyTlq.api';
import { downloadFile } from '/@/utils/common/renderUtils';
import ZyTlqModal from './components/ZyTlqModal.vue'
const queryParam = ref<any>({});
const toggleSearchStatus = ref<boolean>(false);
const registerModal = ref();
//table
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
tableProps: {
title: '讨论区',
api: list,
columns,
canResize:false,
useSearchForm: false,
actionColumn: {
width: 120,
fixed: 'right',
},
beforeFetch: (params) => {
params.column = '',params.order = '';//
return Object.assign(params, queryParam.value);
},
},
exportConfig: {
name: "讨论区",
url: getExportUrl,
},
importConfig: {
url: getImportUrl,
success: handleSuccess
},
});
const [registerTable, { reload, collapseAll, updateTableDataRecord, findTableDataRecord, getDataSource }, { rowSelection, selectedRowKeys }] = tableContext;
const labelCol = reactive({
xs: { span: 24 },
sm: { span: 7 },
});
const wrapperCol = reactive({
xs: { span: 24 },
sm: { span: 16 },
});
/**
* 新增事件
*/
function handleAdd() {
registerModal.value.disableSubmit = false;
registerModal.value.add();
}
/**
* 编辑事件
*/
function handleEdit(record: Recordable) {
registerModal.value.disableSubmit = false;
registerModal.value.edit(record);
}
/**
* 详情
*/
function handleDetail(record: Recordable) {
registerModal.value.disableSubmit = true;
registerModal.value.edit(record);
}
/**
* 删除事件
*/
async function handleDelete(record) {
await deleteOne({ id: record.id }, handleSuccess);
}
/**
* 批量删除事件
*/
async function batchHandleDelete() {
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
}
/**
* 成功回调
*/
function handleSuccess() {
(selectedRowKeys.value = []) && reload();
}
/**
* 操作栏
*/
function getTableAction(record) {
return [
{
label: '编辑',
onClick: handleEdit.bind(null, record),
},
];
}
/**
* 下拉操作栏
*/
function getDropDownAction(record) {
return [
{
label: '详情',
onClick: handleDetail.bind(null, record),
}, {
label: '删除',
popConfirm: {
title: '是否确认删除',
confirm: handleDelete.bind(null, record),
}
}
]
}
/**
* 查询
*/
function searchQuery() {
reload();
}
/**
* 重置
*/
function searchReset() {
queryParam.value = {};
selectedRowKeys.value = [];
//
reload();
}
</script>
<style lang="less" scoped>
.jeecg-basic-table-form-container {
.table-page-search-submitButtons {
display: block;
margin-bottom: 24px;
white-space: nowrap;
}
.query-group-cust{
width: calc(50% - 15px);
min-width: 100px !important;
}
.query-group-split-cust{
width: 30px;
display: inline-block;
text-align: center
}
}
</style>

View File

@ -0,0 +1,198 @@
<template>
<div style="margin-top:10px;background:#fff;">
<!--查询区域-->
<div class="jeecg-basic-table-form-container" >
<a-form @keyup.enter.native="searchQuery" :model="queryParam" :label-col="labelCol" :wrapper-col="wrapperCol">
<a-row :gutter="24">
<a-col :lg="8" style="margin-top:10px;">
<a-form-item label="标题">
<j-input placeholder="请输入标题" v-model:value="queryParam.title"></j-input>
</a-form-item>
</a-col>
<a-col :xl="6" :lg="7" :md="8" :sm="24" style="margin-top:10px;">
<span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
<a-col :lg="6">
<a-button type="primary" preIcon="ant-design:search-outlined" @click="searchQuery">查询</a-button>
<a-button type="primary" preIcon="ant-design:plus-outlined" @click="handleAdd" style="margin-left: 8px"> 新增</a-button>
</a-col>
</span>
</a-col>
</a-row>
</a-form>
</div>
<!--引用表格-->
<a-row style="width:100%;display: block;padding:10px;min-height: 300px">
<a-col :span="24" v-for="(item,index) in dataSource" :key="index">
<!-- <a-card> -->
<a-row>
<a-col :span="24">
<span style="float: left;">{{index+1}}.{{item.title}}</span>
<span style="float: right;">
<span v-if="item.sffb=='0'">未发布</span>
<span v-else>已发布</span>
<a title="修改" @click="handleEdit(item)" v-if="item.sffb=='0'"><Icon icon="ant-design:form-outlined"/></a>
<a-divider type="vertical" style="height: 30px; background-color: #7cb305" v-if="item.sffb=='0'"/>
<a title="删除" @click="handleDelete(item)"><Icon icon="ant-design:delete-outlined" v-if="item.sffb=='0'"/></a>
<a-divider type="vertical" style="height: 30px; background-color: #7cb305" v-if="item.sffb=='0'"/>
<a title="发布" @click="handleFabu(item)"><Icon icon="ant-design:check-circle-outlined" v-if="item.sffb=='0'"/></a>
<a-divider type="vertical" style="height: 30px; background-color: #7cb305" v-if="item.sffb=='0'"/>
<a title="详情" @click="handleDetail(item)"><Icon icon="ant-design:snippets-outlined" /></a>
</span>
</a-col>
<a-col :span="24" v-if="item.picPath.length > 0">
<j-upload v-model:value="item.picPath" fileType="image" :isImageMode="false" :maxCount="1" :buttonVisible="false" disabled="true"></j-upload>
</a-col>
<a-col :span="24" v-if="item.filePath.length > 0">
<j-upload v-model:value="item.filePath" :maxCount="1" :buttonVisible="false" disabled="true"></j-upload>
</a-col>
</a-row>
<!-- <a-divider style="height: 1px; background-color: #7cb305" /> -->
<a-divider style="border-color: #7cb305" dashed />
<!-- </a-card> -->
</a-col>
<a-col :span="24" v-show="dataSource.length>0">
<a-pagination v-model="current" :total="total" @change="handlePageChange" :pageSize="pageSize" style="text-align: right;"/>
</a-col>
<a-col :span="24" v-show="dataSource.length==0">
<a-empty/>
</a-col>
</a-row>
<ZyTlqModal ref="registerModal" @success="handleSuccess" ></ZyTlqModal>
</div>
</template>
<script lang="ts" name="zyTlq-zyTlq" setup>
import { ref, reactive, onMounted, unref } from 'vue';
import { columns } from './ZyTlq.data';
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './ZyTlq.api';
import { downloadFile } from '/@/utils/common/renderUtils';
import ZyTlqModal from './components/ZyTlqModal.vue'
import { Pagination, Empty } from 'ant-design-vue';
import { defHttp } from '/@/utils/http/axios';
import { useRouter } from 'vue-router';
import { JInput } from '/@/components/Form';
import JUpload from '/@/components/Form/src/jeecg/components/JUpload/JUpload.vue';
const queryParam = ref<any>({});
const toggleSearchStatus = ref<boolean>(false);
const registerModal = ref();
const dataSource = ref<any>([]);
const current = ref<number>(0);
const total = ref<number>(0);
const pageNo = ref<number>(0);
const pageSize = ref<number>(3);
const APagination = Pagination;
const { currentRoute } = useRouter();
const { query } = unref(currentRoute);
const { rwbh,xqxn } = query;//
const labelCol = reactive({
xs: { span: 24 },
sm: { span: 7 },
});
const wrapperCol = reactive({
xs: { span: 24 },
sm: { span: 16 },
});
/**
* 发布
*/
function handleFabu(record) {
defHttp.post({ url: '/zyTlq/zyTlq/edit', params: { id: record.id,sffb: "6" } }).then(res => {
total.value = 1;
pageNo.value = 0;
loadData(1);
});
}
//
function handlePageChange(page: number) {
loadData(page);
}
/**
* 新增事件
*/
function handleAdd() {
registerModal.value.disableSubmit = false;
registerModal.value.add();
}
/**
* 编辑事件
*/
function handleEdit(record: Recordable) {
registerModal.value.disableSubmit = false;
registerModal.value.edit(record);
}
/**
* 详情
*/
function handleDetail(record: Recordable) {
var url = "/site/dqkcTlqjh?id="+record.id;
window.open(url,"_blank")
}
/**
* 删除事件
*/
async function handleDelete(record) {
await deleteOne({ id: record.id }, handleSuccess);
}
/**
* 成功回调
*/
function handleSuccess() {
loadData(1);
}
/**
* 查询
*/
function searchQuery() {
loadData(1);
}
/**
* 重置
*/
function searchReset() {
queryParam.value = {};
//
loadData(1);
}
function loadData(arg){
defHttp.get({ url: '/zyTlq/zyTlq/list', params: { pageSize: 3,pageNo:arg, rwbh:rwbh,xqxn:xqxn,column:'createTime',order:'desc' } }).then((res) => {
console.log(`🚀 ~ defHttp.get ~ res:`, res)
dataSource.value = res.records;
total.value = res.total;
});
}
//
onMounted(() => {
loadData(1);
});
</script>
<style lang="less" scoped>
.jeecg-basic-table-form-container {
.table-page-search-submitButtons {
display: block;
margin-bottom: 24px;
white-space: nowrap;
}
.query-group-cust{
width: calc(50% - 15px);
min-width: 100px !important;
}
.query-group-split-cust{
width: 30px;
display: inline-block;
text-align: center
}
}
</style>

View File

@ -0,0 +1,147 @@
<template>
<a-spin :spinning="confirmLoading">
<a-form ref="formRef" class="antd-modal-form" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-row>
<a-col :span="24">
<a-form-item label="标题" v-bind="validateInfos.title">
<a-input v-model:value="formData.title" placeholder="请输入标题" :disabled="disabled"></a-input>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="图片" v-bind="validateInfos.picPath" :labelCol="labelCol" :wrapperCol="wrapperCol2">
<j-upload v-model:value="formData.picPath" fileType="image" maxCount="9"></j-upload>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="附件" v-bind="validateInfos.title">
<j-upload v-model:value="formData.filePath"></j-upload>
</a-form-item>
</a-col>
</a-row>
</a-form>
</a-spin>
</template>
<script lang="ts" setup>
import { ref, reactive, defineExpose, nextTick, defineProps, computed, onMounted, unref } from 'vue';
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from '/@/hooks/web/useMessage';
import { getValueType } from '/@/utils';
import { saveOrUpdate } from '../ZyTlq.api';
import { Form } from 'ant-design-vue';
import JUpload from '/@/components/Form/src/jeecg/components/JUpload/JUpload.vue';
import { useRouter } from 'vue-router';
const { currentRoute } = useRouter();
const { query } = unref(currentRoute);
const { rwbh,xqxn } = query;//
const props = defineProps({
formDisabled: { type: Boolean, default: false },
formData: { type: Object, default: ()=>{} },
formBpm: { type: Boolean, default: true }
});
const formRef = ref();
const useForm = Form.useForm;
const emit = defineEmits(['register', 'ok']);
const formData = reactive<Record<string, any>>({
id: '',
title: '',
picPath:'',
filePath:'',
rwbh,xqxn
});
const { createMessage } = useMessage();
const labelCol = ref<any>({ xs: { span: 24 }, sm: { span: 5 } });
const wrapperCol = ref<any>({ xs: { span: 24 }, sm: { span: 16 } });
const wrapperCol2 = ref<any>({ xs: { span: 24 }, sm: { span: 12 } });
const confirmLoading = ref<boolean>(false);
//
const validatorRules = {
};
const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: true });
//
const disabled = computed(()=>{
if(props.formBpm === true){
if(props.formData.disabled === false){
return false;
}else{
return true;
}
}
return props.formDisabled;
});
/**
* 新增
*/
function add() {
edit({});
}
/**
* 编辑
*/
function edit(record) {
nextTick(() => {
resetFields();
//
Object.assign(formData, record);
});
}
/**
* 提交数据
*/
async function submitForm() {
//
await validate();
confirmLoading.value = true;
const isUpdate = ref<boolean>(false);
//
let model = formData;
if (model.id) {
isUpdate.value = true;
}
//
for (let data in model) {
//
if (model[data] instanceof Array) {
let valueType = getValueType(formRef.value.getProps, data);
//
if (valueType === 'string') {
model[data] = model[data].join(',');
}
}
}
await saveOrUpdate(model, isUpdate.value)
.then((res) => {
if (res.success) {
createMessage.success(res.message);
emit('ok');
} else {
createMessage.warning(res.message);
}
})
.finally(() => {
confirmLoading.value = false;
});
}
defineExpose({
add,
edit,
submitForm,
});
</script>
<style lang="less" scoped>
.antd-modal-form {
min-height: 500px !important;
overflow-y: auto;
padding: 24px 24px 24px 24px;
}
</style>

View File

@ -0,0 +1,75 @@
<template>
<a-modal :title="title" :width="width" :visible="visible" @ok="handleOk" :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }" @cancel="handleCancel" cancelText="关闭">
<ZyTlqForm ref="registerForm" @ok="submitCallback" :formDisabled="disableSubmit" :formBpm="false"></ZyTlqForm>
</a-modal>
</template>
<script lang="ts" setup>
import { ref, nextTick, defineExpose } from 'vue';
import ZyTlqForm from './ZyTlqForm.vue'
const title = ref<string>('');
const width = ref<number>(800);
const visible = ref<boolean>(false);
const disableSubmit = ref<boolean>(false);
const registerForm = ref();
const emit = defineEmits(['register', 'success']);
/**
* 新增
*/
function add() {
title.value = '新增';
visible.value = true;
nextTick(() => {
registerForm.value.add();
});
}
/**
* 编辑
* @param record
*/
function edit(record) {
title.value = disableSubmit.value ? '详情' : '编辑';
visible.value = true;
nextTick(() => {
registerForm.value.edit(record);
});
}
/**
* 确定按钮点击事件
*/
function handleOk() {
registerForm.value.submitForm();
}
/**
* form保存回调事件
*/
function submitCallback() {
handleCancel();
emit('success');
}
/**
* 取消按钮回调事件
*/
function handleCancel() {
visible.value = false;
}
defineExpose({
add,
edit,
disableSubmit,
});
</script>
<style>
/**隐藏样式-modal确定按钮 */
.jee-hidden {
display: none !important;
}
</style>

View File

@ -0,0 +1,72 @@
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from "/@/hooks/web/useMessage";
const { createConfirm } = useMessage();
enum Api {
list = '/zyTlqContent/zyTlqContent/list',
save='/zyTlqContent/zyTlqContent/add',
edit='/zyTlqContent/zyTlqContent/edit',
deleteOne = '/zyTlqContent/zyTlqContent/delete',
deleteBatch = '/zyTlqContent/zyTlqContent/deleteBatch',
importExcel = '/zyTlqContent/zyTlqContent/importExcel',
exportXls = '/zyTlqContent/zyTlqContent/exportXls',
}
/**
* api
* @param params
*/
export const getExportUrl = Api.exportXls;
/**
* api
*/
export const getImportUrl = Api.importExcel;
/**
*
* @param params
*/
export const list = (params) => defHttp.get({ url: Api.list, params });
/**
*
* @param params
* @param handleSuccess
*/
export const deleteOne = (params,handleSuccess) => {
return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => {
handleSuccess();
});
}
/**
*
* @param params
* @param handleSuccess
*/
export const batchDelete = (params, handleSuccess) => {
createConfirm({
iconType: 'warning',
title: '确认删除',
content: '是否删除选中数据',
okText: '确认',
cancelText: '取消',
onOk: () => {
return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
handleSuccess();
});
}
});
}
/**
*
* @param params
* @param isUpdate
*/
export const saveOrUpdate = (params, isUpdate) => {
let url = isUpdate ? Api.edit : Api.save;
return defHttp.post({ url: url, params }, { isTransformResponse: false });
}

View File

@ -0,0 +1,72 @@
import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
{
title: 'mainId',
align: "center",
dataIndex: 'mainId'
},
{
title: '讨论信息',
align: "center",
dataIndex: 'content'
},
{
title: '图片',
align: "center",
dataIndex: 'picPath'
},
{
title: '附件',
align: "center",
dataIndex: 'filePath'
},
{
title: '点赞',
align: "center",
dataIndex: 'dianzan'
},
];
//查询数据
export const searchFormSchema: FormSchema[] = [
];
//表单数据
export const formSchema: FormSchema[] = [
{
label: 'mainId',
field: 'mainId',
component: 'Input',
},
{
label: '讨论信息',
field: 'content',
component: 'InputTextArea',
},
{
label: '图片',
field: 'picPath',
component: 'InputTextArea',
},
{
label: '附件',
field: 'filePath',
component: 'InputTextArea',
},
{
label: '点赞',
field: 'dianzan',
component: 'InputNumber',
},
// TODO 主键隐藏字段目前写死为ID
{
label: '',
field: 'id',
component: 'Input',
show: false,
},
];

View File

@ -0,0 +1,215 @@
<template>
<div>
<!--查询区域-->
<div class="jeecg-basic-table-form-container">
<a-form @keyup.enter.native="searchQuery" :model="queryParam" :label-col="labelCol" :wrapper-col="wrapperCol">
<a-row :gutter="24">
</a-row>
</a-form>
</div>
<!--引用表格-->
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<!--插槽:table标题-->
<template #tableTitle>
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
<j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
<a-dropdown v-if="selectedRowKeys.length > 0">
<template #overlay>
<a-menu>
<a-menu-item key="1" @click="batchHandleDelete">
<Icon icon="ant-design:delete-outlined"></Icon>
删除
</a-menu-item>
</a-menu>
</template>
<a-button>批量操作
<Icon icon="mdi:chevron-down"></Icon>
</a-button>
</a-dropdown>
</template>
<!--操作栏-->
<template #action="{ record }">
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)"/>
</template>
<!--字段回显插槽-->
<template #htmlSlot="{text}">
<div v-html="text"></div>
</template>
<!--省市区字段回显插槽-->
<!--<template #pcaSlot="{text}">
{{ getAreaTextByCode(text) }}
</template>-->
<template #fileSlot="{text}">
<span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
<a-button v-else :ghost="true" type="primary" preIcon="ant-design:download-outlined" size="small" @click="downloadFile(text)">下载</a-button>
</template>
</BasicTable>
<!-- 表单区域 -->
<ZyTlqContentModal ref="registerModal" @success="handleSuccess"></ZyTlqContentModal>
</div>
</template>
<script lang="ts" name="zyTlqContent-zyTlqContent" setup>
import { ref, reactive } from 'vue';
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { useListPage } from '/@/hooks/system/useListPage';
import { columns } from './ZyTlqContent.data';
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './ZyTlqContent.api';
import { downloadFile } from '/@/utils/common/renderUtils';
import ZyTlqContentModal from './components/ZyTlqContentModal.vue'
const queryParam = ref<any>({});
const toggleSearchStatus = ref<boolean>(false);
const registerModal = ref();
//table
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
tableProps: {
title: '讨论内容',
api: list,
columns,
canResize:false,
useSearchForm: false,
actionColumn: {
width: 120,
fixed: 'right',
},
beforeFetch: (params) => {
params.column = '',params.order = '';//
return Object.assign(params, queryParam.value);
},
},
exportConfig: {
name: "讨论内容",
url: getExportUrl,
},
importConfig: {
url: getImportUrl,
success: handleSuccess
},
});
const [registerTable, { reload, collapseAll, updateTableDataRecord, findTableDataRecord, getDataSource }, { rowSelection, selectedRowKeys }] = tableContext;
const labelCol = reactive({
xs: { span: 24 },
sm: { span: 7 },
});
const wrapperCol = reactive({
xs: { span: 24 },
sm: { span: 16 },
});
/**
* 新增事件
*/
function handleAdd() {
registerModal.value.disableSubmit = false;
registerModal.value.add();
}
/**
* 编辑事件
*/
function handleEdit(record: Recordable) {
registerModal.value.disableSubmit = false;
registerModal.value.edit(record);
}
/**
* 详情
*/
function handleDetail(record: Recordable) {
registerModal.value.disableSubmit = true;
registerModal.value.edit(record);
}
/**
* 删除事件
*/
async function handleDelete(record) {
await deleteOne({ id: record.id }, handleSuccess);
}
/**
* 批量删除事件
*/
async function batchHandleDelete() {
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
}
/**
* 成功回调
*/
function handleSuccess() {
(selectedRowKeys.value = []) && reload();
}
/**
* 操作栏
*/
function getTableAction(record) {
return [
{
label: '编辑',
onClick: handleEdit.bind(null, record),
},
];
}
/**
* 下拉操作栏
*/
function getDropDownAction(record) {
return [
{
label: '详情',
onClick: handleDetail.bind(null, record),
}, {
label: '删除',
popConfirm: {
title: '是否确认删除',
confirm: handleDelete.bind(null, record),
}
}
]
}
/**
* 查询
*/
function searchQuery() {
reload();
}
/**
* 重置
*/
function searchReset() {
queryParam.value = {};
selectedRowKeys.value = [];
//
reload();
}
</script>
<style lang="less" scoped>
.jeecg-basic-table-form-container {
.table-page-search-submitButtons {
display: block;
margin-bottom: 24px;
white-space: nowrap;
}
.query-group-cust{
width: calc(50% - 15px);
min-width: 100px !important;
}
.query-group-split-cust{
width: 30px;
display: inline-block;
text-align: center
}
}
</style>

View File

@ -0,0 +1,151 @@
<template>
<a-spin :spinning="confirmLoading">
<a-form ref="formRef" class="antd-modal-form" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-row>
<a-col :span="24">
<a-form-item label="mainId" v-bind="validateInfos.mainId">
<a-input v-model:value="formData.mainId" placeholder="请输入mainId" :disabled="disabled"></a-input>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="讨论信息" v-bind="validateInfos.content">
<a-textarea v-model:value="formData.content" rows="4" placeholder="请输入讨论信息" :disabled="disabled"/>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="图片" v-bind="validateInfos.picPath">
<a-textarea v-model:value="formData.picPath" rows="4" placeholder="请输入图片" :disabled="disabled"/>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="附件" v-bind="validateInfos.filePath">
<a-textarea v-model:value="formData.filePath" rows="4" placeholder="请输入附件" :disabled="disabled"/>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="点赞" v-bind="validateInfos.dianzan">
<a-input-number v-model:value="formData.dianzan" placeholder="请输入点赞" style="width: 100%" :disabled="disabled"/>
</a-form-item>
</a-col>
</a-row>
</a-form>
</a-spin>
</template>
<script lang="ts" setup>
import { ref, reactive, defineExpose, nextTick, defineProps, computed, onMounted } from 'vue';
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from '/@/hooks/web/useMessage';
import { getValueType } from '/@/utils';
import { saveOrUpdate } from '../ZyTlqContent.api';
import { Form } from 'ant-design-vue';
const props = defineProps({
formDisabled: { type: Boolean, default: false },
formData: { type: Object, default: ()=>{} },
formBpm: { type: Boolean, default: true }
});
const formRef = ref();
const useForm = Form.useForm;
const emit = defineEmits(['register', 'ok']);
const formData = reactive<Record<string, any>>({
id: '',
mainId: '',
content: '',
picPath: '',
filePath: '',
dianzan: undefined,
});
const { createMessage } = useMessage();
const labelCol = ref<any>({ xs: { span: 24 }, sm: { span: 5 } });
const wrapperCol = ref<any>({ xs: { span: 24 }, sm: { span: 16 } });
const confirmLoading = ref<boolean>(false);
//
const validatorRules = {
};
const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: true });
//
const disabled = computed(()=>{
if(props.formBpm === true){
if(props.formData.disabled === false){
return false;
}else{
return true;
}
}
return props.formDisabled;
});
/**
* 新增
*/
function add() {
edit({});
}
/**
* 编辑
*/
function edit(record) {
nextTick(() => {
resetFields();
//
Object.assign(formData, record);
});
}
/**
* 提交数据
*/
async function submitForm() {
//
await validate();
confirmLoading.value = true;
const isUpdate = ref<boolean>(false);
//
let model = formData;
if (model.id) {
isUpdate.value = true;
}
//
for (let data in model) {
//
if (model[data] instanceof Array) {
let valueType = getValueType(formRef.value.getProps, data);
//
if (valueType === 'string') {
model[data] = model[data].join(',');
}
}
}
await saveOrUpdate(model, isUpdate.value)
.then((res) => {
if (res.success) {
createMessage.success(res.message);
emit('ok');
} else {
createMessage.warning(res.message);
}
})
.finally(() => {
confirmLoading.value = false;
});
}
defineExpose({
add,
edit,
submitForm,
});
</script>
<style lang="less" scoped>
.antd-modal-form {
min-height: 500px !important;
overflow-y: auto;
padding: 24px 24px 24px 24px;
}
</style>

View File

@ -0,0 +1,75 @@
<template>
<a-modal :title="title" :width="width" :visible="visible" @ok="handleOk" :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }" @cancel="handleCancel" cancelText="关闭">
<ZyTlqContentForm ref="registerForm" @ok="submitCallback" :formDisabled="disableSubmit" :formBpm="false"></ZyTlqContentForm>
</a-modal>
</template>
<script lang="ts" setup>
import { ref, nextTick, defineExpose } from 'vue';
import ZyTlqContentForm from './ZyTlqContentForm.vue'
const title = ref<string>('');
const width = ref<number>(800);
const visible = ref<boolean>(false);
const disableSubmit = ref<boolean>(false);
const registerForm = ref();
const emit = defineEmits(['register', 'success']);
/**
* 新增
*/
function add() {
title.value = '新增';
visible.value = true;
nextTick(() => {
registerForm.value.add();
});
}
/**
* 编辑
* @param record
*/
function edit(record) {
title.value = disableSubmit.value ? '详情' : '编辑';
visible.value = true;
nextTick(() => {
registerForm.value.edit(record);
});
}
/**
* 确定按钮点击事件
*/
function handleOk() {
registerForm.value.submitForm();
}
/**
* form保存回调事件
*/
function submitCallback() {
handleCancel();
emit('success');
}
/**
* 取消按钮回调事件
*/
function handleCancel() {
visible.value = false;
}
defineExpose({
add,
edit,
disableSubmit,
});
</script>
<style>
/**隐藏样式-modal确定按钮 */
.jee-hidden {
display: none !important;
}
</style>