From 99c9aed75c0bf5356e3170b7070ed00d7ba653ca Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期日, 29 一月 2023 17:00:30 +0800 Subject: [PATCH] 2023-01-29 --- src/components/header/index.jsx | 20 + src/mob/mobshell/index.jsx | 20 + src/pc/menushell/index.jsx | 20 + src/tabviews/custom/popview/index.scss | 5 src/templates/sharecomponent/fieldscomponent/index.jsx | 34 +- src/menu/components/tabs/tabcomponents/index.jsx | 20 + src/mob/components/tabs/tabcomponents/index.jsx | 20 + src/tabviews/custom/index.scss | 5 src/views/billprint/index.jsx | 2 src/menu/menushell/card.jsx | 4 src/mob/mobshell/card.jsx | 4 src/assets/css/main.scss | 4 src/index.js | 1 src/tabviews/custom/components/module/voucher/index.jsx | 65 ++++ src/tabviews/basetable/index.scss | 5 src/pc/menushell/card.jsx | 4 src/tabviews/custom/components/module/voucher/voucherTable/index.scss | 52 +++ src/mob/components/tabs/tabcomponents/card.jsx | 4 /dev/null | 259 ----------------- src/tabviews/custom/components/module/voucher/voucherTable/index.jsx | 228 +++++++++++--- src/menu/components/module/voucher/index.scss | 2 src/menu/components/tabs/tabcomponents/card.jsx | 4 src/menu/menushell/index.jsx | 20 + src/templates/zshare/modalform/modaleditable/index.jsx | 46 +- src/menu/components/group/normal-group/index.jsx | 37 ++ src/templates/zshare/modalform/modaleditable/index.scss | 9 26 files changed, 511 insertions(+), 383 deletions(-) diff --git a/src/assets/css/main.scss b/src/assets/css/main.scss index 630b514..eb2dcfb 100644 --- a/src/assets/css/main.scss +++ b/src/assets/css/main.scss @@ -488,4 +488,8 @@ display: flex; flex: auto; min-height: 100%; +} + +.component-wrap >.ant-col { + min-height: 0; } \ No newline at end of file diff --git a/src/components/header/index.jsx b/src/components/header/index.jsx index 7f2669a..369d9c5 100644 --- a/src/components/header/index.jsx +++ b/src/components/header/index.jsx @@ -225,6 +225,8 @@ getMenulist = (result) => { let thdMenuList = [] let menulist = [] + let names = new Map() + let doublenames = new Map() result.fst_menu && result.fst_menu.forEach(fst => { let fstItem = { MenuID: fst.MenuID, @@ -268,6 +270,7 @@ ParentId: snd.MenuID, MenuID: trd.MenuID, MenuName: trd.MenuName, + menu_name: trd.MenuName, ParentNames: [fst.MenuName, snd.MenuName], MenuNo: trd.MenuNo, EasyCode: trd.EasyCode, @@ -296,6 +299,12 @@ trdItem.OpenType = trdItem.OpenType.toLowerCase() // NewPage涓烘墦寮�澶栭儴椤甸潰鍦板潃 + if (names.has(trdItem.menu_name)) { + doublenames.set(trdItem.menu_name, true) + } else { + names.set(trdItem.menu_name, true) + } + thdMenuList.push(trdItem) return trdItem @@ -309,6 +318,13 @@ } menulist.push(fstItem) + }) + + thdMenuList = thdMenuList.map(item => { + if (doublenames.has(item.menu_name)) { + item.menu_name += '锛�' + item.ParentNames.join('-') + '锛�' + } + return item }) return { menulist, thdMenuList } @@ -740,12 +756,12 @@ option.MenuNo.toLowerCase().indexOf(searchkey.toLowerCase()) >= 0 || option.EasyCode.toLowerCase().indexOf(searchkey.toLowerCase()) >= 0 ) { - return <Menu.Item key={option.MenuID} onClick={() => this.changeVerMenu(option)}>{option.MenuName}</Menu.Item> + return <Menu.Item key={option.MenuID} onClick={() => this.changeVerMenu(option)}>{option.menu_name}</Menu.Item> } else { return null } } - return <Menu.Item key={option.MenuID} onClick={() => this.changeVerMenu(option)}>{option.MenuName}</Menu.Item> + return <Menu.Item key={option.MenuID} onClick={() => this.changeVerMenu(option)}>{option.menu_name}</Menu.Item> })} </Menu> </div> diff --git a/src/index.js b/src/index.js index 6f54818..4fb5ee8 100644 --- a/src/index.js +++ b/src/index.js @@ -290,6 +290,7 @@ }) window.GLOB.CacheMap = new Map() // 缂撳瓨閰嶇疆淇℃伅 + window.GLOB.CacheVoucher = new Map() // 缂撳瓨鍑瘉淇℃伅 window.GLOB.UserCacheMap = new Map() // 缂撳瓨鐢ㄦ埛鑷畾涔夎缃� window.GLOB.CacheData = new Map() // 瀛樺偍閫変腑鏁版嵁 diff --git a/src/menu/components/group/normal-group/index.jsx b/src/menu/components/group/normal-group/index.jsx index 0544f9d..1bf0d91 100644 --- a/src/menu/components/group/normal-group/index.jsx +++ b/src/menu/components/group/normal-group/index.jsx @@ -1,8 +1,8 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { Popover, Button } from 'antd' -import { EditOutlined, ToolOutlined, DeleteOutlined, FontColorsOutlined, PrinterOutlined } from '@ant-design/icons' +import { Popover, Button, Modal } from 'antd' +import { EditOutlined, ToolOutlined, DeleteOutlined, FontColorsOutlined, PrinterOutlined, UngroupOutlined } from '@ant-design/icons' import MKEmitter from '@/utils/events.js' import asyncComponent from '@/utils/asyncComponent' @@ -11,6 +11,7 @@ import getSettingForm from './options' import './index.scss' +const { confirm } = Modal const NormalForm = asyncIconComponent(() => import('@/components/normalform')) const CopyComponent = asyncIconComponent(() => import('@/menu/components/share/copycomponent')) const NormalHeader = asyncComponent(() => import('@/menu/components/share/normalheader')) @@ -21,6 +22,7 @@ static propTpyes = { group: PropTypes.object, deletecomponent: PropTypes.func, + unGroup: PropTypes.func, updateConfig: PropTypes.func, } @@ -129,6 +131,36 @@ this.updateComponent(group) } + unGroup = () => { + const { group } = this.state + + if (group.components.length === 0) return + + const _this = this + confirm({ + title: '纭畾閲婃斁鍒嗙粍鍏冪礌鍚楋紵', + content: '', + onOk() { + _this.props.unGroup(group.uuid) + + setTimeout(() => { + _this.updataGroup() + }, 10) + }, + onCancel() {} + }) + } + + updataGroup = () => { + const { group } = this.props + + if (group.components.length === 0) { + this.setState({ + group: fromJS(group).toJS() + }) + } + } + render() { const { group } = this.state let _style = resetStyle(group.style) @@ -147,6 +179,7 @@ <EditOutlined style={{color: '#1890ff'}} title="缂栬緫"/> </NormalForm> <CopyComponent type="tabs" card={group}/> + <UngroupOutlined title="閲婃斁" style={group.components.length > 0 ? {color: '#32c5d2'} : {color: '#eeeeee', cursor: 'not-allowed'}} onClick={this.unGroup}/> <PasteComponent insert={this.insert} /> <FontColorsOutlined className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle}/> <DeleteOutlined className="close" title="delete" onClick={() => this.props.deletecomponent(group.uuid)} /> diff --git a/src/menu/components/module/voucher/index.scss b/src/menu/components/module/voucher/index.scss index c7def70..f88ea60 100644 --- a/src/menu/components/module/voucher/index.scss +++ b/src/menu/components/module/voucher/index.scss @@ -30,7 +30,7 @@ } } .voucher-body { - padding: 0 15px; + padding: 0 30px; .voucher-code { display: inline-block; width: 160px; diff --git a/src/menu/components/tabs/tabcomponents/card.jsx b/src/menu/components/tabs/tabcomponents/card.jsx index 7b1e17d..9115d53 100644 --- a/src/menu/components/tabs/tabcomponents/card.jsx +++ b/src/menu/components/tabs/tabcomponents/card.jsx @@ -29,7 +29,7 @@ const Timeline = asyncComponent(() => import('@/menu/components/timeline/normal-timeline')) const AntvG6 = asyncComponent(() => import('@/menu/components/chart/antv-G6')) -const Card = ({ id, card, moveCard, findCard, delCard, updateConfig }) => { +const Card = ({ id, card, moveCard, findCard, delCard, unGroup, updateConfig }) => { const originalIndex = findCard(id).index const [{ isDragging }, drag] = useDrag({ item: { type: 'menu', id, originalIndex }, @@ -102,7 +102,7 @@ } else if (card.type === 'table' && card.subtype === 'editable') { return (<EditTable card={card} updateConfig={updateConfig} deletecomponent={delCard}/>) } else if (card.type === 'group' && card.subtype === 'normalgroup') { - return (<NormalGroup group={card} updateConfig={updateConfig} deletecomponent={delCard}/>) + return (<NormalGroup group={card} updateConfig={updateConfig} unGroup={unGroup} deletecomponent={delCard}/>) } else if (card.type === 'editor') { return (<BraftEditor card={card} updateConfig={updateConfig} deletecomponent={delCard}/>) } else if (card.type === 'code') { diff --git a/src/menu/components/tabs/tabcomponents/index.jsx b/src/menu/components/tabs/tabcomponents/index.jsx index a0ed8c1..bda63dd 100644 --- a/src/menu/components/tabs/tabcomponents/index.jsx +++ b/src/menu/components/tabs/tabcomponents/index.jsx @@ -34,6 +34,25 @@ handleList({...config, components: cards.map(item => item.uuid === element.uuid ? element : item)}) } + const unGroup = (id) => { + let { card, index } = findCard(`${id}`) + let components = [...card.components].map(item => { + if (item.wrap) { + item.wrap.width = card.width + item.width = card.width + } else if (item.plot) { + item.plot.width = card.width + item.width = card.width + } + return item + }) + card.components = [] + + const _cards = update(cards, { $splice: [[index, 1, card, ...components]] }) + + handleList({...config, components: _cards}) + } + const deleteCard = (id) => { const { card } = findCard(id) @@ -146,6 +165,7 @@ card={card} moveCard={moveCard} delCard={deleteCard} + unGroup={unGroup} findCard={findCard} updateConfig={updateConfig} /> diff --git a/src/menu/menushell/card.jsx b/src/menu/menushell/card.jsx index 0226f8f..5d9b196 100644 --- a/src/menu/menushell/card.jsx +++ b/src/menu/menushell/card.jsx @@ -32,7 +32,7 @@ const Iframe = asyncComponent(() => import('@/menu/components/iframe')) const AntvG6 = asyncComponent(() => import('@/menu/components/chart/antv-G6')) -const Card = ({ id, card, moveCard, findCard, delCard, updateConfig }) => { +const Card = ({ id, card, moveCard, findCard, delCard, unGroup, updateConfig }) => { const originalIndex = findCard(id).index const [{ isDragging }, drag] = useDrag({ item: { type: 'menu', id, originalIndex }, @@ -105,7 +105,7 @@ } else if (card.type === 'table' && card.subtype === 'editable') { return (<EditTable card={card} updateConfig={updateConfig} deletecomponent={delCard}/>) } else if (card.type === 'group' && card.subtype === 'normalgroup') { - return (<NormalGroup group={card} updateConfig={updateConfig} deletecomponent={delCard}/>) + return (<NormalGroup group={card} updateConfig={updateConfig} unGroup={unGroup} deletecomponent={delCard}/>) } else if (card.type === 'editor') { return (<BraftEditor card={card} updateConfig={updateConfig} deletecomponent={delCard}/>) } else if (card.type === 'code') { diff --git a/src/menu/menushell/index.jsx b/src/menu/menushell/index.jsx index 9024341..9533aa5 100644 --- a/src/menu/menushell/index.jsx +++ b/src/menu/menushell/index.jsx @@ -36,6 +36,25 @@ setCards(_cards) } + const unGroup = (id) => { + let { card, index } = findCard(`${id}`) + let components = [...card.components].map(item => { + if (item.wrap) { + item.wrap.width = card.width + item.width = card.width + } else if (item.plot) { + item.plot.width = card.width + item.width = card.width + } + return item + }) + card.components = [] + + const _cards = update(cards, { $splice: [[index, 1, card, ...components]] }) + + handleList({...menu, components: _cards}) + } + const deleteCard = (id) => { const { card } = findCard(id) @@ -155,6 +174,7 @@ card={card} moveCard={moveCard} delCard={deleteCard} + unGroup={unGroup} findCard={findCard} updateConfig={updateConfig} /> diff --git a/src/mob/components/tabs/tabcomponents/card.jsx b/src/mob/components/tabs/tabcomponents/card.jsx index 700de18..76430f6 100644 --- a/src/mob/components/tabs/tabcomponents/card.jsx +++ b/src/mob/components/tabs/tabcomponents/card.jsx @@ -27,7 +27,7 @@ const CodeSandbox = asyncComponent(() => import('@/menu/components/code/sandbox')) const Timeline = asyncComponent(() => import('@/menu/components/timeline/normal-timeline')) -const Card = ({ id, card, moveCard, findCard, delCard, updateConfig }) => { +const Card = ({ id, card, moveCard, findCard, delCard, unGroup, updateConfig }) => { const originalIndex = findCard(id).index const [{ isDragging }, drag] = useDrag({ item: { type: 'menu', id, originalIndex }, @@ -98,7 +98,7 @@ } else if (card.type === 'table' && card.subtype === 'normaltable') { return (<NormalTable card={card} updateConfig={updateConfig} deletecomponent={delCard}/>) } else if (card.type === 'group' && card.subtype === 'normalgroup') { - return (<NormalGroup group={card} updateConfig={updateConfig} deletecomponent={delCard}/>) + return (<NormalGroup group={card} updateConfig={updateConfig} unGroup={unGroup} deletecomponent={delCard}/>) } else if (card.type === 'editor') { return (<BraftEditor card={card} updateConfig={updateConfig} deletecomponent={delCard}/>) } else if (card.type === 'menubar') { diff --git a/src/mob/components/tabs/tabcomponents/index.jsx b/src/mob/components/tabs/tabcomponents/index.jsx index d202e5e..1d146b5 100644 --- a/src/mob/components/tabs/tabcomponents/index.jsx +++ b/src/mob/components/tabs/tabcomponents/index.jsx @@ -34,6 +34,25 @@ handleList({...config, components: cards.map(item => item.uuid === element.uuid ? element : item)}) } + const unGroup = (id) => { + let { card, index } = findCard(`${id}`) + let components = [...card.components].map(item => { + if (item.wrap) { + item.wrap.width = card.width + item.width = card.width + } else if (item.plot) { + item.plot.width = card.width + item.width = card.width + } + return item + }) + card.components = [] + + const _cards = update(cards, { $splice: [[index, 1, card, ...components]] }) + + handleList({...config, components: _cards}) + } + const deleteCard = (id) => { const { card } = findCard(id) @@ -139,6 +158,7 @@ card={card} moveCard={moveCard} delCard={deleteCard} + unGroup={unGroup} findCard={findCard} updateConfig={updateConfig} /> diff --git a/src/mob/mobshell/card.jsx b/src/mob/mobshell/card.jsx index 517db7f..f7965f6 100644 --- a/src/mob/mobshell/card.jsx +++ b/src/mob/mobshell/card.jsx @@ -33,7 +33,7 @@ const ShareCode = asyncComponent(() => import('@/mob/components/sharecode')) const Iframe = asyncComponent(() => import('@/menu/components/iframe')) -const Card = ({ id, card, moveCard, findCard, delCard, updateConfig }) => { +const Card = ({ id, card, moveCard, findCard, delCard, unGroup, updateConfig }) => { const originalIndex = findCard(id).index const [{ isDragging }, drag] = useDrag({ item: { type: 'menu', id, originalIndex }, @@ -120,7 +120,7 @@ } else if (card.type === 'table' && card.subtype === 'normaltable') { return (<NormalTable card={card} updateConfig={updateConfig} deletecomponent={delCard}/>) } else if (card.type === 'group' && card.subtype === 'normalgroup') { - return (<NormalGroup group={card} updateConfig={updateConfig} deletecomponent={delCard}/>) + return (<NormalGroup group={card} updateConfig={updateConfig} unGroup={unGroup} deletecomponent={delCard}/>) } else if (card.type === 'code') { return (<CodeSandbox card={card} updateConfig={updateConfig} deletecomponent={delCard}/>) } else if (card.type === 'editor') { diff --git a/src/mob/mobshell/index.jsx b/src/mob/mobshell/index.jsx index 0063894..c7b5442 100644 --- a/src/mob/mobshell/index.jsx +++ b/src/mob/mobshell/index.jsx @@ -36,6 +36,25 @@ setCards(_cards) } + const unGroup = (id) => { + let { card, index } = findCard(`${id}`) + let components = [...card.components].map(item => { + if (item.wrap) { + item.wrap.width = card.width + item.width = card.width + } else if (item.plot) { + item.plot.width = card.width + item.width = card.width + } + return item + }) + card.components = [] + + const _cards = update(cards, { $splice: [[index, 1, card, ...components]] }) + + handleList({...menu, components: _cards}) + } + const deleteCard = (id) => { const { card } = findCard(id) @@ -220,6 +239,7 @@ card={card} moveCard={moveCard} delCard={deleteCard} + unGroup={unGroup} findCard={findCard} updateConfig={updateConfig} /> diff --git a/src/pc/menushell/card.jsx b/src/pc/menushell/card.jsx index 085daf7..c0bf99b 100644 --- a/src/pc/menushell/card.jsx +++ b/src/pc/menushell/card.jsx @@ -32,7 +32,7 @@ const AntvG6 = asyncComponent(() => import('@/menu/components/chart/antv-G6')) const Iframe = asyncComponent(() => import('@/menu/components/iframe')) -const Card = ({ id, card, moveCard, findCard, delCard, updateConfig }) => { +const Card = ({ id, card, moveCard, findCard, delCard, unGroup, updateConfig }) => { const originalIndex = findCard(id).index const [{ isDragging }, drag] = useDrag({ item: { type: 'menu', id, originalIndex }, @@ -125,7 +125,7 @@ } else if (card.type === 'table' && card.subtype === 'editable') { return (<EditTable card={card} updateConfig={updateConfig} deletecomponent={delCard}/>) } else if (card.type === 'group' && card.subtype === 'normalgroup') { - return (<NormalGroup group={card} updateConfig={updateConfig} deletecomponent={delCard}/>) + return (<NormalGroup group={card} updateConfig={updateConfig} unGroup={unGroup} deletecomponent={delCard}/>) } else if (card.type === 'editor') { return (<BraftEditor card={card} updateConfig={updateConfig} deletecomponent={delCard}/>) } else if (card.type === 'code') { diff --git a/src/pc/menushell/index.jsx b/src/pc/menushell/index.jsx index 3bd54a3..32b17b4 100644 --- a/src/pc/menushell/index.jsx +++ b/src/pc/menushell/index.jsx @@ -36,6 +36,25 @@ setCards(_cards) } + const unGroup = (id) => { + let { card, index } = findCard(`${id}`) + let components = [...card.components].map(item => { + if (item.wrap) { + item.wrap.width = card.width + item.width = card.width + } else if (item.plot) { + item.plot.width = card.width + item.width = card.width + } + return item + }) + card.components = [] + + const _cards = update(cards, { $splice: [[index, 1, card, ...components]] }) + + handleList({...menu, components: _cards}) + } + const deleteCard = (id) => { const { card } = findCard(id) @@ -173,6 +192,7 @@ card={card} moveCard={moveCard} delCard={deleteCard} + unGroup={unGroup} findCard={findCard} updateConfig={updateConfig} /> diff --git a/src/tabviews/basetable/index.scss b/src/tabviews/basetable/index.scss index 4a12545..ca8acd1 100644 --- a/src/tabviews/basetable/index.scss +++ b/src/tabviews/basetable/index.scss @@ -7,10 +7,7 @@ padding-left: 16px; padding-right: 16px; background-size: 100%; - - .component-wrap >.ant-col { - min-height: 0; - } + .box404 { padding-top: 30px; } diff --git a/src/tabviews/custom/components/module/voucher/assistTable/index.jsx b/src/tabviews/custom/components/module/voucher/assistTable/index.jsx deleted file mode 100644 index 4a5edb7..0000000 --- a/src/tabviews/custom/components/module/voucher/assistTable/index.jsx +++ /dev/null @@ -1,734 +0,0 @@ -import React, {Component} from 'react' -import PropTypes from 'prop-types' -import { is, fromJS } from 'immutable' -import { Table, Modal, Input, InputNumber, notification, message } from 'antd' -// import { EditOutlined } from '@ant-design/icons' - -import Api from '@/api' -import Utils from '@/utils/utils.js' -import MKEmitter from '@/utils/events.js' -import './index.scss' - -class BodyRow extends React.Component { - shouldComponentUpdate (nextProps, nextState) { - return !is(fromJS(this.props.data), fromJS(nextProps.data)) - } - - render() { - let { data, ...resProps } = this.props - let style = {} - let className = '' - - return <tr {...resProps} className={className} style={style}/> - } -} - -class BodyCell extends React.Component { - state = { - editing: false, - } - - shouldComponentUpdate (nextProps, nextState) { - return !is(fromJS(this.props.record), fromJS(nextProps.record)) || - nextState.editing !== this.state.editing - } - - componentDidMount () { - MKEmitter.addListener('tdFocus', this.tdFocus) - } - - /** - * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊锛屾竻闄ゅ揩鎹烽敭璁剧疆 - */ - componentWillUnmount () { - this.setState = () => { - return - } - MKEmitter.removeListener('tdFocus', this.tdFocus) - } - - tdFocus = (id) => { - const { col, record } = this.props - - if (id !== col.uuid + record.uuid) return - - this.focus() - } - - enterPress = () => { - const { col, record } = this.props - const { value } = this.state - - this.setState({editing: false}) - - if (value !== record[col.field]) { - let line = {...record, [col.field]: value} - - if (col.field === 'debtor') { - line.creditor = '' - } else { - line.debtor = '' - } - - MKEmitter.emit('changeRecord', col.tableId, line) - } - - setTimeout(() => { - if (col.field === 'creditor') { - MKEmitter.emit('nextLine', col, record) - } else { - let cl = {remark: 'subject', subject: 'debtor', debtor: 'creditor'} - MKEmitter.emit('tdFocus', cl[col.uuid] + record.uuid) - } - }, 50) - } - - focus = () => { - const { col, record } = this.props - - if (record.type === 'total') return - - this.setState({editing: true, value: record[col.field]}, () => { - let node = document.getElementById(col.uuid + record.uuid) - node && node.select() - }) - } - - onBlur = () => { - const { col, record } = this.props - const { value } = this.state - - this.setState({editing: false}) - - if (value !== record[col.field]) { - let line = {...record, [col.field]: value} - - if (col.field === 'debtor') { - line.creditor = '' - } else { - line.debtor = '' - } - - MKEmitter.emit('changeRecord', col.tableId, line) - } - } - - onChange = (val) => { - this.setState({value: val}) - } - - render() { - let { col, record, className } = this.props - const { editing } = this.state - - let children = null - let colSpan = 1 - - if (col.field === 'remark') { - let val = record.remark || '' - - if (record.type === 'total') { - children = <div className="content-wrap" style={{lineHeight: '60px'}}>鍚堣: {val}</div> - colSpan = 2 - } else { - if (editing) { - children = <Input.TextArea id={col.uuid + record.uuid} autoSize={false} defaultValue={val} onChange={(e) => this.onChange(e.target.value)} onPressEnter={this.enterPress} onBlur={this.onBlur}/> - } else { - children = <div className="content-wrap" onClick={this.focus}>{val}</div> - } - } - } else if (col.field === 'subject') { - if (record.type === 'total') { - colSpan = 0 - } else { - let val = record.subject || '' - - if (editing) { - children = <Input.TextArea id={col.uuid + record.uuid} autoSize={false} defaultValue={val} onChange={(e) => this.onChange(e.target.value)} onPressEnter={this.enterPress} onBlur={this.onBlur}/> - } else { - children = <div className="content-wrap" onClick={this.focus}>{val}</div> - } - } - } else if (col.field === 'debtor') { - let val = record.debtor - let down = false - let vals = [] - if (typeof(val) === 'number') { - if (val < 0) { - down = true - val = Math.abs(val) - } - vals = (val * 100).toFixed(0).split('').reverse() - } - - if (editing) { - children = <InputNumber id={col.uuid + record.uuid} defaultValue={val} onChange={(val) => this.onChange(val)} onPressEnter={this.enterPress} onBlur={this.onBlur}/> - } else { - children = <div className={'money-uint' + (down ? ' down' : '')} onClick={this.focus}> - <span>{vals[10] || ''}</span> <span>{vals[9] || ''}</span> <span>{vals[8] || ''}</span> <span>{vals[7] || ''}</span> <span>{vals[6] || ''}</span> <span>{vals[5] || ''}</span> - <span>{vals[4] || ''}</span> <span>{vals[3] || ''}</span> <span>{vals[2] || ''}</span> <span>{vals[1] || ''}</span> <span className="last">{vals[0] || ''}</span> - </div> - } - } else if (col.field === 'creditor') { - let val = record.creditor - let down = false - let vals = [] - if (typeof(val) === 'number') { - if (val < 0) { - down = true - val = Math.abs(val) - } - vals = (val * 100).toFixed(0).split('').reverse() - } - - if (editing) { - children = <InputNumber id={col.uuid + record.uuid} defaultValue={val} onChange={(val) => this.onChange(val)} onPressEnter={this.enterPress} onBlur={this.onBlur}/> - } else { - children = <div className={'money-uint' + (down ? ' down' : '')} onClick={this.focus}> - <span>{vals[10] || ''}</span> <span>{vals[9] || ''}</span> <span>{vals[8] || ''}</span> <span>{vals[7] || ''}</span> <span>{vals[6] || ''}</span> <span>{vals[5] || ''}</span> - <span>{vals[4] || ''}</span> <span>{vals[3] || ''}</span> <span>{vals[2] || ''}</span> <span>{vals[1] || ''}</span> <span className="last">{vals[0] || ''}</span> - </div> - } - } - - if (!colSpan) return null - - return (<td colSpan={colSpan} className={className}>{children}</td>) - } -} - -class AssistTable extends Component { - static propTpyes = { - config: PropTypes.object, // 鑿滃崟Id - BID: PropTypes.any, // 涓昏〃ID - data: PropTypes.any, // 琛ㄦ牸鏁版嵁 - total: PropTypes.any, // 鎬绘暟 - loading: PropTypes.bool, // 琛ㄦ牸鍔犺浇涓� - refreshdata: PropTypes.func, // 琛ㄦ牸涓帓搴忓垪銆侀〉鐮佺殑鍙樺寲鏃跺埛鏂� - } - - state = { - data: [], - edData: [], - edColumns: [], - tableId: '', // 琛ㄦ牸ID - pageSize: 10, // 姣忛〉鏁版嵁鏉℃暟 - columns: null, // 鏄剧ず鍒� - loading: false, - } - - UNSAFE_componentWillMount () { - const { config } = this.props - - let data = [ - {remark: '鎻愮幇', subject: '1001 搴撳瓨鐜伴噾', debtor: 124, creditor: ''}, - {remark: '璐叆鍥哄畾璧勪骇', subject: '1001 搴撳瓨鐜伴噾', debtor: '', creditor: 124}, - {remark: '杞粨閿�鍞垚鏈�', subject: '1001 搴撳瓨鐜伴噾', debtor: -524, creditor: ''}, - {remark: '鎻愮幇', subject: '1001 搴撳瓨鐜伴噾', debtor: 34, creditor: ''}, - ] - - data = this.initData(data) - data.push(this.getTotalLine(data)) - - let columns = [ - { - title: '鎽樿', - dataIndex: 'remark', - key: 'remark', - width: '22%', - onCell: record => ({ - record, - col: {uuid: 'remark', field: 'remark', tableId: config.uuid}, - }) - }, - { - title: '浼氳绉戠洰', - dataIndex: 'subject', - key: 'subject', - width: '34%', - onCell: record => ({ - record, - col: {uuid: 'subject', field: 'subject', tableId: config.uuid}, - }) - }, - { - title: () => (<> - <div className="money-title">鍊熸柟閲戦</div> - <div className="money-uint"> - <span>浜�</span> <span>鍗�</span> <span>鐧�</span> <span>鍗�</span> <span>涓�</span> <span>鍗�</span> - <span>鐧�</span> <span>鍗�</span> <span>鍏�</span> <span>瑙�</span> <span className="last">鍒�</span> - </div> - </>), - dataIndex: 'debtor', - key: 'debtor', - width: '22%', - onCell: record => ({ - record, - col: {uuid: 'debtor', field: 'debtor', tableId: config.uuid}, - }) - }, - { - title: () => (<> - <div className="money-title">璐锋柟閲戦</div> - <div className="money-uint"> - <span>浜�</span> <span>鍗�</span> <span>鐧�</span> <span>鍗�</span> <span>涓�</span> <span>鍗�</span> - <span>鐧�</span> <span>鍗�</span> <span>鍏�</span> <span>瑙�</span> <span className="last">鍒�</span> - </div> - </>), - dataIndex: 'creditor', - key: 'creditor', - width: '22%', - onCell: record => ({ - record, - col: {uuid: 'creditor', field: 'creditor', tableId: config.uuid}, - }) - } - ] - - this.setState({ - data: data, - edData: fromJS(data).toJS(), - columns, - tableId: config.uuid - }) - } - - shouldComponentUpdate (nextProps, nextState) { - return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) - } - - componentDidMount () { - MKEmitter.addListener('nextLine', this.nextLine) - MKEmitter.addListener('delRecord', this.delRecord) - MKEmitter.addListener('changeRecord', this.changeRecord) - } - - /** - * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊 - */ - componentWillUnmount () { - this.setState = () => { - return - } - MKEmitter.removeListener('nextLine', this.nextLine) - MKEmitter.removeListener('delRecord', this.delRecord) - MKEmitter.removeListener('changeRecord', this.changeRecord) - } - - UNSAFE_componentWillReceiveProps(nextProps) { - if (!is(fromJS(this.props.data), fromJS(nextProps.data))) { - this.setState({data: nextProps.data || []}) - } - } - - initData = (data) => { - let _data = data.map((item, i) => { - item.uuid = Utils.getuuid() - item.index = i - - return item - }) - - if (_data.length < 4) { - for (let i = _data.length - 1; i < 4; i++) { - _data.push({uuid: Utils.getuuid(), index: i + 1, remark: '', subject: '', debtor: '', creditor: ''}) - } - } - return _data - } - - getTotalLine = (data) => { - let totalLine = {uuid: Utils.getuuid(), type: 'total'} - let debtor = '' - let creditor = '' - - data.forEach(item => { - if (typeof(item.debtor) === 'number') { - if (debtor === '') { - debtor = 0 - } - - debtor += item.debtor - } else if (typeof(item.creditor) === 'number') { - if (debtor === '') { - debtor = 0 - } - if (creditor === '') { - creditor = 0 - } - creditor += item.creditor - } - }) - - totalLine.debtor = debtor - totalLine.creditor = creditor - - totalLine.remark = this.changeMoneyToChinese(debtor) - - return totalLine - } - - changeMoneyToChinese = (money) => { - let cnNums = ['闆�', '澹�', '璐�', '鍙�', '鑲�', '浼�', '闄�', '鏌�', '鎹�', '鐜�'] - let cnIntRadice = ['', '鎷�', '浣�', '浠�'] - let cnIntUnits = ['', '涓�', '浜�', '鍏�'] - let cnDecUnits = ['瑙�', '鍒�', '姣�', '鍘�'] - let cnInteger = '鏁�' - let cnIntLast = '鍏�' - let maxNum = 999999999999999.9999 // 鏈�澶у鐞嗙殑鏁板瓧 - let IntegerNum = null - let DecimalNum = null - let ChineseStr = '' - let parts = null // 鍒嗙閲戦鍚庣敤鐨勬暟缁勶紝棰勫畾涔� - let Symbol = '' // 姝h礋鍊兼爣璁� - - if (money === '') return '' - - if (money >= maxNum) return '瓒呭嚭鏈�澶у鐞嗘暟瀛�' - - if (money === 0) { - ChineseStr = cnNums[0] + cnIntLast + cnInteger; - return ChineseStr - } - if(money < 0) { - money = -money - Symbol = '璐�' - } - money = money.toString() // 杞崲涓哄瓧绗︿覆 - if (money.indexOf('.') === -1) { - IntegerNum = money - DecimalNum = '' - } else { - parts = money.split('.') - IntegerNum = parts[0] - DecimalNum = parts[1].substr(0, 4) - } - - if (parseInt(IntegerNum, 10) > 0) { // 鑾峰彇鏁村瀷閮ㄥ垎杞崲 - let zeroCount = 0 - let IntLen = IntegerNum.length - for (let i = 0; i < IntLen; i++) { - let n = IntegerNum.substr(i, 1) - let p = IntLen - i - 1 - let q = p / 4 - let m = p % 4 - - if (n === '0') { - zeroCount++ - } else { - if (zeroCount > 0) { - ChineseStr += cnNums[0] - } - zeroCount = 0 // 褰掗浂 - ChineseStr += cnNums[parseInt(n)] + cnIntRadice[m] - } - - if (m === 0 && zeroCount < 4) { - ChineseStr += cnIntUnits[q] - } - } - ChineseStr += cnIntLast - } - - if (DecimalNum !== '') { // 灏忔暟閮ㄥ垎 - let decLen = DecimalNum.length - - for (let i = 0; i < decLen; i++) { - let n = DecimalNum.substr(i, 1) - if (n !== '0') { - ChineseStr += cnNums[Number(n)] + cnDecUnits[i] - } - } - } - if (ChineseStr === '') { - ChineseStr += cnNums[0] + cnIntLast + cnInteger - } else if (DecimalNum === '') { - ChineseStr += cnInteger - } - - ChineseStr = Symbol + ChineseStr - - return ChineseStr - } - - nextLine = (col, record) => { - const { edData, tableId } = this.state - - if (col.tableId !== tableId) return - - if (record.index < edData.length - 2) { - MKEmitter.emit('tdFocus', 'remark' + edData[record.index + 1].uuid) - } else { - let _data = fromJS(edData).toJS() - let line = {uuid: Utils.getuuid(), index: _data.length - 1, remark: record.remark || '', subject: '', debtor: '', creditor: ''} - - _data.splice(_data.length - 1, 0, line) - - this.setState({edData: _data}, () => { - MKEmitter.emit('tdFocus', 'remark' + line.uuid) - }) - } - } - - plusLine = (initEditLine) => { - const { edData } = this.state - - let item = {...edData[edData.length - 1]} - - item.key = item.key + 1 - item.$$uuid = '$new' - - this.setState({edData: [...edData, item]}, () => { - MKEmitter.emit('tdFocus', initEditLine.uuid + item.uuid) - }) - } - - delRecord = (id, record) => { - const { tableId, edData } = this.state - - if (id !== tableId) return - - let _data = edData.filter(item => item.uuid !== record.uuid) - - _data.pop() - - if (_data.length < 4) { - for (let i = _data.length - 1; i < 4; i++) { - _data.push({uuid: Utils.getuuid(), index: i + 1, remark: '', subject: '', debtor: '', creditor: ''}) - } - } - - _data.push(this.getTotalLine(_data)) - - this.setState({edData: _data}) - } - - changeRecord = (tableId, record) => { - if (tableId !== this.state.tableId) return - - let _data = this.state.edData.map(item => { - if (item.uuid === record.uuid) { - return record - } else { - return item - } - }) - - _data.pop() - - if (record.index === _data.length - 1) { - _data.push({uuid: Utils.getuuid(), index: record.index + 1, remark: '', subject: '', debtor: '', creditor: ''}) - } - - _data.push(this.getTotalLine(_data)) - - this.setState({edData: _data}) - } - - addLine = () => { - const { BID } = this.props - const { edData } = this.state - - let item = {} - if (edData.length > 0) { - item = {...edData[edData.length - 1]} - item.key = item.key + 1 - item.$$uuid = '$new' - } else { - item.key = 0 - item.$$uuid = '$new' - item.$$BID = BID || '' - } - - this.setState({edData: [...edData, item]}) - } - - checkData = () => { - const { edData } = this.state - - if (edData.length === 0) { - notification.warning({ - top: 92, - message: '鎻愪氦鏁版嵁涓嶅彲涓虹┖锛�', - duration: 5 - }) - return - } - let err = '' - let data = fromJS(edData).toJS().map(item => { - // let line = [] - // fields.forEach(col => { - // if (col.editable !== 'true' || item.$deleted) { - // if (col.type === 'number') { - // item[col.field] = +item[col.field] - // if (isNaN(item[col.field])) { - // item[col.field] = 0 - // } - // } else { - // item[col.field] = item[col.field] !== undefined ? (item[col.field] + '') : '' - // } - // return - // } - // if (col.type === 'text') { - // let val = item[col.field] !== undefined ? (item[col.field] + '') : '' - // if (col.required === 'true' && !val) { - // line.push(`${col.label}涓嶅彲涓虹┖`) - // } - // item[col.field] = val - // } else if (col.type === 'number') { - // let val = item[col.field] - // if (!val && val !== 0) { - // line.push(`${col.label}涓嶅彲涓虹┖`) - // return - // } - // val = +val - // if (isNaN(val)) { - // line.push(`${col.label}鏁版嵁鏍煎紡閿欒`) - // return - // } - - // val = +val.toFixed(col.decimal || 0) - - // if (typeof(col.max) === 'number' && val > col.max) { - // line.push(`${col.label}涓嶅彲澶т簬${col.max}`) - // } else if (typeof(col.min) === 'number' && val < col.min) { - // line.push(`${col.label}涓嶅彲灏忎簬${col.min}`) - // } - - // item[col.field] = val - // } - // }) - - return item - }) - - if (err) { - notification.warning({ - top: 92, - message: err, - duration: 5 - }) - } else { - this.submit(data) - } - } - - submit = (data) => { - const { BID } = this.props - - let param = { - // excel_in: result.lines, - BID: BID || '' - } - - this.setState({ - loading: true - }) - - param.func = 'submit.innerFunc' - - Api.genericInterface(param).then((res) => { - if (res.status) { - this.execSuccess(res) - } else { - this.execError(res) - } - }, () => { - this.execError({}) - }) - } - - execSuccess = (res) => { - const { submit } = this.props - - if (res && res.ErrCode === 'S') { // 鎵ц鎴愬姛 - notification.success({ - top: 92, - message: res.ErrMesg || '鎵ц鎴愬姛', - duration: submit.stime ? submit.stime : 2 - }) - } else if (res && res.ErrCode === 'Y') { // 鎵ц鎴愬姛 - Modal.success({ - title: res.ErrMesg || '鎵ц鎴愬姛' - }) - } else if (res && res.ErrCode === '-1') { // 瀹屾垚鍚庝笉鎻愮ず - - } - - this.setState({ - loading: false - }) - - if (submit.closetab === 'true') { - MKEmitter.emit('popclose') - } - if (submit.execSuccess !== 'never') { - MKEmitter.emit('refreshByButtonResult', submit.$menuId, submit.execSuccess, submit) - } - } - - execError = (res) => { - const { submit } = this.props - - if (res.ErrCode === 'E') { - Modal.error({ - title: res.message || res.ErrMesg, - }) - } else if (res.ErrCode === 'N') { - notification.error({ - top: 92, - message: res.message || res.ErrMesg, - duration: submit.ntime ? submit.ntime : 10 - }) - } else if (res.ErrCode === 'F') { - notification.error({ - className: 'notification-custom-error', - top: 92, - message: res.message || res.ErrMesg, - duration: submit.ftime ? submit.ftime : 10 - }) - } else if (res.ErrCode === 'NM') { - message.error(res.message || res.ErrMesg) - } - - this.setState({ - loading: false - }) - - if (submit.execError !== 'never') { - MKEmitter.emit('refreshByButtonResult', submit.$menuId, submit.execError, submit) - } - } - - render() { - const { edData, columns} = this.state - - const components = { - body: { - row: BodyRow, - cell: BodyCell - } - } - - return ( - <div className="voucher-table-wrap"> - <Table - rowKey="uuid" - components={components} - columns={columns} - dataSource={edData} - bordered={true} - // loading={this.props.loading} - onRow={(record, index) => { - return { - data: record - } - }} - pagination={false} - /> - </div> - ) - } -} - -export default AssistTable \ No newline at end of file diff --git a/src/tabviews/custom/components/module/voucher/assistTable/index.scss b/src/tabviews/custom/components/module/voucher/assistTable/index.scss deleted file mode 100644 index e8175c8..0000000 --- a/src/tabviews/custom/components/module/voucher/assistTable/index.scss +++ /dev/null @@ -1,259 +0,0 @@ -.voucher-table-wrap { - position: relative; - padding: 0px; - - .normal-table-footer { - padding: 10px 0px; - color: rgba(0, 0, 0, 0.65); - } - .normal-table-footer.pagination { - position: absolute; - bottom: 10px; - } - >.ant-table-wrapper { - position: relative; - z-index: 1; - } - .ant-table { - color: inherit; - font-size: inherit; - } - - .money-uint { - display: flex; - span { - display: inline-block; - flex: 1; - text-align: center; - font-size: 12px; - } - span:not(.last) { - border-right: 1px solid #e9e9e9; - } - span:nth-child(3), span:nth-child(6) { - border-color: #91d5ff; - } - span:nth-child(9) { - border-color: #ffa39e; - } - } - - table { - max-width: 100%; - width: 100%; - .ant-table-thead { - tr { - th { - position: relative; - background-color: transparent; - padding: 0; - height: 60px; - line-height: 60px; - text-align: center; - - .ant-table-header-column { - display: block; - width: 100%; - height: 100%; - - .ant-table-column-title { - display: block; - width: 100%; - height: 100%; - font-weight: bold; - font-size: 13px; - } - } - .money-title { - line-height: 30px; - font-weight: bold; - font-size: 13px; - } - .money-uint { - line-height: 30px; - border-top: 1px solid #dadada; - } - } - } - } - .ant-table-selection-column { - width: 60px; - min-width: 60px; - max-width: 60px; - } - .ant-table-tbody { - tr td { - position: relative; - background-color: transparent; - padding: 0; - height: 60px; - vertical-align: top; - - .content-wrap { - padding: 5px; - height: 100%; - font-size: 13px; - font-weight: bold; - } - .money-uint { - height: 100%; - line-height: 60px; - - span { - font-size: 14px; - font-weight: bold; - } - } - .money-uint.down { - span { - color: #ff4d4f; - } - } - } - } - } - .ant-input { - height: 60px; - border-radius: 0; - resize: none; - } - .ant-input-number { - height: 60px; - border-radius: 0; - - .ant-input-number-handler-wrap { - display: none; - } - .ant-input-number-input { - border-radius: 0; - height: 60px; - } - } - .editing_table_cell { - .ant-input { - padding: 0px; - position: absolute; - top: 0px; - left: 0px; - right: 0px; - bottom: 0px; - border: 1px solid #1890ff; - } - .ant-input-number-input { - position: absolute; - top: 0px; - left: 0px; - right: 0px; - bottom: 0px; - border: 1px solid #1890ff; - } - .anticon { - color: #ff4d4f; - position: absolute; - right: 3px; - top: calc(50% - 8px); - } - } - td.pointer { - position: relative; - } - td.pointer { - .mk-mask { - display: none; - cursor: pointer; - position: absolute; - top: 0; - left: 0; - bottom: 0; - right: 0; - } - } -} -.edit-custom-table.editable { - td { - background-color: #ffffff!important; - } - td.pointer .mk-mask { - display: block; - } - .mk-operation { - display: none; - } - .ant-table-placeholder { - display: none; - } -} -.edit-custom-table:not(.fixed-height) { - .ant-table-body::-webkit-scrollbar { - width: 8px; - height: 10px; - } - ::-webkit-scrollbar-thumb { - border-radius: 5px; - box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.13); - background: rgba(0, 0, 0, 0.13); - } - ::-webkit-scrollbar-track {/*婊氬姩鏉¢噷闈㈣建閬�*/ - box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.05); - border-radius: 3px; - border: 1px solid rgba(0, 0, 0, 0.07); - background: rgba(0, 0, 0, 0); - } -} -.edit-custom-table.fixed-height { - .ant-table-body { - border-bottom: 1px solid rgba(0, 0, 0, .05); - .ant-table-fixed { - border-bottom: 0; - } - } -} -.edit-custom-table.hidden { - thead { - display: none; - } -} -.edit-custom-table.ghost { - .ant-table-thead > tr { - > th { - color: inherit; - background: transparent; - .ant-table-column-sorter .ant-table-column-sorter-inner { - color: inherit; - } - } - > th:hover { - background: transparent; - } - } - .ant-table-body { - overflow-x: auto; - tr { - td { - background: transparent!important; - } - } - tr:hover td { - background: transparent!important; - } - } -} -.image-scale-modal { - width: 70vw; - min-height: 80vh; - top: 10vh; - .ant-modal-body { - min-height: calc(80vh - 110px); - line-height: calc(80vh - 160px); - text-align: center; - } - .ant-modal-footer { - text-align: center; - span { - display: inline-block; - color: #1890ff; - padding: 5px 15px; - cursor: pointer; - } - } -} \ No newline at end of file diff --git a/src/tabviews/custom/components/module/voucher/index.jsx b/src/tabviews/custom/components/module/voucher/index.jsx index 1b18806..c7cfe01 100644 --- a/src/tabviews/custom/components/module/voucher/index.jsx +++ b/src/tabviews/custom/components/module/voucher/index.jsx @@ -24,7 +24,6 @@ disableAdd: false, disableSave: false, typeOptions: [], - subjects: [], charType: '', charInt: '', vouDate: null, @@ -45,6 +44,8 @@ if (BData) { BID = BData.$BID || '' } + + window.GLOB.CacheVoucher.delete(config.uuid) this.setState({ config: fromJS(config).toJS(), @@ -100,7 +101,7 @@ } loadData = () => { - const { book } = this.state + const { book, config } = this.state if (!book) return @@ -126,8 +127,62 @@ typeOptions: typeOptions, charType: typeOptions[0] ? typeOptions[0].voucher_class : '', charInt: typeOptions[0] ? typeOptions[0].voucher_char_int : '', - subjects: res.subjects || [], }) + + let names = {} + let supplier = [] + let customer = [] + let department = [] + let project = [] + let inventory = [] + let employee = [] + let cash_flow = [] + + res.sup && res.sup.forEach(item => { + names[item.sup_type_code] = item.sup_type_name + }) + + res.supplier && res.supplier.forEach(item => { + supplier.push({value: item.suppliercode, label: item.suppliername}) + }) + + res.customer && res.customer.forEach(item => { + customer.push({value: item.customercode, label: item.customername}) + }) + + res.co_pro && res.co_pro.forEach(item => { + department.push({value: item.co_pro_code, label: item.co_pro_name}) + }) + + res.pm && res.pm.forEach(item => { + project.push({value: item.projectcode, label: item.projectname}) + }) + + res.materiel && res.materiel.forEach(item => { + inventory.push({value: item.productcode, label: item.productname}) + }) + + res.workers && res.workers.forEach(item => { + employee.push({value: item.workercode, label: item.workername}) + }) + + res.cash_flow && res.cash_flow.forEach(item => { + cash_flow.push({value: item.cash_flow_code, label: item.cash_flow_name}) + }) + + let message = { + subjects: res.subjects || [], + names: names, + supplier: supplier, + customer: customer, + department: department, + project: project, + inventory: inventory, + employee: employee, + cash_flow: cash_flow, + } + + window.GLOB.CacheVoucher.set(config.uuid, message) setTimeout(() => { this.getVoucher() @@ -162,7 +217,7 @@ } render() { - const { config, disableSave, disableAdd, typeOptions, charType, charInt, data, vouDate, subjects } = this.state + const { config, disableSave, disableAdd, typeOptions, charType, charInt, data, vouDate } = this.state return ( <div className="menu-voucher-wrap" style={config.style}> @@ -192,7 +247,7 @@ <Button type="link" className="" onClick={this.triggerprint}>澶囨敞</Button> </div> </div> - <VoucherTable config={config} subjects={subjects} data={data}/> + <VoucherTable config={config} data={data}/> </div> : null} {config.wrap.type === 'check' ? <div className="voucher-body"> <div className="pre-wrap"> diff --git a/src/tabviews/custom/components/module/voucher/voucherTable/index.jsx b/src/tabviews/custom/components/module/voucher/voucherTable/index.jsx index 61a3be3..b3baf55 100644 --- a/src/tabviews/custom/components/module/voucher/voucherTable/index.jsx +++ b/src/tabviews/custom/components/module/voucher/voucherTable/index.jsx @@ -1,7 +1,7 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { Table, Modal, Input, InputNumber, notification, message, AutoComplete, Select } from 'antd' +import { Table, Modal, Form, Input, InputNumber, notification, message, AutoComplete, Select, Popover, Button } from 'antd' import { PlusOutlined, CloseOutlined } from '@ant-design/icons' import Api from '@/api' @@ -25,14 +25,102 @@ } } +class Accounting extends React.Component { + state = { + subAccounts: [], + record: null + } + + UNSAFE_componentWillMount() { + const { data, tableId } = this.props + let subAccounts = data.sup_accounting.split(',') + let msg = window.GLOB.CacheVoucher.get(tableId) || {} + let names = msg.names || {} + + subAccounts = subAccounts.map(n => { + let item = { + field: n, + label: names[n] || n, + initval: data[n] || '', + options: [] + } + + if (msg[n]) { + item.options = msg[n] + } + + return item + }) + + this.setState({subAccounts: subAccounts, record: fromJS(data).toJS()}) + } + + selectChange = (val, item) => { + this.setState({record: {...this.state.record, [item.field]: val || ''}}) + } + + getFields() { + const { subAccounts } = this.state + + const fields = [] + + subAccounts.forEach((item) => { + fields.push( + <Form.Item label={item.label} key={item.field}> + <Select + showSearch + allowClear + defaultValue={item.initval} + filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} + onChange={(val) => this.selectChange(val, item)} + > + {item.options.map((option, i) => + <Select.Option key={i} value={option.value}>{option.label}</Select.Option> + )} + </Select> + </Form.Item> + ) + }) + + return fields + } + + confirm = () => { + const { subAccounts, record } = this.state + + let empty = '' + subAccounts.forEach(item => { + if (!empty && !record[item.field]) { + empty = item.label + } + }) + + if (empty) { + notification.warning({ + top: 92, + message: '璇烽�夋嫨' + empty, + duration: 5 + }) + } else { + this.props.confirm(record) + } + } + + render() { + return <div> + {this.getFields()} + <div className="footer"> + <Button onClick={this.props.cancel}>鍙栨秷</Button> + <Button onClick={this.confirm}>纭畾</Button> + </div> + </div> + } +} + class BodyCell extends React.Component { state = { editing: false, - } - - shouldComponentUpdate (nextProps, nextState) { - return !is(fromJS(this.props.record), fromJS(nextProps.record)) || - nextState.editing !== this.state.editing + visible: false, } componentDidMount () { @@ -121,8 +209,6 @@ this.setState({editing: false}) - if (col.field === 'subjectscode') return - if (value !== record[col.field]) { let line = {...record, [col.field]: value} @@ -164,23 +250,73 @@ MKEmitter.emit('delRecord', col.tableId, record) } + onSelectBlur = () => { + const { visible } = this.state + + if (visible) return + + this.setState({editing: false}) + } + onSelectChange = (val, option) => { const { col, record } = this.props - this.setState({editing: false}) - let line = {...record, ...option.props.extra} + + if (record.sup_accounting && !line.sup_accounting) { + record.sup_accounting.split(',').forEach(item => { + line[item] = '' + }) + } MKEmitter.emit('changeRecord', col.tableId, line) + if (line.sup_accounting) { + setTimeout(() => { + this.setState({visible: true}) + }, 100) + } else { + this.setState({editing: false}) + setTimeout(() => { + MKEmitter.emit('tdFocus', 'debtor' + record.uuid) + }, 50) + } + } + + confirm = (res) => { + const { col } = this.props + + MKEmitter.emit('changeRecord', col.tableId, fromJS(res).toJS()) + + this.setState({editing: false, visible: false}) setTimeout(() => { - MKEmitter.emit('tdFocus', 'debtor' + record.uuid) + MKEmitter.emit('tdFocus', 'debtor' + res.uuid) }, 50) } + cancel = () => { + const { col } = this.props + let record = fromJS(this.props.record).toJS() + record.balance_direction = '' + record.count_type = '' + record.foreign_currency_type = '' + record.mnemonic_code = '' + record.subjectscode = '' + record.subjectsname = '' + record.sup_accounting.split(',').forEach(item => { + record[item] = '' + }) + + record.sup_accounting = '' + + MKEmitter.emit('changeRecord', col.tableId, record) + + this.setState({editing: false, visible: false}) + } + render() { - let { col, record, subjects, className } = this.props - const { editing } = this.state + let { col, record, className } = this.props + const { editing, visible } = this.state let children = null let colSpan = 1 @@ -218,21 +354,35 @@ colSpan = 0 } else { if (editing) { - children = <Select - showSearch - defaultValue={record.subjectscode || ''} - dropdownClassName="edit-table-dropdown" - id={col.uuid + record.uuid} - onBlur={this.onBlur} - filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} - onSelect={this.onSelectChange} - > - {subjects.map((item, i) => (<Select.Option key={i} extra={item} value={item.subjectscode}>{item.subjectscode + ' ' + item.subjectsname}</Select.Option>))} - </Select> + let msg = window.GLOB.CacheVoucher.get(col.tableId) + let subjects = msg ? msg.subjects : [] + + children = <> + <Select + showSearch + defaultValue={record.subjectscode || ''} + dropdownClassName="edit-table-dropdown" + id={col.uuid + record.uuid} + onBlur={this.onSelectBlur} + filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} + onSelect={this.onSelectChange} + > + {subjects.map((item, i) => (<Select.Option key={i} extra={item} value={item.subjectscode}>{item.subjectscode + ' ' + item.subjectsname}</Select.Option>))} + </Select> + <Popover overlayClassName="subject-pop-wrap" placement="bottom" title="杈呭姪鏍哥畻" visible={visible} content={<Accounting confirm={this.confirm} cancel={this.cancel} tableId={col.tableId} data={record}/>}> + <span className="pop-anchor"></span> + </Popover> + </> } else { let val = '' if (record.subjectscode) { val = (record.subjectscode || '') + ' ' + (record.subjectsname || '') + + record.sup_accounting && record.sup_accounting.split(',').forEach(item => { + if (record[item]) { + val += '_' + record[item] + } + }) } children = <div className="content-wrap" onClick={this.focus}>{val}</div> } @@ -288,7 +438,6 @@ class VoucherTable extends Component { static propTpyes = { config: PropTypes.object, // 鑿滃崟Id - subjects: PropTypes.array, // 浼氳绉戠洰 BID: PropTypes.any, // 涓昏〃ID data: PropTypes.any, // 琛ㄦ牸鏁版嵁 total: PropTypes.any, // 鎬绘暟 @@ -308,7 +457,7 @@ } UNSAFE_componentWillMount () { - const { config, subjects, data } = this.props + const { config, data } = this.props let columns = [ { @@ -328,7 +477,6 @@ width: '34%', onCell: record => ({ record, - subjects, col: {uuid: 'subjectscode', field: 'subjectscode', tableId: config.uuid}, }) }, @@ -400,33 +548,7 @@ UNSAFE_componentWillReceiveProps(nextProps) { if (!is(fromJS(this.props.data), fromJS(nextProps.data))) { this.resetData(fromJS(nextProps.data).toJS()) - } else if (!is(fromJS(this.props.subjects), fromJS(nextProps.subjects))) { - this.resetSubjects(nextProps.subjects) } - } - - resetSubjects = (subjects) => { - const { config } = this.props - let columns = fromJS(this.state.columns).toJS() - - this.setState({ - columns: columns.map(col => { - if (col.key === 'subjectscode') { - return { - title: '浼氳绉戠洰', - dataIndex: 'subjectscode', - key: 'subjectscode', - width: '34%', - onCell: record => ({ - record, - subjects, - col: {uuid: 'subjectscode', field: 'subjectscode', tableId: config.uuid}, - }) - } - } - return col - }) - }) } resetData = (data) => { diff --git a/src/tabviews/custom/components/module/voucher/voucherTable/index.scss b/src/tabviews/custom/components/module/voucher/voucherTable/index.scss index 987cb80..197baae 100644 --- a/src/tabviews/custom/components/module/voucher/voucherTable/index.scss +++ b/src/tabviews/custom/components/module/voucher/voucherTable/index.scss @@ -229,8 +229,60 @@ display: inline-block; } } + .pop-anchor { + position: absolute; + bottom: 0; + left: 50%; + } } +.subject-pop-wrap { + padding-top: 0px; + .ant-popover-arrow { + display: none; + } + .ant-popover-content { + position: relative; + z-index: 1; + } + .ant-form-item { + display: flex; + margin-bottom: 15px; + width: 200px; + + .ant-form-item-label { + width: 60px; + } + .ant-form-item-control-wrapper { + flex: 1; + .ant-select { + width: 100%; + } + } + } + .ant-popover-inner-content { + padding-right: 30px; + } + .footer { + text-align: right; + .ant-btn { + border: none; + box-shadow: none; + margin-right: 15px; + } + .ant-btn:last-child { + color: var(--mk-sys-color); + } + } +} +.subject-pop-wrap::before { + content: ''; + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; +} .edit-table-dropdown { .ant-select-dropdown-menu-item { white-space: unset; diff --git a/src/tabviews/custom/index.scss b/src/tabviews/custom/index.scss index b01f497..7d331eb 100644 --- a/src/tabviews/custom/index.scss +++ b/src/tabviews/custom/index.scss @@ -7,10 +7,7 @@ padding-left: 16px; padding-right: 16px; background-size: 100%; - - .component-wrap >.ant-col { - min-height: 0; - } + .box404 { padding-top: 30px; } diff --git a/src/tabviews/custom/popview/index.scss b/src/tabviews/custom/popview/index.scss index 6938042..b69e65d 100644 --- a/src/tabviews/custom/popview/index.scss +++ b/src/tabviews/custom/popview/index.scss @@ -7,10 +7,7 @@ padding-left: 16px; padding-right: 16px; background-size: 100%; - - .component-wrap >.ant-col { - min-height: 0; - } + .box404 { padding-top: 30px; } diff --git a/src/templates/sharecomponent/fieldscomponent/index.jsx b/src/templates/sharecomponent/fieldscomponent/index.jsx index 41a9a0a..38fbab2 100644 --- a/src/templates/sharecomponent/fieldscomponent/index.jsx +++ b/src/templates/sharecomponent/fieldscomponent/index.jsx @@ -169,10 +169,12 @@ this.props.updatefield(items) } else if (type === 'form') { - let lastItem = config.fields[config.fields.length - 1] + let firstItem = config.fields[0] let span = this.state.appType === 'mob' ? 24 : 12 - if (lastItem && lastItem.span) { - span = lastItem.span + let labelwidth = 33.3 + if (firstItem && firstItem.span) { + span = firstItem.span + labelwidth = firstItem.labelwidth || 33.3 } selectCards.forEach(item => { // 寰幆娣诲姞鏂板瀛楁 let newcard = { @@ -183,7 +185,7 @@ type: item.type, resourceType: '0', span: span, - labelwidth: 33.3, + labelwidth: labelwidth, options: [], dataSource: '', decimal: item.decimal, @@ -195,17 +197,19 @@ if (item.type === 'text' && item.length >= 256) { newcard.type = 'textarea' newcard.fieldlength = item.length - if (lastItem && lastItem.type === newcard.type) { - newcard.span = lastItem.span - newcard.labelwidth = lastItem.labelwidth - } else if (lastItem) { - newcard.span = 24 - if (lastItem.span === 12) { - newcard.labelwidth = 16.2 - } else if (lastItem.span === 8) { - newcard.labelwidth = 10.5 - } else if (lastItem.span === 8) { - newcard.labelwidth = 7.7 + if (firstItem) { + if (firstItem.type === newcard.type) { + newcard.span = firstItem.span + newcard.labelwidth = firstItem.labelwidth + } else { + newcard.span = 24 + if (firstItem.span === 12) { + newcard.labelwidth = 16.2 + } else if (firstItem.span === 8) { + newcard.labelwidth = 10.5 + } else if (firstItem.span === 6) { + newcard.labelwidth = 7.7 + } } } else { newcard.span = 24 diff --git a/src/templates/zshare/modalform/modaleditable/index.jsx b/src/templates/zshare/modalform/modaleditable/index.jsx index 3e076af..9edfdf9 100644 --- a/src/templates/zshare/modalform/modaleditable/index.jsx +++ b/src/templates/zshare/modalform/modaleditable/index.jsx @@ -1,7 +1,7 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { Table, Input, Popconfirm, Form, Radio, message } from 'antd' +import { Table, Input, Popconfirm, Form, message } from 'antd' import { ArrowUpOutlined, ArrowDownOutlined, DeleteOutlined, PlusOutlined, SwapOutlined } from '@ant-design/icons' import { formRule } from '@/utils/option.js' @@ -140,27 +140,9 @@ }) } - getColumnSearchProps = column => ({ - filterDropdown: () => ( - <div style={{ padding: 8 }}> - <Radio.Group onChange={(e) => this.changeDatatype(column, e)} value={column.datatype}> - <Radio style={{display: 'block', height: '30px', lineHeight: '30px'}} value="string"> - 瀛楃涓� - </Radio> - <Radio style={{display: 'block', height: '30px', lineHeight: '30px'}} value="number"> - 鏁板瓧 - </Radio> - </Radio.Group> - </div> - ), - filterIcon: () => ( - <SwapOutlined style={{ color: column.datatype === 'number' ? '#1890ff' : ''}} /> - ) - }) - - changeDatatype = (column, e) => { + changeDatatype = (column) => { const { columns, dataSource } = this.state - let value = e.target.value + let value = column.datatype !== 'number' ? 'number' : 'string' let _data = dataSource.map(item => { let val = item[column.dataIndex] if (value === 'number') { @@ -185,7 +167,16 @@ } if (col.dataIndex !== 'operation') { - col = {...col, ...this.getColumnSearchProps(col)} + col.title = <div> + Value + <Popconfirm + title={`纭畾鍒囨崲涓�${col.datatype === 'number' ? '鏂囨湰' : '鏁板��'}鍚楋紵`} + overlayClassName="popover-confirm" + onConfirm={() => this.changeDatatype(col) + }> + <SwapOutlined style={{ color: col.datatype === 'number' ? '#1890ff' : ''}} /> + </Popconfirm> + </div> } return col @@ -376,7 +367,16 @@ return { columns: columns.map(col => { if (col.dataIndex !== 'operation') { - col = {...col, ...this.getColumnSearchProps(col)} + col.title = <div> + Value + <Popconfirm + title={`纭畾鍒囨崲涓�${col.datatype === 'number' ? '鏂囨湰' : '鏁板��'}鍚楋紵`} + overlayClassName="popover-confirm" + onConfirm={() => this.changeDatatype(col) + }> + <SwapOutlined style={{ color: col.datatype === 'number' ? '#1890ff' : ''}} /> + </Popconfirm> + </div> } return col }), diff --git a/src/templates/zshare/modalform/modaleditable/index.scss b/src/templates/zshare/modalform/modaleditable/index.scss index ab53b8e..c802fbe 100644 --- a/src/templates/zshare/modalform/modaleditable/index.scss +++ b/src/templates/zshare/modalform/modaleditable/index.scss @@ -17,6 +17,15 @@ } .ant-table-thead > tr > th { padding: 10px 16px; + position: relative; + + .anticon-swap { + position: absolute; + right: 16px; + font-size: 14px; + top: 12px; + color: #b8b8b8; + } } .ant-table-tbody > tr > td { padding: 5px 10px; diff --git a/src/views/billprint/index.jsx b/src/views/billprint/index.jsx index 1b0e280..8b1b229 100644 --- a/src/views/billprint/index.jsx +++ b/src/views/billprint/index.jsx @@ -886,7 +886,7 @@ <div className="bill-print-wrap" > {loadingview && <Spin size="large" />} {pages ? <div id="bill-print"> - {pages.map((components, index) => (<div className={'print-page' + (auto ? ' auto' : '')} key={index} style={{...config.style, overflow: 'hidden', boxSizing: 'border-box'}}><Row>{this.getComponents(components)}</Row></div>))} + {pages.map((components, index) => (<div className={'print-page' + (auto ? ' auto' : '')} key={index} style={{...config.style, overflow: 'hidden', boxSizing: 'border-box'}}><Row className="component-wrap">{this.getComponents(components)}</Row></div>))} </div> : null} {viewlost ? <NotFount msg={this.state.lostmsg} /> : null} {config && window.GLOB.breakpoint ? <DebugTable /> : null} -- Gitblit v1.8.0