list.vue 6.6 KB

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