factory_web/src/views/mtm/process.vue

116 lines
3.3 KiB
Vue

<template>
<el-container>
<el-header>
<div class="left-panel">
<el-input style="margin-right: 5px;" v-model="query.search" placeholder="产品名称" clearable></el-input>
<el-button type="primary" icon="el-icon-search" @click="handleQuery"></el-button>
</div>
<div class="right-panel">
<el-button type="primary" icon="el-icon-plus" @click="table_add" v-auth="'material.create'"></el-button>
</div>
</el-header>
<el-main class="nopadding">
<scTable ref="table" :apiObj="apiObj" row-key="id" @selection-change="selectionChange">
<el-table-column label="#" type="index" width="50"></el-table-column>
<el-table-column label="名称" prop="name" min-width="100"></el-table-column>
<!-- <el-table-column label="编号" prop="code" min-width="100"></el-table-column> -->
<el-table-column label="大类" prop="cate" min-width="150"></el-table-column>
<el-table-column label="车间" prop="belong_dept_name" min-width="60"></el-table-column>
<el-table-column label="操作" fixed="right" align="center" width="140">
<template #default="scope">
<el-button link size="small" @click="table_edit(scope.row)" v-auth="'material.update'" type="primary">编辑</el-button>
<el-divider direction="vertical"></el-divider>
<el-popconfirm title="确定删除吗?" @confirm="roleDel(scope.row, scope.$index)">
<template #reference>
<el-button link size="small" v-auth="'material.delete'" type="danger">删除</el-button>
</template>
</el-popconfirm>
</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 "./process_form.vue";
export default {
name: 'material',
components: {
saveDialog
},
data() {
return {
apiObj: this.$API.mtm.process.list,
search: {
keyword: null
},
dialog: {
save: false,
},
query: {},
types_:{
0:'电/水/气',
10:'成品',
20:'半成品',
30:'主要原料',
40:'辅助材料',
50:'加工工具',
60:'辅助工装',
},
}
},
methods: {
handleChange(value) {
console.log(value);
console.log(this.form.belong_dept);
},
//添加
table_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);
});
},
//删除产品
async roleDel(row){
var id = row.id;
var res = await this.$API.mtm.material.delete.req(id);
if(res.err_msg){
this.$message.error(res.err_msg)
}else{
this.$refs.table.refresh();
this.$message.success("删除成功")
}
},
//表格选择后回调事件
selectionChange(selection){
this.selection = selection;
},
//搜索
handleQuery(){
this.$refs.table.queryData(this.query)
},
//本地更新数据
handleSaveSuccess(){
this.$refs.table.refresh()
}
}
}
</script>
<style scoped>
.treeMain {width: 100%;height:280px;overflow: auto;border: 1px solid #dcdfe6;margin-bottom: 10px;}
</style>