list.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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 ref="tableSearch" 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 10px;">
  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 fixPagination"
  35. ref="table"
  36. :style="{ height: tableHeight+84.5+'px' }"
  37. size="small"
  38. :rowKey="(record) => record.id"
  39. :columns="columns"
  40. :data="loadData"
  41. :scroll="{ y: tableHeight }"
  42. :defaultLoadData="false"
  43. bordered>
  44. <!-- 操作 -->
  45. <template slot="action" slot-scope="text, record">
  46. <!-- record.sysFlag表示该仓库是否默认,为默认仓库时则不可删除不可编辑 -->
  47. <a-button
  48. size="small"
  49. v-if="$hasPermissions('B_inventory_warehouse_storingLocation_edit') && record.sysFlag==0"
  50. type="link"
  51. class="button-info"
  52. @click="handleEdit(record)"
  53. id="storingLocationList-edit-btn">编辑</a-button>
  54. <a-button
  55. size="small"
  56. v-if="$hasPermissions('B_inventory_warehouse_storingLocation_del') && record.sysFlag==0"
  57. type="link"
  58. class="button-error"
  59. @click="handleDel(record)"
  60. id="storingLocationList-del-btn">删除</a-button>
  61. <span v-if="!$hasPermissions('B_inventory_warehouse_storingLocation_edit') && !$hasPermissions('B_inventory_warehouse_storingLocation_del')">--</span>
  62. </template>
  63. </s-table>
  64. </a-card>
  65. </a-spin>
  66. <!-- 新增/编辑仓位 -->
  67. <storing-location-edit-modal :openModal="openModal" :nowData="nowData" :itemId="itemId" @ok="handleOk" @close="closeModal" />
  68. </div>
  69. </template>
  70. <script>
  71. import { warehouseLocList, warehouseLocDel } from '@/api/warehouse'
  72. import { STable } from '@/components'
  73. import storingLocationEditModal from './editModal.vue'
  74. export default {
  75. components: { STable, storingLocationEditModal },
  76. data () {
  77. return {
  78. spinning: false,
  79. tableHeight: 0,
  80. queryParam: { // 查询条件
  81. warehouseSn: this.$route.params.sn, // 仓库sn
  82. name: '' // 仓位名称
  83. },
  84. disabled: false, // 查询、重置按钮是否可操作
  85. columns: [
  86. { title: '序号', dataIndex: 'no', width: '14%', align: 'center' },
  87. { title: '仓位名称', dataIndex: 'name', width: '40%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  88. { title: '排序', dataIndex: 'sort', width: '16%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  89. { title: '操作', scopedSlots: { customRender: 'action' }, width: '30%', align: 'center' }
  90. ],
  91. // 加载数据方法 必须为 Promise 对象
  92. loadData: parameter => {
  93. this.disabled = true
  94. this.spinning = true
  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. this.spinning = false
  103. return data
  104. })
  105. },
  106. openModal: false, // 新增编辑产品品牌 弹框
  107. itemId: '', // 当前品牌id
  108. nowData: null // 当前记录数据
  109. }
  110. },
  111. methods: {
  112. // 重置
  113. resetSearchForm () {
  114. this.queryParam.warehouseSn = this.$route.params.sn
  115. this.queryParam.name = ''
  116. this.$refs.table.refresh(true)
  117. },
  118. // 新增/编辑
  119. handleEdit (row) {
  120. if (row) {
  121. this.itemId = row.id
  122. row.warehouseSn = this.$route.params.sn
  123. this.nowData = row
  124. } else {
  125. this.itemId = null
  126. this.nowData = { warehouseSn: this.$route.params.sn }
  127. }
  128. this.openModal = true
  129. },
  130. // 新增/编辑 成功
  131. handleOk () {
  132. this.$refs.table.refresh(true)
  133. },
  134. // 关闭弹框
  135. closeModal () {
  136. this.itemId = ''
  137. this.openModal = false
  138. },
  139. // 删除
  140. handleDel (row) {
  141. const _this = this
  142. this.$confirm({
  143. title: '提示',
  144. content: '删除后不可恢复,确定要进行删除吗?',
  145. centered: true,
  146. onOk () {
  147. _this.spinning = true
  148. warehouseLocDel({
  149. id: row.id,
  150. warehouseSn: _this.$route.params.sn
  151. }).then(res => {
  152. if (res.status == 200) {
  153. _this.$message.success(res.message)
  154. _this.$refs.table.refresh()
  155. _this.spinning = false
  156. } else {
  157. _this.spinning = false
  158. }
  159. })
  160. }
  161. })
  162. },
  163. // 返回列表
  164. handleBack () {
  165. this.$router.push({ path: '/inventoryManagement/warehouse/list', query: { closeLastOldTab: true } })
  166. },
  167. pageInit () {
  168. const _this = this
  169. this.$nextTick(() => { // 页面渲染完成后的回调
  170. _this.setTableH()
  171. })
  172. },
  173. setTableH () {
  174. const tableSearchH = this.$refs.tableSearch.offsetHeight
  175. this.tableHeight = window.innerHeight - tableSearchH - 290
  176. }
  177. },
  178. watch: {
  179. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  180. this.setTableH()
  181. }
  182. },
  183. mounted () {
  184. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  185. this.pageInit()
  186. this.resetSearchForm()
  187. }
  188. },
  189. activated () {
  190. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  191. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  192. this.pageInit()
  193. this.resetSearchForm()
  194. }
  195. },
  196. beforeRouteEnter (to, from, next) {
  197. next(vm => {})
  198. }
  199. }
  200. </script>
  201. <style lang="less">
  202. .storingLocationList-wrap{
  203. .storingLocationList-back{
  204. margin-bottom: 10px;
  205. }
  206. }
  207. </style>