Commit fbea7697 by Kyle_Li

update: 编辑指标

parent d1a80ec2
......@@ -3,12 +3,15 @@
<div class="target-box" v-for="item in tableData" :key="item.num">
<header>{{ item.head }}</header>
<div :class="{ content: true, red: isTrue(item) }">
<span v-if="isBatch && !isTrue(item)">无需设置</span>
<span v-if="isBatch && isPreMonth(item) && isLastThree(item.num)">无需设置</span>
<el-input-number
v-else
v-model="item.val"
:controls="false"
placeholder="请输入"
:precision="isPrecision ? 2 : 0"
:min="0"
:max="99999999"
@change="$emit('change', tableData)"
:disabled="item.disabled">
</el-input-number>
......@@ -18,38 +21,44 @@
</template>
<script>
const defaultV = [ // 默认值
{ head: '一月', num: '01', val: undefined, disabled: false },
{ head: '二月', num: '02', val: undefined, disabled: false },
{ head: '三月', num: '03', val: undefined, disabled: false },
{ head: '四月', num: '04', val: undefined, disabled: false },
{ head: '五月', num: '05', val: undefined, disabled: false },
{ head: '六月', num: '06', val: undefined, disabled: false },
{ head: '七月', num: '07', val: undefined, disabled: false },
{ head: '八月', num: '08', val: undefined, disabled: false },
{ head: '九月', num: '09', val: undefined, disabled: false },
{ head: '十月', num: '10', val: undefined, disabled: false },
{ head: '十一月', num: '11', val: undefined, disabled: false },
{ head: '十二月', num: '12', val: undefined, disabled: false },
];
export default {
name: 'MonthTarget',
props: {
data: {
data: { // 回显数据
type: Object,
default: () => []
},
year: {
type: [ String, Number ],
default: '2020'
default: ''
},
isBatch: { // 批量
type: Boolean,
default: false
},
isBatch: {
isPrecision: { // 小数点
type: Boolean,
default: false
}
},
data() {
return {
tableData: [
{ head: '一月', num: '01', val: 0, disabled: false },
{ head: '二月', num: '02', val: 0, disabled: false },
{ head: '三月', num: '03', val: 0, disabled: false },
{ head: '四月', num: '04', val: 0, disabled: false },
{ head: '五月', num: '05', val: 0, disabled: false },
{ head: '六月', num: '06', val: 0, disabled: false },
{ head: '七月', num: '07', val: 0, disabled: false },
{ head: '八月', num: '08', val: 0, disabled: false },
{ head: '九月', num: '09', val: 0, disabled: false },
{ head: '十月', num: '10', val: 0, disabled: false },
{ head: '十一月', num: '11', val: 0, disabled: false },
{ head: '十二月', num: '12', val: 0, disabled: false },
],
tableData: JSON.parse(JSON.stringify(defaultV)),
thisYear: new Date().getFullYear(),
month: new Date().getMonth()
};
......@@ -58,19 +67,35 @@ export default {
this.$emit('change', this.tableData);
},
methods: {
validate() {
// eslint-disable-next-line
return this.tableData.some(item => this.isAllNot ? false : (this.isAllRed || this.month < item.num) && !item.val);
validate() { // 验证
return this.tableData.some(item => this.isTrue(item));
},
isTrue(item) { // 非之前年份,非月末三天,大于等于当月 必填
if (this.isAllNot || this.isLastThree(item.num)) return false;
if ((this.isAllRed || this.month < item.num) && (item.val === undefined)) return true;
// return this.isAllNot || this.isLastThree(item.num) ? false : (this.isAllRed || this.month < item.num) && (item.val === undefined);
},
isPreMonth(item) { // 是否是之前的月份
if (this.isAllNot) return true;
if (this.isAllRed) return false;
return !(this.month < item.num);
// return !(this.isAllNot ? false : this.isAllRed || this.month < item.num);
},
clear() { // 还原默认值
this.tableData = JSON.parse(JSON.stringify(defaultV));
this.$emit('change', this.tableData);
},
isTrue(item) {
return this.isAllNot ? false : (this.isAllRed || this.month < item.num) && !item.val;
isLastThree(month) { // 是否为当月最后三天
if (this.year != this.thisYear) return false;
let days = new Date(this.year, month, 0).getDate(); // 天数
return days - 3 < new Date().getDate();
}
},
computed: {
isAllRed() {
isAllRed() { // 未来
return this.year > this.thisYear;
},
isAllNot() {
isAllNot() { // 之前的年份
return this.year < this.thisYear;
},
},
......@@ -80,12 +105,14 @@ export default {
newV.forEach(item => {
const { performanceYm, performanceValue } = item;
let month = performanceYm.split('-')[1] - 1;
let table = this.tableData[month];
table.val = performanceValue || 0;
let month = performanceYm.split('-')[1];
let table = this.tableData[month - 1];
table.val = !performanceValue && performanceValue != 0 ? undefined : performanceValue;
// 以前的月份,有数据不能编辑
if (performanceValue && !(this.isAllNot ? false : (this.isAllRed || this.month < table.num))) table.disabled = true;
if ((performanceValue || performanceValue == 0) && this.isPreMonth(table)) table.disabled = true;
// 当月最后三天不能修改当月数据
if (this.isLastThree(month)) table.disabled = true;
});
}
}
......
......@@ -104,7 +104,7 @@
</el-table-column>
<el-table-column label="年业绩指标" show-overflow-tooltip>
<template slot-scope="{row}">
{{ row.performanceYearValue ? `¥${row.performanceYearValue}` : '未设置' }}
{{ row.performaneceYearValue ? `¥${row.performaneceYearValue}` : '未设置' }}
</template>
</el-table-column>
<el-table-column label="年新增会员指标" show-overflow-tooltip>
......@@ -141,8 +141,11 @@
tab: activeName,
storeInfoId: row.storeInfoId,
storeName: row.storeName,
storeEdit: row.storeEdit,
edit: '1',
year: search.performanceYear
year: search.performanceYear,
performanceFlag: search1.noPerformanceFlag,
addMemberFlag: search1.noAddMemberFlag
}
})">
编辑
......@@ -222,7 +225,7 @@ export default {
created() {
const { tab, applicationId } = this.$route.query;
this.activeName = tab || '0';
this.activeName = tab !== 'undefined' && tab ? tab : '0';
this.applicationId = applicationId;
const { staffId, wxEnterpriseId } = JSON.parse(localStorage.getItem('haoBanUser'));
this.haoban = { staffId, wxEnterpriseId };
......@@ -276,6 +279,7 @@ export default {
return this.$router.push({ path: '/edit-store-quota', query: { applicationId: this.applicationId } });
case 2: // 批量编辑
if (!this.multipleSelection || !this.multipleSelection.length) return this.$message.warning('请选择指标门店');
if (!this.search.type) return this.$message.warning('请选择指标类型');
localStorage.setItem('targetStoreInfoIds', JSON.stringify(this.multipleSelection));
return this.$router.push({
......@@ -284,18 +288,19 @@ export default {
applicationId: this.applicationId,
tab: this.activeName,
edit: '2',
year: this.search.performanceYear
year: this.search.performanceYear,
type: this.search.type
}
});
case 3: // 批量权限
if (!this.multipleSelection || !this.multipleSelection.length) return this.$message.warning('请选择指标门店');
// 判断是否一致
let edit = this.multipleSelection[0].storeEdit;
let bool = this.multipleSelection.some(item => item.storeEdit !== edit);
if (bool) return this.$message.warning('选择的指标门店的 编辑权限 必须一致');
// let edit = this.multipleSelection[0].storeEdit;
// let bool = this.multipleSelection.some(item => item.storeEdit !== edit);
// if (bool) return this.$message.warning('选择的指标门店的 编辑权限 必须一致');
localStorage.setItem('targetStoreInfoIds', JSON.stringify(this.multipleSelection));
return this.$router.push({ path: '/edit-store-quota', query: { applicationId: this.applicationId, edit: '3', year: this.search.performanceYear, storeEdit: edit } });
return this.$router.push({ path: '/edit-store-quota', query: { applicationId: this.applicationId, edit: '3', year: this.search.performanceYear } });
default:
break;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment