list.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <div class="storingLocationList-wrap">
  3. <a-page-header :ghost="false" @back="handleBack" class="storingLocationList-back">
  4. <!-- 自定义的二级文字标题 -->
  5. <template slot="subTitle">
  6. <a id="storingLocationList-back-btn" href="javascript:;" @click="handleBack">返回列表</a>
  7. </template>
  8. </a-page-header>
  9. <a-card :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 id="storingLocationList-add" type="primary" @click="handleEdit()">新增仓位</a-button>
  29. </div>
  30. <!-- 列表 -->
  31. <s-table
  32. class="sTable"
  33. ref="table"
  34. size="default"
  35. :rowKey="(record) => record.id"
  36. :columns="columns"
  37. :data="loadData"
  38. :showPagination="false"
  39. bordered>
  40. <!-- 操作 -->
  41. <template slot="action" slot-scope="text, record">
  42. <a-button type="primary" @click="handleEdit(record)" id="storingLocationList-edit-btn">编辑</a-button>
  43. <a-button type="danger" @click="handleDel(record)" id="storingLocationList-del-btn" style="margin-left: 15px;">删除</a-button>
  44. </template>
  45. </s-table>
  46. </a-card>
  47. <!-- 新增/编辑仓位 -->
  48. <storing-location-edit-modal :openModal="openModal" :nowData="nowData" :itemId="itemId" @ok="handleOk" @close="closeModal" />
  49. </div>
  50. </template>
  51. <script>
  52. import moment from 'moment'
  53. import { warehouseLocFindAll, warehouseFindAll, warehouseLocDel } from '@/api/warehouse'
  54. import { STable, VSelect } from '@/components'
  55. import storingLocationEditModal from './editModal.vue'
  56. export default {
  57. components: { STable, VSelect, storingLocationEditModal },
  58. data () {
  59. return {
  60. queryParam: { // 查询条件
  61. whId: this.$route.params.id, // 仓库id
  62. name: '', // 仓位名称
  63. },
  64. disabled: false, // 查询、重置按钮是否可操作
  65. columns: [
  66. { title: '仓位名称', dataIndex: 'name', align: 'center', ellipsis: true },
  67. { title: '排序', dataIndex: 'sort', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  68. { title: '操作', scopedSlots: { customRender: 'action' }, width: 240, align: 'center' }
  69. ],
  70. // 加载数据方法 必须为 Promise 对象
  71. loadData: parameter => {
  72. this.disabled = true
  73. return warehouseLocFindAll( this.queryParam ).then(res => {
  74. const data = res.data
  75. this.disabled = false
  76. return data
  77. })
  78. },
  79. openModal: false, // 新增编辑产品品牌 弹框
  80. itemId: '', // 当前品牌id
  81. nowData: null // 当前记录数据
  82. }
  83. },
  84. methods: {
  85. // 重置
  86. resetSearchForm () {
  87. this.queryParam.whId = this.$route.params.id
  88. this.queryParam.name = ''
  89. this.$refs.table.refresh(true)
  90. },
  91. // 新增/编辑
  92. handleEdit(row){
  93. if(row){
  94. this.itemId = row.id
  95. row.whId = this.$route.params.id
  96. this.nowData = row
  97. }else{
  98. this.itemId = null
  99. this.nowData = { whId: this.$route.params.id }
  100. }
  101. this.openModal = true
  102. },
  103. // 新增/编辑 成功
  104. handleOk(){
  105. this.$refs.table.refresh(true)
  106. },
  107. // 关闭弹框
  108. closeModal(){
  109. this.itemId = ''
  110. this.openModal = false
  111. },
  112. // 删除
  113. handleDel(row){
  114. const _this = this
  115. this.$confirm({
  116. title: '提示',
  117. content: '删除后不可恢复,确定要进行删除吗?',
  118. okText: '确定',
  119. cancelText: '取消',
  120. onOk () {
  121. warehouseLocDel({
  122. id: row.id,
  123. whId: _this.$route.params.id
  124. }).then(res => {
  125. if (res.status == 200) {
  126. _this.$message.success(res.message)
  127. _this.$refs.table.refresh()
  128. }
  129. })
  130. }
  131. })
  132. },
  133. // 返回列表
  134. handleBack(){
  135. this.$router.push({ path: '/inventoryManagement/warehouse/list' })
  136. },
  137. }
  138. }
  139. </script>
  140. <style lang="less">
  141. .storingLocationList-wrap{
  142. .storingLocationList-back{
  143. margin-bottom: 15px;
  144. }
  145. }
  146. </style>