list.vue 10 KB

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