#
luxiaotao1123
2024-03-08 a554a78015cb8bd0b9f1e65a4ac478b42f73f5f9
zy-asrs-flow/src/pages/map/components/settings.jsx
@@ -1,10 +1,11 @@
import React, { useState, useRef, useEffect } from 'react';
import moment from 'moment';
import { Col, Form, Input, Row, Checkbox, Slider, Select, Drawer, Space, Button, InputNumber, Switch } from 'antd';
import { FormattedMessage, useIntl, useModel } from '@umijs/max';
import * as PIXI from 'pixi.js';
import { createStyles } from 'antd-style';
import './index.css';
import * as Utils from '../utils'
import * as PIXI from 'pixi.js';
import moment from 'moment';
import Http from '@/utils/http';
const useStyles = createStyles(({ token, css }) => {
@@ -23,9 +24,16 @@
    useEffect(() => {
        form.resetFields();
        form.setFieldsValue({
            ...props.values
        })
        if (curSprite) {
            form.setFieldsValue({
                x: curSprite.position.x,
                y: curSprite.position.y,
                scale: Math.max(curSprite.scale.x, curSprite.scale.y),
                scaleSlider: Math.max(curSprite.scale.x, curSprite.scale.y),
                rotation: curSprite.rotation * 180 / Math.PI,
                rotationSlider: curSprite.rotation * 180 / Math.PI,
            })
        }
    }, [form, props])
    const handleCancel = () => {
@@ -37,7 +45,6 @@
    }
    const handleFinish = async (values) => {
        console.log(values); return
        props.onSubmit({ ...values });
    }
@@ -47,19 +54,41 @@
                const { name: nameList, value } = change;
                nameList.forEach(name => {
                    switch (name) {
                        case 'slider':
                            form.setFieldsValue({
                                no: value
                            })
                        case 'x':
                            curSprite.position.x = value;
                            break;
                        case 'no':
                        case 'y':
                            curSprite.position.x = value;
                            break;
                        case 'scaleSlider':
                            form.setFieldsValue({
                                slider: value
                                scale: value
                            })
                            curSprite.scale.set(value);
                            break;
                        case 'scale':
                            form.setFieldsValue({
                                scaleSlider: value
                            })
                            curSprite.scale.set(value);
                            break;
                        case 'rotationSlider':
                            form.setFieldsValue({
                                rotation: value
                            })
                            curSprite.rotation = value * Math.PI / 180;
                            break;
                        case 'rotation':
                            form.setFieldsValue({
                                rotationSlider: value
                            })
                            curSprite.rotation = value * Math.PI / 180;
                            break;
                        default:
                            break;
                    }
                    Utils.removeSelectedEffect();
                    Utils.showSelectedEffect(curSprite);
                })
            })
        }
