list.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <template>
  2. <div>
  3. <a-card size="small" :bordered="false" class="searchBoxNormal">
  4. <div class="table-page-search-wrapper newTableSearchName" ref="tableSearch">
  5. <a-form-model
  6. id="billingBackReportList-form"
  7. ref="ruleForm"
  8. class="form-model-con"
  9. layout="inline"
  10. :rules="rules"
  11. :model="queryParam"
  12. @keyup.enter.native="handleSearch">
  13. <a-row :gutter="15">
  14. <a-col :md="6" :sm="24">
  15. <a-form-model-item label="退货完成时间" prop="time">
  16. <rangeDate ref="rangeDate" id="billingBackReportList-time" :value="queryParam.time" @change="dateChange"/>
  17. </a-form-model-item>
  18. </a-col>
  19. <a-col :md="6" :sm="24">
  20. <a-form-model-item label="供应商名称">
  21. <supplier id="billingBackReportList-supplierName" v-model="queryParam.supplier.supplierSn" @change="getSupplierName" placeholder="请输入供应商名称"></supplier>
  22. </a-form-model-item>
  23. </a-col>
  24. <a-col :md="6" :sm="24">
  25. <a-form-model-item label="地区">
  26. <AreaList id="billingBackReportList-areaList" changeOnSelect ref="areaList" @change="areaChange" defValKey="id"></AreaList>
  27. </a-form-model-item>
  28. </a-col>
  29. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  30. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="billingBackReportList-refresh">查询</a-button>
  31. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="billingBackReportList-reset">重置</a-button>
  32. <a-button
  33. style="margin-left: 5px"
  34. type="primary"
  35. class="button-warning"
  36. @click="handleExport"
  37. :disabled="disabled"
  38. :loading="exportLoading"
  39. v-if="$hasPermissions('B_regionTypeSalesReportExport')"
  40. id="billingBackReportList-export">导出</a-button>
  41. </a-col>
  42. </a-row>
  43. </a-form-model>
  44. </div>
  45. </a-card>
  46. <!-- 列表 -->
  47. <a-card size="small" :bordered="false">
  48. <a-spin :spinning="spinning" tip="Loading...">
  49. <s-table
  50. class="sTable fixPagination"
  51. ref="table"
  52. size="small"
  53. :defaultLoadData="false"
  54. :rowKey="(record,index) => record.no"
  55. rowKeyName="no"
  56. :columns="columns"
  57. :data="loadData"
  58. :style="{ height: tableHeight+84.5+'px' }"
  59. :scroll="{ x: 1550 ,y: tableHeight-136 }"
  60. bordered>
  61. <template slot="footer" v-if="countLabel.length||countBrandLabel.length">
  62. <a-row>
  63. <a-col span="2">合计:</a-col>
  64. <a-col span="22">
  65. <a-row>
  66. <a-col span="4" v-for="item in countLabel" :key="item.key">
  67. {{ item.title }}:{{ totalData?(totalData[item.dataIndex] ||totalData[item.dataIndex]==0)?toThousands(totalData[item.dataIndex]):'--':'--' }}
  68. </a-col>
  69. </a-row>
  70. <a-row>
  71. <a-col span="24" style="padding:8px;"></a-col>
  72. </a-row>
  73. <a-row>
  74. <a-col span="4" v-for="item in countBrandLabel" :key="item.key">
  75. {{ item.title }}:{{ totalData?(totalData[item.dataIndex] ||totalData[item.dataIndex]==0)?toThousands(totalData[item.dataIndex]):'--':'--' }}
  76. </a-col>
  77. </a-row>
  78. </a-col>
  79. </a-row>
  80. </template>
  81. </s-table>
  82. </a-spin>
  83. <!-- 导出提示框 -->
  84. <reportModal :visible="showExport" @close="showExport=false"></reportModal>
  85. </a-card>
  86. </div>
  87. </template>
  88. <script>
  89. import { commonMixin } from '@/utils/mixin'
  90. import getDate from '@/libs/getDate.js'
  91. import { hdExportExcel } from '@/libs/exportExcel'
  92. // 组件
  93. import { STable, VSelect } from '@/components'
  94. import rangeDate from '@/views/common/rangeDate.vue'
  95. import AreaList from '@/views/common/areaList.js'
  96. import reportModal from '@/views/common/reportModal.vue'
  97. import supplier from '@/views/common/supplier.js'
  98. // 接口
  99. import { querySupplierPage, querySupplierCount, querySupplierTitle, supplierExport } from '@/api/reportData.js'
  100. export default {
  101. name: 'BillingBackReportList',
  102. mixins: [commonMixin],
  103. components: { STable, VSelect, rangeDate, reportModal, AreaList, supplier },
  104. data () {
  105. return {
  106. spinning: false,
  107. showExport: false, // 导出弹窗提示
  108. disabled: false, // 查询、重置按钮是否可操作
  109. exportLoading: false, // 导出按钮加载状态
  110. queryParam: {
  111. // 退货完成日期 默认值
  112. time: [
  113. getDate.getCurrMonthDays().starttime,
  114. getDate.getCurrMonthDays().endtime
  115. ],
  116. beginDate: getDate.getCurrMonthDays().starttime, // 开始日期
  117. endDate: getDate.getCurrMonthDays().endtime, // 结束日期
  118. supplier: {
  119. supplierSn: undefined, // 供应商 sn
  120. supplierName: undefined, // 供应商名称
  121. provinceSn: undefined, // 省
  122. citySn: undefined, // 市
  123. districtSn: undefined// 区
  124. }
  125. },
  126. countLabel: [], // 统计 分类数据
  127. countBrandLabel: [], // 统计 品牌数据
  128. columns: [], // 表头数据
  129. totalData: null, // 统计
  130. rules: {
  131. 'time': [{ required: true, message: '请选择退货完成时间', trigger: 'change' }]
  132. },
  133. // 加载数据方法 必须为 Promise 对象
  134. loadData: parameter => {
  135. this.disabled = true
  136. this.spinning = true
  137. const params = Object.assign(parameter, this.queryParam)
  138. delete params.time
  139. // 获取列表数据 有分页
  140. return querySupplierPage(params).then(res => {
  141. let data
  142. if (res.status == 200) {
  143. data = res.data
  144. // 统计
  145. this.getCount(params)
  146. // 计算列表序号
  147. const no = (data.pageNo - 1) * data.pageSize
  148. for (var i = 0; i < data.list.length; i++) {
  149. data.list[i].no = no + i + 1
  150. }
  151. this.disabled = false
  152. }
  153. this.spinning = false
  154. return data
  155. })
  156. }
  157. }
  158. },
  159. methods: {
  160. // 总计
  161. getCount (params) {
  162. querySupplierCount(params).then(res => {
  163. if (res.status == 200 && res.data) {
  164. this.totalData = res.data
  165. } else {
  166. this.totalData = null
  167. }
  168. })
  169. },
  170. // 选择供应商
  171. getSupplierName (val, item) {
  172. this.queryParam.supplier.supplierName = item ? item.supplierName : undefined
  173. this.queryParam.supplier.supplierSn = val
  174. },
  175. // 退货完成日期 change
  176. dateChange (date) {
  177. if (date[0] && date[1]) {
  178. this.queryParam.time = date
  179. } else {
  180. this.queryParam.time = []
  181. }
  182. this.queryParam.beginDate = date[0] || ''
  183. this.queryParam.endDate = date[1] || ''
  184. },
  185. // 查询
  186. handleSearch () {
  187. const _this = this
  188. this.$refs.ruleForm.validate(valid => {
  189. if (valid) {
  190. _this.$refs.table.refresh(true)
  191. } else {
  192. _this.$message.error('请选择退货完成时间')
  193. return false
  194. }
  195. })
  196. },
  197. // 重置
  198. resetSearchForm () {
  199. this.$refs.ruleForm.resetFields()
  200. this.queryParam.time = [
  201. getDate.getCurrMonthDays().starttime,
  202. getDate.getCurrMonthDays().endtime
  203. ]
  204. this.$refs.rangeDate.resetDate(this.queryParam.time)
  205. this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
  206. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  207. this.queryParam.supplier.supplierName = undefined
  208. this.queryParam.supplier.supplierSn = undefined
  209. this.queryParam.supplier.provinceSn = undefined
  210. this.queryParam.supplier.citySn = undefined
  211. this.queryParam.supplier.districtSn = undefined
  212. this.$refs.areaList.clearData()
  213. this.$refs.table.clearTable()
  214. },
  215. // 地区 change
  216. areaChange (val) {
  217. this.queryParam.supplier.provinceSn = val[0] ? val[0] : ''
  218. this.queryParam.supplier.citySn = val[1] ? val[1] : ''
  219. this.queryParam.supplier.districtSn = val[2] ? val[2] : ''
  220. },
  221. // 导出
  222. handleExport () {
  223. const _this = this
  224. this.$refs.ruleForm.validate(valid => {
  225. if (valid) {
  226. const params = _this.queryParam
  227. _this.$store.state.app.curActionPermission = 'B_billingReturn_Report'
  228. _this.showExport = true
  229. _this.exportLoading = true
  230. _this.spinning = true
  231. hdExportExcel(supplierExport, params, '开单采退', function () {
  232. _this.exportLoading = false
  233. _this.spinning = false
  234. _this.$store.state.app.curActionPermission = ''
  235. })
  236. } else {
  237. _this.$message.error('请选择退货完成时间')
  238. return false
  239. }
  240. })
  241. },
  242. // 获取表头
  243. async getTableTitle () {
  244. const _this = this
  245. const tableTitle = await querySupplierTitle().then(res => res.data)
  246. this.columns = tableTitle.list
  247. this.countLabel = tableTitle.count.filter(item => item.title.indexOf('品牌') < 0)
  248. this.countBrandLabel = tableTitle.count.filter(item => item.title.indexOf('品牌') >= 0)
  249. this.columns.map(item => {
  250. let mw = 20
  251. if (item.customRender == 'amount') {
  252. mw = 15
  253. item.customRender = function (text) { return (text || text == 0) ? _this.toThousands(text) : '--' }
  254. } else {
  255. item.customRender = function (text) { return text || '--' }
  256. }
  257. const w = item.title.length * mw
  258. const tw = w <= 80 ? mw * 5 : w
  259. item.width = tw + 'px'
  260. this.tableWidth = this.tableWidth + tw
  261. })
  262. this.resetSearchForm()
  263. },
  264. // 初始化
  265. pageInit () {
  266. this.getTableTitle()
  267. this.setTableH()
  268. },
  269. // 计算表格高度
  270. setTableH () {
  271. const tableSearchH = this.$refs.tableSearch.offsetHeight
  272. this.tableHeight = window.innerHeight - tableSearchH - 215
  273. }
  274. },
  275. mounted () {
  276. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  277. this.pageInit()
  278. }
  279. },
  280. activated () {
  281. // 如果是新页签打开,则重置当前页面
  282. if (this.$store.state.app.isNewTab) {
  283. this.pageInit()
  284. }
  285. },
  286. beforeRouteEnter (to, from, next) {
  287. next(vm => {})
  288. }
  289. }
  290. </script>