list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  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" :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-allocateTypeSn"
  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-allocateTypeSn" 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 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 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 { STable, VSelect } from '@/components'
  126. import rangeDate from '@/views/common/rangeDate.vue'
  127. import dealerSubareaScopeList from '@/views/common/dealerSubareaScopeList.vue'
  128. import subarea from '@/views/common/subarea.js'
  129. import reportModal from '@/views/common/reportModal.vue'
  130. import AreaList from '@/views/common/areaList.js'
  131. import BizUser from '@/views/common/bizUser.js'
  132. import customerService from '@/views/common/customerService'
  133. import { hdExportExcel } from '@/libs/exportExcel'
  134. import { salesKdxxReportTitle, salesBillReportGroupByBuyerList, salesBillReportCountByBuyer } from '@/api/salesBillReport'
  135. import { salesAmountExport } from '@/api/reportData'
  136. export default {
  137. name: 'SalesAmountReportList',
  138. mixins: [commonMixin],
  139. components: { STable, VSelect, rangeDate, subarea, dealerSubareaScopeList, reportModal, AreaList, BizUser, customerService },
  140. data () {
  141. return {
  142. spinning: false,
  143. advanced: true, // 高级搜索 展开/关闭
  144. tableHeight: 0,
  145. showExport: false,
  146. queryParam: { // 查询条件
  147. time: [
  148. getDate.getCurrMonthDays().starttime,
  149. getDate.getCurrMonthDays().endtime
  150. ],
  151. beginDate: getDate.getCurrMonthDays().starttime,
  152. endDate: getDate.getCurrMonthDays().endtime,
  153. dealerSn: undefined,
  154. provinceSn: undefined,
  155. citySn: undefined,
  156. districtSn: undefined,
  157. dealerLevel: undefined,
  158. subareaArea: {
  159. subareaSn: undefined,
  160. subareaAreaSn: undefined,
  161. bizUserSn: undefined
  162. },
  163. bizUserSn: undefined// 客服
  164. },
  165. columns: [],
  166. countLabel: [],
  167. countBrandLabel: [],
  168. rules: {
  169. 'time': [{ required: true, message: '请选择下推时间', trigger: 'change' }]
  170. },
  171. disabled: false, // 查询、重置按钮是否可操作
  172. exportLoading: false,
  173. // 加载数据方法 必须为 Promise 对象
  174. loadData: parameter => {
  175. this.disabled = true
  176. this.spinning = true
  177. const paramsPage = Object.assign(this.queryParam, { pageNo: parameter.pageNo, pageSize: parameter.pageSize }) // 有分页
  178. return salesBillReportGroupByBuyerList(paramsPage).then(res => {
  179. let data
  180. if (res.status == 200) {
  181. data = res.data
  182. this.getCount(paramsPage)
  183. const no = (data.pageNo - 1) * data.pageSize
  184. for (var i = 0; i < data.list.length; i++) {
  185. data.list[i].no = no + i + 1
  186. }
  187. this.disabled = false
  188. }
  189. this.spinning = false
  190. return data
  191. })
  192. },
  193. totalData: null
  194. }
  195. },
  196. watch: {
  197. advanced (newValue, oldValue) {
  198. const _this = this
  199. this.$nextTick(() => { // 页面渲染完成后的回调
  200. _this.setTableH()
  201. })
  202. },
  203. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  204. this.setTableH()
  205. }
  206. },
  207. methods: {
  208. // 导出
  209. handleExport () {
  210. const _this = this
  211. this.$refs.ruleForm.validate(valid => {
  212. if (valid) {
  213. const params = _this.queryParam
  214. _this.$store.state.app.curActionPermission = 'B_salesAmountReport_export'
  215. _this.showExport = true
  216. _this.exportLoading = true
  217. _this.spinning = true
  218. hdExportExcel(salesAmountExport, params, '开单销售报表', function () {
  219. _this.exportLoading = false
  220. _this.spinning = false
  221. _this.$store.state.app.curActionPermission = ''
  222. })
  223. } else {
  224. return false
  225. }
  226. })
  227. },
  228. // 总计
  229. getCount (params) {
  230. salesBillReportCountByBuyer(params).then(res => {
  231. if (res.status == 200 && res.data) {
  232. this.totalData = res.data
  233. } else {
  234. this.totalData = null
  235. }
  236. })
  237. },
  238. handleSearch () {
  239. const _this = this
  240. this.$refs.ruleForm.validate(valid => {
  241. if (valid) {
  242. _this.$refs.table.refresh(true)
  243. } else {
  244. _this.$message.error('请选择下推时间')
  245. return false
  246. }
  247. })
  248. },
  249. // 创建时间 change
  250. dateChange (date) {
  251. if (date[0] && date[1]) {
  252. this.queryParam.time = date
  253. } else {
  254. this.queryParam.time = []
  255. }
  256. this.queryParam.beginDate = date[0] || ''
  257. this.queryParam.endDate = date[1] || ''
  258. },
  259. custChange (val) {
  260. this.queryParam.dealerSn = val.key
  261. },
  262. subareaChange (val) {
  263. this.queryParam.subareaArea.subareaSn = val[0] ? val[0] : undefined
  264. this.queryParam.subareaArea.subareaAreaSn = val[1] ? val[1] : undefined
  265. },
  266. // 重置
  267. resetSearchForm () {
  268. this.queryParam.time = [
  269. getDate.getCurrMonthDays().starttime,
  270. getDate.getCurrMonthDays().endtime
  271. ]
  272. this.$refs.rangeDate.resetDate(this.queryParam.time)
  273. this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
  274. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  275. this.queryParam.dealerSn = undefined
  276. this.queryParam.provinceSn = undefined
  277. this.queryParam.citySn = undefined
  278. this.queryParam.districtSn = undefined
  279. this.queryParam.subareaArea.subareaSn = undefined
  280. this.queryParam.subareaArea.subareaAreaSn = undefined
  281. this.queryParam.subareaArea.bizUserSn = undefined
  282. this.queryParam.dealerLevel = undefined
  283. this.queryParam.bizUserSn = undefined
  284. this.totalData = null
  285. this.$refs.subarea.clearData()
  286. if (this.advanced) {
  287. this.$refs.areaList.clearData()
  288. }
  289. this.$refs.custList.resetForm()
  290. this.$refs.ruleForm.resetFields()
  291. this.$refs.table.clearTable()
  292. },
  293. areaChange (val) {
  294. this.queryParam.provinceSn = val[0] ? val[0] : ''
  295. this.queryParam.citySn = val[1] ? val[1] : ''
  296. this.queryParam.districtSn = val[2] ? val[2] : ''
  297. },
  298. // 获取表头
  299. async getTableTitle () {
  300. const _this = this
  301. const tableTitle = await salesKdxxReportTitle().then(res => res.data)
  302. this.columns = tableTitle.list
  303. this.countLabel = tableTitle.count.filter(item => item.title.indexOf('品牌') < 0)
  304. this.countBrandLabel = tableTitle.count.filter(item => item.title.indexOf('品牌') >= 0)
  305. this.columns.map(item => {
  306. let mw = 20
  307. if (item.customRender == 'amount') {
  308. mw = 15
  309. item.customRender = function (text) { return (text || text == 0) ? _this.toThousands(text) : '--' }
  310. } else {
  311. item.customRender = function (text) { return text || '--' }
  312. }
  313. const w = item.title.length * mw
  314. const tw = w <= 80 ? mw * 5 : w
  315. item.width = tw + 'px'
  316. this.tableWidth = this.tableWidth + tw
  317. })
  318. this.resetSearchForm()
  319. },
  320. setTableH () {
  321. const tableSearchH = this.$refs.tableSearch.offsetHeight
  322. this.tableHeight = window.innerHeight - tableSearchH - 215
  323. }
  324. },
  325. mounted () {
  326. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  327. this.getTableTitle()
  328. this.setTableH()
  329. }
  330. },
  331. activated () {
  332. // 如果是新页签打开,则重置当前页面
  333. if (this.$store.state.app.isNewTab) {
  334. this.getTableTitle()
  335. this.setTableH()
  336. }
  337. },
  338. beforeRouteEnter (to, from, next) {
  339. next(vm => {})
  340. }
  341. }
  342. </script>