From 44142f71f24c52b9aff1ffba61fbbf226f9fbfa4 Mon Sep 17 00:00:00 2001 From: yunkexin <760754045@qq.com> Date: Wed, 27 Mar 2024 17:10:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=A9=E5=B1=95=E5=81=87=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CustomPages/BI/BI001HomeDetail.js | 341 +++- .../CustomPages/BI/BI054HomeDetail.js | 645 ++++++-- .../CustomPages/BI/BI055HomeDetail.js | 878 ++++++++--- src/routes/Home.js | 37 +- src/utils/common.js | 1382 +++++++++++------ 5 files changed, 2374 insertions(+), 909 deletions(-) diff --git a/src/components/CustomPages/BI/BI001HomeDetail.js b/src/components/CustomPages/BI/BI001HomeDetail.js index 341b1d1..3559670 100644 --- a/src/components/CustomPages/BI/BI001HomeDetail.js +++ b/src/components/CustomPages/BI/BI001HomeDetail.js @@ -9,6 +9,7 @@ import { extendOrder, extend, initQueryFilter, + getSixMonth } from "../../../utils/common"; import { Table, @@ -28,7 +29,161 @@ class BI001HomeDetail extends React.Component { super(props); this.state = { pagination: {}, - retData: [], + retData: [ + { + shopDoneCount: 1541, + shopDoneRate: 99.94, + shopId: "b53266f6-2ba9-9b30-e96f-f9893a48376d", + shopName: "安环科", + shopOntimeCount: 1437, + shopOverDoneRate: 93.19, + shopTotalCount: 1542, + teamDoneCount: 1541, + teamDoneRate: 99.94, + teamId: "45aba808-c12c-b785-fa09-f9acd9922785", + teamName: "民爆储存库班组", + teamOntimeCount: 1437, + teamOverDoneRate: 93.19, + teamTotalCount: 1542, + teamUndoneCount: 1, + }, + { + shopDoneCount: 2792, + shopDoneRate: 99.29, + shopId: "72e83a49-5319-0784-d1ed-025d309b87eb", + shopName: "穿爆车间", + shopOntimeCount: 2080, + shopOverDoneRate: 73.97, + shopTotalCount: 2812, + teamDoneCount: 1466, + teamDoneRate: 99.93, + teamId: "c671778d-dd76-080f-51d1-5dc5ca698419", + teamName: "爆破班组", + teamOntimeCount: 1286, + teamOverDoneRate: 87.66, + teamTotalCount: 1467, + teamUndoneCount: 1, + }, + { + shopDoneCount: 2792, + shopDoneRate: 99.29, + shopId: "72e83a49-5319-0784-d1ed-025d309b87eb", + shopName: "穿爆车间", + shopOntimeCount: 2080, + shopOverDoneRate: 73.97, + shopTotalCount: 2812, + teamDoneCount: 1326, + teamDoneRate: 98.59, + teamId: "821a4fe3-5513-681e-ed3c-e61836b29638", + teamName: "穿孔班组", + teamOntimeCount: 794, + teamOverDoneRate: 59.03, + teamTotalCount: 1345, + teamUndoneCount: 19, + }, + { + shopDoneCount: 15056, + shopDoneRate: 99.87, + shopId: "30ce4b63-9971-c8d3-a2b4-ca4f51cf0fab", + shopName: "金宇宁化分公司", + shopOntimeCount: 9755, + shopOverDoneRate: 64.71, + shopTotalCount: 15075, + teamDoneCount: 1768, + teamDoneRate: 100, + teamId: "bcdca284-6373-6862-083e-645030a2315d", + teamName: "维修班组", + teamOntimeCount: 1254, + teamOverDoneRate: 70.93, + teamTotalCount: 1768, + teamUndoneCount: 0, + }, + { + shopDoneCount: 15056, + shopDoneRate: 99.87, + shopId: "30ce4b63-9971-c8d3-a2b4-ca4f51cf0fab", + shopName: "金宇宁化分公司", + shopOntimeCount: 9755, + shopOverDoneRate: 64.71, + shopTotalCount: 15075, + teamDoneCount: 4927, + teamDoneRate: 99.78, + teamId: "0270fa34-4849-4429-35e8-5fb8b98c9fc9", + teamName: "金宇现场", + teamOntimeCount: 3482, + teamOverDoneRate: 70.51, + teamTotalCount: 4938, + teamUndoneCount: 11, + }, + { + shopDoneCount: 15056, + shopDoneRate: 99.87, + shopId: "30ce4b63-9971-c8d3-a2b4-ca4f51cf0fab", + shopName: "金宇宁化分公司", + shopOntimeCount: 9755, + shopOverDoneRate: 64.71, + shopTotalCount: 15075, + teamDoneCount: 2903, + teamDoneRate: 99.93, + teamId: "8ba1fb97-540b-d451-881a-39f632700975", + teamName: "运输二班", + teamOntimeCount: 1854, + teamOverDoneRate: 63.82, + teamTotalCount: 2905, + teamUndoneCount: 2, + }, + { + shopDoneCount: 15056, + shopDoneRate: 99.87, + shopId: "30ce4b63-9971-c8d3-a2b4-ca4f51cf0fab", + shopName: "金宇宁化分公司", + shopOntimeCount: 9755, + shopOverDoneRate: 64.71, + shopTotalCount: 15075, + teamDoneCount: 5458, + teamDoneRate: 99.89, + teamId: "db1ccb4a-0ffa-63c9-9384-c3d9139e8c8f", + teamName: "运输一班", + teamOntimeCount: 3165, + teamOverDoneRate: 57.92, + teamTotalCount: 5464, + teamUndoneCount: 6, + }, + { + shopDoneCount: 2066, + shopDoneRate: 100, + shopId: "4adbdf10-3cce-ac8a-4abf-104bc12f882a", + shopName: "生产技术科", + shopOntimeCount: 1969, + shopOverDoneRate: 95.3, + shopTotalCount: 2066, + teamDoneCount: 2066, + teamDoneRate: 100, + teamId: "91f40319-fd33-6b72-dfb5-b51b21abac54", + teamName: "生产班", + teamOntimeCount: 1969, + teamOverDoneRate: 95.3, + teamTotalCount: 2066, + teamUndoneCount: 0, + }, + { + shopDoneCount: 2253, + shopDoneRate: 99.96, + shopId: "a144c298-17ef-e105-5cb7-34991ca7b3c2", + shopName: "综合组", + shopOntimeCount: 1488, + shopOverDoneRate: 66.02, + shopTotalCount: 2254, + teamDoneCount: 2253, + teamDoneRate: 99.96, + teamId: "9e171704-f1af-9de4-0287-476216371c16", + teamName: "综合班组", + teamOntimeCount: 1488, + teamOverDoneRate: 66.02, + teamTotalCount: 2254, + teamUndoneCount: 1, + }, + ], columns1: [ // { // title: '序号', @@ -147,7 +302,7 @@ class BI001HomeDetail extends React.Component { { title: "班组", dataIndex: "teamName", - onCell:()=>this.renderSpeedColumn() + onCell: () => this.renderSpeedColumn(), }, { title: "总任务数", @@ -202,13 +357,119 @@ class BI001HomeDetail extends React.Component { componentDidMount() { this.loadData(); } - renderSpeedColumn = ()=>{ - return { className: 'redTableCell'} - } + renderSpeedColumn = () => { + return { className: "redTableCell" }; + }; loadData = () => { this.state.showLoading = true; let param = this.props?.login?.currActivatedMenu?.MENU_FORM_PARAMS; - this.chart1(); + this.chartReal(); + }; + chartReal = () => { + let month = []; + let company = [ + 100, 100, 100, 99.69, 99.86, 100, 99.94, 100, 100, 99.57, 99.56, 99.17, + ]; + let department = [ + 68.79, 58.8, 56.28, 69.59, 69.03, 71.58, 71.08, 75.05, 76.26, 77.09, + 77.84, 80.51, + ]; + for (let i = 0; i < 12; i++) { + month.unshift(getSixMonth(-i, "-", "")); + } + let myChart = echarts.init(document.getElementById("chartClass")); + myChart.setOption({ + tooltip: { + trigger: "axis", + formatter: function (params) { + let temp = ""; + params.forEach((t) => { + temp = + temp + t.marker + t.seriesName + ":" + t.value + "%" + "
"; + }); + return temp; + }, + }, + title: { + text: "班组活动任务完成走势图", + left: "center", + top: "5%", + }, + // label: { + // show: true, + // position: 'top' + // }, + legend: { + // data: ['部门'], + data: ["完成率", "及时完成率"], + bottom: "10px", + }, + grid: { + left: "3%", + right: "4%", + top: "15%", + containLabel: true, + }, + toolbox: { + feature: { + // saveAsImage: {} + }, + }, + xAxis: { + type: "category", + data: month, + axisLabel: { + showMaxLabel: true, + }, + }, + yAxis: { + type: "value", + axisLabel: { + formatter: function (val) { + return val + "%"; + }, + }, + }, + series: [ + { + name: "完成率", + type: "line", + color: "#4b9bf3", + data: company, + smooth: true, + // symbol:'none', + }, + { + name: "及时完成率", + type: "line", + color: "#FCD149", + data: department, + areaStyle: {}, + areaStyle: { + color: { + type: "linear", + x: 0, + y: 0, + x2: 0, + y2: 1, + colorStops: [ + { + offset: 0, + color: "#FCD149", // 0% 处的颜色 + }, + { + offset: 1, + color: "#fff", // 100% 处的颜色 + }, + ], + global: false, + }, + }, + smooth: true, + symbol: "circle", + }, + ], + }); }; //矿山 chart1 = () => { @@ -235,13 +496,19 @@ class BI001HomeDetail extends React.Component { tooltip: { trigger: "axis", formatter: function (params) { - let temp='' - params.forEach(t=>{ - temp=temp+t.marker + t.seriesName +":"+t.value+"%"+'
'; - - }) + let temp = ""; + params.forEach((t) => { + temp = + temp + + t.marker + + t.seriesName + + ":" + + t.value + + "%" + + "
"; + }); return temp; - } + }, }, title: { text: "班组活动任务完成走势图", @@ -290,7 +557,7 @@ class BI001HomeDetail extends React.Component { color: "#4b9bf3", data: company, smooth: true, - // symbol:'none', + // symbol:'none', }, { name: "及时完成率", @@ -300,21 +567,26 @@ class BI001HomeDetail extends React.Component { areaStyle: {}, areaStyle: { color: { - type: 'linear', - x: 0, - y: 0, - x2: 0, - y2: 1, - colorStops: [{ - offset: 0, color: "#FCD149" // 0% 处的颜色 - }, { - offset: 1, color: '#fff' // 100% 处的颜色 - }], - global: false - } - }, + type: "linear", + x: 0, + y: 0, + x2: 0, + y2: 1, + colorStops: [ + { + offset: 0, + color: "#FCD149", // 0% 处的颜色 + }, + { + offset: 1, + color: "#fff", // 100% 处的颜色 + }, + ], + global: false, + }, + }, smooth: true, - symbol:'circle', + symbol: "circle", }, ], }); @@ -360,10 +632,13 @@ class BI001HomeDetail extends React.Component {
-
+
@@ -374,9 +649,11 @@ class BI001HomeDetail extends React.Component {
this.getBaseInfoData(1, this.state.tableKey, 5), 120000); - }; + } componentDidMount() { - this.loadData() + // this.loadData() + this.hiddenDangerTotal(); + this.loadReal(); } componentWillUnmount() { // this.timerID && clearTimeout(this.timerID); } + loadReal = () => { + let result = { + ListSafeCheckCountDepartment: [ + { + DepartmentName: "穿孔班组", + DepartmentType: 2, + NUM: 1, + Parent: { + DepartmentName: "穿爆车间", + RowCount: 2, + listCount: [51, 751, 0, 0, 0], + }, + Percent: 0, + RowCount: 1, + listCount: [0, 350, 0, 0, 0], + listName: [ + "巡回检查", + "例行检查", + "专业检查", + "综合检查", + "综合检查", + ], + }, + { + DepartmentName: "爆破班组", + DepartmentType: 2, + NUM: 2, + Parent: { + DepartmentName: "穿爆车间", + RowCount: 2, + listCount: [51, 751, 0, 0, 0], + }, + Percent: 0, + RowCount: 1, + listCount: [0, 350, 0, 0, 0], + listName: [ + "巡回检查", + "例行检查", + "专业检查", + "综合检查", + "综合检查", + ], + }, + { + DepartmentName: "生产班", + DepartmentType: 2, + Department_ID: "97ee9944-74e6-6c99-d4c3-9e48f29beb98", + NUM: 3, + PARENT_ID: "72e83a49-5319-0784-d1ed-025d309b87eb", + Parent: { + DepartmentName: "生产技术科", + RowCount: 1, + listCount: [51, 522, 0, 0, 0], + }, + Percent: 0, + RowCount: 1, + listCount: [0, 349, 0, 0, 0], + listName: [ + "巡回检查", + "例行检查", + "专业检查", + "综合检查", + "综合检查", + ], + }, + { + DepartmentName: "综合班组", + DepartmentType: 2, + NUM: 4, + Parent: { + DepartmentName: "综合组", + RowCount: 1, + listCount: [0, 349, 0, 0, 0], + }, + Percent: 0, + RowCount: 1, + listCount: [0, 349, 0, 0, 0], + listName: [ + "巡回检查", + "例行检查", + "专业检查", + "综合检查", + "综合检查", + ], + }, + { + DepartmentName: "采制样班", + DepartmentType: 2, + NUM: 5, + Parent: { + DepartmentName: "试验化验室", + RowCount: 2, + listCount: [0, 0, 0, 0, 0], + }, + Percent: 0, + RowCount: 1, + listCount: [0, 0, 0, 0, 0], + listName: [ + "巡回检查", + "例行检查", + "专业检查", + "综合检查", + "综合检查", + ], + }, + { + DepartmentName: "化验班", + DepartmentType: 2, + Department_ID: "97ee9944-74e6-6c99-d4c3-9e48f29beb98", + NUM: 6, + PARENT_ID: "72e83a49-5319-0784-d1ed-025d309b87eb", + Parent: { + DepartmentName: "试验化验室", + RowCount: 2, + listCount: [0, 0, 0, 0, 0], + }, + Percent: 0, + RowCount: 1, + listCount:[0, 0, 0, 0, 0], + listName: [ + "巡回检查", + "例行检查", + "专业检查", + "综合检查", + "综合检查", + ], + }, + { + DepartmentName: "维修班组", + DepartmentType: 2, + Department_ID: "97ee9944-74e6-6c99-d4c3-9e48f29beb98", + NUM: 7, + PARENT_ID: "72e83a49-5319-0784-d1ed-025d309b87eb", + Parent: { + DepartmentName: "金宇宁化分公司", + RowCount: 4, + listCount: [51, 1452, 0, 0, 0], + }, + Percent: 0, + RowCount: 1, + listCount: [0, 351, 0, 0, 0], + listName: [ + "巡回检查", + "例行检查", + "专业检查", + "综合检查", + "综合检查", + ], + }, + { + DepartmentName: "金宇现场", + DepartmentType: 2, + Department_ID: "97ee9944-74e6-6c99-d4c3-9e48f29beb98", + NUM: 8, + PARENT_ID: "72e83a49-5319-0784-d1ed-025d309b87eb", + Parent: { + DepartmentName: "金宇宁化分公司", + RowCount: 4, + listCount: [51, 1452, 0, 0, 0], + }, + Percent: 0, + RowCount: 1, + listCount: [0, 350, 0, 0, 0], + listName: [ + "巡回检查", + "例行检查", + "专业检查", + "综合检查", + "综合检查", + ], + }, + { + DepartmentName: "运输二班", + DepartmentType: 2, + Department_ID: "97ee9944-74e6-6c99-d4c3-9e48f29beb98", + NUM: 9, + PARENT_ID: "72e83a49-5319-0784-d1ed-025d309b87eb", + Parent: { + DepartmentName: "金宇宁化分公司", + RowCount: 4, + listCount: [51, 1452, 0, 0, 0], + }, + Percent: 0, + RowCount: 1, + listCount: [0, 350, 0, 0, 0], + listName: [ + "巡回检查", + "例行检查", + "专业检查", + "综合检查", + "综合检查", + ], + }, + { + DepartmentName: "运输一班", + DepartmentType: 2, + Department_ID: "97ee9944-74e6-6c99-d4c3-9e48f29beb98", + NUM: 10, + PARENT_ID: "72e83a49-5319-0784-d1ed-025d309b87eb", + Parent: { + DepartmentName: "金宇宁化分公司", + RowCount: 4, + listCount: [51, 1452, 0, 0, 0], + }, + Percent: 0, + RowCount: 1, + listCount: [0, 350, 0, 0, 0], + listName: [ + "巡回检查", + "例行检查", + "专业检查", + "综合检查", + "综合检查", + ], + }, + { + DepartmentName: "民爆储存库班组", + DepartmentType: 2, + Department_ID: "97ee9944-74e6-6c99-d4c3-9e48f29beb98", + NUM: 11, + PARENT_ID: "72e83a49-5319-0784-d1ed-025d309b87eb", + Parent: { + DepartmentName: "安环科", + RowCount: 1, + listCount: [52, 400, 2, 1, 1], + }, + Percent: 0, + RowCount: 1, + listCount: [0, 349, 0, 0, 0], + listName: [ + "巡回检查", + "例行检查", + "专业检查", + "综合检查", + "综合检查", + ], + }, + + ], + ListSafeCheckYearMonth: [], + }; + if ( + result.ListSafeCheckCountDepartment != null && + result.ListSafeCheckCountDepartment.length > 0 + ) { + // listName.push('车间名称') + // result.ListSafeCheckCountDepartment[0].listName.forEach((e, i) => { + // listName.push(e) + // }) + + // listName.push('班组名称') + // result.ListSafeCheckCountDepartment[0].listChild[0].listName.forEach(e => { + // listName.push(e) + // }) + + var countTypeTitle = []; + var columnsTb = []; + if ( + result.ListSafeCheckCountDepartment != null && + result.ListSafeCheckCountDepartment.length > 0 + ) { + countTypeTitle = result.ListSafeCheckCountDepartment[0].listName; + } + + if (countTypeTitle.length < 1) { + countTypeTitle.push("巡回检查"); + countTypeTitle.push("例行检查"); + countTypeTitle.push("专业检查"); + countTypeTitle.push("综合检查"); + } + + var typeName = ["车间名称", "班组名称"]; + var RowCount = 0; + + for (let i = 0; i < 2; i++) { + for (let j = 0; j < countTypeTitle.length; j++) { + if (i == 0) { + if (j == 0) { + //头部 + columnsTb.push({ + title: typeName[i], + dataIndex: "NUM", + key: i * 10 + j, + render: (value, record, index) => { + RowCount = record.Parent.RowCount; + if ( + index > 0 && + result.ListSafeCheckCountDepartment[index - 1].Parent + .DepartmentName == record.Parent.DepartmentName + ) { + RowCount = 0; + } + const obj = { + children: record.Parent.DepartmentName, + props: { + rowSpan: RowCount, + }, + }; + return obj; + }, + }); + } + + //非头部 + + columnsTb.push({ + title: countTypeTitle[j], + dataIndex: "NUM", + key: i * 10 + j, + render: (value, record, index) => { + RowCount = record.Parent.RowCount; + if ( + index > 0 && + result.ListSafeCheckCountDepartment[index - 1].Parent + .DepartmentName == record.Parent.DepartmentName + ) { + RowCount = 0; + } + const obj = { + children: record.Parent.listCount[j], + props: { + rowSpan: RowCount, + }, + }; + return obj; + }, + }); + } else { + //班组 + if (j == 0) { + columnsTb.push({ + title: typeName[i], + key: i * 10 + j, + render: (value, record, index) => { + const obj = { + children: record.DepartmentName, + }; + return obj; + }, + }); + } + + columnsTb.push({ + title: countTypeTitle[j], + key: i * 10 + j, + render: (value, record, index) => { + const obj = { + children: record.listCount[j], + }; + return obj; + }, + }); + } + } + } + + this.setState({ + data: { + countTypeTitle: countTypeTitle, + columnsTb: columnsTb, + // listName: listName, + ListSafeCheckYearMonth: result.ListSafeCheckYearMonth, + ListSafeCheckCountDepartment: result.ListSafeCheckCountDepartment, //车间 子集是 班组 + }, + }); + } + }; //加载数据赋值 loadData = () => { this.state.showLoading = true; // let json = initFilter(this.props.login.OrgId, this.props.data.mineType, "NUM"); - let json = initFilter(this.props.login.OrgId,'', "NUM"); + let json = initFilter(this.props.login.OrgId, "", "NUM"); this.props.dispatch({ - type: 'app/getDataByPost', + type: "app/getDataByPost", payload: json, - url: 'BI/BIHome/GetHomeDetailMonthCheckType', + url: "BI/BIHome/GetHomeDetailMonthCheckType", onComplete: (result) => { if (result) { // let listName = [] - if (result.ListSafeCheckCountDepartment != null && result.ListSafeCheckCountDepartment.length > 0) { + if ( + result.ListSafeCheckCountDepartment != null && + result.ListSafeCheckCountDepartment.length > 0 + ) { // listName.push('车间名称') // result.ListSafeCheckCountDepartment[0].listName.forEach((e, i) => { // listName.push(e) @@ -76,21 +457,24 @@ class BI054HomeDetail extends React.Component { // listName.push(e) // }) - var countTypeTitle = [] - var columnsTb = [] - if (result.ListSafeCheckCountDepartment != null && result.ListSafeCheckCountDepartment.length > 0) { - countTypeTitle = result.ListSafeCheckCountDepartment[0].listName + var countTypeTitle = []; + var columnsTb = []; + if ( + result.ListSafeCheckCountDepartment != null && + result.ListSafeCheckCountDepartment.length > 0 + ) { + countTypeTitle = result.ListSafeCheckCountDepartment[0].listName; } if (countTypeTitle.length < 1) { - countTypeTitle.push('巡回检查') - countTypeTitle.push('例行检查') - countTypeTitle.push('专业检查') - countTypeTitle.push('综合检查') + countTypeTitle.push("巡回检查"); + countTypeTitle.push("例行检查"); + countTypeTitle.push("专业检查"); + countTypeTitle.push("综合检查"); } - var typeName = ['车间名称', '班组名称'] - var RowCount = 0 + var typeName = ["车间名称", "班组名称"]; + var RowCount = 0; for (let i = 0; i < 2; i++) { for (let j = 0; j < countTypeTitle.length; j++) { @@ -100,21 +484,25 @@ class BI054HomeDetail extends React.Component { columnsTb.push({ title: typeName[i], dataIndex: "NUM", - key: (i * 10 + j), + key: i * 10 + j, render: (value, record, index) => { - RowCount = record.Parent.RowCount - if (index > 0 && result.ListSafeCheckCountDepartment[index - 1].Parent.DepartmentName == record.Parent.DepartmentName) { - RowCount = 0 + RowCount = record.Parent.RowCount; + if ( + index > 0 && + result.ListSafeCheckCountDepartment[index - 1].Parent + .DepartmentName == record.Parent.DepartmentName + ) { + RowCount = 0; } const obj = { children: record.Parent.DepartmentName, props: { - 'rowSpan': RowCount + rowSpan: RowCount, }, }; return obj; - } - }) + }, + }); } //非头部 @@ -122,101 +510,112 @@ class BI054HomeDetail extends React.Component { columnsTb.push({ title: countTypeTitle[j], dataIndex: "NUM", - key: (i * 10 + j), + key: i * 10 + j, render: (value, record, index) => { - RowCount = record.Parent.RowCount - if (index > 0 && result.ListSafeCheckCountDepartment[index - 1].Parent.DepartmentName == record.Parent.DepartmentName) { - RowCount = 0 + RowCount = record.Parent.RowCount; + if ( + index > 0 && + result.ListSafeCheckCountDepartment[index - 1].Parent + .DepartmentName == record.Parent.DepartmentName + ) { + RowCount = 0; } const obj = { children: record.Parent.listCount[j], props: { - 'rowSpan': RowCount + rowSpan: RowCount, }, }; return obj; - } - }) - - + }, + }); } else { //班组 if (j == 0) { columnsTb.push({ title: typeName[i], - key: (i * 10 + j), + key: i * 10 + j, render: (value, record, index) => { const obj = { children: record.DepartmentName, }; return obj; - } - }) + }, + }); } columnsTb.push({ title: countTypeTitle[j], - key: (i * 10 + j), + key: i * 10 + j, render: (value, record, index) => { const obj = { children: record.listCount[j], }; return obj; - } - }) - + }, + }); } } } - this.setState({ data: { countTypeTitle: countTypeTitle, columnsTb: columnsTb, // listName: listName, ListSafeCheckYearMonth: result.ListSafeCheckYearMonth, - ListSafeCheckCountDepartment: result.ListSafeCheckCountDepartment,//车间 子集是 班组 - } - }) - this.hiddenDangerTotal() + ListSafeCheckCountDepartment: + result.ListSafeCheckCountDepartment, //车间 子集是 班组 + }, + }); + this.hiddenDangerTotal(); } - } - } - }) + }, + }); this.state.showLoading = false; - } + }; hiddenDangerTotal = () => { - if (this.state.data.ListSafeCheckYearMonth) { - let data = this.state.data.ListSafeCheckYearMonth; + let xData = []; - let data1 = []; - let data2 = []; - let data3 = []; - let seriesName = []; - data.map((item) => { - if (item.MONTH>9){ - xData.push(item.YEAR+'-'+ item.MONTH); - }else{ - xData.push(item.YEAR+'-0'+ item.MONTH); - } - seriesName = item.listSOURCENAME; - data1.push(item.listListCount); - }); - - for (var i = 0; i < data[0].listListCount.length; i++) { - for (var j = 0; j < data.length; j++) { - data2.push(data1[j][i]); - } + let data3 = [ + [17, 20, 16, 20, 16, 16, 20, 16, 16, 20, 16, 12], + [317, 330, 316, 330, 292, 286, 299, 286, 295, 299, 223, 201], + [0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + ]; + for (let i = 0; i < 12; i++) { + xData.unshift(getSixMonth(-i, "-", "")); } + let seriesName = [ + "巡回检查", + "例行检查", + "专业检查", + "综合检查", + "综合检查", + ]; + // data.map((item) => { + // if (item.MONTH>9){ + // xData.push(item.YEAR+'-'+ item.MONTH); + // }else{ + // xData.push(item.YEAR+'-0'+ item.MONTH); + // } + // seriesName = item.listSOURCENAME; + // data1.push(item.listListCount); + // }); - for (var i = 0; i < data2.length; i += data.length) { - data3.push(data2.slice(i, i + data.length)); - } + // for (var i = 0; i < data[0].listListCount.length; i++) { + // for (var j = 0; j < data.length; j++) { + // data2.push(data1[j][i]); + // } + // } + // for (var i = 0; i < data2.length; i += data.length) { + // data3.push(data2.slice(i, i + data.length)); + // } let series = []; for (let i = 0; i < data3.length; i++) { series.push({ @@ -301,33 +700,55 @@ class BI054HomeDetail extends React.Component { series: series, }); } - } + }; render() { const { data } = this.state; - return
- -
- -
-
-
- - - + return ( +
+ +
+ +
+
+
+ + + - - - + + + +
+
+ -
-
- - - {/*
+ {/*
{ @@ -386,12 +807,12 @@ class BI054HomeDetail extends React.Component {
*/} - - - - -
- + + + +
+ + ); } } -export default connect(({ login, app }) => ({ login, app }))(BI054HomeDetail) +export default connect(({ login, app }) => ({ login, app }))(BI054HomeDetail); diff --git a/src/components/CustomPages/BI/BI055HomeDetail.js b/src/components/CustomPages/BI/BI055HomeDetail.js index 28c1077..9f1035c 100644 --- a/src/components/CustomPages/BI/BI055HomeDetail.js +++ b/src/components/CustomPages/BI/BI055HomeDetail.js @@ -1,10 +1,20 @@ -import React from 'react' -import { connect } from 'dva' -import { initFilter, extendRule, extendInclude, getIsPC, openNotificationMobile } from "../../../utils/common" -import { ChartBarShow_Vertical, LineShow } from "../../../utils/commonEcharsShow" -import { Table, Row, Progress, Col } from 'antd'; -import echarts from 'echarts'; -import styles from '../HI/StepForm.css'; +import React from "react"; +import { connect } from "dva"; +import { + initFilter, + extendRule, + extendInclude, + getIsPC, + openNotificationMobile, + getSixMonth, +} from "../../../utils/common"; +import { + ChartBarShow_Vertical, + LineShow, +} from "../../../utils/commonEcharsShow"; +import { Table, Row, Progress, Col } from "antd"; +import echarts from "echarts"; +import styles from "../HI/StepForm.css"; const formItemLayout = { labelCol: { span: 6 }, @@ -27,25 +37,375 @@ class BI055HomeDetail extends React.Component { componenthidMount() { if (!getIsPC()) { - openNotificationMobile('bottomRight', notification) - this.state.displayStr = 'none'; + openNotificationMobile("bottomRight", notification); + this.state.displayStr = "none"; this.state.displayNum = 24; } else { - this.state.displayStr = ''; + this.state.displayStr = ""; this.state.displayNum = 16; } - this.loadData() + this.loadReal(); //定时器功能,暂时不开启 // this.timerID = setInterval(() => this.getBaseInfoData(1, this.state.tableKey, 5), 120000); - }; + } componentDidMount() { - this.loadData(); + this.loadReal(); } + loadReal = () => { + let data = { + IsSuccessful: true, + Data: { + ListC: [], + ListSafeCheckYearMonth: [ + { + DepartmentName: "穿孔班组", + NUM: 1, + Parent: { + DepartmentName: "穿爆车间", + RowCount: 2, + listCount: [0, 0, 0, 10000], + }, + RowCount: 1, + listCount: [0, 0, 0, 10000], + listName: [ + "按时整改隐患", + "超期整改隐患", + "未整改隐患", + "隐患整改率", + ], + }, + { + DepartmentName: "爆破班组", + NUM: 2, + Parent: { + DepartmentName: "穿爆车间", + RowCount: 2, + listCount: [0, 0, 0, 10000], + }, + RowCount: 1, + listCount: [0, 0, 0, 10000], + listName: [ + "按时整改隐患", + "超期整改隐患", + "未整改隐患", + "隐患整改率", + ], + }, + { + DepartmentName: "生产班", + NUM: 3, + Parent: { + DepartmentName: "生产技术科", + RowCount: 1, + listCount: [6, 4, 0, 10000], + }, + RowCount: 1, + listCount: [4, 1, 0, 10000], + listName: [ + "按时整改隐患", + "超期整改隐患", + "未整改隐患", + "隐患整改率", + ], + }, + { + DepartmentName: "综合班组", + NUM: 4, + Parent: { + DepartmentName: "综合组", + RowCount: 1, + listCount: [3, 4, 0, 10000], + }, + RowCount: 1, + listCount: [3, 4, 0, 10000], + listName: [ + "按时整改隐患", + "超期整改隐患", + "未整改隐患", + "隐患整改率", + ], + }, + { + DepartmentName: "采制样班", + NUM: 5, + Parent: { + DepartmentName: "试验化验室", + RowCount: 2, + listCount: [0, 0, 0, 10000], + }, + RowCount: 1, + listCount: [0, 0, 0, 10000], + listName: [ + "按时整改隐患", + "超期整改隐患", + "未整改隐患", + "隐患整改率", + ], + }, + { + DepartmentName: "化验班", + NUM: 6, + Parent: { + DepartmentName: "试验化验室", + RowCount: 2, + listCount: [0, 0, 0, 10000], + }, + RowCount: 1, + listCount: [0, 0, 0, 10000], + listName: [ + "按时整改隐患", + "超期整改隐患", + "未整改隐患", + "隐患整改率", + ], + }, + { + DepartmentName: "维修班组", + NUM: 7, + Parent: { + DepartmentName: "金宇宁化分公司", + RowCount: 4, + listCount: [6, 7, 0, 10000], + }, + RowCount: 1, + listCount: [0, 0, 0, 10000], + listName: [ + "按时整改隐患", + "超期整改隐患", + "未整改隐患", + "隐患整改率", + ], + }, + { + DepartmentName: "金宇现场", + NUM: 8, + Parent: { + DepartmentName: "金宇宁化分公司", + RowCount: 4, + listCount: [6, 7, 0, 10000], + }, + RowCount: 1, + listCount: [2, 0, 0, 10000], + listName: [ + "按时整改隐患", + "超期整改隐患", + "未整改隐患", + "隐患整改率", + ], + }, + { + DepartmentName: "运输二班", + NUM: 9, + Parent: { + DepartmentName: "金宇宁化分公司", + RowCount: 4, + listCount: [6, 7, 0, 10000], + }, + RowCount: 1, + listCount: [1, 1, 0, 10000], + listName: [ + "按时整改隐患", + "超期整改隐患", + "未整改隐患", + "隐患整改率", + ], + }, + { + DepartmentName: "运输一班", + NUM: 10, + Parent: { + DepartmentName: "金宇宁化分公司", + RowCount: 4, + listCount: [6, 7, 0, 10000], + }, + RowCount: 1, + listCount: [1, 0, 0, 10000], + listName: [ + "按时整改隐患", + "超期整改隐患", + "未整改隐患", + "隐患整改率", + ], + }, + { + DepartmentName: "民爆储存库班组", + NUM: 11, + Parent: { + DepartmentName: "安环科", + RowCount: 1, + listCount: [2, 1, 0, 10000], + }, + RowCount: 1, + listCount: [0, 0, 0, 10000], + listName: [ + "按时整改隐患", + "超期整改隐患", + "未整改隐患", + "隐患整改率", + ], + }, + ], + }, + }; + var countTypeTitle = []; + var countTypeDataIndex = []; + var columnsTb = []; + if ( + data.Data.ListSafeCheckYearMonth != null && + data.Data.ListSafeCheckYearMonth.length > 0 + ) { + countTypeTitle = data.Data.ListSafeCheckYearMonth[0].listName; + } + + if (countTypeTitle.length < 1) { + countTypeTitle.push("按时整改隐患"); + countTypeTitle.push("超期整改隐患"); + countTypeTitle.push("未整改隐患"); + countTypeTitle.push("隐患整改率"); + } + + var typeName = ["车间名称", "班组名称"]; + var RowCount = 0; + for (let i = 0; i < 2; i++) { + for (let j = 0; j < countTypeTitle.length; j++) { + countTypeDataIndex.push(j); + if (i == 0) { + if (j == 0) { + //头部 + columnsTb.push({ + title: typeName[i], + dataIndex: "NUM", + key: i * 10 + j, + render: (value, record, index) => { + RowCount = record.Parent.RowCount; + if ( + index > 0 && + this.state.ListSafeCheckYearMonth[index - 1].Parent + .DepartmentName == record.Parent.DepartmentName + ) { + RowCount = 0; + } + const obj = { + children: record.Parent.DepartmentName, + props: { + rowSpan: RowCount, + }, + }; + return obj; + }, + }); + } + + //非头部 + if (countTypeTitle[j].indexOf("率") > -1) { + columnsTb.push({ + title: countTypeTitle[j], + dataIndex: "NUM", + key: i * 10 + j, + render: (value, record, index) => { + RowCount = record.Parent.RowCount; + if ( + index > 0 && + this.state.ListSafeCheckYearMonth[index - 1].Parent + .DepartmentName == record.Parent.DepartmentName + ) { + RowCount = 0; + } + const obj = { + children: ( + + ), + props: { + rowSpan: RowCount, + }, + }; + return obj; + }, + }); + } else { + columnsTb.push({ + title: countTypeTitle[j], + dataIndex: "NUM", + key: i * 10 + j, + render: (value, record, index) => { + RowCount = record.Parent.RowCount; + if ( + index > 0 && + this.state.ListSafeCheckYearMonth[index - 1].Parent + .DepartmentName == record.Parent.DepartmentName + ) { + RowCount = 0; + } + const obj = { + children: record.Parent.listCount[j], + props: { + rowSpan: RowCount, + }, + }; + return obj; + }, + }); + } + } else { + //班组 + if (j == 0) { + columnsTb.push({ + title: typeName[i], + key: i * 10 + j, + render: (value, record, index) => { + const obj = { + children: record.DepartmentName, + }; + return obj; + }, + }); + } + + if (countTypeTitle[j].indexOf("率") > -1) { + columnsTb.push({ + title: countTypeTitle[j], + key: i * 10 + j, + render: (text, record) => ( + + ), + }); + } else { + columnsTb.push({ + title: countTypeTitle[j], + key: i * 10 + j, + render: (value, record, index) => { + const obj = { + children: record.listCount[j], + }; + return obj; + }, + }); + } + } + } + } + + this.setState({ + countTypeTitle: countTypeTitle, + columnsTb: columnsTb, + ListC: data.Data.ListC, + ListSafeCheckYearMonth: data.Data.ListSafeCheckYearMonth, + }); + this.safeChekDanger(); + }; renderSpeedColumn = () => { - return { className: 'redTableCell' } - } + return { className: "redTableCell" }; + }; loadData = () => { this.state.showLoading = true; // var mineType = '' @@ -55,7 +415,7 @@ class BI055HomeDetail extends React.Component { // } else { // mineType = this.props.formParam.mineType; // } - + let json = initFilter(this.props.login.OrgId); this.props.dispatch({ type: "app/getDataByPost", @@ -63,109 +423,134 @@ class BI055HomeDetail extends React.Component { payload: json, onlyData: false, onComplete: (data) => { - if (data && data.IsSuccessful && data.Data && (data.Data.ListC || data.Data.ListSafeCheckYearMonth)) { - var countTypeTitle = [] - var countTypeDataIndex = [] - var columnsTb = [] - if (data.Data.ListSafeCheckYearMonth != null && data.Data.ListSafeCheckYearMonth.length > 0) { - countTypeTitle = data.Data.ListSafeCheckYearMonth[0].listName + if ( + data && + data.IsSuccessful && + data.Data && + (data.Data.ListC || data.Data.ListSafeCheckYearMonth) + ) { + var countTypeTitle = []; + var countTypeDataIndex = []; + var columnsTb = []; + if ( + data.Data.ListSafeCheckYearMonth != null && + data.Data.ListSafeCheckYearMonth.length > 0 + ) { + countTypeTitle = data.Data.ListSafeCheckYearMonth[0].listName; } if (countTypeTitle.length < 1) { - countTypeTitle.push('按时整改隐患') - countTypeTitle.push('超期整改隐患') - countTypeTitle.push('未整改隐患') - countTypeTitle.push('隐患整改率') + countTypeTitle.push("按时整改隐患"); + countTypeTitle.push("超期整改隐患"); + countTypeTitle.push("未整改隐患"); + countTypeTitle.push("隐患整改率"); } - var typeName = ['车间名称', '班组名称'] - var RowCount = 0 + var typeName = ["车间名称", "班组名称"]; + var RowCount = 0; for (let i = 0; i < 2; i++) { for (let j = 0; j < countTypeTitle.length; j++) { - countTypeDataIndex.push(j) + countTypeDataIndex.push(j); if (i == 0) { if (j == 0) { //头部 columnsTb.push({ title: typeName[i], dataIndex: "NUM", - key: (i * 10 + j), + key: i * 10 + j, render: (value, record, index) => { - RowCount = record.Parent.RowCount - if (index > 0 && this.state.ListSafeCheckYearMonth[index - 1].Parent.DepartmentName == record.Parent.DepartmentName) { - RowCount = 0 + RowCount = record.Parent.RowCount; + if ( + index > 0 && + this.state.ListSafeCheckYearMonth[index - 1].Parent + .DepartmentName == record.Parent.DepartmentName + ) { + RowCount = 0; } const obj = { children: record.Parent.DepartmentName, props: { - 'rowSpan': RowCount + rowSpan: RowCount, }, }; return obj; - } - }) + }, + }); } //非头部 - if (countTypeTitle[j].indexOf('率') > -1) { + if (countTypeTitle[j].indexOf("率") > -1) { columnsTb.push({ title: countTypeTitle[j], dataIndex: "NUM", - key: (i * 10 + j), + key: i * 10 + j, render: (value, record, index) => { - RowCount = record.Parent.RowCount - if (index > 0 && this.state.ListSafeCheckYearMonth[index - 1].Parent.DepartmentName == record.Parent.DepartmentName) { - RowCount = 0 + RowCount = record.Parent.RowCount; + if ( + index > 0 && + this.state.ListSafeCheckYearMonth[index - 1].Parent + .DepartmentName == record.Parent.DepartmentName + ) { + RowCount = 0; } const obj = { - children: , + children: ( + + ), props: { - 'rowSpan': RowCount, + rowSpan: RowCount, }, }; return obj; - } - }) + }, + }); } else { columnsTb.push({ title: countTypeTitle[j], dataIndex: "NUM", - key: (i * 10 + j), + key: i * 10 + j, render: (value, record, index) => { - RowCount = record.Parent.RowCount - if (index > 0 && this.state.ListSafeCheckYearMonth[index - 1].Parent.DepartmentName == record.Parent.DepartmentName) { - RowCount = 0 + RowCount = record.Parent.RowCount; + if ( + index > 0 && + this.state.ListSafeCheckYearMonth[index - 1].Parent + .DepartmentName == record.Parent.DepartmentName + ) { + RowCount = 0; } const obj = { children: record.Parent.listCount[j], props: { - 'rowSpan': RowCount + rowSpan: RowCount, }, }; return obj; - } - }) + }, + }); } - } else { //班组 if (j == 0) { columnsTb.push({ title: typeName[i], - key: (i * 10 + j), + key: i * 10 + j, render: (value, record, index) => { const obj = { children: record.DepartmentName, }; return obj; - } - }) + }, + }); } - if (countTypeTitle[j].indexOf('率') > -1) { + if (countTypeTitle[j].indexOf("率") > -1) { columnsTb.push({ title: countTypeTitle[j], - key: (i * 10 + j), + key: i * 10 + j, render: (text, record) => ( ), - }) - + }); } else { columnsTb.push({ title: countTypeTitle[j], - key: (i * 10 + j), + key: i * 10 + j, render: (value, record, index) => { const obj = { children: record.listCount[j], }; return obj; - } - }) + }, + }); } - } } } - this.setState({ countTypeTitle: countTypeTitle, columnsTb: columnsTb, @@ -200,8 +582,7 @@ class BI055HomeDetail extends React.Component { ListSafeCheckYearMonth: data.Data.ListSafeCheckYearMonth, }); - this.safeChekDanger() - + this.safeChekDanger(); } }, }); @@ -218,184 +599,223 @@ class BI055HomeDetail extends React.Component { // 安全检查和隐患整改 safeChekDanger = () => { let xData = []; - let ydata = []; - let sourceName = []; - if (this.state.ListC) { - this.state.ListC.map((item) => { - let name = item.NAME.split(","); - xData.push(name); - sourceName.push(item.SOURCENAME); - let valu = item.Val.split(","); - ydata.push(valu); - }); - let safeInspections = document.getElementById("safeInspection2"); - if (safeInspections) { - let myChart = echarts.init(safeInspections); - myChart.setOption( - { - color: ["#72b85b", "#f6841a", "#cc0404", "#4285F4"], - tooltip: { - trigger: "axis", - axisPointer: { - // 坐标轴指示器,坐标轴触发有效 - type: "shadow", // 默认为直线,可选为:'line' | 'shadow' - }, - transitionDuration: 0, - formatter: function (params) { - return ( - params[0].name + - "
" + - params[0].marker + - params[0].seriesName + - " : " + - params[0].value + - "
" + - params[1].marker + - params[1].seriesName + - " : " + - params[1].value + - "
" + - params[2].marker + - params[2].seriesName + - " : " + - params[2].value + - "
" + - params[3].marker + - params[3].seriesName + - " : " + - params[3].value + - "%" - ); + for (let i = 0; i < 12; i++) { + xData.unshift(getSixMonth(-i, "-", "")); + } + let ydata = [ + ["3", "2", "2", "3", "2", "0", "2", "5", "6", "8", "0", "5"], + ["5", "4", "0", "1", "0", "0", "1", "7", "1", "0", "0", "2"], + ["0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0"], + [ + "100.00", + "100.00", + "100.00", + "100.00", + "100.00", + "100.00", + "100.00", + "100.00", + "100.00", + "100.00", + "100.00", + "100.00", + ], + ]; + let sourceName = [ + ["按时整改隐患", "超期整改隐患", "未整改隐患", "隐患整改率"], + ]; + // if (this.state.ListC) { + // this.state.ListC.map((item) => { + // let name = item.NAME.split(","); + // xData.push(name); + // sourceName.push(item.SOURCENAME); + // let valu = item.Val.split(","); + // ydata.push(valu); + // }); + let safeInspections = document.getElementById("safeInspection2"); + if (safeInspections) { + let myChart = echarts.init(safeInspections); + myChart.setOption( + { + color: ["#72b85b", "#f6841a", "#cc0404", "#4285F4"], + tooltip: { + trigger: "axis", + axisPointer: { + // 坐标轴指示器,坐标轴触发有效 + type: "shadow", // 默认为直线,可选为:'line' | 'shadow' + }, + transitionDuration: 0, + formatter: function (params) { + return ( + params[0].name + + "
" + + params[0].marker + + params[0].seriesName + + " : " + + params[0].value + + "
" + + params[1].marker + + params[1].seriesName + + " : " + + params[1].value + + "
" + + params[2].marker + + params[2].seriesName + + " : " + + params[2].value + + "
" + + params[3].marker + + params[3].seriesName + + " : " + + params[3].value + + "%" + ); + }, + }, + grid: { + left: "10%", + // right: "10%", + bottom: "15%", + top: "5%", + containLabel: true, + z: 22, + }, + xAxis: { + type: "category", + data: xData, + axisLine: { + lineStyle: { + color: "#0c3b71", }, }, - grid: { - left: "10%", - // right: "10%", - bottom: "15%", - top: "5%", - containLabel: true, - z: 22, + axisLabel: { + show: true, + color: "rgb(170,170,170)", + interval: 0, + textStyle: { + lineHeight: 14, + }, }, - xAxis: { - type: "category", - data: xData[0], + }, + legend: { + data: sourceName, + left: "center", + align: "left", + bottom: "2%", + textStyle: { + color: "#000", + }, + itemWidth: 10, + itemHeight: 10, + // itemGap: 35, + }, + yAxis: [ + { + type: "value", + position: "left", + splitLine: { + show: true, + lineStyle: { + color: ["#f2f2f2"], + // opacity:0.2 + // zlevel: -1, + }, + }, axisLine: { lineStyle: { color: "#0c3b71", }, }, axisLabel: { - show: true, color: "rgb(170,170,170)", - interval: 0, - textStyle: { - lineHeight: 14, - }, + formatter: "{value} ", }, }, - legend: { - data: sourceName, - left: "center", - align: "left", - bottom: "2%", - textStyle: { - color: "#000", + { + type: "value", + position: "right", + splitLine: { + show: false, + lineStyle: { + color: ["#f2f2f2"], + }, + }, + axisLine: { + lineStyle: { + color: "#f2f2f2", + }, + }, + axisLabel: { + color: "rgb(170,170,170)", + formatter: "{value} %", }, - itemWidth: 10, - itemHeight: 10, - // itemGap: 35, }, - yAxis: [ - { - type: "value", - position: "left", - splitLine: { - show: true, - lineStyle: { - color: ["#f2f2f2"], - // opacity:0.2 - // zlevel: -1, - }, - }, - axisLine: { - lineStyle: { - color: "#0c3b71", - }, - }, - axisLabel: { - color: "rgb(170,170,170)", - formatter: "{value} ", - }, - }, - { - type: "value", - position: "right", - splitLine: { - show: false, - lineStyle: { - color: ["#f2f2f2"], - }, - }, - axisLine: { - lineStyle: { - color: "#f2f2f2", - }, - }, - axisLabel: { - color: "rgb(170,170,170)", - formatter: "{value} %", - }, - }, - ], - series: [ - { - name: sourceName[0], - type: "bar", - data: ydata[0], - barWidth: "20%", - barGap: "10%", - stack: null, - }, - { - name: sourceName[1], - type: "bar", - data: ydata[1], - barWidth: "20%", - barGap: "10%", - stack: null, - }, - { - name: sourceName[2], - type: "bar", - data: ydata[2], - barWidth: "20%", - barGap: "10%", - stack: null, - // zlevel: 99, - }, - { - name: sourceName[3], - type: "line", - data: ydata[3], - yAxisIndex: 1, - // zlevel:100, - }, - ], - } - , true - ); - } + ], + series: [ + { + name: sourceName[0], + type: "bar", + data: ydata[0], + barWidth: "20%", + barGap: "10%", + stack: null, + }, + { + name: sourceName[1], + type: "bar", + data: ydata[1], + barWidth: "20%", + barGap: "10%", + stack: null, + }, + { + name: sourceName[2], + type: "bar", + data: ydata[2], + barWidth: "20%", + barGap: "10%", + stack: null, + // zlevel: 99, + }, + { + name: sourceName[3], + type: "line", + data: ydata[3], + yAxisIndex: 1, + // zlevel:100, + }, + ], + }, + true + ); } + // } }; render() { return ( -
+
-
+
@@ -403,8 +823,16 @@ class BI055HomeDetail extends React.Component { -
- +
+
@@ -414,4 +842,4 @@ class BI055HomeDetail extends React.Component { ); } } -export default connect(({ login, app }) => ({ login, app }))(BI055HomeDetail) +export default connect(({ login, app }) => ({ login, app }))(BI055HomeDetail); diff --git a/src/routes/Home.js b/src/routes/Home.js index 48a91e3..5dba3d2 100644 --- a/src/routes/Home.js +++ b/src/routes/Home.js @@ -10,6 +10,7 @@ import { extendRule, extend, extendOrder, + getSixMonth } from "../utils/common"; import "./home.less"; // 组件库 @@ -189,10 +190,6 @@ class Home extends React.Component { currentpageIndex: "1", visibleStartTime: [], visibleEndTime: [], - mineType: - localStorage.getItem("currentMineType") === "20" - ? "10" - : localStorage.getItem("currentMineType"), detailForm: { isShow: false, formCode: "", @@ -250,16 +247,16 @@ class Home extends React.Component { this.dangerChange(); this.getUser(); } - getSixMonth = (number, yearString = "", monthString = "") => { - let nowdate = new Date(); - nowdate.setMonth(nowdate.getMonth() + number); - let y = nowdate.getFullYear(); - let m = nowdate.getMonth() + 1; - // let d = nowdate.getDate(); - let retrundate = y + yearString + m + monthString; + // getSixMonth = (number, yearString = "", monthString = "") => { + // let nowdate = new Date(); + // nowdate.setMonth(nowdate.getMonth() + number); + // let y = nowdate.getFullYear(); + // let m = nowdate.getMonth() + 1; + // // let d = nowdate.getDate(); + // let retrundate = y + yearString + m + monthString; - return retrundate; - }; + // return retrundate; + // }; showAll = (key) => { const { tableData } = this.state; @@ -617,7 +614,7 @@ class Home extends React.Component { ]; let xData = []; for (let i = 0; i < 12; i++) { - xData.unshift(this.getSixMonth(-i, "年", "月")); + xData.unshift(getSixMonth(-i, "年", "月")); } for (let i = 0; i < data3.length; i++) { series.push({ @@ -727,7 +724,7 @@ class Home extends React.Component { let month = date.getMonth() + 1; let xData = []; for (let i = 0; i < 6; i++) { - xData.unshift(this.getSixMonth(-i, "-", "")); + xData.unshift(getSixMonth(-i, "-", "")); } let dangerChanges = document.getElementById("dangerChange"); if (dangerChanges) { @@ -1217,13 +1214,8 @@ class Home extends React.Component { }; ExpandCancel = () => {}; showDetailModal = (formCode) => { - console.log(this.state.mineType,'this.state.mineType') - var titleTemp = - this.state.mineType == 20 - ? "尾矿库" - : this.state.mineType == 10 - ? "选矿厂" - : "露天矿"; + var titleTemp ='' + if (formCode == "BI054_HOMEDETAIL") { titleTemp += "安全检查次数统计(近12月)"; } else if (formCode == "BI055_HOMEDETAIL") { @@ -1239,7 +1231,6 @@ class Home extends React.Component { const newtmpData = { data: { id: guid(), - mineType: this.state.mineType, onCancel: this.ExpandCancel, homeReload: true, }, diff --git a/src/utils/common.js b/src/utils/common.js index 33358bd..cae311f 100644 --- a/src/utils/common.js +++ b/src/utils/common.js @@ -1,23 +1,25 @@ /* eslint-disable no-undef */ // import { color } from 'html2canvas/dist/types/css/types/color'; //wyw 这个会影响 -import { random, omit } from 'lodash'; -import moment from 'moment'; -const RFC4122_TEMPLATE = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'; +import { random, omit } from "lodash"; +import moment from "moment"; +const RFC4122_TEMPLATE = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"; export function uuid(placeholder) { return RFC4122_TEMPLATE.replace(/[xy]/g, function () { - let value = random(15) - value = placeholder === 'x' ? value : (value & 0x3 | 0x8) - return value.toString(16) - }) + let value = random(15); + value = placeholder === "x" ? value : (value & 0x3) | 0x8; + return value.toString(16); + }); } -export function Base64_Encode(str) { // base64转换 +export function Base64_Encode(str) { + // base64转换 let c1, c2, c3; - let base64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + let base64EncodeChars = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; let i = 0; let len = str.length; - let string = ''; + let string = ""; while (i < len) { c1 = str.charCodeAt(i++) & 0xff; @@ -30,41 +32,58 @@ export function Base64_Encode(str) { // base64转换 c2 = str.charCodeAt(i++); if (i === len) { string += base64EncodeChars.charAt(c1 >> 2); - string += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4)); - string += base64EncodeChars.charAt((c2 & 0xF) << 2); + string += base64EncodeChars.charAt( + ((c1 & 0x3) << 4) | ((c2 & 0xf0) >> 4) + ); + string += base64EncodeChars.charAt((c2 & 0xf) << 2); string += "="; break; } c3 = str.charCodeAt(i++); string += base64EncodeChars.charAt(c1 >> 2); - string += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4)); - string += base64EncodeChars.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >> 6)); - string += base64EncodeChars.charAt(c3 & 0x3F); + string += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xf0) >> 4)); + string += base64EncodeChars.charAt(((c2 & 0xf) << 2) | ((c3 & 0xc0) >> 6)); + string += base64EncodeChars.charAt(c3 & 0x3f); } return string; } export function guid() { function S4() { - return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1) + return Math.floor((1 + Math.random()) * 0x10000) + .toString(16) + .substring(1); } - return S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4(); + return ( + S4() + + S4() + + "-" + + S4() + + "-" + + S4() + + "-" + + S4() + + "-" + + S4() + + S4() + + S4() + ); } export function extend(obj1, obj2) { - if (typeof (obj2) === 'object') - for (let p in obj2) obj1[p] = obj2[p]; + if (typeof obj2 === "object") for (let p in obj2) obj1[p] = obj2[p]; } //wyw 添加 子表过滤条件 -export function extendFilterGroupGroupRules(obj, filed, op, value, isSysParam) { //查询条件 +export function extendFilterGroupGroupRules(obj, filed, op, value, isSysParam) { + //查询条件 let data = {}; if (value === null) { - value = ''; + value = ""; } - data['Field'] = filed; - data['Operate'] = op; - data['Value'] = isSysParam ? value.toString() : value; + data["Field"] = filed; + data["Operate"] = op; + data["Value"] = isSysParam ? value.toString() : value; if (isSysParam) { data["IsSysParamRule"] = true; } @@ -81,15 +100,15 @@ export function extendFilterGroupGroupRules(obj, filed, op, value, isSysParam) { obj.FilterGroup.groups[0].rules.push(data); } - -export function extendRule(obj, filed, op, value, isSysParam) { //查询条件 +export function extendRule(obj, filed, op, value, isSysParam) { + //查询条件 let data = {}; if (value === null) { - value = ''; + value = ""; } - data['Field'] = filed; - data['Operate'] = op; - data['Value'] = isSysParam ? value.toString() : value; + data["Field"] = filed; + data["Operate"] = op; + data["Value"] = isSysParam ? value.toString() : value; if (isSysParam) { data["IsSysParamRule"] = true; } @@ -108,12 +127,10 @@ export function initFilterGroup(IsAnd = true) { IsAnd, Rules: [], Groups: [], - } + }; } - export function extendFilterGroup(obj, obj2) { - if (!obj.FilterGroup) { obj.FilterGroup = {}; } @@ -130,14 +147,15 @@ export function extendChildGroup(obj, obj2) { obj.Groups.push(obj2); } -export function extendGroupRule(obj, filed, op, value, isSysParam) { //查询条件 +export function extendGroupRule(obj, filed, op, value, isSysParam) { + //查询条件 let data = {}; if (value === null) { - value = ''; + value = ""; } - data['Field'] = filed; - data['Operate'] = op; - data['Value'] = isSysParam ? value.toString() : value; + data["Field"] = filed; + data["Operate"] = op; + data["Value"] = isSysParam ? value.toString() : value; if (isSysParam) { data["IsSysParamRule"] = true; } @@ -146,7 +164,6 @@ export function extendGroupRule(obj, filed, op, value, isSysParam) { //查询条 obj.Rules = []; } obj.Rules.push(data); - } export function initQueryFilter(OrgId, PageIndex, Limit, Sort, Order) { @@ -156,18 +173,30 @@ export function initQueryFilter(OrgId, PageIndex, Limit, Sort, Order) { Limit, Start: (PageIndex - 1) * Limit, Sort, - Order: (Order === '' ? 0 : Order), + Order: Order === "" ? 0 : Order, RuleCount: 0, IncludeCount: 0, OrderCount: 0, FilterGroupCount: 0, Include: [], Orders: [], - FilterGroup: { Rules: [], Groups: [] } + FilterGroup: { Rules: [], Groups: [] }, }; } -export function initFilter(OrgId, Keyword = "", Sort, Order, PageIndex = 1, Parameter1, Parameter2, Parameter3, Parameter4, Parameter5, Parameter6) { +export function initFilter( + OrgId, + Keyword = "", + Sort, + Order, + PageIndex = 1, + Parameter1, + Parameter2, + Parameter3, + Parameter4, + Parameter5, + Parameter6 +) { return { Keyword, Parameter1, @@ -181,7 +210,7 @@ export function initFilter(OrgId, Keyword = "", Sort, Order, PageIndex = 1, Para Limit: 10, Start: (PageIndex - 1) * 10, Sort, - Order: (Order === '' ? 0 : Order), + Order: Order === "" ? 0 : Order, RuleCount: 0, IncludeCount: 0, OrderCount: 0, @@ -191,14 +220,13 @@ export function initFilter(OrgId, Keyword = "", Sort, Order, PageIndex = 1, Para FilterGroup: { Rules: [], Groups: [] }, SelectField: [], DataRule: [], - IgnoreDataRule: false + IgnoreDataRule: false, }; // let params = $("#search-form").elFilterParam(); // extend(json, params); } export function extendInclude(obj, clude) { - if (!obj.Include) { obj.Include = []; } @@ -215,41 +243,34 @@ export function extendOrder(obj, filed, order) { obj.Orders.push(data); } export function extendIgnoreDataRule(obj) { - obj.IgnoreDataRule = true + obj.IgnoreDataRule = true; } -function trim(str) { // ? - for (var i = 0; i < str.length && str.charAt(i) == " "; i++) - ; - for (var j = str.length; j > 0 && str.charAt(j - 1) == " "; j--) - ; - if (i > j) - return ""; +function trim(str) { + // ? + for (var i = 0; i < str.length && str.charAt(i) == " "; i++); + for (var j = str.length; j > 0 && str.charAt(j - 1) == " "; j--); + if (i > j) return ""; return str.substring(i, j); } export function empty(v, allowZero) { if (v === "null" || v === undefined || v === "") return true; switch (typeof v) { - case 'undefined': + case "undefined": return true; - case 'string': - if (trim(v).length == 0) - return true; + case "string": + if (trim(v).length == 0) return true; break; - case 'boolean': - if (!v) - return true; + case "boolean": + if (!v) return true; break; - case 'number': - if (0 === v && !allowZero) - return true; + case "number": + if (0 === v && !allowZero) return true; break; - case 'object': - if (null === v) - return true; - if (undefined !== v.length && v.length == 0) - return true; + case "object": + if (null === v) return true; + if (undefined !== v.length && v.length == 0) return true; for (var k in v) { return false; } @@ -259,34 +280,33 @@ export function empty(v, allowZero) { } } -export function strConvert(target, def) { // 点字符串转对象 +export function strConvert(target, def) { + // 点字符串转对象 // str为需要转换的值, def为有固定的最后一个属性值 - let splitFiles = target.split('.'); - let str = ''; + let splitFiles = target.split("."); + let str = ""; let len = splitFiles.length; - splitFiles.forEach(item => { - str += '{\"' + item + '\":' + splitFiles.forEach((item) => { + str += '{"' + item + '":'; }); - str += "" + def + "" + str += "" + def + ""; for (let j = 0; j < len; j++) { - str += '}' + str += "}"; } let mat = JSON.parse(str); - return mat + return mat; } //仅仅获取对象的基础属性,不包含属性中的对象 export function getOnlyPropertyData(data, isGetSysParam) { let result = {}; Object.keys(data).forEach((n) => { - if (n.indexOf('.') !== -1) return; - if (isGetSysParam && n === 'Nav_SysParams') { + if (n.indexOf(".") !== -1) return; + if (isGetSysParam && n === "Nav_SysParams") { result[n] = data[n]; - } - else if (Array.isArray(data[n])) { + } else if (Array.isArray(data[n])) { result[n] = data[n]; - } - else if (typeof (data[n]) !== "object") { + } else if (typeof data[n] !== "object") { result[n] = data[n]; } }); @@ -297,20 +317,19 @@ export function getOnlyPropertyData(data, isGetSysParam) { export function getPropertyData(data, isSetDelete) { let result = {}; Object.keys(data).forEach((n) => { - if (n.indexOf('.') != -1) return; - if (typeof (data[n]) !== "object") { + if (n.indexOf(".") != -1) return; + if (typeof data[n] !== "object") { result[n] = data[n]; - } - else if (data[n] && data[n].length) { + } else if (data[n] && data[n].length) { const array = []; - data[n].forEach(nx => { + data[n].forEach((nx) => { const d = getPropertyData(nx, isSetDelete); array.push(d); }); result[n] = array; } if (isSetDelete) { - result['IS_DELETED'] = true; + result["IS_DELETED"] = true; } }); return result; @@ -318,33 +337,33 @@ export function getPropertyData(data, isSetDelete) { // 取导航属性的最后一个字段 export function dataIndexName(field) { - const valueValid = field ? field.split('.') : []; - return valueValid[valueValid.length - 1] + const valueValid = field ? field.split(".") : []; + return valueValid[valueValid.length - 1]; } export function splitEnum(str) { let newArr = []; - let oArr = str ? str.split(',') : []; - oArr.forEach(item => { - let n = item.split(':'); + let oArr = str ? str.split(",") : []; + oArr.forEach((item) => { + let n = item.split(":"); newArr.push({ label: n[0], - value: n[1] - }) + value: n[1], + }); }); - return newArr + return newArr; } export function getDataFieldValueByCol(data, field, defaultValue) { if (!data || !field) return null; - let opIndex = field.lastIndexOf('/'); + let opIndex = field.lastIndexOf("/"); let op = 0; if (opIndex === -1) { - opIndex = field.indexOf('*'); + opIndex = field.indexOf("*"); if (opIndex === -1) { - opIndex = field.indexOf('+'); + opIndex = field.indexOf("+"); if (opIndex === -1) { - opIndex = field.lastIndexOf('-'); + opIndex = field.lastIndexOf("-"); if (opIndex !== -1) { op = 2; } @@ -364,19 +383,23 @@ export function getDataFieldValueByCol(data, field, defaultValue) { const rightField = field.substring(opIndex + 1); const leftText = getDataFieldValueByCol(data, leftField); const rigthText = getDataFieldValueByCol(data, rightField); - if (leftText !== '' && rigthText !== '' && !isNaN(leftText) && !isNaN(rigthText)) { + if ( + leftText !== "" && + rigthText !== "" && + !isNaN(leftText) && + !isNaN(rigthText) + ) { if (op === 1) { - controlValue = (+leftText) + (+rigthText); + controlValue = +leftText + +rigthText; } else if (op === 2) { - controlValue = (+leftText) - (+rigthText); + controlValue = +leftText - +rigthText; } else if (op === 3) { - controlValue = (+leftText) * (+rigthText); - } else if (op === 3 && (+rigthText) !== 0) { - controlValue = (+leftText) / (+rigthText); + controlValue = +leftText * +rigthText; + } else if (op === 3 && +rigthText !== 0) { + controlValue = +leftText / +rigthText; } } - } - else { + } else { controlValue = getDataFieldValue(data, field, defaultValue); } return controlValue; @@ -384,7 +407,7 @@ export function getDataFieldValueByCol(data, field, defaultValue) { function innerGetDataFieldValue(data, field, defaultValue) { if (!data || !field) return null; - const valueValid = field ? field.split('.') : []; + const valueValid = field ? field.split(".") : []; let controlValue = null; let tmp = { ...data }; if (tmp) { @@ -396,17 +419,16 @@ function innerGetDataFieldValue(data, field, defaultValue) { } else { tmp = null; } - } - else { + } else { let arrayTmp = []; - tmp.forEach(item => { + tmp.forEach((item) => { if (item && item.IS_DELETED) { } else { if (item.hasOwnProperty(valueValid[j])) { arrayTmp.push(item[valueValid[j]]); } } - }) + }); tmp = arrayTmp; } } else { @@ -415,14 +437,14 @@ function innerGetDataFieldValue(data, field, defaultValue) { controlValue = tmp[valueValid[j]]; } } else { - controlValue = ''; - tmp.forEach(item => { + controlValue = ""; + tmp.forEach((item) => { if (item.IS_DELETED) { } else { controlValue += item[valueValid[j]] + ","; } - }) - if (controlValue && controlValue.indexOf(',') > 0) { + }); + if (controlValue && controlValue.indexOf(",") > 0) { controlValue = controlValue.substring(0, controlValue.length - 1); } } @@ -442,25 +464,23 @@ export function getDataFieldValue(data, field, defaultValue) { } return null; } - const key = 'Nav_SysParams'; + const key = "Nav_SysParams"; const index = field.indexOf(key); if (index === -1) { return innerGetDataFieldValue(data, field, defaultValue); - } - else { + } else { const f1 = index > 0 ? field.substring(0, index - 1) : null; const f2 = field.substring(index + key.length + 1); let temp = null; if (f1) { temp = innerGetDataFieldValue(data, f1); - } - else { + } else { temp = data; } if (temp) { let sysParams = temp[key]; if (sysParams) { - let paramRecord = sysParams.filter(t => t.CODE === f2)[0]; + let paramRecord = sysParams.filter((t) => t.CODE === f2)[0]; if (paramRecord) { return paramRecord.VALUE; } @@ -475,7 +495,7 @@ export function getDataFieldValue(data, field, defaultValue) { function innerSetDataFieldValue(data, field, value) { let tmp = data; - const valueValid = field ? field.split('.') : []; + const valueValid = field ? field.split(".") : []; for (let j = 0; j < valueValid.length; j++) { if (j < valueValid.length - 1) { if (!tmp.hasOwnProperty(valueValid[j]) || !tmp[valueValid[j]]) { @@ -494,12 +514,11 @@ function innerSetDataFieldValue(data, field, value) { } export function setDataFieldValue(data, field, value) { if (!data || !field) return data; - const key = 'Nav_SysParams'; + const key = "Nav_SysParams"; const index = field.indexOf(key); if (index === -1) { innerSetDataFieldValue(data, field, value); - } - else { + } else { const f1 = index > 0 ? field.substring(0, index - 1) : null; const f2 = field.substring(index + key.length + 1); let temp = null; @@ -509,8 +528,7 @@ export function setDataFieldValue(data, field, value) { temp = {}; innerSetDataFieldValue(data, f1, temp); } - } - else { + } else { temp = data; } let sysParams = temp[key]; @@ -518,13 +536,13 @@ export function setDataFieldValue(data, field, value) { sysParams = []; temp[key] = sysParams; } - let paramRecord = sysParams.filter(t => t.CODE === f2)[0]; + let paramRecord = sysParams.filter((t) => t.CODE === f2)[0]; if (!paramRecord) { paramRecord = { ID: guid(), CODE: f2, ENTITY_ID: temp.ID, - } + }; sysParams.push(paramRecord); } paramRecord.VALUE = value; @@ -532,8 +550,14 @@ export function setDataFieldValue(data, field, value) { return data; } -export function getParseValue(value, user, getHeadFieldValueFunc, getRecordFieldValueFunc, thisRef) { - if (value && typeof (value) == 'string') { +export function getParseValue( + value, + user, + getHeadFieldValueFunc, + getRecordFieldValueFunc, + thisRef +) { + if (value && typeof value == "string") { let index = value.indexOf("@user."); let departmentIndex = value.indexOf("@department."); let teamIndex = value.indexOf("@team."); @@ -543,7 +567,7 @@ export function getParseValue(value, user, getHeadFieldValueFunc, getRecordField if (user) { value = getDataFieldValue(user, field, null); } - }; + } } else if (departmentIndex == 0) { let field1 = value.substring(12); if (field1) { @@ -552,50 +576,47 @@ export function getParseValue(value, user, getHeadFieldValueFunc, getRecordField } else { value = ""; } - }; + } } else if (teamIndex == 0) { let field2 = value.substring(6); if (field2) { if (user && user.Team) { value = getDataFieldValue(user.Team, field2, null); } else { - value = '00000000-0000-0000-0000-000000000000'; + value = "00000000-0000-0000-0000-000000000000"; } - }; - } - else { + } + } else { index = value.indexOf("@nowDate"); if (index == 0) { - value = moment().format('YYYY-MM-DD'); + value = moment().format("YYYY-MM-DD"); } else { index = value.indexOf("@nowTime"); if (index == 0) { - value = moment().format('HH:mm:ss'); + value = moment().format("HH:mm:ss"); } else { index = value.indexOf("@now"); if (index == 0) { - value = moment().format('YYYY-MM-DD HH:mm:ss'); + value = moment().format("YYYY-MM-DD HH:mm:ss"); } else { index = value.indexOf("@head."); if (index == 0) { const field = value.substring(6); - if (field && typeof getHeadFieldValueFunc === 'function') { + if (field && typeof getHeadFieldValueFunc === "function") { value = getHeadFieldValueFunc(field, thisRef); - }; + } } else { index = value.indexOf("@record."); if (index === 0) { const field = value.substring(8); - if (field && typeof getRecordFieldValueFunc === 'function') { + if (field && typeof getRecordFieldValueFunc === "function") { value = getRecordFieldValueFunc(field, thisRef); - }; + } } } } } } - - } } return value; @@ -605,8 +626,13 @@ export function permissionUtils(login) { const checkPermission = (formId, keyId, type) => { if (login.userType == 99 || !formId) return true; //管理员 let hasPermission = false; - const currActivatedMenu = login.currActivatedMenu || {} - if (login.rolePerm && login.rolePerm.Nav_RolePermForms && login.rolePerm.Nav_RolePermForms.length) { //只要一个角色有权限就有权限 + const currActivatedMenu = login.currActivatedMenu || {}; + if ( + login.rolePerm && + login.rolePerm.Nav_RolePermForms && + login.rolePerm.Nav_RolePermForms.length + ) { + //只要一个角色有权限就有权限 /** * hasPermssion 判断为 true 之后,必须直接赋值为 true, * 不能用条件判断(比如:hasPermission = matchForm;)去赋值 @@ -614,25 +640,31 @@ export function permissionUtils(login) { */ login.rolePerm.Nav_RolePermForms.forEach((n1, i1) => { if (!currActivatedMenu.ID) { - hasPermission = true + hasPermission = true; } else { if (n1.PermFormId === formId) { - const matchForm = (n1.MenuId === currActivatedMenu.ID || !currActivatedMenu.ID) - if (type == 0 && matchForm) { //表单权限 + const matchForm = + n1.MenuId === currActivatedMenu.ID || !currActivatedMenu.ID; + if (type == 0 && matchForm) { + //表单权限 hasPermission = true; - } else if (type == 1) { //按钮权限 + } else if (type == 1) { + //按钮权限 if (n1.Nav_Btns && n1.Nav_Btns.length) { n1.Nav_Btns.forEach((n2, i2) => { - const matchBtn = (n2.MenuId === currActivatedMenu.ID || !currActivatedMenu.ID) + const matchBtn = + n2.MenuId === currActivatedMenu.ID || !currActivatedMenu.ID; if (n2.BtnId === keyId && matchBtn) { hasPermission = true; } }); } - } else if (type == 2) { //行权限 + } else if (type == 2) { + //行权限 if (n1.Nav_Columns && n1.Nav_Columns.length) { n1.Nav_Columns.forEach((n2, i2) => { - const matchRow = (n2.MenuId === currActivatedMenu.ID || !currActivatedMenu.ID) + const matchRow = + n2.MenuId === currActivatedMenu.ID || !currActivatedMenu.ID; if (n2.ColumnId === keyId && matchRow) { hasPermission = true; } @@ -641,8 +673,6 @@ export function permissionUtils(login) { } } } - - }); } return hasPermission; @@ -655,7 +685,7 @@ export function permissionUtils(login) { return checkPermission(formId, columnId, 2); }, checkForm: (formId) => { - return checkPermission(formId, '', 0); + return checkPermission(formId, "", 0); }, }; } @@ -663,18 +693,18 @@ export function permissionUtils(login) { //根据枚举字符串获取枚举列表 export function getEnums(str) { let newArr = {}; - let oArr = str ? str.split(',') : []; - oArr.forEach(item => { - let n = item.split(':'); + let oArr = str ? str.split(",") : []; + oArr.forEach((item) => { + let n = item.split(":"); newArr[[n[1]]] = n[0]; }); - return newArr + return newArr; } export function getCustomParams(customParamsStr) { const customParams = {}; - if (customParamsStr && typeof customParamsStr === 'string') { - let arrays = customParamsStr.split('|'); + if (customParamsStr && typeof customParamsStr === "string") { + let arrays = customParamsStr.split("|"); arrays.forEach(function (n, i) { let paris = n.split("="); if (paris.length >= 2) { @@ -692,32 +722,40 @@ export function getParseValueByDate(date) { let r = null; if (date === "{now}") { r = [moment(), moment()]; - } else if (date.indexOf('{now,') > -1) { - const tt1 = date.indexOf('}'); + } else if (date.indexOf("{now,") > -1) { + const tt1 = date.indexOf("}"); const et = tt1 > -1 ? date.substring(tt1 + 1) : null; - if (et && et.indexOf('{now,') > -1) { + if (et && et.indexOf("{now,") > -1) { const bs = date.substring(0, tt1 + 1); let b1 = bs.substring(5); let e1 = et.substring(5); b1 = b1.substring(0, b1.length - 1); e1 = e1.substring(0, e1.length - 1); - const bts = b1.split(','); - const ets = e1.split(','); + const bts = b1.split(","); + const ets = e1.split(","); if (bts && bts.length >= 2 && ets && ets.length >= 2) { const n1 = bts[1]; const n2 = ets[1]; - const b = n1 > 0 ? moment().add(n1, bts[0]) : (n1 < 0 ? moment().subtract(Math.abs(n1), bts[0]) : moment()); - const e = n2 > 0 ? moment().add(n2, ets[0]) : (n2 < 0 ? moment().subtract(Math.abs(n2), ets[0]) : moment()); + const b = + n1 > 0 + ? moment().add(n1, bts[0]) + : n1 < 0 + ? moment().subtract(Math.abs(n1), bts[0]) + : moment(); + const e = + n2 > 0 + ? moment().add(n2, ets[0]) + : n2 < 0 + ? moment().subtract(Math.abs(n2), ets[0]) + : moment(); if (b.isBefore(e)) { r = [b, e]; } } - - } - else { + } else { let t = date.substring(5); t = t.substring(0, t.length - 1); - const ts = t.split(','); + const ts = t.split(","); if (ts && ts.length >= 2) { if (ts.length === 2) { const n1 = ts[1]; @@ -728,12 +766,21 @@ export function getParseValueByDate(date) { } else { r = [moment(), moment()]; } - } - else { + } else { const n1 = ts[1]; const n2 = ts[2]; - const b = n1 > 0 ? moment().add(n1, ts[0]) : (n1 < 0 ? moment().subtract(Math.abs(n1), ts[0]) : moment()); - const e = n2 > 0 ? moment().add(n2, ts[0]) : (n2 < 0 ? moment().subtract(Math.abs(n2), ts[0]) : moment()); + const b = + n1 > 0 + ? moment().add(n1, ts[0]) + : n1 < 0 + ? moment().subtract(Math.abs(n1), ts[0]) + : moment(); + const e = + n2 > 0 + ? moment().add(n2, ts[0]) + : n2 < 0 + ? moment().subtract(Math.abs(n2), ts[0]) + : moment(); if (b.isBefore(e)) { r = [b, e]; } @@ -741,7 +788,7 @@ export function getParseValueByDate(date) { } } } else { - const temps = value ? value.split(',') : null; + const temps = value ? value.split(",") : null; if (temps && temps.length === 2) { r = [moment(temps[0]), moment(temps[1])]; } @@ -753,22 +800,24 @@ export function getParseValueByDate(date) { export function getGroupByQueryFields(fields, groups, parentId, parent, list) { if (groups && groups.length) { - const tempGroups = groups.filter(t => t.PARENT_ID === parentId); + const tempGroups = groups.filter((t) => t.PARENT_ID === parentId); if (tempGroups && tempGroups.length) { - tempGroups.forEach(t => { + tempGroups.forEach((t) => { const group = { rules: [], childGroups: [], isAnd: t.RELATION_TYPE !== 1, }; if (fields && fields.length) { - const tempFields = fields.filter(t1 => t1.USER_C_C_QUERY_GROUP_ID === t.ID); + const tempFields = fields.filter( + (t1) => t1.USER_C_C_QUERY_GROUP_ID === t.ID + ); if (tempFields && tempFields.length) { group.rules = getRulesByQueryFields(tempFields, group.childGroups); } } if (parent) { - parent.childGroups.push(group) + parent.childGroups.push(group); } else { list.push(group); } @@ -781,7 +830,7 @@ export function getGroupByQueryFields(fields, groups, parentId, parent, list) { export function getRuleAndGroupsByQueryFields(queryFields, queryGroups) { const result = {}; if (queryFields != null && queryFields.length) { - const sysFields = queryFields.filter(t => !t.USER_C_C_QUERY_GROUP_ID); + const sysFields = queryFields.filter((t) => !t.USER_C_C_QUERY_GROUP_ID); result.groups = []; result.rules = getRulesByQueryFields(sysFields, result.groups); getGroupByQueryFields(queryFields, queryGroups, null, null, result.groups); @@ -792,8 +841,13 @@ export function getRuleAndGroupsByQueryFields(queryFields, queryGroups) { export function getRulesByQueryFields(queryFields, groupList) { if (queryFields && queryFields.length) { const result = []; - queryFields.forEach(t => { - if (t.DATA_VALUE === null || t.DATA_VALUE === undefined || t.DATA_VALUE === '') return; + queryFields.forEach((t) => { + if ( + t.DATA_VALUE === null || + t.DATA_VALUE === undefined || + t.DATA_VALUE === "" + ) + return; // dataType-controlType // 5-10: 时分秒区间组件 9-18:月份 10-19:月份区间 12-20:年份 13-20:年份区间 15-22:年月日时分秒区间 16-23:年月日时分区间 17-2:日期选择 if ( @@ -810,46 +864,61 @@ export function getRulesByQueryFields(queryFields, groupList) { if (tmps != null && tmps.length) { if (t.IS_CUSTOM) { const vas = tmps.map((time, timeIndex) => { - return timeIndex === 0 ? moment(time).format('YYYY-MM-DD') : moment(moment(time).format('YYYY-MM-DD')).add(1, 'd').subtract(1, 's').format('YYYY-MM-DD HH:mm:ss') - }) + return timeIndex === 0 + ? moment(time).format("YYYY-MM-DD") + : moment(moment(time).format("YYYY-MM-DD")) + .add(1, "d") + .subtract(1, "s") + .format("YYYY-MM-DD HH:mm:ss"); + }); // 将 2020-07-18 格式化成 2020-07-01 月份开始的时间 - const monthFormat = moment(moment(vas[0]).format('YYYY-MM')).format('YYYY-MM-DD') - const monthEndFormat = moment(moment(vas[1]).format('YYYY-MM')).format('YYYY-MM-DD') + const monthFormat = moment(moment(vas[0]).format("YYYY-MM")).format( + "YYYY-MM-DD" + ); + const monthEndFormat = moment( + moment(vas[1]).format("YYYY-MM") + ).format("YYYY-MM-DD"); // 将 2020-07-18 格式化成 2020-01-01 月份开始的时间 - const yearFormat = moment(moment(vas[0]).format('YYYY')).format('YYYY-MM-DD') - const yearEndFormat = moment(moment(vas[1]).format('YYYY')).format('YYYY-MM-DD') + const yearFormat = moment(moment(vas[0]).format("YYYY")).format( + "YYYY-MM-DD" + ); + const yearEndFormat = moment(moment(vas[1]).format("YYYY")).format( + "YYYY-MM-DD" + ); // 年月日时分或者秒控件 - const dateHMOrS = tmps.map(item => { + const dateHMOrS = tmps.map((item) => { if (t.DATA_TYPE === 15) { // 年月日时分秒控件 - return moment(item).format('YYYY-MM-DD HH:mm:ss') + return moment(item).format("YYYY-MM-DD HH:mm:ss"); } // 将 2020-07-18 18:24:15 格式化成 2020-07-18 18:24:00 开始的时间 - return moment(moment(item).format('YYYY-MM-DD HH:mm')).format('YYYY-MM-DD HH:mm:ss') - }) - let dateVal = vas.join(',') + return moment(moment(item).format("YYYY-MM-DD HH:mm")).format( + "YYYY-MM-DD HH:mm:ss" + ); + }); + let dateVal = vas.join(","); switch (t.DATA_TYPE) { case 9: - dateVal = monthFormat - break + dateVal = monthFormat; + break; case 10: - dateVal = [monthFormat, monthEndFormat].join(',') - break + dateVal = [monthFormat, monthEndFormat].join(","); + break; case 12: - dateVal = yearFormat - break + dateVal = yearFormat; + break; case 13: - dateVal = [yearFormat, yearEndFormat].join(',') - break + dateVal = [yearFormat, yearEndFormat].join(","); + break; case 15: case 16: - dateVal = dateHMOrS.join(',') - break + dateVal = dateHMOrS.join(","); + break; case 17: - dateVal = vas[0] - break + dateVal = vas[0]; + break; default: - break + break; } result.push({ field: t.QUERY_NAME, @@ -869,49 +938,67 @@ export function getRulesByQueryFields(queryFields, groupList) { tempList = group.rules; } tmps.forEach((j, k) => { - const tmpVal = k === 0 ? moment(j).format('YYYY-MM-DD') : moment(moment(j).format('YYYY-MM-DD')).add(1, 'd').subtract(1, 's').format('YYYY-MM-DD HH:mm:ss') - const monthVal = moment(moment(j).format('YYYY-MM')).format('YYYY-MM-DD') - const yearVal = moment(moment(j).format('YYYY')).format('YYYY-MM-DD') - const dateHMS = moment(j).format('YYYY-MM-DD HH:mm:ss') // 15 精确到年月日时分秒 - const dateHM = moment(j).format('YYYY-MM-DD HH:mm') // 16 精确到年月日时分 + const tmpVal = + k === 0 + ? moment(j).format("YYYY-MM-DD") + : moment(moment(j).format("YYYY-MM-DD")) + .add(1, "d") + .subtract(1, "s") + .format("YYYY-MM-DD HH:mm:ss"); + const monthVal = moment(moment(j).format("YYYY-MM")).format( + "YYYY-MM-DD" + ); + const yearVal = moment(moment(j).format("YYYY")).format( + "YYYY-MM-DD" + ); + const dateHMS = moment(j).format("YYYY-MM-DD HH:mm:ss"); // 15 精确到年月日时分秒 + const dateHM = moment(j).format("YYYY-MM-DD HH:mm"); // 16 精确到年月日时分 tempList.push({ field: t.QUERY_NAME, - operator: k === 0 ? '6' : '4', - value: t.DATA_TYPE === 5 || t.DATA_TYPE === 17 ? (t.DATA_TYPE === 16 ? dateHM : t.DATA_TYPE === 15 ? dateHMS : tmpVal) : (t.DATA_TYPE === 9 || t.DATA_TYPE === 10 ? monthVal : yearVal), + operator: k === 0 ? "6" : "4", + value: + t.DATA_TYPE === 5 || t.DATA_TYPE === 17 + ? t.DATA_TYPE === 16 + ? dateHM + : t.DATA_TYPE === 15 + ? dateHMS + : tmpVal + : t.DATA_TYPE === 9 || t.DATA_TYPE === 10 + ? monthVal + : yearVal, isCustom: t.IS_CUSTOM, - isSysParam: t.IS_SYS_PARAM - }) + isSysParam: t.IS_SYS_PARAM, + }); }); } } - } - else if (t.DATA_TYPE === 3 || t.DATA_TYPE === 2) { // 枚举 数值 + } else if (t.DATA_TYPE === 3 || t.DATA_TYPE === 2) { + // 枚举 数值 result.push({ field: t.QUERY_NAME, - operator: t.OP_DEFAULT ? t.OP_DEFAULT : '1', - value: (+t.DATA_VALUE), + operator: t.OP_DEFAULT ? t.OP_DEFAULT : "1", + value: +t.DATA_VALUE, isCustom: t.IS_CUSTOM, isSysParam: t.IS_SYS_PARAM, - }) - } - else if (t.DATA_TYPE === 4) { // 布尔 + }); + } else if (t.DATA_TYPE === 4) { + // 布尔 result.push({ field: t.QUERY_NAME, - operator: t.OP_DEFAULT ? t.OP_DEFAULT : '1', - value: (t.DATA_VALUE && t.DATA_VALUE == 'true' ? true : false), + operator: t.OP_DEFAULT ? t.OP_DEFAULT : "1", + value: t.DATA_VALUE && t.DATA_VALUE == "true" ? true : false, isCustom: t.IS_CUSTOM, isSysParam: t.IS_SYS_PARAM, - }) - } - else if (t.DATA_TYPE === 6) { // 下拉多选 + }); + } else if (t.DATA_TYPE === 6) { + // 下拉多选 let temps = []; - if (t.DATA_VALUE.toString().indexOf(',') > -1) { - temps = t.DATA_VALUE.toString().split(','); - } else if (t.DATA_VALUE.toString().indexOf('_') > -1) { - const tmp = t.DATA_VALUE.toString().split('_'); + if (t.DATA_VALUE.toString().indexOf(",") > -1) { + temps = t.DATA_VALUE.toString().split(","); + } else if (t.DATA_VALUE.toString().indexOf("_") > -1) { + const tmp = t.DATA_VALUE.toString().split("_"); tmp.forEach((n, i) => { - if (n !== '') - temps.push(n); + if (n !== "") temps.push(n); }); } @@ -931,17 +1018,16 @@ export function getRulesByQueryFields(queryFields, groupList) { value: j, isCustom: t.IS_CUSTOM, isSysParam: t.IS_SYS_PARAM, - }) + }); }); - } - else { + } else { result.push({ field: t.QUERY_NAME, - operator: t.OP_DEFAULT ? t.OP_DEFAULT : '9', + operator: t.OP_DEFAULT ? t.OP_DEFAULT : "9", value: t.DATA_VALUE, isCustom: t.IS_CUSTOM, isSysParam: t.IS_SYS_PARAM, - }) + }); } }); return result; @@ -950,12 +1036,12 @@ export function getRulesByQueryFields(queryFields, groupList) { export function locationQuery(query) { if (!query) return {}; - let querys = query.split('?')[1]; - let pair = querys.split('&'); + let querys = query.split("?")[1]; + let pair = querys.split("&"); let obj = {}; for (let i = 0; i < pair.length; i++) { - let propertys = pair[i].split('='); - obj[propertys[0]] = propertys[1] + let propertys = pair[i].split("="); + obj[propertys[0]] = propertys[1]; } return obj; } @@ -968,14 +1054,21 @@ export function getRuleAndGroupByParseValue({ user, isCustom, getHeadFieldValueFunc, - getRecordFieldValueFunc + getRecordFieldValueFunc, }) { - if (isCustom) { //自定义字段 - if (value.indexOf('{now') > -1) { + if (isCustom) { + //自定义字段 + if (value.indexOf("{now") > -1) { const temps = getParseValueByDate(value); - let vas = ''; + let vas = ""; temps.forEach((j, k) => { - const v = k === 0 ? moment(j).format('YYYY-MM-DD') : moment(moment(j).format('YYYY-MM-DD')).add(1, 'd').subtract(1, 's').format('YYYY-MM-DD HH:mm:ss'); + const v = + k === 0 + ? moment(j).format("YYYY-MM-DD") + : moment(moment(j).format("YYYY-MM-DD")) + .add(1, "d") + .subtract(1, "s") + .format("YYYY-MM-DD HH:mm:ss"); vas += v + ","; }); if (ruleJson && ruleJson.rules) { @@ -991,13 +1084,18 @@ export function getRuleAndGroupByParseValue({ ruleJson.rules.push({ field, operator, - value: getParseValue(value, user, getHeadFieldValueFunc, getRecordFieldValueFunc), + value: getParseValue( + value, + user, + getHeadFieldValueFunc, + getRecordFieldValueFunc + ), isCustom: isCustom, }); } } } else { - if (value.indexOf('{now') > -1) { + if (value.indexOf("{now") > -1) { if (ruleJson) { const groups = ruleJson.groups ? ruleJson.groups : ruleJson.childGroups; if (groups) { @@ -1010,8 +1108,14 @@ export function getRuleAndGroupByParseValue({ temps.forEach((j, k) => { group.rules.push({ field, - operator: (k === 0 ? '6' : '4'), - value: (k === 0 ? moment(j).format('YYYY-MM-DD') : moment(moment(j).format('YYYY-MM-DD')).add(1, 'd').subtract(1, 's').format('YYYY-MM-DD HH:mm:ss')), + operator: k === 0 ? "6" : "4", + value: + k === 0 + ? moment(j).format("YYYY-MM-DD") + : moment(moment(j).format("YYYY-MM-DD")) + .add(1, "d") + .subtract(1, "s") + .format("YYYY-MM-DD HH:mm:ss"), isCustom: isCustom, }); }); @@ -1022,7 +1126,12 @@ export function getRuleAndGroupByParseValue({ ruleJson.rules.push({ field, operator, - value: getParseValue(value, user, getHeadFieldValueFunc, getRecordFieldValueFunc), + value: getParseValue( + value, + user, + getHeadFieldValueFunc, + getRecordFieldValueFunc + ), isCustom: isCustom, }); } @@ -1032,11 +1141,17 @@ export function getRuleAndGroupByParseValue({ export function addChildGroups(list, group) { if (list && list.length) { - list.forEach(t => { + list.forEach((t) => { const tempGroup = initFilterGroup(t.isAnd); if (t.rules && t.rules.length) { - t.rules.forEach(t1 => { - extendGroupRule(tempGroup, t1.field, t1.operator, t1.value, t1.isSysParam); + t.rules.forEach((t1) => { + extendGroupRule( + tempGroup, + t1.field, + t1.operator, + t1.value, + t1.isSysParam + ); }); } if (t.childGroups && t.childGroups.length) { @@ -1049,9 +1164,10 @@ export function addChildGroups(list, group) { export function getRandomCode(len) { len = len || 32; - var $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678=-*&@#$%!~+,./?\;:|' /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/ + var $chars = + "ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678=-*&@#$%!~+,./?;:|"; /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/ var maxPos = $chars.length; - var pwd = ''; + var pwd = ""; for (var i = 0; i < len; i++) { pwd += $chars.charAt(Math.floor(Math.random() * maxPos)); } @@ -1061,17 +1177,22 @@ export function getRandomCode(len) { export function addRuleAndGroups(json, ruleAndGroupJson) { if (json && ruleAndGroupJson) { if (ruleAndGroupJson.rules && ruleAndGroupJson.rules.length) { - ruleAndGroupJson.rules.forEach(t => { - if (t.isCustom) { //自定义字段 + ruleAndGroupJson.rules.forEach((t) => { + if (t.isCustom) { + //自定义字段 - if (t.field.indexOf(',') > -1) //modify by陈昌雨 2020/6/4 - { - var splitFileds = t.field.split(','); + if (t.field.indexOf(",") > -1) { + //modify by陈昌雨 2020/6/4 + var splitFileds = t.field.split(","); let values = null; - if (typeof (t.value) === 'number' && t.value !== undefined && t.value != null) { - values = t.value.toString().split(','); + if ( + typeof t.value === "number" && + t.value !== undefined && + t.value != null + ) { + values = t.value.toString().split(","); } else { - values = t.value.split(','); + values = t.value.split(","); } if (splitFileds && values) { @@ -1079,25 +1200,27 @@ export function addRuleAndGroups(json, ruleAndGroupJson) { json[n] = values[i]; }); } - } - else { + } else { json[t.field] = t.value; } - - - } - else { + } else { extendRule(json, t.field, t.operator, t.value, t.isSysParam); } }); } if (ruleAndGroupJson.groups && ruleAndGroupJson.groups.length) { - ruleAndGroupJson.groups.forEach(t => { + ruleAndGroupJson.groups.forEach((t) => { const tempGroup = initFilterGroup(t.isAnd); if (t.rules && t.rules.length) { - t.rules.forEach(t1 => { - extendGroupRule(tempGroup, t1.field, t1.operator, t1.value, t1.isSysParam); + t.rules.forEach((t1) => { + extendGroupRule( + tempGroup, + t1.field, + t1.operator, + t1.value, + t1.isSysParam + ); }); } if (t.childGroups && t.childGroups.length) { @@ -1110,129 +1233,137 @@ export function addRuleAndGroups(json, ruleAndGroupJson) { json.OrgType = ruleAndGroupJson.orgType; } if (ruleAndGroupJson.menuParameter) { - json.MenuParameter = ruleAndGroupJson.menuParameter + json.MenuParameter = ruleAndGroupJson.menuParameter; } } } export function constructStandardTreeData(data, cascader) { - data.forEach(item => { - const { Node, Children } = item - const { NAME, ID } = Node + data.forEach((item) => { + const { Node, Children } = item; + const { NAME, ID } = Node; if (cascader) { - item.label = NAME - item.value = ID - Array.isArray(Children) && Children.length && (item.children = Children) + item.label = NAME; + item.value = ID; + Array.isArray(Children) && Children.length && (item.children = Children); for (let key in Node) { - item[key] = Node[key] + item[key] = Node[key]; } } else { - item.title = NAME - item.key = ID - item.value = ID - item.children = Children + item.title = NAME; + item.key = ID; + item.value = ID; + item.children = Children; } if (Array.isArray(Children) && Children.length) { - constructStandardTreeData(Children, cascader) + constructStandardTreeData(Children, cascader); } - }) + }); } export function renderExportCell(text, record = [], config, enums) { if (config) { - const { enumName } = config + const { enumName } = config; if (enumName) { - return enums[enumName] && enums[enumName].enums ? (enums[enumName].enums[text] || text) : text + return enums[enumName] && enums[enumName].enums + ? enums[enumName].enums[text] || text + : text; } if (config.isBool || config.controlType === 101) { - text = text ? '是' : '否' - } - else if (config.isDate || config.controlType === 102) {//日期 - text = text.toString().substring(0, 10) + text = text ? "是" : "否"; + } else if (config.isDate || config.controlType === 102) { + //日期 + text = text.toString().substring(0, 10); } // 显示日期根据控件类型格式化 else if (config.controlType === 2) { - moment(text).isValid() && (text = moment(text).format('YYYY-MM-DD')) - } - else if (config.controlType === 8) { - moment(text).isValid() && (text = moment(text).format('HH:mm:ss')) - } - else if (config.controlType === 10) { - const dates = (text || '').split(',') + moment(text).isValid() && (text = moment(text).format("YYYY-MM-DD")); + } else if (config.controlType === 8) { + moment(text).isValid() && (text = moment(text).format("HH:mm:ss")); + } else if (config.controlType === 10) { + const dates = (text || "").split(","); if (moment(dates[0]).isValid() && moment(dates[1]).isValid()) { - text = [moment(dates[0]).format('YYYY-MM-DD'), moment(dates[1]).format('YYYY-MM-DD')].join(',') + text = [ + moment(dates[0]).format("YYYY-MM-DD"), + moment(dates[1]).format("YYYY-MM-DD"), + ].join(","); } - } - else if (config.controlType === 18) { - moment(text).isValid() && (text = moment(text).format('YYYY-MM')) - } - else if (config.controlType === 19) { - const months = (text || '').split(',') + } else if (config.controlType === 18) { + moment(text).isValid() && (text = moment(text).format("YYYY-MM")); + } else if (config.controlType === 19) { + const months = (text || "").split(","); if (moment(months[0]).isValid() && moment(months[1]).isValid()) { - text = [moment(months[0]).format('YYYY-MM'), moment(months[1]).format('YYYY-MM')].join(',') + text = [ + moment(months[0]).format("YYYY-MM"), + moment(months[1]).format("YYYY-MM"), + ].join(","); } } // 分页下拉 else if (config.controlType === 9) { if (Array.isArray(record) && record.length) { - const values = (text || '').split(',') - const texts = [] - values.forEach(item => { - const findNode = record.find(rec => rec.ID === item) - findNode && texts.push(`${findNode.CODE}-${findNode.NAME}`) - }) - if (texts.length) return texts.join(',') + const values = (text || "").split(","); + const texts = []; + values.forEach((item) => { + const findNode = record.find((rec) => rec.ID === item); + findNode && texts.push(`${findNode.CODE}-${findNode.NAME}`); + }); + if (texts.length) return texts.join(","); } } // 下拉树选择、级联选择 else if (config.controlType === 11 || config.controlType === 17) { if (Array.isArray(record) && record.length) { - const valueArr = (text || '').split(',') + const valueArr = (text || "").split(","); // 级联选择,取最叶子节点 - const values = config.controlType === 17 ? [valueArr[valueArr.length - 1]] : valueArr - const texts = [] + const values = + config.controlType === 17 + ? [valueArr[valueArr.length - 1]] + : valueArr; + const texts = []; function matchVal(target, source, result) { for (let i = 0, j = source.length; i < j; i++) { - const { title, label, value, children } = source[i] + const { title, label, value, children } = source[i]; if (value === target) { - result.push(title || label) + result.push(title || label); } - if (Array.isArray(children) && children.length) matchVal(target, children, result) + if (Array.isArray(children) && children.length) + matchVal(target, children, result); } } - values.forEach(item => matchVal(item, record, texts)) - if (texts.length) return texts.join(',') + values.forEach((item) => matchVal(item, record, texts)); + if (texts.length) return texts.join(","); } } } - return text + return text; } // 树搜索 export function flatTreeData(tree = [], data = []) { if (Array.isArray(tree) && tree.length) { - tree.forEach(item => { - data.push(omit(item, ['children'])) - flatTreeData(item.children, data) - }) + tree.forEach((item) => { + data.push(omit(item, ["children"])); + flatTreeData(item.children, data); + }); } } export function digTreeData(arr, target) { for (let i = 0, j = arr.length; i < j; i++) { - if (arr[i].Node && arr[i].Node.ID === target) return arr[i] + if (arr[i].Node && arr[i].Node.ID === target) return arr[i]; if (Array.isArray(arr[i].Children) && arr[i].Children.length) { - const result = digTreeData(arr[i].Children, target) - if (result) return result + const result = digTreeData(arr[i].Children, target); + if (result) return result; } } } export function toFixed(num, base = 2, notCeil = true) { - if (typeof num !== 'number') return num - let str = num.toFixed(notCeil ? base + 1 : base) - base === 0 && notCeil && (str = str.substring(0, str.length - 1)) // 防止出现 120. 这类多一个点的字符串 - return str.substring(0, notCeil ? str.length - 1 : str.length) + if (typeof num !== "number") return num; + let str = num.toFixed(notCeil ? base + 1 : base); + base === 0 && notCeil && (str = str.substring(0, str.length - 1)); // 防止出现 120. 这类多一个点的字符串 + return str.substring(0, notCeil ? str.length - 1 : str.length); } //排序 export function compare(obj1, obj2) { @@ -1248,42 +1379,54 @@ export function compare(obj1, obj2) { } export function validUUID(value) { - if (!value) return false - if (value.toString().split('-').length === 4 && value.toString().length === 32) return true - if (value.toString().split('-').length === 5 && value.toString().length === 36) return true - return false + if (!value) return false; + if ( + value.toString().split("-").length === 4 && + value.toString().length === 32 + ) + return true; + if ( + value.toString().split("-").length === 5 && + value.toString().length === 36 + ) + return true; + return false; } //结束任务 export function endTask(orgId, taskID, dispatch) { let jsonEndTask = initFilter(orgId, taskID); dispatch({ - type: 'app/getDataByPost', + type: "app/getDataByPost", payload: jsonEndTask, async: true, - url: 'FM/FMNotificationTask/ChangeStatus', + url: "FM/FMNotificationTask/ChangeStatus", onComplete: (ret) => { if (ret) { } - } + }, }); } //显示审批人签名信息 export function showApprove(listApproveDetail, enums, imgHost, width, height) { // 调用方法钱得自己排序 - var result = [] - if (width == undefined) { width = 200 } - if (height == undefined) { height = 65 } + var result = []; + if (width == undefined) { + width = 200; + } + if (height == undefined) { + height = 65; + } //排序 debugger if (listApproveDetail != null && listApproveDetail.length > 1) { for (let j = 1; j < listApproveDetail.length; j++) { for (let i = 1; i < listApproveDetail.length; i++) { if (listApproveDetail[i - 1].NUM > listApproveDetail[i].NUM) { - let temp = listApproveDetail[i - 1] - listApproveDetail[i - 1] = listApproveDetail[i] - listApproveDetail[i] = temp + let temp = listApproveDetail[i - 1]; + listApproveDetail[i - 1] = listApproveDetail[i]; + listApproveDetail[i] = temp; } } } @@ -1295,17 +1438,26 @@ export function showApprove(listApproveDetail, enums, imgHost, width, height) { // result.push((i > 0 ? ";" : "") + item.NAME + ":" + (item.Nav_ApproveUser != null ? item.Nav_ApproveUser.NAME : "") + "(" + enums[item.NODE_APPROVE_STATUS] + ")") } else { // result.push({item.NAME + ":" + "(" + enums[item.NODE_APPROVE_STATUS] + ")" + (item.CONTEXT == null ? "" : item.CONTEXT)}{item.Nav_ApproveUser) - var url = '#' - if (item.Nav_ApproveUser?.Nav_UserSignFiles != null && item.Nav_ApproveUser?.Nav_UserSignFiles.length > 0) { - if (item.Nav_ApproveUser?.Nav_UserSignFiles[0].Nav_ImgFile?.Nav_File?.FILE_PATH) { - url = imgHost + item.Nav_ApproveUser?.Nav_UserSignFiles[0].Nav_ImgFile.Nav_File.FILE_PATH; + var url = "#"; + if ( + item.Nav_ApproveUser?.Nav_UserSignFiles != null && + item.Nav_ApproveUser?.Nav_UserSignFiles.length > 0 + ) { + if ( + item.Nav_ApproveUser?.Nav_UserSignFiles[0].Nav_ImgFile?.Nav_File + ?.FILE_PATH + ) { + url = + imgHost + + item.Nav_ApproveUser?.Nav_UserSignFiles[0].Nav_ImgFile.Nav_File + .FILE_PATH; } } if (i == 0) { result.push(
-
-
+
+
{item.NAME}
审批结论:{item.CONTEXT == undefined ? "" : item.CONTEXT} @@ -1313,24 +1465,35 @@ export function showApprove(listApproveDetail, enums, imgHost, width, height) { 审核时间:{item.NODE_APPROVE_TIME}
-
- {item.Nav_ApproveUser { - // e.target.src = require('../assets/home/backlog.png'); - // }} +
+ { { + // e.target.src = require('../assets/home/backlog.png'); + // }} />
- ) + ); } else { result.push(
-
-
-
+
+
+
{item.NAME}
审批结论:{item.CONTEXT == undefined ? "" : item.CONTEXT} @@ -1338,215 +1501,370 @@ export function showApprove(listApproveDetail, enums, imgHost, width, height) { 审核时间:{item.NODE_APPROVE_TIME}
-
- {item.Nav_ApproveUser { - // e.target.src = require('../assets/home/backlog.png'); - // }} +
+ { { + // e.target.src = require('../assets/home/backlog.png'); + // }} />
- ) + ); } // result.push({(item.CONTEXT == null ? "" : item.CONTEXT)}{item.Nav_ApproveUser) } - }) - return result + }); + return result; } //显示用户签名 export function showUsersSign(listUsers, imgHost, width, height) { - var result = [] - if (width == undefined) { width = 200 } - if (height == undefined) { height = 50 } + var result = []; + if (width == undefined) { + width = 200; + } + if (height == undefined) { + height = 50; + } if (listUsers != null && listUsers.length > 0) { listUsers = listUsers.sort(function (a, b) { // if (a.CREATE_TIME > b.CREATE_TIME) {//很经常创建时间一样 签名会随机动态变位置 if (a.MODIFY_TIME > b.MODIFY_TIME) { - return 1 + return 1; } else { - return -1 + return -1; } - }) + }); } listUsers?.map((item, i) => { - if (item.Nav_User != null && item.Nav_User.Nav_UserSignFiles != null && item.Nav_User.Nav_UserSignFiles.length > 0) { - result.push({item.Nav_User?.NAME}) - } else if (item.Nav_UserSignFiles != null && item.Nav_UserSignFiles.length > 0) { - result.push({item?.NAME}) + if ( + item.Nav_User != null && + item.Nav_User.Nav_UserSignFiles != null && + item.Nav_User.Nav_UserSignFiles.length > 0 + ) { + result.push( + {item.Nav_User?.NAME} + ); + } else if ( + item.Nav_UserSignFiles != null && + item.Nav_UserSignFiles.length > 0 + ) { + result.push( + {item?.NAME} + ); + } else { + result.push( + {item.Nav_User?.NAME} + ); } - else { - result.push({item.Nav_User?.NAME}) - } - }) - return result + }); + return result; } //显示用户签名 export function showUserSign(user, imgHost, width, height, extShowTimeText) { - var result = [] - if (width == undefined) { width = 200 } - if (height == undefined) { height = 50 } + var result = []; + if (width == undefined) { + width = 200; + } + if (height == undefined) { + height = 50; + } // height={height} - if (user != null && user.Nav_UserSignFiles != null && user.Nav_UserSignFiles.length > 0) { - result.push({user.NAME}) + if ( + user != null && + user.Nav_UserSignFiles != null && + user.Nav_UserSignFiles.length > 0 + ) { + result.push( + {user.NAME} + ); } else { - result.push({user.NAME}) + result.push( + {user.NAME} + ); } if (extShowTimeText) { - result.push({extShowTimeText}) + result.push({extShowTimeText}); } - return result + return result; } //显示参会人(前端map不好去除,) export function showJoinsHtml(arry, isTaskCheck, STATUS) { if (arry != null && arry != undefined && arry.length > 0) { - let arryResult = [] - let j = 0 + let arryResult = []; + let j = 0; arry.map((item, i) => { - if ((item.PERSONNATURE == null || item.PERSONNATURE == 10) && (item.PERSONTYPE == 10 || item.PERSONTYPE == 40)) {//评审人 可能也加入到 参会人员中 || item.PERSONTYPE == 40 + if ( + (item.PERSONNATURE == null || item.PERSONNATURE == 10) && + (item.PERSONTYPE == 10 || item.PERSONTYPE == 40) + ) { + //评审人 可能也加入到 参会人员中 || item.PERSONTYPE == 40 if (!isTaskCheck && (STATUS == 0 || STATUS == 20)) { - arryResult.push((j > 0 ? "," : "") + item.Nav_User.NAME) + arryResult.push((j > 0 ? "," : "") + item.Nav_User.NAME); } else { // 人员 参会反馈情况 有 黑色 无 红色 - arryResult.push(( {(j > 0 ? "," : "") + item.Nav_User.NAME})) + arryResult.push( + + {" "} + {(j > 0 ? "," : "") + item.Nav_User.NAME} + + ); } - j++ + j++; } - }) + }); // if(arryResult[0].substring(0,1)==','){ // arryResult[0]=arryResult[0].substring(1) // } - return arryResult + return arryResult; } else { - return '' + return ""; } } //判断是PC还是移动端 export function getIsPC() { - if (navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/WebOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/Windows Phone/i)) { - return false + if ( + navigator.userAgent.match(/Android/i) || + navigator.userAgent.match(/WebOS/i) || + navigator.userAgent.match(/iPhone/i) || + navigator.userAgent.match(/iPad/i) || + navigator.userAgent.match(/iPod/i) || + navigator.userAgent.match(/Windows Phone/i) + ) { + return false; } else { - return true + return true; } } //task未空的onBeforeSaveHandleRecord事件日志 export function onBeforeSaveHandleRecordLog(params, formCode, title) { - if (params.data.TaskID == '00000000-0000-0000-0000-000000000000' || params.data.id == '00000000-0000-0000-0000-000000000000') { - var orgId = params.login.OrgId; //登录后有存储登录信息 - let json = initFilter(orgId, null, null, null, null, formCode, title, params.data.TaskID, " params.pageCode:[" + params.pageCode + "] params.data.id:[" + params.data.id + "] UserId:[" + params.login.loginInfo.User.ID + "] params.data.taskCode: [" + params.data.taskCode + "] homeReload: [" + params.data.homeReload + "]"); + if ( + params.data.TaskID == "00000000-0000-0000-0000-000000000000" || + params.data.id == "00000000-0000-0000-0000-000000000000" + ) { + var orgId = params.login.OrgId; //登录后有存储登录信息 + let json = initFilter( + orgId, + null, + null, + null, + null, + formCode, + title, + params.data.TaskID, + " params.pageCode:[" + + params.pageCode + + "] params.data.id:[" + + params.data.id + + "] UserId:[" + + params.login.loginInfo.User.ID + + "] params.data.taskCode: [" + + params.data.taskCode + + "] homeReload: [" + + params.data.homeReload + + "]" + ); params.dispatch({ - type: 'app/getDataByPost', - url: 'PF/PFSysLog/addLog', + type: "app/getDataByPost", + url: "PF/PFSysLog/addLog", payload: json, onlyData: false, - onComplete: (ret) => { } - }) + onComplete: (ret) => {}, + }); } } //显示附件 export function showFiles(Nav_Files, imgHost, isShowNO, maxShow = 50) { - var result = [] - var fileName = '' - Nav_Files && Nav_Files?.map((item, i) => { - fileName = item.Nav_ImgFile.FILE_NAME - if (maxShow && maxShow > 3 && fileName.length > maxShow) { - fileName = fileName.substring(0, maxShow - 3) + '......' - } - if (isShowNO) { - result.push({(++i) + "、" + fileName + ' '} ) - } else { - result.push({fileName} ) - } - }) - return result + var result = []; + var fileName = ""; + Nav_Files && + Nav_Files?.map((item, i) => { + fileName = item.Nav_ImgFile.FILE_NAME; + if (maxShow && maxShow > 3 && fileName.length > maxShow) { + fileName = fileName.substring(0, maxShow - 3) + "......"; + } + if (isShowNO) { + result.push( + + {++i + "、" + fileName + " "}{" "} + + ); + } else { + result.push( + + {fileName}{" "} + + ); + } + }); + return result; } export function ShowDateTime(datetime, fmt) { if (datetime == undefined || datetime == null || datetime.length < 1) { - return '' + return ""; } else { - if (fmt == undefined || fmt == null || fmt.length < 1) - fmt = 'yyyy-MM-dd' - return new Date(datetime).Format(fmt) + if (fmt == undefined || fmt == null || fmt.length < 1) fmt = "yyyy-MM-dd"; + return new Date(datetime).Format(fmt); } } export function downLoad(imgHost, fileName) { if (fileName) { - let link = document.createElement('a') - link.href = imgHost + '/' + fileName - document.body.appendChild(link) - window.open(link) + let link = document.createElement("a"); + link.href = imgHost + "/" + fileName; + document.body.appendChild(link); + window.open(link); } else { - alert('获取参数配置失败!') + alert("获取参数配置失败!"); } } Date.prototype.Format = function (fmt) { var o = { - "M+": this.getMonth() + 1, //月份 - "d+": this.getDate(), //日 + "M+": this.getMonth() + 1, //月份 + "d+": this.getDate(), //日 "D+": this.getDate(), //日 //wyw 时间格式 - "H+": this.getHours(), //小时 - "m+": this.getMinutes(), //分 - "s+": this.getSeconds(), //秒 - "q+": Math.floor((this.getMonth() + 3) / 3), //季度 - "S": this.getMilliseconds() //毫秒 + "H+": this.getHours(), //小时 + "m+": this.getMinutes(), //分 + "s+": this.getSeconds(), //秒 + "q+": Math.floor((this.getMonth() + 3) / 3), //季度 + S: this.getMilliseconds(), //毫秒 }; - if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); + if (/(y+)/.test(fmt)) + fmt = fmt.replace( + RegExp.$1, + (this.getFullYear() + "").substr(4 - RegExp.$1.length) + ); for (var k in o) - if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); + if (new RegExp("(" + k + ")").test(fmt)) + fmt = fmt.replace( + RegExp.$1, + RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length) + ); return fmt; -} - +}; export function ShowPrintClose(props) { - if (typeof props.data.onCancel != "undefined" && typeof props.data.onCancel == 'function') + if ( + typeof props.data.onCancel != "undefined" && + typeof props.data.onCancel == "function" + ) props.data.onCancel(); } - //饼图展示 wyw (安全检查情况占比) //legendData, seriesData 数据类型参考方法体 -export function ChartPieShow(echarts, divId, title, legendData, seriesData, tooltipFormatter) { - +export function ChartPieShow( + echarts, + divId, + title, + legendData, + seriesData, + tooltipFormatter +) { //添加缺省参数案例 if (tooltipFormatter == undefined || tooltipFormatter == null) - tooltipFormatter = '{b} : {c} ({d}%)' + tooltipFormatter = "{b} : {c} ({d}%)"; - var element = document.getElementById(divId) + var element = document.getElementById(divId); if (element != undefined) { var myChart = echarts.init(element); var option = { title: { text: title, - left: 'center' + left: "center", }, tooltip: { - trigger: 'item', - formatter: tooltipFormatter + trigger: "item", + formatter: tooltipFormatter, }, legend: { // orient: 'vertical', // left: 'left', - type: 'scroll', + type: "scroll", top: 50, - data: legendData //['综合检查', '例行检查', '巡回检查', '专业检查', '日常巡检'] + data: legendData, //['综合检查', '例行检查', '巡回检查', '专业检查', '日常巡检'] }, series: [ { - type: 'pie', - radius: '55%', - center: ['50%', '50%'], + type: "pie", + radius: "55%", + center: ["50%", "50%"], data: seriesData, // [ // { value: 335, name: '直接访问' }, @@ -1559,120 +1877,150 @@ export function ChartPieShow(echarts, divId, title, legendData, seriesData, tool itemStyle: { shadowBlur: 10, shadowOffsetX: 0, - shadowColor: 'rgba(0, 0, 0, 0.5)' - } - } - } - ] + shadowColor: "rgba(0, 0, 0, 0.5)", + }, + }, + }, + ], }; // 使用刚指定的配置项和数据显示图表。 myChart.setOption(option); } } - //柱状图 (班组安全检查完成率分析) -export function ChartColumnShow(echarts, divId, title, xAxisData, seriesDataFinish, seriesDataNotFinish, tooltipFormatter) { - var element = document.getElementById(divId) +export function ChartColumnShow( + echarts, + divId, + title, + xAxisData, + seriesDataFinish, + seriesDataNotFinish, + tooltipFormatter +) { + var element = document.getElementById(divId); if (element != undefined) { var myChart = echarts.init(element); //添加缺省参数案例 if (tooltipFormatter == undefined || tooltipFormatter == null) - tooltipFormatter = '{b} : {c} ' + tooltipFormatter = "{b} : {c} "; var option = { title: { text: title, - left: 'center' + left: "center", }, tooltip: { - trigger: 'item', - formatter: tooltipFormatter + trigger: "item", + formatter: tooltipFormatter, }, /***横向排列***/ yAxis: { - data: xAxisData + data: xAxisData, }, xAxis: {}, series: [ { - type: 'bar', - stack: 'total', - data: seriesDataFinish,// [320, 302, 301, 334, 390, 330, 320] + type: "bar", + stack: "total", + data: seriesDataFinish, // [320, 302, 301, 334, 390, 330, 320] label: { show: true, // formatter:'{c0/(c0+c1)}%' - } + }, }, { - type: 'bar', - stack: 'total', - data: seriesDataNotFinish,// [120, 132, 101, 134, 90, 230, 210] + type: "bar", + stack: "total", + data: seriesDataNotFinish, // [120, 132, 101, 134, 90, 230, 210] label: { show: true, - } + }, }, ], - } - }; + }; + } // 使用刚指定的配置项和数据显示图表。 myChart.setOption(option); } - export function openNotificationMobile(placement, notification) { notification.info({ duration: 20, message: `友情提示:`, - description: - '您当前用的是手机在访问,为有更好体验,建议使用电脑访问!', + description: "您当前用的是手机在访问,为有更好体验,建议使用电脑访问!", placement, }); } - -export function auditOptionShow(stateData, dataState, stateReject, propName, dataId, dispatch, setFieldVisible) { +export function auditOptionShow( + stateData, + dataState, + stateReject, + propName, + dataId, + dispatch, + setFieldVisible +) { if (propName == undefined || propName == null) { - propName = "AUDIT_OPINION" + propName = "AUDIT_OPINION"; } if (dataState == stateReject) { dispatch({ - type: 'app/getDataByPost', - url: 'HM/HMHazardRecord/GetRejectContent', + type: "app/getDataByPost", + url: "HM/HMHazardRecord/GetRejectContent", payload: { ID: dataId, }, onComplete: (ret) => { // setFieldValue(propName, ret) - stateData[propName] = ret // dataState.AUDIT_OPINION = ret - return ret - } + stateData[propName] = ret; // dataState.AUDIT_OPINION = ret + return ret; + }, }); } else { setFieldVisible(propName, false); } } -export function auditOptionShow2(stateData, dataState, stateReject, propName, dataId, dispatch, setFieldVisible) { +export function auditOptionShow2( + stateData, + dataState, + stateReject, + propName, + dataId, + dispatch, + setFieldVisible +) { if (propName == undefined || propName == null) { - propName = "AUDIT_OPINION" + propName = "AUDIT_OPINION"; } if (dataState == stateReject) { dispatch({ - type: 'app/getDataByGet', - url: 'PF/PFApprove/GetRejectContentByAPPID', + type: "app/getDataByGet", + url: "PF/PFApprove/GetRejectContentByAPPID", //url: 'PF/PFApprove/GetRejectContent?ApproveID=' + dataId, payload: { ApproveID: dataId, }, onComplete: (ret) => { - stateData[propName] = ret - return ret - } + stateData[propName] = ret; + return ret; + }, }); } else { setFieldVisible(propName, false); } -} \ No newline at end of file +} +export function getSixMonth(number, yearString = "", monthString = "") { + let nowdate = new Date(); + nowdate.setMonth(nowdate.getMonth() + number); + let y = nowdate.getFullYear(); + let m = nowdate.getMonth() + 1; + // let d = nowdate.getDate(); + let retrundate = y + yearString + m + monthString; + + return retrundate; +}