list.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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. subareaSn: undefined,
  132. dealerLevel: undefined,
  133. subareaAreaSn: undefined
  134. },
  135. columns: [],
  136. countLabel: [],
  137. rules: {
  138. 'time': [{ required: true, message: '请选择销售日期', trigger: 'change' }]
  139. },
  140. disabled: false, // 查询、重置按钮是否可操作
  141. exportLoading: false,
  142. // 加载数据方法 必须为 Promise 对象
  143. loadData: parameter => {
  144. this.disabled = true
  145. this.spinning = true
  146. if (this.tableHeight == 0) {
  147. this.tableHeight = window.innerHeight - 380
  148. }
  149. const paramsPage = Object.assign(this.queryParam, { pageNo: parameter.pageNo, pageSize: parameter.pageSize }) // 有分页
  150. return salesBillReportGroupByBuyerList(paramsPage).then(res => {
  151. let data
  152. if (res.status == 200) {
  153. data = res.data
  154. this.getCount(paramsPage)
  155. const no = (data.pageNo - 1) * data.pageSize
  156. for (var i = 0; i < data.list.length; i++) {
  157. data.list[i].no = no + i + 1
  158. }
  159. this.disabled = false
  160. }
  161. this.spinning = false
  162. return data
  163. })
  164. },
  165. totalData: null
  166. }
  167. },
  168. methods: {
  169. getSubareaSn (con) {
  170. this.queryParam.subareaSn = con[0]
  171. },
  172. // 导出
  173. handleExport () {
  174. const _this = this
  175. this.$refs.ruleForm.validate(valid => {
  176. if (valid) {
  177. const params = _this.queryParam
  178. _this.$store.state.app.curActionPermission = 'B_salesAmountReport_export'
  179. _this.showExport = true
  180. _this.exportLoading = true
  181. _this.spinning = true
  182. hdExportExcel(salesAmountExport, params, '开单销售报表', function () {
  183. _this.exportLoading = false
  184. _this.spinning = false
  185. _this.$store.state.app.curActionPermission = ''
  186. })
  187. } else {
  188. return false
  189. }
  190. })
  191. },
  192. // 总计
  193. getCount (params) {
  194. salesBillReportCountByBuyer(params).then(res => {
  195. if (res.status == 200 && res.data) {
  196. this.totalData = res.data
  197. } else {
  198. this.totalData = null
  199. }
  200. })
  201. },
  202. handleSearch () {
  203. const _this = this
  204. this.$refs.ruleForm.validate(valid => {
  205. if (valid) {
  206. _this.$refs.table.refresh(true)
  207. } else {
  208. _this.$message.error('请选择销售日期')
  209. return false
  210. }
  211. })
  212. },
  213. // 创建时间 change
  214. dateChange (date) {
  215. if (date[0] && date[1]) {
  216. this.queryParam.time = date
  217. } else {
  218. this.queryParam.time = []
  219. }
  220. this.queryParam.beginDate = date[0] || ''
  221. this.queryParam.endDate = date[1] || ''
  222. },
  223. custChange (val) {
  224. this.queryParam.dealerSn = val.key
  225. },
  226. subareaChange (val) {
  227. this.queryParam.subareaSn = val[0] ? val[0] : undefined
  228. this.queryParam.subareaAreaSn = val[1] ? val[1] : undefined
  229. },
  230. // 重置
  231. resetSearchForm () {
  232. this.queryParam.time = [
  233. getDate.getCurrMonthDays().starttime,
  234. getDate.getCurrMonthDays().endtime
  235. ]
  236. this.$refs.rangeDate.resetDate(this.queryParam.time)
  237. this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
  238. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  239. this.queryParam.dealerSn = undefined
  240. this.queryParam.provinceSn = undefined
  241. this.queryParam.citySn = undefined
  242. this.queryParam.districtSn = undefined
  243. this.queryParam.subareaSn = undefined
  244. this.queryParam.subareaAreaSn = undefined
  245. this.queryParam.dealerLevel = undefined
  246. this.totalData = null
  247. this.$refs.subarea.clearData()
  248. if (this.advanced) {
  249. this.$refs.areaList.clearData()
  250. }
  251. this.$refs.custList.resetForm()
  252. this.$refs.ruleForm.resetFields()
  253. this.$refs.table.clearTable()
  254. },
  255. areaChange (val) {
  256. this.queryParam.provinceSn = val[0] ? val[0] : ''
  257. this.queryParam.citySn = val[1] ? val[1] : ''
  258. this.queryParam.districtSn = val[2] ? val[2] : ''
  259. },
  260. // 获取表头
  261. async getTableTitle () {
  262. const _this = this
  263. const tableTitle = await salesKdxxReportTitle().then(res => res.data)
  264. this.columns = tableTitle.list
  265. this.countLabel = tableTitle.count
  266. this.columns.map(item => {
  267. let mw = 40
  268. if (item.customRender == 'amount') {
  269. mw = 15
  270. item.customRender = function (text) { return (text || text == 0) ? _this.toThousands(text) : '--' }
  271. }
  272. const w = item.title.length * mw
  273. const tw = w <= 80 && item.customRender != 'amount' ? w * 2 : (w >= 360 ? 200 : w)
  274. item.width = tw + 'px'
  275. this.tableWidth = this.tableWidth + tw
  276. })
  277. this.resetSearchForm()
  278. }
  279. },
  280. mounted () {
  281. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  282. this.getTableTitle()
  283. }
  284. },
  285. activated () {
  286. // 如果是新页签打开,则重置当前页面
  287. if (this.$store.state.app.isNewTab) {
  288. this.getTableTitle()
  289. }
  290. },
  291. beforeRouteEnter (to, from, next) {
  292. next(vm => {})
  293. }
  294. }
  295. </script>