新增global,缓存职位信息

This commit is contained in:
huangdeliang
2021-02-23 15:09:17 +08:00
parent 6b50ddcfdd
commit df52ea8f2d
20 changed files with 2333 additions and 1812 deletions

View File

@ -1,8 +1,20 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form
:model="queryParams"
ref="queryForm"
:inline="true"
v-show="showSearch"
label-width="68px"
>
<el-form-item label="岗位" prop="postId">
<el-select v-model="queryParams.postId" placeholder="请选择岗位" clearable size="small" @change="searchPostChange">
<el-select
v-model="queryParams.postId"
placeholder="请选择岗位"
clearable
size="small"
@change="searchPostChange"
>
<el-option
v-for="dict in postIdOptions"
:key="dict.dictValue"
@ -12,7 +24,12 @@
</el-select>
</el-form-item>
<el-form-item label="业务员" prop="userId">
<el-select v-model="queryParams.userId" placeholder="请选择业务员" clearable size="small">
<el-select
v-model="queryParams.userId"
placeholder="请选择业务员"
clearable
size="small"
>
<el-option
v-for="dict in searchUserIdOptions"
:key="dict.dictValue"
@ -22,8 +39,16 @@
</el-select>
</el-form-item>
<el-form-item>
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
<el-button
type="cyan"
icon="el-icon-search"
size="mini"
@click="handleQuery"
>搜索</el-button
>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
>重置</el-button
>
</el-form-item>
</el-form>
@ -35,7 +60,7 @@
size="mini"
@click="handleAdd"
v-hasPermi="['commision:config:add']"
>新增
>新增
</el-button>
</el-col>
<!-- <el-col :span="1.5">-->
@ -70,25 +95,36 @@
<!-- >导出-->
<!-- </el-button>-->
<!-- </el-col>-->
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
<right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="commisionList" :span-method="objectSpanMethod"
@selection-change="handleSelectionChange">
<el-table-column label="业务员" align="center" prop="userName"/>
<el-table-column label="岗位" align="center" prop="postName"/>
<el-table
v-loading="loading"
:data="commisionList"
:span-method="objectSpanMethod"
@selection-change="handleSelectionChange"
>
<el-table-column label="业务员" align="center" prop="userName" />
<el-table-column label="岗位" align="center" prop="postName" />
<el-table-column label="金额" align="center" prop="amount">
<template scope="scope">
{{toThousands(scope.row.amount)}}
{{ toThousands(scope.row.amount) }}
</template>
</el-table-column>
<el-table-column label="比例" align="center" prop="rate">
<template scope="scope">
{{scope.row.rate + '%'}}
{{ scope.row.rate + "%" }}
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark"/>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column
label="操作"
align="center"
class-name="small-padding fixed-width"
>
<template slot-scope="scope">
<el-button
size="mini"
@ -96,7 +132,7 @@
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['commision:config:edit']"
>修改
>修改
</el-button>
<el-button
size="mini"
@ -104,14 +140,14 @@
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['commision:config:remove']"
>删除
>删除
</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@ -124,7 +160,11 @@
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-col :span="12">
<el-form-item label="岗位" prop="postId">
<el-select v-model="form.postId" placeholder="请选择岗位" @change="postChange">
<el-select
v-model="form.postId"
placeholder="请选择岗位"
@change="postChange"
>
<el-option
v-for="dict in postIdOptions"
:key="dict.dictValue"
@ -148,17 +188,21 @@
</el-col>
<el-col :span="12">
<el-form-item label="金额" prop="amount">
<el-input v-model="form.amount" placeholder="请输入金额"/>
<el-input v-model="form.amount" placeholder="请输入金额" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="分成比例" prop="rate">
<el-input v-model="form.rate" placeholder="请输入比例"/>
<el-input v-model="form.rate" placeholder="请输入比例" />
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容"/>
<el-input
v-model="form.remark"
type="textarea"
placeholder="请输入内容"
/>
</el-form-item>
</el-col>
</el-form>
@ -172,282 +216,307 @@
</template>
<script>
import {
listCommision,
getCommision,
delCommision,
addCommision,
updateCommision,
exportCommision,
} from "@/api/custom/commision";
import {
listCommision,
getCommision,
delCommision,
addCommision,
updateCommision,
exportCommision,
} from "@/api/custom/commision";
import {getOptions} from "@/api/custom/order";
import { getOptions } from "@/api/custom/global";
export default {
name: "CommisionConfig",
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: false,
// 总条数
total: 0,
// 业务提成比例表格数据
commisionList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 业务员字典
userIdOptions: [],
//
postIdOptions: [],
//
totalUserIdOptions: [],
//
searchUserIdOptions: [],
//
options: {},
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
userId: null,
postId: null,
amount: null,
rate: null,
},
// 表单参数
form: {},
// 表单校验
rules: {
userId: [
{required: true, message: "业务员不能为空", trigger: "change"}
],
postId: [
{required: true, message: "岗位不能为空", trigger: "change"}
],
amount: [
{required: true, message: "金额不能为空", trigger: "blur"}
],
rate: [
{required: true, message: "分成比例不能为空", trigger: "blur"}
],
export default {
name: "CommisionConfig",
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: false,
// 总条数
total: 0,
// 业务提成比例表格数据
commisionList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 业务员字典
userIdOptions: [],
//
postIdOptions: [],
//
totalUserIdOptions: [],
//
searchUserIdOptions: [],
//
options: {},
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
userId: null,
postId: null,
amount: null,
rate: null,
},
// 表单参数
form: {},
// 表单校验
rules: {
userId: [
{ required: true, message: "业务员不能为空", trigger: "change" },
],
postId: [
{ required: true, message: "岗位不能为空", trigger: "change" },
],
amount: [{ required: true, message: "金额不能为空", trigger: "blur" }],
rate: [
{ required: true, message: "分成比例不能为空", trigger: "blur" },
],
},
};
},
created() {
this.getList();
getOptions().then((response) => {
this.options = response.data.reduce((opts, cur) => {
// if (cur.postCode.startsWith('planner')) {
// return opts;
// }
if (!opts[cur.postId]) {
opts[cur.postId] = [];
}
};
},
created() {
this.getList();
getOptions().then(response => {
this.options = response.data.reduce((opts, cur) => {
// if (cur.postCode.startsWith('planner')) {
// return opts;
// }
if (!opts[cur.postId]) {
opts[cur.postId] = [];
}
opts[cur.postId].push({dictValue: cur.userId, dictLabel: cur.userName});
opts[cur.postId].push({
dictValue: cur.userId,
dictLabel: cur.userName,
});
if (!this.postIdOptions.some(opt => opt.dictValue === cur.postId)) {
this.postIdOptions.push({dictValue: cur.postId, dictLabel: cur.postName});
}
if (!this.totalUserIdOptions.some(opt => opt.dictValue === cur.userId)) {
this.totalUserIdOptions.push({dictValue: cur.userId, dictLabel: cur.userName});
}
return opts;
}, {});
this.searchUserIdOptions = this.totalUserIdOptions.slice();
});
},
methods: {
/** 查询业务提成比例列表 */
getList() {
this.loading = true;
listCommision(this.queryParams).then(response => {
this.commisionList = response.rows.reduce((arr, cur, idx, oriArr) => {
for (let i = 0; i < arr.length; i++) {
if (arr[i].some(e => e.userId === cur.userId && e.postId === cur.postId)) {
arr[i].push(cur);
break;
} else if (i === arr.length - 1) {
arr.push([cur]);
break;
}
}
if (idx === 0) {
if (!this.postIdOptions.some((opt) => opt.dictValue === cur.postId)) {
this.postIdOptions.push({
dictValue: cur.postId,
dictLabel: cur.postName,
});
}
if (
!this.totalUserIdOptions.some((opt) => opt.dictValue === cur.userId)
) {
this.totalUserIdOptions.push({
dictValue: cur.userId,
dictLabel: cur.userName,
});
}
return opts;
}, {});
this.searchUserIdOptions = this.totalUserIdOptions.slice();
});
},
methods: {
/** 查询业务提成比例列表 */
getList() {
this.loading = true;
listCommision(this.queryParams).then((response) => {
this.commisionList = response.rows.reduce((arr, cur, idx, oriArr) => {
for (let i = 0; i < arr.length; i++) {
if (
arr[i].some(
(e) => e.userId === cur.userId && e.postId === cur.postId
)
) {
arr[i].push(cur);
break;
} else if (i === arr.length - 1) {
arr.push([cur]);
}
if (idx === oriArr.length - 1) {
const finalArr = [];
arr.forEach(tmpArr => {
tmpArr.sort((a, b) => a.amount - b.amount)
.forEach((elm, elmIdx) => {
finalArr.push({
...elm,
userSpan: elmIdx ? {
rowspan: 0,
colspan: 0
} : {
rowspan: tmpArr.length,
colspan: 1
},
postSpan: elmIdx ? {
rowspan: 0,
colspan: 0
} : {
rowspan: tmpArr.length,
colspan: 1
}
})
})
});
return finalArr;
}
return arr;
}, []);
this.total = response.total;
this.loading = false;
});
},
// 业务员字典翻译
userIdFormat(row, column) {
return this.selectDictLabel(this.userIdOptions, row.userId);
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.userIdOptions = [];
this.form = {
ruleId: null,
userId: null,
userName: null,
amount: null,
rate: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null,
remark: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
this.searchUserIdOptions = this.totalUserIdOptions.slice();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.ruleId)
this.single = selection.length !== 1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加业务提成比例";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const ruleId = row.ruleId || this.ids
getCommision(ruleId, row.postId).then(response => {
this.form = response.data;
this.userIdOptions = this.options[this.form.postId];
this.open = true;
this.title = "修改业务提成比例";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.ruleId != null) {
updateCommision(this.form).then(response => {
if (response.code === 200) {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
}
});
} else {
addCommision(this.form).then(response => {
if (response.code === 200) {
this.msgSuccess("新增成功");
this.open = false;
this.getList();
}
});
break;
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ruleIds = row.ruleId || this.ids;
this.$confirm('是否确认删除业务提成比例编号为"' + ruleIds + '"的数据项?', "警告", {
if (idx === 0) {
arr.push([cur]);
}
if (idx === oriArr.length - 1) {
const finalArr = [];
arr.forEach((tmpArr) => {
tmpArr
.sort((a, b) => a.amount - b.amount)
.forEach((elm, elmIdx) => {
finalArr.push({
...elm,
userSpan: elmIdx
? {
rowspan: 0,
colspan: 0,
}
: {
rowspan: tmpArr.length,
colspan: 1,
},
postSpan: elmIdx
? {
rowspan: 0,
colspan: 0,
}
: {
rowspan: tmpArr.length,
colspan: 1,
},
});
});
});
return finalArr;
}
return arr;
}, []);
this.total = response.total;
this.loading = false;
});
},
// 业务员字典翻译
userIdFormat(row, column) {
return this.selectDictLabel(this.userIdOptions, row.userId);
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.userIdOptions = [];
this.form = {
ruleId: null,
userId: null,
userName: null,
amount: null,
rate: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null,
remark: null,
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
this.searchUserIdOptions = this.totalUserIdOptions.slice();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map((item) => item.ruleId);
this.single = selection.length !== 1;
this.multiple = !selection.length;
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加业务提成比例";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const ruleId = row.ruleId || this.ids;
getCommision(ruleId, row.postId).then((response) => {
this.form = response.data;
this.userIdOptions = this.options[this.form.postId];
this.open = true;
this.title = "修改业务提成比例";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate((valid) => {
if (valid) {
if (this.form.ruleId != null) {
updateCommision(this.form).then((response) => {
if (response.code === 200) {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
}
});
} else {
addCommision(this.form).then((response) => {
if (response.code === 200) {
this.msgSuccess("新增成功");
this.open = false;
this.getList();
}
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ruleIds = row.ruleId || this.ids;
this.$confirm(
'是否确认删除业务提成比例编号为"' + ruleIds + '"的数据项?',
"警告",
{
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function () {
type: "warning",
}
)
.then(function () {
return delCommision(ruleIds);
}).then(() => {
})
.then(() => {
this.getList();
this.msgSuccess("删除成功");
}).catch(function () {
});
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm('是否确认导出所有业务提成比例数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function () {
})
.catch(function () {});
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm("是否确认导出所有业务提成比例数据项?", "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(function () {
return exportCommision(queryParams);
}).then(response => {
})
.then((response) => {
this.download(response.msg);
}).catch(function () {
});
},
objectSpanMethod({row, column, rowIndex, columnIndex}) {
if (columnIndex === 0) {
return row.userSpan;
} else if (columnIndex === 1) {
return row.postSpan;
}
},
postChange(postId) {
this.userIdOptions = this.options[postId];
},
searchPostChange(postId) {
if (!postId) {
this.searchUserIdOptions = this.totalUserIdOptions.slice();
return;
}
this.searchUserIdOptions = this.options[postId];
this.queryParams.userId = null;
})
.catch(function () {});
},
objectSpanMethod({ row, column, rowIndex, columnIndex }) {
if (columnIndex === 0) {
return row.userSpan;
} else if (columnIndex === 1) {
return row.postSpan;
}
}
};
},
postChange(postId) {
this.userIdOptions = this.options[postId];
},
searchPostChange(postId) {
if (!postId) {
this.searchUserIdOptions = this.totalUserIdOptions.slice();
return;
}
this.searchUserIdOptions = this.options[postId];
this.queryParams.userId = null;
},
},
};
</script>

View File

@ -1,8 +1,20 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form
:model="queryParams"
ref="queryForm"
:inline="true"
v-show="showSearch"
label-width="68px"
>
<el-form-item label="岗位" prop="postId">
<el-select v-model="queryParams.postId" placeholder="请选择岗位" clearable size="small" @change="searchPostChange">
<el-select
v-model="queryParams.postId"
placeholder="请选择岗位"
clearable
size="small"
@change="searchPostChange"
>
<el-option
v-for="dict in postIdOptions"
:key="dict.dictValue"
@ -12,7 +24,13 @@
</el-select>
</el-form-item>
<el-form-item label="业务员" prop="userId">
<el-select v-model="queryParams.userId" filterable placeholder="请选择业务员" clearable size="small">
<el-select
v-model="queryParams.userId"
filterable
placeholder="请选择业务员"
clearable
size="small"
>
<el-option
v-for="dict in searchUserIdOptions"
:key="dict.dictValue"
@ -26,12 +44,21 @@
v-model="month"
@change="monthRangeChange"
type="month"
placeholder="选择月">
placeholder="选择月"
>
</el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
<el-button
type="cyan"
icon="el-icon-search"
size="mini"
@click="handleQuery"
>搜索</el-button
>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
>重置</el-button
>
</el-form-item>
</el-form>
@ -43,40 +70,46 @@
size="mini"
@click="handleExport"
v-hasPermi="['commision:detail:export']"
>导出
>导出
</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
<right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="commisionList"
@selection-change="handleSelectionChange">
<el-table-column label="业务员" align="center" prop="userName"/>
<el-table-column label="岗位" align="center" prop="postName"/>
<el-table
v-loading="loading"
:data="commisionList"
@selection-change="handleSelectionChange"
>
<el-table-column label="业务员" align="center" prop="userName" />
<el-table-column label="岗位" align="center" prop="postName" />
<el-table-column label="总金额" align="center" prop="amount">
<template scope="scope">
{{toThousands(scope.row.amount)}}
{{ toThousands(scope.row.amount) }}
</template>
</el-table-column>
<el-table-column label="比例" align="center" prop="rate">
<template scope="scope">
{{scope.row.rate + '%'}}
{{ scope.row.rate + "%" }}
</template>
</el-table-column>
<el-table-column label="提成" align="center" prop="commision">
<template scope="scope">
{{scope.row.commision.toFixed(2)}}
{{ scope.row.commision.toFixed(2) }}
</template>
</el-table-column>
<el-table-column label="下月应发提成" align="center" prop="commision">
<template scope="scope">
{{scope.row.commision.toFixed(2)}}
{{ scope.row.commision.toFixed(2) }}
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@ -86,147 +119,163 @@
</template>
<script>
import {
detailCommision,
exportCommision,
} from "@/api/custom/commision";
import { detailCommision, exportCommision } from "@/api/custom/commision";
import {getOptions} from "@/api/custom/order";
import { getOptions } from "@/api/custom/global";
import dayjs from 'dayjs';
import dayjs from "dayjs";
export default {
name: "CommisionDetail",
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
//
month: dayjs(),
// 业务提成比例表格数据
commisionList: [],
// 是否显示弹出层
open: false,
// 业务员字典
userIdOptions: [],
//
postIdOptions: [],
//
totalUserIdOptions: [],
//
searchUserIdOptions: [],
//
options: {},
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
userId: null,
postId: null,
},
};
},
created() {
this.getList();
getOptions().then(response => {
this.options = response.data.reduce((opts, cur) => {
// if (cur.postCode.startsWith('planner')) {
// return opts;
// }
if (!opts[cur.postId]) {
opts[cur.postId] = [];
}
opts[cur.postId].push({dictValue: cur.userId, dictLabel: cur.userName});
export default {
name: "CommisionDetail",
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
//
month: dayjs(),
// 业务提成比例表格数据
commisionList: [],
// 是否显示弹出层
open: false,
// 业务员字典
userIdOptions: [],
//
postIdOptions: [],
//
totalUserIdOptions: [],
//
searchUserIdOptions: [],
//
options: {},
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
userId: null,
postId: null,
},
};
},
created() {
this.getList();
getOptions().then((response) => {
this.options = response.data.reduce((opts, cur) => {
// if (cur.postCode.startsWith('planner')) {
// return opts;
// }
if (!opts[cur.postId]) {
opts[cur.postId] = [];
}
opts[cur.postId].push({
dictValue: cur.userId,
dictLabel: cur.userName,
});
if (!this.postIdOptions.some(opt => opt.dictValue === cur.postId)) {
this.postIdOptions.push({dictValue: cur.postId, dictLabel: cur.postName});
}
if (!this.totalUserIdOptions.some(opt => opt.dictValue === cur.userId)) {
this.totalUserIdOptions.push({dictValue: cur.userId, dictLabel: cur.userName});
}
return opts;
}, {});
this.postIdOptions = this.postIdOptions.sort((a, b) => a.dictValue - b.dictValue);
this.searchUserIdOptions = this.totalUserIdOptions.slice();
})
},
methods: {
/** 查询业务提成比例列表 */
getList() {
this.loading = true;
const dateRange = [dayjs(this.month).startOf('month').format('YYYY-MM-DD'), dayjs(this.month).endOf('month').format('YYYY-MM-DD')];
// console.log(dateRange)
detailCommision(this.addDateRange(this.queryParams, dateRange)).then(response => {
if (!this.postIdOptions.some((opt) => opt.dictValue === cur.postId)) {
this.postIdOptions.push({
dictValue: cur.postId,
dictLabel: cur.postName,
});
}
if (
!this.totalUserIdOptions.some((opt) => opt.dictValue === cur.userId)
) {
this.totalUserIdOptions.push({
dictValue: cur.userId,
dictLabel: cur.userName,
});
}
return opts;
}, {});
this.postIdOptions = this.postIdOptions.sort(
(a, b) => a.dictValue - b.dictValue
);
this.searchUserIdOptions = this.totalUserIdOptions.slice();
});
},
methods: {
/** 查询业务提成比例列表 */
getList() {
this.loading = true;
const dateRange = [
dayjs(this.month).startOf("month").format("YYYY-MM-DD"),
dayjs(this.month).endOf("month").format("YYYY-MM-DD"),
];
// console.log(dateRange)
detailCommision(this.addDateRange(this.queryParams, dateRange)).then(
(response) => {
this.commisionList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 业务员字典翻译
userIdFormat(row, column) {
return this.selectDictLabel(this.userIdOptions, row.userId);
},
// 表单重置
reset() {
this.userIdOptions = [];
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
this.searchUserIdOptions = this.totalUserIdOptions.slice();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.ruleId)
this.single = selection.length !== 1
this.multiple = !selection.length
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm('是否确认导出所有业务提成比例数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function () {
return exportCommision(queryParams);
}).then(response => {
this.download(response.msg);
}).catch(function () {
});
},
monthRangeChange(time) {
this.month = time;
},
postChange(postId) {
this.userIdOptions = this.options[postId];
},
searchPostChange(postId) {
if (!postId) {
this.searchUserIdOptions = this.totalUserIdOptions.slice();
return;
}
this.searchUserIdOptions = this.options[postId];
this.queryParams.userId = null;
);
},
// 业务员字典翻译
userIdFormat(row, column) {
return this.selectDictLabel(this.userIdOptions, row.userId);
},
// 表单重置
reset() {
this.userIdOptions = [];
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
this.searchUserIdOptions = this.totalUserIdOptions.slice();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map((item) => item.ruleId);
this.single = selection.length !== 1;
this.multiple = !selection.length;
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm("是否确认导出所有业务提成比例数据项?", "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(function () {
return exportCommision(queryParams);
})
.then((response) => {
this.download(response.msg);
})
.catch(function () {});
},
monthRangeChange(time) {
this.month = time;
},
postChange(postId) {
this.userIdOptions = this.options[postId];
},
searchPostChange(postId) {
if (!postId) {
this.searchUserIdOptions = this.totalUserIdOptions.slice();
return;
}
}
};
this.searchUserIdOptions = this.options[postId];
this.queryParams.userId = null;
},
},
};
</script>

View File

@ -1,8 +1,20 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form
:model="queryParams"
ref="queryForm"
:inline="true"
v-show="showSearch"
label-width="68px"
>
<el-form-item label="岗位" prop="postId">
<el-select v-model="queryParams.postId" placeholder="请选择岗位" clearable size="small" @change="searchPostChange">
<el-select
v-model="queryParams.postId"
placeholder="请选择岗位"
clearable
size="small"
@change="searchPostChange"
>
<el-option
v-for="dict in postIdOptions"
:key="dict.dictValue"
@ -12,7 +24,13 @@
</el-select>
</el-form-item>
<el-form-item label="业务员" prop="userId">
<el-select v-model="queryParams.userId" filterable placeholder="请选择业务员" clearable size="small">
<el-select
v-model="queryParams.userId"
filterable
placeholder="请选择业务员"
clearable
size="small"
>
<el-option
v-for="dict in searchUserIdOptions"
:key="dict.dictValue"
@ -26,20 +44,31 @@
v-model="month"
@change="monthRangeChange"
type="month"
placeholder="选择月份">
placeholder="选择月份"
>
</el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
<el-button
type="cyan"
icon="el-icon-search"
size="mini"
@click="handleQuery"
>搜索</el-button
>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
>重置</el-button
>
</el-form-item>
</el-form>
<div><span style="color:#E6A23C;font-family:PingFang SC">
注意事项
<br/>12021年1月开始的订单才开始按天计算提成只计算已审核的订单
<br/>2发工资日期定为每月15号若当前日期大于15号则认定上个月的工资已发放
</span></div>
<el-row :gutter="10" class="mb8" style="margin-top:10px;">
<div>
<span style="color: #e6a23c; font-family: PingFang SC">
注意事项
<br />12021年1月开始的订单才开始按天计算提成只计算已审核的订单
<br />2发工资日期定为每月15号若当前日期大于15号则认定上个月的工资已发放
</span>
</div>
<el-row :gutter="10" class="mb8" style="margin-top: 10px">
<el-col :span="1.5">
<el-button
type="warning"
@ -47,74 +76,116 @@
size="mini"
@click="handleExport"
v-hasPermi="['commisionDay:detail:export']"
>导出
>导出
</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
<right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="commisionList"
@selection-change="handleSelectionChange" stripe :row-class-name="tableRowClassName">
<el-table
v-loading="loading"
:data="commisionList"
@selection-change="handleSelectionChange"
stripe
:row-class-name="tableRowClassName"
>
<el-table-column label="业务员" align="center" prop="nickName">
<template slot-scope="scope">
<span>{{ scope.row.nickName }}</span>
</template>
</el-table-column>
<el-table-column label="岗位" align="center" prop="postName"/>
<el-table-column label="总提成" align="center" prop="totalCommissionAmount">
<el-table-column label="岗位" align="center" prop="postName" />
<el-table-column
label="总提成"
align="center"
prop="totalCommissionAmount"
>
<template scope="scope">
{{scope.row.totalCommissionAmount.toFixed(fixLength)}}
{{ scope.row.totalCommissionAmount.toFixed(fixLength) }}
</template>
</el-table-column>
<el-table-column label="已发放提成" align="center" prop="totalHasSentCommissionAmount">
<el-table-column
label="已发放提成"
align="center"
prop="totalHasSentCommissionAmount"
>
<template scope="scope">
{{scope.row.totalHasSentCommissionAmount.toFixed(fixLength)}}
{{ scope.row.totalHasSentCommissionAmount.toFixed(fixLength) }}
</template>
</el-table-column>
<el-table-column label="未发放提成" align="center" prop="totalNotSentCommissionAmount">
<el-table-column
label="未发放提成"
align="center"
prop="totalNotSentCommissionAmount"
>
<template scope="scope">
{{scope.row.totalNotSentCommissionAmount.toFixed(fixLength)}}
{{ scope.row.totalNotSentCommissionAmount.toFixed(fixLength) }}
</template>
</el-table-column>
<el-table-column label="下月应发提成" align="center" prop="nextMonthCommission">
<el-table-column
label="下月应发提成"
align="center"
prop="nextMonthCommission"
>
<template scope="scope">
{{scope.row.nextMonthCommission.toFixed(fixLength)}}
{{ scope.row.nextMonthCommission.toFixed(fixLength) }}
</template>
</el-table-column>
<el-table-column label="操作" align="center">
<template scope="scope">
<el-button type="text" @click="openFormDialog('查看发放计划', scope.row)">查看发放计划</el-button>
<el-button
type="text"
@click="openFormDialog('查看发放计划', scope.row)"
>查看发放计划</el-button
>
</template>
</el-table-column>
<!--<el-table-column label="提成" align="center" prop="commissionTotalAmount"></el-table-column>-->
</el-table>
<pagination
v-show="total>0"
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<el-dialog title="提成发放计划" :visible.sync="sendCommissionPlanTable" width="40%" align="center">
<el-table :data="sendCommissionPlan.list" show-summary :summary-method="getSummaries">
<el-table-column property="nickName" label="姓名" width="150"></el-table-column>
<el-dialog
title="提成发放计划"
:visible.sync="sendCommissionPlanTable"
width="40%"
align="center"
>
<el-table
:data="sendCommissionPlan.list"
show-summary
:summary-method="getSummaries"
>
<el-table-column
property="nickName"
label="姓名"
width="150"
></el-table-column>
<el-table-column property="yearMonth" label="提成月份" width="200">
<template scope="scope">
{{scope.row.yearMonth.substring(0, 4)}}{{scope.row.yearMonth.substring(4)}}
{{ scope.row.yearMonth.substring(0, 4) }}{{
scope.row.yearMonth.substring(4)
}}
</template>
</el-table-column>
<el-table-column property="yearMonthCommission" label="提成金额" width="100">
<el-table-column
property="yearMonthCommission"
label="提成金额"
width="100"
>
<template scope="scope">
{{scope.row.yearMonthCommission.toFixed(fixLength)}}
{{ scope.row.yearMonthCommission.toFixed(fixLength) }}
</template>
</el-table-column>
</el-table>
@ -123,197 +194,215 @@
</template>
<style>
.el-table .warning-row {
background: oldlace;
}
.el-table .warning-row {
background: oldlace;
}
.el-table .success-row {
/*background: #1890FF;*/
color: #1890FF
}
.el-table .success-row {
/*background: #1890FF;*/
color: #1890ff;
}
</style>
<script>
import {
detailDayCommision, exportDayCommision} from "@/api/custom/commision";
import { detailDayCommision, exportDayCommision } from "@/api/custom/commision";
import {getOptions} from "@/api/custom/order";
import { getOptions } from "@/api/custom/global";
import dayjs from 'dayjs';
import dayjs from "dayjs";
export default {
name: "CommisionDayDetail",
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
//
month: dayjs(),
// 业务提成比例表格数据
commisionList: [],
// 是否显示弹出层
open: false,
// 业务员字典
userIdOptions: [],
//
postIdOptions: [],
//
totalUserIdOptions: [],
//
searchUserIdOptions: [],
//
options: {},
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 20,
userId: null,
postId: null,
},
sendCommissionPlanTable: false,
sendCommissionPlan:{},
fixLength: 2
};
},
created() {
this.getList();
getOptions().then(response => {
this.options = response.data.reduce((opts, cur) => {
if (cur.postCode != ('after_sale') && cur.postCode != 'nutri') {
return opts;
}
if (!opts[cur.postId]) {
opts[cur.postId] = [];
}
opts[cur.postId].push({dictValue: cur.userId, dictLabel: cur.userName});
if (!this.postIdOptions.some(opt => opt.dictValue === cur.postId)) {
this.postIdOptions.push({dictValue: cur.postId, dictLabel: cur.postName});
}
if (!this.totalUserIdOptions.some(opt => opt.dictValue === cur.userId)) {
this.totalUserIdOptions.push({dictValue: cur.userId, dictLabel: cur.userName});
}
export default {
name: "CommisionDayDetail",
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
//
month: dayjs(),
// 业务提成比例表格数据
commisionList: [],
// 是否显示弹出层
open: false,
// 业务员字典
userIdOptions: [],
//
postIdOptions: [],
//
totalUserIdOptions: [],
//
searchUserIdOptions: [],
//
options: {},
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 20,
userId: null,
postId: null,
},
sendCommissionPlanTable: false,
sendCommissionPlan: {},
fixLength: 2,
};
},
created() {
this.getList();
getOptions().then((response) => {
this.options = response.data.reduce((opts, cur) => {
if (cur.postCode != "after_sale" && cur.postCode != "nutri") {
return opts;
}, {});
this.postIdOptions = this.postIdOptions.sort((a, b) => a.dictValue - b.dictValue);
this.searchUserIdOptions = this.totalUserIdOptions.slice();
})
}
if (!opts[cur.postId]) {
opts[cur.postId] = [];
}
opts[cur.postId].push({
dictValue: cur.userId,
dictLabel: cur.userName,
});
},
methods: {
/** 查询业务提成比例列表 */
getList() {
this.loading = true;
const dateRange = [dayjs(this.month).startOf('month').format('YYYY-MM-DD'), dayjs(this.month).endOf('month').format('YYYY-MM-DD')];
// console.log(dateRange)
detailDayCommision(this.addDateRange(this.queryParams, dateRange)).then(response => {
if (!this.postIdOptions.some((opt) => opt.dictValue === cur.postId)) {
this.postIdOptions.push({
dictValue: cur.postId,
dictLabel: cur.postName,
});
}
if (
!this.totalUserIdOptions.some((opt) => opt.dictValue === cur.userId)
) {
this.totalUserIdOptions.push({
dictValue: cur.userId,
dictLabel: cur.userName,
});
}
return opts;
}, {});
this.postIdOptions = this.postIdOptions.sort(
(a, b) => a.dictValue - b.dictValue
);
this.searchUserIdOptions = this.totalUserIdOptions.slice();
});
},
methods: {
/** 查询业务提成比例列表 */
getList() {
this.loading = true;
const dateRange = [
dayjs(this.month).startOf("month").format("YYYY-MM-DD"),
dayjs(this.month).endOf("month").format("YYYY-MM-DD"),
];
// console.log(dateRange)
detailDayCommision(this.addDateRange(this.queryParams, dateRange)).then(
(response) => {
this.commisionList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 业务员字典翻译
userIdFormat(row, column) {
return this.selectDictLabel(this.userIdOptions, row.userId);
},
// 表单重置
reset() {
this.userIdOptions = [];
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
//this.handleQuery();
this.searchUserIdOptions = this.totalUserIdOptions.slice();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.ruleId)
this.single = selection.length !== 1
this.multiple = !selection.length
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm('是否确认导出所有业务提成比例数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function () {
}
);
},
// 业务员字典翻译
userIdFormat(row, column) {
return this.selectDictLabel(this.userIdOptions, row.userId);
},
// 表单重置
reset() {
this.userIdOptions = [];
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
//this.handleQuery();
this.searchUserIdOptions = this.totalUserIdOptions.slice();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map((item) => item.ruleId);
this.single = selection.length !== 1;
this.multiple = !selection.length;
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm("是否确认导出所有业务提成比例数据项?", "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(function () {
return exportDayCommision(queryParams);
}).then(response => {
})
.then((response) => {
this.download(response.msg);
}).catch(function () {
})
.catch(function () {});
},
monthRangeChange(time) {
this.month = time;
},
postChange(postId) {
this.userIdOptions = this.options[postId];
},
searchPostChange(postId) {
if (!postId) {
this.searchUserIdOptions = this.totalUserIdOptions.slice();
return;
}
this.searchUserIdOptions = this.options[postId];
this.queryParams.userId = null;
},
openFormDialog(title, row) {
this.sendCommissionPlan = {};
var total = 0;
if (row.sendDetailList != null) {
row.sendDetailList.forEach(function (e) {
e.nickName = row.nickName;
total += e.yearMonthCommission;
});
},
monthRangeChange(time) {
this.month = time;
},
postChange(postId) {
this.userIdOptions = this.options[postId];
},
searchPostChange(postId) {
if (!postId) {
this.searchUserIdOptions = this.totalUserIdOptions.slice();
}
this.sendCommissionPlan.list = row.sendDetailList;
this.sendCommissionPlan.total = row.totalNotSentCommissionAmount;
this.sendCommissionPlanTable = true;
},
getSummaries(param) {
//param 是固定的对象,里面包含 columns与 data参数的对象 {columns: Array[4], data: Array[5]},包含了表格的所有的列与数据信息
const { columns, data } = param;
const sums = [];
columns.forEach((column, index) => {
if (index === 0) {
sums[index] = "合计";
return;
}
this.searchUserIdOptions = this.options[postId];
this.queryParams.userId = null;
},
openFormDialog(title, row){
this.sendCommissionPlan = {};
var total = 0;
if(row.sendDetailList != null){
row.sendDetailList.forEach(function (e) {
e.nickName = row.nickName;
total += e.yearMonthCommission;
});
}
this.sendCommissionPlan.list = row.sendDetailList;
this.sendCommissionPlan.total = row.totalNotSentCommissionAmount;
this.sendCommissionPlanTable = true;
},
getSummaries(param) {
//param 是固定的对象,里面包含 columns与 data参数的对象 {columns: Array[4], data: Array[5]},包含了表格的所有的列与数据信息
const { columns, data } = param;
const sums = [];
columns.forEach((column, index) => {
if (index === 0) {
sums[index] = '合计';
return;
}
if(index == 1){
sums[index] = data.length +"个月";
return
}
if(index == 2){
sums[index] = this.sendCommissionPlan.total;
}
});
return sums;
},
tableRowClassName({row, rowIndex}) {
if(this.commisionList.length == rowIndex+1){
return "success-row";
if (index == 1) {
sums[index] = data.length + "个月";
return;
}
return '';
if (index == 2) {
sums[index] = this.sendCommissionPlan.total;
}
});
return sums;
},
tableRowClassName({ row, rowIndex }) {
if (this.commisionList.length == rowIndex + 1) {
return "success-row";
}
}
};
return "";
},
},
};
</script>