list.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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);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. let data
  97. if (res.status == 200) {
  98. data = res.data
  99. const no = (data.pageNo - 1) * data.pageSize
  100. for (var i = 0; i < data.list.length; i++) {
  101. data.list[i].no = no + i + 1
  102. }
  103. this.disabled = false
  104. }
  105. this.spinning = false
  106. return data
  107. })
  108. },
  109. openModal: false, // 新增编辑产品品牌 弹框
  110. itemId: '', // 当前品牌id
  111. nowData: null // 当前记录数据
  112. }
  113. },
  114. methods: {
  115. // 重置
  116. resetSearchForm () {
  117. this.queryParam.warehouseSn = this.$route.params.sn
  118. this.queryParam.name = ''
  119. this.$refs.table.refresh(true)
  120. },
  121. // 新增/编辑
  122. handleEdit (row) {
  123. if (row) {
  124. this.itemId = row.id
  125. row.warehouseSn = this.$route.params.sn
  126. this.nowData = row
  127. } else {
  128. this.itemId = null
  129. this.nowData = { warehouseSn: this.$route.params.sn }
  130. }
  131. this.openModal = true
  132. },
  133. // 新增/编辑 成功
  134. handleOk () {
  135. this.$refs.table.refresh(true)
  136. },
  137. // 关闭弹框
  138. closeModal () {
  139. this.itemId = ''
  140. this.openModal = false
  141. },
  142. // 删除
  143. handleDel (row) {
  144. const _this = this
  145. this.$confirm({
  146. title: '提示',
  147. content: '删除后不可恢复,确定要进行删除吗?',
  148. centered: true,
  149. onOk () {
  150. _this.spinning = true
  151. warehouseLocDel({
  152. id: row.id,
  153. warehouseSn: _this.$route.params.sn
  154. }).then(res => {
  155. if (res.status == 200) {
  156. _this.$message.success(res.message)
  157. _this.$refs.table.refresh()
  158. _this.spinning = false
  159. } else {
  160. _this.spinning = false
  161. }
  162. })
  163. }
  164. })
  165. },
  166. // 返回列表
  167. handleBack () {
  168. this.$router.push({ path: '/inventoryManagement/warehouse/list' })
  169. },
  170. pageInit () {
  171. const _this = this
  172. this.$nextTick(() => { // 页面渲染完成后的回调
  173. _this.setTableH()
  174. })
  175. },
  176. setTableH () {
  177. const tableSearchH = this.$refs.tableSearch.offsetHeight
  178. this.tableHeight = window.innerHeight - tableSearchH - 290
  179. }
  180. },
  181. watch: {
  182. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  183. this.setTableH()
  184. }
  185. },
  186. mounted () {
  187. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  188. this.pageInit()
  189. this.resetSearchForm()
  190. }
  191. },
  192. activated () {
  193. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  194. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  195. this.pageInit()
  196. this.resetSearchForm()
  197. }
  198. },
  199. beforeRouteEnter (to, from, next) {
  200. next(vm => {})
  201. }
  202. }
  203. </script>
  204. <style lang="less">
  205. .storingLocationList-wrap{
  206. .storingLocationList-back{
  207. margin-bottom: 10px;
  208. }
  209. }
  210. </style>