list.vue 14 KB

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