476 lines
17 KiB
Vue
476 lines
17 KiB
Vue
<template>
|
|
<div class="app-container">
|
|
<el-card>
|
|
<el-tabs v-model="activeName" @tab-click="handleClick">
|
|
<el-tab-pane label="油品提成方案" name="oil"></el-tab-pane>
|
|
<el-tab-pane label="非油品提成方案" name="nonOil"></el-tab-pane>
|
|
</el-tabs>
|
|
|
|
<el-alert
|
|
title="方案说明"
|
|
type="info"
|
|
description="同一角色组、同一参与油品只能设置一种启用的提成方案">
|
|
</el-alert>
|
|
|
|
<div style="margin-top: 20px">
|
|
<el-button
|
|
type="primary"
|
|
icon="el-icon-plus"
|
|
@click="handleAdd"
|
|
>新增提成方案</el-button>
|
|
<el-table ref="tables" v-loading="loading" :data="list"
|
|
@selection-change="handleSelectionChange" :default-sort="defaultSort"
|
|
@sort-change="handleSortChange">
|
|
<el-table-column label="ID" prop="id" align="center" width="60"/>
|
|
<el-table-column label="方案名称" prop="name" align="center"/>
|
|
<el-table-column label="员工角色" prop="staffRoleGroup" align="center">
|
|
<template slot-scope="scope">
|
|
<dict-tag :options="dict.type.staff_role" :value="scope.row.staffRoleGroup"/>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="提成来源" prop="commissionSource" align="center" />
|
|
<el-table-column label="满足条件" prop="meetCondition" align="center">
|
|
<template slot-scope="scope">
|
|
<span v-if="form.type == 'orderAmount'">
|
|
订单金额消费满{{scope.row.meetCondition}}元
|
|
</span>
|
|
<span v-if="form.type == 'payAmount'">
|
|
实际金额消费满{{scope.row.meetCondition}}元
|
|
</span>
|
|
<span v-if="form.type == 'refuleNum'">
|
|
加油数量消费满{{scope.row.meetCondition}}单位(升/立方)
|
|
</span>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="油品提成" prop="royaltyRate" align="center"/>
|
|
<!-- <el-table-column label="生效时间" prop="takeEffect" align="center">-->
|
|
<!-- <template slot-scope="scope">-->
|
|
<!-- <span>-->
|
|
<!-- {{JSON.parse(scope.row.takeEffect)[0]}}至{{JSON.parse(scope.row.takeEffect)[1]}}-->
|
|
<!-- </span>-->
|
|
<!-- </template>-->
|
|
<!-- </el-table-column>-->
|
|
<el-table-column label="方案状态" align="center" prop="status">
|
|
<template slot-scope="scope">
|
|
<el-tag v-if="scope.row.status=='qy'">启用</el-tag>
|
|
<el-tag type="info" v-if="scope.row.status=='jy'">禁用</el-tag>
|
|
<!-- <dict-tag :options="dict.type.zhzt" :value="scope.row.status"/>-->
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="创建时间" align="center" width="160" prop="updateTime">
|
|
<template slot-scope="scope">
|
|
<span>{{ parseTime(scope.row.createTime) }}</span>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="操作" align="center" width="120" fixed='right'>
|
|
<template slot-scope="scope">
|
|
<el-button
|
|
size="mini"
|
|
type="text"
|
|
icon="el-icon-edit"
|
|
@click="handleUpdate(scope.row)"
|
|
>修改</el-button>
|
|
<el-button
|
|
size="mini"
|
|
type="text"
|
|
icon="el-icon-delete"
|
|
@click="handleDelete(scope.row)"
|
|
>删除</el-button>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
|
|
<pagination
|
|
v-show="total>0"
|
|
:total="total"
|
|
:page.sync="queryParams.page"
|
|
:limit.sync="queryParams.pageSize"
|
|
@pagination="getList"
|
|
/>
|
|
</div>
|
|
</el-card>
|
|
|
|
<!-- 添加或修改对话框 -->
|
|
<el-dialog :close-on-click-modal="false" :title="title" width="40%" :visible.sync="open" append-to-body>
|
|
<el-form ref="form" :model="form" :rules="rules" label-width="90px">
|
|
<el-row>
|
|
<el-col :span="24">
|
|
<el-form-item label="方案名称" prop="name" style="width: 420px">
|
|
<el-input v-model="form.name" placeholder="请输入方案名称" maxlength="30" />
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
<el-row>
|
|
<el-col :span="24" style="display: flex;margin-bottom: 10px">
|
|
<el-form-item label="提成来源" prop="commissionSource" style="width: 420px">
|
|
<el-radio-group v-model="form.commissionSource">
|
|
<el-radio v-for="dict in dict.type.source" @change="isChange" :label="dict.value">{{ dict.label }}</el-radio>
|
|
</el-radio-group>
|
|
<!-- <el-radio-group v-model="commissionSource" ref="" @change="getCheckbox">-->
|
|
<!-- <el-checkbox-->
|
|
<!-- v-for="dict in dict.type.source"-->
|
|
<!-- :key="dict.value"-->
|
|
<!-- :label="dict.label"-->
|
|
<!-- :value="dict.value"-->
|
|
<!-- ></el-checkbox>-->
|
|
<!-- </el-radio-group>-->
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
<el-row>
|
|
<el-col :span="24">
|
|
<el-form-item label="角色组" prop="staffRoleGroup">
|
|
<el-select v-model="form.staffRoleGroup" placeholder="请选择所属角色">
|
|
<el-option
|
|
v-for="dict in dict.type.staff_role"
|
|
:key="dict.value"
|
|
:label="dict.label"
|
|
:value="dict.value"
|
|
/>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
<el-row>
|
|
<el-col :span="24">
|
|
<el-form-item label="提成类型" prop="type">
|
|
<el-radio-group v-model="form.type">
|
|
<el-radio v-for="dict in dict.type.comissionType" :label="dict.value">{{ dict.label }}</el-radio>
|
|
</el-radio-group>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
<el-row>
|
|
<el-col :span="24">
|
|
<el-form-item label="消费条件" prop="meetCondition">
|
|
<el-input v-if="form.type == 'orderAmount'" v-model="form.meetCondition">
|
|
<template slot="prepend">订单金额消费满</template>
|
|
<template slot="append">元</template>
|
|
</el-input>
|
|
<el-input v-if="form.type == 'payAmount'" v-model="form.meetCondition">
|
|
<template slot="prepend">实际金额消费满</template>
|
|
<template slot="append">元</template>
|
|
</el-input>
|
|
<el-input v-if="form.type == 'refuleNum'" v-model="form.meetCondition">
|
|
<template slot="prepend">加油数量消费满</template>
|
|
<template slot="append">单位(升/立方)</template>
|
|
</el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
<el-row>
|
|
<el-col :span="24">
|
|
<el-form-item label="油品提成" prop="royaltyRate">
|
|
<el-input v-model="form.royaltyRate" placeholder="请输入提成">
|
|
<el-select v-model="select" style="width: 70px" slot="append" placeholder="请选择">
|
|
<el-option label="元" value="元"></el-option>
|
|
<el-option label="%" value="%"></el-option>
|
|
</el-select>
|
|
</el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
<!-- <el-row>-->
|
|
<!-- <el-col :span="24">-->
|
|
<!-- <el-form-item label="生效时间" prop="takeEffect">-->
|
|
<!-- <el-date-picker-->
|
|
<!-- v-model="form.takeEffect"-->
|
|
<!-- type="daterange"-->
|
|
<!-- value-format="yyyy-MM-dd HH:mm:ss"-->
|
|
<!-- range-separator="至"-->
|
|
<!-- start-placeholder="开始日期"-->
|
|
<!-- end-placeholder="结束日期">-->
|
|
<!-- </el-date-picker>-->
|
|
<!-- <div style="font-size: 12px;color: grey">时间范围内的油品交易有效</div>-->
|
|
<!-- </el-form-item>-->
|
|
<!-- </el-col>-->
|
|
<!-- </el-row>-->
|
|
<el-row>
|
|
<el-col :span="24">
|
|
<el-form-item label="方案状态" prop="status">
|
|
<el-radio-group v-model="form.status">
|
|
<el-radio v-for="dict in dict.type.zhzt" :label="dict.value">{{ dict.label }}</el-radio>
|
|
</el-radio-group>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
<el-form-item label="备注" prop="remark">
|
|
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容"></el-input>
|
|
</el-form-item>
|
|
</el-form>
|
|
<div slot="footer" class="dialog-footer">
|
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
|
<el-button @click="cancel">取 消</el-button>
|
|
</div>
|
|
</el-dialog>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
|
|
|
|
import {
|
|
addCommission, delCommission,
|
|
getCommission,
|
|
listCommission,
|
|
queryCommission,
|
|
updateCommission
|
|
} from "@/api/staffCommission/staffcommission";
|
|
|
|
export default {
|
|
dicts: ['source','role','zhzt','comissionType','staff_role'],
|
|
data(){
|
|
return {
|
|
changeCom:false,
|
|
activeName: 'oil',
|
|
select:"元",
|
|
commissionSource:[],
|
|
// 遮罩层
|
|
loading: true,
|
|
// 标题
|
|
title: "",
|
|
// 总条数
|
|
total: 0,
|
|
// 表格数据
|
|
list: [],
|
|
// 是否显示修改对话框
|
|
open: false,
|
|
// 默认排序
|
|
defaultSort: {prop: 'updateTime', order: 'descending'},
|
|
// 查询参数
|
|
queryParams: {
|
|
page: 1,
|
|
pageSize: 10,
|
|
id: '',
|
|
name: '',
|
|
commissionSource:'油品'
|
|
},
|
|
// 表单参数
|
|
form: {
|
|
type:'orderAmount',
|
|
status:'qy'
|
|
},
|
|
// 显示搜索条件
|
|
showSearch: true,
|
|
// 表单校验
|
|
rules: {
|
|
name: [
|
|
{ required: true, message: "供应商名称不能为空", trigger: "blur" },
|
|
],
|
|
commissionSource: [
|
|
{ required: true, message: "请选择提成来源", trigger: "blur" },
|
|
],
|
|
staffRoleGroup: [
|
|
{ required: true, message: "请选择角色组", trigger: "blur" },
|
|
],
|
|
type: [
|
|
{ required: true, message: "请选择提成类型", trigger: "blur" },
|
|
],
|
|
meetCondition: [
|
|
{ required: true, message: "请填写提成消费条件", trigger: "blur" },
|
|
],
|
|
royaltyRate: [
|
|
{ required: true, message: "请填写油品提成", trigger: "blur" },
|
|
],
|
|
// takeEffect: [
|
|
// { required: true, message: "请选择方案生效时间", trigger: "change" },
|
|
// ],
|
|
status: [
|
|
{ required: true, message: "请选择方案状态", trigger: "blur" },
|
|
],
|
|
}
|
|
}
|
|
},
|
|
created() {
|
|
this.getList();
|
|
},
|
|
methods:{
|
|
// 点击标签页
|
|
handleClick(tab, event) {
|
|
if (this.activeName == 'oil'){
|
|
this.queryParams = {
|
|
page: 1,
|
|
pageSize: 10,
|
|
id: '',
|
|
name: '',
|
|
commissionSource:'油品'
|
|
};
|
|
this.getList();
|
|
}else {
|
|
this.queryParams = {
|
|
page: 1,
|
|
pageSize: 10,
|
|
id: '',
|
|
name: '',
|
|
commissionSource:'非油品'
|
|
};
|
|
this.getList();
|
|
}
|
|
},
|
|
|
|
getCheckbox(){
|
|
this.form.commissionSource = this.commissionSource.toString()
|
|
},
|
|
// 查询列表
|
|
getList() {
|
|
this.loading = true;
|
|
listCommission(this.queryParams).then(response => {
|
|
this.list = response.data.records;
|
|
this.total = response.data.total;
|
|
this.loading = false;
|
|
});
|
|
},
|
|
// 表单重置
|
|
reset() {
|
|
this.resetForm("form");
|
|
if (this.activeName == 'oil'){
|
|
this.form = {
|
|
type:'orderAmount',
|
|
status:'qy',
|
|
commissionSource:'油品'
|
|
};
|
|
}else {
|
|
this.form = {
|
|
type:'orderAmount',
|
|
status:'qy',
|
|
commissionSource:'非油品'
|
|
};
|
|
}
|
|
},
|
|
// 新增按钮操作
|
|
handleAdd() {
|
|
this.reset();
|
|
this.open = true;
|
|
this.title = "新增提成方案";
|
|
},
|
|
// 修改按钮操作
|
|
handleUpdate(row) {
|
|
this.reset();
|
|
const id = row.id || this.ids;
|
|
getCommission(id).then(response => {
|
|
this.form = response.data;
|
|
// this.commissionSource = this.form.commissionSource.split(",")
|
|
// this.form.takeEffect = JSON.parse(this.form.takeEffect)
|
|
this.form.royaltyRate = this.form.royaltyRate.slice(0,this.form.royaltyRate.length-1)
|
|
this.open = true;
|
|
this.title = "编辑提成方案";
|
|
});
|
|
},
|
|
// 删除按钮操作
|
|
handleDelete(row) {
|
|
const name = row.name
|
|
this.$modal.confirm('确定删除"' + name + '"的提成方案信息?').then(function() {
|
|
return delCommission(row.id);
|
|
}).then(() => {
|
|
this.queryParams.page = 1
|
|
this.getList();
|
|
this.$modal.msgSuccess("删除成功");
|
|
}).catch(() => {});
|
|
},
|
|
// 判断提成来源是否改变
|
|
isChange(){
|
|
this.changeCom = true;
|
|
},
|
|
add0(m){
|
|
return m<10?'0'+m:m
|
|
},
|
|
// 提交按钮
|
|
submitForm: function() {
|
|
this.$refs["form"].validate(valid => {
|
|
if (valid) {
|
|
// let date = new Date();
|
|
// let year = date.getFullYear()
|
|
// let month = date.getMonth()+1
|
|
// let day = date.getDate()
|
|
// let hour = date.getHours()
|
|
// let minutes = date.getMinutes()
|
|
// let second = date.getSeconds()
|
|
// let now = year+"-"+this.add0(month)+"-"+this.add0(day)+" "+hour+":"+minutes+":"+second
|
|
// if(this.form.takeEffect[0] < now && this.form.takeEffect[1] > now){
|
|
// this.form.status = 'qy'
|
|
// }else {
|
|
// this.form.status = 'jy'
|
|
// }
|
|
// // this.form.commissionSource = this.commissionSource.toString()
|
|
// this.form.takeEffect = JSON.stringify(this.form.takeEffect)
|
|
if (this.form.id) {
|
|
if (this.changeCom){
|
|
queryCommission(this.form).then(response => {
|
|
if (response.data != null) {
|
|
if (this.changeCom) {
|
|
this.$modal.msgError("同一个角色组只能对应一个" + this.form.commissionSource + "提成方案")
|
|
}else {
|
|
this.$modal.msgError("当前时间段已存在相同油品、相同角色组的方案")
|
|
}
|
|
} else {
|
|
this.form.royaltyRate = this.form.royaltyRate + this.select
|
|
updateCommission(this.form).then(response => {
|
|
this.$modal.msgSuccess("提成方案更新成功");
|
|
this.open = false;
|
|
this.changeCom = false;
|
|
this.getList();
|
|
});
|
|
}
|
|
})
|
|
}else {
|
|
this.form.royaltyRate = this.form.royaltyRate + this.select
|
|
updateCommission(this.form).then(response => {
|
|
this.$modal.msgSuccess("提成方案更新成功");
|
|
this.open = false;
|
|
this.getList();
|
|
});
|
|
}
|
|
} else {
|
|
queryCommission(this.form).then(response => {
|
|
if (response.data != null){
|
|
if (response.data.status == 'qy'){
|
|
this.$modal.msgError("同一个角色组只能对应一个"+this.form.commissionSource+"提成方案")
|
|
}else {
|
|
this.form.royaltyRate = this.form.royaltyRate + this.select
|
|
addCommission(this.form).then(response => {
|
|
this.$modal.msgSuccess("提成方案新增成功");
|
|
this.open = false;
|
|
this.getList();
|
|
});
|
|
}
|
|
}else {
|
|
this.form.royaltyRate = this.form.royaltyRate + this.select
|
|
addCommission(this.form).then(response => {
|
|
this.$modal.msgSuccess("提成方案新增成功");
|
|
this.open = false;
|
|
this.getList();
|
|
});
|
|
}
|
|
})
|
|
}
|
|
}
|
|
});
|
|
},
|
|
// 取消按钮
|
|
cancel() {
|
|
this.open = false;
|
|
this.reset();
|
|
},
|
|
// 多选框选中数据
|
|
handleSelectionChange(selection) {
|
|
this.ids = selection.map(item => item.id)
|
|
this.multiple = !selection.length
|
|
},
|
|
// 排序触发事件
|
|
handleSortChange(column, prop, order) {
|
|
this.queryParams.orderByColumn = column.prop;
|
|
this.queryParams.isAsc = column.order;
|
|
this.getList();
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.app-container{
|
|
width: 100%;
|
|
height: 100vh;
|
|
background: #f6f8f9;
|
|
}
|
|
</style>
|