From 3620d67cfd2f2af19ef4d656734badd4445c90b8 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 14 二月 2023 18:35:16 +0800 Subject: [PATCH] 2023-02-14 --- src/tabviews/custom/components/module/voucher/resetAttach/index.jsx | 110 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 89 insertions(+), 21 deletions(-) diff --git a/src/tabviews/custom/components/module/voucher/resetAttach/index.jsx b/src/tabviews/custom/components/module/voucher/resetAttach/index.jsx index 969f343..fcbcb81 100644 --- a/src/tabviews/custom/components/module/voucher/resetAttach/index.jsx +++ b/src/tabviews/custom/components/module/voucher/resetAttach/index.jsx @@ -1,6 +1,6 @@ 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' @@ -23,15 +23,11 @@ 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 = () => { @@ -40,23 +36,66 @@ } 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 @@ -89,7 +128,7 @@ typename: config.name, UserName: sessionStorage.getItem('User_Name') || '', FullName: sessionStorage.getItem('Full_Name') || '', - BID: book.id + BID: res.BID } Api.genericInterface(param).then(result => { @@ -108,14 +147,15 @@ 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}) }) }) } @@ -160,11 +200,38 @@ } 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 ( <> @@ -180,8 +247,9 @@ 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}> -- Gitblit v1.8.0