list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. <template>
  2. <div>
  3. <a-card size="small" :bordered="false" class="salesAmountReportList-wrap searchBoxNormal">
  4. <!-- 搜索条件 -->
  5. <div class="table-page-search-wrapper newTableSearchName" ref="tableSearch">
  6. <a-form-model
  7. id="salesAmountReportList-form"
  8. ref="ruleForm"
  9. class="form-model-con"
  10. layout="inline"
  11. :model="queryParam"
  12. :rules="rules"
  13. @keyup.enter.native="handleSearch">
  14. <a-row :gutter="15">
  15. <a-col :md="6" :sm="24">
  16. <a-form-model-item label="下推时间" prop="time">
  17. <rangeDate ref="rangeDate" id="salesAmountReportList-time" :value="queryParam.time" @change="dateChange" />
  18. </a-form-model-item>
  19. </a-col>
  20. <a-col :md="6" :sm="24">
  21. <a-form-model-item label="客户名称">
  22. <dealerSubareaScopeList ref="custList" id="salesAmountReportList-dealerSn" @change="custChange" />
  23. </a-form-model-item>
  24. </a-col>
  25. <a-col :md="6" :sm="24">
  26. <a-form-model-item label="客户级别">
  27. <v-select
  28. v-model="queryParam.dealerLevel"
  29. ref="dealerLevel"
  30. id="salesAmountReportList-dealerLevel"
  31. code="DEALER_LEVEL"
  32. placeholder="请选择客户级别"
  33. allowClear></v-select>
  34. </a-form-model-item>
  35. </a-col>
  36. <template v-if="advanced">
  37. <a-col :md="6" :sm="24">
  38. <a-form-model-item label="所在区域">
  39. <subarea id="salesAmountReportList-subareaSn" ref="subarea" @change="subareaChange"></subarea>
  40. </a-form-model-item>
  41. </a-col>
  42. <a-col :md="6" :sm="24">
  43. <a-form-model-item label="区域负责人">
  44. <BizUser id="salesAmountReportList-bizUserSn" v-model="queryParam.subareaArea.bizUserSn"></BizUser>
  45. </a-form-model-item>
  46. </a-col>
  47. <a-col :md="6" :sm="24">
  48. <a-form-model-item label="地区">
  49. <AreaList id="salesAmountReportList-areaList" changeOnSelect ref="areaList" @change="areaChange" defValKey="id"></AreaList>
  50. </a-form-model-item>
  51. </a-col>
  52. <a-col :md="6" :sm="24" v-show="isShowCustomerSearch">
  53. <a-form-item label="客服">
  54. <customerService id="salesAmountReportList-customerName" ref="customerName" v-model="queryParam.bizUserSn"></customerService>
  55. </a-form-item>
  56. </a-col>
  57. </template>
  58. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  59. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="salesAmountReportList-refresh">查询</a-button>
  60. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="salesAmountReportList-reset">重置</a-button>
  61. <a-button
  62. style="margin-left: 10px"
  63. type="primary"
  64. class="button-warning"
  65. @click="handleExport"
  66. :disabled="disabled"
  67. :loading="exportLoading"
  68. v-if="$hasPermissions('B_salesAmountReport_export')"
  69. id="returnSlipReportList-export">导出</a-button>
  70. <a @click="advanced=!advanced" style="margin-left: 8px">
  71. {{ advanced ? '收起' : '展开' }}
  72. <a-icon :type="advanced ? 'up' : 'down'"/>
  73. </a>
  74. </a-col>
  75. </a-row>
  76. </a-form-model>
  77. </div>
  78. </a-card>
  79. <a-card size="small" :bordered="false">
  80. <a-spin :spinning="spinning" tip="Loading...">
  81. <!-- 列表 -->
  82. <s-table
  83. class="sTable fixPagination"
  84. ref="table"
  85. size="small"
  86. :defaultLoadData="false"
  87. :rowKey="(record) => record.no"
  88. rowKeyName="no"
  89. :columns="columns"
  90. :data="loadData"
  91. :pageSize="30"
  92. :style="{ height: tableHeight+84.5+'px' }"
  93. :scroll="{ x: 2250 ,y: tableHeight-136 }"
  94. bordered>
  95. <template slot="footer" v-if="countLabel.length||countBrandLabel.length">
  96. <a-row>
  97. <a-col span="2">合计:</a-col>
  98. <a-col span="22">
  99. <a-row>
  100. <a-col span="4" v-for="item in countLabel" :key="item.key">
  101. {{ item.title }}:{{ totalData?(totalData[item.dataIndex]||totalData[item.dataIndex]==0)?toThousands(totalData[item.dataIndex]):'--':'--' }}
  102. </a-col>
  103. </a-row>
  104. <a-row>
  105. <a-col span="24" style="padding:8px;"></a-col>
  106. </a-row>
  107. <a-row>
  108. <a-col span="4" v-for="item in countBrandLabel" :key="item.key">
  109. {{ item.title }}:{{ totalData?(totalData[item.dataIndex] ||totalData[item.dataIndex]==0)?toThousands(totalData[item.dataIndex]):'--':'--' }}
  110. </a-col>
  111. </a-row>
  112. </a-col>
  113. </a-row>
  114. </template>
  115. </s-table>
  116. </a-spin>
  117. <!-- 导出提示框 -->
  118. <reportModal :visible="showExport" @close="showExport=false"></reportModal>
  119. </a-card>
  120. </div>
  121. </template>
  122. <script>
  123. import { commonMixin } from '@/utils/mixin'
  124. import getDate from '@/libs/getDate.js'
  125. import { hdExportExcel } from '@/libs/exportExcel'
  126. // 组件
  127. import { STable, VSelect } from '@/components'
  128. import rangeDate from '@/views/common/rangeDate.vue'
  129. import subarea from '@/views/common/subarea.js'
  130. import reportModal from '@/views/common/reportModal.vue'
  131. import AreaList from '@/views/common/areaList.js'
  132. import BizUser from '@/views/common/bizUser.js'
  133. import customerService from '@/views/common/customerService'
  134. import dealerSubareaScopeList from '@/views/common/dealerSubareaScopeList.vue'
  135. // 接口
  136. import { salesAmountExport } from '@/api/reportData'
  137. import { salesKdxxReportTitle, salesBillReportGroupByBuyerList, salesBillReportCountByBuyer } from '@/api/salesBillReport'
  138. export default {
  139. name: 'SalesAmountReportList',
  140. mixins: [commonMixin],
  141. components: { STable, VSelect, rangeDate, subarea, dealerSubareaScopeList, reportModal, AreaList, BizUser, customerService },
  142. data () {
  143. return {
  144. spinning: false,
  145. advanced: true, // 高级搜索 展开/关闭
  146. disabled: false, // 查询、重置按钮是否可操作
  147. exportLoading: false, // 导出按钮加载状态
  148. tableHeight: 0, // 表格高度
  149. showExport: false, // 导出弹窗
  150. // 查询条件
  151. queryParam: {
  152. // 默认下推时间
  153. time: [
  154. getDate.getCurrMonthDays().starttime,
  155. getDate.getCurrMonthDays().endtime
  156. ],
  157. beginDate: getDate.getCurrMonthDays().starttime, // 开始时间
  158. endDate: getDate.getCurrMonthDays().endtime, // 结束时间
  159. dealerSn: undefined, // 客户sn
  160. provinceSn: undefined, // 省份
  161. citySn: undefined, // 市
  162. districtSn: undefined, // 区
  163. dealerLevel: undefined, // 客户等级
  164. subareaArea: {
  165. subareaSn: undefined, // 区域
  166. subareaAreaSn: undefined, // 分区
  167. bizUserSn: undefined// 区域负责人
  168. },
  169. bizUserSn: undefined// 客服
  170. },
  171. totalData: null, // 统计数据
  172. columns: [], // 列表表头
  173. countLabel: [], // 统计分类数据
  174. countBrandLabel: [], // 统计品牌数据
  175. rules: {
  176. 'time': [{ required: true, message: '请选择下推时间', trigger: 'change' }]
  177. },
  178. // 加载数据方法 必须为 Promise 对象
  179. loadData: parameter => {
  180. this.disabled = true
  181. this.spinning = true
  182. const paramsPage = Object.assign(this.queryParam, { pageNo: parameter.pageNo, pageSize: parameter.pageSize })
  183. // 获取列表数据 有分页
  184. return salesBillReportGroupByBuyerList(paramsPage).then(res => {
  185. let data
  186. if (res.status == 200) {
  187. data = res.data
  188. // 统计
  189. this.getCount(paramsPage)
  190. // 计算序号
  191. const no = (data.pageNo - 1) * data.pageSize
  192. for (var i = 0; i < data.list.length; i++) {
  193. data.list[i].no = no + i + 1
  194. }
  195. this.disabled = false
  196. }
  197. this.spinning = false
  198. return data
  199. })
  200. }
  201. }
  202. },
  203. watch: {
  204. // 展开收起
  205. advanced (newValue, oldValue) {
  206. const _this = this
  207. this.$nextTick(() => { // 页面渲染完成后的回调
  208. _this.setTableH()
  209. })
  210. },
  211. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  212. this.setTableH()
  213. }
  214. },
  215. methods: {
  216. // 导出
  217. handleExport () {
  218. const _this = this
  219. this.$refs.ruleForm.validate(valid => {
  220. if (valid) {
  221. const params = _this.queryParam
  222. _this.$store.state.app.curActionPermission = 'B_salesAmountReport_export'
  223. _this.showExport = true
  224. _this.exportLoading = true
  225. _this.spinning = true
  226. hdExportExcel(salesAmountExport, params, '开单销售报表', function () {
  227. _this.exportLoading = false
  228. _this.spinning = false
  229. _this.$store.state.app.curActionPermission = ''
  230. })
  231. } else {
  232. return false
  233. }
  234. })
  235. },
  236. // 总计
  237. getCount (params) {
  238. salesBillReportCountByBuyer(params).then(res => {
  239. if (res.status == 200 && res.data) {
  240. this.totalData = res.data
  241. } else {
  242. this.totalData = null
  243. }
  244. })
  245. },
  246. // 查询
  247. handleSearch () {
  248. const _this = this
  249. this.$refs.ruleForm.validate(valid => {
  250. if (valid) {
  251. _this.$refs.table.refresh(true)
  252. } else {
  253. _this.$message.error('请选择下推时间')
  254. return false
  255. }
  256. })
  257. },
  258. // 下推时间 change
  259. dateChange (date) {
  260. if (date[0] && date[1]) {
  261. this.queryParam.time = date
  262. } else {
  263. this.queryParam.time = []
  264. }
  265. this.queryParam.beginDate = date[0] || ''
  266. this.queryParam.endDate = date[1] || ''
  267. },
  268. // 客户名称 change
  269. custChange (val) {
  270. this.queryParam.dealerSn = val.key
  271. },
  272. // 区域分区 change
  273. subareaChange (val) {
  274. this.queryParam.subareaArea.subareaSn = val[0] ? val[0] : undefined
  275. this.queryParam.subareaArea.subareaAreaSn = val[1] ? val[1] : undefined
  276. },
  277. // 重置
  278. resetSearchForm () {
  279. this.queryParam.time = [
  280. getDate.getCurrMonthDays().starttime,
  281. getDate.getCurrMonthDays().endtime
  282. ]
  283. this.$refs.rangeDate.resetDate(this.queryParam.time)
  284. this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
  285. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  286. this.queryParam.dealerSn = undefined
  287. this.queryParam.provinceSn = undefined
  288. this.queryParam.citySn = undefined
  289. this.queryParam.districtSn = undefined
  290. this.queryParam.subareaArea.subareaSn = undefined
  291. this.queryParam.subareaArea.subareaAreaSn = undefined
  292. this.queryParam.subareaArea.bizUserSn = undefined
  293. this.queryParam.dealerLevel = undefined
  294. this.queryParam.bizUserSn = undefined
  295. this.totalData = null
  296. this.$refs.subarea.clearData()
  297. if (this.advanced) {
  298. this.$refs.areaList.clearData()
  299. }
  300. this.$refs.custList.resetForm()
  301. this.$refs.ruleForm.resetFields()
  302. this.$refs.table.clearTable()
  303. },
  304. // 地区
  305. areaChange (val) {
  306. this.queryParam.provinceSn = val[0] ? val[0] : ''
  307. this.queryParam.citySn = val[1] ? val[1] : ''
  308. this.queryParam.districtSn = val[2] ? val[2] : ''
  309. },
  310. // 获取表头
  311. async getTableTitle () {
  312. const _this = this
  313. const tableTitle = await salesKdxxReportTitle().then(res => res.data)
  314. this.columns = tableTitle.list
  315. this.countLabel = tableTitle.count.filter(item => item.title.indexOf('品牌') < 0)
  316. this.countBrandLabel = tableTitle.count.filter(item => item.title.indexOf('品牌') >= 0)
  317. this.columns.map(item => {
  318. let mw = 20
  319. if (item.customRender == 'amount') {
  320. mw = 15
  321. item.customRender = function (text) { return (text || text == 0) ? _this.toThousands(text) : '--' }
  322. } else {
  323. item.customRender = function (text) { return text || '--' }
  324. }
  325. const w = item.title.length * mw
  326. const tw = w <= 80 ? mw * 5 : w
  327. item.width = tw + 'px'
  328. this.tableWidth = this.tableWidth + tw
  329. })
  330. this.resetSearchForm()
  331. },
  332. // 计算表格高度
  333. setTableH () {
  334. const tableSearchH = this.$refs.tableSearch.offsetHeight
  335. this.tableHeight = window.innerHeight - tableSearchH - 215
  336. }
  337. },
  338. mounted () {
  339. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  340. this.getTableTitle()
  341. this.setTableH()
  342. }
  343. },
  344. activated () {
  345. // 如果是新页签打开,则重置当前页面
  346. if (this.$store.state.app.isNewTab) {
  347. this.getTableTitle()
  348. this.setTableH()
  349. }
  350. },
  351. beforeRouteEnter (to, from, next) {
  352. next(vm => {})
  353. }
  354. }
  355. </script>