还款计算修改
parent
df135edb0b
commit
16a3098cc1
@ -1,213 +1,214 @@
|
||||
<template>
|
||||
<el-dialog :close-on-click-model="false" v-dialogDrag :title="staffTitle" :visible.sync="dialogVisible" width="500px" append-to-body>
|
||||
<el-button size="mini" type="primary" @click="add()">添加</el-button>
|
||||
<el-button size="mini" type="primary" @click="del()">删除</el-button>
|
||||
<div class="flex">
|
||||
<el-table :data="list" max-height="600">
|
||||
<el-table-column align="center" :label="staffTitle">
|
||||
<el-table-column min-width="140" align="center" label="员工">
|
||||
<template slot-scope="scope">
|
||||
<el-select filterable default-first-option v-model="scope.row.label" placeholder="请选择" @change="editChange($event,scope.$index)">
|
||||
<el-option v-for="item in options" :key="item.id" :label="item.label" :value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column min-width="100" align="center" label="占比">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-focus type="number" @blur="endEdit(scope.row,scope.$index)" :disabled="scope.$index==0" size="samll" v-model="scope.row.ratio"></el-input>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button size="mini" type="primary" plain @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button size="mini" type="primary" @click="confirms()">确 定
|
||||
</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { selectList, selectListType, QuerCompetent } from "@/api/eashier.js";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false, //弹窗开关
|
||||
staffList: [],
|
||||
list: [], //主数组
|
||||
form: {}, //主对象
|
||||
options: [{ label: "10001-刘乐乐" }],
|
||||
staffText: "",
|
||||
staffTitle: "",
|
||||
staffListCopy: [],
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
add() {
|
||||
this.list.push({});
|
||||
this.changeStaff();
|
||||
},
|
||||
endEdit(row, index) {
|
||||
if (!row.ratio) {
|
||||
row.ratio = 0;
|
||||
}
|
||||
row.ratio = row.ratio * 1;
|
||||
let number = 0;
|
||||
this.list.forEach((item, index) => {
|
||||
if (index != 0) {
|
||||
number += item.ratio * 1;
|
||||
}
|
||||
});
|
||||
this.list[0].ratio = 100 - number;
|
||||
this.changeStaff();
|
||||
},
|
||||
editChange(e, index) {
|
||||
let row = this.list[index];
|
||||
let form = {};
|
||||
this.options.forEach((item) => {
|
||||
if (e == item.id) {
|
||||
form = { ...item };
|
||||
}
|
||||
});
|
||||
if (row.ratio > 0) {
|
||||
form.ratio = row.ratio;
|
||||
}
|
||||
this.list.splice(index, 1, form);
|
||||
|
||||
console.log(this.options);
|
||||
this.changeStaff();
|
||||
},
|
||||
del() {
|
||||
let index = this.list.length - 1;
|
||||
this.list[0].ratio += this.list[index].ratio;
|
||||
this.list.splice(index, 1);
|
||||
this.changeStaff();
|
||||
},
|
||||
//组件传值
|
||||
show(form, text) {
|
||||
this.list = [];
|
||||
this.form = { ...form };
|
||||
this.staffText = text;
|
||||
if (text == "zhonggongList") {
|
||||
this.staffTitle = "美发师";
|
||||
}
|
||||
if (text == "largeList") {
|
||||
this.staffTitle = "美容师";
|
||||
}
|
||||
if (text == "smallList") {
|
||||
this.staffTitle = "助理";
|
||||
}
|
||||
if (text == "technicianList") {
|
||||
this.staffTitle = "技师";
|
||||
}
|
||||
if (text == "adminList") {
|
||||
this.staffTitle = "门店管理层";
|
||||
}
|
||||
if (text == "managerList") {
|
||||
this.staffTitle = "高管";
|
||||
}
|
||||
this.list = form[text];
|
||||
this.list.forEach((item) => {
|
||||
if (item.id) {
|
||||
item.label = item.brandNumber + "-" + item.staffName;
|
||||
}
|
||||
});
|
||||
this.dialogVisible = true;
|
||||
this.getData();
|
||||
this.changeStaff();
|
||||
this.endEdit()
|
||||
},
|
||||
changeStaff() {
|
||||
var that = this;
|
||||
console.log(that.list);
|
||||
console.log(that.staffListCopy);
|
||||
var list = that.list.concat(that.staffListCopy).filter(function (v) {
|
||||
return (
|
||||
that.list.indexOf(v) === -1 || that.staffListCopy.indexOf(v) === -1
|
||||
);
|
||||
});
|
||||
this.options = list;
|
||||
},
|
||||
//获取数据
|
||||
async getData() {
|
||||
if (this.text == "adminList") {
|
||||
selectListType({ type: 0 }).then((res) => {
|
||||
if (res.code == "000000") {
|
||||
res.rows.forEach((item) => {
|
||||
item.label = item.brandNumber + "-" + item.staffName;
|
||||
item.ratio = 100;
|
||||
delete item.state;
|
||||
});
|
||||
this.options = res.rows;
|
||||
this.staffListCopy = res.rows;
|
||||
} else {
|
||||
this.$alert(res.message, "加载员工提示", {
|
||||
confirmButtonText: "确定",
|
||||
confirmButtonClass: "confirmbtnFalses",
|
||||
type: "warning",
|
||||
center: true,
|
||||
callback: (action) => {},
|
||||
});
|
||||
}
|
||||
});
|
||||
} else if (this.text == "managerList") {
|
||||
QuerCompetent({ type: 0, pageSize: 999 }).then((res) => {
|
||||
if (res.code == "000000") {
|
||||
res.pageInfo.list.forEach((item) => {
|
||||
item.label = item.brandNumber + "-" + item.staffName;
|
||||
item.ratio = 100;
|
||||
delete item.state;
|
||||
});
|
||||
this.options = res.pageInfo.list;
|
||||
this.staffListCopy = res.pageInfo.list;
|
||||
} else {
|
||||
this.$alert(res.message, "加载高管提示", {
|
||||
confirmButtonText: "确定",
|
||||
confirmButtonClass: "confirmbtnFalses",
|
||||
type: "warning",
|
||||
center: true,
|
||||
callback: (action) => {},
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
let form = { id: "" };
|
||||
if (this.staffName) {
|
||||
form.staffName = this.staffName;
|
||||
}
|
||||
selectList(form).then((res) => {
|
||||
if (res.code == "000000") {
|
||||
res.rows.forEach((item) => {
|
||||
item.label = item.brandNumber + "-" + item.staffName;
|
||||
item.ratio = 0;
|
||||
});
|
||||
this.options = res.rows;
|
||||
this.staffListCopy = res.rows;
|
||||
} else {
|
||||
this.$alert(res.message, "提示", {
|
||||
confirmButtonText: "确定",
|
||||
confirmButtonClass: "confirmbtnFalses",
|
||||
type: "warning",
|
||||
center: true,
|
||||
callback: (action) => {},
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
confirms() {
|
||||
let form = {
|
||||
text: this.staffText,
|
||||
list: this.list,
|
||||
};
|
||||
this.$emit("staffratioData", form);
|
||||
this.dialogVisible = false;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
</style>
|
||||
<template>
|
||||
<el-dialog :close-on-click-model="false" v-dialogDrag :title="staffTitle" :visible.sync="dialogVisible" width="500px" append-to-body>
|
||||
<el-button size="mini" type="primary" @click="add()">添加</el-button>
|
||||
<el-button size="mini" type="primary" @click="del()">删除</el-button>
|
||||
<div class="flex">
|
||||
<el-table :data="list" max-height="600">
|
||||
<el-table-column align="center" :label="staffTitle">
|
||||
<el-table-column min-width="140" align="center" label="员工">
|
||||
<template slot-scope="scope">
|
||||
<el-select filterable default-first-option v-model="scope.row.label" placeholder="请选择" @change="editChange($event,scope.$index)">
|
||||
<el-option v-for="item in options" :key="item.id" :label="item.label" :value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column min-width="100" align="center" label="占比">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-focus type="number" @blur="endEdit(scope.row,scope.$index)" :disabled="scope.$index==0" size="samll" v-model="scope.row.ratio"></el-input>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button size="mini" type="primary" plain @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button size="mini" type="primary" @click="confirms()">确 定
|
||||
</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { selectList, selectListType, QuerCompetent } from "@/api/eashier.js";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false, //弹窗开关
|
||||
staffList: [],
|
||||
list: [], //主数组
|
||||
form: {}, //主对象
|
||||
options: [{ label: "10001-刘乐乐" }],
|
||||
staffText: "",
|
||||
staffTitle: "",
|
||||
staffListCopy: [],
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
add() {
|
||||
this.list.push({});
|
||||
this.changeStaff();
|
||||
},
|
||||
endEdit(row, index) {
|
||||
if (row.ratio || row.ratio * 1 < 101) {
|
||||
row.ratio = row.ratio * 1;
|
||||
} else {
|
||||
row.ratio = 0;
|
||||
}
|
||||
let number = 0;
|
||||
this.list.forEach((item, index) => {
|
||||
if (index != 0) {
|
||||
number += item.ratio * 1;
|
||||
}
|
||||
});
|
||||
this.list[0].ratio = 100 - number;
|
||||
this.changeStaff();
|
||||
},
|
||||
editChange(e, index) {
|
||||
let row = this.list[index];
|
||||
let form = {};
|
||||
this.options.forEach((item) => {
|
||||
if (e == item.id) {
|
||||
form = { ...item };
|
||||
}
|
||||
});
|
||||
if (row.ratio > 0) {
|
||||
form.ratio = row.ratio;
|
||||
}
|
||||
this.list.splice(index, 1, form);
|
||||
|
||||
console.log(this.options);
|
||||
this.changeStaff();
|
||||
},
|
||||
del() {
|
||||
let index = this.list.length - 1;
|
||||
this.list[0].ratio += this.list[index].ratio;
|
||||
this.list.splice(index, 1);
|
||||
this.changeStaff();
|
||||
},
|
||||
//组件传值
|
||||
show(form, text) {
|
||||
this.list = [];
|
||||
this.form = { ...form };
|
||||
this.staffText = text;
|
||||
if (text == "zhonggongList") {
|
||||
this.staffTitle = "美发师";
|
||||
}
|
||||
if (text == "largeList") {
|
||||
this.staffTitle = "美容师";
|
||||
}
|
||||
if (text == "smallList") {
|
||||
this.staffTitle = "助理";
|
||||
}
|
||||
if (text == "technicianList") {
|
||||
this.staffTitle = "技师";
|
||||
}
|
||||
if (text == "adminList") {
|
||||
this.staffTitle = "门店管理层";
|
||||
}
|
||||
if (text == "managerList") {
|
||||
this.staffTitle = "高管";
|
||||
}
|
||||
this.list = form[text];
|
||||
this.list.forEach((item) => {
|
||||
if (item.id) {
|
||||
item.label = item.brandNumber + "-" + item.staffName;
|
||||
}
|
||||
});
|
||||
this.dialogVisible = true;
|
||||
this.getData();
|
||||
this.changeStaff();
|
||||
this.endEdit();
|
||||
},
|
||||
changeStaff() {
|
||||
var that = this;
|
||||
console.log(that.list);
|
||||
console.log(that.staffListCopy);
|
||||
var list = that.list.concat(that.staffListCopy).filter(function (v) {
|
||||
return (
|
||||
that.list.indexOf(v) === -1 || that.staffListCopy.indexOf(v) === -1
|
||||
);
|
||||
});
|
||||
this.options = list;
|
||||
},
|
||||
//获取数据
|
||||
async getData() {
|
||||
if (this.text == "adminList") {
|
||||
selectListType({ type: 0 }).then((res) => {
|
||||
if (res.code == "000000") {
|
||||
res.rows.forEach((item) => {
|
||||
item.label = item.brandNumber + "-" + item.staffName;
|
||||
item.ratio = 100;
|
||||
delete item.state;
|
||||
});
|
||||
this.options = res.rows;
|
||||
this.staffListCopy = res.rows;
|
||||
} else {
|
||||
this.$alert(res.message, "加载员工提示", {
|
||||
confirmButtonText: "确定",
|
||||
confirmButtonClass: "confirmbtnFalses",
|
||||
type: "warning",
|
||||
center: true,
|
||||
callback: (action) => {},
|
||||
});
|
||||
}
|
||||
});
|
||||
} else if (this.text == "managerList") {
|
||||
QuerCompetent({ type: 0, pageSize: 999 }).then((res) => {
|
||||
if (res.code == "000000") {
|
||||
res.pageInfo.list.forEach((item) => {
|
||||
item.label = item.brandNumber + "-" + item.staffName;
|
||||
item.ratio = 100;
|
||||
delete item.state;
|
||||
});
|
||||
this.options = res.pageInfo.list;
|
||||
this.staffListCopy = res.pageInfo.list;
|
||||
} else {
|
||||
this.$alert(res.message, "加载高管提示", {
|
||||
confirmButtonText: "确定",
|
||||
confirmButtonClass: "confirmbtnFalses",
|
||||
type: "warning",
|
||||
center: true,
|
||||
callback: (action) => {},
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
let form = { id: "" };
|
||||
if (this.staffName) {
|
||||
form.staffName = this.staffName;
|
||||
}
|
||||
selectList(form).then((res) => {
|
||||
if (res.code == "000000") {
|
||||
res.rows.forEach((item) => {
|
||||
item.label = item.brandNumber + "-" + item.staffName;
|
||||
item.ratio = 0;
|
||||
});
|
||||
this.options = res.rows;
|
||||
this.staffListCopy = res.rows;
|
||||
} else {
|
||||
this.$alert(res.message, "提示", {
|
||||
confirmButtonText: "确定",
|
||||
confirmButtonClass: "confirmbtnFalses",
|
||||
type: "warning",
|
||||
center: true,
|
||||
callback: (action) => {},
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
confirms() {
|
||||
let form = {
|
||||
text: this.staffText,
|
||||
list: this.list,
|
||||
};
|
||||
this.$emit("staffratioData", form);
|
||||
this.dialogVisible = false;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
</style>
|
||||
|
||||
Loading…
Reference in New Issue