Commit e739ec99 by Kyle_Li

update: 日指标

parent 0c6e26ab
......@@ -14,20 +14,20 @@
{{ parseFloat(form.performanceValue).toFixed(2) }}
<el-button type="text" @click="dialogVisible=true">修改</el-button>
</el-form-item>
<el-form-item label="指标类型">业绩指标日权重</el-form-item>
<el-form-item label="指标类型">{{ [ '业绩指标日权重', '业绩指标日指标' ][form.performanceSubType - 1] }}</el-form-item>
<el-form-item label="">
<div class="content-data">
<span class="color2">月指标:¥ </span>
<span class="color1">{{ parseFloat(form.performanceValue).toFixed(2) }}</span>
<span class="color2">日指标总和:¥ </span>
<span class="color1" :style="{ color: totalDayTarget > monthTarget ? '#F5222D' : '#606266' }">{{ parseFloat(totalDayTarget).toFixed(2) }}</span>
<span class="color1" :style="{ color: totalDayTarget > form.performanceValue ? '#F5222D' : '#606266' }">{{ parseFloat(totalDayTarget).toFixed(2) }}</span>
</div>
</el-form-item>
</el-form>
<div class="target-title">
<span>2020年9</span>
<el-button type="text">设置默认日权重</el-button>
<span>{{ form.date[0] }}{{ form.date[1] }}</span>
<el-button type="text" @click="setDefault" v-if="form.flag === 'false'">设置默认日权重</el-button>
</div>
<div class="target-table">
......@@ -54,7 +54,7 @@
</ul>
</div>
<el-button type="primary" :loading="loading" style="margin-left:20px">保存</el-button>
<el-button type="primary" :loading="loading" style="margin-left:20px" @click="confirm">保存</el-button>
<el-dialog
title="修改指标"
......@@ -93,10 +93,10 @@
</div>
</template>
<script>
import errMsg from '@/common/js/error';
// import errMsg from '@/common/js/error';
// import showMsg from '@/common/js/showmsg';
// import fetch from '@/api/target-manage-app.js';
// const { saveDaySet, getDaySet } = fetch;
import fetch from '@/api/target-manage-app.js';
const { changeStorePerformanceDay, getStorePerformanceDay } = fetch;
export default {
name: 'PerfectDayTarget',
components: {},
......@@ -110,9 +110,19 @@ export default {
},
data() {
return {
form: {},
form: {
tab: '',
performanceYm: '',
performanceSubType: 1,
performanceType: 0,
storeInfoId: '',
storeName: '',
performanceValue: 0,
flag: 'false',
date: [ '', '' ]
},
loading: false,
monthTarget: 10000,
days: 0,
tableData: [],
zerofill: [],
......@@ -122,17 +132,26 @@ export default {
value: ''
},
dialogVisible: false,
haoban: {}
};
},
created() {
this.form = this.$route.query;
this.form = JSON.parse(JSON.stringify(this.$route.query));
const { staffName, staffId, wxEnterpriseId } = JSON.parse(localStorage.getItem('haoBanUser'));
this.haoban = { staffName, staffId, wxEnterpriseId };
let bread = [ { name: '指标管理', path: '/target-list' }, { name: '查看门店', path: '/target-store' }, { name: '完善日指标' } ];
// 修改面包屑
const { tab, applicationId, performanceYm } = this.$route.query;
this.form.date = performanceYm.split('-');
bread[0].path += `?applicationId=${applicationId}&tab=${tab}`;
bread[1].path += `?applicationId=${applicationId}&tab=${tab}&performanceYm=${performanceYm}`;
this.$emit('change-nav', bread);
this.init();
},
mounted() {
this.$emit('showTab', '/target-list');
let bread = [ { name: '指标管理', path: '/target-list' }, { name: '查看门店', path: '/target-store' }, { name: '完善日指标' } ];
// 修改面包屑
this.$emit('change-nav', bread);
},
// watch: {
// brandId() {
......@@ -141,31 +160,78 @@ export default {
methods: {
// 初始化表格
init() {
const { date } = this.$route.query;
let sDate = date ? date.split('-') : '';
if (!sDate) return errMsg('缺少参数,请返回重试');
let week = new Date(sDate[0], sDate[1] - 1).getDay(); // 第一天周几
let days = new Date(sDate[0], sDate[1], 0).getDate(); // 一个月天数
let { date, flag, performanceType, performanceYm, performanceSubType, storeInfoId } = this.form;
date = date && date.length ? date : [ 2020, 1 ];
let week = new Date(date[0], date[1] - 1).getDay(); // 第一天周几
let days = this.days = new Date(date[0], date[1], 0).getDate(); // 一个月天数
this.zerofill = new Array(week).fill(null); // 补空白
this.tableData = new Array(days).fill(null).map((item, i) => {
return {
perfromanceDay: i + 1,
performanceValue: 0,
performanceSubType: 2
performanceValue: 0
};
});
// 末尾补空白
let len = (this.zerofill.length + this.tableData.length) % 7;
if (len) this.zerofillLast = new Array(7 - len).fill(null);
// 默认值
if (flag === 'false') {
this.setDefault();
} else if (flag === 'true') {
let par = {
enterpriseId: this.brandId,
performanceType,
performanceYm,
performanceSubType,
storeInfoId
};
getStorePerformanceDay(par, { headers: { sign: this.brandId } })
.then(res => {
console.lo9g(res.perfromanceValue);
});
}
},
// 修改月指标
confirmMonthTarget() {
this.$refs.targetForm.validate(valid => {
if (!valid) return;
});
},
// 修改月指标
confirm() {
this.loading = true;
let params = {
...this.haoban,
...this.form,
enterpriseId: this.brandId,
dataJson: this.filterJson()
};
changeStorePerformanceDay(params, { headers: { sign: this.brandId } })
.then(res => {
this.$message.success('保存成功');
this.$router.go(-1);
})
.finally(() => this.loading = false);
},
dialogClose() {
this.$refs.targetForm.resetFields();
},
// 格式化json数据
filterJson() {
return JSON.stringify(this.tableData.map(item => {
const { performanceDay, performanceValue } = item;
return {
performanceValue,
performanceSubType: this.form.performanceSubType,
performanceDay: `${this.form.performanceYm}-${performanceDay}`
};
}));
},
// 设置默认值
setDefault() {
let defaultV = (this.form.performanceValue / this.days).toString().match(/^\d+(?:\.\d{0,2})?/)[0];
this.tableData.forEach(item => item.performanceValue = Number(defaultV));
}
},
computed: {
......
......@@ -89,7 +89,7 @@
<el-table
:data="tableData"
:loading="loading"
v-loading="loading"
style="width: 100%"
ref="multipleTable"
@selection-change="handleSelectionChange">
......
......@@ -64,16 +64,16 @@
</el-select>
</div>
<div class="content-data">
<!-- <div class="content-data">
<div>
<span class="color2">总业绩指标:¥ </span>
<span class="color1">100,000</span>
</div>
</div>
</div> -->
<el-table
:data="tableData"
:loading="loading"
v-loading="loading"
style="width: 100%"
ref="multipleTable"
@selection-change="handleSelectionChange">
......@@ -103,9 +103,9 @@
<div :class="{
'state-point': true,
'state-point-success': row.dayFlag == 1,
'state-point-default': row.dayFlag == 0,
'state-point-default': row.dayFlag != 1,
}">
{{ [ '未完善', '已完善' ][row.dayFlag] }}
{{ [ '未完善', '已完善' ][row.dayFlag || 0] }}
</div>
</template>
</el-table-column>
......@@ -114,9 +114,9 @@
<div :class="{
'state-point': true,
'state-point-success': row.clerkFlag == 1,
'state-point-default': row.clerkFlag == 0,
'state-point-default': row.clerkFlag != 1,
}">
{{ [ '未完善', '已完善' ][row.clerkFlag] }}
{{ [ '未完善', '已完善' ][row.clerkFlag || 0] }}
</div>
</template>
</el-table-column>
......@@ -152,7 +152,7 @@
flag: row.clerkFlag == 1
}
})">
{{ [ '完善', '查看' ][row.clerkFlag] }}导购指标
{{ [ '完善', '查看' ][row.clerkFlag || 0] }}导购指标
</el-button>
<el-button
type="text"
......@@ -170,7 +170,7 @@
flag: row.dayFlag == 1
}
})">
{{ [ '完善', '查看' ][row.dayFlag] }}日指标
{{ [ '完善', '查看' ][row.dayFlag || 0] }}日指标
</el-button>
</template>
</el-table-column>
......
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