list.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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 v-if="$hasPermissions('B_inventory_warehouse_storingLocation_add')" 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="small"
  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. <!-- record.sysFlag表示该仓库是否默认,为默认仓库时则不可删除不可编辑 -->
  45. <a-button
  46. size="small"
  47. v-if="$hasPermissions('B_inventory_warehouse_storingLocation_edit') && record.sysFlag==0"
  48. type="link"
  49. class="button-info"
  50. @click="handleEdit(record)"
  51. id="storingLocationList-edit-btn">编辑</a-button>
  52. <a-button
  53. size="small"
  54. v-if="$hasPermissions('B_inventory_warehouse_storingLocation_del') && record.sysFlag==0"
  55. type="link"
  56. class="button-error"
  57. @click="handleDel(record)"
  58. id="storingLocationList-del-btn">删除</a-button>
  59. <span v-if="!$hasPermissions('B_inventory_warehouse_storingLocation_edit') && !$hasPermissions('B_inventory_warehouse_storingLocation_del')">--</span>
  60. </template>
  61. </s-table>
  62. </a-card>
  63. </a-spin>
  64. <!-- 新增/编辑仓位 -->
  65. <storing-location-edit-modal :openModal="openModal" :nowData="nowData" :itemId="itemId" @ok="handleOk" @close="closeModal" />
  66. </div>
  67. </template>
  68. <script>
  69. import { warehouseLocList, warehouseLocDel } from '@/api/warehouse'
  70. import { STable } from '@/components'
  71. import storingLocationEditModal from './editModal.vue'
  72. export default {
  73. components: { STable, storingLocationEditModal },
  74. data () {
  75. return {
  76. spinning: false,
  77. tableHeight: 0,
  78. queryParam: { // 查询条件
  79. warehouseSn: this.$route.params.sn, // 仓库sn
  80. name: '' // 仓位名称
  81. },
  82. disabled: false, // 查询、重置按钮是否可操作
  83. columns: [
  84. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  85. { title: '仓位名称', dataIndex: 'name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  86. { title: '排序', dataIndex: 'sort', align: 'center', width: 150, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  87. { title: '操作', scopedSlots: { customRender: 'action' }, width: 160, align: 'center' }
  88. ],
  89. // 加载数据方法 必须为 Promise 对象
  90. loadData: parameter => {
  91. this.disabled = true
  92. if (this.tableHeight == 0) {
  93. this.tableHeight = window.innerHeight - 380
  94. }
  95. return warehouseLocList(Object.assign(parameter, this.queryParam)).then(res => {
  96. const data = res.data
  97. const no = (data.pageNo - 1) * data.pageSize
  98. for (var i = 0; i < data.list.length; i++) {
  99. data.list[i].no = no + i + 1
  100. }
  101. this.disabled = false
  102. return data
  103. })
  104. },
  105. openModal: false, // 新增编辑产品品牌 弹框
  106. itemId: '', // 当前品牌id
  107. nowData: null // 当前记录数据
  108. }
  109. },
  110. methods: {
  111. // 重置
  112. resetSearchForm () {
  113. this.queryParam.warehouseSn = this.$route.params.sn
  114. this.queryParam.name = ''
  115. this.$refs.table.refresh(true)
  116. },
  117. // 新增/编辑
  118. handleEdit (row) {
  119. if (row) {
  120. this.itemId = row.id
  121. row.warehouseSn = this.$route.params.sn
  122. this.nowData = row
  123. } else {
  124. this.itemId = null
  125. this.nowData = { warehouseSn: this.$route.params.sn }
  126. }
  127. this.openModal = true
  128. },
  129. // 新增/编辑 成功
  130. handleOk () {
  131. this.$refs.table.refresh(true)
  132. },
  133. // 关闭弹框
  134. closeModal () {
  135. this.itemId = ''
  136. this.openModal = false
  137. },
  138. // 删除
  139. handleDel (row) {
  140. const _this = this
  141. this.$confirm({
  142. title: '提示',
  143. content: '删除后不可恢复,确定要进行删除吗?',
  144. centered: true,
  145. onOk () {
  146. _this.spinning = true
  147. warehouseLocDel({
  148. id: row.id,
  149. warehouseSn: _this.$route.params.sn
  150. }).then(res => {
  151. if (res.status == 200) {
  152. _this.$message.success(res.message)
  153. _this.$refs.table.refresh()
  154. _this.spinning = false
  155. } else {
  156. _this.spinning = false
  157. }
  158. })
  159. }
  160. })
  161. },
  162. // 返回列表
  163. handleBack () {
  164. this.$router.push({ path: '/inventoryManagement/warehouse/list', query: { closeLastOldTab: true } })
  165. }
  166. }
  167. }
  168. </script>
  169. <style lang="less">
  170. .storingLocationList-wrap{
  171. .storingLocationList-back{
  172. margin-bottom: 10px;
  173. }
  174. }
  175. </style>