提交 e1256285 authored 作者: huang's avatar huang

添加模块菜单

上级 d3b5272d
......@@ -30,9 +30,33 @@ export function addAnnouncement(data) {
export function getAnnouncement(data) {
return request({
url: '/announcement/getAnnouncement',
method: 'get',
method: 'post',
data: data
})
}
// update announcement
export function updateAnnouncement(data) {
return request({
url: '/announcement/updateAnnouncement',
method: 'post',
data: data
})
}
//delete announce
export function delAnnouncement(ids) {
return request({
url: '/announcement/delAnnouncement/'+ids,
method: 'delete'
})
}
//activate announcement
export function activateAnnouncement(ids) {
return request({
url: '/announcement/activateAnnouncement/'+ids,
method: 'get'
})
}
......@@ -4,7 +4,7 @@
<div style="background:#eee;padding: 20px;margin-bottom: 20px">
<Card :bordered="false">
<p slot="title">当前公告通知</p>
<p v-if="announcement==null">通知公告为空哦~快去添加吧</p>
<p v-if="announcement==null">通知公告为空哦~快去添加吧或选择一个吧!!</p>
<p v-else v-text="announcement.content"></p>
</Card>
</div>
......@@ -19,6 +19,9 @@
<el-col :span="1.5">
<el-button type="danger" icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['system:user:remove']" >删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" icon="el-icon-delete" size="mini" :disabled="single" @click="handleActivate" v-hasPermi="['system:user:active']" >激活</el-button>
</el-col>
</el-row>
<el-table v-loading="loading" :data="announcementList" @selection-change="handleSelectionChange">
......@@ -29,14 +32,12 @@
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="180" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:user:edit']" >修改</el-button>
<el-button v-if="scope.row.userId !== 1" size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['system:user:remove']" >删除</el-button>
</template>
</el-table-column>
</el-table>
<!--分页按钮组-->
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList"
/>
<!-- 添加或修改公告通知对话框 -->
<el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
......@@ -59,7 +60,7 @@
</div>
</template>
<script>
import { getList,getCurrent,addAnnouncement,getAnnouncement} from "@/api/announcement/announcementList";
import { getList,getCurrent,addAnnouncement,getAnnouncement,updateAnnouncement,delAnnouncement,activateAnnouncement} from "@/api/announcement/announcementList";
export default {
//页签缓存页面的name要和路由中的那么要相同,才能缓存,
//如果是自定义菜单,则页面的name和菜单管理中路由地址要相同,才能页签缓存
......@@ -97,7 +98,8 @@
getList() {
this.loading = true;
getList(this.queryParams).then(response=>{
this.announcementList = response.data
this.announcementList = response.rows
this.total=response.total
this.loading = false
})
},
......@@ -107,6 +109,7 @@
getCurrent().then(response=>{
if (response.data){
this.announcement = response.data
this.loading = false
}
})
},
......@@ -130,14 +133,15 @@
},
//多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.dictId)
this.ids = selection.map(item => item.id)
this.single = selection.length!=1
this.multiple = !selection.length
},
/** 修改按钮操作 */
handleUpdate(row) {
//清空表单
this.reset();
const id = row.id || this.ids
const id = row.id || this.ids[0]
let data ={
id:id
}
......@@ -147,18 +151,34 @@
this.title = "修改公告通知内容";
});
},
/** 激活按钮操作 */
handleActivate(row){
const ids = row.id || this.ids[0]
this.$confirm('激活以在小程序端展示?', "确认", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return activateAnnouncement(ids);
}).then(() => {
//重置
this.getCurrent()
this.msgSuccess("激活成功");
}).catch(function() {});
},
/** 提交按钮 */
submitForm: function() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.dictId != undefined) {
updateType(this.form).then(response => {
if (this.form.id != undefined) {
updateAnnouncement(this.form).then(response => {
if (response.code === 200) {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
} else {
this.msgError(response.msg);
this.msgError("修改失败:"+response.msg);
}
});
} else {
......@@ -177,30 +197,17 @@
},
/** 删除按钮操作 */
handleDelete(row) {
const dictIds = row.dictId || this.ids;
this.$confirm('是否确认删除字典编号为"' + dictIds + '"的数据项?', "警告", {
const ids = row.dictId || this.ids;
this.$confirm('是否确认删除已选中的数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return delType(dictIds);
return delAnnouncement(ids);
}).then(() => {
this.getList();
this.msgSuccess("删除成功");
}).catch(function() {});
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm('是否确认导出所有类型数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return exportType(queryParams);
}).then(response => {
this.download(response.msg);
}).catch(function() {});
}
}
};
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论