Commit 2fc59e28 authored by 皮倩雯's avatar 皮倩雯
parents 6de5ac8f 63470ffa
Pipeline #80380 passed with stages
...@@ -114,6 +114,7 @@ ...@@ -114,6 +114,7 @@
"gsap": "^3.10.4", "gsap": "^3.10.4",
"history": "4.9.0", "history": "4.9.0",
"hoist-non-react-statics": "3.3.0", "hoist-non-react-statics": "3.3.0",
"html2canvas": "^1.4.1",
"immer": "3.0.0", "immer": "3.0.0",
"immutability-helper": "latest", "immutability-helper": "latest",
"immutable": "^4.0.0-rc.12", "immutable": "^4.0.0-rc.12",
...@@ -123,9 +124,10 @@ ...@@ -123,9 +124,10 @@
"js-calendar-converter": "0.0.4", "js-calendar-converter": "0.0.4",
"lodash": "4.17.11", "lodash": "4.17.11",
"minimist": "1.2.0", "minimist": "1.2.0",
"panda-xform": "^5.2.3", "panda-xform": "5.2.4",
"parseForm": "^2.3.8", "parseForm": "^2.3.8",
"prop-types": "15.7.2", "prop-types": "15.7.2",
"qrcode.react": "^3.1.0",
"quill": "^1.3.7", "quill": "^1.3.7",
"rc-tween-one": "^3.0.6", "rc-tween-one": "^3.0.6",
"react": "16.14.0", "react": "16.14.0",
......
import React, { useRef, useContext, useState, useEffect } from 'react' import React, { useRef, useContext, useState, useEffect, forwardRef, useImperativeHandle } from 'react'
import styles from './index.less' import styles from './index.less'
import { DownOutlined, VerticalAlignTopOutlined, UpOutlined, VerticalAlignBottomOutlined } from '@ant-design/icons' import { DownOutlined, VerticalAlignTopOutlined, UpOutlined, VerticalAlignBottomOutlined } from '@ant-design/icons'
import { useDrag, useDrop, DndProvider } from 'react-dnd' import { useDrag, useDrop, DndProvider } from 'react-dnd'
import { GlobalStore } from '../index' import { GlobalStore } from '../index'
import Group from './Group' import Group from './Group'
import moment from 'moment' import moment from 'moment'
import { getSiteTree } from '@/services/siteManage/api'; import { getSiteTree } from '@/services/siteManage/api'
const btns = [ const btns = [
{ title: '置顶', icon: <VerticalAlignTopOutlined /> }, { title: '置顶', icon: <VerticalAlignTopOutlined /> },
...@@ -14,10 +14,14 @@ const btns = [ ...@@ -14,10 +14,14 @@ const btns = [
{ title: '置底', icon: <VerticalAlignBottomOutlined /> }, { title: '置底', icon: <VerticalAlignBottomOutlined /> },
] ]
const Container = (props) => { const Container = (props, ref) => {
useImperativeHandle(ref, () => ({
moblieRef
}))
const currentDate = moment().format('YYYY-MM-DD') const currentDate = moment().format('YYYY-MM-DD')
const ref = useRef(null) const moblieRef = useRef(null)
const [currentSite, setCurrentSite] = useState('永吉水务有限公司') const [currentSite, setCurrentSite] = useState('永吉水务有限公司')
const { shema, setShema } = useContext(GlobalStore) const { shema, setShema } = useContext(GlobalStore)
...@@ -30,7 +34,7 @@ const Container = (props) => { ...@@ -30,7 +34,7 @@ const Container = (props) => {
} }
}) })
drop(ref) drop(moblieRef)
const pageClick = () => { const pageClick = () => {
let array = [] let array = []
...@@ -79,12 +83,15 @@ const Container = (props) => { ...@@ -79,12 +83,15 @@ const Container = (props) => {
<div className={styles.container}> <div className={styles.container}>
<div className={styles.content}> <div className={styles.content}>
<div <div
ref={ref} ref={moblieRef}
className={styles.moblie} className={styles.moblie}
onClick={() => pageClick()} onClick={() => pageClick()}
active={`${shema.active}`} active={`${shema.active}`}
> >
<div className={styles.moblieCenter} name={shema.theme}> <div
className={styles.moblieCenter}
name={shema.theme}
>
<div className={styles['m-info']}> <div className={styles['m-info']}>
<div className={styles['i-company']}> <div className={styles['i-company']}>
<span className={styles['c-address']}></span> <span className={styles['c-address']}></span>
...@@ -119,4 +126,4 @@ const Container = (props) => { ...@@ -119,4 +126,4 @@ const Container = (props) => {
} }
export default Container export default forwardRef(Container)
\ No newline at end of file \ No newline at end of file
...@@ -3,6 +3,7 @@ import { Checkbox, Row, Col } from 'antd' ...@@ -3,6 +3,7 @@ import { Checkbox, Row, Col } from 'antd'
import { useDrag, useDrop, DndProvider } from 'react-dnd' import { useDrag, useDrop, DndProvider } from 'react-dnd'
import { CaretRightOutlined } from '@ant-design/icons' import { CaretRightOutlined } from '@ant-design/icons'
import styles from './index.less' import styles from './index.less'
import { GlobalStore } from '../index'
const cardTypes = ['管理', '执行', '运营'] const cardTypes = ['管理', '执行', '运营']
...@@ -97,7 +98,7 @@ const Group = (props) => { ...@@ -97,7 +98,7 @@ const Group = (props) => {
} }
const Card = (props) => { const Card = (props) => {
console.log('pprops', props)
const ref = useRef(null) const ref = useRef(null)
const id = getNanoid() const id = getNanoid()
...@@ -146,6 +147,7 @@ const CardGroup = (props) => { ...@@ -146,6 +147,7 @@ const CardGroup = (props) => {
const Left = () => { const Left = () => {
const { shema, setShema } = useContext(GlobalStore)
const [cardType, setCardType] = useState(cardTypes) const [cardType, setCardType] = useState(cardTypes)
const cardsFilter = useMemo(() => { const cardsFilter = useMemo(() => {
......
...@@ -172,6 +172,10 @@ const Right = () => { ...@@ -172,6 +172,10 @@ const Right = () => {
useEffect(() => { useEffect(() => {
getData() getData()
//初始增加一个供水主题
if (!shema.theme) {
setShema({ ...shema, theme: '供水主题背景' })
}
}, []) }, [])
return ( return (
......
import React, { useState, createContext } from 'react' import React, { useState, createContext, useRef } from 'react'
import { useDrag, useDrop, DndProvider } from 'react-dnd' import { useDrag, useDrop, DndProvider } from 'react-dnd'
import QRcode from 'qrcode.react' import QRcode from 'qrcode.react'
import { Button, Popover } from 'antd' import { Button, Popover, message } from 'antd'
import { EyeOutlined } from '@ant-design/icons' import { EyeOutlined } from '@ant-design/icons'
import { HTML5Backend } from 'react-dnd-html5-backend' import { HTML5Backend } from 'react-dnd-html5-backend'
import styles from './index.less' import styles from './index.less'
import Left from './Left' import Left from './Left'
import Container from './Container' import Container from './Container'
import Right from './Right' import Right from './Right'
import html2canvas from 'html2canvas'
import { request } from '@wisdom-utils/utils/es';
const HtmlToCanvas = (DOM, option) => {
// function saveFile(data, filename) {
// let save_link = document.createElementNS('http://www.w3.org/1999/xhtml', 'a')
// save_link.href = data
// save_link.download = filename
// let event = document.createEvent('MouseEvents')
// event.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null)
// save_link.dispatchEvent(event)
// }
// async function exportToPic() {
// let fileName = option.text
// let canvas = await html2canvas(DOM, option)
// let pageData = canvas.toDataURL('image/jpeg', 1.0)
// saveFile(pageData.replace("image/jpeg", "image/octet-stream"), `${fileName}.jpeg`)
// }
// exportToPic()
}
export const GlobalStore = createContext(null) export const GlobalStore = createContext(null)
...@@ -20,13 +44,37 @@ const Designer = (props) => { ...@@ -20,13 +44,37 @@ const Designer = (props) => {
const { currentCard, } = props const { currentCard, } = props
const [shema, setShema] = useState(currentCard['卡片结构'] ? { ...JSON.parse(currentCard['卡片结构']) } : initShema) const [shema, setShema] = useState(currentCard['卡片结构'] ? { ...JSON.parse(currentCard['卡片结构']) } : initShema)
const containerRef = useRef(null)
const goBack = () => { const goBack = () => {
props?.goBack?.() props?.goBack?.()
} }
const saveDesgin = () => { const UploadSingleFile = (data) => {
props?.saveDesgin?.({ ...currentCard, '卡片结构': JSON.stringify(shema) }) return request({
url: `${origin}/PandaCore/GateWay/PandaOMS/OMS/FileCenter/UploadSingleFile`,
method: 'post',
headers: {
'Content-Type': 'multipart/form-data',
},
data,
});
}
const saveDesgin = async () => {
const moblieDOM = containerRef?.current?.moblieRef?.current
const canvas = await html2canvas(moblieDOM)
canvas.toBlob(async blob => {
const file = new File([blob], `${currentCard['名称']}.png`, { type: 'image/png' })
const formData = new FormData();
formData.append('singleFile', file);
const { code, data, msg } = await UploadSingleFile(formData)
if (code === 0) {
props?.saveDesgin?.({ ...currentCard, '卡片结构': JSON.stringify(shema), '路径': data })
} else {
message.error({ content: msg })
}
})
} }
const preview = () => { const preview = () => {
...@@ -55,7 +103,7 @@ const Designer = (props) => { ...@@ -55,7 +103,7 @@ const Designer = (props) => {
</div> </div>
<div className={styles.bottom}> <div className={styles.bottom}>
<Left></Left> <Left></Left>
<Container></Container> <Container ref={containerRef}></Container>
<Right></Right> <Right></Right>
</div> </div>
</div> </div>
......
...@@ -6,9 +6,9 @@ import { getSchemeList, saveScheme, deleteScheme, roleGroupList } from '@/servic ...@@ -6,9 +6,9 @@ import { getSchemeList, saveScheme, deleteScheme, roleGroupList } from '@/servic
import Designer from './components/Designer' import Designer from './components/Designer'
const cardType = [ const cardType = [
{ label: '管理', value: '管理' }, { label: '管理工作台', value: '管理' },
{ label: '运营', value: '运营' }, { label: '运营工作台', value: '运营' },
{ label: '执行', value: '执行' }, { label: '执行工作台', value: '执行' },
] ]
const WorkDesign = (props) => { const WorkDesign = (props) => {
...@@ -166,6 +166,7 @@ const WorkDesign = (props) => { ...@@ -166,6 +166,7 @@ const WorkDesign = (props) => {
</div> </div>
</div> </div>
<div className={styles.img}> <div className={styles.img}>
{v['路径'] ? <img style={{ width: '100%' }} src={`${origin}/PandaOMS/OMS/FileCenter/DownloadFiles?module=图库&filePath=${v['路径']}`}></img> : null}
<div className={styles.imgCenter}> <div className={styles.imgCenter}>
<div> <div>
<Button type="primary" onClick={() => toDesign(v)}>编辑</Button> <Button type="primary" onClick={() => toDesign(v)}>编辑</Button>
...@@ -234,7 +235,7 @@ const WorkDesign = (props) => { ...@@ -234,7 +235,7 @@ const WorkDesign = (props) => {
</TreeSelect> </TreeSelect>
</Form.Item> </Form.Item>
<Form.Item <Form.Item
label={'组件类型'} label={'工作台类型'}
name={'类型'} name={'类型'}
rules={[{ required: true }]} rules={[{ required: true }]}
> >
...@@ -248,7 +249,7 @@ const WorkDesign = (props) => { ...@@ -248,7 +249,7 @@ const WorkDesign = (props) => {
</Form.Item> </Form.Item>
</Form> </Form>
</Modal> </Modal>
</div > </div>
) )
} }
......
...@@ -124,6 +124,7 @@ ...@@ -124,6 +124,7 @@
margin-top: 5px; margin-top: 5px;
margin-bottom: 5px; margin-bottom: 5px;
border-radius: 4px; border-radius: 4px;
overflow: hidden;
&:hover { &:hover {
cursor: pointer; cursor: pointer;
.imgCenter { .imgCenter {
......
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