list.vue 4.7 KB

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