Commit dfd83c51 authored by renjintao's avatar renjintao

state

parent 1586601e
<template>
<Form ref="form" :model="entity" :rules="rules" :label-width="120">
<template>
<Form ref="form" :model="entity" :rules="rules" :label-width="120">
<Row>
<!--
<!--
<Col :span="12">
<FormItem :label="l('routingStepId')" prop="routingStepId">
<InputNumber v-model="entity.routingStepId"></InputNumber>
......@@ -34,19 +34,14 @@
</Col>
-->
<Col :span="12">
<Col :span="12">
<FormItem :label="l('routingDetailName')" prop="routingDetailId">
<Select v-model="entity.routingDetailId">
<Option
v-for="(item, index) in routingDetailList"
:value="item.value"
:key="index"
>{{ item.label }}</Option
>
</Select>
<Select v-model="entity.routingDetailId">
<Option v-for="(item, index) in routingDetailList" :value="item.value" :key="index">{{ item.label }}</Option>
</Select>
</FormItem>
</Col>
<!-- <Col :span="8">
</Col>
<!-- <Col :span="8">
<FormItem :label="l('materialType')" prop="materialType">
<Dictionary
code="mes_xingchi_resource.material.materialReType"
......@@ -54,66 +49,48 @@
></Dictionary>
</FormItem>
</Col>-->
<Col :span="12">
<Col :span="12">
<!-- <FormItem :label="l('nameMaterial')" prop="materialNumber">
<Materiel :bomId="productBomId" v-model="entity.materialId" @on-change="change"></Materiel>
</FormItem>-->
<FormItem :label="l('nameMaterial')" prop="materialId">
<Select
v-model="entity.materialId"
placeholder="请选择"
style="width: 300px"
>
<Option
v-for="(item, index) in listData"
:key="index"
:value="item.value"
:label="item.label"
style="display: none"
></Option>
<Tree
key="mytree"
:data="dataTree"
ref="mytree"
:render="renderContent"
></Tree>
</Select>
<!-- <Materiel
<Select v-model="entity.materialId" placeholder="请选择" style="width: 300px">
<Option v-for="(item, index) in listData" :key="index" :value="item.value" :label="item.label" style="display: none"></Option>
<Tree key="mytree" :data="dataTree" ref="mytree" :render="renderContent"></Tree>
</Select>
<!-- <Materiel
v-model="entity.materialId"
@on-change="change"
:codeRuleType="1"
:setType="true"
></Materiel> -->
</FormItem>
</Col>
<!-- <Col :span="8" v-if="false">
</Col>
<!-- <Col :span="8" v-if="false">
<FormItem :label="l('nameMaterial')" prop="nameMaterial">
<Input v-model="entity.nameMaterial"></Input>
</FormItem>
</Col>-->
<Col :span="12">
<Col :span="12">
<FormItem :label="l('quantity')" prop="quantity">
<InputNumber
v-model="entity.quantity"
style="width: 100%"
></InputNumber>
<InputNumber v-model="entity.quantity" style="width: 100%"></InputNumber>
</FormItem>
</Col>
<Divider orientation="left">物料属性</Divider>
<Row>
<Col :span="12" v-if="entity.materialId">
<FormItem label="名称:">
<span>{{ entity.nameMaterial }}</span>
</FormItem>
</Col>
<Col :span="12" v-if="entity.materialId">
<FormItem label="编码:">
<span>{{ entity.materialNumber }}</span>
</FormItem>
</Col>
</Row>
<CustomProperties :materialId="entity.materialId" :forItem="forItem" />
<!-- <Col :span="8">
<Divider orientation="left">物料属性</Divider>
<Row>
<Col :span="12" v-if="entity.materialId">
<FormItem label="名称:">
<span>{{ entity.nameMaterial }}</span>
</FormItem>
</Col>
<Col :span="12" v-if="entity.materialId">
<FormItem label="编码:">
<span>{{ entity.materialNumber }}</span>
</FormItem>
</Col>
</Row>
<CustomProperties :materialId="entity.materialId" :forItem="forItem" />
<!-- <Col :span="8">
<FormItem :label="l('brand')" prop="brand">
<Input v-model="entity.brand"></Input>
</FormItem>
......@@ -150,203 +127,205 @@
</Col>-->
</Row>
<FormItem>
<Button type="primary" @click="handleSubmit" v-noClick>保存</Button>
<Button @click="handleClose" class="ml20">取消</Button>
<Button type="primary" @click="handleSubmit" v-noClick>保存</Button>
<Button @click="handleClose" class="ml20">取消</Button>
</FormItem>
</Form>
</Form>
</template>
<script>
<script>
import Api from "./api";
import ApiDetail from "../api";
export default {
name: "Add",
data() {
return {
forItem: {},
listData: [],
dataTree: [],
entity: {
routingHeaderId: null,
routingDetailId: null,
routingStepId: 0,
quantity: null,
materialId: "",
materialType: "",
materialNumber: null,
nameMaterial: "",
brand: "",
specifications: "",
xhgg: "",
texture: "",
procurementStandards: "",
qualityGrade: "",
state: null,
extend: "",
remark: "",
drawNum: "",
json: {},
},
rules: {
routingDetailId: [
{
required: true,
message: "请选择工序",
type: "number",
trigger: "change",
},
],
materialId: [
{
required: true,
message: "请选择工序",
trigger: "change",
},
],
quantity: [
{
required: true,
type: "number",
message: "请选择工序",
trigger: "blur",
},
],
},
routingDetailList: [],
};
},
props: {
v: Object,
eid: Number,
headid: Number,
productBomId: {
type: Number,
default: null,
},
},
mounted() {
this.loadDetails();
this.getData();
},
methods: {
renderContent(h, { root, node, data }) {
//渲染树的样式
return h(
"span",
{
style: {
cursor: "pointer",
},
on: {
click: () => {
this.handleSelect(data); //手动选择树节点
name: "Add",
data() {
return {
forItem: {},
listData: [],
dataTree: [],
entity: {
routingHeaderId: null,
routingDetailId: null,
routingStepId: 0,
quantity: null,
materialId: "",
materialType: "",
materialNumber: null,
nameMaterial: "",
brand: "",
specifications: "",
xhgg: "",
texture: "",
procurementStandards: "",
qualityGrade: "",
state: 0,
extend: "",
remark: "",
drawNum: "",
json: {},
},
},
rules: {
routingDetailId: [{
required: true,
message: "请选择工序",
type: "number",
trigger: "change",
}, ],
materialId: [{
required: true,
message: "请选择工序",
trigger: "change",
}, ],
quantity: [{
required: true,
type: "number",
message: "请选择工序",
trigger: "blur",
}, ],
},
routingDetailList: [],
};
},
props: {
v: Object,
eid: Number,
headid: Number,
productBomId: {
type: Number,
default: null,
},
data.title
);
},
handleSelect(data) {
console.log(data);
mounted() {
this.loadDetails();
this.getData();
},
methods: {
renderContent(h, {
root,
node,
data
}) {
//渲染树的样式
return h(
"span", {
style: {
cursor: "pointer",
},
on: {
click: () => {
this.handleSelect(data); //手动选择树节点
},
},
},
data.title
);
},
handleSelect(data) {
console.log(data);
let obj = {
label: data.title,
value: data.materialId,
};
this.listData = [];
this.listData.push(obj);
this.entity.materialId = this.listData[0].value;
this.entity.nameMaterial = this.listData[0].label;
let obj = {
label: data.title,
value: data.materialId,
};
this.listData = [];
this.listData.push(obj);
this.entity.materialId = this.listData[0].value;
this.entity.nameMaterial = this.listData[0].label;
this.entity.nameMaterial = data.name;
this.entity.materialId = data.materialId;
this.entity.materialNumber = data.mmcode;
this.entity.json.nameMaterial = data.name;
this.entity.json.materialNumber = data.mmcode;
Api.getMaterial({ id: data.materialId }).then((r) => {
if (r.result) {
this.forItem = r.result;
}
});
},
getData() {
Api.alltree({ id: this.productBomId }).then((r) => {
if (r.success) {
this.dataTree = r.result;
// this.$Message.success("获取物料成功");
} else {
this.$Message.error("获取物料失败");
}
});
},
handleSubmit() {
this.$refs.form.validate((v) => {
if (v) {
this.entity.routingHeaderId = this.headid;
Api.create(this.entity)
.then((r) => {
if (r.success) {
this.$Message.success("保存成功");
this.$emit("on-ok");
} else {
this.$Message.error("保存失败");
}
})
.catch((err) => {
this.$Message.error("保存失败");
console.warn(err);
this.entity.nameMaterial = data.name;
this.entity.materialId = data.materialId;
this.entity.materialNumber = data.mmcode;
this.entity.json.nameMaterial = data.name;
this.entity.json.materialNumber = data.mmcode;
Api.getMaterial({
id: data.materialId
}).then((r) => {
if (r.result) {
this.forItem = r.result;
}
});
}
});
},
handleClose() {
this.$emit("on-close");
},
// change(e, v) {
// console.log(e);
// console.log(v);
// this.entity.nameMaterial = e.name;
// this.entity.materialId = e.materialId;
// this.entity.materialNumber = e.mmcode;
},
getData() {
Api.alltree({
id: this.productBomId
}).then((r) => {
if (r.success) {
this.dataTree = r.result;
// this.$Message.success("获取物料成功");
} else {
this.$Message.error("获取物料失败");
}
});
},
handleSubmit() {
this.$refs.form.validate((v) => {
if (v) {
this.entity.routingHeaderId = this.headid;
Api.create(this.entity)
.then((r) => {
if (r.success) {
this.$Message.success("保存成功");
this.$emit("on-ok");
} else {
this.$Message.error("保存失败");
}
})
.catch((err) => {
this.$Message.error("保存失败");
console.warn(err);
});
}
});
},
handleClose() {
this.$emit("on-close");
},
// change(e, v) {
// console.log(e);
// console.log(v);
// this.entity.nameMaterial = e.name;
// this.entity.materialId = e.materialId;
// this.entity.materialNumber = e.mmcode;
// this.entity.json.nameMaterial = e.name;
// this.entity.json.materialNumber = e.mmcode;
// this.forItem = v;
// },
loadDetails() {
//获取工序列表
let parms = {
headerID: this.headid,
};
ApiDetail.pagedDetails(parms).then((r) => {
let tempDetails = r.result;
let tempD = [];
tempDetails.forEach((data) => {
let tempObj = {};
tempObj.value = data.id;
tempObj.label = data.taskSeq + " " + data.name;
tempD.push(tempObj);
});
this.routingDetailList = tempD;
});
},
l(key) {
key = "routingsupporting" + "." + key;
return this.$t(key);
},
},
watch: {
v() {
this.entity = this.$u.clone(this.v);
},
eid(v) {
if (v > 0) {
this.load(v);
}
// this.entity.json.nameMaterial = e.name;
// this.entity.json.materialNumber = e.mmcode;
// this.forItem = v;
// },
loadDetails() {
//获取工序列表
let parms = {
headerID: this.headid,
};
ApiDetail.pagedDetails(parms).then((r) => {
let tempDetails = r.result;
let tempD = [];
tempDetails.forEach((data) => {
let tempObj = {};
tempObj.value = data.id;
tempObj.label = data.taskSeq + " " + data.name;
tempD.push(tempObj);
});
this.routingDetailList = tempD;
});
},
l(key) {
key = "routingsupporting" + "." + key;
return this.$t(key);
},
},
productBomId(v) {
if (v > 0) {
}
watch: {
v() {
this.entity = this.$u.clone(this.v);
},
eid(v) {
if (v > 0) {
this.load(v);
}
},
productBomId(v) {
if (v > 0) {}
},
},
},
};
</script>
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