Files
mosr-web/src/views/article-management/index.vue

210 lines
4.7 KiB
Vue

<template>
<fvSearchForm :searchConfig="researchFundSearchConfig" @search="searchResearchFund"
style="margin-left: 16px"></fvSearchForm>
<fvTable ref="tableIns" :tableConfig="researchFundTableConfig" @headBtnClick="headBtnClick">
<template #empty>
<el-empty description="暂无数据"/>
</template>
</fvTable>
</template>
<script setup lang="jsx">
import {ElNotification} from "element-plus";
import {deleteArticle} from "@/api/article";
import fvSelect from '@/fvcomponents/fvSelect/index.vue'
const router = useRouter();
const researchFundSearchConfig = reactive([
{
label: '文章标题',
prop: 'articleTitle',
component: 'el-input',
props: {
placeholder: '请输入文章标题查询',
clearable: true,
filterable: true,
checkStrictly: true
}
},
{
label: '文章类型',
prop: 'articleType',
component: shallowRef(fvSelect),
props: {
placeholder: '请选择文章类型',
clearable: true,
filterable: true,
checkStrictly: true,
cacheKey: 'article_type',
remote: true
}
},
{
label: '时间',
prop: 'createTime',
component: 'el-date-picker',
props: {
placeholder: '请选择时间',
clearable: true,
type: 'date',
format: 'YYYY-MM-DD',
valueFormat: "YYYY-MM-DD"
},
colProps: {}
},
])
const tableIns = ref()
const researchFundTableConfig = reactive({
columns: [
{
prop: 'index',
type: 'index',
label: '序号',
align: 'center',
width: 85,
index: index => {
return (tableIns.value.getQuery().pageNum - 1) * tableIns.value.getQuery().pageSize + index + 1
}
},
{
prop: 'articleTitle',
label: '文章标题',
align: 'center'
},
{
prop: 'articleType',
label: '文章类型',
align: 'center',
showOverflowTooltip: false,
currentRender: ({row, index}) => {
if (row.articleType == undefined || row.articleType == null) {
return '--'
} else {
return (<Tag dictType={'article_type'} value={row.articleType}/>)
}
}
},
{
prop: 'createTime',
label: '时间',
align: 'center'
},
{
prop: 'remarks',
label: '备注',
align: 'center'
},
{
prop: 'oper',
label: '操作',
align: 'center',
fixed: 'right',
showOverflowTooltip: false,
currentRender: ({row, index}) => {
let btn = []
btn.push({label: '详情', func: () => handleDetail(row), type: 'primary'})
btn.push({label: '编辑', func: () => handleEdit(row), type: 'primary'})
return (
<div style={{width: '100%'}}>
{
btn.map(item => (
<el-button
type={item.type}
// v-perm={item.prem}
onClick={() => item.func()}
link
>
{item.label}
</el-button>
))
}
{
<popover-delete name={row.articleTitle} type={'文章'} btnType={'danger'}
onDelete={() => handleDelete(row)}/>
}
</div>
)
}
}
],
api: '/workflow/mosr/article/list',
btns: [
{name: '新增', key: 'add', color: '#DED0B2'}
],
params: {}
})
const searchResearchFund = (val) => {
let obj = {...val}
if (obj.dateValue) {
obj.startGenerationTime = obj.dateValue[0]
obj.endGenerationTime = obj.dateValue[1]
delete obj.dateValue
}
researchFundTableConfig.params = obj
tableIns.value.refresh()
}
const headBtnClick = (key) => {
switch (key) {
case 'add':
handleAdd()
break;
}
}
const handleAdd = () => {
router.push({
name: 'Article/add',
query: {}
})
}
const handleDetail = (row) => {
router.push({
name: 'Article/detail',
query: {
id: row.articleId
}
})
}
const handleEdit = (row) => {
router.push({
name: 'Article/edit',
query: {
id: row.articleId
}
})
}
const handleDelete = (row) => {
deleteArticle(row.articleId).then(res => {
ElNotification({
title: '提示',
message: res.msg,
type: res.code === 1000 ? 'success' : 'error'
})
if (res.code === 1000) {
tableIns.value.refresh()
}
});
}
</script>
<style scoped lang="scss">
:deep(.el-table__header) {
.is-leaf:first-child {
.cell {
margin-left: -25px !important;
}
}
}
:deep(.el-table__body) {
.el-table__cell:first-child {
.cell {
margin-left: -13px !important;
}
}
}
:deep(.el-date-editor--month) {
width: 100%;
}
</style>