| | |
| | | |
| | | list = list.map(item => { |
| | | item.icon = this.getIcon(item.attachments_url) |
| | | item.name = this.getName(item.attachments_url) |
| | | return item |
| | | }) |
| | | |
| | |
| | | file.attachments = file.attachments.map(item => { |
| | | item.id = item.attach_id |
| | | item.icon = this.getIcon(item.attachments_url) |
| | | item.name = this.getName(item.attachments_url) |
| | | item.data_code = file.data_code |
| | | item.data_name = file.data_name |
| | | item.BID = file.id |
| | |
| | | } |
| | | |
| | | item.icon = this.getIcon(res.url) |
| | | item.name = this.getName(res.url) |
| | | |
| | | list.push(item) |
| | | |
| | |
| | | |
| | | deleteFile = (id) => { |
| | | this.setState({list: this.state.list.filter(item => item.id !== id)}) |
| | | } |
| | | |
| | | getName = (url) => { |
| | | if (!url || !/\//.test(url)) return url |
| | | |
| | | let names = url.split('/') |
| | | |
| | | return names[names.length - 1] |
| | | } |
| | | |
| | | getIcon = (url) => { |
| | |
| | | docSubmit = () => { |
| | | const { selectDocs, list } = this.state |
| | | |
| | | |
| | | if (selectDocs.length > 0 && list.length > 0) { |
| | | let _list = fromJS(list).toJS() |
| | | let err = '' |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { disabled } = this.props |
| | | const { visible, upVisible, docVisible, files, list, documents, loading } = this.state |
| | | |
| | | return ( |
| | |
| | | title="添加附件" |
| | | wrapClassName="voucher-attach-wrap" |
| | | visible={visible} |
| | | width={700} |
| | | width={'62vw'} |
| | | maskClosable={false} |
| | | onOk={this.submit} |
| | | onCancel={() => { this.setState({ visible: false })}} |
| | |
| | | destroyOnClose |
| | | > |
| | | {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> |
| | | <Button type="link" className="attach-type-btn" disabled={loading || disabled} onClick={() => this.setState({upVisible: true})}>上传新文件</Button> |
| | | <Button type="link" className="attach-type-btn" disabled={loading || disabled} onClick={() => this.setState({docVisible: true, selectDocs: []})}>从会计电子档案选择</Button> |
| | | <div className="attach-selected-list"> |
| | | {list.map(item => { |
| | | return <div className="attach-item" key={item.id}> |
| | | <img src={item.icon} alt=""/> |
| | | <div className="attach-msg"> |
| | | <div>{item.attachments_title}</div> |
| | | <div>{item.data_name ? item.data_name + ' / ' : ''}{item.name}</div> |
| | | {/* <div>{item.attachments_title}</div> */} |
| | | <div>{item.data_name ? item.data_name + ' / ' : ''}{item.attachments_title}</div> |
| | | </div> |
| | | <div> |
| | | <DeleteOutlined onClick={() => this.deleteFile(item.id)}/> |
| | | {!disabled ? <DeleteOutlined onClick={() => this.deleteFile(item.id)}/> : null} |
| | | </div> |
| | | </div> |
| | | })} |
| | |
| | | title="添加附件" |
| | | wrapClassName="voucher-attach-add-wrap" |
| | | visible={upVisible} |
| | | width={700} |
| | | width={'62vw'} |
| | | maskClosable={false} |
| | | onOk={this.upSubmit} |
| | | onCancel={() => { this.setState({ upVisible: false })}} |
| | |
| | | title="电子档案" |
| | | wrapClassName="voucher-attach-document-wrap" |
| | | visible={docVisible} |
| | | width={700} |
| | | width={'62vw'} |
| | | maskClosable={false} |
| | | onOk={this.docSubmit} |
| | | onCancel={() => { this.setState({ docVisible: false, selectDocs: [] })}} |
| | | destroyOnClose |
| | | > |
| | | {docVisible ? <Documents documents={documents} onChange={(vals) => this.setState({selectDocs: vals})}/> : null} |
| | | {docVisible ? <Documents documents={documents} list={list} onChange={(vals) => this.setState({selectDocs: vals})}/> : null} |
| | | </Modal> |
| | | </> |
| | | ) |