list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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. <dealerSubareaScopeList ref="custList" id="actualSalesReportList-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.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. <template v-if="advanced">
  37. <a-col :md="6" :sm="24">
  38. <a-form-model-item label="所在区域">
  39. <subarea id="actualSalesReportList-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="actualSalesReportList-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="actualSalesReportList-refresh">查询</a-button>
  55. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="actualSalesReportList-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_actualSalesReport_export')"
  64. id="actualSalesReportList-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. :rowKey="(record) => record.no"
  79. rowKeyName="no"
  80. :columns="columns"
  81. :data="loadData"
  82. :scroll="{ x: 2250 }"
  83. :defaultLoadData="false"
  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 reportModal from '@/views/common/reportModal.vue'
  118. import subarea from '@/views/common/subarea.js'
  119. import AreaList from '@/views/common/areaList.js'
  120. import BizUser from '@/views/common/bizUser.js'
  121. import { hdExportExcel } from '@/libs/exportExcel'
  122. import { salesBillRealReportTitle, salesBillRealAmountQueryPageList, salesBillRealReportCount } from '@/api/salesBillReport'
  123. import { actualSalesExport } from '@/api/reportData'
  124. export default {
  125. name: 'ActualSalesReportList',
  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. subareaArea:{
  142. subareaSn: undefined,
  143. subareaAreaSn: undefined,
  144. bizUserSn: undefined
  145. },
  146. dealer: {
  147. dealerSn: undefined,
  148. provinceSn: undefined,
  149. citySn: undefined,
  150. districtSn: undefined,
  151. dealerLevel: undefined
  152. }
  153. },
  154. rules: {
  155. 'time': [{ required: true, message: '请选择销售日期', trigger: 'change' }]
  156. },
  157. disabled: false, // 查询、重置按钮是否可操作
  158. exportLoading: false,
  159. // 加载数据方法 必须为 Promise 对象
  160. loadData: parameter => {
  161. this.disabled = true
  162. this.spinning = true
  163. if (this.tableHeight == 0) {
  164. this.tableHeight = window.innerHeight - 380
  165. }
  166. const paramsPage = Object.assign(this.queryParam, { pageNo: parameter.pageNo, pageSize: parameter.pageSize }) // 有分页
  167. return salesBillRealAmountQueryPageList(paramsPage).then(res => {
  168. let data
  169. if (res.status == 200) {
  170. data = res.data
  171. this.getCount(paramsPage)
  172. const no = (data.pageNo - 1) * data.pageSize
  173. for (var i = 0; i < data.list.length; i++) {
  174. data.list[i].no = no + i + 1
  175. }
  176. this.disabled = false
  177. }
  178. this.spinning = false
  179. return data
  180. })
  181. },
  182. totalData: null,
  183. columns: [],
  184. countLabel: [],
  185. countBrandLabel:[]
  186. }
  187. },
  188. methods: {
  189. // 导出
  190. handleExport () {
  191. const _this = this
  192. this.$refs.ruleForm.validate(valid => {
  193. if (valid) {
  194. _this.showExport = true
  195. const params = _this.queryParam
  196. _this.$store.state.app.curActionPermission = 'B_actualSalesReport_export'
  197. _this.exportLoading = true
  198. _this.spinning = true
  199. hdExportExcel(actualSalesExport, params, '实售销售报表', function () {
  200. _this.exportLoading = false
  201. _this.spinning = false
  202. _this.$store.state.app.curActionPermission = ''
  203. })
  204. } else {
  205. return false
  206. }
  207. })
  208. },
  209. // 总计
  210. getCount (params) {
  211. salesBillRealReportCount(params).then(res => {
  212. if (res.status == 200 && res.data) {
  213. this.totalData = res.data
  214. } else {
  215. this.totalData = null
  216. }
  217. })
  218. },
  219. handleSearch () {
  220. const _this = this
  221. this.$refs.ruleForm.validate(valid => {
  222. if (valid) {
  223. _this.$refs.table.refresh(true)
  224. } else {
  225. _this.$message.error('请选择销售日期')
  226. return false
  227. }
  228. })
  229. },
  230. // 创建时间 change
  231. dateChange (date) {
  232. if (date[0] && date[1]) {
  233. this.queryParam.time = date
  234. } else {
  235. this.queryParam.time = []
  236. }
  237. this.queryParam.beginDate = date[0] || ''
  238. this.queryParam.endDate = date[1] || ''
  239. },
  240. custChange (val) {
  241. this.queryParam.dealer.dealerSn = val.key
  242. },
  243. subareaChange (val) {
  244. this.queryParam.subareaArea.subareaSn = val[0] ? val[0] : undefined
  245. this.queryParam.subareaArea.subareaAreaSn = val[1] ? val[1] : undefined
  246. },
  247. // 重置
  248. resetSearchForm () {
  249. this.queryParam.time = [
  250. getDate.getCurrMonthDays().starttime,
  251. getDate.getCurrMonthDays().endtime
  252. ]
  253. this.$refs.rangeDate.resetDate(this.queryParam.time)
  254. this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
  255. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  256. this.queryParam.dealer = {
  257. dealerSn: undefined,
  258. provinceSn: undefined,
  259. citySn: undefined,
  260. districtSn: undefined,
  261. dealerLevel: undefined
  262. }
  263. this.queryParam.subareaArea = {
  264. subareaSn: undefined,
  265. subareaAreaSn: undefined,
  266. bizUserSn: undefined
  267. }
  268. this.totalData = null
  269. if (this.advanced) {
  270. this.$refs.areaList.clearData()
  271. this.$refs.subarea.clearData()
  272. }
  273. this.$refs.custList.resetForm()
  274. this.$refs.ruleForm.resetFields()
  275. this.$refs.table.clearTable()
  276. },
  277. areaChange (val) {
  278. this.queryParam.dealer.provinceSn = val[0] ? val[0] : ''
  279. this.queryParam.dealer.citySn = val[1] ? val[1] : ''
  280. this.queryParam.dealer.districtSn = val[2] ? val[2] : ''
  281. },
  282. // 获取表头
  283. async getTableTitle () {
  284. const _this = this
  285. const tableTitle = await salesBillRealReportTitle().then(res => res.data)
  286. this.columns = tableTitle.list
  287. this.countLabel = tableTitle.count.filter(item => item.title.indexOf('品牌')<0)
  288. this.countBrandLabel = tableTitle.count.filter(item => item.title.indexOf('品牌')>=0)
  289. this.columns.map(item => {
  290. let mw = 20
  291. if (item.customRender == 'amount') {
  292. mw = 15
  293. item.customRender = function (text) { return (text || text == 0) ? _this.toThousands(text) : '--' }
  294. }
  295. const w = item.title.length * mw
  296. const tw = w <= 80 && item.customRender != 'amount' ? w * 2 : (w >= 360 ? 200 : w)
  297. item.width = tw + 'px'
  298. this.tableWidth = this.tableWidth + tw
  299. })
  300. this.resetSearchForm()
  301. }
  302. },
  303. mounted () {
  304. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  305. this.getTableTitle()
  306. }
  307. },
  308. activated () {
  309. // 如果是新页签打开,则重置当前页面
  310. if (this.$store.state.app.isNewTab) {
  311. this.getTableTitle()
  312. }
  313. },
  314. beforeRouteEnter (to, from, next) {
  315. next(vm => {})
  316. }
  317. }
  318. </script>