list.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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 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. <a-button
  36. size="small"
  37. type="link"
  38. class="button-warning"
  39. @click="goStoringLocation(record)"
  40. id="warehouseList-storingLocation-btn">仓位管理</a-button>
  41. <a-button
  42. size="small"
  43. type="link"
  44. class="button-info"
  45. @click="handleEdit(record)"
  46. id="warehouseList-edit-btn">编辑</a-button>
  47. <a-button
  48. size="small"
  49. type="link"
  50. class="button-error"
  51. @click="handleDel(record)"
  52. id="warehouseList-del-btn">删除</a-button>
  53. </template>
  54. </s-table>
  55. <!-- 新增/编辑仓库 -->
  56. <warehouse-edit-modal :openModal="openModal" :nowData="nowData" :itemSn="itemSn" @ok="handleOk" @close="closeModal" />
  57. </a-card>
  58. </template>
  59. <script>
  60. import { warehouseList, warehouseDel } from '@/api/warehouse'
  61. import { STable } from '@/components'
  62. import warehouseEditModal from './editModal.vue'
  63. export default {
  64. components: { STable, warehouseEditModal },
  65. data () {
  66. return {
  67. queryParam: { // 查询条件
  68. name: '' // 仓库名称
  69. },
  70. tableHeight: 0,
  71. disabled: false, // 查询、重置按钮是否可操作
  72. columns: [
  73. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  74. { title: '仓库名称', dataIndex: 'name', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  75. { title: '操作', scopedSlots: { customRender: 'action' }, align: 'center' }
  76. ],
  77. // 加载数据方法 必须为 Promise 对象
  78. loadData: parameter => {
  79. this.disabled = true
  80. if (this.tableHeight == 0) {
  81. this.tableHeight = window.innerHeight - 380
  82. }
  83. return warehouseList(Object.assign(parameter, this.queryParam)).then(res => {
  84. const data = res.data
  85. const no = (data.pageNo - 1) * data.pageSize
  86. for (var i = 0; i < data.list.length; i++) {
  87. data.list[i].no = no + i + 1
  88. }
  89. this.disabled = false
  90. return data
  91. })
  92. },
  93. openModal: false, // 新增编辑 弹框
  94. itemSn: '', // 当前sn
  95. nowData: null // 当前记录数据
  96. }
  97. },
  98. methods: {
  99. // 重置
  100. resetSearchForm () {
  101. this.queryParam.name = ''
  102. this.$refs.table.refresh(true)
  103. },
  104. // 新增/编辑
  105. handleEdit (row) {
  106. this.itemSn = row ? row.warehouseSn : null
  107. this.nowData = row || null
  108. this.openModal = true
  109. },
  110. // 新增/编辑 成功
  111. handleOk () {
  112. this.$refs.table.refresh(true)
  113. },
  114. // 关闭弹框
  115. closeModal () {
  116. this.itemSn = ''
  117. this.openModal = false
  118. },
  119. // 删除
  120. handleDel (row) {
  121. const _this = this
  122. this.$confirm({
  123. title: '提示',
  124. content: '删除后不可恢复,确定要进行删除吗?',
  125. centered: true,
  126. onOk () {
  127. warehouseDel({
  128. sn: row.warehouseSn
  129. }).then(res => {
  130. if (res.status == 200) {
  131. _this.$message.success(res.message)
  132. _this.$refs.table.refresh()
  133. }
  134. })
  135. }
  136. })
  137. },
  138. // 查看仓位
  139. goStoringLocation (row) {
  140. this.$router.push({ path: `/basicData/storingLocation/${row.warehouseSn}`, query: { name: row.name } })
  141. }
  142. }
  143. }
  144. </script>