list.vue 13 KB

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