list.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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 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. <a-button
  47. size="small"
  48. type="link"
  49. class="button-info"
  50. v-if="record.defaultFlag!='1'"
  51. @click="handleEdit(record)"
  52. id="storingLocationList-edit-btn">编辑</a-button>
  53. <a-button
  54. size="small"
  55. type="link"
  56. class="button-error"
  57. v-if="record.defaultFlag!='1'"
  58. @click="handleDel(record)"
  59. id="storingLocationList-del-btn">删除</a-button>
  60. <span v-if="record.defaultFlag=='1'">--</span>
  61. </template>
  62. </s-table>
  63. </a-card>
  64. </a-spin>
  65. <!-- 新增/编辑仓位 -->
  66. <storing-location-edit-modal :openModal="openModal" :nowData="nowData" :itemSn="itemSn" @ok="handleOk" @close="closeModal" />
  67. </div>
  68. </template>
  69. <script>
  70. import { commonMixin } from '@/utils/mixin'
  71. import { warehouseLocList, warehouseLocDel } from '@/api/warehouse'
  72. import { STable } from '@/components'
  73. import storingLocationEditModal from './editModal.vue'
  74. export default {
  75. name: 'StoringLocationList',
  76. mixins: [commonMixin],
  77. components: { STable, storingLocationEditModal },
  78. data () {
  79. return {
  80. spinning: false,
  81. tableHeight: 0,
  82. queryParam: { // 查询条件
  83. warehouseSn: this.$route.params.sn, // 仓库sn
  84. name: '' // 仓位名称
  85. },
  86. disabled: false, // 查询、重置按钮是否可操作
  87. columns: [
  88. { title: '序号', dataIndex: 'no', width: '10%', align: 'center' },
  89. { title: '仓位名称', dataIndex: 'name', align: 'center', width: '45%', customRender: function (text) { return text || '--' }, ellipsis: true },
  90. { title: '操作', scopedSlots: { customRender: 'action' }, width: '45%', align: 'center' }
  91. ],
  92. // 加载数据方法 必须为 Promise 对象
  93. loadData: parameter => {
  94. this.disabled = true
  95. this.spinning = true
  96. return warehouseLocList(Object.assign(parameter, this.queryParam)).then(res => {
  97. let data
  98. if (res.status == 200) {
  99. data = res.data
  100. const no = (data.pageNo - 1) * data.pageSize
  101. for (var i = 0; i < data.list.length; i++) {
  102. data.list[i].no = no + i + 1
  103. }
  104. this.disabled = false
  105. }
  106. this.spinning = false
  107. return data
  108. })
  109. },
  110. openModal: false, // 新增编辑产品品牌 弹框
  111. itemSn: '', // 当前sn
  112. nowData: null // 当前记录数据
  113. }
  114. },
  115. methods: {
  116. // 重置
  117. resetSearchForm () {
  118. this.queryParam.warehouseSn = this.$route.params.sn
  119. this.queryParam.name = ''
  120. this.$refs.table.refresh(true)
  121. },
  122. // 新增/编辑
  123. handleEdit (row) {
  124. if (row) {
  125. this.itemSn = row.warehouseLocationSn
  126. row.warehouseSn = this.$route.params.sn
  127. this.nowData = row
  128. } else {
  129. this.itemSn = null
  130. this.nowData = { warehouseSn: this.$route.params.sn }
  131. }
  132. this.openModal = true
  133. },
  134. // 新增/编辑 成功
  135. handleOk () {
  136. this.$refs.table.refresh(true)
  137. },
  138. // 关闭弹框
  139. closeModal () {
  140. this.itemSn = ''
  141. this.openModal = false
  142. },
  143. // 删除
  144. handleDel (row) {
  145. const _this = this
  146. this.$confirm({
  147. title: '提示',
  148. content: '删除后不可恢复,确定要进行删除吗?',
  149. centered: true,
  150. onOk () {
  151. _this.spinning = true
  152. warehouseLocDel({
  153. sn: row.warehouseLocationSn
  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: '/basicData/warehouse/list', query: { closeLastOldTab: true } })
  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 - 285
  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. // 如果是新页签打开,则重置当前页面
  194. if (this.$store.state.app.isNewTab) {
  195. this.pageInit()
  196. this.resetSearchForm()
  197. }
  198. // 仅刷新列表,不重置页面
  199. if (this.$store.state.app.updateList) {
  200. this.pageInit()
  201. this.$refs.table.refresh()
  202. }
  203. },
  204. beforeRouteEnter (to, from, next) {
  205. next(vm => {})
  206. }
  207. }
  208. </script>
  209. <style lang="less">
  210. .storingLocationList-wrap{
  211. .storingLocationList-back{
  212. margin-bottom: 10px;
  213. }
  214. }
  215. </style>