list.vue 9.3 KB

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