Косметические изменения и удаление лишнего кода

This commit is contained in:
goodmice 2022-04-29 16:39:49 +05:00
parent 9e8648d33e
commit dd2315d53e
6 changed files with 47 additions and 35 deletions

View File

@ -1,9 +0,0 @@
# Вопрос Олегу: Какой бит и в каком регистре (или значение регистра) контроллера спинмастера сигнализирует что система спинмастер активана/работает?
Ответ: Такого бита нет, но можно понять если etap %MW1600: INT; не равен 6 и не равен 0 тогда система в работе
# Вопрос Олегу: Какой бит и в каком регистре (или значение регистра) контроллера спинмастера сигнализирует что система стабилизации крутящего момента активна/работает?
Ответ: Такого бита по сути тоже нет но можно понять что
когда stik_sleep %MX2802.01: BOOL; =true
и
etap %MW1600: INT; =7
тогда торк мастер работает

View File

@ -1,19 +1,33 @@
import moment from 'moment' import moment from 'moment'
import { useState, useEffect, memo } from 'react' import { useState, useEffect, memo, ReactNode } from 'react'
import {CaretUpOutlined, CaretDownOutlined, CaretRightOutlined} from '@ant-design/icons' import {CaretUpOutlined, CaretDownOutlined, CaretRightOutlined} from '@ant-design/icons'
import '@styles/display.css' import '@styles/display.css'
export const formatNumber = (value, format) => export const formatNumber = (value?: unknown, format?: number) =>
Number.isInteger(format) && Number.isFinite(value) Number.isInteger(format) && Number.isFinite(value)
? (+value).toFixed(format) ? Number(value).toFixed(format)
: (+value).toPrecision(4) : Number(value).toPrecision(4)
const iconStyle = { color:'#0008' } const iconStyle = { color:'#0008' }
const displayValueStyle = { display: 'flex', flexGrow: 1 } const displayValueStyle = { display: 'flex', flexGrow: 1 }
export const ValueDisplay = ({ prefix, value, suffix, isArrowVisible, format, enumeration }) => { export type ValueDisplayProps = {
const [val, setVal] = useState('---') prefix?: ReactNode
suffix?: ReactNode
format?: number | string
isArrowVisible?: boolean
enumeration?: Record<string, string>
value: string
}
export type DisplayProps = ValueDisplayProps & {
className?: string
label?: ReactNode
}
export const ValueDisplay = memo<ValueDisplayProps>(({ prefix, value, suffix, isArrowVisible, format, enumeration }) => {
const [val, setVal] = useState<string>('---')
const [arrowState, setArrowState] = useState({ const [arrowState, setArrowState] = useState({
preVal: NaN, preVal: NaN,
preTimestamp: Date.now(), preTimestamp: Date.now(),
@ -28,25 +42,25 @@ export const ValueDisplay = ({ prefix, value, suffix, isArrowVisible, format, en
if (Number.isFinite(+value)) { if (Number.isFinite(+value)) {
if (isArrowVisible && (arrowState.preTimestamp + 1000 < Date.now())) { if (isArrowVisible && (arrowState.preTimestamp + 1000 < Date.now())) {
let direction = 0 let direction = 0
if (value > arrowState.preVal) if (+value > arrowState.preVal)
direction = 1 direction = 1
if (value < arrowState.preVal) if (+value < arrowState.preVal)
direction = -1 direction = -1
setArrowState({ setArrowState({
preVal: value, preVal: +value,
preTimestamp: Date.now(), preTimestamp: Date.now(),
direction: direction, direction: direction,
}) })
} }
return formatNumber(value, format) return formatNumber(value, Number(format))
} }
if (value.length > 4) { if (value.length > 4) {
const valueDate = moment(value) const valueDate = moment(value)
if (valueDate.isValid()) if (valueDate.isValid())
return valueDate.format(format) return valueDate.format(String(format))
} }
return value return value
@ -74,9 +88,9 @@ export const ValueDisplay = ({ prefix, value, suffix, isArrowVisible, format, en
{prefix} {val} {suffix}{arrow} {prefix} {val} {suffix}{arrow}
</span> </span>
) )
} })
export const Display = memo(({ className, label, ...other })=> ( export const Display = memo<DisplayProps>(({ className, label, ...other })=> (
<div className={className}> <div className={className}>
<div className={'display_label'}>{label}</div> <div className={'display_label'}>{label}</div>
<div style={displayValueStyle}> <div style={displayValueStyle}>

View File

@ -1,5 +1,7 @@
export class ErrorFetch extends Error { export class ErrorFetch extends Error {
constructor(status, message) { public status: number
constructor(status: number, message?: string) {
super(message) super(message)
this.name = 'ErrorFetch' this.name = 'ErrorFetch'
this.status = status this.status = status

View File

@ -1,22 +1,35 @@
import { memo, useCallback, useState } from 'react' import { memo, useCallback, useState } from 'react'
import { Upload, Button } from 'antd' import { Upload, Button } from 'antd'
import { UploadOutlined } from '@ant-design/icons' import { UploadOutlined } from '@ant-design/icons'
import { UploadFile } from 'antd/lib/upload/interface'
import { upload } from './factory' import { upload } from './factory'
import { ErrorFetch } from './ErrorFetch' import { ErrorFetch } from './ErrorFetch'
export const UploadForm = memo(({ url, disabled, accept, style, formData, onUploadStart, onUploadSuccess, onUploadComplete, onUploadError }) => { export type UploadFormProps = {
const [fileList, setfileList] = useState([]) url: string
disabled?: boolean
accept?: string
style?: CSSStyleSheet
formData: FormData
onUploadStart?: () => void
onUploadSuccess?: () => void
onUploadComplete?: () => void
onUploadError?: (error: unknown) => void
}
export const UploadForm = memo<UploadFormProps>(({ url, disabled, accept, style, formData, onUploadStart, onUploadSuccess, onUploadComplete, onUploadError }) => {
const [fileList, setfileList] = useState<UploadFile<any>[]>([])
const handleFileSend = useCallback(async () => { const handleFileSend = useCallback(async () => {
onUploadStart?.() onUploadStart?.()
try { try {
const formDataLocal = new FormData() const formDataLocal = new FormData()
fileList.forEach((val) => formDataLocal.append('files', val.originFileObj)) fileList.forEach((val) => formDataLocal.append('files', String(val.originFileObj)))
if(formData) if(formData)
for(const propName in formData) for(const propName in formData)
formDataLocal.append(propName, formData[propName]) formDataLocal.append(propName, String(formData.get(propName)))
const response = await upload(url, formDataLocal) const response = await upload(url, formDataLocal)
if (!response.ok) { if (!response.ok) {

View File

@ -1,5 +0,0 @@
import {createContext} from 'react'
const Context = createContext()
export default Context

View File

@ -19,7 +19,6 @@ import Documents from './Documents'
import Telemetry from './Telemetry' import Telemetry from './Telemetry'
import WellOperations from './WellOperations' import WellOperations from './WellOperations'
import DrillingProgram from './DrillingProgram' import DrillingProgram from './DrillingProgram'
import TelemetryAnalysis from './TelemetryAnalysis'
import '@styles/index.css' import '@styles/index.css'
@ -38,7 +37,6 @@ export const Well = memo(() => {
<PrivateMenu.Link key={'report'} icon={<FilePdfOutlined />} title={'Рапорт'} /> <PrivateMenu.Link key={'report'} icon={<FilePdfOutlined />} title={'Рапорт'} />
<PrivateMenu.Link key={'analytics'} icon={<DeploymentUnitOutlined />} title={'Аналитика'} /> <PrivateMenu.Link key={'analytics'} icon={<DeploymentUnitOutlined />} title={'Аналитика'} />
<PrivateMenu.Link key={'operations'} icon={<FolderOutlined />} title={'Операции по скважине'} /> <PrivateMenu.Link key={'operations'} icon={<FolderOutlined />} title={'Операции по скважине'} />
{/* <PrivateMenu.Link key={'telemetryAnalysis'} icon={<FundProjectionScreenOutlined />} title={'Операции по телеметрии'} /> */}
<PrivateMenu.Link key={'document'} icon={<FolderOutlined />} title={'Документы'} /> <PrivateMenu.Link key={'document'} icon={<FolderOutlined />} title={'Документы'} />
<PrivateMenu.Link key={'measure'} icon={<ExperimentOutlined />} title={'Измерения'} /> <PrivateMenu.Link key={'measure'} icon={<ExperimentOutlined />} title={'Измерения'} />
<PrivateMenu.Link key={'drillingProgram'} icon={<FolderOutlined />} title={'Программа бурения'} /> <PrivateMenu.Link key={'drillingProgram'} icon={<FolderOutlined />} title={'Программа бурения'} />
@ -52,7 +50,6 @@ export const Well = memo(() => {
<Report key={'report'} /> <Report key={'report'} />
<Analytics key={'analytics/:tab?'} /> <Analytics key={'analytics/:tab?'} />
<WellOperations key={'operations/:tab?'} /> <WellOperations key={'operations/:tab?'} />
<TelemetryAnalysis key={'telemetryAnalysis/:tab?'} />
<Documents key={'document/:category?'} /> <Documents key={'document/:category?'} />
<Measure key={'measure'} /> <Measure key={'measure'} />
<DrillingProgram key={'drillingProgram'} /> <DrillingProgram key={'drillingProgram'} />