list.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <a-card size="small" :bordered="false" class="warehouseList-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="warehouseList-name" v-model.trim="queryParam.name" 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="warehouseList-refresh">查询</a-button>
  15. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="warehouseList-reset">重置</a-button>
  16. </a-col>
  17. </a-row>
  18. </a-form>
  19. </div>
  20. <!-- 操作按钮 -->
  21. <div class="table-operator">
  22. <a-button v-if="$hasPermissions('B_warehouse_add')" id="warehouseList-add" type="primary" class="button-error" @click="handleEdit()">新增</a-button>
  23. </div>
  24. <!-- 列表 -->
  25. <s-table
  26. class="sTable fixPagination"
  27. ref="table"
  28. :style="{ height: tableHeight+84.5+'px' }"
  29. size="small"
  30. :rowKey="(record) => record.id"
  31. :columns="columns"
  32. :data="loadData"
  33. :scroll="{ y: tableHeight }"
  34. bordered>
  35. <!-- 操作 -->
  36. <template slot="action" slot-scope="text, record">
  37. <a-button
  38. size="small"
  39. type="link"
  40. class="button-warning"
  41. @click="goStoringLocation(record)"
  42. v-if="$hasPermissions('B_warehouse_ckSet')"
  43. id="warehouseList-storingLocation-btn">仓位管理</a-button>
  44. <a-button
  45. size="small"
  46. type="link"
  47. class="button-info"
  48. v-if="record.defaultFlag!='1' &&$hasPermissions('B_warehouse_edit') "
  49. @click="handleEdit(record)"
  50. id="warehouseList-edit-btn">编辑</a-button>
  51. <a-button
  52. size="small"
  53. type="link"
  54. class="button-error"
  55. v-if="record.defaultFlag!='1' &&$hasPermissions('B_warehouse_del')"
  56. @click="handleDel(record)"
  57. id="warehouseList-del-btn">删除</a-button>
  58. <span v-if="record.defaultFlag=='0' && !$hasPermissions('B_warehouse_edit') && !$hasPermissions('B_warehouse_del')">--</span>
  59. </template>
  60. </s-table>
  61. </a-spin>
  62. <!-- 新增/编辑仓库 -->
  63. <warehouse-edit-modal :openModal="openModal" :nowData="nowData" :itemSn="itemSn" @ok="handleOk" @close="closeModal" />
  64. </a-card>
  65. </template>
  66. <script>
  67. import { warehouseList, warehouseDel } from '@/api/warehouse'
  68. import { STable } from '@/components'
  69. import warehouseEditModal from './editModal.vue'
  70. export default {
  71. components: { STable, warehouseEditModal },
  72. data () {
  73. return {
  74. spinning: false,
  75. queryParam: { // 查询条件
  76. name: '' // 仓库名称
  77. },
  78. tableHeight: 0,
  79. disabled: false, // 查询、重置按钮是否可操作
  80. columns: [
  81. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  82. { title: '仓库名称', dataIndex: 'name', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  83. { title: '操作', scopedSlots: { customRender: 'action' }, align: 'center' }
  84. ],
  85. // 加载数据方法 必须为 Promise 对象
  86. loadData: parameter => {
  87. this.disabled = true
  88. this.spinning = true
  89. return warehouseList(Object.assign(parameter, this.queryParam)).then(res => {
  90. const data = res.data
  91. const no = (data.pageNo - 1) * data.pageSize
  92. for (var i = 0; i < data.list.length; i++) {
  93. data.list[i].no = no + i + 1
  94. }
  95. this.disabled = false
  96. this.spinning = false
  97. return data
  98. })
  99. },
  100. openModal: false, // 新增编辑 弹框
  101. itemSn: '', // 当前sn
  102. nowData: null // 当前记录数据
  103. }
  104. },
  105. methods: {
  106. // 重置
  107. resetSearchForm () {
  108. this.queryParam.name = ''
  109. this.$refs.table.refresh(true)
  110. },
  111. // 新增/编辑
  112. handleEdit (row) {
  113. this.itemSn = row ? row.warehouseSn : null
  114. this.nowData = row || null
  115. this.openModal = true
  116. },
  117. // 新增/编辑 成功
  118. handleOk () {
  119. this.$refs.table.refresh(true)
  120. },
  121. // 关闭弹框
  122. closeModal () {
  123. this.itemSn = ''
  124. this.openModal = false
  125. },
  126. // 删除
  127. handleDel (row) {
  128. const _this = this
  129. this.$confirm({
  130. title: '提示',
  131. content: '删除后不可恢复,确定要进行删除吗?',
  132. centered: true,
  133. onOk () {
  134. _this.spinning = true
  135. warehouseDel({
  136. sn: row.warehouseSn
  137. }).then(res => {
  138. if (res.status == 200) {
  139. _this.$message.success(res.message)
  140. _this.$refs.table.refresh()
  141. _this.spinning = false
  142. } else {
  143. _this.spinning = false
  144. }
  145. })
  146. }
  147. })
  148. },
  149. // 查看仓位
  150. goStoringLocation (row) {
  151. this.$router.push({ path: `/basicData/storingLocation/${row.warehouseSn}`, query: { name: row.name } })
  152. },
  153. setTableH () {
  154. const tableSearchH = this.$refs.tableSearch.offsetHeight
  155. this.tableHeight = window.innerHeight - tableSearchH - 245
  156. }
  157. },
  158. mounted () {
  159. const _this = this
  160. this.$nextTick(() => { // 页面渲染完成后的回调
  161. _this.setTableH()
  162. })
  163. }
  164. }
  165. </script>