list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  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. <a-col :md="6" :sm="24" v-if="isShowCustomerSearch">
  37. <a-form-model-item label="销售单号">
  38. <a-input id="salesSlipReportList-salesBillNo" v-model.trim="queryParam.salesBillNo" allowClear placeholder="请输入销售单号"/>
  39. </a-form-model-item>
  40. </a-col>
  41. <template v-if="advanced">
  42. <a-col :md="6" :sm="24" v-if="!isShowCustomerSearch">
  43. <a-form-model-item label="销售单号">
  44. <a-input id="salesSlipReportList-salesBillNo" v-model.trim="queryParam.salesBillNo" allowClear placeholder="请输入销售单号"/>
  45. </a-form-model-item>
  46. </a-col>
  47. <a-col :md="6" :sm="24">
  48. <a-form-model-item label="所在区域">
  49. <subarea id="salesSlipReportList-subareaSn" ref="subarea" @change="subareaChange"></subarea>
  50. </a-form-model-item>
  51. </a-col>
  52. <a-col :md="6" :sm="24">
  53. <a-form-model-item label="区域负责人">
  54. <BizUser id="salesSlipReportList-bizUserSn" v-model="queryParam.subareaArea.bizUserSn"></BizUser>
  55. </a-form-model-item>
  56. </a-col>
  57. <a-col :md="6" :sm="24">
  58. <a-form-model-item label="地区">
  59. <AreaList id="salesSlipReportList-areaList" changeOnSelect ref="areaList" @change="areaChange" defValKey="id"></AreaList>
  60. </a-form-model-item>
  61. </a-col>
  62. <a-col :md="6" :sm="24" v-show="isShowCustomerSearch">
  63. <a-form-model-item label="客服">
  64. <customerService id="salesSlipReportList-customerName" ref="customerName" v-model="queryParam.bizUserSn"></customerService>
  65. </a-form-model-item>
  66. </a-col>
  67. </template>
  68. <a-col :md="isShowCustomerSearch?24:6" :sm="24" style="margin-bottom: 10px;" :style="{textAlign: isShowCustomerSearch?'center':''}">
  69. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="salesSlipReportList-refresh">查询</a-button>
  70. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="salesSlipReportList-reset">重置</a-button>
  71. <a-button
  72. style="margin-left: 10px"
  73. type="primary"
  74. class="button-warning"
  75. @click="handleExport"
  76. :disabled="disabled"
  77. :loading="exportLoading"
  78. v-if="$hasPermissions('B_salesSlip_report')"
  79. id="salesSlipReportList-export">导出</a-button>
  80. <a @click="advanced=!advanced" style="margin-left: 8px">
  81. {{ advanced ? '收起' : '展开' }}
  82. <a-icon :type="advanced ? 'up' : 'down'"/>
  83. </a>
  84. </a-col>
  85. </a-row>
  86. </a-form-model>
  87. </div>
  88. </a-card>
  89. <a-card size="small" :bordered="false">
  90. <a-spin :spinning="spinning" tip="Loading...">
  91. <!-- 列表 -->
  92. <s-table
  93. class="sTable fixPagination"
  94. ref="table"
  95. size="small"
  96. :defaultLoadData="false"
  97. :rowKey="(record) => record.no"
  98. rowKeyName="no"
  99. :columns="columns"
  100. :data="loadData"
  101. :pageSize="30"
  102. :style="{ height: tableHeight+84.5+'px' }"
  103. :scroll="{ x: 2410,y: tableHeight-136 }"
  104. bordered>
  105. <template slot="footer" v-if="countLabel.length||countBrandLabel.length">
  106. <a-row>
  107. <a-col span="2">合计:</a-col>
  108. <a-col span="22">
  109. <a-row>
  110. <a-col span="4" v-for="item in countLabel" :key="item.key">
  111. {{ item.title }}:{{ totalData?(totalData[item.dataIndex]||totalData[item.dataIndex]==0)?toThousands(totalData[item.dataIndex]):'--':'--' }}
  112. </a-col>
  113. </a-row>
  114. <a-row>
  115. <a-col span="24" style="padding:8px;"></a-col>
  116. </a-row>
  117. <a-row>
  118. <a-col span="4" v-for="item in countBrandLabel" :key="item.key">
  119. {{ item.title }}:{{ totalData?(totalData[item.dataIndex] ||totalData[item.dataIndex]==0)?toThousands(totalData[item.dataIndex]):'--':'--' }}
  120. </a-col>
  121. </a-row>
  122. </a-col>
  123. </a-row>
  124. </template>
  125. </s-table>
  126. </a-spin>
  127. <!-- 导出提示框 -->
  128. <reportModal :visible="showExport" @close="showExport=false"></reportModal>
  129. </a-card>
  130. </div>
  131. </template>
  132. <script>
  133. import { commonMixin } from '@/utils/mixin'
  134. import getDate from '@/libs/getDate.js'
  135. import { hdExportExcel } from '@/libs/exportExcel'
  136. // 组件
  137. import { STable, VSelect } from '@/components'
  138. import rangeDate from '@/views/common/rangeDate.vue'
  139. import subarea from '@/views/common/subarea.js'
  140. import reportModal from '@/views/common/reportModal.vue'
  141. import AreaList from '@/views/common/areaList.js'
  142. import BizUser from '@/views/common/bizUser.js'
  143. import customerService from '@/views/common/customerService'
  144. import dealerSubareaScopeList from '@/views/common/dealerSubareaScopeList.vue'
  145. // 接口
  146. import { salesSlipExport } from '@/api/reportData'
  147. import { salesKdxxdReportTitle, salesBillReportList, salesBillReportCount } from '@/api/salesBillReport'
  148. export default {
  149. name: 'SalesSlipReportList',
  150. mixins: [commonMixin],
  151. components: { STable, VSelect, rangeDate, subarea, dealerSubareaScopeList, reportModal, AreaList, BizUser, customerService },
  152. data () {
  153. return {
  154. spinning: false,
  155. advanced: true, // 高级搜索 展开/关闭
  156. disabled: false, // 查询、重置按钮是否可操作
  157. tableHeight: 0, // 表格高度
  158. showExport: false, // 导出弹窗
  159. exportLoading: false, // 导出按钮加载状态
  160. // 查询条件
  161. queryParam: {
  162. // 默认下推时间
  163. time: [
  164. getDate.getCurrMonthDays().starttime,
  165. getDate.getCurrMonthDays().endtime
  166. ],
  167. beginDate: getDate.getCurrMonthDays().starttime, // 开始时间
  168. endDate: getDate.getCurrMonthDays().endtime, // 结束时间
  169. salesBillNo: '', // 销售单号
  170. dealerSn: undefined, // 客户sn
  171. dealerLevel: undefined, // 客户等级
  172. provinceSn: undefined, // 省
  173. citySn: undefined, // 市
  174. districtSn: undefined, // 区
  175. subareaArea: {
  176. subareaSn: undefined, // 区域
  177. subareaAreaSn: undefined, // 分区
  178. bizUserSn: undefined// 区域负责人
  179. },
  180. bizUserSn: undefined// 客服
  181. },
  182. columns: [], // 表格列
  183. countLabel: [], // 统计品牌数据
  184. countBrandLabel: [], // 统计分类数据
  185. totalData: null, // 统计
  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 salesBillReportList(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. const params = _this.queryParam
  233. _this.$store.state.app.curActionPermission = 'B_salesSlip_report'
  234. _this.showExport = true
  235. _this.exportLoading = true
  236. _this.spinning = true
  237. hdExportExcel(salesSlipExport, 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. salesBillReportCount(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.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.salesBillNo = ''
  298. this.queryParam.dealerSn = undefined
  299. this.queryParam.provinceSn = undefined
  300. this.queryParam.citySn = undefined
  301. this.queryParam.districtSn = undefined
  302. this.queryParam.subareaArea.subareaSn = undefined
  303. this.queryParam.subareaArea.subareaAreaSn = undefined
  304. this.queryParam.subareaArea.bizUserSn = undefined
  305. this.queryParam.dealerLevel = undefined
  306. this.queryParam.bizUserSn = undefined
  307. this.totalData = null
  308. if (this.advanced) {
  309. this.$refs.subarea.clearData()
  310. this.$refs.areaList.clearData()
  311. }
  312. this.$refs.custList.resetForm()
  313. this.$refs.ruleForm.resetFields()
  314. this.$refs.table.clearTable()
  315. },
  316. // 地区
  317. areaChange (val) {
  318. this.queryParam.provinceSn = val[0] ? val[0] : ''
  319. this.queryParam.citySn = val[1] ? val[1] : ''
  320. this.queryParam.districtSn = val[2] ? val[2] : ''
  321. },
  322. // 获取表头
  323. async getTableTitle () {
  324. const _this = this
  325. const tableTitle = await salesKdxxdReportTitle().then(res => res.data)
  326. this.columns = tableTitle.list
  327. this.countLabel = tableTitle.count.filter(item => item.title.indexOf('品牌') < 0)
  328. this.countBrandLabel = tableTitle.count.filter(item => item.title.indexOf('品牌') >= 0)
  329. this.columns.map(item => {
  330. let mw = 20
  331. if (item.customRender == 'amount') {
  332. mw = 15
  333. item.customRender = function (text) { return (text || text == 0) ? _this.toThousands(text) : '--' }
  334. } else {
  335. item.customRender = function (text) { return text || '--' }
  336. }
  337. const w = item.title.length * mw
  338. const tw = w <= 80 ? mw * 5 : w
  339. item.width = tw + 'px'
  340. this.tableWidth = this.tableWidth + tw
  341. })
  342. this.resetSearchForm()
  343. },
  344. // 计算表格高度
  345. setTableH () {
  346. const tableSearchH = this.$refs.tableSearch.offsetHeight
  347. this.tableHeight = window.innerHeight - tableSearchH - 215
  348. }
  349. },
  350. mounted () {
  351. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  352. this.getTableTitle()
  353. this.setTableH()
  354. }
  355. },
  356. activated () {
  357. // 如果是新页签打开,则重置当前页面
  358. if (this.$store.state.app.isNewTab) {
  359. this.getTableTitle()
  360. this.setTableH()
  361. }
  362. },
  363. beforeRouteEnter (to, from, next) {
  364. next(vm => {})
  365. }
  366. }
  367. </script>