From 023afca2aa4ae3128d19d6eeb0bbcd20a78bf125 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期二, 12 三月 2024 15:36:52 +0800
Subject: [PATCH] #
---
zy-asrs-flow/src/pages/map/components/settings.jsx | 541 ++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 447 insertions(+), 94 deletions(-)
diff --git a/zy-asrs-flow/src/pages/map/components/settings.jsx b/zy-asrs-flow/src/pages/map/components/settings.jsx
index b1fe434..b98bb02 100644
--- a/zy-asrs-flow/src/pages/map/components/settings.jsx
+++ b/zy-asrs-flow/src/pages/map/components/settings.jsx
@@ -1,57 +1,46 @@
import React, { useState, useRef, useEffect } from 'react';
-import {
- ProForm,
- ProFormDigit,
- ProFormText,
- ProFormSelect,
- ProFormDateTimePicker,
- ProFormTextArea,
- ProFormSlider,
- ProFormSwitch,
-} from '@ant-design/pro-components';
-import moment from 'moment';
-import { Col, Form, Modal, Row, Checkbox, Image, Tree, Drawer, Space, Button, Card, Divider } from 'antd';
+import { Col, Form, Input, Row, Checkbox, Slider, Select, Drawer, Space, Button, InputNumber, Card } 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';
+import SubSpriteSettings from './subSettings';
+import { values } from 'lodash';
const useStyles = createStyles(({ token, css }) => {
})
-const SpriteSettings = (props) => {
+const Settings = (props) => {
const intl = useIntl();
const { styles } = useStyles();
- const { curSprite } = props;
- const [form] = Form.useForm();
+ const [activeTabKey, setActiveTabKey] = useState('map');
+ const [mapForm] = Form.useForm();
- useEffect(() => {
-
- }, []);
-
- useEffect(() => {
- form.resetFields();
- form.setFieldsValue({
- ...props.values
- })
- }, [form, props])
+ const contentList = {
+ map: (
+ <SpriteSettings
+ refCurr={props.refCurr}
+ curSprite={props.curSprite}
+ setSpriteBySettings={props.setSpriteBySettings}
+ setDidClickSprite={props.setDidClickSprite}
+ onSubmit={props.onSubmit}
+ mapForm={mapForm}
+ />
+ ),
+ config: (
+ <h1>Hello</h1>
+ ),
+ };
const handleCancel = () => {
props.onCancel();
};
const handleOk = () => {
- form.submit();
- }
-
- const handleFinish = async (values) => {
- props.onSubmit({ ...values });
- }
-
- const formValuesChange = (changeValues) => {
- console.log(changeValues);
+ mapForm.submit();
}
return (
@@ -74,66 +63,430 @@
</Space>
}
>
- <ProForm
- form={form}
- submitter={false}
- onFinish={handleFinish}
- layout="horizontal"
- grid={true}
- onValuesChange={formValuesChange}
+ <Card
+ hoverable
+ bordered={false}
+ tabList={[
+ {
+ key: 'map',
+ tab: '鍦板浘鍙傛暟',
+ },
+ {
+ key: 'config',
+ tab: '閰嶇疆鍙傛暟',
+ },
+ ]}
+ activeTabKey={activeTabKey}
+ onTabChange={(key) => {
+ setActiveTabKey(key)
+ }}
+ tabProps={{
+ centered: true,
+ size: 'large',
+ type: "card",
+ style: {
+ }
+ }}
>
- {/*
- // position
- // scale
- // rotation
- // copy
- */}
- <ProForm.Group>
- <ProFormText
- name="name"
- label="鍚嶇О"
- colProps={{ md: 12, xl: 12 }}
- />
- <ProFormDigit
- label="InputNumber"
- name="input-number"
- min={1}
- max={10}
- colProps={{ md: 12, xl: 12 }}
- />
- </ProForm.Group>
- <ProForm.Group>
- <ProFormSlider
- name="slider"
- label="Slider"
- width="lg"
- marks={{
- 0: 'A',
- 20: 'B',
- 40: 'C',
- 60: 'D',
- 80: 'E',
- 100: 'F',
- }}
- colProps={{ md: 12, xl: 12 }}
- />
- <ProFormSwitch
- name="switch"
- label="Switch"
- colProps={{ md: 12, xl: 12 }}
- />
- </ProForm.Group>
- <ProForm.Group>
- <ProFormTextArea
- name="memo"
- label="澶囨敞"
- colProps={{ md: 24, xl: 24 }}
- />
- </ProForm.Group>
- </ProForm>
- </Drawer>
+ {contentList[activeTabKey]}
+ </Card>
+
+ </Drawer >
</>
)
}
-export default SpriteSettings;
\ No newline at end of file
+const SpriteSettings = (props) => {
+ const intl = useIntl();
+ const { styles } = useStyles();
+ const { curSprite, mapForm: form } = props;
+
+ const [childrenDrawer, setChildrenDrawer] = useState(false);
+ const [lastCopiedSprites, setLastCopiedSprites] = useState([]);
+
+ useEffect(() => {
+
+ }, []);
+
+ useEffect(() => {
+ form.resetFields();
+ 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,
+
+ copyDire: 'right',
+ copyCount: 1,
+ })
+ }
+ }, [form, props])
+
+ const handleFinish = async (values) => {
+ props.onSubmit({ ...values });
+ }
+
+ const formValuesChange = (changeList) => {
+ if (curSprite && changeList && changeList.length > 0) {
+ changeList.forEach(change => {
+ const { name: nameList, value } = change;
+ nameList.forEach(name => {
+ switch (name) {
+ case 'x':
+ curSprite.position.x = value;
+ break;
+ case 'y':
+ curSprite.position.y = value;
+ break;
+ case 'scaleSlider':
+ form.setFieldsValue({
+ 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);
+ })
+ })
+ }
+ }
+
+ const onFinishFailed = (errorInfo) => {
+ };
+
+ const handleOnCopy = (values) => {
+ if (!curSprite) {
+ return;
+ }
+ setLastCopiedSprites([]);
+ for (let i = 0; i < values.copyCount; i++) {
+ const copiedSprite = Utils.copySprite(curSprite);
+ switch (values.copyDire) {
+ case 'left':
+ copiedSprite.position.x -= (i + 1) * (values.copyGap + copiedSprite.width);
+ break;
+ case 'right':
+ copiedSprite.position.x += (i + 1) * (values.copyGap + copiedSprite.width);
+ break;
+ case 'top':
+ copiedSprite.position.y -= (i + 1) * (values.copyGap + copiedSprite.height);
+ break;
+ case 'bottom':
+ copiedSprite.position.y += (i + 1) * (values.copyGap + copiedSprite.height);
+ break;
+ default:
+ break;
+ }
+ Utils.getMapContainer().addChild(copiedSprite);
+ Utils.beSettings(copiedSprite, props.setSpriteBySettings, props.setDidClickSprite);
+
+ setLastCopiedSprites(prevArr => [...prevArr, copiedSprite]);
+ }
+ setChildrenDrawer(false);
+ }
+
+ return (
+ <>
+ <Form
+ form={form}
+ onFieldsChange={formValuesChange}
+ initialValues={{
+ }}
+ onFinish={handleFinish}
+ onFinishFailed={onFinishFailed}
+ autoComplete="off"
+ style={{
+ maxWidth: 600,
+ }}
+ size='default' // small | default | large
+ variant='filled' // outlined | borderless | filled
+ labelWrap // label 鎹㈣
+ disabled={false}
+ layout='horizontal'
+ >
+ <Row gutter={[24, 16]}>
+
+ <Col span={24}>
+ <Row gutter={24}>
+ <Col span={18}>
+ <Form.Item
+ label={intl.formatMessage({ id: 'map.settings.type', defaultMessage: '绫诲瀷' })}
+ labelCol={{ span: 4 }}
+ >
+ <span>{curSprite?.data?.type}</span>
+ </Form.Item>
+ </Col>
+ </Row>
+ </Col>
+
+ {/* position */}
+ <Col span={24}>
+ <Row gutter={24}>
+ <Col span={18}>
+ <Form.Item
+ label={intl.formatMessage({ id: 'map.settings.position', defaultMessage: '鍧愭爣' })}
+ labelCol={{ span: 4 }}
+ >
+ <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>
+ </Row>
+ </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>
+
+ {/* copy */}
+ <Col span={24}>
+ <Row gutter={0}>
+ <Col span={20}>
+ <Form.Item
+ label={intl.formatMessage({ id: 'map.settings.copy', defaultMessage: '澶嶅埗' })}
+ labelCol={{ span: 4 }}
+ >
+ <Space.Compact>
+ <Form.Item
+ noStyle
+ name="copyDire"
+ >
+ <Select
+ style={{ width: 100 }}
+ options={[
+ { value: 'left', label: intl.formatMessage({ id: 'map.settings.left', defaultMessage: '宸�' }) },
+ { value: 'right', label: intl.formatMessage({ id: 'map.settings.right', defaultMessage: '鍙�' }) },
+ { value: 'top', label: intl.formatMessage({ id: 'map.settings.top', defaultMessage: '涓�' }) },
+ { value: 'bottom', label: intl.formatMessage({ id: 'map.settings.bottom', defaultMessage: '涓�' }) },
+ ]}
+ />
+ </Form.Item>
+ <Form.Item
+ name='copyCount'
+ noStyle
+ rules={[
+ {
+ required: true,
+ },
+ ]}
+ >
+ <InputNumber
+ addonBefore={<Space.Compact></Space.Compact>}
+ style={{
+ width: '50%',
+ }}
+ min={1}
+ step={1}
+ />
+ </Form.Item>
+ <Form.Item>
+ <Button
+ onClick={() => {
+ setChildrenDrawer(true);
+ }}
+ >
+ <FormattedMessage id='common.execute' defaultMessage='鎵ц' />
+ </Button>
+ <SubSpriteSettings
+ open={childrenDrawer}
+ refCurr={props.refCurr}
+ curSprite={props.curSprite}
+ values={form.getFieldsValue()}
+ submit={handleOnCopy}
+ onClose={() => {
+ setChildrenDrawer(false)
+ }}
+ />
+ </Form.Item>
+
+ </Space.Compact>
+ </Form.Item>
+ </Col>
+ </Row>
+ <Row gutter={0}>
+ <Col offset={16} span={8}>
+ <Form.Item>
+ <Button
+ type="dashed"
+ onClick={() => {
+ if (lastCopiedSprites) {
+ lastCopiedSprites.forEach(copiedSprite => {
+ Utils.getMapContainer().removeChild(copiedSprite);
+ })
+ setLastCopiedSprites([]);
+ }
+ }}
+ >
+ <FormattedMessage id='map.settings.sub.copy.undo.last.copies' defaultMessage='鎾ゅ洖澶嶅埗' />
+ </Button>
+ </Form.Item>
+ </Col>
+ </Row>
+ </Col>
+
+ {/* more */}
+ <Col span={24}>
+ <Row gutter={24}>
+ <Col span={18}>
+ <Form.Item
+ label={intl.formatMessage({ id: 'map.settings.more', defaultMessage: '鏇村' })}
+ labelCol={{ span: 4 }}
+ >
+ <Button
+ type="dashed"
+ danger
+ onClick={() => {
+ Utils.getMapContainer().removeChild(curSprite);
+ props.setSpriteBySettings(null);
+ Utils.removeSelectedEffect();
+ form.resetFields();
+ }}
+ >
+ <FormattedMessage id='map.settings.delete' defaultMessage='鍒犻櫎' />
+ </Button>
+ </Form.Item>
+ </Col>
+ </Row>
+ </Col>
+
+ </Row>
+ </Form>
+ </>
+ )
+}
+
+export default Settings;
\ No newline at end of file
--
Gitblit v1.9.1