184 lines
4.7 KiB
Plaintext
184 lines
4.7 KiB
Plaintext
<template>
|
|
<div class="app-container" style="width: 100%">
|
|
<el-form
|
|
ref="formData"
|
|
:rules="rules"
|
|
label-width="120px"
|
|
:model="formData"
|
|
>
|
|
<el-row>
|
|
<el-col :span="12">
|
|
<el-form-item prop="locationCode" label="库位代码">
|
|
<el-input style="width: 230px" v-model="formData.locationCode">
|
|
</el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :span="12">
|
|
<el-form-item label="库位名称">
|
|
<el-input
|
|
style="width: 230px"
|
|
v-model="formData.locationName"
|
|
></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
|
|
<el-row>
|
|
<el-col :span="12">
|
|
<el-form-item label="库位类型">
|
|
<el-select
|
|
style="width: 230px"
|
|
v-model="formData.dictType"
|
|
placeholder="请选择"
|
|
>
|
|
<el-option
|
|
v-for="item in this.$dictType.getLocationTypeArray()"
|
|
:key="item.key"
|
|
:label="item.text"
|
|
:value="item.key"
|
|
>
|
|
</el-option>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :span="12">
|
|
<el-form-item label="库区名称">
|
|
<el-input style="width: 230px" v-model="formData.warehouseName">
|
|
<i
|
|
slot="suffix"
|
|
class="el-icon-search"
|
|
@click.prevent="selectWarehouse"
|
|
></i>
|
|
</el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
|
|
<el-col :span="24">
|
|
<el-form-item style="float: right; margin-right: 20px">
|
|
<el-button type="primary" @click="save">确 定</el-button>
|
|
<el-button @click="goback">取 消</el-button>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-form>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import selectWarehouse from "@/views/mes/BasicData/warehouse/select-warehouse.vue";
|
|
export default {
|
|
props: {
|
|
layerid: {
|
|
type: String,
|
|
default: "",
|
|
},
|
|
lydata: {
|
|
type: Object,
|
|
default: () => {
|
|
return {};
|
|
},
|
|
},
|
|
},
|
|
name: "edit",
|
|
data() {
|
|
return {
|
|
formData: {},
|
|
normalizer(node) {
|
|
return {
|
|
id: node.value,
|
|
label: node.title,
|
|
children: node.children,
|
|
isDefaultExpanded: true,
|
|
};
|
|
},
|
|
treeOptions: [],
|
|
rules: {
|
|
locationCode: [
|
|
{ required: true, message: "请输入库位代码", trigger: "blur" },
|
|
],
|
|
},
|
|
};
|
|
},
|
|
mounted() {
|
|
if (!this.$parent.isAdd) {
|
|
console.log(JSON.parse(JSON.stringify(this.lydata)));
|
|
this.formData = JSON.parse(JSON.stringify(this.lydata));
|
|
} else {
|
|
this.formData = {
|
|
dictType: 1,
|
|
warehouseName: null,
|
|
warehouseCode: null,
|
|
};
|
|
}
|
|
},
|
|
methods: {
|
|
getWarehouse(row) {
|
|
this.formData.warehouseId = row.id;
|
|
this.formData.warehouseCode = row.warehouseCode;
|
|
this.formData.warehouseName = row.warehouseName;
|
|
},
|
|
|
|
selectWarehouse() {
|
|
this.$layer.iframe({
|
|
shadeClose: false,
|
|
content: {
|
|
content: selectWarehouse, //传递的组件对象
|
|
parent: this, //当前的vue对象
|
|
shadeClose: false,
|
|
},
|
|
title: "选择库区",
|
|
});
|
|
},
|
|
|
|
save() {
|
|
this.$refs["formData"].validate((valid) => {
|
|
if (valid) {
|
|
if (this.$parent.isAdd) {
|
|
this.$location.addLocation(this.formData).then((data) => {
|
|
if (data.data.code === 200) {
|
|
this.$message({
|
|
message: "保存成功",
|
|
type: "success",
|
|
});
|
|
this.$parent.getLocation();
|
|
this.$layer.close(this.layerid);
|
|
} else {
|
|
this.$message({
|
|
message: data.data.msg,
|
|
type: "error",
|
|
});
|
|
}
|
|
});
|
|
} else {
|
|
this.$location.updateLocation(this.formData).then((data) => {
|
|
if (data.data.code === 200) {
|
|
this.$message({
|
|
message: "保存成功",
|
|
type: "success",
|
|
});
|
|
this.$parent.getLocation();
|
|
this.$layer.close(this.layerid);
|
|
} else {
|
|
this.$message({
|
|
message: data.data.msg,
|
|
type: "error",
|
|
});
|
|
}
|
|
});
|
|
}
|
|
} else {
|
|
console.log("error submit!!");
|
|
}
|
|
});
|
|
},
|
|
|
|
goback() {
|
|
this.$layer.close(this.layerid);
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<style scoped>
|
|
</style>
|