Files
refinery-admin/src/views/product/components/adjust.vue
xiaozhiyong a28edee556 更新
2023-03-09 11:51:18 +08:00

102 lines
2.6 KiB
Vue

<template>
<el-dialog
title="调价"
:visible.sync="controlWindows.adjust"
width="30%"
:before-close="closeWindow"
@opened="openDrawer"
>
<div class="adjust">
<el-form ref="form" :rules="rules" :model="form" label-width="120px">
<el-form-item label="成本价" prop="floorPrice">
<el-input
maxlength="50"
v-checkNum
v-model="form.floorPrice"
placeholder="请输入成本价"
></el-input>
</el-form-item>
<el-form-item label="企业销售价" prop="salePrice2company">
<el-input
maxlength="50"
v-checkNum
v-model="form.salePrice2company"
placeholder="请输入企业销售价"
></el-input>
</el-form-item>
</el-form>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="closeWindow"> </el-button>
<el-button type="primary" @click="submit"> </el-button>
</span>
</el-dialog>
</template>
<script>
import serve from "api/product.js";
export default {
props: {
controlWindows: Object,
},
data() {
let validatorFloorPrice = (rule, value, callback) => {
if (!value || !+value) return callback("成本价价不能为0或空");
callback();
};
let validatorSalePrice2company = (rule, value, callback) => {
if (!value || !+value) return callback("企业销售价不能为0或空");
if (+value < this.form.floorPrice)
return callback("企业销售价不能低于成本价");
callback();
};
return {
form: {},
rules: {
floorPrice: [
{ required: true, validator: validatorFloorPrice, trigger: "change" },
],
salePrice2company: [
{
required: true,
validator: validatorSalePrice2company,
trigger: "change",
},
],
},
};
},
methods: {
openDrawer() {},
submit() {
this.$refs["form"].validate((valid) => {
if (valid) {
Object.assign(this.form, this.controlWindows.addInfo);
serve.modifyPrice(this.form).then((res) => {
this.$message.success(res.msg);
this.closeWindow();
});
}
});
},
closeWindow() {
this.$emit("closeWindow");
this.form = {};
this.$nextTick(() => {
this.$refs.form.clearValidate();
this.controlWindows.adjust = false;
});
},
},
};
</script>
<style lang="scss" scoped>
.adjust {
.el-input {
width: 200px;
}
}
</style>