Commit e739ec99 by Kyle_Li

update: 日指标

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