1
0

index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" @submit.native.prevent>
  4. <el-form-item label="标题" prop="title">
  5. <el-input v-model="queryParams.title" placeholder="请输入标题" @keyup.enter.native="handleQuery" clearable />
  6. </el-form-item>
  7. <el-form-item label="状态" prop="state">
  8. <el-select v-model="queryParams.state" placeholder="状态" class="se" clearable>
  9. <el-option value="0" label="启用"></el-option>
  10. <el-option value="1" label="禁用"></el-option>
  11. </el-select>
  12. </el-form-item>
  13. <el-form-item>
  14. <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
  15. <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
  16. </el-form-item>
  17. </el-form>
  18. <el-row :gutter="10" class="mb8">
  19. <el-button type="primary" icon="el-icon-plus" :disabled="ids.length > 0" @click="op('add')" v-hasPermi="['work:notice:add']">新增</el-button>
  20. <el-button type="success" icon="el-icon-edit" :disabled="ids.length != 1" @click="op('edit', ids)" v-hasPermi="['work:notice:edit']">修改</el-button>
  21. <el-button type="danger" icon="el-icon-delete" :disabled="ids.length == 0" @click="del" v-hasPermi="['work:notice:remove']">删除{{ ids.length > 0 ? '(' + ids.length + ')' : '' }}</el-button>
  22. </el-row>
  23. <el-table :data="response.rows" border @selection-change="selects" height="calc(100vh - 270px)">
  24. <el-table-column type="selection" width="55" align="center" />
  25. <el-table-column label="通知标题" align="center" prop="title" />
  26. <el-table-column label="是否置顶" align="center" prop="top" width="140">
  27. <template slot-scope="scope">
  28. <el-tag type="success" v-if="scope.row.top == 1">是</el-tag>
  29. <el-tag type="info" v-else>否</el-tag>
  30. </template>
  31. </el-table-column>
  32. <el-table-column label="通知状态" align="center" prop="state" width="140">
  33. <template slot-scope="scope">
  34. <el-tag type="success" v-if="scope.row.state == 0">启用</el-tag>
  35. <el-tag type="danger" v-if="scope.row.state == 1">停用</el-tag>
  36. </template>
  37. </el-table-column>
  38. <el-table-column label="创建时间" align="center" prop="createTime" width="200" />
  39. <el-table-column label="操作" align="center" width="200">
  40. <template slot-scope="scope">
  41. <el-button size="mini" type="text" icon="el-icon-edit" @click="op('edit', scope.row)" v-hasPermi="['work:notice:edit']">修改</el-button>
  42. <el-button size="mini" type="text" icon="el-icon-delete" @click="del(scope.row)" v-hasPermi="['work:notice:remove']">删除</el-button>
  43. </template>
  44. </el-table-column>
  45. <template slot="empty">
  46. <el-empty></el-empty>
  47. </template>
  48. </el-table>
  49. <pagination v-if="response.total > 0" :total="response.total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
  50. </div>
  51. </template>
  52. <script>
  53. import edit from './edit';
  54. export default {
  55. name: 'Notice',
  56. data() {
  57. return {
  58. queryParams: {
  59. pageNum: 1,
  60. pageSize: 10,
  61. title: null,
  62. top: null,
  63. state: null,
  64. orderByColumn: 'id', //排序字段
  65. isAsc: 'desc' //排序方式
  66. }
  67. };
  68. },
  69. created() {
  70. this.getList();
  71. },
  72. methods: {
  73. getList() {
  74. this.ajax({ url: '/work/notice/list', data: this.queryParams }).then((response) => {
  75. this.response = response;
  76. });
  77. },
  78. handleQuery() {
  79. this.queryParams.pageNum = 1;
  80. this.getList();
  81. },
  82. resetQuery() {
  83. this.resetForm('queryForm');
  84. this.handleQuery();
  85. },
  86. selects(rows) {
  87. this.ids = rows.map((item) => item.id);
  88. },
  89. op(tag, row) {
  90. if (tag == 'add') {
  91. this.iframe({ obj: edit, param: {}, title: '新增', width: '58%', height: '65%' });
  92. }
  93. if (tag == 'edit') {
  94. const id = row.id || this.ids[0];
  95. this.iframe({ obj: edit, param: { id: id }, title: '编辑', width: '58%', height: '65%' });
  96. }
  97. },
  98. del(row) {
  99. this.$confirm('是否确认删除选中数据?', '警告', { type: 'warning' }).then(() => {
  100. this.get({ url: '/work/notice/remove/' + (row.id || this.ids) }).then((response) => {
  101. this.$modal.msgSuccess('删除成功');
  102. this.getList();
  103. });
  104. });
  105. }
  106. }
  107. };
  108. </script>