list.vue 9.0 KB

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