list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <template>
  2. <a-card size="small" :bordered="false" class="salesAmountReportList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div class="table-page-search-wrapper newTableSearchName">
  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. </template>
  53. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  54. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="salesAmountReportList-refresh">查询</a-button>
  55. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="salesAmountReportList-reset">重置</a-button>
  56. <a-button
  57. style="margin-left: 10px"
  58. type="primary"
  59. class="button-warning"
  60. @click="handleExport"
  61. :disabled="disabled"
  62. :loading="exportLoading"
  63. v-if="$hasPermissions('B_salesAmountReport_export')"
  64. id="returnSlipReportList-export">导出</a-button>
  65. <a @click="advanced=!advanced" style="margin-left: 8px">
  66. {{ advanced ? '收起' : '展开' }}
  67. <a-icon :type="advanced ? 'up' : 'down'"/>
  68. </a>
  69. </a-col>
  70. </a-row>
  71. </a-form-model>
  72. </div>
  73. <!-- 列表 -->
  74. <s-table
  75. class="sTable"
  76. ref="table"
  77. size="small"
  78. :defaultLoadData="false"
  79. :rowKey="(record) => record.no"
  80. rowKeyName="no"
  81. :columns="columns"
  82. :data="loadData"
  83. :scroll="{ x: 2250 }"
  84. bordered>
  85. <template slot="footer" v-if="countLabel.length||countBrandLabel.length">
  86. <a-row>
  87. <a-col span="2">合计:</a-col>
  88. <a-col span="22">
  89. <a-row>
  90. <a-col span="4" v-for="item in countLabel" :key="item.key">
  91. {{ item.title }}:{{ totalData?(totalData[item.dataIndex]||totalData[item.dataIndex]==0)?toThousands(totalData[item.dataIndex]):'--':'--' }}
  92. </a-col>
  93. </a-row>
  94. <a-row>
  95. <a-col span="24" style="padding:8px;"></a-col>
  96. </a-row>
  97. <a-row>
  98. <a-col span="4" v-for="item in countBrandLabel" :key="item.key">
  99. {{ item.title }}:{{ totalData?(totalData[item.dataIndex] ||totalData[item.dataIndex]==0)?toThousands(totalData[item.dataIndex]):'--':'--' }}
  100. </a-col>
  101. </a-row>
  102. </a-col>
  103. </a-row>
  104. </template>
  105. </s-table>
  106. </a-spin>
  107. <!-- 导出提示框 -->
  108. <reportModal :visible="showExport" @close="showExport=false"></reportModal>
  109. </a-card>
  110. </template>
  111. <script>
  112. import { commonMixin } from '@/utils/mixin'
  113. import getDate from '@/libs/getDate.js'
  114. import { STable, VSelect } from '@/components'
  115. import rangeDate from '@/views/common/rangeDate.vue'
  116. import dealerSubareaScopeList from '@/views/common/dealerSubareaScopeList.vue'
  117. import subarea from '@/views/common/subarea.js'
  118. import reportModal from '@/views/common/reportModal.vue'
  119. import AreaList from '@/views/common/areaList.js'
  120. import BizUser from '@/views/common/bizUser.js'
  121. import { hdExportExcel } from '@/libs/exportExcel'
  122. import { salesKdxxReportTitle, salesBillReportGroupByBuyerList, salesBillReportCountByBuyer } from '@/api/salesBillReport'
  123. import { salesAmountExport } from '@/api/reportData'
  124. export default {
  125. name: 'SalesAmountReportList',
  126. mixins: [commonMixin],
  127. components: { STable, VSelect, rangeDate, subarea, dealerSubareaScopeList, reportModal, AreaList, BizUser },
  128. data () {
  129. return {
  130. spinning: false,
  131. advanced: true, // 高级搜索 展开/关闭
  132. tableHeight: 0,
  133. showExport: false,
  134. queryParam: { // 查询条件
  135. time: [
  136. getDate.getCurrMonthDays().starttime,
  137. getDate.getCurrMonthDays().endtime
  138. ],
  139. beginDate: getDate.getCurrMonthDays().starttime,
  140. endDate: getDate.getCurrMonthDays().endtime,
  141. dealerSn: undefined,
  142. provinceSn: undefined,
  143. citySn: undefined,
  144. districtSn: undefined,
  145. dealerLevel: undefined,
  146. subareaArea:{
  147. subareaSn: undefined,
  148. subareaAreaSn: undefined,
  149. bizUserSn: undefined
  150. },
  151. },
  152. columns: [],
  153. countLabel: [],
  154. countBrandLabel:[],
  155. rules: {
  156. 'time': [{ required: true, message: '请选择销售日期', trigger: 'change' }]
  157. },
  158. disabled: false, // 查询、重置按钮是否可操作
  159. exportLoading: false,
  160. // 加载数据方法 必须为 Promise 对象
  161. loadData: parameter => {
  162. this.disabled = true
  163. this.spinning = true
  164. if (this.tableHeight == 0) {
  165. this.tableHeight = window.innerHeight - 380
  166. }
  167. const paramsPage = Object.assign(this.queryParam, { pageNo: parameter.pageNo, pageSize: parameter.pageSize }) // 有分页
  168. return salesBillReportGroupByBuyerList(paramsPage).then(res => {
  169. let data
  170. if (res.status == 200) {
  171. data = res.data
  172. this.getCount(paramsPage)
  173. const no = (data.pageNo - 1) * data.pageSize
  174. for (var i = 0; i < data.list.length; i++) {
  175. data.list[i].no = no + i + 1
  176. }
  177. this.disabled = false
  178. }
  179. this.spinning = false
  180. return data
  181. })
  182. },
  183. totalData: null
  184. }
  185. },
  186. methods: {
  187. // 导出
  188. handleExport () {
  189. const _this = this
  190. this.$refs.ruleForm.validate(valid => {
  191. if (valid) {
  192. const params = _this.queryParam
  193. _this.$store.state.app.curActionPermission = 'B_salesAmountReport_export'
  194. _this.showExport = true
  195. _this.exportLoading = true
  196. _this.spinning = true
  197. hdExportExcel(salesAmountExport, params, '开单销售报表', function () {
  198. _this.exportLoading = false
  199. _this.spinning = false
  200. _this.$store.state.app.curActionPermission = ''
  201. })
  202. } else {
  203. return false
  204. }
  205. })
  206. },
  207. // 总计
  208. getCount (params) {
  209. salesBillReportCountByBuyer(params).then(res => {
  210. if (res.status == 200 && res.data) {
  211. this.totalData = res.data
  212. } else {
  213. this.totalData = null
  214. }
  215. })
  216. },
  217. handleSearch () {
  218. const _this = this
  219. this.$refs.ruleForm.validate(valid => {
  220. if (valid) {
  221. _this.$refs.table.refresh(true)
  222. } else {
  223. _this.$message.error('请选择销售日期')
  224. return false
  225. }
  226. })
  227. },
  228. // 创建时间 change
  229. dateChange (date) {
  230. if (date[0] && date[1]) {
  231. this.queryParam.time = date
  232. } else {
  233. this.queryParam.time = []
  234. }
  235. this.queryParam.beginDate = date[0] || ''
  236. this.queryParam.endDate = date[1] || ''
  237. },
  238. custChange (val) {
  239. this.queryParam.dealerSn = val.key
  240. },
  241. subareaChange (val) {
  242. this.queryParam.subareaArea.subareaSn = val[0] ? val[0] : undefined
  243. this.queryParam.subareaArea.subareaAreaSn = val[1] ? val[1] : undefined
  244. },
  245. // 重置
  246. resetSearchForm () {
  247. this.queryParam.time = [
  248. getDate.getCurrMonthDays().starttime,
  249. getDate.getCurrMonthDays().endtime
  250. ]
  251. this.$refs.rangeDate.resetDate(this.queryParam.time)
  252. this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
  253. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  254. this.queryParam.dealerSn = undefined
  255. this.queryParam.provinceSn = undefined
  256. this.queryParam.citySn = undefined
  257. this.queryParam.districtSn = undefined
  258. this.queryParam.subareaArea.subareaSn = undefined
  259. this.queryParam.subareaArea.subareaAreaSn = undefined
  260. this.queryParam.subareaArea.bizUserSn = undefined
  261. this.queryParam.dealerLevel = undefined
  262. this.totalData = null
  263. this.$refs.subarea.clearData()
  264. if (this.advanced) {
  265. this.$refs.areaList.clearData()
  266. }
  267. this.$refs.custList.resetForm()
  268. this.$refs.ruleForm.resetFields()
  269. this.$refs.table.clearTable()
  270. },
  271. areaChange (val) {
  272. this.queryParam.provinceSn = val[0] ? val[0] : ''
  273. this.queryParam.citySn = val[1] ? val[1] : ''
  274. this.queryParam.districtSn = val[2] ? val[2] : ''
  275. },
  276. // 获取表头
  277. async getTableTitle () {
  278. const _this = this
  279. const tableTitle = await salesKdxxReportTitle().then(res => res.data)
  280. this.columns = tableTitle.list
  281. this.countLabel = tableTitle.count.filter(item => item.title.indexOf('品牌')<0)
  282. this.countBrandLabel = tableTitle.count.filter(item => item.title.indexOf('品牌')>=0)
  283. this.columns.map(item => {
  284. let mw = 20
  285. if (item.customRender == 'amount') {
  286. mw = 15
  287. item.customRender = function (text) { return (text || text == 0) ? _this.toThousands(text) : '--' }
  288. }else{
  289. item.customRender = function (text) { return text || '--' }
  290. }
  291. const w = item.title.length * mw
  292. const tw = w <= 80 ? mw*5 : w
  293. item.width = tw + 'px'
  294. this.tableWidth = this.tableWidth + tw
  295. })
  296. this.resetSearchForm()
  297. }
  298. },
  299. mounted () {
  300. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  301. this.getTableTitle()
  302. }
  303. },
  304. activated () {
  305. // 如果是新页签打开,则重置当前页面
  306. if (this.$store.state.app.isNewTab) {
  307. this.getTableTitle()
  308. }
  309. },
  310. beforeRouteEnter (to, from, next) {
  311. next(vm => {})
  312. }
  313. }
  314. </script>