list.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <a-card size="small" :bordered="false" class="makeInventoryList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper">
  6. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  7. <a-row :gutter="15">
  8. <a-col :md="6" :sm="24">
  9. <a-form-item label="盘点单号">
  10. <a-input id="makeInventoryList-checkWarehouseNo" v-model.trim="queryParam.checkWarehouseNo" allowClear placeholder="请输入盘点单号"/>
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="makeInventoryList-refresh">查询</a-button>
  15. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="makeInventoryList-reset">重置</a-button>
  16. </a-col>
  17. </a-row>
  18. </a-form>
  19. </div>
  20. <!-- 列表 -->
  21. <s-table
  22. class="sTable fixPagination"
  23. ref="table"
  24. :style="{ height: tableHeight+84.5+'px' }"
  25. size="small"
  26. :rowKey="(record) => record.id"
  27. :columns="columns"
  28. :data="loadData"
  29. :scroll="{ y: tableHeight }"
  30. :defaultLoadData="false"
  31. bordered>
  32. <!-- 操作 -->
  33. <template slot="action" slot-scope="text, record">
  34. <a-button
  35. size="small"
  36. type="link"
  37. v-if="$hasPermissions('B_inventoryMakeInventoryCheck')"
  38. class="button-info"
  39. @click="handleCheck(record)"
  40. id="makeInventoryList-audit-btn">盘点</a-button>
  41. <span v-else>--</span>
  42. </template>
  43. </s-table>
  44. </a-spin>
  45. </a-card>
  46. </template>
  47. <script>
  48. import { STable, VSelect } from '@/components'
  49. import { checkWarehouseList } from '@/api/checkWarehouse'
  50. export default {
  51. components: { STable, VSelect },
  52. data () {
  53. return {
  54. spinning: false,
  55. tableHeight: 0,
  56. disabled: false, // 查询、重置按钮是否可操作
  57. queryParam: { // 查询条件
  58. deleteFlag: '0',
  59. checkWarehouseNo: ''
  60. },
  61. columns: [
  62. { title: '序号', dataIndex: 'no', width: '6%', align: 'center' },
  63. { title: '盘点单号', dataIndex: 'checkWarehouseNo', width: '18%', align: 'center' },
  64. { title: '盘点状态', dataIndex: 'checkStateDictValue', width: '9%', align: 'center', customRender: function (text) { return text || '--' } },
  65. { title: '产品款数', dataIndex: 'productTotalCategory', width: '11%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  66. { title: '库存数量', dataIndex: 'totalStockQty', width: '11%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  67. { title: '盘点数量', dataIndex: 'checkTotalQty', width: '11%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  68. { title: '盘点盈亏数量', dataIndex: 'totalProfitLossQty', width: '11%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  69. { title: '盘点单创建时间', dataIndex: 'createDate', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  70. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  71. ],
  72. // 加载数据方法 必须为 Promise 对象
  73. loadData: parameter => {
  74. this.disabled = true
  75. this.spinning = true
  76. return checkWarehouseList(Object.assign(parameter, this.queryParam, { state: 'WAIT_CHECK' })).then(res => {
  77. let data
  78. if (res.status == 200) {
  79. data = res.data
  80. const no = (data.pageNo - 1) * data.pageSize
  81. for (var i = 0; i < data.list.length; i++) {
  82. data.list[i].no = no + i + 1
  83. }
  84. this.disabled = false
  85. }
  86. this.spinning = false
  87. return data
  88. })
  89. }
  90. }
  91. },
  92. methods: {
  93. // 盘点
  94. handleCheck (row) {
  95. this.$router.push({ path: `/inventoryManagement/makeInventory/check/${row.checkWarehouseSn}` })
  96. },
  97. resetSearchForm () {
  98. this.queryParam.checkWarehouseNo = ''
  99. this.$refs.table.refresh(true)
  100. },
  101. pageInit () {
  102. const _this = this
  103. this.$nextTick(() => { // 页面渲染完成后的回调
  104. _this.setTableH()
  105. })
  106. },
  107. setTableH () {
  108. this.tableHeight = window.innerHeight - 240
  109. }
  110. },
  111. watch: {
  112. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  113. this.setTableH()
  114. }
  115. },
  116. mounted () {
  117. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  118. this.pageInit()
  119. this.$refs.table.refresh(true)
  120. }
  121. },
  122. activated () {
  123. // 如果是新页签打开,则重置当前页面
  124. if (this.$store.state.app.isNewTab) {
  125. this.pageInit()
  126. this.$refs.table.refresh(true)
  127. }
  128. // 仅刷新列表,不重置页面
  129. if (this.$store.state.app.updateList) {
  130. this.pageInit()
  131. this.$refs.table.refresh()
  132. }
  133. },
  134. beforeRouteEnter (to, from, next) {
  135. next(vm => {
  136. const _this = vm
  137. if (vm.$route.query.isRefresh) {
  138. setTimeout(() => {
  139. _this.$refs.table.refresh(true)
  140. }, 300)
  141. }
  142. })
  143. }
  144. }
  145. </script>
  146. <style lang="less">
  147. .makeInventoryList-wrap{
  148. .active{
  149. color: #ed1c24;
  150. cursor: pointer;
  151. }
  152. .common{
  153. color: rgba(0, 0, 0);
  154. }
  155. }
  156. </style>