feat:添加工艺路线复制功能

This commit is contained in:
shijing 2025-04-03 16:46:02 +08:00
parent e6c0069e74
commit ebf0a9a058
2 changed files with 107 additions and 11 deletions

View File

@ -440,8 +440,8 @@ export default {
}, },
copy:{ copy:{
name: "复制", name: "复制",
req: async function (id,data) { req: async function (data) {
return await http.post(`${config.API_URL}/mtm/routepack/${id}/copy/`,data) return await http.post(`${config.API_URL}/mtm/routepack/copy/`,data)
} }
}, },
togglestate:{ togglestate:{

View File

@ -93,14 +93,14 @@
@click="table_show(scope.row, scope.$index)" @click="table_show(scope.row, scope.$index)"
>查看 >查看
</el-button> </el-button>
<!-- <el-button <el-button
link link
type="success" type="success"
size="small" size="small"
v-if="scope.row.state == 30" v-if="scope.row.state == 30"
@click="table_copy(scope.row)" @click="table_copy(scope.row)"
>复制 >复制
</el-button> --> </el-button>
<el-button <el-button
link link
type="success" type="success"
@ -127,6 +127,57 @@
</scTable> </scTable>
</el-main> </el-main>
</el-container> </el-container>
<el-dialog title="复制工艺" v-model="dialogVisible">
<el-form ref="dialogForm" :model="form" :rules="rules" label-position="right" label-width="80px">
<el-row>
<el-col>
<el-form-item label="名称" prop="new_name">
<el-input
v-model="form.new_name"
type="text"
clearable
></el-input>
</el-form-item>
</el-col>
<el-col>
<el-form-item label="原料" prop="material_in">
<el-select
v-model="form.material_in"
style="width: 100%"
filterable
>
<el-option
v-for="item in materialIn"
:key="item.id"
:label="item.full_name"
:value="item.id"
/>
</el-select>
</el-form-item>
</el-col>
<el-col>
<el-form-item label="产品" prop="material_out">
<el-select
v-model="form.material_out"
style="width: 100%"
filterable
>
<el-option
v-for="item in materialOut"
:key="item.id"
:label="item.full_name"
:value="item.id"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer>
<el-button type="primary" :loading="isSaveing" @click="form_save">保存</el-button>
<el-button @click="dialogVisible = false">取消</el-button>
</template>
</el-dialog>
<save-dialog <save-dialog
v-if="dialog.save" v-if="dialog.save"
ref="saveDialog" ref="saveDialog"
@ -183,9 +234,22 @@ export default {
search: "", search: "",
keyword: null, keyword: null,
}, },
form:{
routepack:"",
new_name:"",
material_in:"",
material_out:""
},
rules: {
new_name:[{required: true,message: "请填写新工艺名称",trigger: "blur"}],
material_in:[{required: true,message: "请选择新工艺所用原料",trigger: "blur"}],
material_out:[{required: true,message: "请选择新工艺最终产品",trigger: "blur"}],
},
nodes:[], nodes:[],
edges:[], edges:[],
timeRange: [], timeRange: [],
materialIn: [],
materialOut: [],
filteType: "all", filteType: "all",
stateOptions: [ stateOptions: [
{ {
@ -209,13 +273,28 @@ export default {
filterType: "all", filterType: "all",
isSaveing:false, isSaveing:false,
limitedWatch:false, limitedWatch:false,
dialogVisible:false,
}; };
}, },
mounted() { mounted() {
let userInfo = this.$TOOL.data.get("USER_INFO"); let userInfo = this.$TOOL.data.get("USER_INFO");
this.userId = userInfo.id; this.userId = userInfo.id;
this.getMaterialIn();
this.getMaterialOut();
}, },
methods: { methods: {
getMaterialIn() {
let that = this;
that.$API.mtm.material.list.req({ page: 0, type__in: "20,30",is_hidden: false}).then((res) => {
that.materialIn = res;
});
},
getMaterialOut() {
let that = this;
that.$API.mtm.material.list.req({ page: 0, type__in: "10,20",is_hidden: false}).then((res) => {
that.materialOut = res;
});
},
getType(state) { getType(state) {
if (state == 10) { if (state == 10) {
return "warning"; return "warning";
@ -252,13 +331,30 @@ export default {
}, },
// //
table_copy(row){ table_copy(row){
this.$API.mtm.routepack.copy.req(row.id).then((res) => { let that = this;
this.$message.success("复制成功"); that.form.routepack = row.id;
this.$refs.table.refresh(); that.form.new_name = '';
return res; that.form.material_in = '';
}).catch((err) => { that.form.material_out ='';
return err; that.dialogVisible = true;
}); },
form_save(){
let that = this;
that.$refs.dialogForm.validate(async (valid) => {
if (valid) {
that.isSaveing = true;
that.$API.mtm.routepack.copy.req(that.form).then((res) => {
that.$message.success("复制成功");
that.$refs.table.refresh();
that.isSaveing = false;
that.dialogVisible = false;
return res;
}).catch((err) => {
that.isSaveing = false;
return err;
});
}
})
}, },
// handleWatch(row) { // handleWatch(row) {
// let that = this; // let that = this;