list.vue 5.8 KB

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