油批
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

315 lines
8.6 KiB

2 years ago
<template>
<el-drawer
2 years ago
:title="controlWindows.addInfo.title"
2 years ago
direction="ltr"
2 years ago
size="40%"
:visible="controlWindows.create"
@opened="openDrawer"
:before-close="closeWindow"
>
2 years ago
<div class="create" v-if="controlWindows.create">
2 years ago
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
2 years ago
<el-form-item label="客户名称" prop="customerId">
<el-select v-model="form.customerId" reserve-keyword remote :remote-method="customData" filterable placeholder="请选择客户">
2 years ago
<el-option
v-for="(item, index) in customList"
:key="index"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
<!-- <el-input
2 years ago
maxlength="50"
v-model="form.productName"
placeholder="请输入客户名称"
2 years ago
></el-input> -->
2 years ago
</el-form-item>
<el-form-item label="炼厂名称" prop="refineryId">
2 years ago
<!-- <el-autocomplete
label
v-model="form.refineryId"
:fetch-suggestions="querySearchAsync"
value-key="refineryName"
value="id"
placeholder="炼厂名称"
></el-autocomplete> -->
<autocomplete :params="form" :config="configAutocomplete" />
2 years ago
</el-form-item>
<el-form-item label="产品类型" prop="productType">
2 years ago
<el-select v-model="form.productType" @change="productChange" placeholder="请选择产品类型">
2 years ago
<el-option
v-for="(item, index) in productTypeList"
:key="index"
:label="item.label"
:value="item.value"
></el-option>
</el-select>
</el-form-item>
2 years ago
<el-form-item label="产品名称" prop="productId">
<el-select v-model="form.productId" @change="productDataList" placeholder="请选择产品类型">
2 years ago
<el-option
v-for="(item, index) in productNameList"
:key="index"
:label="item.productName"
:value="item.id"
></el-option>
</el-select>
<!-- <el-input
2 years ago
maxlength="50"
v-model="form.productName"
placeholder="请输入产品名称"
2 years ago
></el-input> -->
2 years ago
</el-form-item>
2 years ago
<el-form-item label="销售价">
2 years ago
<el-input
maxlength="50"
2 years ago
v-model="form.salePrice"
2 years ago
placeholder="请输入销售价"
2 years ago
disabled
2 years ago
></el-input>
/
</el-form-item>
2 years ago
<el-form-item label="预约提货量">
2 years ago
<el-input
maxlength="50"
2 years ago
v-model="form.preQuantity"
2 years ago
placeholder="请输入预约提货量"
></el-input>
</el-form-item>
2 years ago
<el-form-item label="订单金额">
<el-input
maxlength="50"
2 years ago
v-model="form.preAmount"
2 years ago
disabled
></el-input>
2 years ago
2 years ago
</el-form-item>
2 years ago
</el-form>
</div>
<div class="buttons">
<el-button @click="controlWindows.create = false">取消 </el-button>
<el-button @click="submit">确定</el-button>
</div>
</el-drawer>
</template>
<script>
import serve from "api/product.js";
2 years ago
import refineryInfoServe from "api/refineryInfo.js";
import autocomplete from "components/autocomplete/index.vue";
2 years ago
export default {
2 years ago
components: {
autocomplete,
},
2 years ago
props: {
controlWindows: Object,
// refineryTypeEnum: Array,
},
2 years ago
watch:{
"form.salePrice": {
handler(n, o) {
if(n){
2 years ago
this.form.preAmount = this.form.salePrice*(this.form.preQuantity?this.form.preQuantity:0)
2 years ago
}
},
},
"form.preQuantity": {
handler(n, o) {
if(n){
2 years ago
this.form.preAmount = this.form.preQuantity*(this.form.salePrice?this.form.salePrice:0)
2 years ago
}
},
}
},
2 years ago
data() {
2 years ago
let validatorRefineryId = (rule, value, callback) => {
if (this.form.refineryId) callback();
else callback("请选择炼厂");
};
2 years ago
return {
2 years ago
customList:[],
2 years ago
form: {
2 years ago
preAmount:0
2 years ago
},
productNameList:[],
2 years ago
refineryList: [],
2 years ago
productRowData:{},
2 years ago
configAutocomplete: {
serveTarget: refineryInfoServe.findByEntity,
2 years ago
autocompleteKey: "refineryName",
labelKey: "refineryName",
valueKey: "id",
2 years ago
placeholder: "炼厂名称",
querykey: "refineryId",
2 years ago
echoId: "",
echoName: "",
2 years ago
},
2 years ago
productTypeList: [
{
label: "0#柴",
value: "0#",
},
{
label: "-10#柴",
value: "-10#",
},
{
label: "92#汽",
value: "92#",
},
{
label: "95#汽",
value: "95#",
},
],
rules: {
2 years ago
customerId: [
{ required: true, message: "请输入客户名称", trigger: "blur" },
],
productId: [
{ required: true, message: "请输入产品名称", trigger: "change" },
2 years ago
],
refineryId: [
2 years ago
{ required: true, validator: validatorRefineryId, trigger: "change" },
2 years ago
],
enableMark: [
2 years ago
{ required: true, message: "请选择启用状态", trigger: "change" },
2 years ago
],
productType: [
2 years ago
{ required: true, message: "请选择产品类型", trigger: "change" },
2 years ago
],
},
};
},
methods: {
2 years ago
productDataList(e){
this.productRowData = this.productNameList.filter(
(item) => item.id == e
);
this.form.salePrice = this.productRowData[0].salePrice2company
this.form.floorPrice = this.productRowData[0].floorPrice
this.form.productMeasurement = this.productRowData[0].measurement
console.log(this.productRowData,'sssssssdddddddddddddd')
},
2 years ago
productChange(){
this.productData()
},
2 years ago
//搜索炼厂
refineryData(value){
if (value) {
serve.findByEntity({refineryName:value}).then((res) => {
this.refineryList = res.data;
});
2 years ago
this.productData()
2 years ago
}
},
//搜索产品
2 years ago
productData(){
let data = {
refineryId:this.form.refineryId,
productType:this.form.productType,
enableMark:'ENABLE'
2 years ago
}
2 years ago
serve.getRefineryProductList(data).then((res) => {
this.productNameList = res.data;
})
2 years ago
},
//搜索客户
customData(value){
if (value) {
serve.getRefineryCompanyList({name:value}).then((res) => {
this.customList = res.data;
});
}
},
2 years ago
openDrawer() {
let { id } = this.controlWindows.addInfo;
if (id) {
//回显
this.form = JSON.parse(JSON.stringify(this.controlWindows.addInfo));
this.configAutocomplete.echoId = id;
this.configAutocomplete.echoName = this.form.refineryName;
console.log("this.form", this.form.floorPrice);
}
},
2 years ago
submit() {
this.$refs["form"].validate((valid) => {
if (valid) {
2 years ago
2 years ago
this.judgeInterface(this.form).then((res) => {
if (res.code === 20000) {
this.$message.success(res.msg);
this.closeWindow();
}
});
}
});
},
judgeInterface(form) {
2 years ago
// let { id } = this.controlWindows.addInfo;
// if (id) return serve.update(form);
// else
return serve.orderSave(form);
2 years ago
},
//炼厂list
2 years ago
// findByEntity() {
// refineryServe.findByEntity().then((res) => {
// this.refineryList = res.data;
// });
// },
2 years ago
// 远程搜索
// querySearchAsync(queryString, cb) {
// if (queryString) {
// refineryServe
// .findByEntity({ refineryName: queryString })
// .then((res) => {
// let timeInstance = setTimeout(() => {
// clearTimeout(timeInstance);
// if (res.data.length) {
// cb(res.data);
// } else cb([]);
// }, 1000 * Math.random());
// });
// } else cb([]);
// },
2 years ago
closeWindow() {
this.$emit("closeWindow");
this.form = {};
2 years ago
this.$refs.form.clearValidate();
2 years ago
this.controlWindows.create = false;
},
},
};
</script>
<style lang="scss" scoped>
.create {
padding: 20px;
.el-input,
.el-select,
2 years ago
.el-textarea,
.el-autocomplete {
2 years ago
width: 300px;
}
}
.buttons {
position: absolute;
left: 0;
bottom: 0;
padding-right: 40px;
width: 100%;
height: 80px;
line-height: 80px;
text-align: right;
border-top: 1px solid #f2f3f5;
.el-button {
text-align: right;
font-size: 14px;
border-radius: 5px;
}
}
</style>