list.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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 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 { warehouseLocList, warehouseLocDel } from '@/api/warehouse'
  71. import { STable } from '@/components'
  72. import storingLocationEditModal from './editModal.vue'
  73. export default {
  74. components: { STable, storingLocationEditModal },
  75. data () {
  76. return {
  77. spinning: false,
  78. tableHeight: 0,
  79. queryParam: { // 查询条件
  80. warehouseSn: this.$route.params.sn, // 仓库sn
  81. name: '' // 仓位名称
  82. },
  83. disabled: false, // 查询、重置按钮是否可操作
  84. columns: [
  85. { title: '序号', dataIndex: 'no', width: '10%', align: 'center' },
  86. { title: '仓位名称', dataIndex: 'name', align: 'center', width: '45%', customRender: function (text) { return text || '--' }, ellipsis: true },
  87. { title: '操作', scopedSlots: { customRender: 'action' }, width: '45%', align: 'center' }
  88. ],
  89. // 加载数据方法 必须为 Promise 对象
  90. loadData: parameter => {
  91. this.disabled = true
  92. this.spinning = true
  93. return warehouseLocList(Object.assign(parameter, this.queryParam)).then(res => {
  94. let data
  95. if (res.status == 200) {
  96. 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. }
  103. this.spinning = false
  104. return data
  105. })
  106. },
  107. openModal: false, // 新增编辑产品品牌 弹框
  108. itemSn: '', // 当前sn
  109. nowData: null // 当前记录数据
  110. }
  111. },
  112. methods: {
  113. // 重置
  114. resetSearchForm () {
  115. this.queryParam.warehouseSn = this.$route.params.sn
  116. this.queryParam.name = ''
  117. this.$refs.table.refresh(true)
  118. },
  119. // 新增/编辑
  120. handleEdit (row) {
  121. if (row) {
  122. this.itemSn = row.warehouseLocationSn
  123. row.warehouseSn = this.$route.params.sn
  124. this.nowData = row
  125. } else {
  126. this.itemSn = null
  127. this.nowData = { warehouseSn: this.$route.params.sn }
  128. }
  129. this.openModal = true
  130. },
  131. // 新增/编辑 成功
  132. handleOk () {
  133. this.$refs.table.refresh(true)
  134. },
  135. // 关闭弹框
  136. closeModal () {
  137. this.itemSn = ''
  138. this.openModal = false
  139. },
  140. // 删除
  141. handleDel (row) {
  142. const _this = this
  143. this.$confirm({
  144. title: '提示',
  145. content: '删除后不可恢复,确定要进行删除吗?',
  146. centered: true,
  147. onOk () {
  148. _this.spinning = true
  149. warehouseLocDel({
  150. sn: row.warehouseLocationSn
  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: '/basicData/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 - 285
  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. // 如果是新页签打开,则重置当前页面
  191. if (this.$store.state.app.isNewTab) {
  192. this.pageInit()
  193. this.resetSearchForm()
  194. }
  195. // 仅刷新列表,不重置页面
  196. if (this.$store.state.app.updateList) {
  197. this.pageInit()
  198. this.$refs.table.refresh()
  199. }
  200. },
  201. beforeRouteEnter (to, from, next) {
  202. next(vm => {})
  203. }
  204. }
  205. </script>
  206. <style lang="less">
  207. .storingLocationList-wrap{
  208. .storingLocationList-back{
  209. margin-bottom: 10px;
  210. }
  211. }
  212. </style>