list.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <a-card size="small" :bordered="false" class="exportSalesList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch">
  6. <a-form-model
  7. id="exportSalesList-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="exportSalesList-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="exportSalesList-dateArr" 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="exportSalesList-export">导出</a-button>
  48. <a-button @click="pageInit" style="margin-left: 15px" id="exportSalesList-reset">重置</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 { hdExportExcel } from '@/libs/exportExcel'
  58. // 组件
  59. import { STable, VSelect } from '@/components'
  60. import warehouse from '@/views/common/chooseWarehouse.js'
  61. // 接口
  62. import { checkWarehouseExcelList } from '@/api/checkWarehouse'
  63. import { exportSalesOutProduct } from '@/api/stockOut.js'
  64. export default {
  65. name: 'ExportSalesList',
  66. mixins: [commonMixin],
  67. components: { STable, VSelect, warehouse },
  68. data () {
  69. return {
  70. spinning: false,
  71. labelCol: { span: 8 }, // form表单label横向距离
  72. wrapperCol: { span: 16 }, // form表单行缩进距离
  73. disabled: false, // 查询、重置按钮是否可操作
  74. exportLoading: false, // 导出按钮加载状态
  75. // 查询条件
  76. queryParam: {
  77. dateArr: undefined, // 时间范围
  78. warehouseSn: undefined// 仓库
  79. },
  80. rules: {
  81. dateArr: [{ required: true, message: '请选择时间范围', trigger: 'change' }],
  82. warehouseSn: [{ required: true, message: '请选择仓库', trigger: 'change' }]
  83. },
  84. checkList: []// 时间范围数据
  85. }
  86. },
  87. methods: {
  88. // 获取时间范围数据
  89. getList (v) {
  90. this.queryParam.dateArr = undefined
  91. this.checkList = []
  92. if (v) {
  93. checkWarehouseExcelList({ warehouseSn: this.queryParam.warehouseSn }).then(res => {
  94. if (res.status == 200) {
  95. const arr = res.data.reverse()
  96. for (let i = arr.length - 1; i > 0; i--) {
  97. this.checkList.push([arr[i - 1].financeAuditTime, arr[i].financeAuditTime].join(' 至 '))
  98. }
  99. } else {
  100. this.checkList = []
  101. }
  102. })
  103. }
  104. },
  105. // 导出
  106. handleExport () {
  107. const _this = this
  108. this.$refs.ruleForm.validate(valid => {
  109. if (valid) {
  110. const params = _this.queryParam.dateArr.split(' 至 ')
  111. _this.exportLoading = true
  112. _this.spinning = true
  113. hdExportExcel(exportSalesOutProduct, { 'beginDate': params[0], 'endDate': params[1] }, '导出销售', function () {
  114. _this.exportLoading = false
  115. _this.spinning = false
  116. })
  117. } else {
  118. console.log('error submit!!')
  119. return false
  120. }
  121. })
  122. },
  123. // 选择仓库 change
  124. loadWareHouse () {
  125. const defWareHouse = this.$store.state.app.defWarehouse
  126. this.queryParam.dateArr = undefined
  127. this.queryParam.warehouseSn = this.isShowWarehouse ? undefined : (defWareHouse ? defWareHouse.warehouseSn : undefined)
  128. if (!this.isShowWarehouse) {
  129. this.getList(true)
  130. }
  131. },
  132. // 初始化数据
  133. pageInit () {
  134. this.$refs.ruleForm.resetFields()
  135. }
  136. },
  137. mounted () {
  138. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  139. this.pageInit()
  140. }
  141. },
  142. activated () {
  143. // 如果是新页签打开,则重置当前页面
  144. if (this.$store.state.app.isNewTab) {
  145. this.pageInit()
  146. }
  147. // 仅刷新列表,不重置页面
  148. if (this.$store.state.app.updateList) {
  149. this.pageInit()
  150. }
  151. },
  152. beforeRouteEnter (to, from, next) {
  153. next(vm => {})
  154. }
  155. }
  156. </script>
  157. <style lang="less">
  158. .exportSalesList-wrap{
  159. height: 99%;
  160. .form-model-con{
  161. margin-top: 50px;
  162. }
  163. }
  164. </style>