list.vue 8.0 KB

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