@@ -67,19 +96,6 @@
    const onFinishFailed = (errorInfo) => {
    };
    const prefixSelector = (
        <Form.Item name="prefix" noStyle>
            <Select
                style={{
                    width: 70,
                }}
            >
                <Option value="86">+86</Option>
                <Option value="87">+87</Option>
            </Select>
        </Form.Item>
    );
    return (
        <>
@@ -116,14 +132,146 @@
                    variant='filled'    // outlined | borderless | filled
                    labelWrap   // label 换行
                    disabled={false}
                    layout='horizontal'
                >
                    <Row gutter={24}>
                        <Col span={6}>
                            <Form.Item label="Plain Text">
                    <Row gutter={[24, 16]}>
                        {/*  */}
                        <Col span={24}>
                            <Form.Item
                                label={intl.formatMessage({ id: 'map.settings.type', defaultMessage: '类型' })}
                                labelCol={{ span: 2 }}
                            >
                                <span className="ant-form-text">China</span>
                            </Form.Item>
                        </Col>
                        <Col span={12}>
                        {/* position */}
                        <Col span={24}>
                            <Form.Item
                                label={intl.formatMessage({ id: 'map.settings.position', defaultMessage: '坐标' })}
                            >
                                <Space.Compact>
                                    <Form.Item
                                        name='x'
                                        noStyle
                                        rules={[
                                            {
                                                required: true,
                                            },
                                        ]}
                                    >
                                        <InputNumber
                                            addonBefore={<Space.Compact>x</Space.Compact>}
                                            style={{
                                                width: '50%',
                                            }}
                                        />
                                    </Form.Item>
                                    <Form.Item
                                        name='y'
                                        noStyle
                                        rules={[
                                            {
                                                required: true,
                                            },
                                        ]}
                                    >
                                        <InputNumber
                                            addonBefore={<Space.Compact>y</Space.Compact>}
                                            style={{
                                                width: '50%',
                                            }}
                                        />
                                    </Form.Item>
                                </Space.Compact>
                            </Form.Item>
                        </Col>
                        {/* scale */}
                        <Col span={24}>
                            <Row gutter={24}>
                                <Col span={18}>
                                    <Form.Item
                                        label={intl.formatMessage({ id: 'map.settings.scale', defaultMessage: '缩放' })}
                                        name="scaleSlider"
                                        labelCol={{ span: 4 }}
                                    >
                                        <Slider
                                            min={0.1}
                                            max={10}
                                            step={0.1}
                                            marks={{
                                                0.1: '0.1',
                                                1: '1',
                                                10: '10',
                                            }}
                                        />
                                    </Form.Item>
                                </Col>
                                <Col span={6}>
                                    <Form.Item
                                        name="scale"
                                        labelCol={{ span: 4 }}
                                    >
                                        <InputNumber
                                            changeOnWheel
                                            min={0.1} max={10} defaultValue={1} step={0.1}
                                            rules={[
                                                {
                                                    required: true,
                                                },
                                            ]}
                                        />
                                    </Form.Item>
                                </Col>
                            </Row>
                        </Col>
                        {/* rotation */}
                        <Col span={24}>
                            <Row gutter={24}>
                                <Col span={18}>
                                    <Form.Item
                                        label={intl.formatMessage({ id: 'map.settings.rotation', defaultMessage: '角度' })}
                                        name="rotationSlider"
                                        labelCol={{ span: 4 }}
                                    >
                                        <Slider
                                            min={0}
                                            max={360}
                                            step={1}
                                            marks={{
                                                0: '0°',
                                                90: '90°',
                                                180: '180°',
                                                270: '270°',
                                                360: '360°',
                                            }}
                                        />
                                    </Form.Item>
                                </Col>
                                <Col span={6}>
                                    <Form.Item
                                        name="rotation"
                                        labelCol={{ span: 4 }}
                                    >
                                        <InputNumber
                                            changeOnWheel
                                            min={0} max={360} defaultValue={0}
                                            rules={[
                                                {
                                                    required: true,
                                                },
                                            ]}
                                        />
                                    </Form.Item>
                                </Col>
                            </Row>
                        </Col>
                        {/* <Col span={12}>
                            <Form.Item
                                label="Username"
                                name="username"
@@ -141,35 +289,10 @@
                        </Col>
                        <Col span={24}>
                            <Form.Item
                                label="InputNumber"
                                name="no"
                            >
                                <InputNumber
                                    changeOnWheel
                                    min={1} max={10} defaultValue={3}
                                />
                            </Form.Item>
                        </Col>
                        <Col span={24}>
                            <Form.Item
                                label="Switch"
                                valuePropName="checked"
                            >
                                <Switch />
                            </Form.Item>
                        </Col>
                        <Col span={24}>
                            <Form.Item name="slider" label="Slider">
                                <Slider
                                    marks={{
                                        0: 'A',
                                        20: 'B',
                                        40: 'C',
                                        60: 'D',
                                        80: 'E',
                                        100: 'F',
                                    }}
                                />
                            </Form.Item>
                        </Col>
                        <Col span={24}>
@@ -233,7 +356,7 @@
                                    }}
                                />
                            </Form.Item>
                        </Col>
                        </Col> */}