|
@@ -1,305 +1,252 @@
|
|
|
<template>
|
|
|
<div class="pageIndexClass">
|
|
|
- <div style="background-color: #fff; padding: 15px 15px 0">
|
|
|
- <el-form :inline="true" :model="sourceList.pagination">
|
|
|
- <el-form-item label="">
|
|
|
- <el-radio-group v-model="sourceList.pagination.current" size="default" @change="changeCurrent">
|
|
|
- <el-radio-button label="本日" />
|
|
|
- <el-radio-button label="本周" />
|
|
|
- <el-radio-button label="本月" />
|
|
|
- </el-radio-group>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="其他">
|
|
|
- <el-date-picker v-model="sourceList.pagination.beginTime" type="date" placeholder="开始日期" value-format="YYYY-MM-DD 00:00:00"
|
|
|
- :disabled-date="disabledFn" />
|
|
|
- <div style="padding:0 10px">
|
|
|
- -
|
|
|
+ <div>
|
|
|
+ <byTable :hidePagination="true" :source="sourceList.data" :pagination="sourceList.pagination" :config="config" :loading="loading"
|
|
|
+ highlight-current-row :selectConfig="selectConfig" :action-list="[]" :tableBorder="true" :span-method="objectSpanMethod"
|
|
|
+ @get-list="getList">
|
|
|
+ <template v-for="(month, index) in attrData" v-slot:[month]="{ item }" :key="month">
|
|
|
+ <div style="width:100%">
|
|
|
+ <el-input-number v-model="item[month]" :placeholder="''+monthData[index]+'月绩效'" onmousewheel="return false;" :precision="2"
|
|
|
+ :controls="false" :min="0" @change="(val)=>handleChangeVal(item,month,val)" :disabled="getIsDisabled(index)"
|
|
|
+ style="width:100%">
|
|
|
+ </el-input-number>
|
|
|
</div>
|
|
|
- <el-date-picker v-model="sourceList.pagination.endTime" type="date" placeholder="结束日期" value-format="YYYY-MM-DD 23:59:59"
|
|
|
- :disabled-date="disabledFn" />
|
|
|
- </el-form-item>
|
|
|
- <el-form-item>
|
|
|
- <el-button type="primary" @click="onQuery" class="query">搜索</el-button>
|
|
|
- <el-button @click="onReset">重置</el-button>
|
|
|
- <el-button type="primary" @click="exportExcel">导出Excel</el-button>
|
|
|
-
|
|
|
- </el-form-item>
|
|
|
- </el-form>
|
|
|
- </div>
|
|
|
- <div style="background:#fff;padding:15px;margin-top:10px">
|
|
|
- <el-table :data="sourceList.data" :height="tableHeight" style="width: 100%" v-loading="loading" border id="my-table">
|
|
|
- <el-table-column prop="groupName" label="组别" width="110" fixed="left" />
|
|
|
- <el-table-column prop="saleUserName" label="业务员" width="80" fixed="left" />
|
|
|
-
|
|
|
- <template v-if="dayList && dayList.length>0">
|
|
|
- <el-table-column v-for="col in dayList" :key="col" :label="col" align="center">
|
|
|
- <el-table-column prop="address" label="系统" min-width="100" align="right">
|
|
|
- <template #default="{ row, $index }">
|
|
|
- <div style="width: 100%" :class="today==col?'isToday':''" v-if="row[col] && row[col].sumContractAmount">
|
|
|
- {{moneyFormat(row[col].sumContractAmount,2)}}
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column prop="address" label="聚水潭" min-width="100" align="right">
|
|
|
- <template #default="{ row, $index }">
|
|
|
- <div style="width: 100%" :class="today==col?'isToday':''" v-if="row[col] && row[col].sumJstAmount">
|
|
|
- {{moneyFormat(row[col].sumJstAmount,2)}}
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- </el-table-column>
|
|
|
</template>
|
|
|
-
|
|
|
- <el-table-column width="95" align="right" fixed="right">
|
|
|
- <template #header>
|
|
|
- <div>
|
|
|
- 系统
|
|
|
- <br>
|
|
|
- 月累计
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- <template #default="{ row, $index }">
|
|
|
- <div style="width: 100%">
|
|
|
- {{moneyFormat(row.sumContractAmount,2)}}
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column width="95" align="right" fixed="right">
|
|
|
- <template #header>
|
|
|
- <div>
|
|
|
- 聚水潭
|
|
|
- <br>
|
|
|
- 月累计
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- <template #default="{ row, $index }">
|
|
|
- <div style="width: 100%">
|
|
|
- {{moneyFormat(row.sumJstAmount,2)}}
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column width="95" align="right" fixed="right">
|
|
|
- <template #header>
|
|
|
- <div>
|
|
|
- 合计
|
|
|
- <br>
|
|
|
- 月累计
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- <template #default="{ row, $index }">
|
|
|
- <div style="width: 100%">
|
|
|
- {{moneyFormat(row.sumAmount,2)}}
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column label="月目标" width="90" align="right" fixed="right">
|
|
|
- <template #default="{ row, $index }">
|
|
|
- <div style="width: 100%">
|
|
|
- {{moneyFormat(row.targetAmount,2)}}
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column label="月达成率" width="90" align="right" fixed="right">
|
|
|
- <template #default="{ row, $index }">
|
|
|
- <div style="width: 100%">
|
|
|
- {{moneyFormat(row.finishRate,2)}} %
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column prop="ranking" label="排名" width="60" align="center" fixed="right" />
|
|
|
- </el-table>
|
|
|
+ </byTable>
|
|
|
</div>
|
|
|
-
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
import byTable from "@/components/byTable/index";
|
|
|
-import { getMonthBetween } from "@/utils/date.js";
|
|
|
+import byForm from "@/components/byForm/index";
|
|
|
import moment from "moment";
|
|
|
-import FileSaver from "file-saver";
|
|
|
-import * as XLSX from "xlsx";
|
|
|
-import { nextTick } from "vue";
|
|
|
const { proxy } = getCurrentInstance();
|
|
|
-const tableHeight = ref(0);
|
|
|
-const getTableHeight = () => {
|
|
|
- tableHeight.value = window.innerHeight - 150 - 79;
|
|
|
-};
|
|
|
-getTableHeight();
|
|
|
-window.addEventListener("resize", () => {
|
|
|
- getTableHeight();
|
|
|
-});
|
|
|
-const today = ref(moment().format("yyyy-MM-DD"));
|
|
|
-const beginTime = ref(
|
|
|
- moment().startOf("month").format("yyyy-MM-DD") + " 00:00:00"
|
|
|
-);
|
|
|
-const endTime = ref(moment().endOf("month").format("YYYY-MM-DD") + " 23:59:59");
|
|
|
-const weekBegin = ref(
|
|
|
- moment().startOf("week").format("yyyy-MM-DD") + " 00:00:00"
|
|
|
-);
|
|
|
-const weekEnd = ref(moment().endOf("week").format("yyyy-MM-DD") + " 23:59:59");
|
|
|
+const loading = ref(false);
|
|
|
+const submitLoading = ref(false);
|
|
|
const sourceList = ref({
|
|
|
data: [],
|
|
|
pagination: {
|
|
|
+ total: 3,
|
|
|
pageNum: 1,
|
|
|
pageSize: 10,
|
|
|
- beginTime: "",
|
|
|
- endTime: "",
|
|
|
- current: "本月",
|
|
|
+ years: new Date().getFullYear() + "",
|
|
|
},
|
|
|
});
|
|
|
-const loading = ref(false);
|
|
|
-const getList = (req) => {
|
|
|
+const treeData = ref([]);
|
|
|
+const dialogVisible = ref(false);
|
|
|
+const modalType = ref("add");
|
|
|
+const selectConfig = computed(() => [
|
|
|
+ {
|
|
|
+ type: "time",
|
|
|
+ itemType: "year",
|
|
|
+ label: "年份",
|
|
|
+ placeholder: "请选择",
|
|
|
+ prop: "years",
|
|
|
+ placeholderOne: "结束日期",
|
|
|
+ propOne: "",
|
|
|
+ fn: (val) => {
|
|
|
+ getList();
|
|
|
+ },
|
|
|
+ },
|
|
|
+]);
|
|
|
+const config = ref([
|
|
|
+ {
|
|
|
+ attrs: {
|
|
|
+ label: "公司名称",
|
|
|
+ prop: "companyName",
|
|
|
+ width: 100,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ attrs: {
|
|
|
+ label: "部门名称",
|
|
|
+ prop: "deptName",
|
|
|
+ width: 100,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ attrs: {
|
|
|
+ label: "组别",
|
|
|
+ prop: "groupName",
|
|
|
+ width: 160,
|
|
|
+ },
|
|
|
+ },
|
|
|
+]);
|
|
|
+const formData = reactive({
|
|
|
+ data: {},
|
|
|
+});
|
|
|
+const formOption = reactive({
|
|
|
+ inline: true,
|
|
|
+ labelWidth: 100,
|
|
|
+ itemWidth: 100,
|
|
|
+});
|
|
|
+const formDom = ref(null);
|
|
|
+const formConfig = computed(() => {
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ type: "input",
|
|
|
+ prop: "code",
|
|
|
+ label: "店铺编号",
|
|
|
+ itemWidth: 100,
|
|
|
+ disabled: false,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "input",
|
|
|
+ prop: "name",
|
|
|
+ label: "店铺名称",
|
|
|
+ itemWidth: 100,
|
|
|
+ disabled: false,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "treeSelect",
|
|
|
+ prop: "deptId",
|
|
|
+ label: "负责部门",
|
|
|
+ data: treeData.value,
|
|
|
+ propsTreeLabel: "deptName",
|
|
|
+ propsTreeValue: "deptId",
|
|
|
+ itemWidth: 100,
|
|
|
+ disabled: false,
|
|
|
+ },
|
|
|
+ ];
|
|
|
+});
|
|
|
+const rules = ref({
|
|
|
+ deptId: [{ required: true, message: "请选择负责部门", trigger: "change" }],
|
|
|
+ name: [{ required: true, message: "请输入店铺名称", trigger: "blur" }],
|
|
|
+ code: [{ required: true, message: "请输入店铺编号", trigger: "blur" }],
|
|
|
+});
|
|
|
+
|
|
|
+const getList = async (req) => {
|
|
|
sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
|
|
|
loading.value = true;
|
|
|
- proxy
|
|
|
- .post("/deptPerf/monthlyReporting", sourceList.value.pagination)
|
|
|
- .then((res) => {
|
|
|
- sourceList.value.data = res;
|
|
|
- setTimeout(() => {
|
|
|
- loading.value = false;
|
|
|
- }, 500);
|
|
|
- });
|
|
|
+ proxy.post("/deptPerf/list", sourceList.value.pagination).then((res) => {
|
|
|
+ sourceList.value.data = res;
|
|
|
+ setTimeout(() => {
|
|
|
+ loading.value = false;
|
|
|
+ }, 200);
|
|
|
+ });
|
|
|
};
|
|
|
|
|
|
-const dayList = ref([]);
|
|
|
-const onQuery = () => {
|
|
|
- loading.value = true;
|
|
|
- if (
|
|
|
- sourceList.value.pagination.beginTime &&
|
|
|
- sourceList.value.pagination.endTime
|
|
|
- ) {
|
|
|
- dayList.value = getMonthBetween(
|
|
|
- sourceList.value.pagination.beginTime.slice(0, 10),
|
|
|
- sourceList.value.pagination.endTime.slice(0, 10)
|
|
|
- );
|
|
|
- nextTick(() => {
|
|
|
- setTimeout(() => scrollIntoEle(), 1000);
|
|
|
+const processesData = ref([]);
|
|
|
+const monthData = ref([
|
|
|
+ "1",
|
|
|
+ "2",
|
|
|
+ "3",
|
|
|
+ "4",
|
|
|
+ "5",
|
|
|
+ "6",
|
|
|
+ "7",
|
|
|
+ "8",
|
|
|
+ "9",
|
|
|
+ "10",
|
|
|
+ "11",
|
|
|
+ "12",
|
|
|
+]);
|
|
|
+const attrData = ref([
|
|
|
+ "january",
|
|
|
+ "february",
|
|
|
+ "march",
|
|
|
+ "april",
|
|
|
+ "may",
|
|
|
+ "june",
|
|
|
+ "july",
|
|
|
+ "august",
|
|
|
+ "september",
|
|
|
+ "october",
|
|
|
+ "november",
|
|
|
+ "december",
|
|
|
+]);
|
|
|
+const getProcesses = () => {
|
|
|
+ for (let i = 0; i < monthData.value.length; i++) {
|
|
|
+ const ele = monthData.value[i];
|
|
|
+ let attrs = {
|
|
|
+ label: `${ele}月(万元)`,
|
|
|
+ slot: attrData.value[i],
|
|
|
+ isNeedHeaderSlot: false,
|
|
|
+ "min-width": 100,
|
|
|
+ // fixed: "right",
|
|
|
+ };
|
|
|
+ config.value.push({
|
|
|
+ attrs,
|
|
|
});
|
|
|
}
|
|
|
- getList();
|
|
|
};
|
|
|
+getProcesses();
|
|
|
+getList();
|
|
|
|
|
|
-const changeCurrent = (val) => {
|
|
|
- switch (val) {
|
|
|
- case "本日":
|
|
|
- sourceList.value.pagination.beginTime = today.value + " 00:00:00";
|
|
|
- sourceList.value.pagination.endTime = today.value + " 23:59:59";
|
|
|
- break;
|
|
|
- case "本周":
|
|
|
- sourceList.value.pagination.beginTime = weekBegin.value;
|
|
|
- sourceList.value.pagination.endTime = weekEnd.value;
|
|
|
- break;
|
|
|
- case "本月":
|
|
|
- sourceList.value.pagination.beginTime = beginTime.value;
|
|
|
- sourceList.value.pagination.endTime = endTime.value;
|
|
|
- break;
|
|
|
+const objectSpanMethod = ({ rowIndex, columnIndex }) => {
|
|
|
+ if (columnIndex === 0) {
|
|
|
+ const _row = flitterData(sourceList.value.data, "companyId").one[rowIndex];
|
|
|
+ const _col = _row > 0 ? 1 : 0;
|
|
|
+ return {
|
|
|
+ rowspan: _row,
|
|
|
+ colspan: _col,
|
|
|
+ };
|
|
|
}
|
|
|
- onQuery();
|
|
|
-};
|
|
|
-
|
|
|
-const onReset = () => {
|
|
|
- sourceList.value.pagination.current = "本月";
|
|
|
- sourceList.value.pagination.beginTime = beginTime.value;
|
|
|
- sourceList.value.pagination.endTime = endTime.value;
|
|
|
- onQuery();
|
|
|
-};
|
|
|
-onReset();
|
|
|
-
|
|
|
-// const nowYearMonth = ref(moment().format("YYYY-MM"));
|
|
|
-const disabledFn = (date) => {
|
|
|
- if (
|
|
|
- moment(date).isBefore(beginTime.value) ||
|
|
|
- moment(date).isAfter(endTime.value)
|
|
|
- ) {
|
|
|
- return true;
|
|
|
- } else {
|
|
|
- return false;
|
|
|
+ if (columnIndex === 1) {
|
|
|
+ const _row = flitterData(sourceList.value.data, "deptId").one[rowIndex];
|
|
|
+ const _col = _row > 0 ? 1 : 0;
|
|
|
+ return {
|
|
|
+ rowspan: _row,
|
|
|
+ colspan: _col,
|
|
|
+ };
|
|
|
}
|
|
|
};
|
|
|
+const flitterData = (arr, att) => {
|
|
|
+ let spanOneArr = [];
|
|
|
+ let concatOne = 0;
|
|
|
+ arr.forEach((item, index) => {
|
|
|
+ if (index === 0) {
|
|
|
+ spanOneArr.push(1);
|
|
|
+ } else {
|
|
|
+ //注意这里的quarterly是表格绑定的字段,根据自己的需求来改
|
|
|
+ if (item[att] === arr[index - 1][att]) {
|
|
|
+ //第一列需合并相同内容的判断条件
|
|
|
+ spanOneArr[concatOne] += 1;
|
|
|
+ spanOneArr.push(0);
|
|
|
+ } else {
|
|
|
+ spanOneArr.push(1);
|
|
|
+ concatOne = index;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return {
|
|
|
+ one: spanOneArr,
|
|
|
+ };
|
|
|
+};
|
|
|
|
|
|
-const scrollIntoEle = () => {
|
|
|
- let eles = document.querySelectorAll(".isToday");
|
|
|
- if (eles && eles[0]) {
|
|
|
- eles[0].scrollIntoView({
|
|
|
- // behavior: "smooth",
|
|
|
- block: "start",
|
|
|
- inline: "start",
|
|
|
+const handleChangeVal = (item, month, val) => {
|
|
|
+ if (val) {
|
|
|
+ const data = {
|
|
|
+ ...item,
|
|
|
+ id: item.id,
|
|
|
+ deptId: item.deptId,
|
|
|
+ groupId: item.groupId,
|
|
|
+ years: sourceList.value.pagination.years,
|
|
|
+ };
|
|
|
+ data[month] = val;
|
|
|
+ proxy.post("/deptPerf/edit", data).then((res) => {
|
|
|
+ // proxy.msgTip("配置成功");
|
|
|
+ // getList();
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-const exportExcel = () => {
|
|
|
- proxy.msgTip("正在导出,请稍后", 2);
|
|
|
- const wb = XLSX.utils.table_to_book(document.querySelector("#my-table")); // 关联dom节点
|
|
|
- // 设置百分比列的单元格样式
|
|
|
- const percentStyle = {
|
|
|
- font: { bold: true },
|
|
|
- fill: { fgColor: { rgb: "FFFF00" } },
|
|
|
- border: { top: { style: "thin" }, bottom: { style: "thin" } },
|
|
|
- };
|
|
|
-
|
|
|
- if (wb.Sheets.Sheet1) {
|
|
|
- // 达成率单元格的key开头
|
|
|
- let cellKey = "";
|
|
|
- for (const key in wb.Sheets.Sheet1) {
|
|
|
- let value = wb.Sheets.Sheet1[key];
|
|
|
- if (value && value.v == "月达成率") {
|
|
|
- cellKey = key.match(/[a-zA-Z]+/g)[0];
|
|
|
- }
|
|
|
- // key有包含cellKey的
|
|
|
- if (cellKey && key.includes(cellKey)) {
|
|
|
- // 单元格的样式
|
|
|
- wb.Sheets.Sheet1[key].s = percentStyle;
|
|
|
- // 用于指定单元格中显示值的格式,例如日期格式、百分比格式等
|
|
|
- wb.Sheets.Sheet1[key].z = "0.00%";
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- const wbout = XLSX.write(wb, {
|
|
|
- bookType: "xlsx",
|
|
|
- bookSST: true,
|
|
|
- type: "array",
|
|
|
- });
|
|
|
- try {
|
|
|
- FileSaver.saveAs(
|
|
|
- new Blob([wbout], {
|
|
|
- type: "application/octet-stream",
|
|
|
- }),
|
|
|
- "销售报表.xlsx"
|
|
|
- );
|
|
|
- } catch (e) {
|
|
|
- console.log(e, wbout);
|
|
|
+let date = new Date();
|
|
|
+const getIsDisabled = (index) => {
|
|
|
+ let currentMonth = monthData.value[index];
|
|
|
+ let year = sourceList.value.pagination.years;
|
|
|
+ let nowYear = date.getFullYear();
|
|
|
+ let nowMonth = date.getMonth() + 1;
|
|
|
+ if (Number(year) < nowYear) {
|
|
|
+ return true;
|
|
|
+ } else if (Number(year) == nowYear && Number(currentMonth) < nowMonth) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
}
|
|
|
- return wbout;
|
|
|
};
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
-:deep(
|
|
|
- .el-table .el-table__header-wrapper th,
|
|
|
- .el-table .el-table__fixed-header-wrapper th
|
|
|
- ) {
|
|
|
- height: auto !important;
|
|
|
-}
|
|
|
-:deep(.el-table th.el-table__cell) {
|
|
|
- background: #fff !important;
|
|
|
-}
|
|
|
-:deep(.el-table .el-table__cell) {
|
|
|
- padding: 0 !important;
|
|
|
-}
|
|
|
-:deep(.el-table .cell) {
|
|
|
- padding: 0 6px !important;
|
|
|
- font-size: 12px !important;
|
|
|
-}
|
|
|
-.query {
|
|
|
- background: #20b2aa;
|
|
|
- color: #fff;
|
|
|
- border: 1px solid #20b2aa;
|
|
|
-}
|
|
|
-.isToday {
|
|
|
- // background: red !important;
|
|
|
- // color: #fff !important;
|
|
|
- color: #409eff;
|
|
|
-}
|
|
|
-</style>
|
|
|
+</style>
|