123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- <template>
- <a-card size="small" :bordered="false" class="warehouseList-wrap">
- <a-spin :spinning="spinning" tip="Loading...">
- <!-- 搜索条件 -->
- <div ref="tableSearch" class="table-page-search-wrapper">
- <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
- <a-row :gutter="15">
- <a-col :md="6" :sm="24">
- <a-form-item label="仓库名称">
- <a-input id="warehouseList-name" v-model.trim="queryParam.name" allowClear placeholder="请输入仓库名称"/>
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="warehouseList-refresh">查询</a-button>
- <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="warehouseList-reset">重置</a-button>
- </a-col>
- </a-row>
- </a-form>
- </div>
- <!-- 操作按钮 -->
- <div class="table-operator">
- <a-button v-if="$hasPermissions('B_warehouse_add')" id="warehouseList-add" type="primary" class="button-error" @click="handleEdit()">新增</a-button>
- </div>
- <!-- 列表 -->
- <s-table
- class="sTable fixPagination"
- ref="table"
- :style="{ height: tableHeight+84.5+'px' }"
- size="small"
- :rowKey="(record) => record.id"
- :columns="columns"
- :data="loadData"
- :scroll="{ y: tableHeight }"
- bordered>
- <!-- 操作 -->
- <template slot="action" slot-scope="text, record">
- <a-button
- size="small"
- type="link"
- class="button-warning"
- @click="goStoringLocation(record)"
- v-if="$hasPermissions('B_warehouse_ckSet')"
- id="warehouseList-storingLocation-btn">仓位管理</a-button>
- <a-button
- size="small"
- type="link"
- class="button-info"
- v-if="record.defaultFlag!='1' &&$hasPermissions('B_warehouse_edit') "
- @click="handleEdit(record)"
- id="warehouseList-edit-btn">编辑</a-button>
- <a-button
- size="small"
- type="link"
- class="button-error"
- v-if="record.defaultFlag!='1' &&$hasPermissions('B_warehouse_del')"
- @click="handleDel(record)"
- id="warehouseList-del-btn">删除</a-button>
- <span v-if="record.defaultFlag=='0' && !$hasPermissions('B_warehouse_edit') && !$hasPermissions('B_warehouse_del')">--</span>
- </template>
- </s-table>
- </a-spin>
- <!-- 新增/编辑仓库 -->
- <warehouse-edit-modal :openModal="openModal" :nowData="nowData" :itemSn="itemSn" @ok="handleOk" @close="closeModal" />
- </a-card>
- </template>
- <script>
- import { warehouseList, warehouseDel } from '@/api/warehouse'
- import { STable } from '@/components'
- import warehouseEditModal from './editModal.vue'
- export default {
- components: { STable, warehouseEditModal },
- data () {
- return {
- spinning: false,
- queryParam: { // 查询条件
- name: '' // 仓库名称
- },
- tableHeight: 0,
- disabled: false, // 查询、重置按钮是否可操作
- columns: [
- { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
- { title: '仓库名称', dataIndex: 'name', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
- { title: '操作', scopedSlots: { customRender: 'action' }, align: 'center' }
- ],
- // 加载数据方法 必须为 Promise 对象
- loadData: parameter => {
- this.disabled = true
- this.spinning = true
- return warehouseList(Object.assign(parameter, this.queryParam)).then(res => {
- const data = res.data
- const no = (data.pageNo - 1) * data.pageSize
- for (var i = 0; i < data.list.length; i++) {
- data.list[i].no = no + i + 1
- }
- this.disabled = false
- this.spinning = false
- return data
- })
- },
- openModal: false, // 新增编辑 弹框
- itemSn: '', // 当前sn
- nowData: null // 当前记录数据
- }
- },
- methods: {
- // 重置
- resetSearchForm () {
- this.queryParam.name = ''
- this.$refs.table.refresh(true)
- },
- // 新增/编辑
- handleEdit (row) {
- this.itemSn = row ? row.warehouseSn : null
- this.nowData = row || null
- this.openModal = true
- },
- // 新增/编辑 成功
- handleOk () {
- this.$refs.table.refresh(true)
- },
- // 关闭弹框
- closeModal () {
- this.itemSn = ''
- this.openModal = false
- },
- // 删除
- handleDel (row) {
- const _this = this
- this.$confirm({
- title: '提示',
- content: '删除后不可恢复,确定要进行删除吗?',
- centered: true,
- onOk () {
- _this.spinning = true
- warehouseDel({
- sn: row.warehouseSn
- }).then(res => {
- if (res.status == 200) {
- _this.$message.success(res.message)
- _this.$refs.table.refresh()
- _this.spinning = false
- } else {
- _this.spinning = false
- }
- })
- }
- })
- },
- // 查看仓位
- goStoringLocation (row) {
- this.$router.push({ path: `/basicData/storingLocation/${row.warehouseSn}`, query: { name: row.name } })
- },
- setTableH () {
- const tableSearchH = this.$refs.tableSearch.offsetHeight
- this.tableHeight = window.innerHeight - tableSearchH - 245
- }
- },
- mounted () {
- const _this = this
- this.$nextTick(() => { // 页面渲染完成后的回调
- _this.setTableH()
- })
- }
- }
- </script>
|