[update] 添加公告管理

This commit is contained in:
lideqin
2023-07-18 16:49:19 +08:00
parent 7479e7aa7c
commit 8c81312cc0
3 changed files with 287 additions and 0 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

+144
View File
@@ -0,0 +1,144 @@
<template>
<div>
<page-header-title :img-for-icon="IconImg"></page-header-title>
<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="8" :md="8" :sm="24">
<a-form-item label="公告名称">
<a-input placeholder="请输入公告名称" v-model="queryParam.noticeName" :maxLength="50"></a-input>
</a-form-item>
</a-col>
<a-col :xl="6" :lg="8" :md="8" :sm="24">
<a-form-item label="公告内容">
<a-input placeholder="请输入公告内容" v-model="queryParam.noticeContent"></a-input>
</a-form-item>
</a-col>
<a-col :xl="6" :lg="7" :md="8" :sm="24">
<span class="table-page-search-submitButtons">
<!-- v-has="'template:list'"-->
<a-button type="primary" @click="searchQuery" icon="search" v-has="'sysNotice:pageList'">查询</a-button>
<a-button @click="searchReset" icon="reload" class="reset-button" style="margin-left: 8px">重置</a-button>
</span>
</a-col>
</a-row>
</a-form>
</div>
<!-- 操作按钮区域 -->
<div class="table-operator">
<!-- v-has="'template:add:systemNotifications'"-->
<a-button @click="handleAdd" type="primary" icon="plus" v-has="'sysNotice:add'">新增</a-button>
</div>
<!-- table区域-begin -->
<div>
<a-table
ref="table"
size="middle"
bordered
rowKey="id"
:columns="columns"
:dataSource="dataSource"
:pagination="ipagination"
:loading="loading"
:rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
class="j-table-force-nowrap"
@change="handleTableChange">
<!-- 字符串超长截取省略号显示-->
<span slot="templateContent" slot-scope="text">
<a-tooltip>
<template slot="title">
<span v-html="text"></span>
</template>
<span v-html="myEllipsis(text,40)"></span>
</a-tooltip>
</span>
<template slot="text" slot-scope="text">
<j-ellipsis v-if="text" :length="20" :value="text"></j-ellipsis>
<span v-else></span>
</template>
<span slot="action" class="action-span-cell" slot-scope="text, record">
<!-- v-has="'template:list'"-->
<a @click="handleEdit(record)" v-has="'sysNotice:edit'">编辑</a>
<!-- v-has="'template:delete'"-->
<a @click="handleDelete(record.id)" v-has="'sysNotice:deleteById'">删除</a>
</span>
</a-table>
</div>
<!-- table区域-end -->
<!-- 表单区域 -->
<sys-notice-modal ref="modalForm" @ok="modalFormOk"></sys-notice-modal>
</a-card>
</div>
</template>
<script>
import {JeroListMixin} from '@/mixins/JeroListMixin'
import IconImg from '@/assets/imgs/icon/icon_notice.png'
import SysNoticeModal from './modules/SysNoticeModal'
import PageHeaderTitle from '../../../components/layouts/PageHeaderTitle'
export default {
name: 'SysNoticeList',
mixins: [JeroListMixin],
components: {SysNoticeModal, PageHeaderTitle},
data() {
return {
description: '公告管理页面',
IconImg,
// 表头
columns: [
{
title: '序号',
dataIndex: '',
key: 'rowIndex',
width: 60,
align: 'center',
customRender: function (t, r, index) {
return parseInt(index) + 1
}
},
{
title: '公告名称',
align: 'center',
dataIndex: 'noticeName',
scopedSlots: { customRender: 'text' },
width: 300
},
{
title: '公告内容',
align: 'center',
dataIndex: 'noticeContent',
scopedSlots: { customRender: 'text' },
width: 200
},
{
title: '操作',
dataIndex: 'action',
align: 'center',
scopedSlots: { customRender: 'action' },
width: 160
}
],
url: {
list: '/sysNotice/pageList',
delete: '/sysNotice/deleteById',
deleteBatch: '/sysNotice/deleteBatch'
}
}
}
}
</script>
<style scoped lang="less">
@import '~@assets/less/common.less';
</style>
@@ -0,0 +1,143 @@
<template>
<a-modal
:title="title"
:width="800"
:visible="visible"
:confirmLoading="confirmLoading"
@ok="handleOk"
@cancel="handleCancel"
cancelText="关闭">
<a-spin :spinning="confirmLoading">
<a-form :form="form">
<a-form-item
:labelCol="labelCol"
:wrapperCol="wrapperCol"
label="公告名称">
<a-input placeholder="请输入公告名称" v-decorator="['noticeName', validatorRules.noticeName]" :maxLength="50"/>
</a-form-item>
<a-form-item
:labelCol="labelCol"
:wrapperCol="wrapperCol"
label="公告内容">
<a-textarea placeholder="请输入发送内容" v-decorator="['noticeContent', validatorRules.noticeContent]"
:autoSize="{minRows: 3, maxRows: 6}" :maxLength="200"/>
</a-form-item>
<a-form-item
:labelCol="labelCol"
:wrapperCol="wrapperCol"
label="附件">
<j-upload :returnId="true" v-decorator="['noticeFile', validatorRules.noticeFile]"/>
</a-form-item>
<a-form-item
:labelCol="labelCol"
:wrapperCol="wrapperCol"
label="使用状态">
<a-switch checkedChildren="禁用" unCheckedChildren="启用" v-model="model.noticeStatus"/>
</a-form-item>
</a-form>
</a-spin>
</a-modal>
</template>
<script>
import pick from 'lodash.pick'
import { httpAction } from '@/api/manage'
import JUpload from '@/components/jero/JUpload'
export default {
name: 'SysNoticeModal',
components: {JUpload},
data() {
return {
title: '操作',
visible: false,
disable: true,
model: {noticeStatus: false},
labelCol: {
xs: {span: 24},
sm: {span: 5},
},
wrapperCol: {
xs: {span: 24},
sm: {span: 16},
},
confirmLoading: false,
form: this.$form.createForm(this),
disableSubmit: false,
validatorRules: {
noticeName: {rules: [{required: true, message: '请输入公告名称!' }],validateTrigger: 'blur'},
noticeContent: {rules: [{required: true, message: '请选择公告内容!'}],validateTrigger: 'blur'},
noticeFile:{rules: [{required: false, message: '请上传附件!'}],validateTrigger: 'change'}
},
url: {
add: '/sysNotice/add',
edit: '/sysNotice/edit',
}
}
},
methods: {
add() {
this.disable = false
this.edit({})
},
edit(record) {
this.form.resetFields()
this.model = Object.assign({}, record)
if (this.model.id) {
this.model.noticeStatus = (this.model.noticeStatus === 1 ? true : false)
}
console.log(this.model)
this.visible = true
this.$nextTick(() => {
this.form.setFieldsValue(pick(this.model, 'noticeName', 'noticeContent', 'noticeFile'))
})
},
close() {
this.$emit('close')
this.visible = false
this.disable = true
},
handleOk() {
const that = this
// 触发表单验证
this.form.validateFields((err, values) => {
if (!err) {
that.confirmLoading = true
let httpurl = ''
let method = 'post'
if (!this.model.id) {
httpurl += this.url.add
} else {
httpurl += this.url.edit
}
console.log(values)
let formData = Object.assign(this.model, values)
formData.noticeStatus = formData.noticeStatus ? 1 : 0
console.log(formData)
httpAction(httpurl, formData, method).then((res) => {
if (res.success) {
that.$message.success(res.message)
that.$emit('ok')
} else {
that.$message.warning(res.message)
}
}).finally(() => {
that.confirmLoading = false
that.close()
})
}
})
},
handleCancel() {
this.close()
}
}
}
</script>
<style scoped>
</style>