list.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <template>
  2. <a-card size="small" :bordered="false" class="actualSalesReportList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div class="table-page-search-wrapper newTableSearchName">
  6. <a-form-model
  7. id="actualSalesReportList-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="actualSalesReportList-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.dealer.dealerLevel"
  29. ref="dealerLevel"
  30. id="actualSalesReportList-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="actualSalesReportList-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="actualSalesReportList-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="actualSalesReportList-refresh">查询</a-button>
  50. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="actualSalesReportList-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_actualSalesReport_export')"
  59. id="actualSalesReportList-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. :rowKey="(record) => record.id"
  74. :columns="columns"
  75. :data="loadData"
  76. :scroll="{ x: 2250 }"
  77. :defaultLoadData="false"
  78. bordered>
  79. <template slot="footer">
  80. <a-row>
  81. <a-col span="2">合计:</a-col>
  82. <a-col span="22">
  83. <a-row>
  84. <a-col span="4" v-for="item in countLabel" :key="item.key">
  85. {{ item.title }}:{{ totalData?totalData[item.dataIndex]:'--' }}
  86. </a-col>
  87. </a-row>
  88. </a-col>
  89. </a-row>
  90. </template>
  91. </s-table>
  92. </a-spin>
  93. <!-- 导出提示框 -->
  94. <reportModal :visible="showExport" @close="showExport=false"></reportModal>
  95. </a-card>
  96. </template>
  97. <script>
  98. import { commonMixin } from '@/utils/mixin'
  99. import getDate from '@/libs/getDate.js'
  100. import { STable, VSelect } from '@/components'
  101. import rangeDate from '@/views/common/rangeDate.vue'
  102. import custList from '@/views/common/custList.vue'
  103. import reportModal from '@/views/common/reportModal.vue'
  104. import subarea from '@/views/common/subarea.js'
  105. import AreaList from '@/views/common/areaList.js'
  106. import { hdExportExcel } from '@/libs/exportExcel'
  107. import { salesBillRealReportTitle, salesBillRealAmountQueryPageList, salesBillRealReportCount } from '@/api/salesBillReport'
  108. import { actualSalesExport } from '@/api/reportData'
  109. export default {
  110. name: 'ActualSalesReportList',
  111. mixins: [commonMixin],
  112. components: { STable, VSelect, rangeDate, subarea, custList, reportModal, AreaList },
  113. data () {
  114. return {
  115. spinning: false,
  116. advanced: true, // 高级搜索 展开/关闭
  117. tableHeight: 0,
  118. showExport: false, // 导出弹窗初始值
  119. queryParam: { // 查询条件
  120. time: [
  121. getDate.getCurrMonthDays().starttime,
  122. getDate.getCurrMonthDays().endtime
  123. ],
  124. beginDate: getDate.getCurrMonthDays().starttime,
  125. endDate: getDate.getCurrMonthDays().endtime,
  126. dealer: {
  127. dealerSn: undefined,
  128. provinceSn: undefined,
  129. citySn: undefined,
  130. districtSn: undefined,
  131. subareaSn: undefined,
  132. subareaAreaSn: undefined, // 分区
  133. dealerLevel: undefined
  134. }
  135. },
  136. rules: {
  137. 'time': [{ required: true, message: '请选择销售日期', trigger: 'change' }]
  138. },
  139. disabled: false, // 查询、重置按钮是否可操作
  140. exportLoading: false,
  141. // 加载数据方法 必须为 Promise 对象
  142. loadData: parameter => {
  143. this.disabled = true
  144. this.spinning = true
  145. if (this.tableHeight == 0) {
  146. this.tableHeight = window.innerHeight - 380
  147. }
  148. const paramsPage = Object.assign(this.queryParam, { pageNo: parameter.pageNo, pageSize: parameter.pageSize }) // 有分页
  149. return salesBillRealAmountQueryPageList(paramsPage).then(res => {
  150. let data
  151. if (res.status == 200) {
  152. data = res.data
  153. this.getCount(paramsPage)
  154. const no = (data.pageNo - 1) * data.pageSize
  155. for (var i = 0; i < data.list.length; i++) {
  156. data.list[i].no = no + i + 1
  157. }
  158. this.disabled = false
  159. }
  160. this.spinning = false
  161. return data
  162. })
  163. },
  164. totalData: null,
  165. columns: [],
  166. countLabel: []
  167. }
  168. },
  169. methods: {
  170. // 导出
  171. handleExport () {
  172. const _this = this
  173. this.$refs.ruleForm.validate(valid => {
  174. if (valid) {
  175. _this.showExport = true
  176. const params = _this.queryParam
  177. _this.$store.state.app.curActionPermission = 'B_actualSalesReport_export'
  178. _this.exportLoading = true
  179. _this.spinning = true
  180. hdExportExcel(actualSalesExport, params, '实售销售报表', function () {
  181. _this.exportLoading = false
  182. _this.spinning = false
  183. _this.$store.state.app.curActionPermission = ''
  184. })
  185. } else {
  186. return false
  187. }
  188. })
  189. },
  190. // 总计
  191. getCount (params) {
  192. salesBillRealReportCount(params).then(res => {
  193. if (res.status == 200 && res.data) {
  194. this.totalData = res.data
  195. } else {
  196. this.totalData = null
  197. }
  198. })
  199. },
  200. handleSearch () {
  201. const _this = this
  202. this.$refs.ruleForm.validate(valid => {
  203. if (valid) {
  204. _this.$refs.table.refresh(true)
  205. } else {
  206. _this.$message.error('请选择销售日期')
  207. return false
  208. }
  209. })
  210. },
  211. // 创建时间 change
  212. dateChange (date) {
  213. if (date[0] && date[1]) {
  214. this.queryParam.time = date
  215. } else {
  216. this.queryParam.time = []
  217. }
  218. this.queryParam.beginDate = date[0] || ''
  219. this.queryParam.endDate = date[1] || ''
  220. },
  221. custChange (val) {
  222. this.queryParam.dealer.dealerSn = val.key
  223. },
  224. subareaChange (val) {
  225. this.queryParam.dealer.subareaSn = val[0] ? val[0] : undefined
  226. this.queryParam.dealer.subareaAreaSn = val[1] ? val[1] : undefined
  227. },
  228. // 重置
  229. resetSearchForm () {
  230. this.queryParam.time = [
  231. getDate.getCurrMonthDays().starttime,
  232. getDate.getCurrMonthDays().endtime
  233. ]
  234. this.$refs.rangeDate.resetDate(this.queryParam.time)
  235. this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
  236. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  237. this.queryParam.dealer = {
  238. dealerSn: undefined,
  239. provinceSn: undefined,
  240. citySn: undefined,
  241. districtSn: undefined,
  242. subareaSn: undefined,
  243. subareaAreaSn: undefined, // 分区
  244. dealerLevel: undefined
  245. }
  246. this.totalData = null
  247. if (this.advanced) {
  248. this.$refs.areaList.clearData()
  249. this.$refs.subarea.clearData()
  250. }
  251. this.$refs.custList.resetForm()
  252. this.$refs.ruleForm.resetFields()
  253. this.$refs.table.clearTable()
  254. },
  255. areaChange (val) {
  256. this.queryParam.dealer.provinceSn = val[0] ? val[0] : ''
  257. this.queryParam.dealer.citySn = val[1] ? val[1] : ''
  258. this.queryParam.dealer.districtSn = val[2] ? val[2] : ''
  259. },
  260. // 获取表头
  261. async getTableTitle () {
  262. const _this = this
  263. const tableTitle = await salesBillRealReportTitle().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>