list.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <div class="storingLocationList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" class="storingLocationList-back">
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle">
  7. <a id="storingLocationList-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  8. <strong style="color: rgba(0, 0, 0, 0.65);margin-left: 50px;">所属仓库:{{ $route.query.name }}</strong>
  9. </template>
  10. </a-page-header>
  11. <a-card size="small" :bordered="false" class="storingLocationList-cont">
  12. <!-- 搜索条件 -->
  13. <div class="table-page-search-wrapper">
  14. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  15. <a-row :gutter="15">
  16. <a-col :md="6" :sm="24">
  17. <a-form-item label="仓位名称">
  18. <a-input id="storingLocationList-name" v-model.trim="queryParam.name" allowClear placeholder="请输入仓位名称"/>
  19. </a-form-item>
  20. </a-col>
  21. <a-col :md="6" :sm="24">
  22. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="storingLocationList-refresh">查询</a-button>
  23. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="storingLocationList-reset">重置</a-button>
  24. </a-col>
  25. </a-row>
  26. </a-form>
  27. </div>
  28. <!-- 操作按钮 -->
  29. <div class="table-operator" style="border: 0;padding: 0 0 15px;">
  30. <a-button id="storingLocationList-add" type="primary" class="button-error" @click="handleEdit()">新增</a-button>
  31. </div>
  32. <!-- 列表 -->
  33. <s-table
  34. class="sTable"
  35. ref="table"
  36. size="default"
  37. :rowKey="(record) => record.id"
  38. :columns="columns"
  39. :data="loadData"
  40. :scroll="{ y: tableHeight }"
  41. bordered>
  42. <!-- 操作 -->
  43. <template slot="action" slot-scope="text, record">
  44. <a-button
  45. size="small"
  46. type="link"
  47. class="button-info"
  48. v-if="record.defaultFlag!='1'"
  49. @click="handleEdit(record)"
  50. id="storingLocationList-edit-btn">编辑</a-button>
  51. <a-button
  52. size="small"
  53. type="link"
  54. class="button-error"
  55. v-if="record.defaultFlag!='1'"
  56. @click="handleDel(record)"
  57. id="storingLocationList-del-btn">删除</a-button>
  58. <span v-if="record.defaultFlag=='1'">--</span>
  59. </template>
  60. </s-table>
  61. </a-card>
  62. </a-spin>
  63. <!-- 新增/编辑仓位 -->
  64. <storing-location-edit-modal :openModal="openModal" :nowData="nowData" :itemSn="itemSn" @ok="handleOk" @close="closeModal" />
  65. </div>
  66. </template>
  67. <script>
  68. import { warehouseLocList, warehouseLocDel } from '@/api/warehouse'
  69. import { STable } from '@/components'
  70. import storingLocationEditModal from './editModal.vue'
  71. export default {
  72. components: { STable, storingLocationEditModal },
  73. data () {
  74. return {
  75. spinning: false,
  76. tableHeight: 0,
  77. queryParam: { // 查询条件
  78. warehouseSn: this.$route.params.sn, // 仓库sn
  79. name: '' // 仓位名称
  80. },
  81. disabled: false, // 查询、重置按钮是否可操作
  82. columns: [
  83. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  84. { title: '仓位名称', dataIndex: 'name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  85. { title: '操作', scopedSlots: { customRender: 'action' }, width: 160, align: 'center' }
  86. ],
  87. // 加载数据方法 必须为 Promise 对象
  88. loadData: parameter => {
  89. this.disabled = true
  90. if (this.tableHeight == 0) {
  91. this.tableHeight = window.innerHeight - 380
  92. }
  93. return warehouseLocList(Object.assign(parameter, this.queryParam)).then(res => {
  94. const data = res.data
  95. const no = (data.pageNo - 1) * data.pageSize
  96. for (var i = 0; i < data.list.length; i++) {
  97. data.list[i].no = no + i + 1
  98. }
  99. this.disabled = false
  100. return data
  101. })
  102. },
  103. openModal: false, // 新增编辑产品品牌 弹框
  104. itemSn: '', // 当前sn
  105. nowData: null // 当前记录数据
  106. }
  107. },
  108. methods: {
  109. // 重置
  110. resetSearchForm () {
  111. this.queryParam.warehouseSn = this.$route.params.sn
  112. this.queryParam.name = ''
  113. this.$refs.table.refresh(true)
  114. },
  115. // 新增/编辑
  116. handleEdit (row) {
  117. if (row) {
  118. this.itemSn = row.warehouseLocationSn
  119. row.warehouseSn = this.$route.params.sn
  120. this.nowData = row
  121. } else {
  122. this.itemSn = null
  123. this.nowData = { warehouseSn: this.$route.params.sn }
  124. }
  125. this.openModal = true
  126. },
  127. // 新增/编辑 成功
  128. handleOk () {
  129. this.$refs.table.refresh(true)
  130. },
  131. // 关闭弹框
  132. closeModal () {
  133. this.itemSn = ''
  134. this.openModal = false
  135. },
  136. // 删除
  137. handleDel (row) {
  138. const _this = this
  139. this.$confirm({
  140. title: '提示',
  141. content: '删除后不可恢复,确定要进行删除吗?',
  142. centered: true,
  143. onOk () {
  144. _this.spinning = true
  145. warehouseLocDel({
  146. sn: row.warehouseLocationSn
  147. }).then(res => {
  148. if (res.status == 200) {
  149. _this.$message.success(res.message)
  150. _this.$refs.table.refresh()
  151. _this.spinning = false
  152. } else {
  153. _this.spinning = false
  154. }
  155. })
  156. }
  157. })
  158. },
  159. // 返回列表
  160. handleBack () {
  161. this.$router.push({ path: '/basicData/warehouse/list', query: { closeLastOldTab: true } })
  162. }
  163. }
  164. }
  165. </script>
  166. <style lang="less">
  167. .storingLocationList-wrap{
  168. .storingLocationList-back{
  169. margin-bottom: 10px;
  170. }
  171. }
  172. </style>