list.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <div>
  3. <a-card size="small" :bordered="false">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper newTableSearchName">
  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-model-item label="所属区域/分区">
  10. <subarea id="dealerZoneSearch-subareaSn" ref="subarea" @change="subareaChange"></subarea>
  11. </a-form-model-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-item label="经销商">
  15. <custList id="dealerZoneSearch-dealerName" placeholder="请输入经销商名称搜索" ref="indirectDealer" @change="dealerChange" />
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="8" :sm="24">
  19. <a-form-item label="客服/区域负责人/销售总监">
  20. <a-input id="dealerZoneSearch-dealerName" v-model.trim="queryParam.bizUserName" allowClear placeholder="请输入客服/区域负责人/销售总监"/>
  21. </a-form-item>
  22. </a-col>
  23. <a-col :md="24" :sm="24" style="margin-top: 10px;text-align:center;">
  24. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="dealerZoneSearch-refresh">查询</a-button>
  25. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="dealerZoneSearch-reset">重置</a-button>
  26. <a-button
  27. style="margin-left: 5px"
  28. type="primary"
  29. class="button-warning"
  30. @click="handleExport"
  31. :loading="exportLoading"
  32. id="dealerZoneSearch-export">导出</a-button>
  33. </a-col>
  34. </a-row>
  35. </a-form>
  36. </div>
  37. </a-card>
  38. <a-card size="small" :bordered="false" class="dealerZoneSearch-wrap">
  39. <a-spin :spinning="spinning" tip="Loading...">
  40. <!-- 列表 -->
  41. <s-table
  42. class="sTable fixPagination"
  43. ref="table"
  44. :style="{ height: tableHeight+84.5+'px' }"
  45. size="small"
  46. :rowKey="(record) => record.no"
  47. rowKeyName="no"
  48. :columns="columns"
  49. :data="loadData"
  50. :scroll="{ y: tableHeight }"
  51. :defaultLoadData="false"
  52. bordered>
  53. <template slot="kf" slot-scope="text, record">
  54. <a-tooltip placement="top" v-if="record.userNameKfs">
  55. <template slot="title">
  56. {{ record.userNameKfs }}
  57. </template>
  58. <div class="line-2">{{ record.userNameKfs }}</div>
  59. </a-tooltip>
  60. <span v-else>--</span>
  61. </template>
  62. <template slot="qyfzr" slot-scope="text, record">
  63. <a-tooltip placement="top" v-if="record.userNameQyfzrs">
  64. <template slot="title">
  65. {{ record.userNameQyfzrs }}
  66. </template>
  67. <div class="line-2">{{ record.userNameQyfzrs }}</div>
  68. </a-tooltip>
  69. <span v-else>--</span>
  70. </template>
  71. <template slot="xszj" slot-scope="text, record">
  72. <a-tooltip placement="top" v-if="record.userNameXszjs">
  73. <template slot="title">
  74. {{ record.userNameXszjs }}
  75. </template>
  76. <div class="line-2">{{ record.userNameXszjs }}</div>
  77. </a-tooltip>
  78. <span v-else>--</span>
  79. </template>
  80. </s-table>
  81. </a-spin>
  82. </a-card>
  83. </div>
  84. </template>
  85. <script>
  86. import { commonMixin } from '@/utils/mixin'
  87. import { STable } from '@/components'
  88. import subarea from '@/views/common/subarea.js'
  89. import { exportExcel } from '@/libs/JGPrint.js'
  90. import { queryDealerWithBizuser, exportDealerWithBizuser } from '@/api/dealerRelation'
  91. import custList from '@/views/common/custList.vue'
  92. export default {
  93. name: 'DealerZoneSearch',
  94. mixins: [commonMixin],
  95. components: { STable, subarea, custList },
  96. data () {
  97. return {
  98. spinning: false,
  99. disabled: false, // 查询、重置按钮是否可操作
  100. tableHeight: 0,
  101. queryParam: {
  102. subareaSn: undefined,
  103. subareaAreaSn: undefined,
  104. dealer: {
  105. dealerSn: '',
  106. dealerName: ''
  107. },
  108. bizUserName: ''
  109. },
  110. exportLoading: false, // 导出loading
  111. columns: [
  112. { title: '经销商名称', dataIndex: 'dealer.dealerName', width: '20%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  113. { title: '所属区域', dataIndex: 'subareaName', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  114. { title: '所属分区', dataIndex: 'subareaAreaName', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  115. { title: '客服', scopedSlots: { customRender: 'kf' }, dataIndex: 'userNameKfs', width: '18%', align: 'center' },
  116. { title: '区域负责人', scopedSlots: { customRender: 'qyfzr' }, dataIndex: 'userNameQyfzrs', width: '18%', align: 'center' },
  117. { title: '销售总监', scopedSlots: { customRender: 'xszj' }, dataIndex: 'userNameXszjs', width: '18%', align: 'center' }
  118. ],
  119. // 加载数据方法 必须为 Promise 对象
  120. loadData: parameter => {
  121. this.disabled = true
  122. this.spinning = true
  123. return queryDealerWithBizuser(Object.assign(parameter, this.queryParam)).then(res => {
  124. let data
  125. if (res.status == 200) {
  126. data = res.data
  127. const no = 0
  128. for (var i = 0; i < data.list.length; i++) {
  129. data.list[i].no = no + i + 1
  130. }
  131. this.disabled = false
  132. }
  133. this.spinning = false
  134. return data
  135. })
  136. }
  137. }
  138. },
  139. methods: {
  140. // 导出
  141. handleExport () {
  142. const _this = this
  143. const params = this.queryParam
  144. this.spinning = true
  145. this.exportLoading = true
  146. exportExcel(exportDealerWithBizuser, params, '经销商所属分区导出', function () {
  147. _this.spinning = false
  148. _this.exportLoading = false
  149. })
  150. },
  151. subareaChange (val) {
  152. this.queryParam.subareaSn = val[0] ? val[0] : undefined
  153. this.queryParam.subareaAreaSn = val[1] ? val[1] : undefined
  154. },
  155. // 重置
  156. resetSearchForm () {
  157. this.queryParam.subareaSn = undefined
  158. this.queryParam.subareaAreaSn = undefined
  159. this.queryParam.dealer.dealerSn = ''
  160. this.queryParam.dealer.dealerName = ''
  161. this.queryParam.bizUserName = ''
  162. this.$refs.indirectDealer.resetForm()
  163. this.$refs.subarea.clearData()
  164. this.$refs.table.refresh(true)
  165. },
  166. // 选择经销商
  167. dealerChange (val) {
  168. this.queryParam.dealer.dealerSn = val.key
  169. this.queryParam.dealer.dealerName = (val.label.replace('\n', '')).trim()
  170. },
  171. pageInit () {
  172. const _this = this
  173. this.$nextTick(() => { // 页面渲染完成后的回调
  174. _this.setTableH()
  175. })
  176. this.$refs.table.refresh()
  177. },
  178. setTableH () {
  179. const tableSearchH = this.$refs.tableSearch.offsetHeight
  180. this.tableHeight = window.innerHeight - tableSearchH - 235
  181. }
  182. },
  183. watch: {
  184. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  185. this.setTableH()
  186. }
  187. },
  188. mounted () {
  189. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  190. this.pageInit()
  191. }
  192. },
  193. activated () {
  194. // 如果是新页签打开,则重置当前页面
  195. if (this.$store.state.app.isNewTab) {
  196. this.pageInit()
  197. }
  198. },
  199. beforeRouteEnter (to, from, next) {
  200. next(vm => {})
  201. }
  202. }
  203. </script>
  204. <style lang="less" scoped>
  205. .dealerZoneSearch-wrap{
  206. height: 100%;
  207. margin-top:6px;
  208. }
  209. /deep/.ant-select-combobox .ant-select-arrow{
  210. display:inline-block !important;
  211. }
  212. .line-2{
  213. width: 100%;
  214. overflow:hidden;
  215. text-overflow: ellipsis;
  216. -webkit-line-clamp: 2;
  217. display: -webkit-box;
  218. -webkit-box-orient: vertical;
  219. }
  220. </style>