| | |
| | | import React, { useState } from 'react' |
| | | import { useDrop } from 'react-dnd' |
| | | import { is, fromJS } from 'immutable' |
| | | import update from 'immutability-helper' |
| | | import { Empty, notification, Modal } from 'antd' |
| | | |
| | | import Utils from '@/utils/utils.js' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import MenuUtils from '@/menu/utils/menuUtils.js' |
| | | import MenuUtils from '@/utils/utils-custom.js' |
| | | import Card from './card' |
| | | import './index.scss' |
| | | |
| | |
| | | const { card, index } = findCard(id) |
| | | const _cards = update(cards, { $splice: [[index, 1], [atIndex, 0, card]] }) |
| | | handleList({...menu, components: _cards}) |
| | | setCards(_cards) |
| | | } |
| | | |
| | | if (!is(fromJS(cards), fromJS(menu.components))) { |
| | | if (menu.components.length > cards.length) { |
| | | setCards(menu.components) |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | const updateConfig = (element) => { |
| | | handleList({...menu, components: cards.map(item => item.uuid === element.uuid ? element : item)}) |
| | | const _cards = cards.map(item => item.uuid === element.uuid ? element : item) |
| | | handleList({...menu, components: _cards}) |
| | | setCards(_cards) |
| | | } |
| | | |
| | | const deleteCard = (id) => { |
| | |
| | | title: `确定删除《${card.name}》吗?`, |
| | | content: hasComponent ? '当前组件中含有子组件!' : '', |
| | | onOk() { |
| | | const _cards = cards.filter(item => item.uuid !== card.uuid) |
| | | handleList({...menu, components: _cards}) |
| | | setCards(_cards) |
| | | |
| | | if (uuids.length === 0) return |
| | | |
| | | MKEmitter.emit('delButtons', uuids) |
| | | handleList({...menu, components: cards.filter(item => item.uuid !== card.uuid)}) |
| | | }, |
| | | onCancel() {} |
| | | }) |
| | |
| | | let name = '' |
| | | let names = { |
| | | bar: '柱状图', |
| | | chart: '图表', |
| | | line: '折线图', |
| | | tabs: '标签组', |
| | | pie: '饼图', |
| | | search: '搜索', |
| | | table: '表格', |
| | | group: '分组', |
| | | editor: '富文本', |
| | | code: '自定义', |
| | | carousel: '轮播', |
| | | form: '表单', |
| | | dashboard: '仪表盘', |
| | | scatter: '散点图', |
| | | tree: '树形列表', |
| | | balcony: '浮动卡', |
| | | card: '卡片' |
| | | } |
| | | let i = 1 |
| | |
| | | const _cards = update(cards, { $splice: [[overIndex + 1, 0, newcard]] }) |
| | | |
| | | handleList({...menu, components: _cards}) |
| | | setCards(_cards) |
| | | } |
| | | }) |
| | | |