list.vue 14 KB

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