list.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <a-card size="small" :bordered="false" class="exportCheckList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch">
  6. <a-form-model
  7. id="exportCheckList-form"
  8. ref="ruleForm"
  9. class="form-model-con"
  10. :model="queryParam"
  11. :rules="rules"
  12. :labelCol="labelCol"
  13. :wrapperCol="wrapperCol"
  14. @keyup.enter.native="handleSearch" >
  15. <a-row :gutter="15" v-show="isShowWarehouse">
  16. <a-col :md="12" :sm="24">
  17. <a-form-model-item label="选择仓库" prop="warehouseSn">
  18. <warehouse
  19. v-model="queryParam.warehouseSn"
  20. isPermission
  21. @load="loadWareHouse"
  22. id="exportCheckList-warehouseSn"
  23. placeholder="请选择仓库"
  24. @change="getList"
  25. />
  26. </a-form-model-item>
  27. </a-col>
  28. </a-row>
  29. <a-row :gutter="15">
  30. <a-col :md="12" :sm="24">
  31. <a-form-model-item label="选择时间范围" prop="dateArr">
  32. <a-select id="exportCheckList-print" v-model="queryParam.dateArr" placeholder="请选择时间范围" allowClear>
  33. <a-select-option v-for="item in checkList" :value="item" :key="item">
  34. <span>{{ item }}</span>
  35. </a-select-option>
  36. </a-select>
  37. </a-form-model-item>
  38. </a-col>
  39. </a-row>
  40. <a-form-model-item :wrapper-col="{ span: 12, offset: 6 }">
  41. <a-button
  42. type="primary"
  43. class="button-warning"
  44. @click="handleExport"
  45. :disabled="disabled"
  46. :loading="exportLoading"
  47. id="exportCheckList-export">导出</a-button>
  48. <a-button @click="pageInit" style="margin-left: 15px" id="chooseCustom-btn-back">重置</a-button>
  49. </a-form-model-item>
  50. </a-form-model>
  51. </div>
  52. </a-spin>
  53. </a-card>
  54. </template>
  55. <script>
  56. import { commonMixin } from '@/utils/mixin'
  57. import { STable, VSelect } from '@/components'
  58. import { checkWarehouseExcelList } from '@/api/checkWarehouse'
  59. import { exportSalesOutProduct } from '@/api/stockOut.js'
  60. import warehouse from '@/views/common/chooseWarehouse.js'
  61. import { hdExportExcel } from '@/libs/exportExcel'
  62. export default {
  63. name: 'ExportSalesList',
  64. mixins: [commonMixin],
  65. components: { STable, VSelect, warehouse },
  66. data () {
  67. return {
  68. spinning: false,
  69. tableHeight: 0,
  70. labelCol: { span: 8 },
  71. wrapperCol: { span: 16 },
  72. queryParam: { // 查询条件
  73. dateArr: undefined,
  74. warehouseSn: undefined
  75. },
  76. rules: {
  77. 'dateArr': [{ required: true, message: '请选择时间范围', trigger: 'change' }],
  78. warehouseSn: [{ required: true, message: '请选择仓库', trigger: 'change' }]
  79. },
  80. disabled: false, // 查询、重置按钮是否可操作
  81. exportLoading: false,
  82. checkList: []
  83. }
  84. },
  85. methods: {
  86. getList (v) {
  87. this.queryParam.dateArr = undefined
  88. this.checkList = []
  89. if(v){
  90. checkWarehouseExcelList({warehouseSn: this.queryParam.warehouseSn}).then(res => {
  91. if (res.status == 200) {
  92. const arr = res.data.reverse()
  93. for (let i = arr.length - 1; i > 0; i--) {
  94. this.checkList.push([arr[i - 1].financeAuditTime, arr[i].financeAuditTime].join(' 至 '))
  95. }
  96. } else {
  97. this.checkList = []
  98. }
  99. })
  100. }
  101. },
  102. // 导出
  103. handleExport () {
  104. const _this = this
  105. this.$refs.ruleForm.validate(valid => {
  106. if (valid) {
  107. const params = _this.queryParam.dateArr.split(' 至 ')
  108. _this.exportLoading = true
  109. _this.spinning = true
  110. hdExportExcel(exportSalesOutProduct, { 'beginDate': params[0], 'endDate': params[1] }, '导出销售', function () {
  111. _this.exportLoading = false
  112. _this.spinning = false
  113. })
  114. } else {
  115. console.log('error submit!!')
  116. return false
  117. }
  118. })
  119. },
  120. loadWareHouse(){
  121. const defWareHouse = this.$store.state.app.defWarehouse
  122. this.queryParam.dateArr = undefined
  123. this.queryParam.warehouseSn = this.isShowWarehouse ? undefined : (defWareHouse?defWareHouse.warehouseSn:undefined)
  124. if(!this.isShowWarehouse){
  125. this.getList(true)
  126. }
  127. },
  128. pageInit () {
  129. this.$refs.ruleForm.resetFields()
  130. }
  131. },
  132. mounted () {
  133. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  134. this.pageInit()
  135. }
  136. },
  137. activated () {
  138. // 如果是新页签打开,则重置当前页面
  139. if (this.$store.state.app.isNewTab) {
  140. this.pageInit()
  141. }
  142. // 仅刷新列表,不重置页面
  143. if (this.$store.state.app.updateList) {
  144. this.pageInit()
  145. }
  146. },
  147. beforeRouteEnter (to, from, next) {
  148. next(vm => {})
  149. }
  150. }
  151. </script>
  152. <style lang="less">
  153. .exportCheckList-wrap{
  154. height: 99%;
  155. .form-model-con{
  156. margin-top: 50px;
  157. }
  158. }
  159. </style>