Product.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <a-card :bordered="false">
  3. <div class="table-page-search-wrapper">
  4. <a-form layout="inline">
  5. <a-row :gutter="48">
  6. <a-col :md="8" :sm="24">
  7. <a-form-item label="关键字">
  8. <a-input v-model.trim="queryParam.title" placeholder="请输入名称"/>
  9. </a-form-item>
  10. </a-col>
  11. <a-col :md="8 || 24" :sm="24">
  12. <span class="table-page-search-submitButtons">
  13. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  14. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  15. </span>
  16. </a-col>
  17. </a-row>
  18. </a-form>
  19. </div>
  20. <div class="table-operator" style="margin-bottom: 8px;">
  21. <a-button v-if="$auth('operate-articles-add')" type="primary" icon="plus" @click="$refs.baseModal.base()">新增</a-button>
  22. </div>
  23. <s-table
  24. ref="table"
  25. size="default"
  26. rowKey="id"
  27. :columns="columns"
  28. :data="loadData"
  29. :alert="options.alert"
  30. :rowSelection="options.rowSelection"
  31. showPagination="auto"
  32. >
  33. <span slot="action" slot-scope="record">
  34. <template>
  35. <a @click="handleView(record)">查看</a>
  36. <a-divider type="vertical" />
  37. <a @click="handleEdit(record)">修改</a>
  38. </template>
  39. </span>
  40. </s-table>
  41. <base-form ref="baseModal" @ok="handleOk"/>
  42. <detail ref="detailModal" />
  43. </a-card>
  44. </template>
  45. <script>
  46. import { STable, Ellipsis } from '@/components'
  47. import BaseForm from './modules/BaseForm'
  48. import Detail from './modules/Detail'
  49. import {
  50. getProductPage,
  51. fetchProduct
  52. } from '@/api/qykh/product'
  53. import DictCache from '@/utils/dict'
  54. export default {
  55. name: 'PlanDetailList',
  56. components: {
  57. STable,
  58. Ellipsis,
  59. BaseForm,
  60. Detail
  61. },
  62. data () {
  63. return {
  64. // 查询参数
  65. queryParam: {
  66. },
  67. // 表头
  68. columns: [
  69. {
  70. title: '序号',
  71. dataIndex: 'index',
  72. customRender: (text, record, index) => {
  73. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  74. }
  75. },
  76. {
  77. title: '标题',
  78. dataIndex: 'pname'
  79. },
  80. /* {
  81. title: '摘要',
  82. dataIndex: 'shortdesc'
  83. },
  84. {
  85. title: 'purl',
  86. dataIndex: 'purl'
  87. },
  88. {
  89. title: 'bannerurl',
  90. dataIndex: 'bannerurl'
  91. }, */
  92. {
  93. title: '关键字',
  94. dataIndex: 'keywords'
  95. },
  96. {
  97. title: '排序',
  98. dataIndex: 'ord'
  99. },
  100. {
  101. title: '操作',
  102. key: 'action',
  103. align: 'center',
  104. scopedSlots: { customRender: 'action' }
  105. }
  106. ],
  107. // 加载数据方法 必须为 Promise 对象
  108. loadData: parameter => {
  109. parameter = {
  110. ...parameter,
  111. keyword: this.queryParam.keyword,
  112. dataScope: {
  113. sortBy: 'desc',
  114. sortName: 'update_time'
  115. }
  116. }
  117. return getProductPage(Object.assign(parameter, this.queryParam))
  118. .then(res => {
  119. return res.data
  120. })
  121. },
  122. selectedRowKeys: [],
  123. selectedRows: [],
  124. options: {
  125. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  126. rowSelection: {
  127. selectedRowKeys: this.selectedRowKeys,
  128. onChange: this.onSelectChange
  129. }
  130. },
  131. optionAlertShow: false
  132. }
  133. },
  134. created () {
  135. },
  136. methods: {
  137. tableOption () {
  138. if (!this.optionAlertShow) {
  139. this.options = {
  140. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  141. rowSelection: {
  142. selectedRowKeys: this.selectedRowKeys,
  143. onChange: this.onSelectChange,
  144. getCheckboxProps: record => ({
  145. props: {
  146. disabled: false,
  147. name: record.id + ''
  148. }
  149. })
  150. }
  151. }
  152. this.optionAlertShow = true
  153. } else {
  154. this.options = {
  155. alert: false,
  156. rowSelection: null
  157. }
  158. this.optionAlertShow = false
  159. }
  160. },
  161. handleEdit (record) {
  162. fetchProduct({ id: record.id }).then(res => {
  163. const modal = this.$refs.baseModal
  164. modal.base(res.data)
  165. })
  166. },
  167. handleView (record) {
  168. fetchProduct({ id: record.id }).then(res => {
  169. const modal = this.$refs.detailModal
  170. modal.base(res.data)
  171. })
  172. },
  173. handleOk () {
  174. this.$refs.table.refresh()
  175. },
  176. onSelectChange (selectedRowKeys, selectedRows) {
  177. this.selectedRowKeys = selectedRowKeys
  178. this.selectedRows = selectedRows
  179. },
  180. resetSearchForm () {
  181. this.queryParam = {
  182. }
  183. this.$refs.table.refresh(true)
  184. }
  185. }
  186. }
  187. </script>