| | |
| | | import React, {Component} from 'react' |
| | | import { fromJS } from 'immutable' |
| | | import { Button, Modal, notification } from 'antd' |
| | | import { Button, Modal, notification, Spin } from 'antd' |
| | | import moment from 'moment' |
| | | import { DeleteOutlined } from '@ant-design/icons' |
| | | // import md5 from 'md5' |
| | |
| | | visible: false, |
| | | upVisible: false, |
| | | docVisible: false, |
| | | files: [{data_code: 'ddd', data_name: '凭证'}], |
| | | files: [], |
| | | list: [], |
| | | documents: [ |
| | | {id: '1223', folder: '凭证附件', icon: excelImg, attachments_title: '主表20230130173553.xlsx', attachments_url: 'http://主表20230130173553.xlsx'}, |
| | | {id: '1224', folder: '凭证附件', icon: excelImg, attachments_title: '主表2sdfsafjifjiji.xlsx', attachments_url: 'http://主表2sdfsafjifjiji.xlsx'}, |
| | | {id: '1225', folder: '凭证附件', icon: excelImg, attachments_title: '主表20230sjiejgiej.xlsx', attachments_url: 'http://主表20230sjiejgiej.xlsx'}, |
| | | {id: '1227', folder: '回执', icon: excelImg, attachments_title: '主表2023sdfrgtgfgd.xlsx', attachments_url: 'http://主表2023sdfrgtgfgd.xlsx'}, |
| | | ], |
| | | selectDocs: [] |
| | | documents: [], |
| | | selectDocs: [], |
| | | loading: false |
| | | } |
| | | |
| | | submit = () => { |
| | |
| | | } |
| | | |
| | | trigger = () => { |
| | | const { attachlist } = this.props |
| | | let list = fromJS(attachlist).toJS() |
| | | const { voucherCode, orgcode } = this.props |
| | | let list = fromJS(this.props.attachlist).toJS() |
| | | |
| | | list = list.map(item => { |
| | | item.icon = this.getIcon(item.attachments_url) |
| | | return item |
| | | }) |
| | | |
| | | this.setState({visible: true, list: list}) |
| | | this.setState({visible: true, loading: true, list: list, files: [], documents: []}) |
| | | |
| | | let param = { |
| | | func: 's_get_fcc_voucher_attachments', |
| | | voucher_code: voucherCode || '', |
| | | orgcode: orgcode |
| | | } |
| | | |
| | | Api.genericInterface(param).then(result => { |
| | | this.setState({loading: false}) |
| | | |
| | | if (!result.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | if (result.fcc_files) { |
| | | let files = [] |
| | | let documents = [] |
| | | |
| | | result.fcc_files.forEach(file => { |
| | | files.push({data_code: file.data_code, data_name: file.data_name, id: file.id}) |
| | | |
| | | file.attachments = file.attachments.map(item => { |
| | | item.id = item.attach_id |
| | | item.icon = this.getIcon(item.attachments_url) |
| | | item.data_code = file.data_code |
| | | item.data_name = file.data_name |
| | | item.BID = file.id |
| | | |
| | | return item |
| | | }) |
| | | |
| | | documents.push(file) |
| | | }) |
| | | |
| | | this.setState({files, documents}) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | upSubmit = () => { |
| | | const { config, book, orgcode } = this.props |
| | | const { config, orgcode } = this.props |
| | | |
| | | if (!book) { |
| | | if (!orgcode) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请选择账套!', |
| | | message: '公司编码不可为空!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | |
| | | typename: config.name, |
| | | UserName: sessionStorage.getItem('User_Name') || '', |
| | | FullName: sessionStorage.getItem('Full_Name') || '', |
| | | BID: book.id |
| | | BID: res.BID |
| | | } |
| | | |
| | | Api.genericInterface(param).then(result => { |
| | |
| | | data_code: res.data_code, |
| | | data_name: res.data_name, |
| | | attachments_title: res.attachments_title, |
| | | attachments_url: res.url |
| | | attachments_url: res.url, |
| | | BID: res.BID |
| | | } |
| | | |
| | | item.icon = this.getIcon(res.url) |
| | | |
| | | list.push(item) |
| | | |
| | | this.setState({list: list}) |
| | | this.setState({list: list, upVisible: false}) |
| | | }) |
| | | }) |
| | | } |
| | |
| | | } |
| | | |
| | | docSubmit = () => { |
| | | const { selectDocs, list } = this.state |
| | | |
| | | |
| | | if (selectDocs.length > 0 && list.length > 0) { |
| | | let _list = fromJS(list).toJS() |
| | | let err = '' |
| | | let ids = list.map(item => item.id) |
| | | |
| | | selectDocs.forEach(item => { |
| | | if (!ids.includes(item.id)) { |
| | | _list.push(item) |
| | | } else { |
| | | err += (err ? '、' : '') + item.attachments_title |
| | | } |
| | | }) |
| | | |
| | | this.setState({list: _list, docVisible: false}) |
| | | |
| | | if (err) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '文件' + err + '已添加。', |
| | | duration: 5 |
| | | }) |
| | | } |
| | | } else { |
| | | this.setState({list: [...list, ...selectDocs], docVisible: false}) |
| | | } |
| | | } |
| | | |
| | | render() { |
| | | const { visible, upVisible, docVisible, files, list, documents } = this.state |
| | | const { visible, upVisible, docVisible, files, list, documents, loading } = this.state |
| | | |
| | | return ( |
| | | <> |
| | |
| | | cancelText="" |
| | | destroyOnClose |
| | | > |
| | | <Button type="link" className="attach-type-btn" onClick={() => this.setState({upVisible: true})}>上传新文件</Button> |
| | | <Button type="link" className="attach-type-btn" onClick={() => this.setState({docVisible: true, selectDocs: []})}>从会计电子档案选择</Button> |
| | | {loading ? <Spin /> : null} |
| | | <Button type="link" className="attach-type-btn" disabled={loading} onClick={() => this.setState({upVisible: true})}>上传新文件</Button> |
| | | <Button type="link" className="attach-type-btn" disabled={loading} onClick={() => this.setState({docVisible: true, selectDocs: []})}>从会计电子档案选择</Button> |
| | | <div className="attach-selected-list"> |
| | | {list.map(item => { |
| | | return <div className="attach-item" key={item.id}> |