簡書-若依-通知公告模塊升級

<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="公告標題" prop="noticeTitle">
<el-input
v-model="queryParams.noticeTitle"
placeholder="請輸入公告標題"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="操作人員" prop="createBy">
<el-input
v-model="queryParams.createBy"
placeholder="請輸入操作人員"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="類型" prop="noticeType">
<el-select v-model="queryParams.noticeType" placeholder="公告類型" clearable>
<el-option
v-for="dict in dict.type.sys_notice_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>

<el-row :gutter="10" class="mb8">
  <el-col :span="1.5">
    <el-button
      type="primary"
      plain
      icon="el-icon-plus"
      size="mini"
      @click="handleAdd"
      v-hasPermi="['system:notice:add']"
    >新增</el-button>
  </el-col>
  <el-col :span="1.5">
    <el-button
      type="success"
      plain
      icon="el-icon-edit"
      size="mini"
      :disabled="single"
      @click="handleUpdate"
      v-hasPermi="['system:notice:edit']"
    >修改</el-button>
  </el-col>
  <el-col :span="1.5">
    <el-button
      type="danger"
      plain
      icon="el-icon-delete"
      size="mini"
      :disabled="multiple"
      @click="handleDelete"
      v-hasPermi="['system:notice:remove']"
    >刪除</el-button>
  </el-col>
  <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>

<el-table v-loading="loading" :data="noticeList" @selection-change="handleSelectionChange">
  <el-table-column type="selection" width="55" align="center" />
  <el-table-column label="序號" align="center" prop="noticeId" width="100" />
  <el-table-column
    label="公告標題"
    align="center"
    prop="noticeTitle"
    :show-overflow-tooltip="true"
  />
  <el-table-column label="公告類型" align="center" prop="noticeType" width="100">
    <template slot-scope="scope">
      <dict-tag :options="dict.type.sys_notice_type" :value="scope.row.noticeType"/>
    </template>
  </el-table-column>
  <el-table-column label="狀態(tài)" align="center" prop="status" width="100">
    <template slot-scope="scope">
      <dict-tag :options="dict.type.sys_notice_status" :value="scope.row.status"/>
    </template>
  </el-table-column>
  <el-table-column label="創(chuàng)建者" align="center" prop="createBy" width="100" />
  <el-table-column label="創(chuàng)建時間" align="center" prop="createTime" width="100">
    <template slot-scope="scope">
      <span>{{ parseTime(scope.row.createTime, '{y}-{m}-osss887') }}</span>
    </template>
  </el-table-column>
  <el-table-column label="操作" align="center" 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:notice:edit']"
      >修改</el-button>
      <el-button
        size="mini"
        type="text"
        icon="el-icon-delete"
        @click="handleDelete(scope.row)"
        v-hasPermi="['system:notice:remove']"
      >刪除</el-button>
      <el-button
        size="mini"
        type="text"
        icon="el-icon-view"
        @click="openDetailDialog(scope.row.noticeId)"
      >查看</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="780px" append-to-body>
  <el-form ref="form" :model="form" :rules="rules" label-width="80px">
    <el-row>
      <el-col :span="12">
        <el-form-item label="公告標題" prop="noticeTitle">
          <el-input v-model="form.noticeTitle" placeholder="請輸入公告標題" />
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="公告類型" prop="noticeType">
          <el-select v-model="form.noticeType" placeholder="請選擇公告類型">
            <el-option
              v-for="dict in dict.type.sys_notice_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="24">
        <el-form-item label="狀態(tài)">
          <el-radio-group v-model="form.status">
            <el-radio
              v-for="dict in dict.type.sys_notice_status"
              :key="dict.value"
              :label="dict.value"
            >{{dict.label}}</el-radio>
          </el-radio-group>
        </el-form-item>
      </el-col>
      <el-col :span="24">
        <el-form-item label="內容">
          <editor v-model="form.noticeContent" :min-height="192"/>
        </el-form-item>
      </el-col>
    </el-row>
  </el-form>
  <div slot="footer" class="dialog-footer">
    <el-button type="primary" @click="submitForm">確 定</el-button>
    <el-button @click="cancel">取 消</el-button>
  </div>
