list.vue 6.9 KB

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