list.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template>
  2. <a-card size="small" :bordered="false" class="noticeManagementList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper">
  6. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  7. <a-row :gutter="15">
  8. <a-col :md="6" :sm="24">
  9. <a-form-item label="标题">
  10. <a-input id="noticeManagementList-title" v-model.trim="queryParam.title" allowClear placeholder="请输入标题"/>
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-item label="类别">
  15. <v-select code="NOTITY_BIZ_TYPE" id="noticeManagementList-type" v-model="queryParam.type" allowClear placeholder="请选择类别"></v-select>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-form-item label="发布状态">
  20. <v-select code="NOTITY_SEND_STATUS" id="noticeManagementList-sendStatus" v-model="queryParam.sendStatus" allowClear placeholder="请选择发布状态"></v-select>
  21. </a-form-item>
  22. </a-col>
  23. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  24. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="noticeManagementList-refresh">查询</a-button>
  25. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="noticeManagementList-reset">重置</a-button>
  26. </a-col>
  27. </a-row>
  28. </a-form>
  29. </div>
  30. <!-- 操作按钮 -->
  31. <div class="table-operator">
  32. <a-button id="noticeManagementList-add" type="primary" class="button-error" @click="handleAdd">新增</a-button>
  33. </div>
  34. <!-- 总计 -->
  35. <!-- <a-alert type="info" style="margin-bottom:10px">
  36. <div slot="message">合计:<strong>{{ total || 0 }}</strong>条</div>
  37. </a-alert> -->
  38. <!-- 列表 -->
  39. <s-table
  40. class="sTable fixPagination"
  41. ref="table"
  42. :style="{ height: tableHeight+84.5+'px' }"
  43. size="small"
  44. :rowKey="(record) => record.id"
  45. :columns="columns"
  46. :data="loadData"
  47. :scroll="{ y: tableHeight }"
  48. :defaultLoadData="false"
  49. bordered>
  50. <!-- 操作 -->
  51. <template slot="action" slot-scope="text, record">
  52. <a-button
  53. size="small"
  54. type="link"
  55. class="button-info"
  56. v-if="record.sendStatus=='0'"
  57. @click="handleEdit(record)"
  58. id="noticeManagementList-edit-btn">编辑</a-button>
  59. <a-button
  60. size="small"
  61. type="link"
  62. class="button-success"
  63. v-if="record.sendStatus=='1'"
  64. @click="handleDetail(record)"
  65. id="noticeManagementList-detail-btn">详情</a-button>
  66. <a-button
  67. size="small"
  68. type="link"
  69. class="button-error"
  70. v-if="record.sendStatus=='0'"
  71. @click="handleDel(record)"
  72. id="noticeManagementList-del-btn">删除</a-button>
  73. </template>
  74. </s-table>
  75. </a-spin>
  76. <!-- 编辑 -->
  77. <notice-edit-modal :openModal="openModal" :itemId="itemId" @close="closeModal" @ok="$refs.table.refresh()" />
  78. <!-- 详情 -->
  79. <notice-detail-modal :openModal="openDetailModal" :itemId="itemId" @close="closeDetailModal" />
  80. </a-card>
  81. </template>
  82. <script>
  83. import { STable, VSelect } from '@/components'
  84. import noticeEditModal from './editModal.vue'
  85. import noticeDetailModal from './detailModal.vue'
  86. import { noticeList, noticeDel } from '@/api/notice'
  87. export default {
  88. components: { STable, VSelect, noticeEditModal, noticeDetailModal },
  89. data () {
  90. return {
  91. spinning: false,
  92. tableHeight: 0,
  93. queryParam: { // 查询条件
  94. title: '',
  95. type: undefined,
  96. sendStatus: undefined
  97. },
  98. disabled: false, // 查询、重置按钮是否可操作
  99. columns: [
  100. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  101. { title: '创建时间', dataIndex: 'createDate', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  102. { title: '类别', dataIndex: 'typeDictValue', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  103. { title: '标题', dataIndex: 'title', align: 'center', width: '25%', customRender: function (text) { return text || '--' }, ellipsis: true },
  104. { title: '可见性', dataIndex: 'toAppNameDictValue', width: '9%', align: 'center', customRender: function (text) { return text || '--' } },
  105. { title: '发布时间', dataIndex: 'releaseDate', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  106. { title: '发布状态', dataIndex: 'sendStatusDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  107. { title: '操作', scopedSlots: { customRender: 'action' }, width: '15%', align: 'center' }
  108. ],
  109. // 加载数据方法 必须为 Promise 对象
  110. loadData: parameter => {
  111. this.disabled = true
  112. this.spinning = true
  113. return noticeList(Object.assign(parameter, this.queryParam)).then(res => {
  114. const data = res.data
  115. const no = (data.pageNo - 1) * data.pageSize
  116. for (var i = 0; i < data.list.length; i++) {
  117. data.list[i].no = no + i + 1
  118. data.list[i].typeDictValue = data.list[i].type == 'notity' ? '公告' : data.list[i].type == 'news_company' ? '企业新闻' : data.list[i].type == 'news_trade' ? '行业咨询' : '--'
  119. data.list[i].sendStatusDictValue = data.list[i].sendStatus == 1 ? '已发布' : data.list[i].sendStatus == 0 ? '未发布' : '--'
  120. data.list[i].toAppNameDictValue = data.list[i].toAppName == '1,2' ? '所有' : data.list[i].toAppName == '2' ? '经销商' : data.list[i].toAppName == '1' ? '总部' : '--'
  121. }
  122. this.total = data.count || 0
  123. this.disabled = false
  124. this.spinning = false
  125. return data
  126. })
  127. },
  128. total: 0, // 合计
  129. openModal: false, // 编辑 弹框
  130. openDetailModal: false, // 详情 弹框
  131. itemId: '' // 当前产品id
  132. }
  133. },
  134. methods: {
  135. // 重置
  136. resetSearchForm () {
  137. this.queryParam.title = ''
  138. this.queryParam.type = undefined
  139. this.queryParam.sendStatus = undefined
  140. this.$refs.table.refresh(true)
  141. },
  142. // 详情
  143. handleDetail (row) {
  144. this.itemId = row.id
  145. this.openDetailModal = true
  146. },
  147. // 新增
  148. handleAdd () {
  149. this.itemId = ''
  150. this.openModal = true
  151. },
  152. // 编辑
  153. handleEdit (row) {
  154. this.itemId = row.id
  155. this.openModal = true
  156. },
  157. // 关闭弹框
  158. closeModal () {
  159. this.itemId = ''
  160. this.openModal = false
  161. },
  162. // 关闭详情弹框
  163. closeDetailModal () {
  164. this.itemId = ''
  165. this.openDetailModal = false
  166. },
  167. // 删除
  168. handleDel (row) {
  169. const _this = this
  170. this.$confirm({
  171. title: '提示',
  172. content: '确认要删除吗?',
  173. centered: true,
  174. onOk () {
  175. _this.spinning = true
  176. noticeDel({ id: row.id }).then(res => {
  177. if (res.status == 200) {
  178. _this.$message.success(res.message)
  179. _this.$refs.table.refresh()
  180. _this.spinning = false
  181. } else {
  182. _this.spinning = false
  183. }
  184. })
  185. }
  186. })
  187. },
  188. pageInit () {
  189. const _this = this
  190. this.$nextTick(() => { // 页面渲染完成后的回调
  191. _this.setTableH()
  192. })
  193. },
  194. setTableH () {
  195. const tableSearchH = this.$refs.tableSearch.offsetHeight
  196. this.tableHeight = window.innerHeight - tableSearchH - 235
  197. }
  198. },
  199. mounted () {
  200. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  201. this.pageInit()
  202. this.resetSearchForm()
  203. }
  204. },
  205. activated () {
  206. // 如果是新页签打开,则重置当前页面
  207. if (this.$store.state.app.isNewTab) {
  208. this.pageInit()
  209. this.resetSearchForm()
  210. }
  211. // 仅刷新列表,不重置页面
  212. if (this.$store.state.app.updateList) {
  213. this.pageInit()
  214. this.$refs.table.refresh()
  215. }
  216. }
  217. }
  218. </script>