list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <template>
  2. <div>
  3. <a-card size="small" :bordered="false" class="customerCountList-wrap searchBoxNormal">
  4. <!-- 搜索条件 -->
  5. <div class="table-page-search-wrapper" ref="tableSearch">
  6. <a-form-model
  7. id="customerCountList-form"
  8. ref="ruleForm"
  9. class="form-model-con"
  10. layout="inline"
  11. :model="queryParam">
  12. <a-row :gutter="15">
  13. <a-col :md="6" :sm="24">
  14. <a-form-model-item label="客户名称">
  15. <dealerSubareaScopeList ref="dealerSubareaScopeList" id="customerCountList-dealerName" @change="custChange" />
  16. </a-form-model-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-form-model-item label="客户级别">
  20. <v-select
  21. v-model="queryParam.dealerLevel"
  22. ref="dealerLevel"
  23. id="customerCountList-dealerLevel"
  24. code="DEALER_LEVEL"
  25. placeholder="请选择客户级别"
  26. allowClear></v-select>
  27. </a-form-model-item>
  28. </a-col>
  29. <a-col :md="6" :sm="24">
  30. <a-form-item label="所在区域">
  31. <subarea id="customerCountList-subarea" ref="subarea" @change="subareaChange"></subarea>
  32. </a-form-item>
  33. </a-col>
  34. <template v-if="advanced">
  35. <a-col :md="6" :sm="24">
  36. <a-form-model-item label="区域负责人">
  37. <BizUser id="customerCountList-bizUserSn" v-model="queryParam.subareaArea.bizUserSn"></BizUser>
  38. </a-form-model-item>
  39. </a-col>
  40. <a-col :md="6" :sm="24">
  41. <a-form-model-item label="地区">
  42. <AreaList id="customerCountList-areaList" changeOnSelect ref="areaList" @change="areaChange" defValKey="id"></AreaList>
  43. </a-form-model-item>
  44. </a-col>
  45. <a-col :md="6" :sm="24">
  46. <a-form-model-item label="客服">
  47. <customerService ref="customerName" id="customerCountList-customerName" v-model="queryParam.subareaArea.kfSn"></customerService>
  48. </a-form-model-item>
  49. </a-col>
  50. </template>
  51. <a-col :md="6" :sm="24">
  52. <a-button
  53. type="primary"
  54. @click="handleSearch"
  55. :disabled="disabled"
  56. id="customerCountList-refresh">查询</a-button>
  57. <a-button
  58. style="margin-left: 8px"
  59. @click="resetSearchForm"
  60. :disabled="disabled"
  61. id="customerCountList-reset">重置</a-button>
  62. <a-button
  63. style="margin-left: 10px"
  64. type="primary"
  65. class="button-warning"
  66. @click="handleExport"
  67. :disabled="disabled"
  68. :loading="exportLoading"
  69. v-if="$hasPermissions('B_newCustomSearchExport')"
  70. id="customerCountList-export">导出</a-button>
  71. <a @click="advanced=!advanced" style="margin-left: 5px">
  72. {{ advanced ? '收起' : '展开' }}
  73. <a-icon :type="advanced ? 'up' : 'down'" />
  74. </a>
  75. </a-col>
  76. </a-row>
  77. </a-form-model>
  78. </div>
  79. </a-card>
  80. <a-card size="small" :bordered="false">
  81. <a-spin :spinning="spinning" tip="Loading...">
  82. <!-- 列表 -->
  83. <s-table
  84. class="sTable fixPagination"
  85. ref="table"
  86. size="small"
  87. :rowKey="(record) => record.no"
  88. rowKeyName="no"
  89. :style="{ height: tableHeight+70+'px' }"
  90. :columns="columns"
  91. :data="loadData"
  92. :scroll="{y: tableHeight}"
  93. bordered>
  94. </s-table>
  95. </a-spin>
  96. </a-card>
  97. </div>
  98. </template>
  99. <script>
  100. import { commonMixin } from '@/utils/mixin'
  101. import { hdExportExcel } from '@/libs/exportExcel'
  102. // 组件
  103. import { STable, VSelect } from '@/components'
  104. import subarea from '@/views/common/subarea.js'
  105. import AreaList from '@/views/common/areaList.js'
  106. import dealerSubareaScopeList from '@/views/common/dealerSubareaScopeList.vue'
  107. import BizUser from '@/views/common/bizUser.js'
  108. import customerService from '@/views/common/customerService.vue'
  109. // 接口
  110. import { dealerNewLogPageList, dealerNewLogExport } from '@/api/dealearNewLog'
  111. export default {
  112. name: 'CustomerCountList',
  113. mixins: [commonMixin],
  114. components: { STable, VSelect, subarea, AreaList, dealerSubareaScopeList, BizUser, customerService },
  115. data () {
  116. const _this = this
  117. return {
  118. spinning: false,
  119. disabled: false, // 查询、重置按钮是否可操作
  120. advanced: true, // 高级搜索 展开/关闭
  121. tableHeight: 0, // 表格高度
  122. exportLoading: false, // 导出按钮加载状态
  123. // 查询条件
  124. queryParam: {
  125. dealerLevel: undefined, // 客户等级
  126. dealerSn: undefined, // 客户sn
  127. dealerName: undefined, // 客户名称
  128. provinceSn: undefined, // 省
  129. citySn: undefined, // 市
  130. districtSn: undefined, // 区
  131. subareaArea: {
  132. subareaSn: '', // 区域
  133. subareaAreaSn: '', // 分区
  134. bizUserSn: undefined, // 区域负责人
  135. kfSn: undefined// 客服
  136. }
  137. },
  138. columns: [
  139. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  140. { title: '区域', dataIndex: 'subareaArea.subareaName', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  141. { title: '分区', dataIndex: 'subareaArea.subareaAreaName', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  142. { title: '区域负责人', dataIndex: 'subareaArea.bizUserName', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  143. { title: '省份', dataIndex: 'provinceName', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  144. { title: '客户名称', dataIndex: 'dealerName', width: '17%', align: 'left', customRender: function (text) { return text || '--' } },
  145. { title: '客户级别', dataIndex: 'dealerLevelDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  146. { title: '年份', dataIndex: 'year', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  147. { title: '月份', dataIndex: 'month', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  148. { title: '第一笔时间', dataIndex: 'firstDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  149. { title: '最后一笔时间', dataIndex: 'lastDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  150. { title: '首笔订单数', dataIndex: 'billCount', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  151. { title: '总开单金额', dataIndex: 'totalAmount', width: '8%', align: 'right', customRender: function (text) { return _this.toThousands(text) || '--' } },
  152. { title: '总实售金额', dataIndex: 'totalRealAmount', width: '8%', align: 'right', customRender: function (text) { return _this.toThousands(text) || '--' } }
  153. ],
  154. // 加载数据方法 必须为 Promise 对象
  155. loadData: parameter => {
  156. this.disabled = true
  157. this.spinning = true
  158. const params = Object.assign(parameter, this.queryParam)
  159. // 获取列表数据 有分页
  160. return dealerNewLogPageList(params).then(res => {
  161. let data
  162. if (res.status == 200) {
  163. data = res.data
  164. // 计算表格序号
  165. const no = (data.pageNo - 1) * data.pageSize
  166. for (var i = 0; i < data.list.length; i++) {
  167. data.list[i].no = no + i + 1
  168. }
  169. this.disabled = false
  170. }
  171. this.spinning = false
  172. return data
  173. })
  174. }
  175. }
  176. },
  177. watch: {
  178. advanced (newValue, oldValue) {
  179. const _this = this
  180. this.$nextTick(() => { // 页面渲染完成后的回调
  181. _this.setTableH()
  182. })
  183. },
  184. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  185. this.setTableH()
  186. }
  187. },
  188. methods: {
  189. // 查询
  190. handleSearch () {
  191. this.$refs.table.refresh(true)
  192. },
  193. // 客户名称 change
  194. custChange (val) {
  195. this.queryParam.dealerName = val.name
  196. this.queryParam.dealerSn = val.key
  197. },
  198. // 地区
  199. areaChange (val) {
  200. this.queryParam.provinceSn = val[0] ? val[0] : undefined
  201. this.queryParam.citySn = val[1] ? val[1] : undefined
  202. this.queryParam.districtSn = val[2] ? val[2] : undefined
  203. },
  204. // 区域分区 change
  205. subareaChange (val) {
  206. this.queryParam.subareaArea.subareaSn = val[0] ? val[0] : ''
  207. this.queryParam.subareaArea.subareaAreaSn = val[1] ? val[1] : ''
  208. },
  209. // 重置
  210. resetSearchForm () {
  211. this.queryParam.provinceSn = undefined
  212. this.queryParam.citySn = undefined
  213. this.queryParam.districtSn = undefined
  214. this.queryParam.dealerName = undefined
  215. this.queryParam.dealerSn = undefined
  216. this.queryParam.subareaArea.subareaSn = ''
  217. this.queryParam.subareaArea.subareaAreaSn = ''
  218. this.queryParam.subareaArea.bizUserSn = undefined
  219. this.queryParam.subareaArea.kfSn = undefined
  220. this.queryParam.dealerLevel = undefined
  221. if (this.advanced) {
  222. this.$refs.subarea.clearData()
  223. this.$refs.dealerSubareaScopeList.resetForm()
  224. this.$refs.areaList.clearData()
  225. }
  226. this.$refs.table.clearTable()
  227. this.$refs.ruleForm.resetFields()
  228. this.$refs.table.refresh(false)
  229. },
  230. // 导出
  231. handleExport () {
  232. const _this = this
  233. const params = JSON.parse(JSON.stringify(_this.queryParam))
  234. _this.exportLoading = true
  235. _this.spinning = true
  236. hdExportExcel(dealerNewLogExport, params, '新客户查询', function () {
  237. _this.exportLoading = false
  238. _this.spinning = false
  239. })
  240. },
  241. // 初始化
  242. pageInit () {
  243. this.$nextTick(() => { // 页面渲染完成后的回调
  244. this.setTableH()
  245. this.resetSearchForm()
  246. })
  247. },
  248. // 计算表格高度
  249. setTableH () {
  250. const tableSearchH = this.$refs.tableSearch.offsetHeight
  251. this.tableHeight = window.innerHeight - tableSearchH - 200
  252. }
  253. },
  254. mounted () {
  255. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  256. this.pageInit()
  257. }
  258. },
  259. activated () {
  260. // 如果是新页签打开,则重置当前页面
  261. if (this.$store.state.app.isNewTab) {
  262. this.pageInit()
  263. }
  264. }
  265. }
  266. </script>
  267. <style lang="less" scoped>
  268. .monthBox{
  269. width: 100%;
  270. /deep/.ant-calendar-picker-icon{
  271. display:none !important;
  272. }
  273. /deep/.ant-calendar-picker input{
  274. text-align:center;
  275. }
  276. }
  277. </style>