Commit f38802ff authored by 陈龙's avatar 陈龙

feat: 提交AssemblyScroll变更

parent e0af2891
...@@ -13,6 +13,7 @@ import 'swiper/swiper.min.css'; ...@@ -13,6 +13,7 @@ import 'swiper/swiper.min.css';
import 'swiper/components/pagination/pagination.min.css'; import 'swiper/components/pagination/pagination.min.css';
import 'swiper/components/navigation/navigation.min.css'; import 'swiper/components/navigation/navigation.min.css';
import SwiperCore, {Autoplay, Pagination, Navigation} from 'swiper/core'; import SwiperCore, {Autoplay, Pagination, Navigation} from 'swiper/core';
import {isFunction, isString} from "../../BasicReport/src/ReportsManage/utils/utils";
SwiperCore.use([Autoplay, Pagination, Navigation]); SwiperCore.use([Autoplay, Pagination, Navigation]);
/* /*
...@@ -95,65 +96,72 @@ const AlarmScrollAssembly = (props) => { ...@@ -95,65 +96,72 @@ const AlarmScrollAssembly = (props) => {
}, []); }, []);
return ( return (
<> <>
{realTimeDataList && realTimeDataList.length ? <div {realTimeDataList && realTimeDataList.length ? <>
className={classnames(styles.alarScrollAssembly, (realTimeDataList?.length > 1000 ? styles.moreThan1000 : styles.lessThan1000))} {
id={'alarmListDiv'}> props.prefix ? <span>{props.prefix}</span> : ''
<Swiper }
slidesPerView={1} <div
modules={[Pagination]} className={classnames(styles.alarScrollAssembly, (realTimeDataList?.length > 1000 ? styles.moreThan1000 : styles.lessThan1000))}
pagination={{ id={'alarmListDiv'}>
type: 'fraction', <Swiper
formatFractionCurrent: (num) => `第${num}条`, slidesPerView={1}
formatFractionTotal: (num) => `共${num}条`, modules={[Pagination]}
}} pagination={{
navigation type: 'fraction',
autoplay={{ formatFractionCurrent: (num) => `第${num}条`,
delay: 3000, formatFractionTotal: (num) => `共${num}条`,
disableOnInteraction: false, }}
}} navigation
loop autoplay={{
direction="vertical" delay: 3000,
onSlideChange={(e) => { disableOnInteraction: false,
if (e.activeIndex === realTimeDataList.length - 1) getData(); }}
}} loop
> direction="vertical"
{realTimeDataList.map((item, index) => { onSlideChange={(e) => {
return ( if (e.activeIndex === realTimeDataList.length - 1) getData();
<SwiperSlide }}
key={index}
virtualIndex={index}
onClick={() => {
setCurrentInfo(item);
setModalVisible(true);
}}
>
<InfoItem key={index} info={item}/>
</SwiperSlide>
);
})}
</Swiper>
{modalVisible && (
<Modal
visible={modalVisible}
onCancel={() => setModalVisible(false)}
width={'80%'}
destroyOnClose
> >
<NormChart {realTimeDataList.map((item, index) => {
info={currentInfo} return (
deviceType={currentInfo.deviceType} <SwiperSlide
deviceCode={currentInfo.stationCode} key={index}
/> virtualIndex={index}
</Modal> onClick={() => {
)} setCurrentInfo(item);
</div> : ''} setModalVisible(true);
}}
>
<InfoItem key={index} info={item}/>
</SwiperSlide>
);
})}
</Swiper>
{modalVisible && (
<Modal
visible={modalVisible}
onCancel={() => setModalVisible(false)}
width={'80%'}
destroyOnClose
>
<NormChart
info={currentInfo}
deviceType={currentInfo.deviceType}
deviceCode={currentInfo.stationCode}
/>
</Modal>
)}
</div>
</> : ''}
</> </>
); );
}; };
AlarmScrollAssembly.defaultProps = { AlarmScrollAssembly.defaultProps = {
deviceType: '二供泵房,二供机组', deviceType: '二供泵房,二供机组',
prefix: ''
}; };
AlarmScrollAssembly.propTypes = { AlarmScrollAssembly.propTypes = {
deviceType: PropTypes.string, deviceType: PropTypes.string,
prefix: PropTypes.string
}; };
export default AlarmScrollAssembly; export default AlarmScrollAssembly;
const isObject = (obj) => { const isObject = (obj) => {
return Object.prototype.toString.call(obj) === '[object Object]'; return Object.prototype.toString.call(obj) === '[object Object]';
}; };
const isString = (obj) => { const isString = (obj) => {
return Object.prototype.toString.call(obj) === '[object String]'; return Object.prototype.toString.call(obj) === '[object String]';
}; };
const isNumber = (num) => { const isNumber = (num) => {
return Object.prototype.toString.call(num) === '[object Number]'; return Object.prototype.toString.call(num) === '[object Number]';
}; };
const isArray = (arr) => { const isArray = (arr) => {
return Object.prototype.toString.call(arr) === '[object Array]'; return Object.prototype.toString.call(arr) === '[object Array]';
}; };
const isFunction = (obj) => {
return Object.prototype.toString.call(obj) === '[object Function]';
}
const hasMoney = (configItems) => { const hasMoney = (configItems) => {
if (!configItems) return false; if (!configItems) return false;
let _items = configItems.split('|'); let _items = configItems.split('|');
return !!_items.find((item) => item === '金额'); return !!_items.find((item) => item === '金额');
}; };
const isSelect = (configItems) => { const isSelect = (configItems) => {
if (!configItems) return false; if (!configItems) return false;
let _items = configItems.split('|'); let _items = configItems.split('|');
return !!_items.find((item) => item === 'renderAsSelect'); return !!_items.find((item) => item === 'renderAsSelect');
}; };
// options=name1[.value1],name2[.value2],name3[.value3]; // options=name1[.value1],name2[.value2],name3[.value3];
const returnOptions = (configItems) => { const returnOptions = (configItems) => {
if (!configItems) return false; if (!configItems) return false;
let _items = configItems.split('|'); let _items = configItems.split('|');
let _options = _items.find((item) => item.includes('options=')); let _options = _items.find((item) => item.includes('options='));
if (!_options) return false; if (!_options) return false;
return _options.replace('options=', '').split(','); return _options.replace('options=', '').split(',');
}; };
const returnRows = (configItems) => { const returnRows = (configItems) => {
if (!configItems) return 3; if (!configItems) return 3;
let _items = configItems.split('|'); let _items = configItems.split('|');
let _options = _items.find((item) => item.includes('rows=')); let _options = _items.find((item) => item.includes('rows='));
if (!_options) return 3; if (!_options) return 3;
let _rows = Number(_options.replace('rows=', '')); let _rows = Number(_options.replace('rows=', ''));
return !isNaN(_rows) && _rows >= 1 ? _rows : 3; return !isNaN(_rows) && _rows >= 1 ? _rows : 3;
}; };
const returnCols = (configItems) => { const returnCols = (configItems) => {
if (!configItems) return 1; if (!configItems) return 1;
let _items = configItems.split('|'); let _items = configItems.split('|');
let _options = _items.find((item) => item.includes('cols=')); let _options = _items.find((item) => item.includes('cols='));
if (!_options) return 1; if (!_options) return 1;
let _cols = Number(_options.replace('cols=', '')); let _cols = Number(_options.replace('cols=', ''));
return !isNaN(_cols) && _cols <= 3 && _cols >= 0 ? _cols : 1; return !isNaN(_cols) && _cols <= 3 && _cols >= 0 ? _cols : 1;
}; };
/** /**
* @description: 用来在summary中处理数值的配置 * @description: 用来在summary中处理数值的配置
...@@ -51,36 +54,36 @@ const returnCols = (configItems) => { ...@@ -51,36 +54,36 @@ const returnCols = (configItems) => {
* @author: ChenLong * @author: ChenLong
*/ */
const returnHandledNumber = (configItems, num, isSummary) => { const returnHandledNumber = (configItems, num, isSummary) => {
// 精度、前缀、后缀、倍率 // 精度、前缀、后缀、倍率
// $_d|_d%|_d*0.0001|金额|0.00 // $_d|_d%|_d*0.0001|金额|0.00
if (isNaN(num)) return '-'; if (isNaN(num)) return '-';
if (!configItems) return num; if (!configItems) return num;
num = Number(num); num = Number(num);
let _items = configItems.split('|'); let _items = configItems.split('|');
/* let prefix = ''; /* let prefix = '';
let suffix = '';*/ let suffix = '';*/
let template = '_d'; let template = '_d';
let precision = 0; let precision = 0;
let rate = 1; let rate = 1;
_items.forEach((item) => { _items.forEach((item) => {
let _arr = []; let _arr = [];
if (item.match(/_d[^\*]/)) { if (item.match(/_d[^\*]/)) {
// 后缀 // 后缀
template = item; template = item;
} else if (item.match(/^_d\*/)) { } else if (item.match(/^_d\*/)) {
// 倍率 // 倍率
let _rate = item.replace(/_d\*/, ''); let _rate = item.replace(/_d\*/, '');
rate = _rate && isSummary ? Number(_rate) : 1; // 总结栏计算需要计算倍率,其他不用 rate = _rate && isSummary ? Number(_rate) : 1; // 总结栏计算需要计算倍率,其他不用
} else if (item.match(/^0\./)) { } else if (item.match(/^0\./)) {
// 精度 // 精度
precision = item.replace('0.', '').length; precision = item.replace('0.', '').length;
} }
}); });
// 可能存在NaN的问题 // 可能存在NaN的问题
let final = _items.includes('金额') let final = _items.includes('金额')
? Number((num * rate).toFixed(precision)).toLocaleString() ? Number((num * rate).toFixed(precision)).toLocaleString()
: Number((num * rate).toFixed(precision)).toLocaleString(); : Number((num * rate).toFixed(precision)).toLocaleString();
return template.replace(/_d/, isString(final) ? final : '-'); return template.replace(/_d/, isString(final) ? final : '-');
}; };
/** /**
* @description: 返回configItems内配置的默认值、默认模式等等 * @description: 返回configItems内配置的默认值、默认模式等等
...@@ -100,21 +103,21 @@ const returnHandledNumber = (configItems, num, isSummary) => { ...@@ -100,21 +103,21 @@ const returnHandledNumber = (configItems, num, isSummary) => {
* defaultDateValue 时间参数 默认时间 * defaultDateValue 时间参数 默认时间
*/ */
const returnDefaultValueOrConfigs = (configItems = '', keysArray = []) => { const returnDefaultValueOrConfigs = (configItems = '', keysArray = []) => {
let _map = {}; let _map = {};
let _configItemsArray = configItems.split('|'); let _configItemsArray = configItems.split('|');
keysArray.forEach((key) => { keysArray.forEach((key) => {
_map[key] = _configItemsArray.find((item) => item.includes(`${key}=`))?.replace(`${key}=`, ''); _map[key] = _configItemsArray.find((item) => item.includes(`${key}=`))?.replace(`${key}=`, '');
}); });
return _map; return _map;
}; };
function downloadFunc(url, name, target = '_self') { function downloadFunc(url, name, target = '_self') {
const a = document.createElement('a'); const a = document.createElement('a');
a.href = url; a.href = url;
a.target = target; a.target = target;
a.download = name; a.download = name;
a.click(); a.click();
a.remove(); a.remove();
} }
/** /**
...@@ -125,35 +128,36 @@ function downloadFunc(url, name, target = '_self') { ...@@ -125,35 +128,36 @@ function downloadFunc(url, name, target = '_self') {
* @returns {Object} {type: error | success ,content: 提示...} * @returns {Object} {type: error | success ,content: 提示...}
*/ */
function filenameVerification(file, special) { function filenameVerification(file, special) {
// 文件名含有特殊字符 提示不能上传 {+,:/?#[]@!$&\\*+;=} // 文件名含有特殊字符 提示不能上传 {+,:/?#[]@!$&\\*+;=}
// 规则对象(flag) // 规则对象(flag)
var flag = !special var flag = !special
? new RegExp("[`~!@#$^&*=|{}':;',\\[\\]/?~!@#¥&*——|{}【】‘;:”“'。,、?]") ? new RegExp("[`~!@#$^&*=|{}':;',\\[\\]/?~!@#¥&*——|{}【】‘;:”“'。,、?]")
: new RegExp("[`~!@#$^&*=|{}':;',[\\]?~!@#¥&*——|{}【】‘;:”“'。,、?]"); : new RegExp("[`~!@#$^&*=|{}':;',[\\]?~!@#¥&*——|{}【】‘;:”“'。,、?]");
if (flag.test(file.name)) { if (flag.test(file.name)) {
return {
type: 'error',
content: `文件名格式错误,请检查文件名是否含有特殊字符${"~!@#$^&*=|{}':;',\\[\\]/?~!@#¥&*——|{}【】‘;:”“'。,、?"}`,
};
}
return { return {
type: 'error', type: 'success',
content: `文件名格式错误,请检查文件名是否含有特殊字符${"~!@#$^&*=|{}':;',\\[\\]/?~!@#¥&*——|{}【】‘;:”“'。,、?"}`, content: `上传成功!`,
}; };
}
return {
type: 'success',
content: `上传成功!`,
};
} }
export { export {
isObject, isObject,
isString, isString,
isNumber, isNumber,
hasMoney, hasMoney,
isArray, isArray,
returnHandledNumber, isFunction,
returnDefaultValueOrConfigs, returnHandledNumber,
downloadFunc, returnDefaultValueOrConfigs,
filenameVerification, downloadFunc,
isSelect, filenameVerification,
returnOptions, isSelect,
returnRows, returnOptions,
returnCols, returnRows,
returnCols,
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment