announcement.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <!-- 订单 -->
  2. <template>
  3. <div class="order">
  4. <template v-if="!addOrUpdateVisible">
  5. <el-form :inline="true" :model="dataForm" @keyup.enter.native="queryData()">
  6. <el-form-item label="标题">
  7. <el-input v-model="dataForm.title" clearable/>
  8. </el-form-item>
  9. <el-form-item>
  10. <el-button @click="queryData()">查询</el-button>
  11. </el-form-item>
  12. </el-form>
  13. <el-table
  14. :data="dataList"
  15. border
  16. v-loading="dataListLoading"
  17. @selection-change="selectionChangeHandle"
  18. style="width: 100%;">
  19. <el-table-column
  20. label="序号"
  21. type="index"
  22. width="50"
  23. align="center">
  24. </el-table-column>
  25. <el-table-column
  26. prop="title"
  27. header-align="center"
  28. align="center"
  29. width="180"
  30. :show-tooltip-when-overflow="true"
  31. label="公告主题名称">
  32. </el-table-column>
  33. <el-table-column
  34. prop="levelName"
  35. header-align="center"
  36. align="center"
  37. label="级别">
  38. </el-table-column>
  39. <el-table-column
  40. prop="content"
  41. header-align="center"
  42. align="center"
  43. width="200"
  44. :show-tooltip-when-overflow="true"
  45. label="公告内容">
  46. </el-table-column>
  47. <el-table-column
  48. prop="attachList"
  49. header-align="center"
  50. align="center"
  51. min-width="200"
  52. label="附件">
  53. <template slot-scope="scope">
  54. <div v-for="(item, index) in scope.row.attachList" style="display: inline">
  55. <span v-if="index > 0">,</span>
  56. <a :key="item.fileName + index" type="primary" href="#" @click="previewFile(item.fileName, item.url)">{{ item.fileName }}</a>
  57. </div>
  58. </template>
  59. </el-table-column>
  60. <el-table-column
  61. prop="isRead"
  62. header-align="center"
  63. align="center"
  64. label="是否已读">
  65. <template slot-scope="scope">
  66. <span v-if="Number(scope.row.isRead) === 0" style="color: red">未读</span>
  67. <span v-else>已读</span>
  68. </template>
  69. </el-table-column>
  70. <el-table-column
  71. prop="publisherName"
  72. header-align="center"
  73. align="center"
  74. label="发布人">
  75. </el-table-column>
  76. <el-table-column
  77. prop="createTime"
  78. header-align="center"
  79. align="center"
  80. width="160"
  81. label="发布时间">
  82. </el-table-column>
  83. <el-table-column
  84. prop="notes"
  85. header-align="center"
  86. align="center"
  87. width="200"
  88. :show-tooltip-when-overflow="true"
  89. label="备注">
  90. </el-table-column>
  91. <el-table-column
  92. fixed="right"
  93. header-align="center"
  94. align="center"
  95. width="150"
  96. label="操作">
  97. <template slot-scope="scope">
  98. <el-button type="text" size="small" @click="detailHandle(scope.row)">查看</el-button>
  99. </template>
  100. </el-table-column>
  101. </el-table>
  102. <el-pagination
  103. @size-change="sizeChangeHandle"
  104. @current-change="currentChangeHandle"
  105. :current-page="pageIndex"
  106. :page-sizes="[10, 20, 50, 100]"
  107. :page-size="pageSize"
  108. :total="totalPage"
  109. layout="total, sizes, prev, pager, next, jumper">
  110. </el-pagination>
  111. </template>
  112. <!-- 弹窗,详情 -->
  113. <detail v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getAnnouncementList" @onChose="onChose"></detail>
  114. <!-- 文件预览 -->
  115. <preview-component v-if="previewVisible" ref="preview"/>
  116. </div>
  117. </template>
  118. <script>
  119. import Detail from './announcement-detail'
  120. import { getAnnouncementList } from '@/api/msg'
  121. import { getCusList } from '@/api/cus'
  122. import { downloadUrl } from '@/api/file'
  123. import {readNotice} from '@/utils/msg'
  124. import PreviewComponent from '../common/preview-component'
  125. export default {
  126. name: 'announcement',
  127. components: {
  128. PreviewComponent,
  129. Detail
  130. },
  131. created () {
  132. this.optionsState = this.$store.state.common.approveStates
  133. this.queryData()
  134. },
  135. computed: {
  136. // 监听消息ID
  137. listenNotice () {
  138. return this.$route.params.notice
  139. }
  140. },
  141. watch: {
  142. listenNotice: function (notice) {
  143. console.log('notice = ' + JSON.stringify(notice))
  144. if (!notice) return
  145. this.dataForm.noticeId = notice.noticeId
  146. this.dataForm.businessId = notice.businessId
  147. this.queryData()
  148. }
  149. },
  150. data () {
  151. return {
  152. addOrUpdateVisible: false,
  153. previewVisible: false,
  154. dataForm: {},
  155. dataList: [],
  156. pageIndex: 1,
  157. pageSize: 10,
  158. totalPage: 0,
  159. downloadUrl: downloadUrl,
  160. dataListLoading: false,
  161. dataListSelections: [],
  162. optionsState: [],
  163. optionsCustomer: []
  164. }
  165. },
  166. methods: {
  167. onChose () {
  168. this.addOrUpdateVisible = false
  169. },
  170. // 查询
  171. queryData () {
  172. this.pageIndex = 1
  173. this.getAnnouncementList()
  174. },
  175. // 获取数据列表
  176. getAnnouncementList () {
  177. this.dataList = []
  178. this.dataListLoading = true
  179. let params = {
  180. 'current': this.pageIndex,
  181. 'size': this.pageSize,
  182. 'createTime': this.dataForm.createTime ? this.dataForm.createTime : null,
  183. 'state': this.dataForm.state ? this.dataForm.state : null,
  184. 'businessId': this.dataForm.businessId ? this.dataForm.businessId : null
  185. }
  186. getAnnouncementList(params).then(({data}) => {
  187. if (data && data.code === '200') {
  188. this.dataList = data.data.records
  189. this.totalPage = Number(data.data.total)
  190. } else {
  191. this.dataList = []
  192. this.totalPage = 0
  193. }
  194. this.dataListLoading = false
  195. })
  196. },
  197. // 每页数
  198. sizeChangeHandle (val) {
  199. this.pageSize = val
  200. this.pageIndex = 1
  201. this.getAnnouncementList()
  202. },
  203. // 当前页
  204. currentChangeHandle (val) {
  205. this.pageIndex = val
  206. this.getAnnouncementList()
  207. },
  208. // 多选
  209. selectionChangeHandle (val) {
  210. this.dataListSelections = val
  211. },
  212. // 远程方法:获取客户列表
  213. async remoteCustomer (query) {
  214. if (!query) {
  215. query = ''
  216. }
  217. await getCusList({'customerName': query}).then(({data}) => {
  218. if (data && data.code === '200') {
  219. this.optionsCustomer = []
  220. data.data.records.forEach((item) => {
  221. this.optionsCustomer.push({
  222. code: item.customerId,
  223. value: item.customerName
  224. })
  225. })
  226. }
  227. })
  228. },
  229. // 详情
  230. detailHandle (row) {
  231. this.addOrUpdateVisible = true
  232. this.$nextTick(() => {
  233. this.$refs.addOrUpdate.init(row.noticeId)
  234. })
  235. if (row.noticeId) {
  236. readNotice(this, row.noticeId)
  237. }
  238. },
  239. // 预览
  240. previewFile (fileName, url) {
  241. this.previewVisible = true
  242. this.$nextTick(() => {
  243. this.$refs.preview.init(fileName, url)
  244. })
  245. }
  246. }
  247. }
  248. </script>
  249. <style scoped>
  250. </style>