factory_web/src/views/mpr/warehouse.vue

83 lines
2.4 KiB
Vue

<template>
<el-container>
<el-header>
<div class="left-panel">
<el-button type="primary" icon="el-icon-plus" @click="add" v-auth="'warehouse.create'">新增</el-button>
</div>
</el-header>
<el-main class="nopadding">
<scTable ref="table" :apiObj="apiObj" row-key="id" stripe :params="query">
<el-table-column type="index" width="50" />
<el-table-column label="库房名称" prop="name" show-overflow-tooltip>
</el-table-column>
<el-table-column label="库房编号" prop="number">
</el-table-column>
<el-table-column label="库房地点" prop="place">
</el-table-column>
<el-table-column label="创建时间" prop="create_time" show-overflow-tooltip>
</el-table-column>
<el-table-column label="操作" fixed="right" align="center" width="150px">
<template #default="scope">
<el-button link type="primary" @click="table_edit(scope.row)" v-auth="'warehouse.update'">
编辑
</el-button>
<el-button link type="danger" @click="table_del(scope.row)" v-auth="'warehouse.delete'">
删除
</el-button>
</template>
</el-table-column>
</scTable>
</el-main>
</el-container>
<save-dialog v-if="dialog.save" ref="saveDialog" @success="handleSaveSuccess"
@closed="dialog.save = false"></save-dialog>
</template>
<script>
import saveDialog from "./warehouse_form2.vue";
export default {
name: "mprWarehouse",
components: {
saveDialog,
},
data() {
return {
dialog: {
save: false,
},
apiObj: this.$API.mpr.warehouse.list,
query: {
page: 1,
page_size: 20,
},
};
},
methods: {
add() {
this.dialog.save = true;
this.$nextTick(() => {
this.$refs.saveDialog.open("add");
});
},
table_edit(row) {
this.dialog.save = true;
this.$nextTick(() => {
this.$refs.saveDialog.open("edit").setData(row);
});
},
table_del(row) {
this.$confirm(`确定删除吗?`, "提示", {
type: "warning",
}).then(() => {
this.$API.mpr.warehouse.delete.req(row.id).then(() => {
this.$message.success("删除成功");
this.$refs.table.refresh();
});
}).catch(() => { });
},
handleSaveSuccess(data, mode) {
this.$refs.table.refresh();
},
},
};
</script>