|
@@ -32,10 +32,9 @@
|
|
|
disabled
|
|
|
placeholder="分类名称"
|
|
|
maxlength="20"
|
|
|
- ><template v-if="pid_name" slot="prepend">{{
|
|
|
- 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
|
|
@@ -124,7 +123,7 @@
|
|
|
type="primary"
|
|
|
:size="'small'"
|
|
|
@click="submitForm"
|
|
|
- >保 存
|
|
|
+ >保 存
|
|
|
</el-button>
|
|
|
<el-button :size="'small'" @click="showModelThis = false">{{
|
|
|
id == "007" ? "关 闭" : "取 消"
|
|
@@ -136,129 +135,129 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import asyncRequest from "@/apis/service/serviceParam/grossProfit";
|
|
|
-import companyHelper from "@/mixins/companyHelper";
|
|
|
-import resToken from "@/mixins/resToken";
|
|
|
+import asyncRequest from '@/apis/service/serviceParam/grossProfit'
|
|
|
+import companyHelper from '@/mixins/companyHelper'
|
|
|
+import resToken from '@/mixins/resToken'
|
|
|
|
|
|
export default {
|
|
|
- name: "Sort",
|
|
|
+ name: 'Sort',
|
|
|
mixins: [resToken, companyHelper],
|
|
|
- props: ["showModel", "id", "sitem", "titleList", "isDetail"],
|
|
|
+ props: ['showModel', 'id', 'sitem', 'titleList', 'isDetail'],
|
|
|
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: {
|
|
|
- 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" }],
|
|
|
+ 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" },
|
|
|
+ { 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" }],
|
|
|
- },
|
|
|
- };
|
|
|
+ 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;
|
|
|
- },
|
|
|
+ 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 {
|
|
|
pid,
|
|
@@ -270,65 +269,65 @@ export default {
|
|
|
rate,
|
|
|
fund_code,
|
|
|
low_rate,
|
|
|
- money_rate,
|
|
|
- } = this.sitem;
|
|
|
+ money_rate
|
|
|
+ } = this.sitem
|
|
|
|
|
|
this.ruleForm = {
|
|
|
- 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",
|
|
|
- };
|
|
|
+ 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'
|
|
|
+ }
|
|
|
}
|
|
|
- });
|
|
|
+ })
|
|
|
},
|
|
|
rate_change(e, key) {
|
|
|
- this.ruleForm[key] = e + "";
|
|
|
- this.$refs.ruleForm.validateField(key);
|
|
|
+ this.ruleForm[key] = e + ''
|
|
|
+ this.$refs.ruleForm.validateField(key)
|
|
|
},
|
|
|
|
|
|
async submitForm() {
|
|
|
- if (!this.isHasCurrentCompany()) return;
|
|
|
+ if (!this.isHasCurrentCompany()) return
|
|
|
|
|
|
- await this.$refs.ruleForm.validate(async (valid) => {
|
|
|
+ await this.$refs.ruleForm.validate(async(valid) => {
|
|
|
if (valid) {
|
|
|
if (!this.loading) {
|
|
|
- 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.editRate(model);
|
|
|
- this.loading = false;
|
|
|
+ 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.editRate(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");
|
|
|
+ this.$emit('refresh')
|
|
|
} else if (res && res.code >= 100 && res.code <= 104) {
|
|
|
- await this.logout();
|
|
|
+ await this.logout()
|
|
|
} else {
|
|
|
- this.$message.warning(res.message);
|
|
|
+ this.$message.warning(res.message)
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- console.log("error submit!!");
|
|
|
- return false;
|
|
|
+ console.log('error submit!!')
|
|
|
+ return false
|
|
|
}
|
|
|
- });
|
|
|
- },
|
|
|
- },
|
|
|
-};
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|