list.vue 7.4 KB

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