Commit 12dd60d5 authored by 何远江's avatar 何远江

完善打样申请模版

parent cc2d3fab
<template>
<div>
<el-row :gutter="10" class="mb8">
<el-row :gutter="10" class="mb8" v-if="mode != 'info'">
<el-col :span="1.5">
<el-button
type="primary"
......@@ -85,7 +85,12 @@
prop="itemRemark"
min-width="120"
/>
<el-table-column label="操作" align="center" width="120">
<el-table-column
v-if="mode != 'info'"
label="操作"
align="center"
width="120"
>
<template slot-scope="{ row, $index }">
<el-button
type="text"
......@@ -232,7 +237,7 @@ export default {
rules: {},
/**多选 */
selection: [],
optType: 'add',
optType: "add",
/**表单初始化数据 */
form: {
quantity: "",
......@@ -247,7 +252,7 @@ export default {
bomItemRemark: "",
itemRemark: "",
},
currentRowIdx: undefined
currentRowIdx: undefined,
};
},
created() {},
......@@ -262,13 +267,13 @@ export default {
handleAdd() {
this.resetForm();
this.showFlag = true;
this.optType = 'add'
this.optType = "add";
},
/**更新行 */
updateRow(row, idx) {
Object.assign(this.form, row);
this.currentRowIdx = idx
this.optType = 'edit'
this.currentRowIdx = idx;
this.optType = "edit";
this.showFlag = true;
},
/**删除行 */
......@@ -291,10 +296,10 @@ export default {
submitForm() {
this.$refs["form"].validate((valid) => {
if (valid) {
if (this.optType == 'add') {
if (this.optType == "add") {
this.tableData.unshift({ ...this.form });
} else {
this.tableData.splice(this.currentRowIdx, 1, this.form)
this.tableData.splice(this.currentRowIdx, 1, this.form);
}
this.showFlag = false;
}
......@@ -316,6 +321,11 @@ export default {
itemRemark: "",
};
},
/**重置组件状态 */
resetState() {
this.resetForm()
this.tableData = []
},
/**获取组件数据 */
getComData() {
return this.tableData;
......
......@@ -10,7 +10,7 @@
/>
<el-table-column label="工作站" prop="workstationId" align="center" />
<el-table-column label="甘特图显示颜色" prop="colorCode" align="center" />
<el-table-column label="操作" align="center" width="150">
<el-table-column v-if="mode != 'info'" label="操作" align="center" width="150">
<template slot-scope="{ row, $index }">
<el-button
type="text"
......@@ -141,6 +141,7 @@ import ItemBomSelect from "@/components/itemBomSelect/single.vue";
import ProcessProd from "./ProcessProd.vue";
export default {
components: { ItemBomSelect, ProcessProd },
inject: ['mode'],
props: {
bomList: {
type: Array,
......@@ -218,6 +219,11 @@ export default {
itemRemark: "",
};
},
/**重置组件状态 */
resetState() {
this.resetForm()
this.tableData = []
}
},
};
</script>
......
<template>
<div class="form-page">
<div class="form-page" v-loading="loading">
<PageTitle>
{{ pageTitle }}
<!-- 申请按钮显示 -->
<template slot="buttons" v-if="mode == 'apply'">
<el-button size="mini" @click="resetForm">重置</el-button>
<el-button size="mini" type="primary" @click="saveForm">提交</el-button>
</template>
<!-- 修改 按钮显示 -->
<template slot="buttons" v-if="mode == 'edit'">
<el-button size="mini" type="primary" @click="saveForm">提交</el-button>
</template>
</PageTitle>
<PageWrapper>
......@@ -179,8 +185,12 @@ import ProogingProcess from "./components/ProogingProcess.vue";
import ItemSelect from "@/components/itemSelect/single.vue";
import RoutesProcessSelect from "@/components/routesProcessSelect/index.vue";
import { listRouteprocess } from "@/api/mes/pro/routeprocess";
import { Loading } from "element-ui";
import { addPrototypeRequest } from "@/api/mes/pro/prototypeRequest";
import { closeOpenPage } from "@/plugins/tab";
import {
addPrototypeRequest,
getPrototypeRequest,
updatePrototypeRequest,
} from "@/api/mes/pro/prototypeRequest";
export default {
components: { ProogingBom, ProogingProcess, ItemSelect, RoutesProcessSelect },
......@@ -192,6 +202,7 @@ export default {
},
data() {
return {
loading: false,
bomList: [],
// 表单参数
form: {
......@@ -233,11 +244,34 @@ export default {
},
},
created() {
genCode("PROTOTYPE_REQUEST_CODE").then((response) => {
this.form.prototypeRequestCode = response;
});
this.getFormInfo();
this.gCode();
},
methods: {
/** 根据 id 获取页面数据 */
getFormInfo() {
if (this.mode != "apply") {
const id = this.$route.query.prototypeRequestId;
this.loading = true;
getPrototypeRequest(id)
.then(({ data }) => {
Object.assign(this.form, data);
this.bomList = data.bomList;
// 设置组件数据
this.$refs["ProogingBomRef"].tableData = data.bomList;
this.$refs["ProogingProcess"].tableData = data.processList;
})
.finally(() => {
this.loading = false;
});
}
},
/** 生成编码 */
gCode() {
genCode("PROTOTYPE_REQUEST_CODE").then((response) => {
this.form.prototypeRequestCode = response;
});
},
/** 点击tab 获取bom的数据,将参数传递给后面的组件 */
tabClick(val) {
if (val.index != 0) {
......@@ -275,16 +309,29 @@ export default {
bomList,
processList,
};
console.log("params", params);
const loadingInstance = Loading.service({ fullscreen: true });
addPrototypeRequest(params)
.then((res) => {
loadingInstance.close();
this.$modal.msgSuccess("提交成功!");
})
.catch(() => {
loadingInstance.close();
});
this.loading = true;
if (mode == "apply") {
addPrototypeRequest(params)
.then((res) => {
this.loading = false;
this.$modal.msgSuccess("提交成功!");
// 关闭页签
closeOpenPage();
})
.catch(() => {
this.loading = false;
});
} else {
updatePrototypeRequest(params)
.then(() => {
this.loading = false;
this.$modal.msgSuccess("提交成功!");
})
.catch(() => {
this.loading = false;
});
}
},
/**重置表单 */
resetForm() {
......@@ -305,6 +352,9 @@ export default {
testStandard: "",
remark: "",
};
this.$refs["ProogingBomRef"].resetState();
this.$refs["ProogingProcessRef"].resetState();
this.gCode();
},
},
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment