list.vue 9.9 KB

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