From f3d4db769ba9b51b799d981511a710fd443d0e08 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 21 四月 2025 12:18:03 +0800 Subject: [PATCH] Merge branch 'master' into positec --- src/tabviews/custom/components/module/account/index.jsx | 203 +++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 165 insertions(+), 38 deletions(-) diff --git a/src/tabviews/custom/components/module/account/index.jsx b/src/tabviews/custom/components/module/account/index.jsx index 8438606..0218232 100644 --- a/src/tabviews/custom/components/module/account/index.jsx +++ b/src/tabviews/custom/components/module/account/index.jsx @@ -1,12 +1,17 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -// import { Button, Select, Input, DatePicker } from 'antd' -// import { EditOutlined, ToolOutlined, DeleteOutlined, FontColorsOutlined } from '@ant-design/icons' +import { notification, Select, Divider, Modal } from 'antd' +import { PlusOutlined } from '@ant-design/icons' +import moment from 'moment' import Api from '@/api' -// import MKEmitter from '@/utils/events.js' +import Utils from '@/utils/utils.js' +import MKEmitter from '@/utils/events.js' import './index.scss' + +const { Option } = Select +const { confirm } = Modal class AccountModule extends Component { static propTpyes = { @@ -14,37 +19,13 @@ } state = { - BID: '', - type: '', - config: null - } - - UNSAFE_componentWillMount () { - const { config } = this.props - - let BID = '' - let BData = '' - - if (config.wrap.supModule) { - BData = window.GLOB.CacheData.get(config.wrap.supModule) - } else { - BData = window.GLOB.CacheData.get(config.$pageId) - } - if (BData) { - BID = BData.$BID || '' - } - - this.setState({ - config: fromJS(config).toJS(), - BID: BID || '', - type: config.wrap.type - }, () => { - this.loadData() - }) + activeItem: null, + books: [] } componentDidMount () { - + this.loadData() + MKEmitter.addListener('reloadData', this.reloadData) } shouldComponentUpdate (nextProps, nextState) { @@ -58,26 +39,172 @@ this.setState = () => { return } + MKEmitter.removeListener('reloadData', this.reloadData) + } + + reloadData = (menuId) => { + const { config } = this.props + const { activeItem } = this.state + + if (config.uuid !== menuId) return + + if (activeItem) { + MKEmitter.emit('resetSelectLine', config.uuid, activeItem.id, activeItem) + } else { + this.loadData() + } } loadData = () => { let param = { - func: 's_get_fcc_account_data' + func: 's_get_fcc_book_data', + dataM: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', + mk_organization: sessionStorage.getItem('organization') || '' } - Api.genericInterface(param) - let _param = { - func: 's_get_fcc_book_data' + Api.genericInterface(param).then(res => { + if (!res.status) { + notification.warning({ + top: 92, + message: res.message, + duration: 5 + }) + return + } + + let books = res.book || [] + let activeItem = null + let map = new Map() + books = books.filter(item => { + if (!item.id) return false + if (map.has(item.id)) return false + map.set(item.id, true) + + if (item.selected === 'true' && !activeItem) { + if (res.invoice_type) { + item.invoice_type = res.invoice_type.map(cell => ({value: cell.invoice_type_code, label: cell.invoice_type_name})) + } + item.$$uuid = item.id + activeItem = item + } + if (item.months) { + item.date = item.months.replace('-', '骞�') + '鏈�' + } + return true + }) + + this.setState({books, activeItem}) + + if (activeItem) { + MKEmitter.emit('resetSelectLine', this.props.config.uuid, activeItem.id, activeItem) + } + }) + } + + changeBook = (value) => { + const { books, activeItem } = this.state + + let Item = books.filter(item => item.id === value)[0] + + if (!activeItem && Item) { + this.setBook(Item) + } else if (Item) { + const that = this + confirm({ + title: '纭畾鍒囨崲璐﹀鍚楋紵', + content: '鍒囨崲璐﹀鏃剁郴缁熼渶瑕佸埛鏂般��', + onOk() { + return new Promise(resolve => { + that.setBook(Item, resolve) + }) + }, + onCancel() {} + }) } - Api.genericInterface(_param) + } + + setBook = (item, resolve) => { + const { config } = this.props + + if (!resolve) { + this.setState({activeItem: item}) + + MKEmitter.emit('resetSelectLine', config.uuid, item.id, item) + } + + let userid = sessionStorage.getItem('UserID') || '' + let sid = localStorage.getItem('SessionUid') || '' + let param = { + func: 'sPC_TableData_InUpDe', + LText: `delete tmp_session_show_key where createuserid='${userid}' and key_type='fcc_years' + insert into tmp_session_show_key ( key_id,key_type,createuserid,CreateUser,CreateStaff) + select '${item.id}','fcc_years','${userid}','${sid}','${sessionStorage.getItem('Full_Name') || ''}'`, + exec_type: window.GLOB.execType || 'y' + } + + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + param.secretkey = Utils.encrypt('', param.timestamp) + param.LText = Utils.formatOptions(param.LText, param.exec_type) + + Api.genericInterface(param).then(res => { + if (!res.status) { + notification.warning({ + top: 92, + message: res.message, + duration: 5 + }) + resolve && resolve() + return + } + + if (resolve) { + sessionStorage.setItem('ThirdMenu', config.$pageId) + window.location.reload() + } + }) + } + + addBook = () => { + const { config } = this.props + + let menu = { + MenuID: config.wrap.MenuID, + MenuName: config.wrap.MenuName, + type: config.wrap.tabType, + param: {} + } + + if (window.GLOB.mkThdMenus.has(config.wrap.MenuID)) { + menu = {...window.GLOB.mkThdMenus.get(config.wrap.MenuID), param: {}} + } + + MKEmitter.emit('modifyTabs', menu, true) } render() { - const { config } = this.state + const { config } = this.props + const { activeItem, books } = this.state return ( <div className="menu-account-wrap" style={config.style}> - + {config.wrap.MenuID ? <Select dropdownMatchSelectWidth={false} showSearch filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} value={activeItem ? activeItem.id : ''} placeholder="璇烽�夋嫨璐﹀" onChange={this.changeBook} dropdownRender={menu => ( + <div> + {menu} + <Divider style={{ margin: '4px 0' }} /> + <div className="mk-add-book" onMouseDown={this.addBook}> + <PlusOutlined /> 鐐瑰嚮鏂板璐﹀ + </div> + </div> + )}> + {books.map(item => ( + <Option disabled={!item.months} title={item.account_name} key={item.id}>{item.account_name}</Option> + ))} + </Select> : <Select dropdownMatchSelectWidth={false} showSearch filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} value={activeItem ? activeItem.id : ''} disabled={config.wrap.readonly === 'true'} placeholder="璇烽�夋嫨璐﹀" onChange={this.changeBook}> + {books.map(item => ( + <Option disabled={!item.months} title={item.account_name} key={item.id}>{item.account_name}</Option> + ))} + </Select>} + {activeItem ? <span className="date">{activeItem.date}</span> : null} </div> ) } -- Gitblit v1.8.0