factory_web/src/views/wpm_gx/handover.vue

285 lines
6.0 KiB
Vue

<template>
<el-container>
<el-header>
<div class="left-panel">
<el-header>
<el-segmented
v-model="values"
:options="options"
size="default"
></el-segmented>
</el-header>
<el-button
type="primary"
icon="el-icon-plus"
@click="table_add(10)"
v-auth="'mgroup.create'"
>新增</el-button
>
<el-button
type="primary"
icon="el-icon-plus"
@click="table_add(20)"
v-auth="'mgroup.create'"
>返工</el-button
>
</div>
<div class="right-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>
</el-header>
<el-main class="nopadding">
<scTable
v-if="values == '交送'"
ref="table"
:apiObj="apiObj"
row-key="id"
:params="params_sender"
>
<el-table-column
label="#"
type="index"
width="50"
></el-table-column>
<el-table-column
label="物料"
prop="material_name"
min-width="120"
></el-table-column>
<el-table-column label="批次" prop="batch" min-width="100">
</el-table-column>
<el-table-column label="数量" prop="count"></el-table-column>
<el-table-column
label="交送人"
prop="send_user_name"
></el-table-column>
<el-table-column
label="接收人"
prop="recive_user_name"
></el-table-column>
<el-table-column
label="交接日期"
prop="send_date"
width="120"
></el-table-column>
<el-table-column
label="操作"
fixed="right"
align="center"
width="120"
>
<template #default="scope">
<el-button
link
size="small"
@click="table_edit(scope.row)"
v-auth="'mgroup.update'"
type="primary"
>编辑</el-button
>
<el-divider direction="vertical"></el-divider>
<el-popconfirm
title="确定删除吗?"
@confirm="table_del(scope.row, scope.$index)"
>
<template #reference>
<el-button
link
size="small"
v-auth="'mgroup.delete'"
type="danger"
>删除</el-button
>
</template>
</el-popconfirm>
</template>
</el-table-column>
</scTable>
<scTable
v-if="values == '接收'"
ref="table"
:apiObj="apiObj"
row-key="id"
:params="params_recive"
>
<el-table-column
label="#"
type="index"
width="50"
></el-table-column>
<el-table-column
label="物料"
prop="material_name"
min-width="120"
></el-table-column>
<el-table-column label="批次" prop="batch" min-width="100">
</el-table-column>
<el-table-column label="数量" prop="count"></el-table-column>
<el-table-column
label="交送人"
prop="send_user_name"
></el-table-column>
<el-table-column
label="接收人"
prop="recive_user_name"
></el-table-column>
<el-table-column
label="交接日期"
prop="send_date"
width="120"
></el-table-column>
<el-table-column
label="操作"
fixed="right"
align="center"
width="120"
>
<template #default="scope">
<el-button
link
size="small"
@click="table_edit(scope.row)"
v-auth="'mgroup.update'"
type="primary"
>编辑</el-button
>
<el-divider direction="vertical"></el-divider>
<el-popconfirm
title="确定删除吗?"
@confirm="table_del(scope.row, scope.$index)"
>
<template #reference>
<el-button
link
size="small"
v-auth="'mgroup.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"
:type="type"
:mgroupId="mgroupId"
@success="handleSaveSuccess"
@closed="dialog.save = false"
>
</save-dialog>
</template>
<script>
import saveDialog from "./handover_form.vue";
export default {
props: {
mgroupName: {
type: String,
default: "",
},
},
name: "handover",
components: {
saveDialog,
},
data() {
return {
apiObj: null,
query: {},
dialog: {
save: false,
permission: false,
},
params_sender: { send_mgroup: "" },
params_recive: { recive_mgroup: "" },
options: ["交送", "接收"],
tableData: [],
selection: [],
values: "交送",
mtask: "",
mlogId: "",
processId: "",
processCate: "",
};
},
mounted() {
let that = this;
that.$API.mtm.mgroup.list
.req({ page: 0, search: that.mgroupName })
.then((res) => {
that.mgroupId = res[0].id;
that.processId = res[0].process;
that.processCate = res[0].process_cate;
that.params_sender.send_mgroup = that.mgroupId;
that.params_recive.recive_mgroup = that.mgroupId;
that.apiObj = that.$API.wpm.handover.list;
});
},
methods: {
//添加
table_add(type) {
this.dialog.save = true;
this.type = type;
this.$nextTick(() => {
this.$refs.saveDialog.open("add");
});
},
//编辑
table_edit(row) {
this.dialog.save = true;
this.$nextTick(() => {
this.$refs.saveDialog.open("edit").setData(row);
});
},
//删除
async table_del(row) {
var id = row.id;
var res = await this.$API.mtm.mgroup.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(data, mode) {
this.dialog.save = true;
this.$refs.table.refresh();
},
},
};
</script>
<style scoped>
.treeMain {
width: 100%;
height: 280px;
overflow: auto;
border: 1px solid #dcdfe6;
margin-bottom: 10px;
}
</style>