subareaList.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <template>
  2. <div>
  3. <a-card size="small" :bordered="false" class="tireSalesReportList-wrap searchBoxNormal">
  4. <!-- 搜索条件 -->
  5. <div class="table-page-search-wrapper" ref="tableSearch">
  6. <a-form-model
  7. id="tireSalesReportList-form"
  8. ref="ruleForm"
  9. class="form-model-con"
  10. layout="inline"
  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="time" @change="dateChange" />
  17. </a-form-model-item>
  18. </a-col>
  19. <a-col :md="6" :sm="24">
  20. <a-form-item label="区域/分区">
  21. <subarea id="allocateBillList-subarea" ref="subarea" @change="subareaChange"></subarea>
  22. </a-form-item>
  23. </a-col>
  24. <a-col :md="6" :sm="24">
  25. <a-form-model-item label="区域负责人">
  26. <BizUser v-model="queryParam.bizUserSn"></BizUser>
  27. </a-form-model-item>
  28. </a-col>
  29. <a-col :md="6" :sm="24">
  30. <a-button
  31. style="margin-left: 5px"
  32. type="primary"
  33. @click="handleSearch"
  34. :disabled="disabled"
  35. id="salesOrderTotalList-refresh">查询</a-button>
  36. <a-button
  37. style="margin-left: 8px"
  38. @click="resetSearchForm"
  39. :disabled="disabled"
  40. id="salesOrderTotalList-reset">重置</a-button>
  41. <a-button
  42. style="margin-left: 10px"
  43. type="primary"
  44. class="button-warning"
  45. @click="handleExport"
  46. :disabled="disabled"
  47. :loading="exportLoading"
  48. v-if="$hasPermissions('B_tireSalesAreaReportExport')"
  49. id="salesOrderTotalList-export">导出</a-button>
  50. </a-col>
  51. </a-row>
  52. </a-form-model>
  53. </div>
  54. </a-card>
  55. <a-card size="small" :bordered="false">
  56. <a-spin :spinning="spinning" tip="Loading...">
  57. <!-- 列表 -->
  58. <s-table
  59. class="sTable fixPagination"
  60. ref="table"
  61. size="small"
  62. :rowKey="(record) => record.salesBillNo"
  63. :style="{ height: tableHeight+70+'px' }"
  64. rowKeyName="salesBillNo"
  65. :columns="columns"
  66. :data="loadData"
  67. :scroll="{ y: tableHeight-30 }"
  68. :pageSize="30"
  69. :defaultLoadData="false"
  70. bordered>
  71. <template slot="footer">
  72. <a-row :gutter="15">
  73. <a-col :md="4" :sm="24">采购数量:{{ (totalData && (totalData.totalbuyAmount || totalData.totalbuyAmount==0)) ? totalData.totalbuyAmount : '--' }}</a-col>
  74. <a-col :md="4" :sm="24">库存数量:{{ (totalData && (totalData.totalstoreAmount || totalData.totalsellAmount==0)) ? totalData.totalsellAmount: '--' }}</a-col>
  75. <a-col :md="4" :sm="24">售出数量:{{ (totalData && (totalData.totalsellAmount || totalData.totalsellAmount==0)) ?totalData.totalsellAmount: '--' }}</a-col>
  76. <a-col :md="4" :sm="24">已绑质保单数量:{{ (totalData && (totalData.totalwarrantyAmount || totalData.totalwarrantyAmount==0)) ?totalData.totalwarrantyAmount: '--' }}</a-col>
  77. </a-row>
  78. </template>
  79. </s-table>
  80. </a-spin>
  81. </a-card>
  82. </div>
  83. </template>
  84. <script>
  85. import { commonMixin } from '@/utils/mixin'
  86. import getDate from '@/libs/getDate.js'
  87. import { STable } from '@/components'
  88. import rangeDate from '@/views/common/rangeDate.vue'
  89. import subarea from '@/views/common/subarea.js'
  90. import BizUser from '@/views/common/bizUser.js'
  91. import { hdExportExcel } from '@/libs/exportExcel'
  92. import { querySaleAreaCount, excelSaleAreaOnlineExport, querySaleAreaPage } from '@/api/reportData'
  93. export default {
  94. name: 'TireSalesSubareaList',
  95. mixins: [commonMixin],
  96. components: { STable, rangeDate, subarea, BizUser },
  97. data () {
  98. return {
  99. spinning: false,
  100. tableHeight: 0,
  101. time: [
  102. getDate.getThreeMonthDays().starttime,
  103. getDate.getCurrMonthDays().endtime
  104. ],
  105. queryParam: { // 查询条件
  106. beginDate: getDate.getThreeMonthDays().starttime,
  107. endDate: getDate.getCurrMonthDays().endtime,
  108. subareaSn: undefined,
  109. subareaAreaSn: undefined,
  110. bizUserSn: undefined
  111. },
  112. disabled: false, // 查询、重置按钮是否可操作
  113. exportLoading: false,
  114. // 加载数据方法 必须为 Promise 对象
  115. loadData: parameter => {
  116. this.disabled = true
  117. this.spinning = true
  118. const params = Object.assign(parameter, this.queryParam)
  119. return querySaleAreaPage(params).then(res => {
  120. let data
  121. if (res.status == 200) {
  122. data = res.data
  123. this.getCount(params)
  124. const no = (data.pageNo - 1) * data.pageSize
  125. for (var i = 0; i < data.list.length; i++) {
  126. data.list[i].no = no + i + 1
  127. }
  128. this.disabled = false
  129. }
  130. this.spinning = false
  131. return data
  132. })
  133. },
  134. totalData: null,
  135. columns: [
  136. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  137. { title: '区域', dataIndex: 'subareaName', width: '16%', align: 'center', customRender: function (text) { return text || '--' } },
  138. { title: '分区', dataIndex: 'subareaAreaName', width: '16%', align: 'center', customRender: function (text) { return text || '--' } },
  139. { title: '区域负责人', dataIndex: 'userNameQyfzrs', width: '16%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  140. { title: '采购数量', dataIndex: 'buyAmount', width: '12%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  141. { title: '库存数量', dataIndex: 'storeAmount', width: '12%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  142. { title: '售出数量', dataIndex: 'sellAmount', width: '12%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  143. { title: '已绑质保单数量', dataIndex: 'warrantyAmount', width: '12%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  144. ]
  145. }
  146. },
  147. methods: {
  148. // 统计
  149. getCount (params) {
  150. querySaleAreaCount(params).then(res => {
  151. if (res.status == 200 && res.data) {
  152. this.totalData = res.data
  153. } else {
  154. this.totalData = null
  155. }
  156. })
  157. },
  158. handleSearch () {
  159. this.$refs.table.refresh(true)
  160. },
  161. // 下推时间 change
  162. dateChange (date) {
  163. if (date[0] && date[1]) {
  164. this.time = date
  165. } else {
  166. this.time = []
  167. }
  168. this.queryParam.beginDate = date[0] || ''
  169. this.queryParam.endDate = date[1] || ''
  170. },
  171. subareaChange (val) {
  172. this.queryParam.subareaSn = val[0] ? val[0] : undefined
  173. this.queryParam.subareaAreaSn = val[1] ? val[1] : undefined
  174. },
  175. // 重置
  176. resetSearchForm () {
  177. this.time = [
  178. getDate.getThreeMonthDays().starttime,
  179. getDate.getCurrMonthDays().endtime
  180. ]
  181. this.$refs.rangeDate.resetDate(this.time)
  182. this.queryParam.beginDate = getDate.getThreeMonthDays().starttime
  183. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  184. this.queryParam.subareaSn = undefined
  185. this.queryParam.subareaAreaSn = undefined
  186. this.queryParam.bizUserSn = undefined
  187. this.totalData = null
  188. this.$refs.subarea.clearData()
  189. this.$refs.table.clearTable()
  190. },
  191. // 导出
  192. handleExport () {
  193. const _this = this
  194. const params = _this.queryParam
  195. _this.exportLoading = true
  196. _this.spinning = true
  197. hdExportExcel(excelSaleAreaOnlineExport, params, '轮胎销售报表(区域/分区)', function () {
  198. _this.exportLoading = false
  199. _this.spinning = false
  200. })
  201. },
  202. pageInit () {
  203. const _this = this
  204. this.$nextTick(() => { // 页面渲染完成后的回调
  205. _this.setTableH()
  206. })
  207. },
  208. setTableH () {
  209. const tableSearchH = this.$refs.tableSearch.offsetHeight
  210. this.tableHeight = window.innerHeight - tableSearchH - 245
  211. }
  212. },
  213. mounted () {
  214. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  215. this.pageInit()
  216. this.resetSearchForm()
  217. }
  218. },
  219. activated () {
  220. // 如果是新页签打开,则重置当前页面
  221. if (this.$store.state.app.isNewTab) {
  222. this.pageInit()
  223. this.resetSearchForm()
  224. }
  225. },
  226. beforeRouteEnter (to, from, next) {
  227. next(vm => {})
  228. }
  229. }
  230. </script>