list.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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>0">
  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-col>
  73. </a-row>
  74. </template>
  75. </s-table>
  76. </a-spin>
  77. <!-- 导出提示框 -->
  78. <reportModal :visible="showExport" @close="showExport=false"></reportModal>
  79. </a-card>
  80. </template>
  81. <script>
  82. import { commonMixin } from '@/utils/mixin'
  83. import { STable, VSelect } from '@/components'
  84. import rangeDate from '@/views/common/rangeDate.vue'
  85. import AreaList from '@/views/common/areaList.js'
  86. import subarea from '@/views/common/subarea.js'
  87. import { hdExportExcel } from '@/libs/exportExcel'
  88. import reportModal from '@/views/common/reportModal.vue'
  89. import supplier from '@/views/common/supplier.js'
  90. import { querySupplierPage, querySupplierCount, querySupplierTitle, supplierExport } from '@/api/reportData.js'
  91. export default {
  92. name: 'RegionTypeSalesReportList',
  93. mixins: [commonMixin],
  94. components: { STable, VSelect, rangeDate, subarea, reportModal, AreaList, supplier },
  95. data () {
  96. return {
  97. spinning: false,
  98. showExport: false,
  99. queryParam: {
  100. time: [],
  101. beginDate: '',
  102. endDate: '',
  103. subareaArea:{
  104. subareaSn: undefined,
  105. subareaAreaSn: undefined
  106. },
  107. supplier: {
  108. supplierSn: undefined,
  109. supplierName: undefined,
  110. provinceSn: undefined,
  111. citySn: undefined,
  112. districtSn: undefined
  113. }
  114. },
  115. countLabel: [],
  116. columns: [],
  117. disabled: false, // 查询、重置按钮是否可操作
  118. exportLoading: false,
  119. totalData: null,
  120. rules: {
  121. 'time': [{ required: true, message: '请选择退货完成时间', trigger: 'change' }]
  122. },
  123. // 加载数据方法 必须为 Promise 对象
  124. loadData: parameter => {
  125. this.disabled = true
  126. this.spinning = true
  127. const params = Object.assign(parameter, this.queryParam) // 无分页
  128. delete params.time
  129. return querySupplierPage(params).then(res => {
  130. let data
  131. if (res.status == 200) {
  132. data = res.data
  133. this.getCount(params)
  134. const no = (data.pageNo - 1) * data.pageSize
  135. for (var i = 0; i < data.list.length; i++) {
  136. data.list[i].no = no + i + 1
  137. }
  138. this.disabled = false
  139. }
  140. this.spinning = false
  141. return data
  142. })
  143. }
  144. }
  145. },
  146. methods: {
  147. // 总计
  148. getCount (params) {
  149. querySupplierCount(params).then(res => {
  150. if (res.status == 200 && res.data) {
  151. this.totalData = res.data
  152. } else {
  153. this.totalData = null
  154. }
  155. })
  156. },
  157. // 选择供应商
  158. getSupplierName (val, item) {
  159. this.queryParam.supplier.supplierName = item.supplierName
  160. this.queryParam.supplier.supplierSn = val
  161. },
  162. // 创建时间 change
  163. dateChange (date) {
  164. if (date[0] && date[1]) {
  165. this.queryParam.time = date
  166. } else {
  167. this.queryParam.time = []
  168. }
  169. this.queryParam.beginDate = date[0] || ''
  170. this.queryParam.endDate = date[1] || ''
  171. },
  172. // 查询
  173. handleSearch () {
  174. const _this = this
  175. this.$refs.ruleForm.validate(valid => {
  176. if (valid) {
  177. _this.$refs.table.refresh(true)
  178. } else {
  179. _this.$message.error('请选择退货完成时间')
  180. return false
  181. }
  182. })
  183. },
  184. subareaChange(val){
  185. this.queryParam.subareaArea.subareaSn = val[0] ? val[0] : undefined
  186. this.queryParam.subareaArea.subareaAreaSn = val[1] ? val[1] : undefined
  187. },
  188. // 重置
  189. resetSearchForm () {
  190. this.$refs.ruleForm.resetFields()
  191. this.queryParam.time = []
  192. this.$refs.rangeDate.resetDate(this.queryParam.time)
  193. this.queryParam.beginDate = ''
  194. this.queryParam.endDate = ''
  195. this.queryParam.supplier.supplierName = undefined
  196. this.queryParam.supplier.supplierSn = undefined
  197. this.queryParam.supplier.provinceSn = undefined
  198. this.queryParam.supplier.citySn = undefined
  199. this.queryParam.supplier.districtSn = undefined
  200. this.queryParam.subareaArea.subareaSn = undefined
  201. this.queryParam.subareaArea.subareaAreaSn = undefined
  202. this.$refs.subarea.clearData()
  203. this.$refs.areaList.clearData()
  204. this.$refs.table.clearTable()
  205. },
  206. areaChange (val) {
  207. this.queryParam.provinceSn = val[0] ? val[0] : ''
  208. this.queryParam.citySn = val[1] ? val[1] : ''
  209. this.queryParam.districtSn = val[2] ? val[2] : ''
  210. },
  211. // 导出
  212. handleExport () {
  213. const _this = this
  214. this.$refs.ruleForm.validate(valid => {
  215. if (valid) {
  216. const params = _this.queryParam
  217. _this.$store.state.app.curActionPermission = 'B_billingReturn_Report'
  218. _this.showExport = true
  219. _this.exportLoading = true
  220. _this.spinning = true
  221. hdExportExcel(supplierExport, params, '开单采退', function () {
  222. _this.exportLoading = false
  223. _this.spinning = false
  224. _this.$store.state.app.curActionPermission = ''
  225. })
  226. } else {
  227. _this.$message.error('请选择退货完成时间')
  228. return false
  229. }
  230. })
  231. },
  232. // 获取表头
  233. async getTableTitle () {
  234. const _this = this
  235. const tableTitle = await querySupplierTitle().then(res => res.data)
  236. this.columns = tableTitle.list
  237. this.countLabel = tableTitle.count
  238. this.columns.map(item => {
  239. let mw = 40
  240. if (item.customRender == 'amount') {
  241. mw = 15
  242. item.customRender = function (text) { return (text || text == 0) ? _this.toThousands(text) : '--' }
  243. }
  244. const w = item.title.length * mw
  245. const tw = w <= 80 && item.customRender != 'amount' ? w * 2 : (w >= 360 ? 200 : w)
  246. item.width = tw + 'px'
  247. this.tableWidth = this.tableWidth + tw
  248. })
  249. this.resetSearchForm()
  250. },
  251. pageInit () {
  252. this.getTableTitle()
  253. }
  254. },
  255. mounted () {
  256. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  257. this.pageInit()
  258. }
  259. },
  260. activated () {
  261. // 如果是新页签打开,则重置当前页面
  262. if (this.$store.state.app.isNewTab) {
  263. this.pageInit()
  264. }
  265. },
  266. beforeRouteEnter (to, from, next) {
  267. next(vm => {})
  268. }
  269. }
  270. </script>