</el-dialog>


<!--通知公告詳情 -->
<el-dialog :title="form.noticeTitle" :visible.sync="openDetail" width="800px" append-to-body>
  <div style="margin-top:-20px;margin-bottom:10px;">
    <el-tag size="mini" effect="dark" type="warning" v-if="form.noticeType==2">公告</el-tag>
    <el-tag size="mini" effect="dark" v-else>信息</el-tag>
    <span style="margin-left:20px;">{{form.createTime}}</span>
  </div>
  <div v-loading="loadingDetail" class="content">
    <div v-html="form.noticeContent" style="margin-left:0px;margin-right:76px" class="ql-editor"></div>
  </div>
  <div slot="footer" class="dialog-footer">
    <el-button type="primary" @click="closeDetail"> 關 閉 </el-button>
  </div>
</el-dialog>

</div>
</template>

<script>
import { listNotice, getNotice, delNotice, addNotice, updateNotice } from "@/api/system/notice";

export default {
name: "Notice",
dicts: ['sys_notice_status', 'sys_notice_type'],
data() {
return {
// 遮罩層
loading: true,
// 詳情加載
loadingDetail: false,
// 打開詳情
openDetail: false,
// 選中數組
ids: [],
// 非單個禁用
single: true,
// 非多個禁用
multiple: true,
// 顯示搜索條件
showSearch: true,
// 總條數
total: 0,
// 公告表格數據
noticeList: [],
// 彈出層標題
title: "",
// 是否顯示彈出層
open: false,
// 查詢參數
queryParams: {
pageNum: 1,
pageSize: 10,
noticeTitle: undefined,
createBy: undefined,
status: undefined
},
// 表單參數
form: {},
// 表單校驗
rules: {
noticeTitle: [
{ required: true, message: "公告標題不能為空", trigger: "blur" }
],
noticeType: [
{ required: true, message: "公告類型不能為空", trigger: "change" }
]
}
};
},
created() {
this.getList();
},
methods: {
/** 查詢公告列表 /
getList() {
this.loading = true;
listNotice(this.queryParams).then(response => {
this.noticeList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按鈕
cancel() {
this.open = false;
this.reset();
},
// 表單重置
reset() {
this.form = {
noticeId: undefined,
noticeTitle: undefined,
noticeType: undefined,
noticeContent: undefined,
status: "0"
};
this.resetForm("form");
},
/
* 搜索按鈕操作 /
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/
* 重置按鈕操作 /
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多選框選中數據
handleSelectionChange(selection) {
this.ids = selection.map(item => item.noticeId)
this.single = selection.length!=1
this.multiple = !selection.length
},
/
* 新增按鈕操作 /
handleAdd() {
this.reset();
this.open = true;
this.title = "添加公告";
},
/
* 修改按鈕操作 /
handleUpdate(row) {
this.reset();
const noticeId = row.noticeId || this.ids
getNotice(noticeId).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改公告";
});
},
// 打開信息詳情
openDetailDialog(id) {
this.openDetail = true;
this.loadingDetail = true;
getNotice(id).then(response => {
this.form = response.data;
this.openDetail = true;
this.loadingDetail = false;
});
},
// 取消按鈕
closeDetail() {
this.titleDetail = "詳情";
this.openDetail = false;
this.reset();
},
/
* 提交按鈕 */
submitForm: function() {
this.refs["form"].validate(valid => { if (valid) { if (this.form.noticeId != undefined) { updateNotice(this.form).then(response => { this.modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addNotice(this.form).then(response => {
this.modal.msgSuccess("新增成功"); this.open = false; this.getList(); }); } } }); }, /** 刪除按鈕操作 */ handleDelete(row) { const noticeIds = row.noticeId || this.ids this.modal.confirm('是否確認刪除公告編號為"' + noticeIds + '"的數據項?').then(function() {
return delNotice(noticeIds);
}).then(() => {
this.getList();
this.$modal.msgSuccess("刪除成功");
}).catch(() => {});
}
}
};
</script>

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
  • 序言:七十年代末辜膝,一起剝皮案震驚了整個濱河市婴渡,隨后出現的幾起案子,更是在濱河造成了極大的恐慌春寿,老刑警劉巖,帶你破解...
    沈念sama閱讀 221,198評論 6 514
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現場離奇詭異召衔,居然都是意外死亡大审,警方通過查閱死者的電腦和手機蘸际,發(fā)現死者居然都...
    沈念sama閱讀 94,334評論 3 398
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來徒扶,“玉大人粮彤,你說我怎么就攤上這事。” “怎么了导坟?”我有些...
    開封第一講書人閱讀 167,643評論 0 360
  • 文/不壞的土叔 我叫張陵屿良,是天一觀的道長。 經常有香客問我惫周,道長尘惧,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 59,495評論 1 296
  • 正文 為了忘掉前任递递,我火速辦了婚禮喷橙,結果婚禮上,老公的妹妹穿的比我還像新娘登舞。我一直安慰自己重慢,他們只是感情好,可當我...
    茶點故事閱讀 68,502評論 6 397
  • 文/花漫 我一把揭開白布逊躁。 她就那樣靜靜地躺著似踱,像睡著了一般。 火紅的嫁衣襯著肌膚如雪稽煤。 梳的紋絲不亂的頭發(fā)上核芽,一...
    開封第一講書人閱讀 52,156評論 1 308
  • 那天,我揣著相機與錄音酵熙,去河邊找鬼轧简。 笑死,一個胖子當著我的面吹牛匾二,可吹牛的內容都是我干的哮独。 我是一名探鬼主播,決...
    沈念sama閱讀 40,743評論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼察藐,長吁一口氣:“原來是場噩夢啊……” “哼皮璧!你這毒婦竟也來了?” 一聲冷哼從身側響起分飞,我...
    開封第一講書人閱讀 39,659評論 0 276
  • 序言:老撾萬榮一對情侶失蹤悴务,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后譬猫,有當地人在樹林里發(fā)現了一具尸體讯檐,經...
    沈念sama閱讀 46,200評論 1 319
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 38,282評論 3 340
  • 正文 我和宋清朗相戀三年染服,在試婚紗的時候發(fā)現自己被綠了别洪。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 40,424評論 1 352
  • 序言:一個原本活蹦亂跳的男人離奇死亡柳刮,死狀恐怖挖垛,靈堂內的尸體忽然破棺而出痒钝,到底是詐尸還是另有隱情,我是刑警寧澤晕换,帶...
    沈念sama閱讀 36,107評論 5 349
  • 正文 年R本政府宣布午乓,位于F島的核電站站宗,受9級特大地震影響闸准,放射性物質發(fā)生泄漏。R本人自食惡果不足惜梢灭,卻給世界環(huán)境...
    茶點故事閱讀 41,789評論 3 333
  • 文/蒙蒙 一夷家、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧敏释,春花似錦库快、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,264評論 0 23
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至蜂大,卻和暖如春闽铐,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背奶浦。 一陣腳步聲響...
    開封第一講書人閱讀 33,390評論 1 271
  • 我被黑心中介騙來泰國打工兄墅, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人澳叉。 一個月前我還...
    沈念sama閱讀 48,798評論 3 376
  • 正文 我出身青樓隙咸,卻偏偏與公主長得像,于是被迫代替她去往敵國和親成洗。 傳聞我的和親對象是個殘疾皇子五督,可洞房花燭夜當晚...
    茶點故事閱讀 45,435評論 2 359