list.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <a-card size="small" :bordered="false" class="warehouseList-wrap">
  3. <!-- 搜索条件 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  6. <a-row :gutter="15">
  7. <a-col :md="6" :sm="24">
  8. <a-form-item label="仓库名称">
  9. <a-input id="warehouseList-name" v-model.trim="queryParam.name" allowClear placeholder="请输入仓库名称"/>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6" :sm="24">
  13. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="warehouseList-refresh">查询</a-button>
  14. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="warehouseList-reset">重置</a-button>
  15. </a-col>
  16. </a-row>
  17. </a-form>
  18. </div>
  19. <!-- 操作按钮 -->
  20. <div class="table-operator">
  21. <a-button v-if="$hasPermissions('B_inventory_warehouse_add')" id="warehouseList-add" type="primary" class="button-error" @click="handleEdit()">新增</a-button>
  22. </div>
  23. <!-- 列表 -->
  24. <s-table
  25. class="sTable"
  26. ref="table"
  27. size="default"
  28. :rowKey="(record) => record.id"
  29. :columns="columns"
  30. :data="loadData"
  31. :scroll="{ y: tableHeight }"
  32. bordered>
  33. <!-- 操作 -->
  34. <template slot="action" slot-scope="text, record">
  35. <!-- record.sysFlag表示该仓库是否默认,为默认仓库时则不可删除不可编辑 -->
  36. <a-button
  37. size="small"
  38. v-if="$hasPermissions('M_inventory_warehouse_storingLocation')"
  39. type="link"
  40. class="button-warning"
  41. @click="goStoringLocation(record)"
  42. id="warehouseList-storingLocation-btn">仓位管理</a-button>
  43. <a-button
  44. size="small"
  45. v-if="$hasPermissions('B_inventory_warehouse_edit') && record.sysFlag==0"
  46. type="link"
  47. class="button-info"
  48. @click="handleEdit(record)"
  49. id="warehouseList-edit-btn">编辑</a-button>
  50. <a-button
  51. size="small"
  52. v-if="$hasPermissions('B_inventory_warehouse_del') && record.sysFlag==0"
  53. type="link"
  54. class="button-error"
  55. @click="handleDel(record)"
  56. id="warehouseList-del-btn">删除</a-button>
  57. </template>
  58. </s-table>
  59. <!-- 新增/编辑仓库 -->
  60. <warehouse-edit-modal :openModal="openModal" :nowData="nowData" :itemId="itemId" @ok="handleOk" @close="closeModal" />
  61. </a-card>
  62. </template>
  63. <script>
  64. import { warehouseList, warehouseDel } from '@/api/warehouse'
  65. import { STable } from '@/components'
  66. import warehouseEditModal from './editModal.vue'
  67. export default {
  68. components: { STable, warehouseEditModal },
  69. data () {
  70. return {
  71. queryParam: { // 查询条件
  72. name: '' // 仓库名称
  73. },
  74. tableHeight: 0,
  75. disabled: false, // 查询、重置按钮是否可操作
  76. columns: [
  77. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  78. { title: '仓库名称', dataIndex: 'name', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  79. { title: '排序', dataIndex: 'sort', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  80. { title: '操作', scopedSlots: { customRender: 'action' }, align: 'center' }
  81. ],
  82. // 加载数据方法 必须为 Promise 对象
  83. loadData: parameter => {
  84. this.disabled = true
  85. if (this.tableHeight == 0) {
  86. this.tableHeight = window.innerHeight - 380
  87. }
  88. return warehouseList(Object.assign(parameter, this.queryParam)).then(res => {
  89. const data = res.data
  90. const no = (data.pageNo - 1) * data.pageSize
  91. for (var i = 0; i < data.list.length; i++) {
  92. data.list[i].no = no + i + 1
  93. }
  94. this.disabled = false
  95. return data
  96. })
  97. },
  98. openModal: false, // 新增编辑 弹框
  99. itemId: '', // 当前id
  100. nowData: null // 当前记录数据
  101. }
  102. },
  103. methods: {
  104. // 重置
  105. resetSearchForm () {
  106. this.queryParam.name = ''
  107. this.$refs.table.refresh(true)
  108. },
  109. // 新增/编辑
  110. handleEdit (row) {
  111. this.itemId = row ? row.id : null
  112. this.nowData = row || null
  113. this.openModal = true
  114. },
  115. // 新增/编辑 成功
  116. handleOk () {
  117. this.$refs.table.refresh(true)
  118. },
  119. // 关闭弹框
  120. closeModal () {
  121. this.itemId = ''
  122. this.openModal = false
  123. },
  124. // 删除
  125. handleDel (row) {
  126. const _this = this
  127. this.$confirm({
  128. title: '提示',
  129. content: '删除后不可恢复,确定要进行删除吗?',
  130. centered: true,
  131. onOk () {
  132. warehouseDel({
  133. id: row.id
  134. }).then(res => {
  135. if (res.status == 200) {
  136. _this.$message.success(res.message)
  137. _this.$refs.table.refresh()
  138. }
  139. })
  140. }
  141. })
  142. },
  143. // 查看仓位
  144. goStoringLocation (row) {
  145. this.$router.push({ path: `/inventoryManagement/storingLocation/${row.warehouseSn}`, query: { name: row.name } })
  146. }
  147. }
  148. }
  149. </script>
  150. <style lang="less"></style>