list.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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="handleExport" >
  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="checkWarehouseSn">
  32. <a-select id="exportCheckList-checkWarehouseSn" v-model="queryParam.checkWarehouseSn" placeholder="请选择盘点单" allowClear>
  33. <a-select-option v-for="item in checkList" :value="item.checkWarehouseSn" :key="item.checkWarehouseSn">
  34. <span>{{ item.financeAuditTime }} - {{ item.checkWarehouseNo }}</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="exportCheckList-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, checkWarehouseExport } from '@/api/checkWarehouse'
  63. export default {
  64. name: 'ExportCheckList',
  65. mixins: [commonMixin],
  66. components: { STable, VSelect, warehouse },
  67. data () {
  68. return {
  69. spinning: false,
  70. labelCol: { span: 8 }, // label 标签布局
  71. wrapperCol: { span: 16 }, // 表单设置布局
  72. disabled: false, // 查询、重置按钮是否可操作
  73. exportLoading: false, // 导出按钮加载状态
  74. // 查询条件
  75. queryParam: {
  76. checkWarehouseSn: undefined, // 盘点单 sn
  77. warehouseSn: undefined// 仓库sn
  78. },
  79. // 表单验证规则
  80. rules: {
  81. checkWarehouseSn: [{ 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.checkWarehouseSn = undefined
  91. this.checkList = []
  92. if (v) {
  93. checkWarehouseExcelList({ warehouseSn: this.queryParam.warehouseSn }).then(res => {
  94. if (res.status == 200) {
  95. this.checkList = res.data || []
  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
  108. _this.exportLoading = true
  109. _this.spinning = true
  110. hdExportExcel(checkWarehouseExport, params, '导出盘点', function () {
  111. _this.exportLoading = false
  112. _this.spinning = false
  113. })
  114. } else {
  115. console.log('error submit!!')
  116. return false
  117. }
  118. })
  119. },
  120. // 加载仓库信息
  121. loadWareHouse () {
  122. const defWareHouse = this.$store.state.app.defWarehouse
  123. this.queryParam.checkWarehouseSn = undefined
  124. this.queryParam.warehouseSn = this.isShowWarehouse ? undefined : (defWareHouse ? defWareHouse.warehouseSn : undefined)
  125. if (!this.isShowWarehouse) {
  126. this.getList(true)
  127. }
  128. },
  129. // 初始化数据
  130. pageInit () {
  131. this.$refs.ruleForm.resetFields()
  132. }
  133. },
  134. mounted () {
  135. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  136. this.pageInit()
  137. }
  138. },
  139. activated () {
  140. // 如果是新页签打开,则重置当前页面
  141. if (this.$store.state.app.isNewTab) {
  142. this.pageInit()
  143. }
  144. // 仅刷新列表,不重置页面
  145. if (this.$store.state.app.updateList) {
  146. this.pageInit()
  147. }
  148. },
  149. beforeRouteEnter (to, from, next) {
  150. next(vm => {})
  151. }
  152. }
  153. </script>
  154. <style lang="less">
  155. .exportCheckList-wrap{
  156. height: 99%;
  157. .form-model-con{
  158. margin-top: 50px;
  159. }
  160. }
  161. </style>