|
@@ -1,7 +1,7 @@
|
|
|
<template>
|
|
|
<el-dialog
|
|
|
v-loading="loading"
|
|
|
- :title="'设置毛利率'"
|
|
|
+ :title="title"
|
|
|
:center="true"
|
|
|
align="left"
|
|
|
top="12vh"
|
|
@@ -24,6 +24,7 @@
|
|
|
:rules="rulesThis"
|
|
|
label-width="110px"
|
|
|
class="demo-ruleForm"
|
|
|
+ :disabled="isDetail"
|
|
|
>
|
|
|
<el-form-item label="分类名称" prop="cat_name">
|
|
|
<el-input
|
|
@@ -31,18 +32,22 @@
|
|
|
disabled
|
|
|
placeholder="分类名称"
|
|
|
maxlength="20"
|
|
|
- >
|
|
|
- <template slot="prepend" v-if="pid_name">
|
|
|
- {{ pid_name }}
|
|
|
- </template>
|
|
|
- </el-input>
|
|
|
+ ><template v-if="pid_name" slot="prepend">{{
|
|
|
+ pid_name
|
|
|
+ }}</template></el-input>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="财务核算码" prop="fund_code">
|
|
|
- <el-input
|
|
|
- v-model="ruleForm.fund_code"
|
|
|
- disabled
|
|
|
- placeholder="财务核算码"
|
|
|
- maxlength="50"
|
|
|
+ <el-form-item label="预算→成本" prop="order_rate">
|
|
|
+ <digital-input
|
|
|
+ :values="ruleForm.order_rate"
|
|
|
+ :placeholder="'预算→成本'"
|
|
|
+ :min="0"
|
|
|
+ :max="100000000000"
|
|
|
+ :position="'right'"
|
|
|
+ :precision="2"
|
|
|
+ :size="'mini'"
|
|
|
+ :controls="false"
|
|
|
+ :append="'%'"
|
|
|
+ @reschange="rate_change($event, 'order_rate')"
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="成本→售价" prop="sale_rate">
|
|
@@ -59,15 +64,58 @@
|
|
|
@reschange="rate_change($event, 'sale_rate')"
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="主管利率" prop="rate">
|
|
|
+ <digital-input
|
|
|
+ :values="ruleForm.rate"
|
|
|
+ :placeholder="'主管利率'"
|
|
|
+ :min="-100"
|
|
|
+ :max="100000000000"
|
|
|
+ :position="'right'"
|
|
|
+ :precision="2"
|
|
|
+ :size="'mini'"
|
|
|
+ :controls="false"
|
|
|
+ :append="'%'"
|
|
|
+ @reschange="rate_change($event, 'rate')"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="财务利率" prop="money_rate">
|
|
|
+ <digital-input
|
|
|
+ :values="ruleForm.money_rate"
|
|
|
+ :placeholder="'财务利率'"
|
|
|
+ :min="-100"
|
|
|
+ :max="100000000000"
|
|
|
+ :position="'right'"
|
|
|
+ :precision="2"
|
|
|
+ :size="'mini'"
|
|
|
+ :controls="false"
|
|
|
+ :append="'%'"
|
|
|
+ @reschange="rate_change($event, 'money_rate')"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="项目最低毛利" prop="low_rate">
|
|
|
+ <digital-input
|
|
|
+ :values="ruleForm.low_rate"
|
|
|
+ :placeholder="'项目最低毛利'"
|
|
|
+ :min="-100"
|
|
|
+ :max="100000000000"
|
|
|
+ :position="'right'"
|
|
|
+ :precision="2"
|
|
|
+ :size="'mini'"
|
|
|
+ :controls="false"
|
|
|
+ :append="'%'"
|
|
|
+ @reschange="rate_change($event, 'low_rate')"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
</el-form>
|
|
|
</el-col>
|
|
|
<el-col :span="24" style="text-align: right">
|
|
|
<el-button
|
|
|
- v-if="id !== '007'"
|
|
|
+ v-if="id !== '007' && !isDetail"
|
|
|
type="primary"
|
|
|
:size="'small'"
|
|
|
@click="submitForm"
|
|
|
- >保 存
|
|
|
+ >保 存
|
|
|
</el-button>
|
|
|
<el-button :size="'small'" @click="showModelThis = false">{{
|
|
|
id == "007" ? "关 闭" : "取 消"
|
|
@@ -77,123 +125,143 @@
|
|
|
</el-card>
|
|
|
</el-dialog>
|
|
|
</template>
|
|
|
+
|
|
|
<script>
|
|
|
-import asyncRequest from "@/apis/service/youzan/othsearchSort";
|
|
|
-import resToken from "@/mixins/resToken";
|
|
|
+import asyncRequest from '@/apis/service/goodStore/platformGrossProfit'
|
|
|
+import companyHelper from '@/mixins/companyHelper'
|
|
|
+import resToken from '@/mixins/resToken'
|
|
|
+
|
|
|
export default {
|
|
|
- name: "sort",
|
|
|
- props: ["showModel", "id", "sitem", "titleList"],
|
|
|
- mixins: [resToken],
|
|
|
+ name: 'Sort',
|
|
|
+ mixins: [resToken, companyHelper],
|
|
|
+ props: ['showModel', 'id', 'sitem', 'titleList', 'isDetail', 'platform_id'],
|
|
|
data() {
|
|
|
const validate_rate = (rule, value, callback) => {
|
|
|
- const { required } = rule;
|
|
|
- if (value === "" && required) {
|
|
|
- callback(new Error("主管利率毛利率不能为空!"));
|
|
|
+ const { required } = rule
|
|
|
+ if (value === '' && required) {
|
|
|
+ callback(new Error('主管利率毛利率不能为空!'))
|
|
|
} else {
|
|
|
- callback();
|
|
|
+ callback()
|
|
|
}
|
|
|
- };
|
|
|
+ }
|
|
|
const validate_order_rate = (rule, value, callback) => {
|
|
|
- const { required } = rule;
|
|
|
- if (value === "" && required) {
|
|
|
- callback(new Error("预算→成本毛利率不能为空!"));
|
|
|
+ const { required } = rule
|
|
|
+ if (value === '' && required) {
|
|
|
+ callback(new Error('预算→成本毛利率不能为空!'))
|
|
|
} else {
|
|
|
- callback();
|
|
|
+ callback()
|
|
|
}
|
|
|
- };
|
|
|
+ }
|
|
|
const validate_sale_rate = (rule, value, callback) => {
|
|
|
- const { required } = rule;
|
|
|
- if (value === "" && required) {
|
|
|
- callback(new Error("成本→售价毛利率不能为空!"));
|
|
|
+ const { required } = rule
|
|
|
+ if (value === '' && required) {
|
|
|
+ callback(new Error('成本→售价毛利率不能为空!'))
|
|
|
} else {
|
|
|
- callback();
|
|
|
+ callback()
|
|
|
}
|
|
|
- };
|
|
|
+ }
|
|
|
|
|
|
const validate_lower_rate = (rule, value, callback) => {
|
|
|
- const { required } = rule;
|
|
|
- if (value === "" && required) {
|
|
|
- callback(new Error("BOSS毛利率不能为空!"));
|
|
|
+ const { required } = rule
|
|
|
+ if (value === '' && required) {
|
|
|
+ callback(new Error('BOSS毛利率不能为空!'))
|
|
|
} else {
|
|
|
- callback();
|
|
|
+ callback()
|
|
|
}
|
|
|
- };
|
|
|
+ }
|
|
|
const validate_low_rate = (rule, value, callback) => {
|
|
|
- const { required } = rule;
|
|
|
- if (value === "" && required) {
|
|
|
- callback(new Error("项目最低毛利率不能为空!"));
|
|
|
+ const { required } = rule
|
|
|
+ if (value === '' && required) {
|
|
|
+ callback(new Error('项目最低毛利率不能为空!'))
|
|
|
} else {
|
|
|
- callback();
|
|
|
+ callback()
|
|
|
}
|
|
|
- };
|
|
|
+ }
|
|
|
const validate_money_rate = (rule, value, callback) => {
|
|
|
- const { required } = rule;
|
|
|
- if (value === "" && required) {
|
|
|
- callback(new Error("财务毛利率不能为空!"));
|
|
|
+ const { required } = rule
|
|
|
+ if (value === '' && required) {
|
|
|
+ callback(new Error('财务毛利率不能为空!'))
|
|
|
} else {
|
|
|
- callback();
|
|
|
+ callback()
|
|
|
}
|
|
|
- };
|
|
|
+ }
|
|
|
return {
|
|
|
loading: false,
|
|
|
showModelThis: this.showModel,
|
|
|
- pid_name: "",
|
|
|
+ pid_name: '',
|
|
|
ruleForm: {
|
|
|
- platform_id: "",
|
|
|
- cat_id: "",
|
|
|
- cat_name: "",
|
|
|
- order_rate: "0",
|
|
|
- sale_rate: "0",
|
|
|
- lower_rate: "0",
|
|
|
- rate: "0",
|
|
|
- low_rate: "0",
|
|
|
- money_rate: "0",
|
|
|
+ id: '',
|
|
|
+ cat_name: '',
|
|
|
+ order_rate: '0',
|
|
|
+ sale_rate: '0',
|
|
|
+ lower_rate: '0',
|
|
|
+ rate: '0',
|
|
|
+ low_rate: '0',
|
|
|
+ money_rate: '0'
|
|
|
},
|
|
|
rulesThis: this.rules,
|
|
|
rules: {
|
|
|
- order_rate: [{ required: true, validator: validate_order_rate, trigger: "blur" }],
|
|
|
- sale_rate: [{ required: true, validator: validate_sale_rate, trigger: "blur" }],
|
|
|
- lower_rate: [{ required: false, validator: validate_lower_rate, trigger: "blur" }],
|
|
|
- rate: [{ required: true, validator: validate_rate, trigger: "blur" }],
|
|
|
- low_rate: [{ required: true, validator: validate_low_rate, trigger: "blur" }],
|
|
|
- money_rate: [{ required: true, validator: validate_money_rate, trigger: "blur" }],
|
|
|
- },
|
|
|
- };
|
|
|
+ order_rate: [
|
|
|
+ { required: true, validator: validate_order_rate, trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ sale_rate: [
|
|
|
+ { required: true, validator: validate_sale_rate, trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ lower_rate: [
|
|
|
+ { required: false, validator: validate_lower_rate, trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ rate: [{ required: true, validator: validate_rate, trigger: 'blur' }],
|
|
|
+ low_rate: [
|
|
|
+ { required: true, validator: validate_low_rate, trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ money_rate: [
|
|
|
+ { required: true, validator: validate_money_rate, trigger: 'blur' }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ title() {
|
|
|
+ const base = '毛利率'
|
|
|
+ const prefix = this.isDetail ? '查看' : '设置'
|
|
|
+ return prefix + base
|
|
|
+ }
|
|
|
},
|
|
|
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;
|
|
|
- this.pid_name = "";
|
|
|
+ this.loading = true
|
|
|
+ this.pid_name = ''
|
|
|
this.titleList.forEach((e, i) => {
|
|
|
- this.pid_name += i !== 0 ? `${e.titleName}/` : "";
|
|
|
- });
|
|
|
- this.rulesThis = this.rules;
|
|
|
- await this.resetForm();
|
|
|
- this.loading = false;
|
|
|
+ this.pid_name += i !== 0 ? `${e.titleName}/` : ''
|
|
|
+ })
|
|
|
+ this.rulesThis = this.rules
|
|
|
+ await this.resetForm()
|
|
|
+ this.loading = false
|
|
|
},
|
|
|
|
|
|
async resetForm() {
|
|
|
// 重置
|
|
|
await this.$nextTick(() => {
|
|
|
if (this.$refs.ruleForm) {
|
|
|
- this.$refs.ruleForm.resetFields();
|
|
|
- this.$refs.ruleForm.clearValidate();
|
|
|
+ this.$refs.ruleForm.resetFields()
|
|
|
+ this.$refs.ruleForm.clearValidate()
|
|
|
+
|
|
|
const {
|
|
|
- platform_id,
|
|
|
- id,
|
|
|
+ pid,
|
|
|
+ cat_id,
|
|
|
cat_name,
|
|
|
order_rate,
|
|
|
sale_rate,
|
|
@@ -201,77 +269,110 @@ export default {
|
|
|
rate,
|
|
|
fund_code,
|
|
|
low_rate,
|
|
|
- money_rate,
|
|
|
- } = this.sitem;
|
|
|
+ money_rate
|
|
|
+ } = this.sitem
|
|
|
+
|
|
|
this.ruleForm = {
|
|
|
- platform_id: platform_id + "" || "",
|
|
|
- cat_id: id || "",
|
|
|
- cat_name: cat_name || "",
|
|
|
- fund_code: fund_code || "",
|
|
|
- order_rate: order_rate || "0",
|
|
|
- sale_rate: sale_rate || "0",
|
|
|
- lower_rate: lower_rate || "0",
|
|
|
- rate: rate || "0",
|
|
|
- low_rate: low_rate || "0",
|
|
|
- money_rate: money_rate || "0",
|
|
|
- };
|
|
|
+ pid: pid || '',
|
|
|
+ cat_id: cat_id || '',
|
|
|
+ cat_name: cat_name || '',
|
|
|
+ fund_code: fund_code || '',
|
|
|
+ order_rate: order_rate || '0',
|
|
|
+ sale_rate: sale_rate || '0',
|
|
|
+ lower_rate: lower_rate || '0',
|
|
|
+ rate: rate || '0',
|
|
|
+ low_rate: low_rate || '0',
|
|
|
+ money_rate: money_rate || '0',
|
|
|
+ platform_id: this.platform_id || ''
|
|
|
+ }
|
|
|
}
|
|
|
- });
|
|
|
+ })
|
|
|
},
|
|
|
+
|
|
|
rate_change(e, key) {
|
|
|
- this.ruleForm[key] = e + "";
|
|
|
- this.$refs.ruleForm.validateField(key);
|
|
|
+ this.ruleForm[key] = e + ''
|
|
|
+ this.$refs.ruleForm.validateField(key)
|
|
|
+ },
|
|
|
+
|
|
|
+ async changeStatus(cat_id, status) {
|
|
|
+ await this.$confirm(`确定要改为${status + '' === '1' ? '禁用' : '启用'}?`, {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ })
|
|
|
+ .then(async() => {
|
|
|
+ this.loading = true
|
|
|
+
|
|
|
+ console.log(status + '' === '1' ? '0' : '1')
|
|
|
+
|
|
|
+ const model = {
|
|
|
+ cat_id,
|
|
|
+ platform_id: this.pa,
|
|
|
+ status: status + '' === '1' ? '0' : '1',
|
|
|
+ companyNo: this.currentCompany
|
|
|
+ }
|
|
|
+
|
|
|
+ const res = await asyncRequest.status(model)
|
|
|
+ if (res && res.code === 0) {
|
|
|
+ this.loading = false
|
|
|
+
|
|
|
+ this.$notify.success({
|
|
|
+ title: '状态修改成功!',
|
|
|
+ message: ''
|
|
|
+ })
|
|
|
+
|
|
|
+ await this.searchList()
|
|
|
+ } else if (res && res.code >= 100 && res.code <= 104) {
|
|
|
+ await this.logout()
|
|
|
+ } else {
|
|
|
+ this.loading = false
|
|
|
+ this.$message.warning(res.message)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ console.log('取消')
|
|
|
+ })
|
|
|
},
|
|
|
+
|
|
|
async submitForm() {
|
|
|
- await this.$refs.ruleForm.validate(async (valid) => {
|
|
|
+ if (!this.isHasCurrentCompany()) return
|
|
|
+
|
|
|
+ await this.$refs.ruleForm.validate(async(valid) => {
|
|
|
if (valid) {
|
|
|
if (!this.loading) {
|
|
|
- this.loading = true;
|
|
|
- let model = JSON.parse(JSON.stringify(this.ruleForm));
|
|
|
- delete model["cat_name"];
|
|
|
- // delete model["pid"];
|
|
|
- // delete model["fund_code"];
|
|
|
- const { code, data, message } = await asyncRequest.update(model);
|
|
|
- this.loading = false;
|
|
|
- if (code === 0) {
|
|
|
+ this.loading = true
|
|
|
+ const model = JSON.parse(JSON.stringify(this.ruleForm))
|
|
|
+ model.companyNo = this.currentCompany
|
|
|
+ delete model['cat_name']
|
|
|
+ delete model['pid']
|
|
|
+ delete model['fund_code']
|
|
|
+ const res = await asyncRequest.setSpcp(model)
|
|
|
+ this.loading = false
|
|
|
+ if (res && res.code === 0) {
|
|
|
this.$notify.success({
|
|
|
- title: "毛利率设置成功!",
|
|
|
- message: "",
|
|
|
- });
|
|
|
- this.showModelThis = false;
|
|
|
+ title: '毛利率设置成功!',
|
|
|
+ message: ''
|
|
|
+ })
|
|
|
+ this.showModelThis = false
|
|
|
// 刷新
|
|
|
- this.$emit("refresh");
|
|
|
- } else if (code >= 100 && code <= 104) {
|
|
|
- await this.logout();
|
|
|
- } else if (code === 10004) {
|
|
|
- const { skuCode } = data;
|
|
|
- let resList = JSON.parse(JSON.stringify(skuCode));
|
|
|
-
|
|
|
- let htmlList = "<ul>";
|
|
|
- resList.forEach((v) => {
|
|
|
- htmlList += `<li><span>${v.skuCode}__</span><span>${v.good_name}</span></li>`;
|
|
|
- });
|
|
|
- htmlList += "</ul>";
|
|
|
- this.$notify({
|
|
|
- title: "新毛利已影响以下线上商品售价,请下线后再修改!",
|
|
|
- dangerouslyUseHTMLString: true,
|
|
|
- message: htmlList,
|
|
|
- });
|
|
|
+ this.$emit('refresh')
|
|
|
+ } else if (res && res.code >= 100 && res.code <= 104) {
|
|
|
+ await this.logout()
|
|
|
} else {
|
|
|
- this.$message.warning(message);
|
|
|
+ this.$message.warning(res.message)
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- console.log("error submit!!");
|
|
|
- return false;
|
|
|
+ console.log('error submit!!')
|
|
|
+ return false
|
|
|
}
|
|
|
- });
|
|
|
- },
|
|
|
- },
|
|
|
-};
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
-<style lang="scss" scoped>
|
|
|
+ <style lang="scss" scoped>
|
|
|
.sort {
|
|
|
}
|
|
|
</style>
|