list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  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. dealerNewFlag: undefined
  185. },
  186. columns: [], // 表格列
  187. countLabel: [], // 统计品牌数据
  188. countBrandLabel: [], // 统计分类数据
  189. totalData: null, // 统计
  190. rules: {
  191. 'time': [{ required: true, message: '请选择下推时间', trigger: 'change' }]
  192. },
  193. // 加载数据方法 必须为 Promise 对象
  194. loadData: parameter => {
  195. this.disabled = true
  196. this.spinning = true
  197. const paramsPage = Object.assign(this.queryParam, { pageNo: parameter.pageNo, pageSize: parameter.pageSize })
  198. // 获取列表数据 有分页
  199. return salesBillReportList(paramsPage).then(res => {
  200. let data
  201. if (res.status == 200) {
  202. data = res.data
  203. // 获取统计数据
  204. this.getCount(paramsPage)
  205. // 计算列表序号
  206. const no = (data.pageNo - 1) * data.pageSize
  207. for (var i = 0; i < data.list.length; i++) {
  208. data.list[i].no = no + i + 1
  209. }
  210. this.disabled = false
  211. }
  212. this.spinning = false
  213. return data
  214. })
  215. }
  216. }
  217. },
  218. watch: {
  219. // 展开关闭
  220. advanced (newValue, oldValue) {
  221. const _this = this
  222. this.$nextTick(() => { // 页面渲染完成后的回调
  223. _this.setTableH()
  224. })
  225. },
  226. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  227. this.setTableH()
  228. }
  229. },
  230. methods: {
  231. // 导出
  232. handleExport () {
  233. const _this = this
  234. this.$refs.ruleForm.validate(valid => {
  235. if (valid) {
  236. const params = _this.queryParam
  237. _this.$store.state.app.curActionPermission = 'B_salesSlip_report'
  238. _this.showExport = true
  239. _this.exportLoading = true
  240. _this.spinning = true
  241. hdExportExcel(salesSlipExport, params, '开单销售单报表', function () {
  242. _this.exportLoading = false
  243. _this.spinning = false
  244. _this.$store.state.app.curActionPermission = ''
  245. })
  246. } else {
  247. return false
  248. }
  249. })
  250. },
  251. // 总计
  252. getCount (params) {
  253. salesBillReportCount(params).then(res => {
  254. if (res.status == 200 && res.data) {
  255. this.totalData = res.data
  256. } else {
  257. this.totalData = null
  258. }
  259. })
  260. },
  261. // 查询
  262. handleSearch () {
  263. const _this = this
  264. this.$refs.ruleForm.validate(valid => {
  265. if (valid) {
  266. _this.$refs.table.refresh(true)
  267. } else {
  268. _this.$message.error('请选择下推时间')
  269. return false
  270. }
  271. })
  272. },
  273. // 下推时间 change
  274. dateChange (date) {
  275. if (date[0] && date[1]) {
  276. this.queryParam.time = date
  277. } else {
  278. this.queryParam.time = []
  279. }
  280. this.queryParam.beginDate = date[0] || ''
  281. this.queryParam.endDate = date[1] || ''
  282. },
  283. // 客户名称 change
  284. custChange (val) {
  285. this.queryParam.dealerSn = val.key
  286. },
  287. // 区域分区 change
  288. subareaChange (val) {
  289. this.queryParam.subareaArea.subareaSn = val[0] ? val[0] : undefined
  290. this.queryParam.subareaArea.subareaAreaSn = val[1] ? val[1] : undefined
  291. },
  292. // 重置
  293. resetSearchForm () {
  294. this.queryParam.time = [
  295. getDate.getCurrMonthDays().starttime,
  296. getDate.getCurrMonthDays().endtime
  297. ]
  298. this.$refs.rangeDate.resetDate(this.queryParam.time)
  299. this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
  300. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  301. this.queryParam.salesBillNo = ''
  302. this.queryParam.dealerSn = undefined
  303. this.queryParam.provinceSn = undefined
  304. this.queryParam.citySn = undefined
  305. this.queryParam.districtSn = undefined
  306. this.queryParam.subareaArea.subareaSn = undefined
  307. this.queryParam.subareaArea.subareaAreaSn = undefined
  308. this.queryParam.subareaArea.bizUserSn = undefined
  309. this.queryParam.dealerLevel = undefined
  310. this.queryParam.bizUserSn = undefined
  311. this.queryParam.dealerNewFlag = undefined
  312. this.totalData = null
  313. if (this.advanced) {
  314. this.$refs.subarea.clearData()
  315. this.$refs.areaList.clearData()
  316. }
  317. this.$refs.custList.resetForm()
  318. this.$refs.ruleForm.resetFields()
  319. this.$refs.table.clearTable()
  320. },
  321. // 地区
  322. areaChange (val) {
  323. this.queryParam.provinceSn = val[0] ? val[0] : ''
  324. this.queryParam.citySn = val[1] ? val[1] : ''
  325. this.queryParam.districtSn = val[2] ? val[2] : ''
  326. },
  327. // 获取表头
  328. async getTableTitle () {
  329. const _this = this
  330. const tableTitle = await salesKdxxdReportTitle().then(res => res.data)
  331. this.columns = tableTitle.list
  332. this.countLabel = tableTitle.count.filter(item => item.title.indexOf('品牌') < 0)
  333. this.countBrandLabel = tableTitle.count.filter(item => item.title.indexOf('品牌') >= 0)
  334. this.columns.map(item => {
  335. let mw = 20
  336. if (item.customRender == 'amount') {
  337. mw = 15
  338. item.customRender = function (text) { return (text || text == 0) ? _this.toThousands(text) : '--' }
  339. } else {
  340. item.customRender = function (text) { return text || '--' }
  341. }
  342. const w = item.title.length * mw
  343. const tw = w <= 80 ? mw * 5 : w
  344. item.width = tw + 'px'
  345. this.tableWidth = this.tableWidth + tw
  346. })
  347. this.resetSearchForm()
  348. },
  349. // 计算表格高度
  350. setTableH () {
  351. const tableSearchH = this.$refs.tableSearch.offsetHeight
  352. this.tableHeight = window.innerHeight - tableSearchH - 215
  353. }
  354. },
  355. mounted () {
  356. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  357. this.getTableTitle()
  358. this.setTableH()
  359. }
  360. },
  361. activated () {
  362. // 如果是新页签打开,则重置当前页面
  363. if (this.$store.state.app.isNewTab) {
  364. this.getTableTitle()
  365. this.setTableH()
  366. }
  367. },
  368. beforeRouteEnter (to, from, next) {
  369. next(vm => {})
  370. }
  371. }
  372. </script>