From f0bf8c399c354c22227f8f1a76ed806098db59c0 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 21 五月 2024 16:51:02 +0800 Subject: [PATCH] 2024-05-21 --- src/tabviews/custom/components/module/voucher/index.jsx | 301 ++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 231 insertions(+), 70 deletions(-) diff --git a/src/tabviews/custom/components/module/voucher/index.jsx b/src/tabviews/custom/components/module/voucher/index.jsx index 8c282b4..0fd7ac5 100644 --- a/src/tabviews/custom/components/module/voucher/index.jsx +++ b/src/tabviews/custom/components/module/voucher/index.jsx @@ -12,10 +12,8 @@ import ResetRemark from './resetRemark' import ResetAttach from './resetAttach' import LoadFromTemp from './loadFromTemp' -import asyncComponent from '@/utils/asyncComponent' import './index.scss' -const PrintVoucher = asyncComponent(() => import('./printVoucher')) const { confirm } = Modal class VoucherModule extends Component { @@ -39,6 +37,8 @@ username: sessionStorage.getItem('User_Name'), remark: '', attachments: 0, + vouAduited: false, + vouReadOnly: false, attachlist: [], oriAttachs: [], tempTypes: [], @@ -304,6 +304,7 @@ let data = [] if (res.voucher) { + let disabled = res.voucher_status === 'true' data = res.voucher.map(line => { line.uuid = line.subject_id || '' @@ -320,6 +321,7 @@ line.exratename = line.foreign_exratename || '' line.local_currency = line.local_exratecode || '' line.foreign_currency_type = line.foreign_type || '' + line.$disabled = disabled if (line.sup) { line.supAccounts = line.sup.map(cell => { @@ -351,7 +353,9 @@ data: data, attachlist: files, vouDate: res.fibvoucherdate ? moment(res.fibvoucherdate, 'YYYY-MM-DD') : null, - charType: res.voucher_class, + charType: res.voucher_class || 'keeping', + vouAduited: res.voucher_status === 'true' || res.read_only === 'true', + vouReadOnly: res.read_only === 'true', charName: res.voucher_char, charInt: res.voucher_char_int, // orgcode: res.orgcode, @@ -1059,10 +1063,6 @@ this.setState({status: 'change', attachlist: vals, attachments: num}) } - triggermore = () => { - - } - triggerclose = () => { const { config, status } = this.state @@ -1139,72 +1139,233 @@ }) } - render() { - const { type, status, loading, config, orgcode, orgname, typeOptions, tempTypes, charType, charName, charInt, data, vouDate, username, remark, attachments, title, attachlist, tempTypeClass } = this.state + triggerPrint = () => { + const { config, BID } = this.state - return ( - <div className="menu-voucher-wrap" style={config.style}> - {type === 'createVoucher' ? <div className="voucher-header"> - <Button className="add-background header-btn" disabled={status === 'empty'} onClick={() => this.triggersave('add')}>淇濆瓨骞舵柊澧�</Button> - <Button className="add-background header-btn" disabled={status === 'empty' || status === 'saved'} onClick={() => this.triggersave()}>淇濆瓨</Button> - <PrintVoucher ID={config.uuid + 'print'} data={data} orgname={orgname} vouDate={vouDate} charName={charName} charInt={charInt} attachments={attachments} disabled={status !== 'saved'}/> - <Dropdown overlay={<div className="mk-voucher-dropdown-wrap"> - <SaveAsTemp tempTypes={tempTypes} onChange={this.triggerTempsave}/> - <div className="split"></div> - <LoadFromTemp tempTypes={tempTypes} onChange={this.triggerTempLoad}/> - </div>} trigger={['click']}> - <Button className="out-background header-btn" onClick={this.triggermore}>鏇村</Button> - </Dropdown> - </div> : null} - {type === 'checkVoucher' ? <div className="voucher-header"> - <Button className="add-background header-btn" disabled={status === 'empty' || status === 'saved'} onClick={() => this.triggersave()}>淇濆瓨</Button> - <PrintVoucher ID={config.uuid + 'print'} data={data} orgname={orgname} vouDate={vouDate} charName={charName} charInt={charInt} attachments={attachments} disabled={status !== 'saved'}/> - <Button className="out-background header-btn" onClick={this.triggerclose}>鍏抽棴</Button> - </div> : null} - <div className="voucher-body" style={{padding: `0px ${config.wrap.space || 0}px`}}> - {type === 'createVoucher' || type === 'checkVoucher' ? <div className="pre-wrap"> - <div className="voucher-code"> - <Select value={charType} dropdownClassName="mk-vcode-dropdown" onChange={(val, option) => this.setState({status: 'change', charType: val, charName: option.props.charName, charInt: option.props.charint})}> - {typeOptions.map(option => - <Select.Option key={option.id} value={option.voucher_class} charName={option.voucher_char} charint={option.voucher_char_int}>{option.voucher_char}</Select.Option> - )} - </Select> - <InputNumber precision={0} min={1} value={charInt} autoComplete="off" onChange={(val) => this.setState({status: 'change', charInt: val})}/> 鍙� + if (!config.wrap.printTemp) { + notification.warning({ + top: 92, + message: '灏氭湭璁剧疆鎵撳嵃妯℃澘锛�', + duration: 5 + }) + return + } + + window.open('#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify({ id: BID, tempId: config.wrap.printTemp, pageId: config.$pageId || '', dataM: sessionStorage.getItem('dataM') })))) + } + + triggerAduit = () => { + const { book, BID, voucherCode, username } = this.state + + if (!book) { + notification.warning({ + top: 92, + message: '璇烽�夋嫨璐﹀锛�', + duration: 5 + }) + return + } + + let param = { + func: 's_fcc_voucher_sub', + ID: BID, + status: 10, + statusname: '宸插鏍�', + voucher_code: voucherCode || '', + username: username, + fullname: sessionStorage.getItem('Full_Name') || '' + } + + const that = this + + confirm({ + content: '纭畾瑕佸鏍稿悧锛�', + onOk() { + Api.genericInterface(param).then(res => { + if (!res.status) { + notification.warning({ + top: 92, + message: res.message, + duration: 5 + }) + return + } + + notification.success({ + top: 92, + message: '宸茬粡閫氳繃瀹℃牳', + duration: 2 + }) + + that.getVoucher() + }) + }, + onCancel() {} + }) + } + + triggerUnAduit = () => { + const { book, BID, voucherCode, username } = this.state + + if (!book) { + notification.warning({ + top: 92, + message: '璇烽�夋嫨璐﹀锛�', + duration: 5 + }) + return + } + + let param = { + func: 's_fcc_voucher_sub', + ID: BID, + status: 0, + statusname: '鍙栨秷瀹℃牳', + voucher_code: voucherCode || '', + username: username, + fullname: sessionStorage.getItem('Full_Name') || '' + } + + const that = this + + confirm({ + content: '纭瑕佸彇娑堝鏍稿悧锛�', + onOk() { + Api.genericInterface(param).then(res => { + if (!res.status) { + notification.warning({ + top: 92, + message: res.message, + duration: 5 + }) + return + } + + notification.success({ + top: 92, + message: '瀹℃牳宸插彇娑�', + duration: 2 + }) + + that.getVoucher() + }) + }, + onCancel() {} + }) + } + + render() { + const { type, status, loading, config, orgcode, typeOptions, tempTypes, charType, charInt, data, vouDate, username, remark, attachments, title, attachlist, tempTypeClass, vouAduited, vouReadOnly, voucherCode } = this.state + + if (type === 'checkVoucher') { + return ( + <div className="menu-voucher-wrap" style={config.style}> + <div className="voucher-header" style={{padding: `10px ${config.wrap.space || 0}px`}}> + {!vouAduited ? <Button disabled={status === 'empty' || status === 'saved'} onClick={() => this.triggersave()}>淇濆瓨</Button> : null} + {/* <PrintVoucher ID={config.uuid + 'print'} data={data} orgname={orgname} vouDate={vouDate} charName={charName} charInt={charInt} attachments={attachments} disabled={status !== 'saved'}/> */} + <Button disabled={status !== 'saved'} onClick={this.triggerPrint}>鎵撳嵃</Button> + {vouAduited && !vouReadOnly ? <Button onClick={this.triggerUnAduit}>鍙栨秷瀹℃牳</Button> : null} + {!vouAduited && !vouReadOnly ? <Button onClick={this.triggerAduit}>瀹℃牳</Button> : null} + <Button onClick={this.triggerclose}>鍏抽棴</Button> + </div> + <div className="voucher-body" style={{padding: `0px ${config.wrap.space || 0}px`}}> + <div className="pre-wrap"> + <div className="voucher-number"> + 鍑瘉鍙凤細{voucherCode} + </div> + <div className="voucher-code"> + <Select value={charType} disabled={vouAduited} dropdownClassName="mk-vcode-dropdown" onChange={(val, option) => this.setState({status: 'change', charType: val, charName: option.props.charname, charInt: option.props.charint})}> + {typeOptions.map(option => + <Select.Option key={option.id} value={option.voucher_class} charname={option.voucher_char} charint={option.voucher_char_int}>{option.voucher_char}</Select.Option> + )} + </Select> + <InputNumber precision={0} min={1} disabled={vouAduited} value={charInt} autoComplete="off" onChange={(val) => this.setState({status: 'change', charInt: val})}/> 鍙� + </div> + <div className="voucher-date"> + 鏃ユ湡锛�<DatePicker value={vouDate} disabled={vouAduited} onChange={this.changeVouDate}/> + </div> + <div className="voucher-text"> + <Input value={title} placeholder={vouAduited ? '' : '鍑瘉鏂囨湰'} disabled={vouAduited} autoComplete="off" onChange={(e) => this.setState({status: 'change', title: e.target.value})}/> + </div> + <div className="voucher-affix"> + 闄勫崟鎹� <InputNumber precision={0} disabled={vouAduited} value={attachments || 0} autoComplete="off" onChange={this.changeAttach}/> 寮� + <ResetAttach config={config} disabled={vouAduited} orgcode={orgcode} voucherCode={this.state.voucherCode} attachlist={attachlist} onChange={this.resetAttachList}/> + <ResetRemark remark={remark} disabled={vouAduited} ID={config.uuid + 'remark'} onChange={(val) => this.setState({status: 'change', remark: val})}/> + </div> </div> - <div className="voucher-date"> - 鏃ユ湡锛�<DatePicker value={vouDate} onChange={this.changeVouDate}/> - </div> - <div className="voucher-text"> - <Input value={title} placeholder="鍑瘉鏂囨湰" autoComplete="off" onChange={(e) => this.setState({status: 'change', title: e.target.value})}/> - </div> - <div className="voucher-affix"> - 闄勫崟鎹� <InputNumber precision={0} value={attachments || 0} autoComplete="off" onChange={this.changeAttach}/> 寮� - <ResetAttach config={config} orgcode={orgcode} voucherCode={this.state.voucherCode} attachlist={attachlist} onChange={this.resetAttachList}/> - <ResetRemark remark={remark} ID={config.uuid + 'remark'} onChange={(val) => this.setState({status: 'change', remark: val})}/> - </div> - </div> : null} - {type === 'createTemp' || type === 'checkTemp' ? <div className="pre-temp-wrap"> - <div className="temp-text"> - <span>妯℃澘鍚嶇О锛�</span><Input value={title} placeholder="妯℃澘鍚嶇О" autoComplete="off" onChange={(e) => this.setState({title: e.target.value})}/> - </div> - <div className="temp-text"> - <span>妯℃澘绫诲瀷锛�</span> - <Select value={tempTypeClass} dropdownClassName="mk-vcode-dropdown" onChange={(val, option) => this.setState({tempTypeClass: val, tempTypeName: option.props.children})}> - {tempTypes.map(option => - <Select.Option key={option.data_code} value={option.data_code}>{option.data_name}</Select.Option> - )} - </Select> - </div> - <div className="temp-action"> - <Button className="save-temp header-btn" onClick={() => this.triggerTempsave()}>淇濆瓨</Button> - <Button className="close-temp header-btn" onClick={this.triggerclose}>鍏抽棴</Button> - </div> - </div> : null} - <VoucherTable config={config} loading={loading} data={data} onChange={this.dataChange}/> + <VoucherTable config={config} loading={loading} data={data} onChange={this.dataChange}/> + </div> + <div className="user" style={{paddingLeft: `${config.wrap.space || 0}px`}}>鍒跺崟浜猴細{username}</div> </div> - {type === 'createVoucher' || type === 'checkVoucher' ? <div className="user">鍒跺崟浜猴細{username}</div> : null} - </div> - ) + ) + } else if (type === 'createVoucher') { + return ( + <div className="menu-voucher-wrap" style={config.style}> + <div className="voucher-header" style={{padding: `10px ${config.wrap.space || 0}px`}}> + <Button disabled={status === 'empty'} onClick={() => this.triggersave('add')}>淇濆瓨骞舵柊澧�</Button> + <Button disabled={status === 'empty' || status === 'saved'} onClick={() => this.triggersave()}>淇濆瓨</Button> + <Button disabled={status !== 'saved'} onClick={this.triggerPrint}>鎵撳嵃</Button> + <Dropdown overlay={<div className="mk-voucher-dropdown-wrap"> + <SaveAsTemp tempTypes={tempTypes} onChange={this.triggerTempsave}/> + <div className="split"></div> + <LoadFromTemp tempTypes={tempTypes} onChange={this.triggerTempLoad}/> + </div>} trigger={['hover']} placement="bottomCenter"> + <Button>鏇村</Button> + </Dropdown> + </div> + <div className="voucher-body" style={{padding: `0px ${config.wrap.space || 0}px`}}> + <div className="pre-wrap"> + <div className="voucher-code"> + <Select value={charType} dropdownClassName="mk-vcode-dropdown" onChange={(val, option) => this.setState({status: 'change', charType: val, charName: option.props.charname, charInt: option.props.charint})}> + {typeOptions.map(option => + <Select.Option key={option.id} value={option.voucher_class} charname={option.voucher_char} charint={option.voucher_char_int}>{option.voucher_char}</Select.Option> + )} + </Select> + <InputNumber precision={0} min={1} value={charInt} autoComplete="off" onChange={(val) => this.setState({status: 'change', charInt: val})}/> 鍙� + </div> + <div className="voucher-date"> + 鏃ユ湡锛�<DatePicker value={vouDate} onChange={this.changeVouDate}/> + </div> + <div className="voucher-text"> + <Input value={title} placeholder="鍑瘉鏂囨湰" autoComplete="off" onChange={(e) => this.setState({status: 'change', title: e.target.value})}/> + </div> + <div className="voucher-affix"> + 闄勫崟鎹� <InputNumber precision={0} value={attachments || 0} autoComplete="off" onChange={this.changeAttach}/> 寮� + <ResetAttach config={config} orgcode={orgcode} voucherCode={this.state.voucherCode} attachlist={attachlist} onChange={this.resetAttachList}/> + <ResetRemark remark={remark} ID={config.uuid + 'remark'} onChange={(val) => this.setState({status: 'change', remark: val})}/> + </div> + </div> + <VoucherTable config={config} loading={loading} data={data} onChange={this.dataChange}/> + </div> + <div className="user" style={{paddingLeft: `${config.wrap.space || 0}px`}}>鍒跺崟浜猴細{username}</div> + </div> + ) + } else { + return ( + <div className="menu-voucher-wrap" style={config.style}> + <div className="voucher-body" style={{padding: `0px ${config.wrap.space || 0}px`}}> + <div className="pre-temp-wrap"> + <div className="temp-text"> + <span>妯℃澘鍚嶇О锛�</span><Input value={title} placeholder="妯℃澘鍚嶇О" autoComplete="off" onChange={(e) => this.setState({title: e.target.value})}/> + </div> + <div className="temp-text"> + <span>妯℃澘绫诲瀷锛�</span> + <Select value={tempTypeClass} dropdownClassName="mk-vcode-dropdown" onChange={(val, option) => this.setState({tempTypeClass: val, tempTypeName: option.props.children})}> + {tempTypes.map(option => + <Select.Option key={option.data_code} value={option.data_code}>{option.data_name}</Select.Option> + )} + </Select> + </div> + <div className="temp-action"> + <Button onClick={() => this.triggerTempsave()}>淇濆瓨</Button> + <Button onClick={this.triggerclose}>鍏抽棴</Button> + </div> + </div> + <VoucherTable config={config} loading={loading} data={data} onChange={this.dataChange}/> + </div> + </div> + ) + } } } -- Gitblit v1.8.0