|
@@ -42,11 +42,11 @@
|
|
|
</el-form-item>
|
|
|
<el-form-item label="系统售价" prop="new_sale_price">
|
|
|
<el-input
|
|
|
- placeholder="系统售价"
|
|
|
+ v-model="ruleForm.new_sale_price"
|
|
|
v-loading="search_loading"
|
|
|
+ placeholder="系统售价"
|
|
|
:disabled="true"
|
|
|
maxlength="20"
|
|
|
- v-model="ruleForm.new_sale_price"
|
|
|
>
|
|
|
<template slot="append">元</template>
|
|
|
</el-input>
|
|
@@ -84,8 +84,8 @@
|
|
|
|
|
|
<el-form-item label="对比平台" prop="market_platform">
|
|
|
<el-input
|
|
|
- placeholder="对比平台"
|
|
|
v-model="ruleForm.market_platform"
|
|
|
+ placeholder="对比平台"
|
|
|
maxlength="50"
|
|
|
/>
|
|
|
</el-form-item>
|
|
@@ -99,10 +99,13 @@
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="8" style="text-align: right">
|
|
|
- <el-button :size="'small'" type="primary" @click="submitForm"
|
|
|
- >保 存
|
|
|
+ <el-button
|
|
|
+ :size="'small'"
|
|
|
+ type="primary"
|
|
|
+ @click="submitForm"
|
|
|
+ >保 存
|
|
|
</el-button>
|
|
|
- <el-button @click="showModelThis = false" :size="'small'">{{
|
|
|
+ <el-button :size="'small'" @click="showModelThis = false">{{
|
|
|
"取 消"
|
|
|
}}</el-button>
|
|
|
</el-col>
|
|
@@ -114,50 +117,50 @@
|
|
|
</el-dialog>
|
|
|
</template>
|
|
|
<script>
|
|
|
-import resToken from "@/mixins/resToken";
|
|
|
-import asyncRequest from "@/apis/service/goodStore/goodsOnline";
|
|
|
+import resToken from '@/mixins/resToken'
|
|
|
+import asyncRequest from '@/apis/service/goodStore/goodsOnline'
|
|
|
export default {
|
|
|
- name: "brand",
|
|
|
- props: ["showModel", "index", "sitem", "spuCode"],
|
|
|
+ name: 'Brand',
|
|
|
mixins: [resToken],
|
|
|
+ props: ['showModel', 'index', 'sitem', 'spuCode'],
|
|
|
data() {
|
|
|
const validate_min_num = (rule, value, callback) => {
|
|
|
- if (value === "") {
|
|
|
- callback(new Error("起订量不能为空!"));
|
|
|
- } else if (value === "0") {
|
|
|
- callback(new Error("起订量不能为零!"));
|
|
|
+ if (value === '') {
|
|
|
+ callback(new Error('起订量不能为空!'))
|
|
|
+ } else if (value === '0') {
|
|
|
+ callback(new Error('起订量不能为零!'))
|
|
|
} else {
|
|
|
- callback();
|
|
|
+ callback()
|
|
|
}
|
|
|
- };
|
|
|
+ }
|
|
|
const validate_sale_price = (rule, value, callback) => {
|
|
|
- if (value === "") {
|
|
|
- callback(new Error("售价不能为空!"));
|
|
|
+ if (value === '') {
|
|
|
+ callback(new Error('售价不能为空!'))
|
|
|
} else {
|
|
|
- callback();
|
|
|
+ callback()
|
|
|
}
|
|
|
- };
|
|
|
+ }
|
|
|
const validate_market_price = (rule, value, callback) => {
|
|
|
- if (value === "") {
|
|
|
- callback(new Error("市场价不能为空!"));
|
|
|
+ if (value === '') {
|
|
|
+ callback(new Error('市场价不能为空!'))
|
|
|
} else {
|
|
|
- callback();
|
|
|
+ callback()
|
|
|
}
|
|
|
- };
|
|
|
+ }
|
|
|
return {
|
|
|
loading: false,
|
|
|
- title: "",
|
|
|
+ title: '',
|
|
|
showModelThis: this.showModel,
|
|
|
ruleForm: {
|
|
|
- id: "",
|
|
|
- index: "-1",
|
|
|
- min_num: "0",
|
|
|
- sale_price: "0",
|
|
|
- market_price: "0",
|
|
|
- market_platform: "",
|
|
|
- new_sale_price: "",
|
|
|
- status: "1",
|
|
|
- is_del: "0",
|
|
|
+ id: '',
|
|
|
+ index: '-1',
|
|
|
+ min_num: '0',
|
|
|
+ sale_price: '0',
|
|
|
+ market_price: '0',
|
|
|
+ market_platform: '',
|
|
|
+ new_sale_price: '',
|
|
|
+ status: '1',
|
|
|
+ is_del: '0'
|
|
|
},
|
|
|
rulesThis: this.rules,
|
|
|
search_loading: false,
|
|
@@ -166,68 +169,68 @@ export default {
|
|
|
{
|
|
|
required: true,
|
|
|
validator: validate_min_num,
|
|
|
- trigger: "blur",
|
|
|
- },
|
|
|
+ trigger: 'blur'
|
|
|
+ }
|
|
|
],
|
|
|
sale_price: [
|
|
|
{
|
|
|
required: true,
|
|
|
validator: validate_sale_price,
|
|
|
- trigger: "blur",
|
|
|
- },
|
|
|
+ trigger: 'blur'
|
|
|
+ }
|
|
|
],
|
|
|
market_price: [
|
|
|
{
|
|
|
required: true,
|
|
|
- type: "number",
|
|
|
+ type: 'number',
|
|
|
validator: validate_market_price,
|
|
|
- trigger: "blur",
|
|
|
- },
|
|
|
+ trigger: 'blur'
|
|
|
+ }
|
|
|
],
|
|
|
market_platform: [
|
|
|
- { required: true, message: "对比平台不能为空", trigger: "blur" },
|
|
|
+ { required: true, message: '对比平台不能为空', trigger: 'blur' }
|
|
|
],
|
|
|
status: [
|
|
|
- { required: true, message: "请选择使用状态", trigger: "change" },
|
|
|
- ],
|
|
|
- },
|
|
|
- };
|
|
|
+ { required: true, message: '请选择使用状态', trigger: 'change' }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
watch: {
|
|
|
- showModel: function (val) {
|
|
|
- this.showModelThis = val;
|
|
|
+ showModel: function(val) {
|
|
|
+ this.showModelThis = val
|
|
|
if (val) {
|
|
|
- this.initForm();
|
|
|
+ this.initForm()
|
|
|
}
|
|
|
},
|
|
|
showModelThis(val) {
|
|
|
if (!val) {
|
|
|
- this.$emit("cancel");
|
|
|
+ this.$emit('cancel')
|
|
|
}
|
|
|
- },
|
|
|
+ }
|
|
|
},
|
|
|
methods: {
|
|
|
async initForm() {
|
|
|
- this.loading = true;
|
|
|
- await this.resetForm();
|
|
|
- this.rulesThis = this.rules;
|
|
|
- if (this.index + "" === "-1") {
|
|
|
- this.title = "添加销售成本阶梯";
|
|
|
+ this.loading = true
|
|
|
+ await this.resetForm()
|
|
|
+ this.rulesThis = this.rules
|
|
|
+ if (this.index + '' === '-1') {
|
|
|
+ this.title = '添加销售成本阶梯'
|
|
|
} else {
|
|
|
- this.title = "修改销售成本阶梯";
|
|
|
+ this.title = '修改销售成本阶梯'
|
|
|
}
|
|
|
|
|
|
- this.loading = false;
|
|
|
+ this.loading = false
|
|
|
},
|
|
|
async resetForm() {
|
|
|
// 重置
|
|
|
- await this.$nextTick(async () => {
|
|
|
+ await this.$nextTick(async() => {
|
|
|
if (this.$refs.ruleForm) {
|
|
|
- this.$refs.ruleForm.resetFields();
|
|
|
- this.$refs.ruleForm.clearValidate();
|
|
|
- await this.resetFormData();
|
|
|
+ this.$refs.ruleForm.resetFields()
|
|
|
+ this.$refs.ruleForm.clearValidate()
|
|
|
+ await this.resetFormData()
|
|
|
}
|
|
|
- });
|
|
|
+ })
|
|
|
},
|
|
|
async resetFormData() {
|
|
|
const {
|
|
@@ -237,78 +240,78 @@ export default {
|
|
|
market_price,
|
|
|
market_platform,
|
|
|
status,
|
|
|
- is_del,
|
|
|
- } = this.sitem;
|
|
|
+ is_del
|
|
|
+ } = this.sitem
|
|
|
this.ruleForm = {
|
|
|
- id: id || "",
|
|
|
+ id: id || '',
|
|
|
index: this.index,
|
|
|
- min_num: min_num || "0",
|
|
|
- sale_price: sale_price || "0",
|
|
|
- market_price: market_price || "0",
|
|
|
- market_platform: market_platform || "",
|
|
|
- new_sale_price: "",
|
|
|
- status: status || "1",
|
|
|
- is_del: is_del || "0",
|
|
|
- };
|
|
|
- await this.get_new(this.ruleForm.min_num);
|
|
|
+ min_num: min_num || '0',
|
|
|
+ sale_price: sale_price || '0',
|
|
|
+ market_price: market_price || '0',
|
|
|
+ market_platform: market_platform || '',
|
|
|
+ new_sale_price: '',
|
|
|
+ status: status || '1',
|
|
|
+ is_del: is_del || '0'
|
|
|
+ }
|
|
|
+ await this.get_new(this.ruleForm.min_num)
|
|
|
},
|
|
|
|
|
|
async submitForm() {
|
|
|
- await this.$refs.ruleForm.validate(async (valid) => {
|
|
|
+ await this.$refs.ruleForm.validate(async(valid) => {
|
|
|
if (valid) {
|
|
|
- this.showModelThis = false;
|
|
|
+ this.showModelThis = false
|
|
|
// 刷新
|
|
|
- this.$emit("refresh", this.ruleForm);
|
|
|
+ this.$emit('refresh', this.ruleForm)
|
|
|
} else {
|
|
|
- console.log(this.ruleForm);
|
|
|
- console.log("error submit!!");
|
|
|
- return false;
|
|
|
+ console.log(this.ruleForm)
|
|
|
+ console.log('error submit!!')
|
|
|
+ return false
|
|
|
}
|
|
|
- });
|
|
|
+ })
|
|
|
},
|
|
|
async min_num_change(e) {
|
|
|
- this.ruleForm.min_num = e + "";
|
|
|
- this.$refs.ruleForm.validateField("min_num");
|
|
|
- await this.get_new(this.ruleForm.min_num);
|
|
|
+ this.ruleForm.min_num = e + ''
|
|
|
+ this.$refs.ruleForm.validateField('min_num')
|
|
|
+ await this.get_new(this.ruleForm.min_num)
|
|
|
},
|
|
|
async get_new(min_num) {
|
|
|
if (!this.search_loading) {
|
|
|
- if (min_num === "" || min_num === "0") {
|
|
|
- this.ruleForm.new_sale_price = "0";
|
|
|
+ if (min_num === '' || min_num === '0') {
|
|
|
+ this.ruleForm.new_sale_price = '0'
|
|
|
} else {
|
|
|
- this.search_loading = true;
|
|
|
- let { code, data, message } = await asyncRequest.goodupprice({
|
|
|
+ this.search_loading = true
|
|
|
+ const { code, data, message } = await asyncRequest.goodupprice({
|
|
|
min_num: min_num,
|
|
|
- spuCode: this.spuCode,
|
|
|
- });
|
|
|
- this.search_loading = false;
|
|
|
+ spuCode: this.spuCode
|
|
|
+ })
|
|
|
+ this.search_loading = false
|
|
|
if (code === 0) {
|
|
|
- const { sale_price } = data;
|
|
|
- this.ruleForm.new_sale_price = sale_price;
|
|
|
+ const { sale_price } = data
|
|
|
+ this.ruleForm.new_sale_price = sale_price
|
|
|
} else if (code >= 100 && code <= 104) {
|
|
|
- await this.logout();
|
|
|
+ await this.logout()
|
|
|
} else if (code == 1010) {
|
|
|
- this.ruleForm.new_sale_price = "0";
|
|
|
+ this.ruleForm.new_sale_price = '0'
|
|
|
} else {
|
|
|
- this.$message.warning(message);
|
|
|
+ this.$message.warning(message)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
sale_price_change(e) {
|
|
|
- this.ruleForm.sale_price = e;
|
|
|
- this.$refs.ruleForm.validateField("sale_price");
|
|
|
+ this.ruleForm.sale_price = e
|
|
|
+ this.$refs.ruleForm.validateField('sale_price')
|
|
|
},
|
|
|
market_price_change(e) {
|
|
|
- this.ruleForm.market_price = e;
|
|
|
- this.$refs.ruleForm.validateField("market_price");
|
|
|
+ this.ruleForm.market_price = e
|
|
|
+ this.$refs.ruleForm.validateField('market_price')
|
|
|
},
|
|
|
reschange(e) {
|
|
|
- this.ruleForm.price = e;
|
|
|
- this.$refs.ruleForm.validateField("price");
|
|
|
- },
|
|
|
- },
|
|
|
-};
|
|
|
+ this.ruleForm.price = e
|
|
|
+ this.$refs.ruleForm.validateField('price')
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|