bibi 3 years ago
parent c123e77767
commit 1c3e0d5aaf

@ -0,0 +1,38 @@
import httpService from "@/request"
// 公告列表
export function announcementList(params) {
return httpService({
url: `/user/announcement/list`,
method: 'get',
params: params,
})
}
export function announcementInfo(params) {
return httpService({
url: `/user/announcement/findById`,
method: 'get',
params: params,
})
}
export function announcementInsert(params) {
return httpService({
url: `/user/announcement/insert`,
method: 'post',
data: params,
})
}
export function announcementDel(params) {
return httpService({
url: `/user/announcement/delete`,
method: 'post',
data: params,
})
}
export function announcementUpdate(params) {
return httpService({
url: `/user/announcement/update`,
method: 'post',
data: params,
})
}

@ -26,7 +26,7 @@ export const columns = [
{
title: "状态",
dataIndex: "status",
width: "16%",
width: "12%",
customRender: function (status) {
switch (status) {
case 1:

@ -0,0 +1,114 @@
export const formItem = [
{
type: 'input',
label:'标题',
prop:'title',
placeholder:'请输入'
},
{
type: 'select',
label:'推送对象',
prop:'object',
option:[{ id:1,name:'全部'},{ id:2,name:'住户'},{ id:3,name:'业主'},{ id:4,name:'租户'},{ id:5,name:'管家'}],
placeholder:'请选择'
},
{
type: 'select',
label:'发布状态',
prop:'status',
option:[{ id:1,name:'未发布'},{ id:2,name:'已发布'}],
placeholder:'请选择'
},
{
type: 'time',
label:'更新时间',
start: 'modifyStartTime',
end:'modifyEndTime'
},
]
export const columns = [
{
title: "标题",
dataIndex: "title",
width: "16%",
},
{
title: "推送对象",
dataIndex: "object",
width: "10%",
customRender: function (object) {
switch (object) {
case 1:
return '全部'
break;
case 2:
return '住户'
break;
case 3:
return '业主'
break;
case 4:
return '租户'
break;
case 5:
return '管家'
break;
default:
break;
}
}
},
{
title: "状态",
dataIndex: "status",
width: "10%",
customRender: function (status) {
switch (status) {
case 1:
return '未发布'
break;
case 2:
return '已发布'
break;
default:
break;
}
}
},
{
title: "内容",
dataIndex: "content",
width: "13%",
},
{
title: "阅读量",
dataIndex: "readingVolume",
width: "10%",
},
{
title: "附件下载次数",
dataIndex: "downloadNum",
width: "10%",
},
{
title: "更新时间",
dataIndex: "modifyDate",
width: "14%",
},
{
title: "操作",
dataIndex: "action",
key: "action",
width: "180",
fixed: "right",
scopedSlots: { customRender: "action" },
},
]
export const pagination = {
current: 1,
total: 0,
pageSize: 10,
showTotal: (total) => `${total}`,
showSizeChanger: true,
showQuickJumper: true,
}

@ -0,0 +1,28 @@
export const form = {
id:undefined,
title:undefined,
object:undefined,
status:undefined,
content:undefined,
coverImgUrls:[],
annexUrls:[],
}
export const rules = {
title:[{required:true,message:'请输入标题',trigger:'blur'}],
object:[{required:true,message:'请选择',trigger:'change'}],
status:[{required:true,message:'请选择',trigger:'change'}],
content:[{required:true,message:'请输入标题',trigger:'blur'}],
}
export const options = {
status:[
{ id:1, name:'未发布' },
{ id:2, name:'已发布' },
],
object:[
{ id:1, name:'全部' },
{ id:2, name:'住户' },
{ id:3, name:'业主' },
{ id:4, name:'租户' },
{ id:5, name:'管家' },
],
}

@ -0,0 +1,239 @@
<template>
<div>
<a-drawer
:title="title"
:width="720"
:visible="show"
:body-style="{ paddingBottom: '80px' }"
@close="addClose"
>
<div class="drawer-content">
基本信息
<a-divider></a-divider>
<a-form-model
ref="ruleForm"
:model="form"
:rules="rules"
layout="vertical"
>
<a-form-model-item prop="title" label="标题">
<a-input
v-model="form.title"
placeholder="请输入标题"
style="width: 80%"
></a-input>
</a-form-model-item>
<a-form-model-item prop="object" label="推送对象">
<a-select
v-model="form.object"
placeholder="请选择"
style="width: 80%"
>
<a-select-option
v-for="item in options.object"
:key="item.id"
:value="item.id"
>{{ item.name }}</a-select-option
>
</a-select>
</a-form-model-item>
<a-form-model-item prop="status" label="状态">
<a-select
v-model="form.status"
placeholder="请选择"
style="width: 80%"
>
<a-select-option
v-for="item in options.status"
:key="item.id"
:value="item.id"
>{{ item.name }}</a-select-option
>
</a-select>
</a-form-model-item>
<a-form-model-item prop="content" label="内容">
<a-textarea
v-model="form.content"
placeholder="请输入内容"
style="width: 80%"
></a-textarea>
</a-form-model-item>
封面图片
<commonUpload
:fileList="fileList"
@handleChange="handleChange"
></commonUpload>
附件
<a-upload
name="file"
:multiple="true"
:action="`${$upload}`"
:file-list="documentList"
accept=".doc,.DOC,.xls,.XLS,.xlsx,.XLSX,.pdf,.PDF"
:headers="uploadHeaders"
@change="changeFile"
>
<a-button> <a-icon type="upload" /> 上传附件</a-button>
</a-upload>
</a-form-model>
</div>
<div class="drawer-footer">
<a-button :style="{ marginRight: '8px' }" @click="addClose">
关闭
</a-button>
<a-button type="primary" @click="submit"> </a-button>
</div>
</a-drawer>
</div>
</template>
<script>
import store from "@/store";
import { form, rules, options } from "./form.js";
import {
announcementInsert,
announcementUpdate,
announcementInfo,
} from "@/api/operation/announcement";
export default {
props: {
show: {
type: Boolean,
default: false,
},
editId: Number,
},
data() {
return {
title: "新增公告",
form,
rules,
options,
fileList: [],
documentList: [],
uploadHeaders: {
"manage-login-token": store.getters.getToken,
},
};
},
methods: {
addClose() {
this.$refs.ruleForm.resetFields();
this.fileList = [];
this.documentList = [];
this.$emit("addClose");
},
success() {
this.$emit("success");
this.addClose();
},
submit() {
console.log(this.documentList);
let arr = [];
for (let k of this.documentList) {
if (k.response) {
arr.push(k.response.data);
} else {
arr.push(k.url.split("/")[k.url.split("/").length - 1]);
}
}
this.form.annexUrls = arr;
console.log(this.form);
this.$refs.ruleForm.validate(async (valid) => {
if (valid) {
if (this.editId === null) {
let res = await announcementInsert(this.form);
if (res.code === 200) {
this.$message.success(res.msg);
this.success();
} else {
this.$message.error(res.msg);
}
} else {
console.log(this.form);
let res = await announcementUpdate(this.form);
if (res.code === 200) {
this.$message.success(res.msg);
this.success();
} else {
this.$message.error(res.msg);
}
}
}
});
},
changeFile(info) {
this.documentList = info.fileList;
if (info.file.status !== "uploading") {
console.log(info.file, info.fileList);
}
if (info.file.status === "done") {
this.$message.success(`${info.file.name} 上传成功`);
// this.form.annexUrls.push(info.file.response.data);
} else if (info.file.status === "error") {
this.$message.error(`${info.file.name} 上传失败`);
}
},
handleChange(data) {
this.fileList = data;
this.form.coverImgUrls = [];
if (data[0].status === "done") {
console.log("-------done-------");
this.form.coverImgUrls.push(data[0].response.data);
}
},
},
watch: {
editId: {
handler(val) {
if (val !== null) {
this.title = "修改公告";
this.form.id = val;
announcementInfo({ announcementId: val }).then((res) => {
this.form = res.data;
if (res.data.coverImgList.length > 0) {
console.log(res.data.coverImgList);
const pic = [];
for (let item of res.data.coverImgList) {
let obj = {
name: item.url.split("_")[0] + "." + item.url.split(".")[1],
url: this.$ImgUrl(item.url),
uid: item.url.split("_")[1],
status: "done",
thumbUrl: this.$ImgUrl(item.url),
};
pic.push(obj);
}
this.fileList = pic;
} else {
this.form.coverImgList = [];
}
if (res.data.annexImgList.length > 0) {
console.log(res.data.annexImgList);
const file = [];
for (let item of res.data.annexImgList) {
let obj = {
name: item.url.split("_")[0] + "." + item.url.split(".")[1],
url: this.$ImgUrl(item.url),
uid: item.url.split("_")[1],
status: "done",
thumbUrl: this.$ImgUrl(item.url),
};
file.push(obj);
}
this.documentList = file;
} else {
this.form.coverImgList = [];
}
});
} else {
this.title = "新增公告";
}
},
immediate: true,
},
},
};
</script>
<style></style>

@ -1,15 +1,163 @@
<template>
<div>
<div class="cardTitle">公告</div>
<searchForm :formItem="formItem" @getSearch="getData($event)"></searchForm>
<a-button style="margin: 10px" class="add-btn" @click="drawer.show = true"
>新增公告</a-button
>
<a-table
:columns="columns"
:data-source="tableData"
:pagination="pagination"
:scroll="{ x: 1600 }"
@change="handleTableChange"
:row-selection="{
selectedRowKeys: selectedRowKeys,
onChange: selectionChoosed,
}"
:row-key="
(record, index) => {
return record.id;
}
"
>
<span slot="action" slot-scope="text, row">
<a-space>
<a class="ant-dropdown-link" @click="edit(row.id)"></a>
<a class="ant-dropdown-link" @click="del([row.id])"></a>
</a-space>
</span>
</a-table>
<div class="action">
<a-dropdown :disabled="!hasSelected">
<a-menu slot="overlay" @click="handleMenuClick">
<a-menu-item key="del"> 批量删除 </a-menu-item>
</a-menu>
<a-button> 批量操作 <a-icon type="down" /> </a-button>
</a-dropdown>
<span style="margin-left: 8px">
<template v-if="hasSelected">
{{ `已选择 ${selectedRowKeys.length}` }}
</template>
</span>
</div>
<addForm
:show="drawer.show"
@success="success"
@addClose="addClose"
:editId="editId"
></addForm>
</div>
</template>
<script>
import { announcementList, announcementDel } from "@/api/operation/announcement";
import { formItem, columns, pagination } from "./depend/config";
import addForm from "./depend/form.vue";
export default {
}
components: {
addForm,
},
data() {
return {
drawer: {
show: false,
},
editId: null,
tableData: [],
searchForm: {
title:undefined,
status:undefined,
object:undefined,
modifyStartTime:undefined,
modifyEndTime:undefined,
},
formItem,
columns,
pagination,
// index
selectedRowKeys: [],
};
},
mounted() {
this.getData();
},
methods: {
async getData(data) {
if (data !== undefined) {
console.log(data);
this.searchForm = data;
console.log(this.searchForm);
}
let res = await announcementList({
pageNum: this.pagination.current,
size: this.pagination.pageSize,
...this.searchForm
});
this.tableData = res.data.rows;
this.pagination.total = res.data.total;
this.selectedRowKeys=[]
},
edit(id) {
this.editId = id;
this.drawer.show = true;
},
del(ids) {
console.log(ids);
this.$confirm({
title: "是否删除",
// okText:'',
// cancelText:'',
icon: "delete",
onOk: async () => {
let res = await announcementDel({ activityOrganizerIds: ids });
if (res.code === 200) {
this.$message.success(res.msg);
this.getData();
} else {
this.$message.error(res.msg);
}
},
});
},
// id
selectionChoosed(data) {
this.selectedRowKeys = data;
},
//
handleMenuClick(data) {
console.log(data);
if (data.key === "del") {
this.del(this.selectedRowKeys);
}
},
//
handleTableChange(pagination) {
console.log(pagination);
const pager = { ...this.pagination };
pager.current = pagination.current;
pager.pageSize = pagination.pageSize;
this.pagination = pager;
this.getData();
},
addClose() {
this.drawer.show = false;
this.editId = null;
},
success() {
this.getData();
},
},
computed: {
hasSelected() {
return this.selectedRowKeys.length > 0;
},
},
};
</script>
<style>
<style lang="less" scoped>
.table-img {
width: 40px;
height: 40px;
}
</style>
Loading…
Cancel
Save