list.vue 9.5 KB

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