Commit 82b14c9a by wangzhihui

预警基线管理

1 parent eef4ce17
......@@ -5,138 +5,135 @@
* @Last Modified time: 2021-06-30 14:30:41
*/
import axiosPackage from "axios";
import util from "@/libs/util.js";
import { baseConfig } from "@/main";
// import axios from "@/plugin/axios"
import axios from "@/plugin/axios/index_code"
import sign from "./sign"
import RequestMethods from "./request.methods"
import util from "@/libs/util.js"
import { baseConfig } from "@/main"
import axiosPackage from "axios"
const request = (
params = {},
method = RequestMethods.GET,
noSignAttr = [],
options = {}
) => {
// 兼容线上dj和scrm appkey和secret不一样的情况
let apiName = ""
if (params.method.includes("dj.api.smartcarlife")) {
apiName = "dj"
} else if (params.method.includes("dj.api.script")) {
apiName = "script"
} else if (params.method.includes("dj.staff.api")) {
apiName = "staff"
} else if (params.method.includes("dj.smartcarlife.stock")) {
apiName = "dj.smartcarlife"
} else if (params.method.includes("risk.manage.api")) {
apiName = "riskmanage"
} else if (params.method.includes("dj.api.strategy")) {
apiName = "strategy"
} else if (params.method.includes("dj.api.supervisor")) {
apiName = "supervisor"
} else {
// console.log(params.method.split(".api"))
apiName = params.method.split(".api")[0]
}
import axios from "@/plugin/axios/index_code";
import RequestMethods from "./request.methods";
import sign from "./sign";
// console.log("params.method", params.method)
// console.log("apiName", apiName)
// 为空报错
if (!apiName) {
throw new Error("apiName is null")
}
const mappingName = {
"dj.smartcarlife": "axios",
dj: "axios",
scrm: "axios2",
merchants: "axios3",
reportExport: "axios4",
"glsx.accounts.biz.common.pictureUpload": "common",
clue: "axios5",
"dj.businessSchool": "axios6",
script: "axios7",
staff: "axios9",
riskmanage: "axios10",
strategy: 'axios_strategy',
supervisor: 'axios_supervisor'
}
const baseApiName = mappingName[apiName]
// console.log(baseApiName, "baseApiName")
// params.appKey = baseConfig[baseApiName].appkey
if (baseApiName == "common") {
params.app_key = baseConfig[baseApiName].appkey
} else {
params.appKey = baseConfig[baseApiName].appkey
}
// console.log("params.appKey", params.appKey)
params.timestamp = new Date().getTime()
params.v = "1.0.0"
params.format = "json"
params.locale = "zh_CN"
if (params.method !== "dj.api.user.login") {
params.sessionId = util.cookies.get("token")
}
/**
* mock - url = params.method
* 调后端接口 - url = ''
*/
const url = baseConfig[baseApiName].baseURL
// const url = "/api"
/**
* 调后端接口,请使用以下代码。
*/
const signWay = {
"dj.smartcarlife": "sha1",
dj: "sha1",
scrm: "sha1",
glsx: "md5",
"glsx.accounts.biz.common.pictureUpload": "md5",
clue: "sha1",
script: "sha1",
staff: "sha1",
riskmanage: 'sha1'
}
// console.log(signWay[apiName], "baseApiName")
const secret = baseConfig[baseApiName].secret
const CancelToken = axiosPackage.CancelToken
var reqData =
method === RequestMethods.POST
? {
baseURL: "/",
data: sign(params, noSignAttr, secret, signWay[apiName])
}
: { params: sign(params, noSignAttr, secret, signWay[apiName]) }
function request(params = {}, method = RequestMethods.GET, noSignAttr = [], options = {}) {
// 兼容线上dj和scrm appkey和secret不一样的情况
let apiName = "";
if (params.method.includes("dj.api.smartcarlife")) {
apiName = "dj";
} else if (params.method.includes("dj.api.script")) {
apiName = "script";
} else if (params.method.includes("dj.staff.api")) {
apiName = "staff";
} else if (params.method.includes("dj.smartcarlife.stock")) {
apiName = "dj.smartcarlife";
} else if (params.method.includes("risk.manage.api")) {
apiName = "riskmanage";
} else if (params.method.includes("dj.api.strategy")) {
apiName = "strategy";
} else if (params.method.includes("dj.api.supervisor")) {
apiName = "supervisor";
} else {
// console.log(params.method.split(".api"))
apiName = params.method.split(".api")[0];
}
reqData = Object.assign(reqData, options, {})
// 请求进度
if (params?.onProcess) {
reqData.onUploadProgress = params.onProcess
}
// 取消请求
if (params?.cancelFun) {
reqData.cancelToken = new CancelToken(function excutor (c) {
params.cancelFun.cancel = c
})
}
// console.log(method === RequestMethods.POST)
// console.log(url)
// console.log(options)
// console.log(reqData)
let axiosParams = {
url,
method,
...reqData
}
if (options.returnAll) axiosParams.headers = { 'return-all': true }
return axios(axiosParams)
// console.log("params.method", params.method)
// console.log("apiName", apiName)
// 为空报错
if (!apiName) {
throw new Error("apiName is null");
}
const mappingName = {
"dj.smartcarlife": "axios",
"dj": "axios",
"scrm": "axios2",
"merchants": "axios3",
"reportExport": "axios4",
"glsx.accounts.biz.common.pictureUpload": "common",
"clue": "axios5",
"dj.businessSchool": "axios6",
"script": "axios7",
"staff": "axios9",
"riskmanage": "axios10",
"strategy": "axios_strategy",
"supervisor": "axios_supervisor",
};
const baseApiName = mappingName[apiName];
// console.log(baseApiName, "baseApiName")
// params.appKey = baseConfig[baseApiName].appkey
if (baseApiName == "common") {
params.app_key = baseConfig[baseApiName].appkey;
} else {
params.appKey = baseConfig[baseApiName].appkey;
}
// console.log("params.appKey", params.appKey)
params.timestamp = new Date().getTime();
params.v = "1.0.0";
params.format = "json";
params.locale = "zh_CN";
if (params.method !== "dj.api.user.login") {
params.sessionId = util.cookies.get("token");
}
/**
* mock - url = params.method
* 调后端接口 - url = ''
*/
const url = baseConfig[baseApiName].baseURL;
// const url = "/api"
/**
* 调后端接口,请使用以下代码。
*/
const signWay = {
"dj.smartcarlife": "sha1",
"dj": "sha1",
"scrm": "sha1",
"glsx": "md5",
"glsx.accounts.biz.common.pictureUpload": "md5",
"clue": "sha1",
"script": "sha1",
"staff": "sha1",
"riskmanage": "sha1",
};
// console.log(signWay[apiName], "baseApiName")
const secret = baseConfig[baseApiName].secret;
const CancelToken = axiosPackage.CancelToken;
let reqData
= method === RequestMethods.POST
? {
baseURL: "/",
data: sign(params, noSignAttr, secret, signWay[apiName]),
}
: { params: sign(params, noSignAttr, secret, signWay[apiName]) };
/**
* mock,请使用以下代码。
*/
// return axios({
// url,
// method,
// params: sign(params, noSignAttr)
// })
reqData = Object.assign(reqData, options, {});
// 请求进度
if (params?.onProcess) {
reqData.onUploadProgress = params.onProcess;
}
// 取消请求
if (params?.cancelFun) {
reqData.cancelToken = new CancelToken((c) => {
params.cancelFun.cancel = c;
});
}
// console.log(method === RequestMethods.POST)
// console.log(url)
// console.log(options)
// console.log(reqData)
let axiosParams = {
url,
method,
...reqData,
};
if (options.returnAll)
axiosParams.headers = { "return-all": true };
return axios(axiosParams);
/**
* mock,请使用以下代码。
*/
// return axios({
// url,
// method,
// params: sign(params, noSignAttr)
// })
}
export default request
export default request;
......@@ -691,7 +691,7 @@ export function getCommissionListApi(data = {}) {
}
// 获取督导管理列表数据
export function getSupervisorListApi(data = {}) {
data.method = ""
data.method = "";
return request(data, "post");
}
// 获取督导管理汇总数据
......@@ -701,31 +701,43 @@ export function getSupervisorSummaryApi(data = {}) {
}
// 获取督导详情数据
export function getSupervisorDetailApi(data = {}) {
data.method = ""
data.method = "";
return request(data, "post");
}
// 获取督导任务列表数据
export function getSupervisorTaskListApi(data = {}) {
data.method = "dj.api.supervisor.page.task"
data.method = "dj.api.supervisor.page.task";
return request(data, "post");
}
// 获取督导任务汇总数据
export function getSupervisorTaskSummaryApi(data = {}) {
data.method = "dj.api.supervisor.get.task.summary"
data.method = "dj.api.supervisor.get.task.summary";
return request(data, "post");
}
// 获取督导任务详情数据
export function getSupervisorTaskDetailApi(data = {}) {
data.method = "dj.api.supervisor.getTaskDetailById"
data.method = "dj.api.supervisor.getTaskDetailById";
return request(data, "post");
}
// 获取督导录音复盘列表数据
export function getSupervisorRecordListApi(data = {}) {
data.method = "dj.api.supervisor.page.audioReview"
data.method = "dj.api.supervisor.page.audioReview";
return request(data, "post");
}
// 获取最近三年所有周数据
export function getRecentWeekListApi(data = {}) {
data.method = "dj.api.supervisor.get.generateWeeklyRanges"
data.method = "dj.api.supervisor.get.generateWeeklyRanges";
return request(data, "post");
}
// 创建或修改预警基线配置
export function createOrUpdateBaselineConfig(data = {}) {
data.method = "dj.api.supervisor.baseline.config.createOrUpdate";
return request(data, "post");
}
// 查询所有预警基线配置
export function listAllBaselineConfigApi(data = {}) {
data.method = "dj.api.supervisor.baseline.config.listAll";
return request(data, "post");
}
<template>
<d2-dialog :is-visible="visible"
<d2-dialog class="addConfigDialog"
:is-visible="visible"
title="新增预警基线管理"
width="800px"
@closeDialog="handleClose"
......@@ -58,7 +59,7 @@
</template>
<script>
import { cancelDeduct, getScoreDetail } from "@api/point";
import { createOrUpdateBaselineConfig } from "@api/resident";
import { deepClone, Util } from "@/common/util";
export default {
......@@ -78,13 +79,13 @@ export default {
addForm: {
indicatorCode: "A036",
indicatorName: "个人产值",
timeDimension: "1",
timeDimension: 1,
configList: [],
},
configRef: "configRef",
formRules: {
indicatorCode: [{ required: true, message: "请输入撤销原因", trigger: "change" }],
timeDimension: [{ required: true, message: "请输入撤销原因", trigger: "change" }],
// indicatorCode: [{ required: true, message: "请选择指标", trigger: "change" }],
// timeDimension: [{ required: true, message: "请选择时间维度", trigger: "change" }],
},
editFormData: [
{
......@@ -92,6 +93,7 @@ export default {
name: "indicatorCode",
type: "radio",
optionList: [],
isDisabled: false,
optionId: "confId",
optionLabel: "confValue",
optionsName: "indicatorOpt",
......@@ -102,14 +104,15 @@ export default {
name: "timeDimension",
type: "radio",
optionList: [],
isDisabled: false,
optionId: "confId",
optionLabel: "confValue",
optionsName: "timeDimensionOpt",
handleRadioChange: (val) => {},
},
{
label: "预警规则:",
name: "timeDimension",
label: "预警规则",
name: "configList",
addHtml: "ruleHtml",
},
],
......@@ -121,9 +124,9 @@ export default {
},
],
timeDimensionOpt: [
{ confId: "1", confValue: "日" },
{ confId: "2", confValue: "周" },
{ confId: "3", confValue: "月" },
{ confId: 1, confValue: "日" },
{ confId: 2, confValue: "周" },
{ confId: 3, confValue: "月" },
],
},
};
......@@ -137,10 +140,13 @@ export default {
},
},
mounted() {
this.ininFormatData();
this.initFormatData();
this.getOptionsList(this, "editFormData", false);
},
methods: {
findAttrIdx(formName, attrName) {
return this[formName].findIndex(item => item.name == attrName);
},
// 表头样式
headerCellStyle() {
return {
......@@ -151,19 +157,35 @@ export default {
borderBottom: "1px solid #e2e8f0",
};
},
ininFormatData() {
let obj = {
warningLevel: 0,
minValue: "",
maxValue: null,
maxValueInf: 0,
};
for (let i = 0; i < 3; i++) {
obj.warningLevel = i;
obj.minValue = i == 0 ? 0 : "";
obj.maxValue = i == 2 ? "+∞" : "";
obj.maxValueInf = i == 2 ? 1 : 0;
this.addForm.configList.push(deepClone(obj));
initFormatData() {
console.log(this.recordInfo);
if (Object.keys(this.recordInfo).length) {
this.addForm.indicatorCode = this.recordInfo.indicatorCode;
this.addForm.indicatorName = this.recordInfo.indicatorName;
this.addForm.timeDimension = this.recordInfo.timeDimension;
if (Array.isArray(this.recordInfo.configList) && this.recordInfo.configList.length) {
this.addForm.configList = this.recordInfo.configList.map(item => ({
...item,
maxValue: item.maxValueInf == 1 ? "+∞" : item.maxValue,
}));
}
this.editFormData[this.findAttrIdx("editFormData", "indicatorCode")].isDisabled = true;
this.editFormData[this.findAttrIdx("editFormData", "timeDimension")].isDisabled = true;
} else {
const obj = {
warningLevel: 0,
minValue: "",
maxValue: null,
maxValueInf: 0,
};
for (let i = 0; i < 3; i++) {
obj.warningLevel = i;
obj.minValue = i === 0 ? 0 : "";
obj.maxValue = i === 2 ? "+∞" : "";
obj.maxValueInf = i === 2 ? 1 : 0;
this.addForm.configList.push(deepClone(obj));
}
}
},
// 预警级别文字
......@@ -283,22 +305,32 @@ export default {
this.$refs.formRef.$refs[this.configRef].validate(async (valid) => {
if (valid) {
let detailData = await getScoreDetail({ id: this.id });
let params = {};
params.remark = this.addForm.remark;
params.orderCode = detailData.orderCode;
params.scoreId = this.id;
cancelDeduct(params).then((res) => {
const configList = this.addForm.configList.map((item) => {
return {
warningLevel: item.warningLevel,
minValue: item.minValue,
maxValue: item.maxValueInf == 1 ? null : item.maxValue,
maxValueInf: item.maxValueInf,
id: item.id,
};
});
const params = {
indicatorCode: this.addForm.indicatorCode,
indicatorName: this.addForm.indicatorName,
timeDimension: this.addForm.timeDimension,
configList,
};
createOrUpdateBaselineConfig(params).then((res) => {
if (res) {
this.$emit("handleConfirm", false);
this.notice.okTips("操作成功");
this.$emit("handleAddConfirm", false);
this.$message.success("操作成功");
}
});
}
});
},
handleClose() {
this.$emit("dialogClose", false);
this.$emit("handleClose", false);
},
getOptionsList(that, formName, hasAll = true, refreshSigle) {
if (refreshSigle) {
......@@ -330,6 +362,16 @@ export default {
</script>
<style lang="scss" scoped>
.addConfigDialog {
::v-deep {
.el-dialog__header {
border-bottom: 1px solid #e5e5e5;
}
.el-dialog__footer {
border-top: 1px solid #e5e5e5;
}
}
}
.warning-level {
display: flex;
align-items: center;
......
......@@ -96,7 +96,8 @@
</template>
</el-table-column>
</el-table>
<AddConfigDialog ref="addConfigDialog"
<AddConfigDialog v-if="addConfigDialogVisible"
ref="addConfigDialog"
:record-info="recordInfo"
:visible.sync="addConfigDialogVisible"
@handleAddConfirm="handleAddConfirm"
......@@ -106,6 +107,7 @@
</template>
<script>
import { listAllBaselineConfigApi } from "@/api/resident";
import AddConfigDialog from "./addConfig.vue";
export default {
......@@ -116,166 +118,10 @@ export default {
},
data() {
return {
recordInfo: null,
recordInfo: {},
addConfigDialogVisible: false,
// 原始数据(你提供的格式)
originalData: [
{
indicatorCode: "A036",
indicatorName: "个人产值",
timeDimension: 1, // 1-日
configList: [
{
id: 101,
warningLevel: 0, // 红灯
minValue: 0,
maxValue: 1000,
maxValueInf: 0,
indicatorCode: "A036",
indicatorName: "个人产值",
timeDimension: 1,
deleteFlag: "0",
createdBy: "admin",
updatedBy: "admin",
createTime: "2024-06-01 10:00:00",
updateDate: "2024-06-01 10:00:00",
},
{
id: 102,
warningLevel: 1, // 黄灯
minValue: 1000,
maxValue: 2000,
maxValueInf: 0,
indicatorCode: "A036",
indicatorName: "个人产值",
timeDimension: 1,
deleteFlag: "0",
createdBy: "admin",
updatedBy: "admin",
createTime: "2024-06-01 10:00:00",
updateDate: "2024-06-01 10:00:00",
},
{
id: 103,
warningLevel: 2, // 绿灯
minValue: 2000,
maxValue: null,
maxValueInf: 1,
indicatorCode: "A036",
indicatorName: "个人产值",
timeDimension: 1,
deleteFlag: "0",
createdBy: "admin",
updatedBy: "admin",
createTime: "2024-06-01 10:00:00",
updateDate: "2024-06-01 10:00:00",
},
],
},
{
indicatorCode: "B102",
indicatorName: "客单价",
timeDimension: 2, // 2-周
configList: [
{
id: 201,
warningLevel: 0,
minValue: 0,
maxValue: 1000,
maxValueInf: 0,
indicatorCode: "B102",
indicatorName: "客单价",
timeDimension: 2,
deleteFlag: "0",
createdBy: "admin",
updatedBy: "ops",
createTime: "2024-06-02 09:00:00",
updateDate: "2024-06-02 09:00:00",
},
{
id: 202,
warningLevel: 1,
minValue: 1000,
maxValue: 2000,
maxValueInf: 0,
indicatorCode: "B102",
indicatorName: "客单价",
timeDimension: 2,
deleteFlag: "0",
createdBy: "admin",
updatedBy: "ops",
createTime: "2024-06-02 09:00:00",
updateDate: "2024-06-02 09:00:00",
},
{
id: 203,
warningLevel: 2,
minValue: 2000,
maxValue: null,
maxValueInf: 1,
indicatorCode: "B102",
indicatorName: "客单价",
timeDimension: 2,
deleteFlag: "0",
createdBy: "admin",
updatedBy: "ops",
createTime: "2024-06-02 09:00:00",
updateDate: "2024-06-02 09:00:00",
},
],
},
{
indicatorCode: "C210",
indicatorName: "转化率",
timeDimension: 3, // 3-月
configList: [
{
id: 301,
warningLevel: 0,
minValue: 0,
maxValue: 30,
maxValueInf: 0,
indicatorCode: "C210",
indicatorName: "转化率",
timeDimension: 3,
deleteFlag: "0",
createdBy: "pm",
updatedBy: "pm",
createTime: "2024-06-03 08:30:00",
updateDate: "2024-06-03 08:30:00",
},
{
id: 302,
warningLevel: 1,
minValue: 30,
maxValue: 50,
maxValueInf: 0,
indicatorCode: "C210",
indicatorName: "转化率",
timeDimension: 3,
deleteFlag: "0",
createdBy: "pm",
updatedBy: "pm",
createTime: "2024-06-03 08:30:00",
updateDate: "2024-06-03 08:30:00",
},
{
id: 303,
warningLevel: 2,
minValue: 50,
maxValue: null,
maxValueInf: 1,
indicatorCode: "C210",
indicatorName: "转化率",
timeDimension: 3,
deleteFlag: "0",
createdBy: "pm",
updatedBy: "pm",
createTime: "2024-06-03 08:30:00",
updateDate: "2024-06-03 08:30:00",
},
],
},
],
};
},
......@@ -302,6 +148,7 @@ export default {
indicatorCode: indicator.indicatorCode,
indicatorName: indicator.indicatorName,
timeDimension: indicator.timeDimension,
configList: configs,
});
});
});
......@@ -309,15 +156,29 @@ export default {
return flatData;
},
},
mounted() {
this.getBaseLineConfigList();
},
methods: {
handleAdd(row) {
async getBaseLineConfigList() {
try {
let result = await listAllBaselineConfigApi();
console.log("获取预警基线配置列表成功:", result);
if (result) {
this.originalData = result || [];
}
} catch (error) {
console.error("获取预警基线配置列表失败:", error);
}
},
handleAdd() {
this.addConfigDialogVisible = true;
this.recordInfo = row;
this.recordInfo = {};
},
// 合并单元格逻辑
objectSpanMethod({ row, column, rowIndex, columnIndex }) {
// 合并指标列(第1列)和时间维度列(第2列)
if (columnIndex === 0 || columnIndex === 1 || columnIndex === 2) {
if (columnIndex !== 3) {
// 获取当前指标组的起始索引
let startIndex = 0;
for (let i = 0; i < this.originalData.length; i++) {
......@@ -347,7 +208,6 @@ export default {
color: "#475569",
fontWeight: "600",
fontSize: "14px",
borderBottom: "1px solid #e2e8f0",
};
},
......@@ -411,7 +271,15 @@ export default {
});
},
handleConfig(row) {
this.recordInfo = row;
this.addConfigDialogVisible = true;
},
handleClose() {
this.addConfigDialogVisible = false;
},
handleAddConfirm() {
this.addConfigDialogVisible = false;
this.getBaseLineConfigList();
},
},
};
......@@ -461,22 +329,9 @@ export default {
padding-left: 12px;
}
.title::before {
content: "";
position: absolute;
left: 0;
top: 50%;
transform: translateY(-50%);
width: 4px;
height: 18px;
background: #2d6ee0;
border-radius: 2px;
}
/* 表格覆盖Element默认样式 */
.warning-table {
margin-left: 170px !important;
border: 1px solid #e9edf4;
// border: 1px solid #e9edf4;
width: calc(100% - 190px) !important;
}
......@@ -511,7 +366,7 @@ export default {
min-width: 48px;
font-weight: 500;
padding: 2px 0;
margin-right: 102px;
margin-right: 70px;
}
.level {
display: inline-block;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!