list.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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="billingOrderReport-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="5" :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="5" :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="4" :sm="24">
  25. <a-form-model-item label="采购退货单号" >
  26. <a-input id="billingBackReport-sparePartsReturnNo" v-model.trim="queryParam.sparePartsReturnNo" allowClear placeholder="请输入采购退货单号"/>
  27. </a-form-model-item>
  28. </a-col>
  29. <a-col :md="5" :sm="24">
  30. <a-form-model-item label="所在区域/分区">
  31. <subarea id="billingOrderReport-subareaSn" v-model="queryParam.subareaSn"></subarea>
  32. </a-form-model-item>
  33. </a-col>
  34. <a-col :md="5" :sm="24">
  35. <a-form-model-item label="地区">
  36. <AreaList id="returnSlipReportList-areaList" changeOnSelect ref="areaList" @change="areaChange" defValKey="id"></AreaList>
  37. </a-form-model-item>
  38. </a-col>
  39. <a-col :md="24" :sm="24" style="margin-bottom: 10px;display:flex;algin-item:center;justify-content: center;">
  40. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="billingOrderReport-refresh">查询</a-button>
  41. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="billingOrderReport-reset">重置</a-button>
  42. <a-button
  43. style="margin-left: 5px"
  44. type="primary"
  45. class="button-warning"
  46. @click="handleExport"
  47. :disabled="disabled"
  48. :loading="exportLoading"
  49. v-if="$hasPermissions('B_regionTypeSalesReportExport')"
  50. id="billingOrderReport-export">导出</a-button>
  51. </a-col>
  52. </a-row>
  53. </a-form-model>
  54. </div>
  55. <!-- 列表 -->
  56. <s-table
  57. class="sTable"
  58. ref="table"
  59. size="small"
  60. :defaultLoadData="false"
  61. :rowKey="(record,index) => record.no"
  62. :rowKeyName="no"
  63. :columns="columns"
  64. :data="loadData"
  65. :showPagination="false"
  66. :scroll="{ x: 1550 }"
  67. bordered>
  68. <template slot="footer">
  69. <a-row>
  70. <a-col span="2">合计:</a-col>
  71. <a-col span="22">
  72. <a-row>
  73. <a-col span="4" v-for="item in countLabel" :key="item.key">
  74. {{ item.title }}:{{ totalData?(totalData[item.dataIndex]||totalData[item.dataIndex]==0)?toThousands(totalData[item.dataIndex]):'--':'--' }}
  75. </a-col>
  76. </a-row>
  77. </a-col>
  78. </a-row>
  79. </template>
  80. </s-table>
  81. </a-spin>
  82. <!-- 导出提示框 -->
  83. <reportModal :visible="showExport" @close="showExport=false"></reportModal>
  84. </a-card>
  85. </template>
  86. <script>
  87. import { commonMixin } from '@/utils/mixin'
  88. import { STable, VSelect } from '@/components'
  89. import rangeDate from '@/views/common/rangeDate.vue'
  90. import AreaList from '@/views/common/areaList.js'
  91. import subarea from '@/views/common/subarea.js'
  92. import { hdExportExcel } from '@/libs/exportExcel'
  93. import reportModal from '@/views/common/reportModal.vue'
  94. import supplier from '@/views/common/supplier.js'
  95. import { queryBillNoPage, queryBillNoCount, queryBillNoTitle, billNoExport } from '@/api/reportData.js'
  96. export default {
  97. name: 'BillingOrderReportList',
  98. mixins: [commonMixin],
  99. components: { STable, VSelect, rangeDate, subarea, reportModal, AreaList, supplier },
  100. data () {
  101. return {
  102. spinning: false,
  103. showExport: false, // 导出弹窗
  104. queryParam: {
  105. time: [],
  106. beginDate: '',
  107. endDate: '',
  108. subareaSn: undefined,
  109. sparePartsReturnNo: undefined,
  110. supplier: {
  111. supplierSn: undefined,
  112. supplierName: undefined,
  113. provinceSn: undefined,
  114. citySn: undefined,
  115. districtSn: undefined
  116. }
  117. },
  118. countLabel: [],
  119. columns: [],
  120. totalData: null,
  121. disabled: false, // 查询、重置按钮是否可操作
  122. exportLoading: false,
  123. rules: {
  124. 'time': [{ required: true, message: '请选择退货完成时间', trigger: 'change' }]
  125. },
  126. // 加载数据方法 必须为 Promise 对象
  127. loadData: parameter => {
  128. this.disabled = true
  129. this.spinning = true
  130. const params = Object.assign(parameter, this.queryParam)
  131. delete params.time
  132. return queryBillNoPage(params).then(res => {
  133. let data
  134. if (res.status == 200) {
  135. data = res.data
  136. this.getCount(params)
  137. const no = (data.pageNo - 1) * data.pageSize
  138. for (var i = 0; i < data.list.length; i++) {
  139. data.list[i].no = no + i + 1
  140. }
  141. this.disabled = false
  142. }
  143. this.spinning = false
  144. return data
  145. })
  146. }
  147. }
  148. },
  149. methods: {
  150. // 选择供应商
  151. getSupplierName (val, item) {
  152. this.queryParam.supplier.supplierName = item.supplierName
  153. this.queryParam.supplier.supplierSn = val
  154. },
  155. // 总计
  156. getCount (params) {
  157. queryBillNoCount(params).then(res => {
  158. if (res.status == 200 && res.data) {
  159. this.totalData = res.data
  160. } else {
  161. this.totalData = null
  162. }
  163. })
  164. },
  165. // 退货完成时间 change
  166. dateChange (date) {
  167. if (date[0] && date[1]) {
  168. this.queryParam.time = date
  169. } else {
  170. this.queryParam.time = []
  171. }
  172. this.queryParam.beginDate = date[0] || ''
  173. this.queryParam.endDate = date[1] || ''
  174. },
  175. // 查询
  176. handleSearch () {
  177. const _this = this
  178. this.$refs.ruleForm.validate(valid => {
  179. if (valid) {
  180. _this.$refs.table.refresh(true)
  181. } else {
  182. _this.$message.error('请选择退货完成时间')
  183. return false
  184. }
  185. })
  186. },
  187. // 重置
  188. resetSearchForm () {
  189. this.$refs.ruleForm.resetFields()
  190. this.queryParam.time = []
  191. this.$refs.rangeDate.resetDate(this.queryParam.time)
  192. this.queryParam.beginDate = ''
  193. this.queryParam.endDate = ''
  194. this.queryParam.supplier.provinceSn = undefined
  195. this.queryParam.supplier.citySn = undefined
  196. this.queryParam.supplier.districtSn = undefined
  197. this.queryParam.subareaSn = undefined
  198. this.queryParam.sparePartsReturnNo = undefined
  199. this.queryParam.supplier.supplierName = undefined
  200. this.queryParam.supplier.supplierSn = 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(billNoExport, 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 queryBillNoTitle().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>