list.vue 12 KB

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