list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. <template>
  2. <a-card size="small" :bordered="false" class="salesSlipReportList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div class="table-page-search-wrapper newTableSearchName">
  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">
  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">
  43. <a-form-model-item label="所在区域">
  44. <subarea id="salesSlipReportList-allocateTypeSn" ref="subarea" @change="subareaChange"></subarea>
  45. </a-form-model-item>
  46. </a-col>
  47. <a-col :md="6" :sm="24">
  48. <a-form-model-item label="地区">
  49. <AreaList id="salesSlipReportList-areaList" changeOnSelect ref="areaList" @change="areaChange" defValKey="id"></AreaList>
  50. </a-form-model-item>
  51. </a-col>
  52. </template>
  53. <a-col :md="24" :sm="24" style="margin-bottom: 10px;text-align:center;">
  54. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="salesSlipReportList-refresh">查询</a-button>
  55. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="salesSlipReportList-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_salesSlip_report')"
  64. id="salesSlipReportList-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. :defaultLoadData="false"
  79. :rowKey="(record) => record.no"
  80. rowKeyName="no"
  81. :columns="columns"
  82. :data="loadData"
  83. :scroll="{ x: 2410 }"
  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 subarea from '@/views/common/subarea.js'
  118. import reportModal from '@/views/common/reportModal.vue'
  119. import AreaList from '@/views/common/areaList.js'
  120. import { hdExportExcel } from '@/libs/exportExcel'
  121. import { salesKdxxdReportTitle, salesBillReportList, salesBillReportCount } from '@/api/salesBillReport'
  122. import { salesSlipExport } from '@/api/reportData'
  123. export default {
  124. name: 'SalesSlipReportList',
  125. mixins: [commonMixin],
  126. components: { STable, VSelect, rangeDate, subarea, dealerSubareaScopeList, reportModal, AreaList },
  127. data () {
  128. return {
  129. spinning: false,
  130. advanced: true, // 高级搜索 展开/关闭
  131. tableHeight: 0,
  132. showExport: false,
  133. queryParam: { // 查询条件
  134. time: [
  135. getDate.getCurrMonthDays().starttime,
  136. getDate.getCurrMonthDays().endtime
  137. ],
  138. beginDate: getDate.getCurrMonthDays().starttime,
  139. endDate: getDate.getCurrMonthDays().endtime,
  140. salesBillNo: '', // 销售单号
  141. dealerSn: undefined,
  142. provinceSn: undefined,
  143. citySn: undefined,
  144. districtSn: undefined,
  145. subareaArea:{
  146. subareaSn: undefined,
  147. subareaAreaSn: undefined
  148. },
  149. dealerLevel: undefined
  150. },
  151. columns: [],
  152. countLabel: [],
  153. countBrandLabel:[],
  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 salesBillReportList(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. }
  184. },
  185. methods: {
  186. // 导出
  187. handleExport () {
  188. const _this = this
  189. this.$refs.ruleForm.validate(valid => {
  190. if (valid) {
  191. const params = _this.queryParam
  192. _this.$store.state.app.curActionPermission = 'B_salesSlip_report'
  193. _this.showExport = true
  194. _this.exportLoading = true
  195. _this.spinning = true
  196. hdExportExcel(salesSlipExport, params, '开单销售单报表', function () {
  197. _this.exportLoading = false
  198. _this.spinning = false
  199. _this.$store.state.app.curActionPermission = ''
  200. })
  201. } else {
  202. return false
  203. }
  204. })
  205. },
  206. // 总计
  207. getCount (params) {
  208. salesBillReportCount(params).then(res => {
  209. if (res.status == 200 && res.data) {
  210. this.totalData = res.data
  211. } else {
  212. this.totalData = null
  213. }
  214. })
  215. },
  216. handleSearch () {
  217. const _this = this
  218. this.$refs.ruleForm.validate(valid => {
  219. if (valid) {
  220. _this.$refs.table.refresh(true)
  221. } else {
  222. _this.$message.error('请选择销售日期')
  223. return false
  224. }
  225. })
  226. },
  227. // 创建时间 change
  228. dateChange (date) {
  229. if (date[0] && date[1]) {
  230. this.queryParam.time = date
  231. } else {
  232. this.queryParam.time = []
  233. }
  234. this.queryParam.beginDate = date[0] || ''
  235. this.queryParam.endDate = date[1] || ''
  236. },
  237. custChange (val) {
  238. this.queryParam.dealerSn = val.key
  239. },
  240. subareaChange (val) {
  241. this.queryParam.subareaArea.subareaSn = val[0] ? val[0] : undefined
  242. this.queryParam.subareaArea.subareaAreaSn = val[1] ? val[1] : undefined
  243. },
  244. // 重置
  245. resetSearchForm () {
  246. this.queryParam.time = [
  247. getDate.getCurrMonthDays().starttime,
  248. getDate.getCurrMonthDays().endtime
  249. ]
  250. this.$refs.rangeDate.resetDate(this.queryParam.time)
  251. this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
  252. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  253. this.queryParam.salesBillNo = ''
  254. this.queryParam.dealerSn = undefined
  255. this.queryParam.provinceSn = undefined
  256. this.queryParam.citySn = undefined
  257. this.queryParam.districtSn = undefined
  258. this.queryParam.subareaArea.subareaSn = undefined
  259. this.queryParam.subareaArea.subareaAreaSn = undefined
  260. this.queryParam.dealerLevel = undefined
  261. this.totalData = null
  262. if (this.advanced) {
  263. this.$refs.subarea.clearData()
  264. this.$refs.areaList.clearData()
  265. }
  266. this.$refs.custList.resetForm()
  267. this.$refs.ruleForm.resetFields()
  268. this.$refs.table.clearTable()
  269. },
  270. areaChange (val) {
  271. this.queryParam.provinceSn = val[0] ? val[0] : ''
  272. this.queryParam.citySn = val[1] ? val[1] : ''
  273. this.queryParam.districtSn = val[2] ? val[2] : ''
  274. },
  275. // 获取表头
  276. async getTableTitle () {
  277. const _this = this
  278. const tableTitle = await salesKdxxdReportTitle().then(res => res.data)
  279. this.columns = tableTitle.list
  280. this.countLabel = tableTitle.count.filter(item => item.title.indexOf('品牌')<0)
  281. this.countBrandLabel = tableTitle.count.filter(item => item.title.indexOf('品牌')>=0)
  282. this.columns.map(item => {
  283. let mw = 40
  284. if (item.customRender == 'amount') {
  285. mw = 15
  286. item.customRender = function (text) { return (text || text == 0) ? _this.toThousands(text) : '--' }
  287. }
  288. const w = item.title.length * mw
  289. const tw = w <= 80 && item.customRender != 'amount' ? w * 2 : (w >= 360 ? 200 : w)
  290. item.width = tw + 'px'
  291. this.tableWidth = this.tableWidth + tw
  292. })
  293. this.resetSearchForm()
  294. }
  295. },
  296. mounted () {
  297. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  298. this.getTableTitle()
  299. }
  300. },
  301. activated () {
  302. // 如果是新页签打开,则重置当前页面
  303. if (this.$store.state.app.isNewTab) {
  304. this.getTableTitle()
  305. }
  306. },
  307. beforeRouteEnter (to, from, next) {
  308. next(vm => {})
  309. }
  310. }
  311. </script>