noticeList.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <template>
  2. <div class="ioc-notice-list">
  3. <div class="ioc-notice-list-header">
  4. <span v-if="type==='unReadNotice'">未读通知</span>
  5. <span v-else-if="type==='readNotice'">已读通知</span>
  6. <span v-else-if="type==='allNotice'">全部通知</span>
  7. <span v-else></span>
  8. </div>
  9. <div class="ioc-notice-list-query">
  10. <div style="display: inline-block;vertical-align: middle">
  11. <a-button type="link" @click="setRead" v-if="type!='readNotice'">设为已读</a-button>
  12. <a-popconfirm
  13. title="确定要删除吗?"
  14. ok-text="是"
  15. cancel-text="否"
  16. @confirm="del"
  17. >
  18. <a-button type="link">删除</a-button>
  19. </a-popconfirm>
  20. </div>
  21. <div style="display: inline-block;vertical-align: middle;float: right;">
  22. <a-form layout="inline" :form="formData">
  23. <a-form-item>
  24. <a-select v-model="formData.noticeType" style="width: 120px" placeholder="消息类别">
  25. <a-select-option value="">全部</a-select-option>
  26. <a-select-option value="1">系统通知</a-select-option>
  27. <a-select-option value="2">提醒消息</a-select-option>
  28. <a-select-option value="3">设备告警</a-select-option>
  29. </a-select>
  30. </a-form-item>
  31. <a-form-item>
  32. <TimeRange :time-range.sync="formData.timeRange" ref="timeRange" style="width: 250px"></TimeRange>
  33. </a-form-item>
  34. <a-form-item>
  35. <a-button size="small" @click="refresh">重置</a-button>
  36. <a-button size="small" type="primary" @click="getNotice">查询</a-button>
  37. </a-form-item>
  38. </a-form>
  39. </div>
  40. </div>
  41. <div class="ioc-notice-list-content">
  42. <a-table :rowKey="(record, index) => record.id"
  43. style="height: 100%"
  44. :columns="columns"
  45. :data-source="tableData"
  46. :pagination="false"
  47. :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
  48. >
  49. <template #operation="text">
  50. <a-button type="link">删除</a-button>
  51. <a-button type="link">查看</a-button>
  52. </template>
  53. <template #type="text, record">
  54. <span v-if="record.status==0" style="color: red;padding-right: 5px">•</span>
  55. <span>{{text}}</span>
  56. </template>
  57. </a-table>
  58. <a-pagination
  59. show-size-changer
  60. v-model="page.current"
  61. :page-size="page.pageSize"
  62. :total="page.total"
  63. style="float: right"
  64. />
  65. <br/>
  66. </div>
  67. </div>
  68. </template>
  69. <script>
  70. import TimeRange from "@/components/common/timeRange.vue";
  71. import ApiNotice from "@/api/dashboard/apiNotice";
  72. export default {
  73. components: {TimeRange},
  74. watch: {
  75. type: function (val) {
  76. this.refresh();
  77. },
  78. 'page': {
  79. handler: function (val) {
  80. this.getNotice();
  81. },
  82. deep: true,
  83. }
  84. },
  85. data() {
  86. let timeRange = this.$util.dateUtil.getNearlyMonthRange();
  87. return {
  88. formData: {
  89. noticeType: '',
  90. timeRange: timeRange
  91. },
  92. selectedRowKeys: [],
  93. page: {
  94. current: 1,
  95. pageSize: 10,
  96. total: 20
  97. },
  98. columns: [
  99. {
  100. title: '消息类别',
  101. dataIndex: 'type',
  102. align: 'center',
  103. width: 150,
  104. key: 'type',
  105. scopedSlots: { customRender: 'type' },
  106. },
  107. {
  108. title: '事件内容',
  109. dataIndex: 'content',
  110. align: 'center',
  111. key: 'content'
  112. },
  113. {
  114. title: '地点',
  115. dataIndex: 'area',
  116. align: 'center',
  117. minWidth: 240,
  118. key: 'area'
  119. },
  120. {
  121. title: '通知时间',
  122. dataIndex: 'time',
  123. align: 'center',
  124. width: 240,
  125. key: 'time'
  126. },
  127. {
  128. title: '操作',
  129. dataIndex: 'operation',
  130. key: 'operation',
  131. width: 200,
  132. align: 'center',
  133. scopedSlots: {customRender: 'operation'},
  134. }
  135. ],
  136. tableData: [],
  137. }
  138. },
  139. props: {
  140. type: String,
  141. data: Array,
  142. },
  143. mounted() {
  144. this.getNotice();
  145. },
  146. methods: {
  147. refresh() {
  148. this.formData = {};
  149. this.selectedRowKeys = [];
  150. this.getNotice();
  151. },
  152. onSelectChange(selectedRowKeys) {
  153. this.selectedRowKeys = selectedRowKeys;
  154. },
  155. getNotice() {
  156. let status = this.type == 'unReadNotice' ? '0' : this.type == 'readNotice' ? '1' : '';
  157. let param = {
  158. type: this.formData.noticeType,
  159. status: status,
  160. pageStart: (this.page.current-1)*this.page.pageSize,
  161. pageSize: this.page.pageSize,
  162. }
  163. Object.assign(param, this.formData.timeRange)
  164. ApiNotice.getNoticeList(param).then(res => {
  165. this.tableData = res.data;
  166. this.page.total = res.total;
  167. })
  168. },
  169. del() {
  170. let param = this.selectedRowKeys;
  171. ApiNotice.delNotice(param).then(res=>{
  172. this.$message.success('删除成功');
  173. this.getNotice();
  174. this.selectedRowKeys = []
  175. })
  176. },
  177. setRead() {
  178. let param = this.selectedRowKeys;
  179. ApiNotice.readNotice(param).then(res=>{
  180. this.$message.success('操作成功');
  181. this.getNotice();
  182. this.selectedRowKeys = []
  183. })
  184. }
  185. }
  186. }
  187. </script>
  188. <style lang="less" scoped>
  189. .ioc-notice-list {
  190. width: 100%;
  191. height: 100%;
  192. .ioc-notice-list-header {
  193. font-size: 16px;
  194. }
  195. .ioc-notice-list-query {
  196. margin: 12px 0;
  197. }
  198. .ioc-notice-list-content {
  199. height: 600px;
  200. }
  201. }
  202. </style>