list.vue 8.9 KB

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