From 0522a8f2bcab8a9b4219d88581ee9178e6ff7d49 Mon Sep 17 00:00:00 2001 From: yunkexin <760754045@qq.com> Date: Wed, 22 Apr 2026 13:47:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AF=E8=A7=86=E5=8C=96=E3=80=81tableconfig?= =?UTF-8?q?=E5=AF=B9=E4=BA=8E=E6=8C=89=E9=92=AEand=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TableBaseComponent/index.js | 1769 +++++++++------- src/layout/FullOther/HomeContent.js | 630 ++++++ src/layout/FullScreenInter.js | 1868 ++--------------- src/layout/fullinter.less | 867 ++++---- 4 files changed, 2237 insertions(+), 2897 deletions(-) create mode 100644 src/layout/FullOther/HomeContent.js diff --git a/src/baseComponents/TableBaseComponent/index.js b/src/baseComponents/TableBaseComponent/index.js index 59d85bf..000cf5b 100644 --- a/src/baseComponents/TableBaseComponent/index.js +++ b/src/baseComponents/TableBaseComponent/index.js @@ -1,40 +1,41 @@ -import React from 'react' -import { Table, Button, message, notification, Icon, Checkbox, Pagination, Spin, Upload } from 'antd' +import React from 'react'; +import { Table, Button, message, notification, Icon, Checkbox, Pagination, Spin, Upload } from 'antd'; import { empty, extendInclude, getDataFieldValue, guid, - initFilter, getCustomParams, + initFilter, + getCustomParams, addRuleAndGroups, setDataFieldValue, extendOrder, extend, renderExportCell, compare, - getParseValue -} from '../../utils/common' -import ComponentBase from "../ComponentBase"; + getParseValue, +} from '../../utils/common'; +import ComponentBase from '../ComponentBase'; import styles from './index.css'; import EditModal from '../../components/Edit/EditModal'; import TableFooterByTotal from '../../components/Table/TableFooterByTotal'; import FormPage from '../../components/FormPage'; import ShowModal from '../../components/common/ShowModal'; -import FormModal from '../../components/FormModal' -import { ConfirmButton, ExportToExcel, HttpPrint, PictureThumb, IFComponent } from '@woowalker/feui' +import FormModal from '../../components/FormModal'; +import { ConfirmButton, ExportToExcel, HttpPrint, PictureThumb, IFComponent } from '@woowalker/feui'; import DataLoading from '../../components/common/DataLoading'; import BDWordPreviewPage from '../../components/CustomPages/BD/BDWordPreviewPage'; import ColumnSetting from './TableColumnSetting'; -import ColumnSort from "../../components/common/CustomFieldsManage"; +import ColumnSort from '../../components/common/CustomFieldsManage'; import ImportModal from './ImportModal'; import TableResizableCell from '../../components/Table/TableResizableCell'; -import { cloneDeep, get } from 'lodash' -import classNames from 'classnames' +import { cloneDeep, get } from 'lodash'; +import classNames from 'classnames'; import TableModal from '../../components/Table/TableModal'; -import CombinationModal from '../../components/Combination/CombinationModal' -import { getDragableProps, DragDropCard } from '../../utils/withDragDropContext' -import update from 'immutability-helper' -import config from "../../config" +import CombinationModal from '../../components/Combination/CombinationModal'; +import { getDragableProps, DragDropCard } from '../../utils/withDragDropContext'; +import update from 'immutability-helper'; +import config from '../../config'; import storage from '../../utils/storage'; const { Column } = Table; @@ -45,23 +46,23 @@ class TableBaseComponent extends ComponentBase { data: {}, tableConfig: {}, loadParam: {}, - searchColumnText: "", // 列搜索文本 - showColumnSetting: null, // 显示表头的设置图标 + searchColumnText: '', // 列搜索文本 + showColumnSetting: null, // 显示表头的设置图标 showFilterDropdown: false, formLoading: false, localSearch: { // field: "", // value: "" - } + }, }; this.defaultTableCode = 'table'; this.genDataSource = this.genDataSource.bind(this); - }; + } componentDidMount() { super.componentDidMount(); this.onLoadData(); - }; + } /* 加载数据 事件 @@ -73,7 +74,7 @@ class TableBaseComponent extends ComponentBase { if (!tableConfig) { tableConfig = {}; } - tableConfigs.forEach(t => { + tableConfigs.forEach((t) => { if (t.tableCode === undefined) { t.tableCode = this.defaultTableCode; } @@ -94,13 +95,15 @@ class TableBaseComponent extends ComponentBase { } tableConfig[t.tableCode] = t; }); - this.setState({ - tableConfig, - }, () => { - this.onAfterLoadData(); - }); - } - else { + this.setState( + { + tableConfig, + }, + () => { + this.onAfterLoadData(); + } + ); + } else { this.onAfterLoadData(); } } @@ -142,27 +145,23 @@ class TableBaseComponent extends ComponentBase { isShowRowNo,是否显示序号 } */ - onGetTableConfig() { - - } + onGetTableConfig() {} /* 获取表配置信息 之后 */ - onAfterGetTableConfig() { - - } + onAfterGetTableConfig() {} /* 依搜索参数加载表数据 */ loadDataTableBySearch = (tableCode, data) => { - const tableConfig = this.getTableConfig({ tableCode }) - const customParams = getCustomParams(tableConfig.customParams) + const tableConfig = this.getTableConfig({ tableCode }); + const customParams = getCustomParams(tableConfig.customParams); let { param, extendParam = {} } = data ? data : {}; - extendParam["PageIndex"] = 1; - extendParam["Start"] = 0; + extendParam['PageIndex'] = 1; + extendParam['Start'] = 0; extendParam['IsAllLoad'] = !!customParams.IsAllLoad; const tempParamJson = this.getLoadParam({ tableCode }); if (param && extendParam) { @@ -174,45 +173,42 @@ class TableBaseComponent extends ComponentBase { const loadParamJson = this.initLoadParam({ tableCode }); extendParam = { ...loadParamJson, - ...extendParam - } + ...extendParam, + }; } this.setLoadParam({ tableCode, loadParam: extendParam, onComplete: () => { this.loadTableData({ tableCode }); - } - }) - } + }, + }); + }, }); - } - else if (param) { + } else if (param) { this.setSearchParam({ tableCode, searchParam: param, onComplete: () => { this.loadTableData({ tableCode }); - } + }, }); - } - else if (extendParam) { + } else if (extendParam) { if (!tempParamJson) { const loadParamJson = this.initLoadParam({ tableCode }); extendParam = { ...loadParamJson, - ...extendParam - } + ...extendParam, + }; } this.setLoadParam({ tableCode, loadParam: extendParam, onComplete: () => { this.loadTableData({ tableCode }); - } - }) - } - else { + }, + }); + } else { this.loadTableData({ tableCode }); } }; @@ -239,26 +235,28 @@ class TableBaseComponent extends ComponentBase { if (pageIndex) { let pz = 10; if (pageSize >= 0) { - pz = pageSize + pz = pageSize; } else if (defaultPageSize) { - pz = defaultPageSize + pz = defaultPageSize; } else { - pz = 10 + pz = 10; } loadParamJson.PageIndex = pageIndex; loadParamJson.Start = (pageIndex - 1) * pz; } - const selectFields = (tableConfig.navColumns || []).map(col => { - return col.FIELD_NAME && col.FIELD_NAME !== 'null' ? col.FIELD_NAME : false - }).filter(field => !!field) + const selectFields = (tableConfig.navColumns || []) + .map((col) => { + return col.FIELD_NAME && col.FIELD_NAME !== 'null' ? col.FIELD_NAME : false; + }) + .filter((field) => !!field); if (selectFields.length && !tableConfig.isNoSelectField) { if (selectFields.indexOf('ID') === -1) { - selectFields.push('ID') + selectFields.push('ID'); } if (selectFields.indexOf('ORG_ID') === -1) { - selectFields.push('ORG_ID') + selectFields.push('ORG_ID'); } - loadParamJson.SelectField = selectFields + loadParamJson.SelectField = selectFields; } if (tableConfig && tableConfig.rule) { addRuleAndGroups(loadParamJson, tableConfig.rule); @@ -281,10 +279,9 @@ class TableBaseComponent extends ComponentBase { const paramJson = this.getLoadParam({ tableCode }); const tempJson = paramJson ? JSON.parse(JSON.stringify(paramJson)) : {}; this.doLoadTableData({ ...tempJson }, tableCode, onComplete, onLoadData); - } + }, }); - } - else { + } else { const paramJson = this.getLoadParam({ tableCode }); const tempJson = paramJson ? JSON.parse(JSON.stringify(paramJson)) : {}; this.doLoadTableData({ ...tempJson }, tableCode, onComplete, onLoadData); @@ -294,24 +291,20 @@ class TableBaseComponent extends ComponentBase { /* 重置加载表数据参数 */ - onLoadTableDataParam(params) { - - } + onLoadTableDataParam(params) {} /* 加载数据之后 */ - onAfterLoadTableData(params) { - - } - getRequestHeaders =() =>{ + onAfterLoadTableData(params) {} + getRequestHeaders = () => { // 请求参数 - const addHeader = 'Bearer ' + storage('lacal').getItem('accessToken').val - const userId = storage('lacal').getItem('userid').val - const user = storage('lacal').getItem('loginUserVerify').val - const RootOrgId = storage('lacal').getItem('RootOrgId').val - const orgId = storage('lacal').getItem('webOrgId').val - const Tenant = storage('lacal').getItem('Tenant').val + const addHeader = 'Bearer ' + storage('lacal').getItem('accessToken').val; + const userId = storage('lacal').getItem('userid').val; + const user = storage('lacal').getItem('loginUserVerify').val; + const RootOrgId = storage('lacal').getItem('RootOrgId').val; + const orgId = storage('lacal').getItem('webOrgId').val; + const Tenant = storage('lacal').getItem('Tenant').val; const headers = { // 'Content-Type': type === 'post' ? 'application/json' : 'application/x-www-form-urlencoded', Authorization: addHeader, @@ -319,10 +312,10 @@ class TableBaseComponent extends ComponentBase { username: user ? user.username : '', RootOrgId, orgId, - Tenant:Tenant - } - return headers - } + Tenant: Tenant, + }; + return headers; + }; /** * 获取表格加载参数 @@ -337,7 +330,7 @@ class TableBaseComponent extends ComponentBase { const { api, sorts, orgType, authOrgCodes, ignoreOrgRule } = tableConfig ? tableConfig : {}; if (api === null || api === undefined) return false; if (sorts && sorts.length) { - sorts.forEach(t => { + sorts.forEach((t) => { extendOrder(loadParamJson, t.sort, t.order); }); } @@ -345,12 +338,14 @@ class TableBaseComponent extends ComponentBase { //去重添加添加导航属性 const navFields = []; if (tableConfig && tableConfig.includes && tableConfig.includes.length) { - tableConfig.includes.forEach(t => { + tableConfig.includes.forEach((t) => { navFields.push(t); }); - } - else if (tableConfig) { - const cols = tableConfig.originalColumns && tableConfig.originalColumns.length ? tableConfig.originalColumns : tableConfig.columns; + } else if (tableConfig) { + const cols = + tableConfig.originalColumns && tableConfig.originalColumns.length + ? tableConfig.originalColumns + : tableConfig.columns; if (cols && cols.length) { const doGetInclude = (f) => { if (f && f.indexOf('.') > 0) { @@ -358,8 +353,8 @@ class TableBaseComponent extends ComponentBase { let includeTable = f.substring(0, pos); navFields.push(includeTable); } - } - cols.forEach(t => { + }; + cols.forEach((t) => { const field = t.field; if (field) { let opIndex = field.indexOf('+'); @@ -377,8 +372,7 @@ class TableBaseComponent extends ComponentBase { const rightField = field.substring(opIndex + 1); doGetInclude(leftField); doGetInclude(rightField); - } - else { + } else { doGetInclude(field); } } @@ -406,32 +400,33 @@ class TableBaseComponent extends ComponentBase { } } // 菜单参数 - const { currActivatedMenu } = this.props.app || {} - loadParamJson['MenuParameter'] = currActivatedMenu && currActivatedMenu.MENU_FORM_PARAMS ? currActivatedMenu.MENU_FORM_PARAMS : '' + const { currActivatedMenu } = this.props.app || {}; + loadParamJson['MenuParameter'] = + currActivatedMenu && currActivatedMenu.MENU_FORM_PARAMS ? currActivatedMenu.MENU_FORM_PARAMS : ''; // 是否忽略组织权限 if (ignoreOrgRule) { - loadParamJson.IgnoreOrgRule = ignoreOrgRule + loadParamJson.IgnoreOrgRule = ignoreOrgRule; } const isError = this.onLoadTableDataParam({ tableCode, loadParam: loadParamJson, tableConfig }); if (isError) return false; - return loadParamJson - } + return loadParamJson; + }; /* 实际加载表数据 */ doLoadTableData = (loadParamJson, tableCode, onComplete, onLoadData) => { - console.log('调用查询实际过程', 6) - const payloadJson = this.getLoadTableDataParams(loadParamJson, tableCode) - if (!payloadJson) return + console.log('调用查询实际过程', 6); + const payloadJson = this.getLoadTableDataParams(loadParamJson, tableCode); + if (!payloadJson) return; if (tableCode === undefined) { tableCode = this.defaultTableCode; } const tableConfig = this.getTableConfig({ tableCode }); const { api } = tableConfig ? tableConfig : {}; - console.log('调用查询实际过程', 7, api) + console.log('调用查询实际过程', 7, api); this.props.dispatch({ type: 'listPage/getTableData', @@ -443,19 +438,21 @@ class TableBaseComponent extends ComponentBase { } if (ret && ret.Data && ret.Data.length && tableConfig.isShowRowNo) { ret.Data.forEach((n, i) => { - n.ROW_NO = (i + 1); + n.ROW_NO = i + 1; }); } if (typeof onLoadData === 'function') { onLoadData(ret); - } - else { + } else { this.setTableData({ tableCode, data: ret, onComplete: () => { if (ret && typeof tableConfig.onAfterGetData === 'function') { - tableConfig.onAfterGetData(ret.Data, tableConfig.pageTable ? tableConfig.pageTable.CODE : tableConfig.tableCode); + tableConfig.onAfterGetData( + ret.Data, + tableConfig.pageTable ? tableConfig.pageTable.CODE : tableConfig.tableCode + ); } if (ret) { this.onAfterLoadTableData({ tableCode, data: ret.Data }); @@ -463,16 +460,16 @@ class TableBaseComponent extends ComponentBase { if (typeof onComplete === 'function') { onComplete(); } - } + }, }); } // 设置默认选中 - const { rowSelectedKeys } = this.props + const { rowSelectedKeys } = this.props; if (Array.isArray(rowSelectedKeys) && rowSelectedKeys.length) { - this.setTableSelectedRowKeys({ tableCode, selectedKeys: rowSelectedKeys }) + this.setTableSelectedRowKeys({ tableCode, selectedKeys: rowSelectedKeys }); } - } - }) + }, + }); }; /* @@ -529,13 +526,16 @@ class TableBaseComponent extends ComponentBase { [tableCode]: tableConfig, }; - this.setState({ - tableConfig: tempTableConfig - }, () => { - if (typeof onComplete === 'function') { - onComplete(); + this.setState( + { + tableConfig: tempTableConfig, + }, + () => { + if (typeof onComplete === 'function') { + onComplete(); + } } - }); + ); } /* @@ -574,13 +574,16 @@ class TableBaseComponent extends ComponentBase { [tableCode]: loadParam, }; - this.setState({ - loadParam: tempLoadParam - }, () => { - if (typeof onComplete === 'function') { - onComplete(); + this.setState( + { + loadParam: tempLoadParam, + }, + () => { + if (typeof onComplete === 'function') { + onComplete(); + } } - }); + ); } /* @@ -619,13 +622,16 @@ class TableBaseComponent extends ComponentBase { [tableCode]: searchParam, }; - this.setState({ - searchParam: tempSearchParam - }, () => { - if (typeof onComplete === 'function') { - onComplete(); + this.setState( + { + searchParam: tempSearchParam, + }, + () => { + if (typeof onComplete === 'function') { + onComplete(); + } } - }); + ); } /* @@ -656,13 +662,16 @@ class TableBaseComponent extends ComponentBase { [tableCode]: data, }; - this.setState({ - data: tempData - }, () => { - if (typeof onComplete === 'function') { - onComplete(); + this.setState( + { + data: tempData, + }, + () => { + if (typeof onComplete === 'function') { + onComplete(); + } } - }); + ); } /* @@ -683,7 +692,7 @@ class TableBaseComponent extends ComponentBase { /** * add by qxiong 2020.06.11 - * @param {*} param0 + * @param {*} param0 * 设置所有页面选中 * 在此日期前,有关 selectedKeys 的使用 * 并没有发现复制一份旧的 selectedKeys, 然后使用 tableCode 保存新一份 selectedKeys 有什么作用 @@ -693,15 +702,15 @@ class TableBaseComponent extends ComponentBase { * 所以就相当于直接在这个组件中定义 state,基本都取不到 */ setTableSelectedRowsAll = ({ selectedRowKeys, selectedRows = [] }) => { - const { selectedRowsAll = [] } = this.state - selectedRowsAll.push(...selectedRows) - const tempSelected = [] - selectedRowKeys.forEach(key => { - const find = selectedRowsAll.find(row => row.ID === key) - find && tempSelected.push(find) - }) - this.state.selectedRowsAll = tempSelected - } + const { selectedRowsAll = [] } = this.state; + selectedRowsAll.push(...selectedRows); + const tempSelected = []; + selectedRowKeys.forEach((key) => { + const find = selectedRowsAll.find((row) => row.ID === key); + find && tempSelected.push(find); + }); + this.state.selectedRowsAll = tempSelected; + }; /* 设置选中 @@ -722,18 +731,24 @@ class TableBaseComponent extends ComponentBase { if (!selectedKeys || !selectedKeys.length) { isSelected = false; } - this.setState({ - selectedKeys: tempSelectedKeys, - [tableCode + '_isSelected']: isSelected, - }, () => { - const tableConfig = this.getTableConfig({ tableCode }); - if (tableConfig && typeof tableConfig.onSelectChange === 'function') { - tableConfig.onSelectChange(this.getTableSelectedRowKeys({ tableCode }), (tableConfig.pageTable ? tableConfig.pageTable.CODE : tableCode)); + this.setState( + { + selectedKeys: tempSelectedKeys, + [tableCode + '_isSelected']: isSelected, + }, + () => { + const tableConfig = this.getTableConfig({ tableCode }); + if (tableConfig && typeof tableConfig.onSelectChange === 'function') { + tableConfig.onSelectChange( + this.getTableSelectedRowKeys({ tableCode }), + tableConfig.pageTable ? tableConfig.pageTable.CODE : tableCode + ); + } + if (typeof onComplete === 'function') { + onComplete(); + } } - if (typeof onComplete === 'function') { - onComplete(); - } - }); + ); } /* @@ -742,18 +757,17 @@ class TableBaseComponent extends ComponentBase { onTableChange = (tableCode, pagination, filters, sorter) => { const { current, pageSize } = pagination; const loadParam = this.getLoadParam({ tableCode }); - let sort = { - }; + let sort = {}; if (sorter && sorter.field) { - sort["Sort"] = sorter.field; - sort["Order"] = sorter.order === "descend" ? '0' : '1'; + sort['Sort'] = sorter.field; + sort['Order'] = sorter.order === 'descend' ? '0' : '1'; } let newParams = { ...loadParam, OrgId: this.props.login.OrgId, PageIndex: current, Limit: pageSize, - Start: (current - 1) * pageSize + Start: (current - 1) * pageSize, }; const tempParam = { ...newParams, ...sort }; if (!loadParam.IsAllLoad) { @@ -765,7 +779,7 @@ class TableBaseComponent extends ComponentBase { loadParam: tempParam, onComplete: () => { this.onAfterTableChange({ tableCode, pagination, filters, sorter, loadParam: tempParam }); - } + }, }); }; @@ -779,18 +793,17 @@ class TableBaseComponent extends ComponentBase { loadParam } */ - onAfterTableChange(params) { - - } + onAfterTableChange(params) {} /* 选中表行项改变时 */ - onSelectTableChange = (tableCode, selectedRowKeys, selectedRows) => { // 选择表格行 - this.setTableSelectedRowsAll({ selectedRowKeys, selectedRows }) + onSelectTableChange = (tableCode, selectedRowKeys, selectedRows) => { + // 选择表格行 + this.setTableSelectedRowsAll({ selectedRowKeys, selectedRows }); this.setTableSelectedRowKeys({ tableCode, selectedKeys: selectedRowKeys }); this.setState({ - [tableCode + '_isSelected']: selectedRowKeys && selectedRowKeys.length + [tableCode + '_isSelected']: selectedRowKeys && selectedRowKeys.length, }); }; @@ -806,12 +819,12 @@ class TableBaseComponent extends ComponentBase { const selectKeys = this.getTableSelectedRowKeys({ tableCode }); const result = []; if (selectKeys && tableData && tableData.Data) { - selectKeys.forEach(item => { - tableData.Data.forEach(t => { + selectKeys.forEach((item) => { + tableData.Data.forEach((t) => { if (item.toString().toUpperCase() == t.ID.toString().toUpperCase()) { result.push(t); } - }) + }); }); } return result; @@ -830,7 +843,7 @@ class TableBaseComponent extends ComponentBase { list = []; data.Data = []; } - const index = list.findIndex(item => record.ID === item.ID); + const index = list.findIndex((item) => record.ID === item.ID); const item = list[index]; if (item) { list.splice(index, 1, { @@ -841,16 +854,14 @@ class TableBaseComponent extends ComponentBase { this.setTableData({ tableCode, data, - onComplete + onComplete, }); } /* {field,value,colConfig,record,thisRef,tableCode} */ - onAfterRowControlChange(params) { - - } + onAfterRowControlChange(params) {} /* {field,value,colConfig,record,thisRef} */ @@ -879,9 +890,7 @@ class TableBaseComponent extends ComponentBase { /* {field,colConfig,record,thisRef,tableCode} */ - onAfterRowControlBlur(params) { - - } + onAfterRowControlBlur(params) {} /* {record,选中记录 @@ -891,28 +900,30 @@ class TableBaseComponent extends ComponentBase { tableCode, } */ - onRowDropDownFillData(params) { - - } + onRowDropDownFillData(params) {} /* {record,complete,colConfig,data,columns,thisRef} */ - onBeforeRowDropDownSelect(params) { - - } + onBeforeRowDropDownSelect(params) {} /* {record,complete,colConfig,data,columns,thisRef} */ - onAfterRowDropDownSelect(params) { - - } + onAfterRowDropDownSelect(params) {} /* {record,complete,colConfig,data,columns,thisRef} */ onRowDropDownSelect(params) { - const { record, complete, colConfig, data, columns, thisRef, tableCode = thisRef.defaultTableCode } = params ? params : {}; + const { + record, + complete, + colConfig, + data, + columns, + thisRef, + tableCode = thisRef.defaultTableCode, + } = params ? params : {}; if (thisRef.onBeforeRowDropDownSelect({ ...params })) return; const configData = colConfig.data; thisRef.fillDropDownSelectRecord({ @@ -937,9 +948,15 @@ class TableBaseComponent extends ComponentBase { const saveFields = configData.saveField ? configData.saveField.split(',') : []; if (saveFields && saveFields.length && columns && columns.length) { saveFields.forEach((n, i) => { - columns.forEach(item => { + columns.forEach((item) => { if (item.field == n) { - thisRef.onAfterRowControlChange({ field: n, value: getDataFieldValue(data, n), colConfig: item, record: data, tableCode }); + thisRef.onAfterRowControlChange({ + field: n, + value: getDataFieldValue(data, n), + colConfig: item, + record: data, + tableCode, + }); } }); }); @@ -951,9 +968,7 @@ class TableBaseComponent extends ComponentBase { /* {record,colConfig,params,thisRef,tableCode} */ - onRowDropDownFilter(params) { - - } + onRowDropDownFilter(params) {} /* {tableCode,record,isShow,isPermit,getHeadFieldValue} @@ -964,10 +979,10 @@ class TableBaseComponent extends ComponentBase { return { record: record, onSave: (row) => { - this.saveRowRecord({ ...params, record: row, }); + this.saveRowRecord({ ...params, record: row }); }, stateData: data ? [] : data.Data, - } + }; } /* @@ -977,8 +992,9 @@ class TableBaseComponent extends ComponentBase { col.value = getDataFieldValue(record, col.field); if (col.field && col.field.indexOf('Nav_SysParams') > -1) { col.value = this.getControlValue({ - controlType: col.controlType, value: col.value, - data: col.data + controlType: col.controlType, + value: col.value, + data: col.data, }); } col.showFormId = record && col.showIdField ? getDataFieldValue(record, col.showIdField) : null; @@ -986,16 +1002,18 @@ class TableBaseComponent extends ComponentBase { this.onRowControlChange({ ...params, ...changeParam, record, colConfig: col }); }; col.onBlur = (blurParam) => { - this.onRowControlBlur({ ...params, ...blurParam, record, colConfig: col, }); + this.onRowControlBlur({ ...params, ...blurParam, record, colConfig: col }); }; - if (col.controlType === 9) {//分页下拉 + if (col.controlType === 9) { + //分页下拉 if (!col.data) { col.data = {}; } col.data.onSelect = (selectParam) => { this.onRowDropDownSelect({ - ...params, ...selectParam, + ...params, + ...selectParam, complete: selectParam.complete, record: selectParam.record, data: record, @@ -1004,13 +1022,13 @@ class TableBaseComponent extends ComponentBase { }; col.data.onFilter = (filterParams) => { this.onRowDropDownFilter({ ...params, ...filterParams, record, colConfig: col }); - } + }; } if (col.editFormCode) { if (!col.data) { col.data = {}; } - col.data.editFormData = this.onRowEditFormData({ ...params, record, }); + col.data.editFormData = this.onRowEditFormData({ ...params, record }); } } @@ -1030,29 +1048,35 @@ class TableBaseComponent extends ComponentBase { tableCode: tc, loadParam: { Order: orderType, - Sort: sortType + Sort: sortType, }, onComplete: () => { this.loadTableData({ tableCode: tc }); - } - }) - } + }, + }); + }; /**搜索单列 */ - setSearchInfo = (value, fields,) => { + setSearchInfo = (value, fields) => { this.setState({ localSearch: { fields, - value - } - }) - } + value, + }, + }); + }; /**单元格 */ renderCell = ({ isShowCol, col, tableCode, tableConfig, record, text, columns }) => { if (isShowCol) { if (col.formatFuncName) { col.format = (params) => { - const formatValue = this.onTableRowFormatColumn({ record: params.record, text: params.text, tableCode, tableConfig, colConfig: params.col }); + const formatValue = this.onTableRowFormatColumn({ + record: params.record, + text: params.text, + tableCode, + tableConfig, + colConfig: params.col, + }); setDataFieldValue(record, (col.field ? col.field : col.formatFuncName) + '_formatValue', formatValue); return formatValue; }; @@ -1060,12 +1084,15 @@ class TableBaseComponent extends ComponentBase { return this.getTableCellText({ col, record, text }); } this.setRowColumnConfig({ col, params: { columns, tableCode, tableConfig }, record }); - return
0 && col.width, wordWrap: 'break-word', wordBreak: 'break-all' }}> - { - this.getControl(col) - } -
- } + return ( +
0 && col.width, wordWrap: 'break-word', wordBreak: 'break-all' }} + > + {this.getControl(col)} +
+ ); + }; /* { @@ -1089,46 +1116,45 @@ class TableBaseComponent extends ComponentBase { if (tableConfig.isShowRowNo) { tmp.push({ title: '序号', key: 'ROW_NO', dataIndex: 'ROW_NO', width: 60 }); } - columns.forEach(col => { + columns.forEach((col) => { if (col.visible || col.visible === undefined) { - const isShowCol = col.controlType === null || col.controlType === undefined || col.controlType === 0 || col.controlType > 100; - const uniqueKey = col.id ? col.id : (col.field ? col.field : col.formatFuncName); + const isShowCol = + col.controlType === null || col.controlType === undefined || col.controlType === 0 || col.controlType > 100; + const uniqueKey = col.id ? col.id : col.field ? col.field : col.formatFuncName; const columnObj = { - title:
{col.label}
, + title:
{col.label}
, key: uniqueKey, dataIndex: col.field, - filterDropdown: args => { - return this.setSortData(type, col.field, tableCode)} - setSearchInfo={val => this.setSearchInfo(val, col.field, tableCode)} - tableConfig={tableConfig} - onMouseLeave={() => this.setState({ showFilterDropdown: false, showColumnSetting: null })} - stateTableConfig={this.state.tableConfig} - setTableConfig={value => this.setState({ tableConfig: value })} - colConfig={col} - /> + filterDropdown: (args) => { + return ( + this.setSortData(type, col.field, tableCode)} + setSearchInfo={(val) => this.setSearchInfo(val, col.field, tableCode)} + tableConfig={tableConfig} + onMouseLeave={() => this.setState({ showFilterDropdown: false, showColumnSetting: null })} + stateTableConfig={this.state.tableConfig} + setTableConfig={(value) => this.setState({ tableConfig: value })} + colConfig={col} + /> + ); }, filterDropdownVisible: showFilterDropdown && showColumnSetting === uniqueKey, - filterIcon: filtered => ( - showColumnSetting === uniqueKey - ? - :
- ), + filterIcon: (filtered) => (showColumnSetting === uniqueKey ? :
), onFilterDropdownVisibleChange: (visible) => { this.setState({ - showFilterDropdown: visible - }) + showFilterDropdown: visible, + }); }, render: (text, record) => { const convertText = this.renderCell({ isShowCol, col, tableCode, tableConfig, record, text, columns }); - const cellTitle = (typeof convertText === "string" || typeof convertText === "number") ? convertText : ""; - return {convertText} - } - } - col.width && (columnObj.width = col.width) + const cellTitle = typeof convertText === 'string' || typeof convertText === 'number' ? convertText : ''; + return {convertText}; + }, + }; + col.width && (columnObj.width = col.width); tmp.push(columnObj); } }); @@ -1145,55 +1171,78 @@ class TableBaseComponent extends ComponentBase { 获取渲染按钮 */ getRenderBtns(tableCode, tableConfig, record, btns, type) { - const filterBtns = [] + console.log('1111111111'); + const filterBtns = []; if (btns && btns.length) { - btns.forEach(btn => { - const { BTN_CONDITION } = btn.btn || {} + btns.forEach((btn) => { + const { BTN_CONDITION } = btn.btn || {}; if (BTN_CONDITION) { - const conditions = BTN_CONDITION.split('|').map(item => { - const conds = item.split(',') + // 判断是 AND 还是 OR 逻辑 + let isAndLogic = BTN_CONDITION.includes('&'); + let separator = isAndLogic ? '&' : '|'; + const conditionGroups = BTN_CONDITION.split(separator).map((item) => { + const conds = item.split(','); return { field: conds[0], operate: conds[1], //value: conds[2] - value: getParseValue(conds[2], this.props.login.user) - } - }) - const find = conditions.find(cond => { - const { field, operate, value } = cond - //let fileValue=getDataFieldValue(record, field); - let fileValue=get(record,field); - switch (Number(operate)) { - case 1: // 等于 - return fileValue == value - case 2: // 不等于 - return fileValue != value - default: - return false - } - }) - find && filterBtns.push(btn) + value: getParseValue(conds[2], this.props.login.user), + }; + }); + // 根据逻辑类型判断是否满足条件 + let isConditionMatch = false; + if (isAndLogic) { + // AND 逻辑:所有条件都必须满足 + isConditionMatch = conditionGroups.every((cond) => { + const { field, operate, value } = cond; + let fileValue = get(record, field); + switch (Number(operate)) { + case 1: // 等于 + return fileValue == value; + case 2: // 不等于 + return fileValue != value; + default: + return false; + } + }); + } else { + // OR 逻辑:任意一个条件满足即可 + isConditionMatch = conditionGroups.some((cond) => { + const { field, operate, value } = cond; + let fileValue = get(record, field); + switch (Number(operate)) { + case 1: + return fileValue == value; + case 2: + return fileValue != value; + default: + return false; + } + }); + } + + if (isConditionMatch) { + filterBtns.push(btn); + } } else { - filterBtns.push(btn) + filterBtns.push(btn); } - }) + }); } //排序 filterBtns.sort(compare); - return filterBtns.map(t => { + return filterBtns.map((t) => { return this.getRenderBtn({ tableCode, tableConfig, record, btnConfig: t, type }); - }) + }); } - /* 获取表行项样式类名称 */ onTableRowClassName({ tableConfig, record }) { if (this.props.SetRowClass && typeof this.props.SetRowClass === 'function') { return this.props.SetRowClass(record); - } - else if (tableConfig && tableConfig.classField) { + } else if (tableConfig && tableConfig.classField) { let className = null; let classAry = tableConfig.classField.split(','); classAry.forEach((n, i) => { @@ -1207,7 +1256,8 @@ class TableBaseComponent extends ComponentBase { let index = 0; let isGet = false; for (index = 0; index < values.length; index = index + 2) { - if (values[index].toString() == r.toString()) { //如果数组中某个元素和你想要测试的元素对象element相等,则证明数组中包含这个元素,返回true + if (values[index].toString() == r.toString()) { + //如果数组中某个元素和你想要测试的元素对象element相等,则证明数组中包含这个元素,返回true isGet = true; break; @@ -1228,30 +1278,26 @@ class TableBaseComponent extends ComponentBase { /* 渲染表行项子表 */ - onRenderTableSubRow({ tableCode, tableConfig, record }) { - - } + onRenderTableSubRow({ tableCode, tableConfig, record }) {} /* 展开表行项时 */ - onTableExpandRow({ tableCode, tableConfig, record, expanded }) { - - } + onTableExpandRow({ tableCode, tableConfig, record, expanded }) {} /* 渲染表页脚 */ onRenderTableFooter({ tableCode, tableConfig, data, columns, selectedRowKeys }) { - return + return ( + + ); } /* 点击表行项 */ - onTableClickRow({ tableCode, tableConfig, record }) { - - } + onTableClickRow({ tableCode, tableConfig, record }) {} /** * 按钮点击日志埋点 @@ -1259,7 +1305,7 @@ class TableBaseComponent extends ComponentBase { * @param {*} BtnName */ btnOperateLog = (btnConfig) => { - const { btnType: BtnCode, label: BtnName } = btnConfig || {} + const { btnType: BtnCode, label: BtnName } = btnConfig || {}; if (BtnCode !== undefined && BtnName !== undefined) { this.props.dispatch({ type: 'app/operateLog', @@ -1269,11 +1315,11 @@ class TableBaseComponent extends ComponentBase { FormCode: this.state.formData.CODE, FormName: this.state.formData.NAME, UserId: this.props.login.userId, - OrgId: this.props.login.OrgId - } - }) + OrgId: this.props.login.OrgId, + }, + }); } - } + }; /* btn={ @@ -1296,22 +1342,22 @@ class TableBaseComponent extends ComponentBase { const { formData } = this.state || {}; const isRow = record; const isSelected = this.state[tableCode + '_isSelected']; - const loadKey = tableCode + '_' + (record ? (record.ID + btnConfig.id) : btnConfig.id); + const loadKey = tableCode + '_' + (record ? record.ID + btnConfig.id : btnConfig.id); const btnIsLoading = this.state[loadKey]; const btnLoading = (loading) => { this.setState({ [loadKey]: loading, - }) - } + }); + }; const setformLoading = (loading) => { this.setState({ formLoading: loading, - }) - } + }); + }; const close = (type) => { if (type === undefined || type === 0) { - const tmpFunc = this.state['closeModelFunc' + (record ? (record.ID + btnConfig.id) : btnConfig.id)]; + const tmpFunc = this.state['closeModelFunc' + (record ? record.ID + btnConfig.id : btnConfig.id)]; if (tmpFunc) { tmpFunc(); } @@ -1327,22 +1373,23 @@ class TableBaseComponent extends ComponentBase { let { disabled, onBtnDisabled, content, click, json, onClick } = btnParam ? btnParam : {}; - let disabledClick = disabled ? e => e.stopPropagation() : null; - let disabledStyle = disabled ? { color: "#c5c3c3", cursor: "not-allowed" } : { cursor: "pointer" }; + let disabledClick = disabled ? (e) => e.stopPropagation() : null; + let disabledStyle = disabled ? { color: '#c5c3c3', cursor: 'not-allowed' } : { cursor: 'pointer' }; - if (btnConfig.btnType === 0) { //自定义弹窗 + if (btnConfig.btnType === 0) { + //自定义弹窗 const closeFunc = (fun) => { const data = {}; - data['closeModelFunc' + (record ? (record.ID + btnConfig.id) : btnConfig.id)] = fun; + data['closeModelFunc' + (record ? record.ID + btnConfig.id : btnConfig.id)] = fun; this.setState(data); }; const showData = { regClose: closeFunc, }; - const getIds = () => { - if (btnConfig.btn.BTN_FUN_TYPE == 1) {//行按鈕 + if (btnConfig.btn.BTN_FUN_TYPE == 1) { + //行按鈕 if (record) { let d = false; if (typeof onBtnDisabled === 'function') { @@ -1351,11 +1398,10 @@ class TableBaseComponent extends ComponentBase { if (d) return; return record.ID; } - } - else { + } else { const selectRecords = this.getTableSelectedRecord({ tableCode }); const tempSelectRecordIds = []; - selectRecords.forEach(t => { + selectRecords.forEach((t) => { let d = false; if (typeof onBtnDisabled === 'function') { d = onBtnDisabled(t); @@ -1369,14 +1415,13 @@ class TableBaseComponent extends ComponentBase { } }; - if (!content && btnParam) { const that = this; const clickKey = btnConfig.code ? btnConfig.code : btnConfig.id; // let tempData = { - id: (record ? record.ID : ''), - ORG_ID_HV: (record ? record.ORG_ID : ''),//wyw 集团查看 明细 + id: record ? record.ID : '', + ORG_ID_HV: record ? record.ORG_ID : '', //wyw 集团查看 明细 parentRecord: record, clickKey, close, @@ -1396,15 +1441,14 @@ class TableBaseComponent extends ComponentBase { this.regDestroyCacheDataFunc = {}; } this.regDestroyCacheDataFunc[clickKey + (record ? record.ID : '')] = ret; - } + }, }; - - const regClick = async function () { - let ids = ""; + let ids = ''; let isError = false; - if (btnConfig.btn.BTN_FUN_TYPE == 0) {//按鈕 非行按鈕 + if (btnConfig.btn.BTN_FUN_TYPE == 0) { + //按鈕 非行按鈕 ids = that.getTableSelectedRowKeys({ tableCode }); if (btnConfig.checkSelected && !ids) { message.error('请选择记录'); @@ -1415,58 +1459,91 @@ class TableBaseComponent extends ComponentBase { await that.props.dispatch({ type: 'custom/save', payload: { - [clickKey + (record ? record.ID : '')]: true + [clickKey + (record ? record.ID : '')]: true, }, }); } - that.btnOperateLog(btnConfig) + that.btnOperateLog(btnConfig); return { - isReturn: isError - } + isReturn: isError, + }; }; if (btnParam.data) { tempData = { ...tempData, ...btnParam.data, - } + }; } btnParam.content = ; - btnParam.click = () => { return regClick() }; + btnParam.click = () => { + return regClick(); + }; showData.close = () => { if (this.regDestroyCacheDataFunc && this.regDestroyCacheDataFunc[clickKey + (record ? record.ID : '')]) { this.regDestroyCacheDataFunc[clickKey + (record ? record.ID : '')](); } - } + }; } if (btnParam) { extend(showData, btnParam); } - let disabledClick = (disabled || !getIds()) ? e => e.stopPropagation() : null; - let disabledStyle = (disabled || !getIds()) ? { color: "c5c3c3", cursor: "not-allowed" } : { cursor: "pointer" }; + let disabledClick = disabled || !getIds() ? (e) => e.stopPropagation() : null; + let disabledStyle = disabled || !getIds() ? { color: 'c5c3c3', cursor: 'not-allowed' } : { cursor: 'pointer' }; - return - {isRow - ?
- : } -
; - } - else if (btnConfig.btnType === 2) { // 刷新 + return ( + + {isRow ? ( +
+ +
+ ) : ( + + )} +
+ ); + } else if (btnConfig.btnType === 2) { + // 刷新 if (!isRow) { return ( + key={btnConfig.id} + > + 刷新 + ); } - } - else if (btnConfig.btnType === 5 || btnConfig.btnType === 3 || btnConfig.btnType === 8 || btnConfig.btnType === 10) { //编辑 新增 查看 复制新增 + } else if ( + btnConfig.btnType === 5 || + btnConfig.btnType === 3 || + btnConfig.btnType === 8 || + btnConfig.btnType === 10 + ) { + //编辑 新增 查看 复制新增 const isShow = btnConfig.btnType === 8; const getIds = () => { if (record) { @@ -1479,7 +1556,7 @@ class TableBaseComponent extends ComponentBase { } const selectRecords = this.getTableSelectedRecord({ tableCode }); const tempSelectRecordIds = []; - selectRecords.forEach(t => { + selectRecords.forEach((t) => { let d = false; if (typeof onBtnDisabled === 'function') { d = onBtnDisabled(t); @@ -1493,8 +1570,8 @@ class TableBaseComponent extends ComponentBase { }; const isBatchEdit = btnConfig.btnType === 5 && !isRow; const isEdit = !isBatchEdit; - const extKey = record ? (record.ID + btnConfig.id) : btnConfig.id; - const reloadKey = (isEdit ? '' : 'batchEdit_') + (btnConfig.formCode + '_' + extKey + '_reload') + const extKey = record ? record.ID + btnConfig.id : btnConfig.id; + const reloadKey = (isEdit ? '' : 'batchEdit_') + (btnConfig.formCode + '_' + extKey + '_reload'); const data = { isShow: isShow, record, @@ -1512,38 +1589,49 @@ class TableBaseComponent extends ComponentBase { if (record && !disabled) { disabled = !getIds(); } - disabledClick = disabled ? e => e.stopPropagation() : null; - disabledStyle = disabled ? { color: "#c5c3c3", cursor: "not-allowed" } : { cursor: "pointer" }; + disabledClick = disabled ? (e) => e.stopPropagation() : null; + disabledStyle = disabled ? { color: '#c5c3c3', cursor: 'not-allowed' } : { cursor: 'pointer' }; const id = btnConfig.btnType !== 10 && record ? record.ID : ''; const copySrcId = btnConfig.btnType === 10 && record ? record.ID : ''; return ( { - this.loadTableData({ tableCode }) + this.loadTableData({ tableCode }); }} formCode={btnConfig.formCode} - click={visible => { - visible && this.btnOperateLog(btnConfig) + click={(visible) => { + visible && this.btnOperateLog(btnConfig); if (typeof click === 'function') { - click(visible) + click(visible); } }} > - { - isRow - ?
- : - } + {isRow ? ( +
+ +
+ ) : ( + + )}
- ) - } - else if (btnConfig.btnType === 4) { //删除 + ); + } else if (btnConfig.btnType === 4) { + //删除 const getIds = () => { if (record) { let d = false; @@ -1555,7 +1643,7 @@ class TableBaseComponent extends ComponentBase { } const selectRecords = this.getTableSelectedRecord({ tableCode }); const tempSelectRecordIds = []; - selectRecords.forEach(t => { + selectRecords.forEach((t) => { let d = false; if (typeof onBtnDisabled === 'function') { d = onBtnDisabled(t); @@ -1570,11 +1658,11 @@ class TableBaseComponent extends ComponentBase { if (isRow) { return ( { - this.btnOperateLog(btnConfig) - this.onTableBtnDelete({ ...params, btnConfig, id: getIds(), btnLoading }) + this.btnOperateLog(btnConfig); + this.onTableBtnDelete({ ...params, btnConfig, id: getIds(), btnLoading }); }} type={btnConfig.css ? btnConfig.css : 'danger'} icon={btnConfig.icon ? btnConfig.icon : 'delete'} @@ -1584,16 +1672,15 @@ class TableBaseComponent extends ComponentBase { disabled={disabled || !getIds()} loading={btnIsLoading} /> - ) - } - else { + ); + } else { return ( { - this.btnOperateLog(btnConfig) - this.onTableBtnBatchDelete({ ...params, btnConfig, ids: getIds(), btnLoading }) + this.btnOperateLog(btnConfig); + this.onTableBtnBatchDelete({ ...params, btnConfig, ids: getIds(), btnLoading }); }} type={btnConfig.css ? btnConfig.css : 'danger'} icon={btnConfig.icon ? btnConfig.icon : 'delete'} @@ -1602,10 +1689,10 @@ class TableBaseComponent extends ComponentBase { disabled={disabled || !isSelected} loading={btnIsLoading} /> - ) + ); } - } - else if (btnConfig.btnType === 6) { //自定义按钮事件 + } else if (btnConfig.btnType === 6) { + //自定义按钮事件 const regClick = () => { let tempBtnParam = null; if (typeof click === 'function') { @@ -1623,7 +1710,7 @@ class TableBaseComponent extends ComponentBase { } const selectRecords = this.getTableSelectedRecord({ tableCode }); const tempSelectRecordIds = []; - selectRecords.forEach(t => { + selectRecords.forEach((t) => { let d = false; if (typeof onBtnDisabled === 'function') { d = onBtnDisabled(t); @@ -1636,7 +1723,7 @@ class TableBaseComponent extends ComponentBase { } }; const ids = getIds(); - if (!ids && (isRow || !isRow && btnConfig.checkSelected)) { + if (!ids && (isRow || (!isRow && btnConfig.checkSelected))) { message.error('请选择记录或者记录无效'); return; } @@ -1660,23 +1747,35 @@ class TableBaseComponent extends ComponentBase { message.success('执行成功'); //添加日志 if (btnConfig.isAddLog) { - const formId = (tableConfig.formId ? tableConfig.formId : (tableConfig.formData ? tableConfig.formData.ID : this.props.formId)); - const formCode = tableConfig.formCode ? tableConfig.formCode : (tableConfig.formData ? tableConfig.formData.CODE : this.props.formCode); + const formId = tableConfig.formId + ? tableConfig.formId + : tableConfig.formData + ? tableConfig.formData.ID + : this.props.formId; + const formCode = tableConfig.formCode + ? tableConfig.formCode + : tableConfig.formData + ? tableConfig.formData.CODE + : this.props.formCode; const title = '用户【' + this.props.login.user.NAME + '】:执行按钮' + btnConfig.title; const data = 'ID:' + ids; - const extData = "Json:" + JSON.stringify(temJson); + const extData = 'Json:' + JSON.stringify(temJson); this.addOtherLog({ formCode, formId, title, data, extData }); } } - } - }) + }, + }); } - this.btnOperateLog(btnConfig) + this.btnOperateLog(btnConfig); }; - disabled = disabled ? disabled : (((isRow && false || !isRow && !isSelected && btnConfig.checkSelected)) ? true : false); + disabled = disabled + ? disabled + : (isRow && false) || (!isRow && !isSelected && btnConfig.checkSelected) + ? true + : false; return ( - ) - } - else if (btnConfig.btnType === 7) { //自定义 + ); + } else if (btnConfig.btnType === 7) { + //自定义 const getIds = () => { if (record) { let d = false; @@ -1701,7 +1800,7 @@ class TableBaseComponent extends ComponentBase { } const selectRecords = this.getTableSelectedRecord({ tableCode }); const tempSelectRecordIds = []; - selectRecords.forEach(t => { + selectRecords.forEach((t) => { let d = false; if (typeof onBtnDisabled === 'function') { d = onBtnDisabled(t); @@ -1732,7 +1831,7 @@ class TableBaseComponent extends ComponentBase { } } btnLoading(true); - this.btnOperateLog(btnConfig) + this.btnOperateLog(btnConfig); this.props.dispatch({ type: 'app/getDataByPost', payload: temJson, @@ -1744,21 +1843,33 @@ class TableBaseComponent extends ComponentBase { message.success('执行成功'); //添加日志 if (btnConfig.isAddLog) { - const formId = (tableConfig.formId ? tableConfig.formId : (tableConfig.formData ? tableConfig.formData.ID : this.props.formId)); - const formCode = tableConfig.formCode ? tableConfig.formCode : (tableConfig.formData ? tableConfig.formData.CODE : this.props.formCode); + const formId = tableConfig.formId + ? tableConfig.formId + : tableConfig.formData + ? tableConfig.formData.ID + : this.props.formId; + const formCode = tableConfig.formCode + ? tableConfig.formCode + : tableConfig.formData + ? tableConfig.formData.CODE + : this.props.formCode; const title = '用户【' + this.props.login.user.NAME + '】:执行按钮' + btnConfig.title; const data = 'ID:' + ids; - const extData = "Json:" + JSON.stringify(temJson); + const extData = 'Json:' + JSON.stringify(temJson); this.addOtherLog({ formCode, formId, title, data, extData }); } } - } - }) + }, + }); }; - disabled = disabled ? disabled : (((isRow && !getIds() || !isRow && !isSelected && btnConfig.checkSelected)) ? true : false); + disabled = disabled + ? disabled + : (isRow && !getIds()) || (!isRow && !isSelected && btnConfig.checkSelected) + ? true + : false; return ( - ) + ); } - const customParams = getCustomParams(btnConfig.customParams) + const customParams = getCustomParams(btnConfig.customParams); if (customParams && customParams.print === 'true') { return ( this.btnOperateLog(btnConfig)}> - + - ) + ); } - } - else if (btnConfig.btnType === 9) { // 导出 + } else if (btnConfig.btnType === 9) { + // 导出 let { tableCode = this.defaultTableCode, tableConfig } = params ? params : {}; tableConfig === undefined && (tableConfig = this.getTableConfig({ tableCode })); - const tableColumns = this.getColumnByColumnConfig(tableCode) - const tableDataSource = this.getTableData({ tableCode }) - const tableSelectedKeys = this.getTableSelectedRowKeys({ tableCode }) - const loadParamJson = this.getLoadTableDataParams(cloneDeep(this.initLoadParam({ tableCode })), tableCode) + const tableColumns = this.getColumnByColumnConfig(tableCode); + const tableDataSource = this.getTableData({ tableCode }); + const tableSelectedKeys = this.getTableSelectedRowKeys({ tableCode }); + const loadParamJson = this.getLoadTableDataParams(cloneDeep(this.initLoadParam({ tableCode })), tableCode); // 计算导出的 excel 需要在第一行插入的标题 - const formCode = tableConfig.formCode ? tableConfig.formCode : (tableConfig.formData ? tableConfig.formData.CODE : this.props.formCode) + const formCode = tableConfig.formCode + ? tableConfig.formCode + : tableConfig.formData + ? tableConfig.formData.CODE + : this.props.formCode; const searchModel = this.props.search || { fieldConfigs: {}, - relatedFieldConfigs: {} - } - const relatedFieldConfigs = searchModel.relatedFieldConfigs[formCode] || {} - const relatedFormCode = relatedFieldConfigs.relatedTo - const relatedExtraRows = relatedFieldConfigs.extraRows - const fieldConfigs = searchModel.fieldConfigs[relatedFormCode || formCode] || [] - const exportInserTitle = [tableConfig.exportTitle || formData.NAME] + relatedFieldConfigs: {}, + }; + const relatedFieldConfigs = searchModel.relatedFieldConfigs[formCode] || {}; + const relatedFormCode = relatedFieldConfigs.relatedTo; + const relatedExtraRows = relatedFieldConfigs.extraRows; + const fieldConfigs = searchModel.fieldConfigs[relatedFormCode || formCode] || []; + const exportInserTitle = [tableConfig.exportTitle || formData.NAME]; if (relatedFormCode && Array.isArray(relatedExtraRows)) { - exportInserTitle.push(...relatedExtraRows) + exportInserTitle.push(...relatedExtraRows); } - fieldConfigs.forEach(fc => { - const { isExportTitle, label, value, dataSource } = fc - const cellText = renderExportCell(value, dataSource, fc, this.props.app.enums || {}) + fieldConfigs.forEach((fc) => { + const { isExportTitle, label, value, dataSource } = fc; + const cellText = renderExportCell(value, dataSource, fc, this.props.app.enums || {}); if (isExportTitle && cellText) { - exportInserTitle.push(`${label}:${cellText}`) + exportInserTitle.push(`${label}:${cellText}`); } - }) + }); if (!isRow) { return ( @@ -1823,68 +1940,72 @@ class TableBaseComponent extends ComponentBase { type: 'listPage/getTableData', payload: loadParamJson || {}, url: tableConfig.api, - customParams:btnConfig.customParams//wyw 添加 参数到导出功能 url + customParams: btnConfig.customParams, //wyw 添加 参数到导出功能 url }} /> - ) + ); } return null; - } - else if (btnConfig.btnType === 11) { // 导入 + } else if (btnConfig.btnType === 11) { + // 导入 if (!isRow) { return ( { this.btnOperateLog(btnConfig) }} + click={() => { + this.btnOperateLog(btnConfig); + }} > - + - ) + ); } return null; - } - else if (btnConfig.btnType === 12) { // 列表弹窗 + } else if (btnConfig.btnType === 12) { + // 列表弹窗 return ( { - visible && this.btnOperateLog(btnConfig) + click={(visible) => { + visible && this.btnOperateLog(btnConfig); if (typeof this.click === 'function') { - this.click(visible) + this.click(visible); } - }}> + }} + > - ) - } - else if (btnConfig.btnType === 14) { // 组合表单 + ); + } else if (btnConfig.btnType === 14) { + // 组合表单 return ( { - visible && this.btnOperateLog(btnConfig) + click={(visible) => { + visible && this.btnOperateLog(btnConfig); if (typeof this.click === 'function') { - this.click(visible) + this.click(visible); } - }}> + }} + > - ) - } - else if (btnConfig.btnType === 15) { // 自定义导入 + ); + } else if (btnConfig.btnType === 15) { + // 自定义导入 const uploadProps = { name: 'file', showUploadList: false, @@ -1892,109 +2013,124 @@ class TableBaseComponent extends ComponentBase { data: { OrgId: this.props.login.OrgId }, headers: this.getRequestHeaders(), onChange: (info) => { - const { name, status, response = {} } = info.file - const { IsSuccessful, ErrorMessage } = response + const { name, status, response = {} } = info.file; + const { IsSuccessful, ErrorMessage } = response; if (status === 'done') { if (IsSuccessful) { - message.success(`${name} 导入并保存成功`) - this.forceUpdate() + message.success(`${name} 导入并保存成功`); + this.forceUpdate(); } else { - message.error(`${name} 导入失败,${ErrorMessage}`) + message.error(`${name} 导入失败,${ErrorMessage}`); } } else if (status === 'error') { if (response.ErrorMessage) { - message.error(`${name} 导入错误,${ErrorMessage}`) + message.error(`${name} 导入错误,${ErrorMessage}`); } else { - message.error(`${name} 导入错误`) + message.error(`${name} 导入错误`); } } - } - } + }, + }; return ( - + - ) - } - else if (btnConfig.btnType === 16) { // 带参数的自定义弹窗 + ); + } else if (btnConfig.btnType === 16) { + // 带参数的自定义弹窗 return ( { - visible && this.btnOperateLog(btnConfig) + click={(visible) => { + visible && this.btnOperateLog(btnConfig); if (typeof this.click === 'function') { - return this.click(visible) + return this.click(visible); } - }}> + }} + > - ) - } - else if (btnConfig.btnType === 17) { // 树弹窗 + ); + } else if (btnConfig.btnType === 17) { + // 树弹窗 return ( { - visible && this.btnOperateLog(btnConfig) + click={(visible) => { + visible && this.btnOperateLog(btnConfig); if (typeof this.click === 'function') { - return this.click(visible) + return this.click(visible); } - }}> + }} + > - ) - } - else if (btnConfig.btnType === 18) { // word打印模板 + ); + } else if (btnConfig.btnType === 18) { + // word打印模板 return ( + content: , }} > - ) - } - else if (btnConfig.btnType === 20) { // 复选框 + ); + } else if (btnConfig.btnType === 20) { + // 复选框 return ( { - tableConfig.dragable = evt.target.checked - this.forceUpdate() + onChange={(evt) => { + tableConfig.dragable = evt.target.checked; + this.forceUpdate(); }} > {btnConfig.label} - ) + ); } - return isRow ? -
: - ; + return isRow ? ( +
+ +
+ ) : ( + + ); } - /* 参数:{ tableCode,tableConfig,record,btnConfig, @@ -2057,29 +2193,37 @@ class TableBaseComponent extends ComponentBase { const deleteData = []; if (btnConfig.isAddLog) { const tableData = this.getTableData({ tableCode }); - const selectKeys = id.split(',');// this.getTableSelectedRowKeys({ tableCode }); + const selectKeys = id.split(','); // this.getTableSelectedRowKeys({ tableCode }); if (selectKeys && tableData && tableData.Data) { - selectKeys.forEach(item => { - tableData.Data.forEach(t => { + selectKeys.forEach((item) => { + tableData.Data.forEach((t) => { if (item.toString().toUpperCase() === t.ID.toString().toUpperCase()) { deleteData.push(t); } - }) + }); }); } } message.success('删除成功'); this.loadTableData({ tableCode }); if (btnConfig.isAddLog) { - const formId = (tableConfig.formId ? tableConfig.formId : (tableConfig.formData ? tableConfig.formData.ID : this.props.formId)); - const formCode = tableConfig.formCode ? tableConfig.formCode : (tableConfig.formData ? tableConfig.formData.CODE : this.props.formCode); + const formId = tableConfig.formId + ? tableConfig.formId + : tableConfig.formData + ? tableConfig.formData.ID + : this.props.formId; + const formCode = tableConfig.formCode + ? tableConfig.formCode + : tableConfig.formData + ? tableConfig.formData.CODE + : this.props.formCode; const extData = deleteData ? ('删除数据,详情:', JSON.stringify(deleteData)) : null; this.addDeleteLog({ formCode, ids: id, formId, extData }); } } - } - }) + }, + }); } /* @@ -2102,7 +2246,7 @@ class TableBaseComponent extends ComponentBase { this.props.dispatch({ type: 'app/deleteItemBatch', payload: { - ids: ids + ids: ids, }, url: delApiUrl, onComplete: (ret) => { @@ -2113,15 +2257,15 @@ class TableBaseComponent extends ComponentBase { const deleteData = []; if (btnConfig.isAddLog) { const tableData = this.getTableData({ tableCode }); - const selectKeys = ids.split(',');// this.getTableSelectedRowKeys({ tableCode }); + const selectKeys = ids.split(','); // this.getTableSelectedRowKeys({ tableCode }); if (selectKeys && tableData && tableData.Data) { - selectKeys.forEach(item => { - tableData.Data.forEach(t => { + selectKeys.forEach((item) => { + tableData.Data.forEach((t) => { if (item.toString().toUpperCase() === t.ID.toString().toUpperCase()) { deleteData.push(t); } - }) + }); }); } } @@ -2129,29 +2273,45 @@ class TableBaseComponent extends ComponentBase { message.success('删除成功'); this.setTableSelectedRowKeys({ tableCode, selectedKeys: [] }); if (btnConfig.isAddLog) { - const formId = (tableConfig.formId ? tableConfig.formId : (tableConfig.formData ? tableConfig.formData.ID : this.props.formId)); - const formCode = tableConfig.formCode ? tableConfig.formCode : (tableConfig.formData ? tableConfig.formData.CODE : this.props.formCode); + const formId = tableConfig.formId + ? tableConfig.formId + : tableConfig.formData + ? tableConfig.formData.ID + : this.props.formId; + const formCode = tableConfig.formCode + ? tableConfig.formCode + : tableConfig.formData + ? tableConfig.formData.CODE + : this.props.formCode; const extData = deleteData ? ('删除数据,详情:', JSON.stringify(deleteData)) : null; this.addDeleteLog({ formCode, ids, formId: formId, extData }); } } - } - }) + }, + }); } - genDataSource(tableCode, tableData) { // 生产表格的dataSource + genDataSource(tableCode, tableData) { + // 生产表格的dataSource const { localSearch = {} } = this.state; if (tableData.Data) { if (Object.keys(localSearch).length) { const tableConfig = this.getTableConfig({ tableCode }); - return tableData.Data.filter(record => { - const col = tableConfig.columns.filter(t => t.field === localSearch.fields)[0];// '';//localSearch.fields + return tableData.Data.filter((record) => { + const col = tableConfig.columns.filter((t) => t.field === localSearch.fields)[0]; // '';//localSearch.fields let val = getDataFieldValue(record, col.field); - const isShowCol = col.controlType === null || col.controlType === undefined || col.controlType === 0 || col.controlType > 100; + const isShowCol = + col.controlType === null || col.controlType === undefined || col.controlType === 0 || col.controlType > 100; if (isShowCol) { if (col.formatFuncName) { col.format = (params) => { - const formatValue = this.onTableRowFormatColumn({ record, text: val, tableCode, tableConfig, colConfig: params.col }); + const formatValue = this.onTableRowFormatColumn({ + record, + text: val, + tableCode, + tableConfig, + colConfig: params.col, + }); setDataFieldValue(record, (col.field ? col.field : col.formatFuncName) + '_formatValue', formatValue); val = formatValue; }; @@ -2162,28 +2322,30 @@ class TableBaseComponent extends ComponentBase { //val = getDataFieldValue(record, col.field); if (col.field && col.field.indexOf('Nav_SysParams') > -1) { val = this.getControlValue({ - controlType: col.controlType, value: col.value, - data: col.data + controlType: col.controlType, + value: col.value, + data: col.data, }); } - if (val) { // 值 - if (typeof val === "number") { - val = val.toString() + if (val) { + // 值 + if (typeof val === 'number') { + val = val.toString(); } - if (String(val) === "null") { - return false + if (String(val) === 'null') { + return false; } return val.indexOf(localSearch.value) >= 0; } return false; - }) + }); } else { - return tableData.Data + return tableData.Data; } } else { - return [] + return []; } } @@ -2202,8 +2364,8 @@ class TableBaseComponent extends ComponentBase { clearCustomConfig={() => this.clearCustomConfig(tableConfig)} saveCustomConfig={() => this.saveCustomConfig(tableConfig)} /> - ) - } + ); + }; if (rowBtns && rowBtns.length) { let currRecord = {}; @@ -2223,7 +2385,7 @@ class TableBaseComponent extends ComponentBase { } render={(text, record, index) => { // 此项宽度设置为 单个样式宽 * 按钮个数 - 左右边距 - return
- { - this.getRenderBtns(tableCode, tableConfig, record, rowBtns, 0) - } -
+ return ( +
+ {this.getRenderBtns(tableCode, tableConfig, record, rowBtns, 0)} +
+ ); }} /> - ) + ); } else { return ( } filterDropdown={} width={35} render={() =>
} /> - ) + ); } } // 伸缩表格列操作 - handleResize = (tableCode, colu) => (e, { size }) => { - if (this.state.tableConfig === undefined || !this.state.tableConfig[tableCode]) { - message.error("表单配置错误!"); - return - } - - let thisColumns = { ...this.state.tableConfig[tableCode] } - if (this.state.tableConfig === undefined) { - this.state.tableConfig = {}; - } - thisColumns.columns.forEach(item => { - if (item.field === colu.dataIndex) { - item.width = size.width + handleResize = + (tableCode, colu) => + (e, { size }) => { + if (this.state.tableConfig === undefined || !this.state.tableConfig[tableCode]) { + message.error('表单配置错误!'); + return; } - }) - this.setState({ - tableConfig: { - ...this.state.tableConfig, - [this.state.tableConfig[tableCode]]: thisColumns + let thisColumns = { ...this.state.tableConfig[tableCode] }; + if (this.state.tableConfig === undefined) { + this.state.tableConfig = {}; } - }) - } + thisColumns.columns.forEach((item) => { + if (item.field === colu.dataIndex) { + item.width = size.width; + } + }); + + this.setState({ + tableConfig: { + ...this.state.tableConfig, + [this.state.tableConfig[tableCode]]: thisColumns, + }, + }); + }; /** * 批量新增保存 */ handleBatchAddSave = (tableCode) => { - const { selectedRowsAll = [] } = this.state - const { close } = this.props.data - close instanceof Function && close(undefined, cloneDeep(selectedRowsAll)) - this.state.selectedRowsAll = undefined - this.onSelectTableChange(tableCode, [], []) - } + const { selectedRowsAll = [] } = this.state; + const { close } = this.props.data; + close instanceof Function && close(undefined, cloneDeep(selectedRowsAll)); + this.state.selectedRowsAll = undefined; + this.onSelectTableChange(tableCode, [], []); + }; moveRow = (dragIndex, hoverIndex, tableCode, tableConfig) => { - const tableData = this.state.data[tableCode].Data - const dragRow = tableData[dragIndex] - const hoverRow = tableData[hoverIndex] - const pageTable = tableConfig.pageTable || {} + const tableData = this.state.data[tableCode].Data; + const dragRow = tableData[dragIndex]; + const hoverRow = tableData[hoverIndex]; + const pageTable = tableConfig.pageTable || {}; if (!pageTable.SORT) { - message.error('未配置排序字段,操作取消') - return + message.error('未配置排序字段,操作取消'); + return; } // 调用接口 this.props.dispatch({ @@ -2307,20 +2471,23 @@ class TableBaseComponent extends ComponentBase { Parameter1: dragRow.ID, Parameter2: hoverRow.ID, Parameter3: pageTable.SORT, - OrgId: this.props.login.OrgId + OrgId: this.props.login.OrgId, }, onComplete: (res) => { if (res) { // 更新数据 const updateData = update(tableData, { - $splice: [[dragIndex, 1], [hoverIndex, 0, dragRow]] - }) - this.state.data[tableCode].Data = updateData - this.setState({ data: this.state.data }) + $splice: [ + [dragIndex, 1], + [hoverIndex, 0, dragRow], + ], + }); + this.state.data[tableCode].Data = updateData; + this.setState({ data: this.state.data }); } - } - }) - } + }, + }); + }; /* 渲染表 @@ -2342,50 +2509,57 @@ class TableBaseComponent extends ComponentBase { const selectKeys = this.getTableSelectedRowKeys({ tableCode }); loadParam = loadParam || {}; tableData = tableData || {}; - const tableDataSource = this.genDataSource(tableCode, tableData) - tableDataSource.forEach(tds => { - !tds.hasOwnProperty('key') && (tds.key = tds.ID) - }) - const defaultExpandedRowKeys = tableDataSource && tableDataSource.length ? [tableDataSource[0].key] : [] + const tableDataSource = this.genDataSource(tableCode, tableData); + tableDataSource.forEach((tds) => { + !tds.hasOwnProperty('key') && (tds.key = tds.ID); + }); + const defaultExpandedRowKeys = tableDataSource && tableDataSource.length ? [tableDataSource[0].key] : []; - const paginationConfig = loadParam?.IsAllLoad ? false : { - pageSizeOptions: ['5', '10', '20','100','1000'], - current: loadParam ? loadParam.PageIndex : 1, - pageSize: loadParam ? loadParam.Limit : 10, - total: tableData ? tableData.TotalCount : 0, - showSizeChanger: true, - showQuickJumper: true, - size: 'small', - position: (tableConfig.position ? tableConfig.position : 'bottom'), - showTotal: () => `共 ${tableData ? tableData.TotalCount : 0} 条` - }; + const paginationConfig = loadParam?.IsAllLoad + ? false + : { + pageSizeOptions: ['5', '10', '20', '100', '1000'], + current: loadParam ? loadParam.PageIndex : 1, + pageSize: loadParam ? loadParam.Limit : 10, + total: tableData ? tableData.TotalCount : 0, + showSizeChanger: true, + showQuickJumper: true, + size: 'small', + position: tableConfig.position ? tableConfig.position : 'bottom', + showTotal: () => `共 ${tableData ? tableData.TotalCount : 0} 条`, + }; // 配置最多可选个数 - const customRowSelection = tableConfig.maxCheckCount ? { - hideDefaultSelections: true, - columnTitle: ' ', - getCheckboxProps: (record) => { - return { - disabled: selectKeys.length >= tableConfig.maxCheckCount && selectKeys.indexOf(record.ID) === -1 + const customRowSelection = tableConfig.maxCheckCount + ? { + hideDefaultSelections: true, + columnTitle: ' ', + getCheckboxProps: (record) => { + return { + disabled: selectKeys.length >= tableConfig.maxCheckCount && selectKeys.indexOf(record.ID) === -1, + }; + }, } - } - } : {} + : {}; const rowSelection = { // 如果需要支持拖曳排序,则不允许fixed,否则会报错 fixed: !tableConfig.hasChildren && !tableConfig.dragable, selectedRowKeys: selectKeys, columnWidth: 32, - onChange: (selectedRowKeys, selectedRows) => { this.onSelectTableChange(tableCode, selectedRowKeys, selectedRows); }, - type: tableConfig && tableConfig.checkType == 1 ? "radio" : "checkbox", + onChange: (selectedRowKeys, selectedRows) => { + this.onSelectTableChange(tableCode, selectedRowKeys, selectedRows); + }, + type: tableConfig && tableConfig.checkType == 1 ? 'radio' : 'checkbox', hideDefaultSelections: false, - ...customRowSelection + ...customRowSelection, }; - let hasFooter = () => { // 是否显示底部 + let hasFooter = () => { + // 是否显示底部 let footerSumType = tableConfig.footerSumType; if (footerSumType === 1) { - return true + return true; } else if (footerSumType === 2) { return selectKeys && selectKeys.length > 0; } else { @@ -2402,15 +2576,15 @@ class TableBaseComponent extends ComponentBase { if (isFixed) { const totalWidth = newColumns.reduce((a, b) => { if (b.width) { - return a + b.width + return a + b.width; } else { - return a + 0 + return a + 0; } }, 0); - const scrollX = tableWidth > (totalWidth + 200) ? tableWidth : (totalWidth + 200); - return { scroll: { x: scrollX, y: tableHeight } } + const scrollX = tableWidth > totalWidth + 200 ? tableWidth : totalWidth + 200; + return { scroll: { x: scrollX, y: tableHeight } }; } else { - return { scroll: { y: tableHeight } } + return { scroll: { y: tableHeight } }; } }; @@ -2419,166 +2593,171 @@ class TableBaseComponent extends ComponentBase { notification.open({ message: h.title, key: h.key, - placement: "bottomRight", - }) + placement: 'bottomRight', + }); }; - let isLoading = this.props.loading ? this.props.loading.effects["listPage/getTableData"] : false; + let isLoading = this.props.loading ? this.props.loading.effects['listPage/getTableData'] : false; if (!isLoading) { - isLoading = this.state.formLoading + isLoading = this.state.formLoading; } - const isBatchAddList = this.props.data && this.props.data.btnTypeBatchAdd - const contentWidth = tableConfig.pageTable && tableConfig.pageTable.WIDTH ? tableConfig.pageTable.WIDTH : "auto" + const isBatchAddList = this.props.data && this.props.data.btnTypeBatchAdd; + const contentWidth = tableConfig.pageTable && tableConfig.pageTable.WIDTH ? tableConfig.pageTable.WIDTH : 'auto'; const TableHeadBtns = this.getRenderBtns(tableCode, tableConfig, null, tableConfig.btns, 1); - const { components } = getDragableProps() - const dragableProps = tableConfig.dragable ? { - components: { - ...components, - ...TableResizableCell - }, - onRow: (rowRecord, index) => ({ - index, - moveRow: (dragIndex, hoverIndex) => this.moveRow(dragIndex, hoverIndex, tableCode, tableConfig), - onClick: () => { - this.onTableClickRow({ tableCode, tableConfig, rowRecord }); + const { components } = getDragableProps(); + const dragableProps = tableConfig.dragable + ? { + components: { + ...components, + ...TableResizableCell, + }, + onRow: (rowRecord, index) => ({ + index, + moveRow: (dragIndex, hoverIndex) => this.moveRow(dragIndex, hoverIndex, tableCode, tableConfig), + onClick: () => { + this.onTableClickRow({ tableCode, tableConfig, rowRecord }); + }, + }), } - }) - } : { - components: TableResizableCell, - onRow: (rowRecord, index) => ({ - onClick: () => { - this.onTableClickRow({ tableCode, tableConfig, rowRecord }); - } - }) - } - return - { - isBatchAddList - ? ( -
- -
- ) : ( - TableHeadBtns && TableHeadBtns.length - ? ( -
- {TableHeadBtns} -
- ) - : null - ) - } + : { + components: TableResizableCell, + onRow: (rowRecord, index) => ({ + onClick: () => { + this.onTableClickRow({ tableCode, tableConfig, rowRecord }); + }, + }), + }; + return ( + + {isBatchAddList ? ( +
+ +
+ ) : TableHeadBtns && TableHeadBtns.length ? ( +
{TableHeadBtns}
+ ) : null} -
- { - this.onTableChange(tableCode, pagination, filters, sorter) - }} - rowSelection={tableConfig.checked ? rowSelection : null} - rowClassName={(record, index) => { - const remoteClass = this.onTableRowClassName({ tableConfig, record }) - const crossClass = index % 2 === 1 ? 'dark-row' : 'light-row' - if (remoteClass) { - return classNames(styles[remoteClass]); +
+
{ + this.onTableChange(tableCode, pagination, filters, sorter); + }} + rowSelection={tableConfig.checked ? rowSelection : null} + rowClassName={(record, index) => { + const remoteClass = this.onTableRowClassName({ tableConfig, record }); + const crossClass = index % 2 === 1 ? 'dark-row' : 'light-row'; + if (remoteClass) { + return classNames(styles[remoteClass]); + } + return classNames(styles[crossClass]); + }} + expandedRowRender={ + tableConfig.hasChildren + ? (record) => { + return this.onRenderTableSubRow({ record, tableCode, tableConfig }); + } + : null } - return classNames(styles[crossClass]) - }} - expandedRowRender={(tableConfig.hasChildren ? (record) => { - return this.onRenderTableSubRow({ record, tableCode, tableConfig }); - } : null)} - expandIcon={(props) => { - if (!props.expandable) return null - if (props.expanded) { - return props.onExpand(props.record, e)} /> - } else { - return props.onExpand(props.record, e)} /> + expandIcon={(props) => { + if (!props.expandable) return null; + if (props.expanded) { + return props.onExpand(props.record, e)} />; + } else { + return props.onExpand(props.record, e)} />; + } + }} + expandedRowKeys={this.state.expandedRowKeysChanged ? this.state.expandedRowKeys : defaultExpandedRowKeys} + onExpand={(expanded, record) => { + this.onTableExpandRow({ tableCode, tableConfig, record, expanded }); + }} + onExpandedRowsChange={(expandedRowKeys) => { + this.setState({ + expandedRowKeysChanged: true, + expandedRowKeys, + }); + }} + footer={ + hasFooter() + ? (data) => { + return this.onRenderTableFooter({ + tableCode, + tableConfig, + selectedRowKeys: selectKeys, + data, + columns: tableConfig.columns, + }); + } + : null } - }} - expandedRowKeys={this.state.expandedRowKeysChanged ? this.state.expandedRowKeys : defaultExpandedRowKeys} - onExpand={(expanded, record) => { - this.onTableExpandRow({ tableCode, tableConfig, record, expanded }) - }} - onExpandedRowsChange={expandedRowKeys => { - this.setState({ - expandedRowKeysChanged: true, - expandedRowKeys - }) - }} - footer={hasFooter() ? (data) => { - return this.onRenderTableFooter({ - tableCode, - tableConfig, - selectedRowKeys: selectKeys, - data, - columns: tableConfig.columns - }); - } : null} - bordered - {...isScrollX()} - {...dragableProps} - > - { - newColumns && newColumns.map((h, index) => { - return ( - { - return { - onDoubleClick: (e) => { - e.preventDefault(); - e.stopPropagation() - if (h.title) { - openNotification(h); - } - } - } - }} - onHeaderCell={column => { - return { - onMouseEnter: () => { // 鼠标移入表头单元格 - this.setState({ - showColumnSetting: column.key - }) - }, - width: column.width, - onResize: this.handleResize(tableCode, column) - }; - }} - /> - ) - }) - } - {!isBatchAddList ? this.tableOperateColumn(tableCode) : null} -
-
-
+ bordered + {...isScrollX()} + {...dragableProps} + > + {newColumns && + newColumns.map((h, index) => { + return ( + { + return { + onDoubleClick: (e) => { + e.preventDefault(); + e.stopPropagation(); + if (h.title) { + openNotification(h); + } + }, + }; + }} + onHeaderCell={(column) => { + return { + onMouseEnter: () => { + // 鼠标移入表头单元格 + this.setState({ + showColumnSetting: column.key, + }); + }, + width: column.width, + onResize: this.handleResize(tableCode, column), + }; + }} + /> + ); + })} + {!isBatchAddList ? this.tableOperateColumn(tableCode) : null} + +
+ + ); } handleTableCardSelect = (evt, item, tableCode) => { - const selectKeys = cloneDeep(this.getTableSelectedRowKeys({ tableCode })) + const selectKeys = cloneDeep(this.getTableSelectedRowKeys({ tableCode })); if (evt.target.checked) { - this.onSelectTableChange(tableCode, [item.ID].concat(selectKeys), [item]) + this.onSelectTableChange(tableCode, [item.ID].concat(selectKeys), [item]); } else { - const findIndex = selectKeys.findIndex(sel => sel === item.ID) + const findIndex = selectKeys.findIndex((sel) => sel === item.ID); if (findIndex !== -1) { - selectKeys.splice(findIndex, 1) - this.onSelectTableChange(tableCode, selectKeys, []) + selectKeys.splice(findIndex, 1); + this.onSelectTableChange(tableCode, selectKeys, []); } } - } + }; /* * 渲染卡片式表格 */ getRenderTableCard(tableCode) { - if (tableCode === undefined) tableCode = this.defaultTableCode - let tableConfig = this.getTableConfig({ tableCode }) + if (tableCode === undefined) tableCode = this.defaultTableCode; + let tableConfig = this.getTableConfig({ tableCode }); if (!tableConfig) return null; let loadParam = this.getLoadParam({ tableCode }); @@ -2586,49 +2765,51 @@ class TableBaseComponent extends ComponentBase { loadParam = loadParam || { PageIndex: 1, IsAllLoad: false, Limit: 10 }; tableData = tableData || { TotalCount: 0 }; - const newColumns = this.getColumnByColumnConfig(tableCode) // 表头字段 - const tableDataSource = this.genDataSource(tableCode, tableData) - const selectKeys = this.getTableSelectedRowKeys({ tableCode }) + const newColumns = this.getColumnByColumnConfig(tableCode); // 表头字段 + const tableDataSource = this.genDataSource(tableCode, tableData); + const selectKeys = this.getTableSelectedRowKeys({ tableCode }); const paginationConfig = { - pageSizeOptions: ['5', '10', '20','100','100'], + pageSizeOptions: ['5', '10', '20', '100', '100'], current: loadParam ? loadParam.PageIndex : 1, pageSize: loadParam ? (loadParam.IsAllLoad ? loadParam.ShowLimit : loadParam.Limit) : 10, total: tableData ? tableData.TotalCount : 0, showSizeChanger: true, showQuickJumper: true, size: 'small', - position: (tableConfig.position ? tableConfig.position : 'bottom'), - showTotal: () => `共 ${tableData ? tableData.TotalCount : 0} 条` - } + position: tableConfig.position ? tableConfig.position : 'bottom', + showTotal: () => `共 ${tableData ? tableData.TotalCount : 0} 条`, + }; - let isLoading = this.props.loading ? this.props.loading.effects["listPage/getTableData"] : false; + let isLoading = this.props.loading ? this.props.loading.effects['listPage/getTableData'] : false; if (!isLoading) { - isLoading = this.state.formLoading + isLoading = this.state.formLoading; } - const isBatchAddList = this.props.data && this.props.data.btnTypeBatchAdd - const TableHeadBtns = this.getRenderBtns(tableCode, tableConfig, null, tableConfig.btns, 1) + const isBatchAddList = this.props.data && this.props.data.btnTypeBatchAdd; + const TableHeadBtns = this.getRenderBtns(tableCode, tableConfig, null, tableConfig.btns, 1); - const WrapComponent = tableConfig.dragable ? DragDropCard : React.Fragment + const WrapComponent = tableConfig.dragable ? DragDropCard : React.Fragment; - return - -
{TableHeadBtns}
-
- } - > -
- -
- -
- - { - tableDataSource.map((ds, dsIndex) => { - const actionBtns = this.getRenderBtns(tableCode, tableConfig, ds, tableConfig.rowBtns, 0) - const thumbCode = get(ds, tableConfig.cardPicField) + return ( + + +
{TableHeadBtns}
+
+ } + > +
+ +
+ +
+ + {tableDataSource.map((ds, dsIndex) => { + const actionBtns = this.getRenderBtns(tableCode, tableConfig, ds, tableConfig.rowBtns, 0); + const thumbCode = get(ds, tableConfig.cardPicField); return ( this.handleTableCardSelect(evt, ds, tableCode)} + onChange={(evt) => this.handleTableCardSelect(evt, ds, tableCode)} className={styles.tableCardCheckbox} /> - { - newColumns.map(col => { - return ( -
- {col.title} - - {col.render ? col.render(ds[col.dataIndex], ds) : ds[col.dataIndex]} -
- ) - }) - } + {newColumns.map((col) => { + return ( +
+ {col.title} + + {col.render ? col.render(ds[col.dataIndex], ds) : ds[col.dataIndex]} +
+ ); + })}
操作: @@ -2676,21 +2855,21 @@ class TableBaseComponent extends ComponentBase {
- ) - }) - } -
- { - this.onTableChange(tableCode, { ...paginationConfig, current, pageSize }) - }} - onShowSizeChange={(current, pageSize) => { - this.onTableChange(tableCode, { ...paginationConfig, current, pageSize }) - }} - {...paginationConfig} - /> -
-
+ ); + })} +
+ { + this.onTableChange(tableCode, { ...paginationConfig, current, pageSize }); + }} + onShowSizeChange={(current, pageSize) => { + this.onTableChange(tableCode, { ...paginationConfig, current, pageSize }); + }} + {...paginationConfig} + /> +
+
+ ); } } diff --git a/src/layout/FullOther/HomeContent.js b/src/layout/FullOther/HomeContent.js new file mode 100644 index 0000000..acfb817 --- /dev/null +++ b/src/layout/FullOther/HomeContent.js @@ -0,0 +1,630 @@ +// HomeContent.js +import React, { useEffect, useRef } from 'react'; +import { Row, Col, Icon, Carousel } from 'antd'; +import styles from './../fullinter.less'; +import echarts from 'echarts'; + +class HomeContent extends React.Component { + constructor(props) { + super(props); + this.carouselRef = React.createRef(); + this.echartsInstances = { + riskLevel: null, + safeCheckChart: null, + dangerOperation: null, + backLogChart: null, + }; + this.chartResizeHandlers = {}; + this.isUnmounted = false; + } + + waitForElement = (elementId, maxRetries = 10) => { + return new Promise((resolve) => { + let retries = 0; + const checkInterval = setInterval(() => { + const element = document.getElementById(elementId); + if (element || retries >= maxRetries) { + clearInterval(checkInterval); + resolve(!!element); + } + retries++; + }, 50); + }); + }; + + riskLevel = async () => { + if (this.isUnmounted) return; + const elementExists = await this.waitForElement('riskLevelFull'); + if (!elementExists || this.isUnmounted) return; + + if (this.echartsInstances.riskLevel) { + this.echartsInstances.riskLevel.dispose(); + this.echartsInstances.riskLevel = null; + } + + const riskLevels = document.getElementById('riskLevelFull'); + if (!riskLevels) return; + + this.echartsInstances.riskLevel = echarts.init(riskLevels); + const data = this.props.riskTypeRate || []; + + const option = { + color: ['#c92a2a', '#ffa94d', '#ffe066', '#4285F4'], + title: [ + { + text: '风险分级占比', + x: 'center', + y: '5%', + textStyle: { fontSize: 16, color: '#000' }, + }, + ], + tooltip: { + trigger: 'item', + formatter: function (params) { + const color = params.color; + return `
+ + ${params.name}: + ${params.value} +
`; + }, + backgroundColor: 'rgba(255, 255, 255, 0.5)', + borderColor: '#FFFFFF', + borderWidth: 2, + textStyle: { color: '#000', fontSize: 14 }, + }, + series: [ + { + name: '访问来源', + type: 'pie', + minAngle: 20, + radius: ['55%', '80%'], + center: ['50%', '50%'], + clockwise: true, + avoidLabelOverlap: true, + hoverOffset: 15, + label: { + show: true, + position: 'inside', + formatter: '{a|{b}:{c}}{e|({d}%)}\n', + color: '#000', + textBorderWidth: 0, + rich: { + a: { padding: [-15, 0, 0, 0], fontSize: 15, color: '#000', textBorderWidth: 0 }, + e: { fontSize: 14, color: '#000', padding: [-15, 0, 0, 5], textBorderWidth: 0 }, + }, + }, + labelLine: { normal: { show: false } }, + data: data.map((item) => ({ name: item.riskType, value: item.count })), + }, + ], + }; + + this.echartsInstances.riskLevel.setOption(option); + + const resizeHandler = () => { + if (this.echartsInstances.riskLevel && !this.isUnmounted) { + this.echartsInstances.riskLevel.resize(); + } + }; + this.chartResizeHandlers.riskLevel = resizeHandler; + window.addEventListener('resize', resizeHandler); + }; + + transformDat = (originalData, barTopColor, num) => { + if (!originalData || !Array.isArray(originalData) || originalData.length === 0) { + return { companyNames: [], series: [], legendData: [] }; + } + + let allTypes = []; + if (num == 1) { + allTypes = [...new Set(originalData.flatMap((item) => item.details?.map((detail) => detail.jobName)))]; + } else { + allTypes = [...new Set(originalData.flatMap((item) => item.details?.map((detail) => detail.name)))]; + } + + allTypes = allTypes.filter(Boolean); + const companyNames = originalData?.map((item) => item.company); + const series = allTypes?.map((typeName, index) => ({ + name: typeName, + type: 'bar', + itemStyle: { + normal: { + color: function (params) { + if (num == 1) { + return barTopColor[index]; + } else { + return new echarts.graphic.LinearGradient(0, 0, 0, 1, [ + { offset: 0, color: barTopColor[index][0] }, + { offset: 1, color: barTopColor[index][1] }, + ]); + } + }, + }, + }, + data: originalData?.map((company) => { + const detail = company.details?.find((d) => (num == 1 ? d.jobName : d.name) === typeName); + return detail ? detail.qty : 0; + }), + })); + + return { companyNames, series, legendData: allTypes }; + }; + + safeCheckChart = async () => { + if (this.isUnmounted) return; + const elementExists = await this.waitForElement('safeCheckChart'); + if (!elementExists || this.isUnmounted) return; + + if (this.echartsInstances.safeCheckChart) { + this.echartsInstances.safeCheckChart.dispose(); + this.echartsInstances.safeCheckChart = null; + } + + let safeCheckCharts = document.getElementById('safeCheckChart'); + if (!safeCheckCharts) return; + + const barTopColor = ['#02c3f1', '#53e568', '#a154e9']; + const jobData = this.props.jobTodayTop3 || []; + + if (jobData.length === 0) return; + + this.echartsInstances.safeCheckChart = echarts.init(safeCheckCharts); + let xdata = this.transformDat(jobData, barTopColor, 1); + + this.echartsInstances.safeCheckChart.setOption({ + title: { + text: '当日工作票排名前三家的数据', + textStyle: { fontSize: 16, color: '#fff' }, + }, + tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' } }, + legend: { + data: xdata.legendData, + align: 'right', + right: 10, + itemGap: 16, + itemWidth: 18, + itemHeight: 10, + textStyle: { color: '#fff', fontSize: 14 }, + }, + color: barTopColor, + grid: { left: '3%', right: '4%', bottom: '3%', containLabel: true }, + xAxis: [ + { + type: 'category', + data: xdata.companyNames, + axisLine: { lineStyle: { color: '#3eb2e8' } }, + axisLabel: { textStyle: { color: '#fff' } }, + }, + ], + yAxis: [ + { + type: 'value', + axisLine: { show: false }, + axisLabel: { textStyle: { color: '#fff' } }, + splitLine: { lineStyle: { color: '#4784e8' } }, + }, + ], + series: xdata.series, + }); + + const resizeHandler = () => { + if (this.echartsInstances.safeCheckChart && !this.isUnmounted) { + this.echartsInstances.safeCheckChart.resize(); + } + }; + this.chartResizeHandlers.safeCheckChart = resizeHandler; + window.addEventListener('resize', resizeHandler); + }; + + dangerOperation = async () => { + if (this.isUnmounted) return; + const elementExists = await this.waitForElement('dangerOperationChart'); + if (!elementExists || this.isUnmounted) return; + + if (this.echartsInstances.dangerOperation) { + this.echartsInstances.dangerOperation.dispose(); + this.echartsInstances.dangerOperation = null; + } + + const dangerOperationCharts = document.getElementById('dangerOperationChart'); + if (!dangerOperationCharts) return; + + const linkData = this.props.linkSum || []; + if (linkData.length === 0) return; + + this.echartsInstances.dangerOperation = echarts.init(dangerOperationCharts); + const xAxisData = linkData.map((item) => item.name); + const seriesData = linkData.map((item) => item.qty); + + const option = { + color: ['#4285F4'], + title: [ + { + text: '当日工作票的统计数量', + x: 'center', + y: '5%', + textStyle: { fontSize: 16, color: '#000' }, + }, + ], + tooltip: { + trigger: 'axis', + axisPointer: { type: 'shadow' }, + formatter: function (params) { + const color = params[0].color; + return `
+ + ${params[0].name}: + ${params[0].value} +
`; + }, + backgroundColor: 'rgba(255, 255, 255, 0.5)', + borderColor: '#FFFFFF', + borderWidth: 2, + textStyle: { color: '#000', fontSize: 14 }, + }, + grid: { left: '10%', right: '5%', top: '15%', bottom: '10%', containLabel: true }, + xAxis: [ + { + type: 'category', + data: xAxisData, + axisLine: { lineStyle: { color: '#000' } }, + axisTick: { show: false }, + axisLabel: { textStyle: { color: '#000' }, rotate: 30, interval: 0 }, + }, + ], + yAxis: [ + { + type: 'value', + name: '', + nameTextStyle: { color: '#000' }, + axisLine: { show: false }, + axisTick: { show: false }, + axisLabel: { textStyle: { color: '#000' } }, + splitLine: { show: false }, + }, + ], + series: [ + { + name: '危险作业数量', + type: 'bar', + data: seriesData, + itemStyle: { + normal: { color: '#4285F4', borderRadius: 12 }, + emphasis: { shadowBlur: 10, shadowOffsetX: 0, shadowColor: 'rgba(0, 0, 0, 0.5)' }, + }, + label: { show: true, position: 'top', textStyle: { color: '#000', fontSize: 12 }, formatter: '{c}' }, + barWidth: '60%', + }, + ], + }; + + this.echartsInstances.dangerOperation.setOption(option); + + const resizeHandler = () => { + if (this.echartsInstances.dangerOperation && !this.isUnmounted) { + this.echartsInstances.dangerOperation.resize(); + } + }; + this.chartResizeHandlers.dangerOperation = resizeHandler; + window.addEventListener('resize', resizeHandler); + }; + + backLog = async () => { + if (this.isUnmounted) return; + const elementExists = await this.waitForElement('backLogChart'); + if (!elementExists || this.isUnmounted) return; + + if (this.echartsInstances.backLogChart) { + this.echartsInstances.backLogChart.dispose(); + this.echartsInstances.backLogChart = null; + } + + let backLogCharts = document.getElementById('backLogChart'); + if (!backLogCharts) return; + + const taskData = this.props.taskTop3 || []; + if (taskData.length === 0) return; + + const barTopColor = [ + ['#75baf3', '#2177d5'], + ['#ffa94d', '#f76707'], + ['#99ca6e', '#48a447'], + ]; + + this.echartsInstances.backLogChart = echarts.init(backLogCharts); + let xdata = this.transformDat(taskData, barTopColor, 2); + const legendColors = barTopColor.map((gradient) => gradient[0]); + + this.echartsInstances.backLogChart.setOption({ + title: { + text: '各事项排名前三名统计', + x: 'center', + y: '5%', + textStyle: { fontSize: 16, color: '#000' }, + }, + tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' } }, + legend: { + data: xdata.legendData.map((name, index) => ({ + name: name, + itemStyle: { color: legendColors[index], borderWidth: 0 }, + textStyle: { color: '#000', fontSize: 14 }, + })), + align: 'right', + top: 10, + right: 10, + itemGap: 16, + itemWidth: 18, + itemHeight: 12, + }, + color: legendColors, + grid: { left: '3%', right: '4%', bottom: '3%', containLabel: true }, + xAxis: [ + { + type: 'category', + data: xdata.companyNames, + axisLine: { lineStyle: { color: '#3eb2e8' } }, + axisLabel: { textStyle: { color: '#000' } }, + }, + ], + yAxis: [ + { + type: 'value', + axisLine: { show: false }, + axisLabel: { textStyle: { color: '#000' } }, + splitLine: { lineStyle: { color: '#4784e8' } }, + }, + ], + series: xdata.series, + }); + + const resizeHandler = () => { + if (this.echartsInstances.backLogChart && !this.isUnmounted) { + this.echartsInstances.backLogChart.resize(); + } + }; + this.chartResizeHandlers.backLogChart = resizeHandler; + window.addEventListener('resize', resizeHandler); + }; + + initAllCharts = () => { + if (this.isUnmounted) return; + setTimeout(() => { + if (this.isUnmounted) return; + this.riskLevel(); + this.safeCheckChart(); + this.dangerOperation(); + this.backLog(); + }, 100); + }; + + disposeAllCharts = () => { + Object.keys(this.echartsInstances).forEach((key) => { + if (this.echartsInstances[key]) { + try { + this.echartsInstances[key].dispose(); + } catch (e) { + console.warn(`Dispose chart ${key} error:`, e); + } + this.echartsInstances[key] = null; + } + }); + + Object.keys(this.chartResizeHandlers).forEach((key) => { + if (this.chartResizeHandlers[key]) { + window.removeEventListener('resize', this.chartResizeHandlers[key]); + } + }); + this.chartResizeHandlers = {}; + }; + + handlePrev = () => { + if (this.carouselRef.current) { + this.carouselRef.current.prev(); + } + }; + + handleNext = () => { + if (this.carouselRef.current) { + this.carouselRef.current.next(); + } + }; + + handleCarouselChange = (current) => { + this.props.onCarouselChange?.(current); + }; + + handleDotClick = (index) => { + this.props.onDotClick?.(index); + if (this.carouselRef.current) { + this.carouselRef.current.goTo(index); + } + }; + + componentDidMount() { + this.isUnmounted = false; + this.initAllCharts(); + } + + componentDidUpdate(prevProps) { + if ( + prevProps.riskTypeRate !== this.props.riskTypeRate || + prevProps.jobTodayTop3 !== this.props.jobTodayTop3 || + prevProps.linkSum !== this.props.linkSum || + prevProps.taskTop3 !== this.props.taskTop3 + ) { + this.disposeAllCharts(); + this.initAllCharts(); + } + } + + componentWillUnmount() { + this.isUnmounted = true; + this.disposeAllCharts(); + } + + render() { + const { + riskTypeRate = [], + riskTotal = [], + mediaList = [], + announcementList = [], + currentMediaIndex = 0, + } = this.props; + + return ( +
+ + {/* 左侧区域 */} + +
+ + + {riskTypeRate.map((item, index) => ( +
+
{item.riskType}
+
{item.count}
+
+ ))} + + +
+ +
+
+ +
+ +
+ + +
年度隐患数据
+ {riskTotal.map((item, index) => ( +
+
{item.name}
+
{item.value}
+
+ ))} + + +
+ +
+
+ + + {/* 中间区域 */} + +
+
安全方针:以人为本、关注健康、依法治企、安全发展。
+
安全理念:一切风险皆可控,一切事故皆可防!
+
+ +
+
+ + {mediaList.map((item, index) => ( +
+ {item.type === 'video' ? ( +
+ ))} +
+
+ +
+
+ +
+
+ {mediaList.map((_, index) => ( + this.handleDotClick(index)} + /> + ))} +
+
+
+ +
+
+
+ + 公司公告 +
+ 共 {announcementList.length} 条公告 +
+
+ {announcementList.length > 0 ? ( +
    + {announcementList.map((item, index) => ( +
  • item.url && window.open(item.url)} + > + + {item.title} + + + {item.publishTime || item.createTime || item.date} + +
  • + ))} +
+ ) : ( +
+ + 暂无公告 +
+ )} +
+
+ + + {/* 右侧区域 */} + +
+ + +
年度培训数据
+ {riskTotal.map((item, index) => ( +
+
{item.name}
+
{item.value}
+
+ ))} + + +
+ +
+
+ +
+ +
+
+
+ +
+
+ ); + } +} + +export default HomeContent; diff --git a/src/layout/FullScreenInter.js b/src/layout/FullScreenInter.js index cec0895..60d6efa 100644 --- a/src/layout/FullScreenInter.js +++ b/src/layout/FullScreenInter.js @@ -1,34 +1,18 @@ -import React, { useState, useEffect, useMemo, useRef } from 'react'; +// FullScreenInter.js - 主文件保持简洁 +import React from 'react'; import { connect } from 'dva'; -import { withRouter, matchPath } from 'dva/router'; -import { Scrollbars } from 'react-custom-scrollbars'; -import { Icon, Row, Col, Progress, Tabs } from 'antd'; -import EnergyIcon from '../utils/energyIcon'; -import { $consts } from '../plugins'; +import { withRouter } from 'dva/router'; +import { Icon, Row, Col } from 'antd'; import styles from './fullinter.less'; -import echarts from 'echarts'; -import realGif from '../assets/layout/mofang.png'; import logo from '../assets/layout/headerno-logo-new.png'; import debounce from 'lodash.debounce'; import storage from '../utils/storage'; import { initFilter } from '../utils/common'; -import { - FullScreenContainer, - BorderBox8, - BorderBox10, - ScrollBoard, - CapsuleChart, - WaterLevelPond, - BorderBox7, - BorderBox6, -} from '@jiaminghi/data-view-react'; -import { color } from 'echarts/lib/export'; -import { title } from 'process'; -const { TabPane } = Tabs; +import HomeContent from './FullOther/HomeContent'; const getScale = () => { const width = 1920, - height = 1080; // 此处可以根据实际设计稿尺寸修改 + height = 1080; let ww = window.innerWidth / width; let wh = window.innerHeight / height; return ww < wh ? ww : wh; @@ -38,1722 +22,228 @@ class FullScreen extends React.Component { constructor(props) { super(props); this.state = { - safetySloganOne: '', - animationDuration: 20, - sliderColor: '#de4e58', - sliderSize: '24px', nowDate: '', - riskTypeRate: [], //风险等级占比 + riskTypeRate: [], + riskTotal: [ + { name: '年度重大隐患数', value: 1 }, + { name: '年度一般隐患数量', value: 89 }, + { name: '未整改隐患数量', value: 18 }, + ], linkSum: [], - jobTodayTop3: [], //当日工作票排名前三 - hiddenRectify: {}, //隐患整改率 - taskTop3: [], //各事项排名前三 - jobFinishRate: [], //作业现场完成情况统计 - safeCheckSum: [], //各公司安全检查统计 - listSETrainSum: [], //各公司安全培训统计 + jobTodayTop3: [], + taskTop3: [], scale: getScale(), - configBanner: ['首页', '风险管理', '安全检查', '隐患管理', '作业现场', '安全培训'], - }; - this.echartsInstances = { - riskLevel: null, - opretionTrend: null, - completeone: null, + configBanner: ['首页', '风险管控', '隐患治理', '班组建设', '危险作业', '安全培训'], + mediaList: [], + currentMediaIndex: 0, + announcementList: [], + activeTab: '首页', }; + this.isUnmounted = false; } setScale = debounce(() => { - // debounce节流 - // 获取到缩放比,设置它 - let scale = getScale(); - this.setState({ scale }); + if (this.isUnmounted) return; + this.setState({ scale: getScale() }); }, 500); + toggleFullscreen = () => { + if (!document.fullscreenElement) { + document.documentElement.requestFullscreen?.(); + } else { + document.exitFullscreen?.(); + } + }; + componentDidMount() { - window.addEventListener('resize', this.setScale); // 得到呈现的屏幕宽高比 - // this.getHomeTitle(); + this.isUnmounted = false; + window.addEventListener('resize', this.setScale); this.getHomeDataArray(); - this.setState({ activeTab: '首页' }); + this.loadMediaFiles(); + this.getAnnouncementData(); this.timer = setInterval(() => { - this.setState({ - nowDate: this.getDate(), - }); + if (!this.isUnmounted) this.setState({ nowDate: this.getDate() }); }, 1000); + + document.addEventListener('fullscreenchange', this.handleFullscreenChange); } - executionChart = () => { - this.riskLevel(); - this.safeCheckChart(); - this.dangerOperation(); - this.completeChart(); - this.backLog(); - this.safedanger(); + + getAnnouncementData = () => { + this.setState({ + announcementList: [ + { id: 1, title: '关于2024年安全生产月活动的通知', publishTime: '2024-06-01', url: '' }, + { id: 2, title: '公司第三季度安全培训安排', publishTime: '2024-05-28', url: '' }, + { id: 3, title: '关于开展安全隐患排查整治工作的通知', publishTime: '2024-05-20', url: '' }, + { id: 4, title: '安全生产标准化建设阶段性总结', publishTime: '2024-05-15', url: '' }, + { id: 5, title: '关于表彰2024年第一季度安全生产先进单位的决定', publishTime: '2024-05-10', url: '' }, + ], + }); + }; + + loadMediaFiles = () => { + this.setState({ + mediaList: [ + { type: 'image', url: 'http://10.2.7.18:28028//WZ_Images/static/smyzw@2x.png' }, + { type: 'video', url: 'http://10.2.7.18:28028/WZ_Images/Img_JFSC/welcom/1.mp4' }, + ], + }); + }; + + handleCarouselChange = (current) => { + this.setState({ currentMediaIndex: current }); + }; + + handleDotClick = (index) => { + this.setState({ currentMediaIndex: index }); }; - componentDidUpdate(prevProps, prevState) { - // 当从其他tab切换回首页时 - if (prevState.activeTab !== this.state.activeTab && this.state.activeTab === '首页') { - // 延迟确保DOM已渲染 - setTimeout(() => { - this.executionChart(); - }, 300); // 稍微增加延迟时间 - } - } handleTabClick = (name) => { - // 如果从首页切换到其他tab,先清理图表 - this.setState({ activeTab: name }); - - const tabActions = { - 首页: () => { - console.log('跳转到首页'); - // 首页图表会在componentDidUpdate中初始化 - }, - 风险管控: () => { - console.log('跳转到风险管控'); - }, - 隐患治理: () => { - console.log('跳转到隐患治理'); - }, - // ... 其他tab - }; - - if (tabActions[name]) { - tabActions[name](); - } }; + + handleFullscreenChange = () => { + this.forceUpdate(); + }; + componentWillUnmount() { + this.isUnmounted = true; window.removeEventListener('resize', this.setScale); - clearInterval(this.timer); + if (this.timer) clearInterval(this.timer); + document.removeEventListener('fullscreenchange', this.handleFullscreenChange); } + getDate = () => { - var myDate = new Date(); - var year = myDate.getFullYear(); //获取当前年 - var mon = myDate.getMonth() + 1; //获取当前月 - var date = myDate.getDate(); //获取当前日 - // var hours = myDate.getHours(); //获取当前小时 - // var minutes = myDate.getMinutes(); //获取当前分钟 - - if (myDate.getHours() < 10) { - var hours = '0' + myDate.getHours(); - } else { - hours = myDate.getHours(); //获取当前小时 - } - if (myDate.getMinutes() < 10) { - var minutes = '0' + myDate.getMinutes(); - } else { - minutes = myDate.getMinutes(); //获取当前分钟 - } - if (myDate.getSeconds() < 10) { - var seconds = '0' + myDate.getSeconds(); - } else { - seconds = myDate.getSeconds(); //获取当前秒 - } - - var now = year + ' 年 ' + mon + ' 月 ' + date + ' 日 ' + '\t\t\t' + hours + ' : ' + minutes + ' : ' + seconds; - return now; + const myDate = new Date(); + const year = myDate.getFullYear(); + const mon = myDate.getMonth() + 1; + const date = myDate.getDate(); + let hours = myDate.getHours(); + let minutes = myDate.getMinutes(); + let seconds = myDate.getSeconds(); + hours = hours < 10 ? '0' + hours : hours; + minutes = minutes < 10 ? '0' + minutes : minutes; + seconds = seconds < 10 ? '0' + seconds : seconds; + return `${year} 年 ${mon} 月 ${date} 日 \t\t\t${hours} : ${minutes} : ${seconds}`; }; + getHomeDataArray = () => { - var orgId = storage('lacal').getItem('webOrgId')?.val; //登录后有存储登录信息 - let json = initFilter(orgId); + const orgId = storage('lacal').getItem('webOrgId')?.val; + const json = initFilter(orgId); this.props.dispatch({ type: 'app/getDataByPost', payload: json, url: 'BI/BIKanBanController/ReturnAllData', onComplete: (ret) => { - if (ret) { - this.setState( - { - riskTypeRate: ret.riskTypeRate, - linkSum: ret.linkSum, - jobTodayTop3: ret.jobTodayTop3, - hiddenRectify: ret.hiddenRectify, - taskTop3: ret.taskTop3, - jobFinishRate: ret.jobFinishRate, - safeCheckSum: ret.safeCheckSum, - listSETrainSum: ret.listSETrainSum, - }, - () => { - this.executionChart(); - } - ); + if (ret && !this.isUnmounted) { + this.setState({ + riskTypeRate: ret.riskTypeRate || [], + linkSum: ret.linkSum || [], + jobTodayTop3: ret.jobTodayTop3 || [], + taskTop3: ret.taskTop3 || [], + }); } }, }); }; - riskLevel = () => { - // 如果已有实例,先销毁 - if (this.echartsInstances.riskLevel) { - this.echartsInstances.riskLevel.dispose(); - this.echartsInstances.riskLevel = null; - } - const riskLevels = document.getElementById('riskLevelFull'); - if (!riskLevels) { - // 使用requestAnimationFrame而不是setTimeout - requestAnimationFrame(() => { - this.executionChart(); - }); - return; - } - // 初始化echarts实例并保存引用 - this.echartsInstances.riskLevel = echarts.init(riskLevels); - const option = { - color: ['#c92a2a', '#FF6710', '#FFDD1E', '#0091FF', '#fa8a89'], - title: [ - { - text: '风险分级占比', - x: 'center', - y: '5%', - textStyle: { - fontSize: 16, - color: '#fff', - }, - }, - ], - tooltip: { - trigger: 'item', - formatter: function (params) { - const color = params.color; - return `
- - ${params.name}: - ${params.value} -
`; - }, - backgroundColor: 'rgba(255, 255, 255, 0.5)', - borderColor: '#FFFFFF', - borderWidth: 2, - textStyle: { - color: '#000', - fontSize: 14, - fontWeight: 'normal', - }, - }, - series: [ - { - name: '访问来源', - type: 'pie', - minAngle: 20, - radius: ['40%', '60%'], - center: ['50%', '50%'], - clockwise: true, - avoidLabelOverlap: true, - hoverOffset: 15, - label: { - show: true, - position: 'inside', - formatter: '{a|{b}:{c}}{e|({d}%)}\n', - color: '#FFFFFF', - textBorderWidth: 0, - rich: { - a: { - padding: [-15, 0, 0, 0], - fontSize: 15, - color: '#FFFFFF', - textBorderWidth: 0, - textShadow: 'none', - }, - e: { - fontSize: 14, - color: '#FFFFFF', - padding: [-15, 0, 0, 5], - textBorderWidth: 0, - textShadow: 'none', - }, - }, - }, - labelLine: { - normal: { - show: false, - }, - }, - data: this.state.riskTypeRate.map((item) => ({ - name: item.riskType, - value: item.count, - })), - }, - ], - }; - - this.echartsInstances.riskLevel.setOption(option); - - // 监听窗口大小变化 - const resizeHandler = () => { - if (this.echartsInstances.riskLevel) { - this.echartsInstances.riskLevel.resize(); - } - }; - - // 移除旧的监听器 - if (this.riskResizeHandler) { - window.removeEventListener('resize', this.riskResizeHandler); - } - - this.riskResizeHandler = resizeHandler; - window.addEventListener('resize', resizeHandler); - }; - transformDat = (originalData, barTopColor, num) => { - // 添加空值检查 - if (!originalData || !Array.isArray(originalData) || originalData.length === 0) { - return { - companyNames: [], - series: [], - legendData: [], - }; - } - // 获取所有的类型名称(去重) - let allTypes = []; - if (num == 1) { - allTypes = [...new Set(originalData.flatMap((item) => item.details?.map((detail) => detail.jobName)))]; - } else { - allTypes = [...new Set(originalData.flatMap((item) => item.details?.map((detail) => detail.name)))]; - } - - // 获取所有的公司名称(作为 x 轴标签) - const companyNames = originalData?.map((item) => item.company); - - // 为每个类型创建数据系列 - const series = allTypes?.map((typeName, index) => { - return { - name: typeName, - type: 'bar', - itemStyle: { - normal: { - color: function (params) { - if (num == 1) { - return barTopColor[index]; - } else { - return new echarts.graphic.LinearGradient(0, 0, 0, 1, [ - { - offset: 0, - color: barTopColor[index][0], - }, - { - offset: 1, - color: barTopColor[index][1], - }, - ]); - } - }, - }, - }, - data: originalData?.map((company) => { - // 找到该公司对应类型的数据,如果没有则返回 0 - const detail = company.details?.find((d) => (num == 1 ? d.jobName : d.name) === typeName); - return detail ? detail.qty : 0; - }), - }; - }); - - return { - companyNames, // x 轴数据 - series, // 系列数据 - legendData: allTypes, // legend 的 data - }; - }; - - safeCheckChart = () => { - if (this.echartsInstances.safeCheckChart) { - this.echartsInstances.safeCheckChart.dispose(); - this.echartsInstances.safeCheckChart = null; - } - - let safeCheckCharts = document.getElementById('safeCheckChart'); - if (!safeCheckCharts) { - requestAnimationFrame(() => { - this.safeCheckChart(); - }); - return; - } - const barTopColor = ['#02c3f1', '#53e568', '#a154e9']; - - this.echartsInstances.safeCheckChart = echarts.init(safeCheckCharts); - let xdata = []; - xdata = this.transformDat(this.state.jobTodayTop3, barTopColor, 1); - this.echartsInstances.safeCheckChart.setOption({ - title: { - text: '当日工作票排名前三家的数据', - textStyle: { - fontSize: 16, - color: '#fff', - }, - }, - tooltip: { - trigger: 'axis', - axisPointer: { - // 坐标轴指示器,坐标轴触发有效 - type: 'shadow', // 默认为直线,可选为:'line' | 'shadow' - }, - }, - legend: { - data: xdata.legendData, - align: 'right', - right: 10, - itemGap: 16, - itemWidth: 18, - itemHeight: 10, - textStyle: { - color: '#fff', - fontStyle: 'normal', - fontFamily: '微软雅黑', - fontSize: 14, - }, - }, - color: barTopColor, - grid: { - left: '3%', - right: '4%', - bottom: '3%', - containLabel: true, - }, - xAxis: [ - { - type: 'category', - data: xdata.companyNames, - textStyle: { - fontSize: 18, - color: '#ffffff', - }, - //坐标轴 - axisLine: { - lineStyle: { - color: '#3eb2e8', - }, - }, - //坐标值标注 - axisLabel: { - show: true, - textStyle: { - color: '#fff', - }, - }, - }, - ], - yAxis: [ - { - type: 'value', - textStyle: { - fontSize: 14, - color: '#ffffff', - }, - //坐标轴 - axisLine: { - show: false, - }, - //坐标值标注 - axisLabel: { - show: true, - textStyle: { - color: '#fff', - }, - }, - //分格线 - splitLine: { - lineStyle: { - color: '#4784e8', - }, - }, - }, - ], - series: xdata.series, - }); - - // 监听resize - const resizeHandler = () => { - if (this.echartsInstances.safeCheckChart) { - this.echartsInstances.safeCheckChart.resize(); - } - }; - - if (this.safeCheckResizeHandler) { - window.removeEventListener('resize', this.safeCheckResizeHandler); - } - - this.safeCheckResizeHandler = resizeHandler; - window.addEventListener('resize', resizeHandler); - }; - dangerOperation = () => { - // 如果已有实例,先销毁 - if (this.echartsInstances.dangerOperation) { - this.echartsInstances.dangerOperation.dispose(); - this.echartsInstances.dangerOperation = null; - } - - const dangerOperationCharts = document.getElementById('dangerOperationChart'); - if (!dangerOperationCharts) { - // 使用requestAnimationFrame而不是setTimeout - requestAnimationFrame(() => { - this.executionChart(); - }); - return; - } - - let legendData = []; - (this.state.linkSum.map((item) => { - legendData.push(item.name); - }), - // 初始化echarts实例并保存引用 - (this.echartsInstances.dangerOperation = echarts.init(dangerOperationCharts))); - - const option = { - color: [ - '#0090FF', - '#36CE9E', - '#e690d1', - '#FF515A', - '#8B5CFF', - '#00CA69', - '#FFC107', - '#E91E63', - '#9C27B0', - '#3F51B5', - '#2196F3', - '#4CAF50', - '#FF9800', - '#795548', - '#607D8B', - ], - title: [ - { - text: '各公司危险作业分类统计', - x: 'center', - y: '5%', - textStyle: { - fontSize: 16, - color: '#fff', - }, - }, - ], - legend: { - type: 'scroll', - orient: 'vertical', - left: '5%', - align: 'left', - top: '5%', - textStyle: { - color: '#fff', - }, - height: 250, - }, - tooltip: { - trigger: 'item', - formatter: function (params) { - const color = params.color; - return `
- - ${params.name}: - ${params.value} -
`; - }, - backgroundColor: 'rgba(255, 255, 255, 0.5)', - borderColor: '#FFFFFF', - borderWidth: 2, - textStyle: { - color: '#000', - fontSize: 14, - fontWeight: 'normal', - }, - }, - series: [ - { - name: '访问来源', - type: 'pie', - minAngle: 20, - center: ['55%', '50%'], - radius: ['40%', '65%'], - clockwise: true, - avoidLabelOverlap: true, - hoverOffset: 15, - label: { - show: true, - position: 'outside', - formatter: '{a|{b}:{c}}{e|({d}%)}\n', - // color: '#FFFFFF', - textBorderWidth: 0, - rich: { - a: { - padding: [-15, 0, 0, 0], - fontSize: 15, - // color: '#FFFFFF', - textBorderWidth: 0, - textShadow: 'none', - }, - e: { - fontSize: 14, - // color: '#FFFFFF', - padding: [-15, 0, 0, 5], - textBorderWidth: 0, - textShadow: 'none', - }, - }, - }, - labelLine: { - normal: { - length: 5, - length2: 3, - smooth: true, - }, - }, - data: this.state.linkSum.map((item) => ({ - name: item.name, - value: item.qty, - })), - }, - ], - }; - - this.echartsInstances.dangerOperation.setOption(option); - - // 监听窗口大小变化 - const resizeHandler = () => { - if (this.echartsInstances.dangerOperation) { - this.echartsInstances.dangerOperation.resize(); - } - }; - - // 移除旧的监听器 - if (this.dangerOperationResizeHandler) { - window.removeEventListener('resize', this.dangerOperationResizeHandler); - } - - this.dangerOperationResizeHandler = resizeHandler; - window.addEventListener('resize', resizeHandler); - }; - backLog = () => { - if (this.echartsInstances.backLogChart) { - this.echartsInstances.backLogChart.dispose(); - this.echartsInstances.backLogChart = null; - } - - let backLogCharts = document.getElementById('backLogChart'); - if (!backLogCharts) { - requestAnimationFrame(() => { - this.backLogChart(); - }); - return; - } - const barTopColor = [ - ['#75baf3', '#2177d5'], - ['#ffa94d', '#f76707'], - ['#99ca6e', '#48a447'], - ]; - - this.echartsInstances.backLogChart = echarts.init(backLogCharts); - let xdata = []; - xdata = this.transformDat(this.state.taskTop3, barTopColor, 2); - // 创建图例的渐变色块 - const legendColors = barTopColor.map((gradient) => gradient[0]); - this.echartsInstances.backLogChart.setOption({ - title: { - text: '各事项排名前三名统计', - textStyle: { - fontSize: 16, - color: '#fff', - }, - }, - tooltip: { - trigger: 'axis', - axisPointer: { - // 坐标轴指示器,坐标轴触发有效 - type: 'shadow', // 默认为直线,可选为:'line' | 'shadow' - }, - }, - legend: { - data: xdata.legendData.map((name, index) => ({ - name: name, - // 使用渐变的起始颜色作为图例颜色 - // icon: 'rect', - itemStyle: { - color: legendColors[index], - borderWidth: 0, - }, - textStyle: { - color: '#fff', - fontSize: 14, - }, - })), - align: 'right', - right: 10, - itemGap: 16, - itemWidth: 18, - itemHeight: 12, - textStyle: { - color: '#fff', - fontStyle: 'normal', - fontFamily: '微软雅黑', - fontSize: 14, - }, - }, - color: legendColors, // 设置全局颜色 - - grid: { - left: '3%', - right: '4%', - bottom: '3%', - containLabel: true, - }, - xAxis: [ - { - type: 'category', - data: xdata.companyNames, - textStyle: { - fontSize: 18, - color: '#ffffff', - }, - //坐标轴 - axisLine: { - lineStyle: { - color: '#3eb2e8', - }, - }, - //坐标值标注 - axisLabel: { - show: true, - textStyle: { - color: '#fff', - }, - }, - }, - ], - yAxis: [ - { - type: 'value', - textStyle: { - fontSize: 14, - color: '#ffffff', - }, - //坐标轴 - axisLine: { - show: false, - }, - //坐标值标注 - axisLabel: { - show: true, - textStyle: { - color: '#fff', - }, - }, - //分格线 - splitLine: { - lineStyle: { - color: '#4784e8', - }, - }, - }, - ], - series: xdata.series, - }); - - // 监听resize - const resizeHandler = () => { - if (this.echartsInstances.backLogChart) { - this.echartsInstances.backLogChart.resize(); - } - }; - - if (this.backLogResizeHandler) { - window.removeEventListener('resize', this.backLogResizeHandler); - } - - this.backLogResizeHandler = resizeHandler; - window.addEventListener('resize', resizeHandler); - }; - completeChart = () => { - if (this.echartsInstances.completeone) { - this.echartsInstances.completeone.dispose(); - this.echartsInstances.completeone = null; - } - - let completeCharts = document.getElementById('completeone'); - if (!completeCharts) { - requestAnimationFrame(() => { - this.completeChart(); - }); - return; - } - - this.echartsInstances.completeone = echarts.init(completeCharts); - let seriesArr = []; - let centerArr = [ - ['20%', '50%'], - ['50%', '50%'], - ['80%', '50%'], - ]; - const completeData = this.state.jobFinishRate - .filter((item) => item.name === '班前会议' || item.name === '岗位当班' || item.name === '岗位交接班') - .map((item) => { - return { - name: item.name, - value: item.rate, - }; - }); - const colorArr = [ - [ - [0.2, '#2ec7c9'], - [0.8, '#b6a2de'], - [1, '#5ab1ef'], - ], - [ - [0.2, '#5470c6'], - [0.8, '#91cc75'], - [1, '#fac858'], - ], - [ - [0.2, '#4ea397'], - [0.8, '#22c3aa'], - [1, '#7bd9a5'], - ], - ]; - completeData.forEach((item, index) => { - seriesArr.push({ - center: centerArr[index], - axisLine: { - show: true, - lineStyle: { - color: colorArr[index], - width: 8, - }, - radius: '90%', // 控制轴线本身的半径 - }, - axisTick: { - show: false, - }, - splitLine: { - length: 8, // 刻度线长度 - distance: 25, // 向内移动距离,负值越大越向内 - lineStyle: { - color: '#fff', // 刻度线颜色 - width: 1, // 刻度线宽度 - }, - }, - axisLabel: { - distance: 15, // 标签与刻度线的距离 - textStyle: { - color: '#fff', - fontSize: 10, - }, - // 调整标签偏移 - offset: [0, 0], // [水平偏移, 垂直偏移] - }, - itemStyle: { - normal: { - color: 'auto', - }, - }, - radius: '80%', - pointer: { - show: true, - width: '8%', - length: '30%', - }, - title: { - textStyle: { - // fontWeight: 'bolder', - fontSize: 14, - color: '#fff', - }, - offsetCenter: [0, '100%'], - }, - detail: { - textStyle: { - fontWeight: 'bolder', - fontSize: 16, - color: '#fff', - }, - offsetCenter: [0, '68%'], - formatter: '{value}%', - // formatter: '{value}万\n(5048人)', - }, - min: 0, - max: 100, - // name: '米类仪表盘', - type: 'gauge', - show: false, - splitNumber: 10, - data: [ - { - name: item.name, - value: item.value, - }, - ], - }); - }); - this.echartsInstances.completeone.setOption({ - series: seriesArr, - }); - - // 监听resize - const resizeHandler = () => { - if (this.echartsInstances.completeone) { - this.echartsInstances.completeone.resize(); - } - }; - - if (this.completeResizeHandler) { - window.removeEventListener('resize', this.completeResizeHandler); - } - - this.completeResizeHandler = resizeHandler; - window.addEventListener('resize', resizeHandler); - }; - safedanger = () => { - if (this.echartsInstances.opretionTrend) { - this.echartsInstances.opretionTrend.dispose(); - this.echartsInstances.opretionTrend = null; - } - - const opretionTrends = document.getElementById('opretionTrend'); - if (!opretionTrends) { - requestAnimationFrame(() => { - this.safedanger(); - }); - return; - } - - this.echartsInstances.opretionTrend = echarts.init(opretionTrends); - - // ... 原有配置代码 - let bgColor = '#000'; - let color = [ - '#0090FF', - '#36CE9E', - '#e690d1', - '#FF515A', - '#8B5CFF', - '#00CA69', - '#FFC107', - '#E91E63', - '#9C27B0', - '#3F51B5', - '#2196F3', - '#4CAF50', - '#FF9800', - '#795548', - '#607D8B', - ]; - const seriesNames = []; - this.state.listSETrainSum.map((item) => { - seriesNames.push(item.CN); - }); - - // 生成x轴数据(12个月) - let xAxisData = []; - xAxisData = Object.keys( - this.state.listSETrainSum[0] === undefined || this.state.listSETrainSum[0] === null - ? {} - : this.state.listSETrainSum[0] - ) - .filter((key) => key.startsWith('dtNowYM')) - .map((key) => this.state.listSETrainSum[0][key].substring(0, 7)) - .sort((a, b) => new Date(a) - new Date(b)); // 按日期升序 - - let yAxisData = []; - yAxisData = this.state.listSETrainSum.map((item) => { - const values = []; - for (let i = 0; i <= 5; i++) { - const key = i === 0 ? 'SUM_TRAIN_HOUR' : `SUM_TRAIN_HOUR_${i}`; - values.push(item[key]); - } - return values; - }); - - // 生成15个系列的数据 - let seriesArr = []; - for (let i = 0; i < this.state.listSETrainSum.length; i++) { - seriesArr.push({ - name: seriesNames[i], - type: 'line', - smooth: true, - symbolSize: 6, - data: yAxisData[i], - }); - } - - const hexToRgba = (hex, opacity) => { - let rgbaColor = ''; - let reg = /^#[\da-f]{6}$/i; - if (reg.test(hex)) { - rgbaColor = `rgba(${parseInt('0x' + hex.slice(1, 3))},${parseInt('0x' + hex.slice(3, 5))},${parseInt( - '0x' + hex.slice(5, 7) - )},${opacity})`; - } - return rgbaColor; - }; - const option = { - title: [ - { - text: '各家公司的安全教育培训学时统计', - x: 'center', - y: '5%', - textStyle: { - fontSize: 16, - color: '#fff', - }, - }, - ], - backgroundColor: '', - color: color, - legend: { - type: 'scroll', // 如果项目多可以使用滚动 - orient: 'vertical', // 设置为垂直排列 - right: 10, // 距离右侧的距离 - top: 'center', // 垂直居中 - align: 'left', // 文本左对齐 - textStyle: { - color: '#fff', // 文字颜色 - fontSize: 12, - }, - itemStyle: { - color: 'inherit', - borderWidth: 0, - opacity: 1, - }, - symbol: 'rect', // 实心矩形 - symbolSize: [12, 8], // 大小 - itemWidth: 10, // 图例标记的宽度 - itemHeight: 10, // 图例标记的高度 - itemGap: 15, // 图例每项之间的间隔 - pageButtonItemGap: 3, - pageButtonGap: 5, - pageButtonPosition: 'end', - pageIconColor: '#00caf7', - width: 100, // 限制宽度 - height: 250, // 限制高度,超出就会显示滚动 - }, - tooltip: { - trigger: 'axis', - formatter: function (params) { - let html = ''; - params.forEach((v) => { - html += `
- - ${v.seriesName} - ${v.value} - `; - }); - - return html; - }, - extraCssText: 'background: #fff; border-radius: 0;box-shadow: 0 0 3px rgba(0, 0, 0, 0.2);color: #333;', - axisPointer: { - type: 'shadow', - shadowStyle: { - // color: "#ffffff", - shadowColor: 'rgba(225,225,225,1)', - shadowBlur: 5, - }, - }, - }, - grid: { - top: '15%', - left: '5%', - right: '15%', // 为图例留出空间 - bottom: '15%', - containLabel: true, - }, - xAxis: [ - { - type: 'category', - boundaryGap: false, - axisLabel: { - textStyle: { - color: '#fff', - }, - }, - axisTick: { - show: false, - }, - axisLine: { - lineStyle: { - color: '#fff', - }, - }, - data: xAxisData, - }, - ], - yAxis: [ - { - type: 'value', - axisLabel: { - textStyle: { - color: '#fff', - }, - }, - nameTextStyle: { - color: '#fff', - fontSize: 12, - lineHeight: 40, - }, - splitLine: { - show: false, - lineStyle: { - type: 'dashed', - color: '#fff', - }, - }, - axisLine: { - show: false, - lineStyle: { - color: '#00c7ff', - width: 1, - type: 'solid', - }, - }, - axisTick: { - show: false, - }, - }, - ], - series: seriesArr, - }; - - this.echartsInstances.opretionTrend.setOption(option); - // 监听resize - const resizeHandler = () => { - if (this.echartsInstances.opretionTrend) { - this.echartsInstances.opretionTrend.resize(); - } - }; - - if (this.trendResizeHandler) { - window.removeEventListener('resize', this.trendResizeHandler); - } - - this.trendResizeHandler = resizeHandler; - window.addEventListener('resize', resizeHandler); + renderOtherTabContent = () => { + const { activeTab } = this.state; + return ( +
+
+
{activeTab} 页面
+
这里是 {activeTab} 的内容展示区域
+
请根据实际需求替换此内容
+
+
+ ); }; render() { const width = 1920, height = 1080; - // 固定好16:9的宽高比,计算出最合适的缩放比,宽高比可根据需要自行更改 - const { scale, safetySloganOne, animationDuration, sliderColor, sliderSize, activeTab } = this.state; - const renderContent = () => { - const riskChangeData = [ - { - name: '隐患数', - value: this.state.hiddenRectify.qty, - }, - { - name: '按期整改数', - value: this.state.hiddenRectify.ontimeQty, - }, - { - name: '延期整改数', - value: this.state.hiddenRectify.delayQty, - }, - ]; - const chartConfig = { - data: this.state.safeCheckSum.map((item) => ({ - name: item.company, - value: item.qty, - })), - showValue: true, - }; - const meetingData = this.state.jobFinishRate.map((item) => ({ - name: item.name, - value: item.qty, - })); - if (activeTab === '首页') { - return ( - <> - {/* 首页内容 - 原来的两行布局 */} -
- - {/* 原第一行内容 */} - - {/* 风险等级基本信息 */} -
- - - -
- {this.state.riskTypeRate.map((item, index) => ( -
-
{item.riskType}
-
{item.count}
-
- ))} -
- - -
- -
-
-
+ const { + scale, + activeTab, + riskTypeRate, + riskTotal, + jobTodayTop3, + linkSum, + taskTop3, + mediaList, + announcementList, + currentMediaIndex, + } = this.state; -
-
- -
-
-
-
-
- - - - {/* 中间内容 */} -
- -
-
-
- 安全方针:以人为本、关注健康、依法治企、安全发展。 -
-
- 安全理念:一切风险皆可控,一切事故皆可防! -
-
-
-
-
-
- -
-
-
-
-
- - - - {/* 右边内容 */} -
- -
-
-
-
-
- -
-
- -
-
-
-
-
- - {meetingData && - meetingData.map((item, index) => ( - -
-
-
-
{item.name}
-
- {item.value} - - 次 - -
-
-
-
- - ))} -
-
-
-
-
- -
-
- - {/* 第二行内容 */} -
- - -
- -
-
- {riskChangeData && - riskChangeData.map((item, index) => ( -
-
-
-
{item.name}
-
{item.value}
-
-
-
- ))} -
-
-
-
-
-
整改率
-
{this.state.hiddenRectify.rate}%
-
-
-
-
-
-
-
- - -
- -
-
-
- - -
- -
- - 各家公司安全检查统计 - - -
-
-
- -
-
- - ); - } else { - // 其他tab的内容 - 这里可以替换为你想要的其他内容 - return ( -
- - -
-
{activeTab} 页面
-
这里是 {activeTab} 的内容展示区域
-
请根据实际需求替换此内容
-
- -
-
- ); - } - }; return ( - -
-
-
- {/* 头部保持不变 */} -
- - -
- logo +
+
+
+ {/* 头部 */} +
+ + + logo +
+ {this.state.configBanner.slice(0, 3).map((item, index) => (
this.handleTabClick(item)} > - {this.state.configBanner && - this.state.configBanner.slice(0, 3).map((item, index) => ( -
this.handleTabClick(item)} - onKeyPress={(e) => e.key === 'Enter' && this.handleTabClick(item)} - tabIndex={0} - title={`点击进入${item}`} - role="button" - style={{ cursor: 'pointer' }} - > - {item} -
- ))} + {item}
-
- - -
-
金源公司安全生产管控平台
-
- - -
- {this.state.configBanner && - this.state.configBanner.slice(3, 6).map((item, index) => ( -
this.handleTabClick(item)} - onKeyPress={(e) => e.key === 'Enter' && this.handleTabClick(item)} - tabIndex={0} - title={`点击进入${item}`} - role="button" - style={{ cursor: 'pointer' }} - > - {item} -
- ))} -
-
- {/* {this.state.nowWeek} */} - {this.state.nowDate} -
- -
-
- - {/* 条件渲染的内容区域 */} - {renderContent()} + ))} +
+ + +
金源公司安全生产管控平台
+ + +
+ {this.state.configBanner.slice(3, 6).map((item, index) => ( +
this.handleTabClick(item)} + > + {item} +
+ ))} +
+ +
+ {this.state.nowDate} +
+ +
+ + {/* 内容区域 */} + {activeTab === '首页' ? ( + + ) : ( + this.renderOtherTabContent() + )}
- +
); } } diff --git a/src/layout/fullinter.less b/src/layout/fullinter.less index 78156c9..0e7a020 100644 --- a/src/layout/fullinter.less +++ b/src/layout/fullinter.less @@ -1,3 +1,4 @@ +// fullinter.less - 修复后的完整样式 @font-face { font-family: pangmenzhengdao; src: url('../assets/fonts/pangmenzhengdao.ttf'); @@ -16,6 +17,7 @@ font-display: swap; } +// 主容器 .box { transform-origin: 0 0; position: absolute; @@ -25,76 +27,72 @@ } .blackBack { - background-image: url('../assets/login/bg.png'); width: 100%; - // height: calc(100% - 10px); // 进入全屏 height: 100%; background-size: cover; background-position: center; background-repeat: no-repeat; } + .backImage { - background-color: #021428; //021428 + background-color: #f2f5f9; width: 100%; height: 100%; - opacity: 0.9; display: flex; flex-direction: column; overflow: hidden; } + +// 头部 .header { - // background-image: url('../assets/layout/full-header.png'); - // background-size: cover; - // background-position: center; - // background-repeat: no-repeat; height: 60px; display: flex; align-items: center; justify-content: space-between; flex-direction: row; margin: 10px; - background-color: rgba(73, 122, 175, 0.3); + background-color: #fff; + flex-shrink: 0; } + .headerText { - color: GoldenRod; + color: #000; font-size: 32px; white-space: nowrap; - // font-weight: bold; - // margin-top: 10px; - font-family: 'pangmenzhengdao'; + font-weight: bold; } + .configBanners { - // height: 100%; width: 110px; height: 48px; - font-size: 20px; // 适当减小字体大小 + font-size: 20px; margin: 0px 10px; font-style: italic; font-weight: bold; - color: #fff; - border: 1px solid transparent; // 默认透明边框 - // border: 1px solid #00caf7; + color: #000; + border: 1px solid transparent; white-space: nowrap; - background: linear-gradient(to bottom, #01408e, #07295e); - display: flex; // 使用flex布局 - align-items: center; // 垂直居中 - justify-content: center; // 水平居中 - text-align: center; // 文字居中 - box-sizing: border-box; // 确保边框计算在内 - padding: 0 2px; // 如果需要可以添加内边距 - overflow: hidden; // 防止内容溢出 - text-overflow: ellipsis; // 文字过长显示省略号 - position: relative; + background: #e3f2e9; + display: flex; + align-items: center; + justify-content: center; + text-align: center; + box-sizing: border-box; + padding: 0 2px; overflow: hidden; + text-overflow: ellipsis; + position: relative; + cursor: pointer; + &:hover { - border-color: #00caf7; // 悬停效果 + border-color: #00caf7; opacity: 0.9; } &.active { border: 1px solid #00caf7 !important; - background: linear-gradient(to bottom, #0150a0, #083070); // 激活时背景加深 - box-shadow: 0 0 10px rgba(0, 202, 247, 0.5); // 可选:添加发光效果 + background: linear-gradient(to bottom, #01408e, #07295e); + color: #fff; } &::after { @@ -116,6 +114,7 @@ animation: pulse 2s infinite; } } + @keyframes pulse { 0% { box-shadow: 0 0 5px rgba(0, 202, 247, 0.5); @@ -127,18 +126,10 @@ box-shadow: 0 0 5px rgba(0, 202, 247, 0.5); } } -.boxBack { - width: 100%; - height: 100%; - display: flex; - align-items: center; - flex-direction: column; - padding: 0px 20px; -} + +// 其他tab内容 .otherTabContent { - flex: 1; // 占据剩余空间 - // width: 100%; - height: 100%; + flex: 1; display: flex; align-items: center; justify-content: center; @@ -147,405 +138,455 @@ margin: 0px 10px 10px 10px; border: 1px solid rgba(0, 202, 247, 0.3); } -.row { - // height: calc(65% - 200px); + +// ========== HomeContent 组件样式 ========== +.homeContentWrapper { flex: 1; width: 100%; + overflow: hidden; + padding: 0 10px 10px 10px; + box-sizing: border-box; } -.rowTwo { - height: 30%; + +.homeContentRow { + height: 100%; width: 100%; +} + +// 左右列通用样式 +.leftCol, +.rightCol, +.middleCol { + height: 100%; + display: flex; + flex-direction: column; + overflow: hidden; +} + +// 左侧和右侧卡片样式 +.riskCard { + flex: 1; + background-color: #fff; + border-radius: 4px; + overflow: hidden; + min-height: 0; +} + +.hiddenCard { + flex: 1; + background-color: #fff; + border-radius: 4px; + overflow: hidden; margin-top: 10px; + min-height: 0; } -.boxleft { + +.dangerCard { + flex: 1; + background-color: #fff; + border-radius: 4px; + overflow: hidden; + min-height: 0; +} + +.spacer { + height: 10px; + flex-shrink: 0; +} + +.riskRow { height: 100%; - // width: 100%; + width: 100%; +} + +.riskStatsCol, +.hiddenStatsCol, +.trainingStatsCol { + height: 100%; + display: flex; + flex-direction: column; + justify-content: space-between; + padding: 10px 0; +} + +.chartCol { + height: 100%; + display: flex; + align-items: center; + justify-content: center; +} + +.chartContainer { + width: 100%; + height: 100%; + min-height: 0; +} + +.fullChartContainer { + width: 100%; + height: 100%; + min-height: 0; +} + +// 风险等级统计项 +.riskStatItem { display: flex; flex-direction: column; align-items: center; justify-content: center; -} -.fullBorderBox { - width: 100%; - height: 100%; - display: flex; - align-items: center; - justify-content: center; - padding: 10px; // 如果需要内边距 - box-sizing: border-box; // 确保内边距计算在内 -} -.risklevel { - height: 50%; - width: 100%; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - padding: 0px 10px; -} -.risklevelOne { - height: 50%; - width: 100%; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - padding: 0px 10px; -} -.risklevelTwo { - height: 100%; - width: 100%; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - padding: 0px 10px 10px 10px; -} -.riskChange { - width: 30%; - height: 100%; - display: flex; - flex-direction: column; - align-items: center; - justify-content: space-around; - padding: 20px 10px; -} -.riskChangeTwo { - width: 70%; - height: 100%; - padding: 26px 10px; - display: flex; - align-items: center; - justify-content: flex-start; -} -.gradient { - background-image: linear-gradient( - 250deg, - rgba(47, 109, 255, 1) 0%, - rgba(255, 255, 255, 54) 50%, - rgba(47, 109, 255, 1) 100% - ); - width: 100%; - height: 30%; - display: flex; - align-items: center; - justify-content: center; - padding: 2px; - // margin: 10px; -} -.gradientTwo { - background-image: linear-gradient( - 250deg, - rgba(47, 109, 255, 1) 0%, - rgba(255, 255, 255, 54) 50%, - rgba(47, 109, 255, 1) 100% - ); - width: 100%; - height: 100%; - display: flex; - align-items: center; - justify-content: space-around; - padding: 2px; -} -.gradientThree { - background-image: linear-gradient( - 275deg, - rgba(47, 109, 255, 1) 0%, - rgba(255, 255, 255, 54) 50%, - rgba(47, 109, 255, 1) 100% - ); - display: flex; - align-items: center; - justify-content: space-around; - padding: 2px; -} -.gradientNext { - width: 100%; - height: 100%; - background-color: #021428; - // z-index: 999; -} -.gradientNextTwo { - width: 100%; - height: 100%; - background-color: rgba(47, 109, 255, 0.1); - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - padding: 5px; - color: #fff; -} -.gradientText { - font-size: 34px; font-weight: bold; - color: #49ebff; - font-style: italic; - font-family: '站酷庆科黄油体'; -} -.gradientName { - font-size: 12px; -} -.gradientTextTwo { - font-size: 86px; - font-weight: bold; - // color: #ef595a; - color: #12f714; -} -.gradientNameTwo { - font-size: 28px; -} -.title { - background-image: url('../assets/layout/title.png'); - background-size: cover; - background-position: bottom; - background-repeat: no-repeat; - width: 90%; - height: 25px; - padding-bottom: 10px; - display: flex; - flex-direction: row; - align-items: center; - // justify-content: center; -} -.circle { - width: 12px; - height: 12px; - background: #021428; - border-radius: 50%; - border: 3px solid #fff; - margin-right: 5px; -} -.titlename { color: #fff; - font-size: 16px; - font-family: '站酷庆科黄油体'; - letter-spacing: 3px; -} -// .risklevelOne { -// height: 60%; -// width: 90%; -// } -.boxTwo { - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - height: 100%; - // width: 100%; -} -.capsuleChart { - width: 100%; - height: 100%; - display: flex; - align-items: flex-start; - justify-content: center; - flex-direction: column; - padding: 20px; -} -.scrollboard { - width: 90%; - height: 100%; - display: flex; - align-items: center; - justify-content: center; - margin: 0px 20px 20px 20px; + margin: 10px 20px; + padding: 5px 10px; + border-radius: 4px; flex: 1; } -.scrollboard :global(.header) { - height: auto; + +.riskStatName { + margin-bottom: 5px; + font-size: 16px; +} + +.riskStatValue { + font-size: 26px; +} + +// 风险等级背景色 +.riskLevel重大风险 { + background-color: #c92a2a; +} +.riskLevel较大风险 { + background-color: #ffa94d; +} +.riskLevel一般风险 { + background-color: #ffe066; +} +.riskLevel低风险 { + background-color: #4285f4; +} + +// 隐患统计样式 +.hiddenTitle { + color: #000; + font-size: 16px; + margin: 10px 0; + font-weight: bold; + text-align: center; +} + +.hiddenStatItem { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + font-weight: bold; + color: #fff; + background-color: #1e2a3a; + margin: 10px 20px; + padding: 5px 10px; + border-radius: 4px; + flex: 1; +} + +.hiddenStatName { + margin-bottom: 5px; + font-size: 14px; +} + +.hiddenStatValue { + font-size: 36px; +} + +// 培训统计样式 +.trainingTitle { + color: #000; + font-size: 16px; + margin: 10px 0; + font-weight: bold; + text-align: center; +} + +.trainingStatItem { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + font-weight: bold; + color: #fff; + background-color: #1e2a3a; + margin: 10px 20px; + padding: 5px 10px; + border-radius: 4px; + flex: 1; +} + +.trainingStatName { + margin-bottom: 5px; + font-size: 14px; +} + +.trainingStatValue { + font-size: 36px; +} + +// 中间区域样式 +.middleCol { + padding: 0 10px; +} + +.sloganCard { + background-color: #fff; + border-radius: 4px; + padding: 15px; + text-align: center; + flex-shrink: 0; +} + +.sloganText { + font-size: 20px; + font-weight: bold; + margin-bottom: 8px; + color: #000; +} + +.sloganSubText { + font-size: 20px; + font-weight: bold; + color: #000; +} + +.carouselCard { + flex: 4; + background-color: #fff; + border-radius: 4px; + margin-top: 10px; + overflow: hidden; + min-height: 0; +} + +.carouselWrapper { + position: relative; + width: 100%; + height: 100%; +} + +.carousel { + width: 100%; + height: 100%; +} + +.carouselItem { + width: 100%; + height: 100%; +} + +.mediaVideo { + width: 100%; + height: 100%; + object-fit: cover; +} + +.mediaImage { + width: 100%; + height: 100%; + object-fit: cover; +} + +.announcementCard { + flex: 3; + background-color: #fff; + border-radius: 4px; + margin-top: 10px; + display: flex; + flex-direction: column; + overflow: hidden; + min-height: 0; +} + +.announcementHeader { + width: 100%; + padding: 12px 16px; + border-bottom: 2px solid #1890ff; + display: flex; + align-items: center; + justify-content: space-between; + flex-shrink: 0; +} + +.announcementTitle { + display: flex; + align-items: center; +} + +.announcementIcon { + font-size: 20px; + color: #1890ff; + margin-right: 8px; +} + +.announcementTitle span { + font-size: 20px; + font-weight: bold; + color: #1890ff; +} + +.announcementCount { + font-size: 14px; + color: #999; +} + +.announcementList { + flex: 1; + overflow-y: auto; + padding: 8px 0; +} + +.announcementUl { + list-style: none; + margin: 0; padding: 0; } -.scrollboard :global(.dv-scroll-board .rows .ceil) { - text-align: center; -} -.scrollboard :global(.dv-scroll-board .header .header-item) { - text-align: center; + +.announcementItem { + display: flex; + align-items: center; + justify-content: space-between; + padding: 10px 16px; + border-bottom: 1px solid #f0f0f0; + cursor: pointer; + transition: background-color 0.3s; + + &:hover { + background-color: #f5f5f5; + } } -.scoreBox { - // background-image: url("../assets/layout/score-box.png"); - // background-size: cover; - // background-position: center; - // background-repeat: no-repeat; - width: 100%; - display: flex; - flex-direction: row; - align-items: center; - justify-content: space-between; - margin-bottom: 20px; +.announcementItemTitle { + font-size: 18px; + color: #333; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + flex: 1; + text-align: left; } -.scoreBox1 { - background-image: url('../assets/layout/score-box.png'); - background-size: contain; - background-position: center; - background-repeat: no-repeat; - width: 100%; - // height: 140px; - display: flex; - flex-direction: row; - align-items: center; - justify-content: space-around; - margin-bottom: 20px; - padding: 5px; + +.announcementItemTime { + font-size: 16px; + color: #999; + margin-left: 16px; + white-space: nowrap; } -.score { - display: flex; - flex-direction: row; - // align-items: center; - // justify-content: space-between; - background-image: url('../assets/layout/ks.png'); - background-size: cover; - background-position: center; - background-repeat: no-repeat; - object-fit: cover; - // width: 230px; - width: 33%; - height: auto; - margin: 10px; -} -.score2 { - display: flex; - flex-direction: row; - // align-items: center; - // justify-content: space-between; - background-image: url('../assets/layout/xk.png'); - background-size: cover; - background-position: center; - background-repeat: no-repeat; - object-fit: cover; - width: 33%; - height: auto; - margin: 10px; -} -.score3 { - display: flex; - flex-direction: row; - // align-items: center; - // justify-content: space-between; - background-image: url('../assets/layout/wk.png'); - background-size: cover; - background-position: center; - background-repeat: no-repeat; - object-fit: cover; - width: 33%; - height: auto; - margin: 10px; -} -.score4 { - display: flex; - flex-direction: column; - align-items: center; - justify-content: space-between; - background-image: url('../assets/layout/score.png'); - background-size: contain; - background-position: center; - background-repeat: no-repeat; - width: 30%; - padding: 0px 15px; - // height: 100%; - // margin: 10px; -} -.scoreRight { + +.emptyAnnouncement { display: flex; flex-direction: column; align-items: center; justify-content: center; - width: 40%; - margin-left: 50%; -} -.scoreLeft { - font-size: 12px; - font-weight: bold; - color: #6cc8d9; - margin-top: 5px; -} -.scoreText { - font-size: 13px; - font-weight: bold; - color: #6cc8d9; -} -.scoreText2 { - font-size: 33px; - color: #7fffff; - font-weight: bold; - // font-style: oblique; -} -.scoreText3 { - font-size: 12px; - color: #6cc8d9; - font-weight: bold; -} -.ulData { - li { - // transform: rotate(45deg); - position: absolute; - left: 50%; - top: 50%; - // margin-left: -20px; - // margin-right: -20px; - transform: translate(-50%, -50%); - } - li:nth-of-type(1) { - // transform: rotate(45deg); - transform: translate(-50%, -50%) rotate(12deg) translate(-280px) rotate(-12deg); - // transform-origin: 20px 220px; - } - li:nth-of-type(2) { - transform: translate(-50%, -50%) rotate(38deg) translate(-280px) rotate(-38deg); - } - li:nth-of-type(3) { - transform: translate(-50%, -50%) rotate(64deg) translate(-280px) rotate(-64deg); - } - li:nth-of-type(4) { - transform: translate(-50%, -50%) rotate(90deg) translate(-280px) rotate(-90deg); - } - li:nth-of-type(5) { - transform: translate(-50%, -50%) rotate(116deg) translate(-280px) rotate(-116deg); - } - li:nth-of-type(6) { - transform: translate(-50%, -50%) rotate(142deg) translate(-280px) rotate(-142deg); - } - li:nth-of-type(7) { - transform: translate(-50%, -50%) rotate(168deg) translate(-280px) rotate(-168deg); - } - li:nth-of-type(8) { - transform: translate(-50%, -50%) rotate(-12deg) translate(-280px) rotate(12deg); - } - li:nth-of-type(9) { - transform: translate(-50%, -50%) rotate(-38deg) translate(-280px) rotate(38deg); - } - li:nth-of-type(10) { - transform: translate(-50%, -50%) rotate(-64deg) translate(-280px) rotate(64deg); - } - li:nth-of-type(11) { - transform: translate(-50%, -50%) rotate(-116deg) translate(-280px) rotate(116deg); - } - - li:nth-of-type(12) { - transform: translate(-50%, -50%) rotate(-142deg) translate(-280px) rotate(142deg); - } - li:nth-of-type(13) { - transform: translate(-50%, -50%) rotate(-168deg) translate(-280px) rotate(168deg); - } + height: 100%; + color: #999; } -.roateData { - background-image: linear-gradient( - 275deg, - rgba(47, 109, 255, 1) 0%, - rgba(255, 255, 255, 54) 50%, - rgba(47, 109, 255, 1) 100% - ); +.emptyIcon { + font-size: 48px; + margin-bottom: 16px; +} + +// 轮播图控件 +.customArrowLeft, +.customArrowRight { + position: absolute; + top: 50%; + transform: translateY(-50%); + width: 40px; + height: 60px; display: flex; align-items: center; - justify-content: space-around; - padding: 2px; - // background-color: rgba(47, 109, 255, 0.1); + justify-content: center; + cursor: pointer; + z-index: 10; + transition: all 0.3s ease; + backdrop-filter: blur(4px); + + &:hover { + background-color: rgba(0, 0, 0, 0.3); + transform: translateY(-50%) scale(1.1); + } + + &:active { + transform: translateY(-50%) scale(0.95); + } } -.roatBack { - background-color: #021428; - width: 100%; - height: 100%; - padding: 5px; + +.customArrowLeft { + left: 20px; +} + +.customArrowRight { + right: 20px; +} + +.customDots { + position: absolute; + bottom: 16px; + left: 0; + right: 0; + display: flex; + justify-content: center; + align-items: center; + gap: 12px; + z-index: 10; +} + +.dot { + width: 24px; + height: 6px; + border-radius: 5px; + background-color: rgba(255, 255, 255, 0.5); + cursor: pointer; + transition: all 0.3s ease; + + &:hover { + background-color: rgba(255, 255, 255, 0.8); + transform: scale(1.2); + } +} + +.activeDot { + width: 24px; + border-radius: 5px; + background-color: rgba(255, 255, 255, 0.8); +} + +// 全局 Carousel 样式 +:global { + .ant-carousel { + height: 100%; + width: 100%; + } + .slick-slider { + height: 100%; + width: 100%; + } + .slick-list { + height: 100%; + } + .slick-track { + height: 100%; + } + .slick-slider > div, + .slick-list > div, + .slick-track > div, + .slick-slide > div { + height: 100%; + } + .slick-slide, + .slick-slide > div { + height: 100%; + } + .slick-slider div, + .slick-list div, + .slick-track div { + height: 100%; + } }