list.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <a-card size="small" :bordered="false" class="rebateSettingsList-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="rebateSettingsList-dealerName" v-model.trim="queryParam.dealerName" allowClear placeholder="请输入经销商名称"/>
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  14. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="rebateSettingsList-refresh">查询</a-button>
  15. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="rebateSettingsList-reset">重置</a-button>
  16. </a-col>
  17. </a-row>
  18. </a-form>
  19. </div>
  20. <!-- 列表 -->
  21. <s-table
  22. class="sTable fixPagination"
  23. ref="table"
  24. :style="{ height: tableHeight+84.5+'px' }"
  25. size="small"
  26. :rowKey="(record) => record.id"
  27. :columns="columns"
  28. :data="loadData"
  29. :scroll="{ y: tableHeight }"
  30. :defaultLoadData="false"
  31. bordered>
  32. <!-- 操作 -->
  33. <template slot="action" slot-scope="text, record">
  34. <a-button
  35. size="small"
  36. type="link"
  37. v-if="$hasPermissions('B_rebateSettings_edit')"
  38. class="button-info"
  39. @click="handleEdit(record)"
  40. id="rebateSettingsList-edit-btn">编辑</a-button>
  41. <span v-else>--</span>
  42. </template>
  43. <!-- 经销商名称 -->
  44. <template slot="jxs" slot-scope="text, record">
  45. <span v-if="record.subDealer">{{ record.subDealer.dealerName }}</span>
  46. <span v-else>--</span>
  47. </template>
  48. <!-- 经销商级别 -->
  49. <template slot="dealerLevel" slot-scope="text, record">
  50. <span v-if="record.subDealer">{{ record.subDealer.provinceName }} > {{ record.subDealer.dealerLevelDictValue }}</span>
  51. <span v-else>--</span>
  52. </template>
  53. <!-- 差价归属 -->
  54. <template slot="cjgs" slot-scope="text, record">
  55. <span v-if="record.supDealer">{{ record.supDealer.dealerName }}</span>
  56. <span v-else>--</span>
  57. </template>
  58. <!-- 归属经销商级别 -->
  59. <template slot="gsjxsjb" slot-scope="text, record">
  60. <span v-if="record.supDealer">{{ record.supDealer.provinceName }} > {{ record.supDealer.dealerLevelDictValue }}</span>
  61. <span v-else>--</span>
  62. </template>
  63. </s-table>
  64. </a-spin>
  65. <!-- 关联下级 -->
  66. <associate-modal :openModal="openModal" :nowData="nowData" @ok="$refs.table.refresh(true)" @close="closeModal" />
  67. </a-card>
  68. </template>
  69. <script>
  70. import { STable, VSelect } from '@/components'
  71. import associateModal from './associateModal.vue'
  72. import { queryRebatePage } from '@/api/dealerRelation'
  73. export default {
  74. components: { STable, VSelect, associateModal },
  75. data () {
  76. return {
  77. spinning: false,
  78. tableHeight: 0,
  79. formItemLayout: {
  80. labelCol: { span: 6 },
  81. wrapperCol: { span: 16 }
  82. },
  83. queryParam: {
  84. dealerName: ''
  85. },
  86. disabled: false, // 查询、重置按钮是否可操作
  87. columns: [
  88. { title: '经销商名称', width: '22.5%', scopedSlots: { customRender: 'jxs' }, align: 'center', ellipsis: true },
  89. { title: '经销商级别', scopedSlots: { customRender: 'dealerLevel' }, align: 'center', width: '22.5%' },
  90. { title: '差价归属', scopedSlots: { customRender: 'cjgs' }, align: 'center', width: '22.5%' },
  91. { title: '归属经销商级别', scopedSlots: { customRender: 'gsjxsjb' }, align: 'center', width: '22.5%' },
  92. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  93. ],
  94. // 加载数据方法 必须为 Promise 对象
  95. loadData: parameter => {
  96. this.disabled = true
  97. this.spinning = true
  98. return queryRebatePage(Object.assign(parameter, this.queryParam)).then(res => {
  99. let data
  100. if (res.status == 200) {
  101. data = res.data
  102. const no = (data.pageNo - 1) * data.pageSize
  103. for (var i = 0; i < data.list.length; i++) {
  104. data.list[i].no = no + i + 1
  105. }
  106. this.disabled = false
  107. }
  108. this.spinning = false
  109. return data
  110. })
  111. },
  112. defaultExpandedRowKeys: [], // 树形数据默认展开项
  113. openModal: false, // 新增编辑 弹框
  114. nowData: null // 当前记录数据
  115. }
  116. },
  117. methods: {
  118. // 重置
  119. resetSearchForm () {
  120. this.queryParam.dealerName = ''
  121. this.$refs.table.refresh(true)
  122. },
  123. // 编辑
  124. handleEdit (row) {
  125. this.nowData = row
  126. this.openModal = true
  127. },
  128. // 关闭弹框
  129. closeModal () {
  130. this.nowData = null
  131. this.openModal = false
  132. },
  133. pageInit () {
  134. const _this = this
  135. this.$nextTick(() => { // 页面渲染完成后的回调
  136. _this.setTableH()
  137. })
  138. },
  139. setTableH () {
  140. const tableSearchH = this.$refs.tableSearch.offsetHeight
  141. this.tableHeight = window.innerHeight - tableSearchH - 195
  142. }
  143. },
  144. watch: {
  145. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  146. this.setTableH()
  147. }
  148. },
  149. mounted () {
  150. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  151. this.pageInit()
  152. this.resetSearchForm()
  153. }
  154. },
  155. activated () {
  156. // 如果是新页签打开,则重置当前页面
  157. if (this.$store.state.app.isNewTab) {
  158. this.pageInit()
  159. this.resetSearchForm()
  160. }
  161. // 仅刷新列表,不重置页面
  162. if (this.$store.state.app.updateList) {
  163. this.pageInit()
  164. this.$refs.table.refresh()
  165. }
  166. }
  167. }
  168. </script>