dealerList.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <template>
  2. <div>
  3. <a-card size="small" :bordered="false" class="tireSalesDealerList-wrap searchBoxNormal">
  4. <!-- 搜索条件 -->
  5. <div class="table-page-search-wrapper" ref="tableSearch">
  6. <a-form-model
  7. id="tireSalesDealerList-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. <rangeDate ref="rangeDate" :value="time" @change="dateChange" />
  16. </a-form-model-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-form-model-item label="地区">
  20. <AreaList id="tireSalesDealerList-areaList" changeOnSelect ref="areaList" @change="areaChange" defValKey="id"></AreaList>
  21. </a-form-model-item>
  22. </a-col>
  23. <a-col :md="6" :sm="24">
  24. <a-form-item label="区域/分区">
  25. <subarea id="tireSalesDealerList-subarea" ref="subarea" @change="subareaChange"></subarea>
  26. </a-form-item>
  27. </a-col>
  28. <template v-if="advanced">
  29. <a-col :md="6" :sm="24">
  30. <a-form-model-item label="客户名称">
  31. <a-input
  32. id="tireSalesDealerList-buyerName"
  33. v-model.trim="queryParam.buyerName"
  34. allowClear
  35. placeholder="请输入客户名称" />
  36. </a-form-model-item>
  37. </a-col>
  38. <a-col :md="6" :sm="24">
  39. <a-form-model-item label="区域负责人">
  40. <BizUser v-model="queryParam.bizUserSn"></BizUser>
  41. </a-form-model-item>
  42. </a-col>
  43. </template>
  44. <a-col :md="6" :sm="24">
  45. <a-button
  46. style="margin-left: 5px"
  47. type="primary"
  48. @click="$refs.table.refresh(true)"
  49. :disabled="disabled"
  50. id="tireSalesDealerList-refresh">查询</a-button>
  51. <a-button
  52. style="margin-left: 8px"
  53. @click="resetSearchForm"
  54. :disabled="disabled"
  55. id="tireSalesDealerList-reset">重置</a-button>
  56. <a-button
  57. style="margin-left: 10px"
  58. type="primary"
  59. class="button-warning"
  60. @click="handleExport"
  61. :disabled="disabled"
  62. :loading="exportLoading"
  63. v-if="$hasPermissions('B_tireSalesDealerReportExport')"
  64. id="tireSalesDealerList-export">导出</a-button>
  65. <a @click="advanced=!advanced" style="margin-left: 5px">
  66. {{ advanced ? '收起' : '展开' }}
  67. <a-icon :type="advanced ? 'up' : 'down'" />
  68. </a>
  69. </a-col>
  70. </a-row>
  71. </a-form-model>
  72. </div>
  73. </a-card>
  74. <a-card size="small" :bordered="false">
  75. <a-spin :spinning="spinning" tip="Loading...">
  76. <!-- 列表 -->
  77. <s-table
  78. class="sTable fixPagination"
  79. ref="table"
  80. size="small"
  81. :rowKey="(record) => record.salesBillNo"
  82. :style="{ height: tableHeight+70+'px' }"
  83. rowKeyName="salesBillNo"
  84. :columns="columns"
  85. :data="loadData"
  86. :scroll="{ y: tableHeight-30 }"
  87. :defaultLoadData="false"
  88. bordered>
  89. <template slot="addressInfo" slot-scope="text, record">
  90. {{ record.provinceName }}{{ '/'+record.cityName }}{{ '/'+record.districtName }}
  91. </template>
  92. <template slot="footer">
  93. <a-row :gutter="15">
  94. <a-col :md="4" :sm="24">采购数量:{{ (totalData && (totalData.totalbuyAmount || totalData.totalbuyAmount==0)) ? totalData.totalbuyAmount : '--' }}</a-col>
  95. <a-col :md="4" :sm="24">库存数量:{{ (totalData && (totalData.totalstoreAmount || totalData.totalstoreAmount==0)) ? totalData.totalstoreAmount: '--' }}</a-col>
  96. <a-col :md="4" :sm="24">已售出数量:{{ (totalData && (totalData.totalsellAmount || totalData.totalsellAmount==0)) ?totalData.totalsellAmount: '--' }}</a-col>
  97. </a-row>
  98. </template>
  99. </s-table>
  100. </a-spin>
  101. </a-card>
  102. </div>
  103. </template>
  104. <script>
  105. import { commonMixin } from '@/utils/mixin'
  106. import getDate from '@/libs/getDate.js'
  107. import { STable, VSelect } from '@/components'
  108. import rangeDate from '@/views/common/rangeDate.vue'
  109. import subarea from '@/views/common/subarea.js'
  110. import AreaList from '@/views/common/areaList.js'
  111. import BizUser from '@/views/common/bizUser.js'
  112. import { hdExportExcel } from '@/libs/exportExcel'
  113. import { querySaleDealercount, excelSaleOnlineExport, querybyDealerList } from '@/api/reportData'
  114. export default {
  115. name: 'TireSalesDealerList',
  116. mixins: [commonMixin],
  117. components: { STable, VSelect, rangeDate, subarea, AreaList, BizUser },
  118. data () {
  119. return {
  120. spinning: false,
  121. advanced: true, // 高级搜索 展开/关闭
  122. tableHeight: 0,
  123. time: [
  124. getDate.getThreeMonthDays().starttime,
  125. getDate.getCurrMonthDays().endtime
  126. ],
  127. queryParam: { // 查询条件
  128. beginDate: getDate.getThreeMonthDays().starttime,
  129. endDate: getDate.getCurrMonthDays().endtime,
  130. provinceSn: undefined,
  131. citySn: undefined,
  132. districtSn: undefined,
  133. buyerName: '',
  134. subareaSn: undefined,
  135. subareaAreaSn: undefined,
  136. bizUserSn: undefined
  137. },
  138. disabled: false, // 查询、重置按钮是否可操作
  139. exportLoading: false,
  140. // 加载数据方法 必须为 Promise 对象
  141. loadData: parameter => {
  142. this.disabled = true
  143. this.spinning = true
  144. const params = Object.assign(parameter, this.queryParam)
  145. return querybyDealerList(params).then(res => {
  146. let data
  147. if (res.status == 200) {
  148. data = res.data
  149. const no = (data.pageNo - 1) * data.pageSize
  150. for (var i = 0; i < data.list.length; i++) {
  151. data.list[i].no = no + i + 1
  152. }
  153. this.disabled = false
  154. this.getCount(params)
  155. }
  156. this.spinning = false
  157. return data
  158. })
  159. },
  160. totalData: null,
  161. columns: [
  162. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  163. { title: '地区', scopedSlots: { customRender: 'addressInfo' }, width: '12%', align: 'center' },
  164. { title: '区域', dataIndex: 'subareaName', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  165. { title: '分区', dataIndex: 'subareaAreaName', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  166. { title: '区域负责人', dataIndex: 'userNameQyfzrs', width: '12%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  167. { title: '客户名称', dataIndex: 'buyerName', width: '16%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  168. { title: '商户类型', dataIndex: 'dealerTypeDictValue', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  169. { title: '商户级别', dataIndex: 'dealerLevelDictValue ', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  170. { title: '采购数量', dataIndex: 'buyAmount', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  171. { title: '库存数量', dataIndex: 'storeAmount', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  172. { title: '已售出数量', dataIndex: 'sellAmount', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  173. ]
  174. }
  175. },
  176. watch: {
  177. advanced (newValue, oldValue) {
  178. const _this = this
  179. this.$nextTick(() => { // 页面渲染完成后的回调
  180. _this.setTableH()
  181. })
  182. },
  183. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  184. this.setTableH()
  185. }
  186. },
  187. methods: {
  188. // 统计
  189. getCount (params) {
  190. querySaleDealercount(params).then(res => {
  191. if (res.status == 200 && res.data) {
  192. this.totalData = res.data
  193. } else {
  194. this.totalData = null
  195. }
  196. })
  197. },
  198. // 地区
  199. areaChange (val) {
  200. this.queryParam.provinceSn = val[0] ? val[0] : ''
  201. this.queryParam.citySn = val[1] ? val[1] : ''
  202. this.queryParam.districtSn = val[2] ? val[2] : ''
  203. },
  204. // 下推时间 change
  205. dateChange (date) {
  206. if (date[0] && date[1]) {
  207. this.time = date
  208. } else {
  209. this.time = []
  210. }
  211. this.queryParam.beginDate = date[0] || ''
  212. this.queryParam.endDate = date[1] || ''
  213. },
  214. custChange (val) {
  215. this.queryParam.dealerSn = val.key
  216. },
  217. subareaChange (val) {
  218. this.queryParam.subareaSn = val[0] ? val[0] : undefined
  219. this.queryParam.subareaAreaSn = val[1] ? val[1] : undefined
  220. },
  221. // 重置
  222. resetSearchForm () {
  223. this.time = [
  224. getDate.getThreeMonthDays().starttime,
  225. getDate.getCurrMonthDays().endtime
  226. ]
  227. this.$refs.rangeDate.resetDate(this.time)
  228. this.queryParam.beginDate = getDate.getThreeMonthDays().starttime
  229. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  230. this.queryParam.provinceSn = undefined
  231. this.queryParam.citySn = undefined
  232. this.queryParam.districtSn = undefined
  233. this.queryParam.buyerName = ''
  234. this.queryParam.subareaSn = undefined
  235. this.queryParam.subareaAreaSn = undefined
  236. this.queryParam.bizUserSn = undefined
  237. this.totalData = null
  238. if (this.advanced) {
  239. this.$refs.subarea.clearData()
  240. this.$refs.areaList.clearData()
  241. }
  242. this.$refs.table.clearTable()
  243. },
  244. // 导出
  245. handleExport () {
  246. const _this = this
  247. const params = _this.queryParam
  248. _this.exportLoading = true
  249. _this.spinning = true
  250. hdExportExcel(excelSaleOnlineExport, params, '轮胎销售报表(经销商)', function () {
  251. _this.exportLoading = false
  252. _this.spinning = false
  253. })
  254. },
  255. pageInit () {
  256. const _this = this
  257. this.$nextTick(() => { // 页面渲染完成后的回调
  258. _this.setTableH()
  259. })
  260. this.resetSearchForm()
  261. },
  262. setTableH () {
  263. const tableSearchH = this.$refs.tableSearch.offsetHeight
  264. this.tableHeight = window.innerHeight - tableSearchH - 245
  265. }
  266. },
  267. mounted () {
  268. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  269. this.pageInit()
  270. }
  271. },
  272. activated () {
  273. // 如果是新页签打开,则重置当前页面
  274. if (this.$store.state.app.isNewTab) {
  275. this.pageInit()
  276. }
  277. },
  278. beforeRouteEnter (to, from, next) {
  279. next(vm => {})
  280. }
  281. }
  282. </script>