index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <div class="app-container">
  3. <!-- 筛选 -->
  4. <div class="select-box">
  5. <div class="search-icon">
  6. <i class="el-icon-search"></i>
  7. <span> 筛选搜查</span>
  8. <div class="search-button">
  9. <el-button @click="resetQuery">重置</el-button>
  10. <el-button type="primary" @click="handleQuery">查询搜索</el-button>
  11. </div>
  12. </div>
  13. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="80px">
  14. <el-form-item class="inline" label="公告标题: " prop="noticeTitle" >
  15. <el-input
  16. v-model="queryParams.noticeTitle"
  17. placeholder="筛选公告标题"
  18. clearable
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item class="inline" label="发布时间: " prop="dateRange">
  23. <el-date-picker
  24. v-model="queryParams.dateRange"
  25. type="daterange"
  26. range-separator="至"
  27. start-placeholder="开始日期"
  28. end-placeholder="结束日期"
  29. placeholder="选择时间范围"
  30. value-format="yyyy-MM-dd"
  31. @keyup.enter.native="handleQuery"
  32. unlink-panels >
  33. </el-date-picker>
  34. </el-form-item>
  35. </el-form>
  36. </div>
  37. <!-- 标题 -->
  38. <el-row>
  39. <div class="list-title">
  40. <div class="title">
  41. <span class="el-icon-tickets"></span>
  42. <span class="title-font">公告列表</span>
  43. </div>
  44. <div class="btn-add">
  45. <el-button size="small" type="primary" plain @click="handleAdd()">添加</el-button>
  46. </div>
  47. </div>
  48. </el-row>
  49. <!-- 列表 -->
  50. <el-table v-loading="loading" :data="noticeList" border>
  51. <el-table-column label="ID" align="center" prop="noticeId" width="100" />
  52. <el-table-column
  53. label="公告标题"
  54. align="center"
  55. prop="noticeTitle"
  56. :show-overflow-tooltip="true"
  57. />
  58. <el-table-column label="发布时间" align="center" prop="createTime" width="180">
  59. <template slot-scope="scope">
  60. <span>{{ parseTime(scope.row.createTime) }}</span>
  61. </template>
  62. </el-table-column>
  63. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="170">
  64. <template slot-scope="scope">
  65. <el-button
  66. size="mini"
  67. type="text"
  68. @click="handleDetail(scope.row)"
  69. >查看详情</el-button>
  70. <el-button
  71. size="mini"
  72. type="text"
  73. @click="handleDelete(scope.row)"
  74. >删除</el-button>
  75. </template>
  76. </el-table-column>
  77. </el-table>
  78. <!-- 分页 -->
  79. <el-pagination
  80. background
  81. :current-page="pagination.current"
  82. :page-size="pagination.pageSize"
  83. layout="total, prev, pager, next"
  84. :total="pagination.total"
  85. @pagination="getList"
  86. @current-change="onPageChange"
  87. class="paper"
  88. >
  89. </el-pagination>
  90. </div>
  91. </template>
  92. <script>
  93. import { getNoticeList, deleteNotice } from '@/api/announce/list';
  94. export default {
  95. name: "Notice",
  96. data() {
  97. return {
  98. // 遮罩层
  99. loading: true,
  100. // 公告表格数据
  101. noticeList: [],
  102. // 查询参数
  103. queryParams: {
  104. noticeTitle: undefined,
  105. dateRange:[]
  106. },
  107. // 分页参数
  108. pagination:{
  109. total:0,
  110. current:1,
  111. pageSize:10,
  112. },
  113. };
  114. },
  115. created() {
  116. this.getList();
  117. },
  118. methods: {
  119. /** 查询公告列表 */
  120. getList() {
  121. this.loading = true;
  122. getNoticeList({
  123. pageIndex: this.pagination.current,
  124. pageSize: this.pagination.pageSize,
  125. queryParams:this.queryParams
  126. }).then( res =>{
  127. let data = res.data.data;
  128. this.noticeList = data.noticeList;
  129. this.pagination.total = data.total;
  130. this.pagination.current = data.pageIndex;
  131. this.loading = false;
  132. })
  133. },
  134. /** 搜索按钮操作 */
  135. handleQuery() {
  136. this.pagination.current = 1;
  137. this.getList();
  138. },
  139. /** 重置按钮操作 */
  140. resetQuery() {
  141. this.resetForm("queryForm");
  142. this.handleQuery();
  143. },
  144. /** 新增按钮操作 */
  145. handleAdd() {
  146. this.$router.push({name:"announcementAdd"});
  147. },
  148. // 查看详情
  149. handleDetail(row) {
  150. this.$router.push({name:"announcementDetail",params:{row}});
  151. },
  152. /** 删除按钮操作 */
  153. handleDelete(row) {
  154. const noticeIds = row.noticeId;
  155. this.$modal.confirm('是否确认删除公告编号为"' + noticeIds + '"的数据项?').then(function() {
  156. return deleteNotice({id:noticeIds});
  157. }).then(() => {
  158. this.getList();
  159. this.$modal.msgSuccess("删除成功");
  160. }).catch(() => {});
  161. },
  162. // 页号发生变化
  163. onPageChange(number){
  164. this.pagination.current=number;
  165. this.getList();
  166. }
  167. }
  168. };
  169. </script>
  170. <style lang="scss" scoped>
  171. .el-row {
  172. margin-bottom: 20px;
  173. }
  174. .list-title {
  175. height: 50px;
  176. width: 100%;
  177. border: solid 1px #DCDFE6;
  178. .title {
  179. margin: 14px;
  180. float: left;
  181. }
  182. .title-font {
  183. margin-left: 5px;
  184. }
  185. }
  186. .btn-add {
  187. margin: 10px;
  188. float: right;
  189. }
  190. .select-box{
  191. border: 1px solid rgb(0, 0, 0,0.1);
  192. margin-bottom:20px;
  193. padding: 20px;
  194. }
  195. .inline{
  196. margin-right: 30px;
  197. }
  198. .search-icon{
  199. padding-bottom: 20px
  200. }
  201. .search-button{
  202. float: right;
  203. }
  204. .paper{
  205. float: right;
  206. margin-top: 10px;
  207. }
  208. </style>