Commit 1cd179700495c20743e0162e2342409a399bf416
Merge branch 'main' of http://git.xlyprint.cn/zhangz/xlyUmi into main
Showing
2 changed files
with
71 additions
and
9 deletions
src/components/CommonElementEvent/StatementInfo.js
| @@ -13,7 +13,7 @@ import { | @@ -13,7 +13,7 @@ import { | ||
| 13 | UploadOutlined, | 13 | UploadOutlined, |
| 14 | } from '@ant-design/icons'; | 14 | } from '@ant-design/icons'; |
| 15 | 15 | ||
| 16 | -import { Modal, Upload, message } from 'antd-v4'; | 16 | +import { Modal, Upload, message, Radio, Button } from 'antd-v4'; |
| 17 | import * as commonUtils from '../../utils/utils'; | 17 | import * as commonUtils from '../../utils/utils'; |
| 18 | import * as commonServices from '../../services/services'; | 18 | import * as commonServices from '../../services/services'; |
| 19 | import commonConfig from '../../utils/config'; | 19 | import commonConfig from '../../utils/config'; |
| @@ -28,6 +28,7 @@ export default class StatementInfo extends Component { | @@ -28,6 +28,7 @@ export default class StatementInfo extends Component { | ||
| 28 | constructor(props) { | 28 | constructor(props) { |
| 29 | super(props); | 29 | super(props); |
| 30 | this.state = { | 30 | this.state = { |
| 31 | + showUploadModal: false, | ||
| 31 | }; | 32 | }; |
| 32 | } | 33 | } |
| 33 | 34 | ||
| @@ -223,6 +224,31 @@ export default class StatementInfo extends Component { | @@ -223,6 +224,31 @@ export default class StatementInfo extends Component { | ||
| 223 | this.props.onSaveState({ [`${name}Data`]: tableData }); | 224 | this.props.onSaveState({ [`${name}Data`]: tableData }); |
| 224 | this.handleBtnSave(); | 225 | this.handleBtnSave(); |
| 225 | }; | 226 | }; |
| 227 | + handleShowUpload = () => { | ||
| 228 | + const { reportSelectedRowKeys, app , sModelsId, formSrcRoute} = this.props; | ||
| 229 | + if (reportSelectedRowKeys === undefined || reportSelectedRowKeys.length !== 1) { | ||
| 230 | + message.warn(commonFunc.showMessage(app.commonConst, 'selectedRowKeysNo')); | ||
| 231 | + return; | ||
| 232 | + } | ||
| 233 | + // 根据用户语言决定流程 | ||
| 234 | + if (app.userinfo.sLanguage === 'sChinese') { | ||
| 235 | + // 中文用户直接触发上传 | ||
| 236 | + this.uploadRef.upload.uploader.fileInput.click(); | ||
| 237 | + } else { | ||
| 238 | + // 英文用户显示选择类型弹窗 | ||
| 239 | + this.setState({ showUploadModal: true }); | ||
| 240 | + } | ||
| 241 | + }; | ||
| 242 | + | ||
| 243 | + handleUploadConfirm = () => { | ||
| 244 | + this.setState({ showUploadModal: false }); // 关闭Modal | ||
| 245 | + if (this.uploadRef) { | ||
| 246 | + this.uploadRef.upload.uploader.fileInput.click(); | ||
| 247 | + } else { | ||
| 248 | + message.error('Error'); | ||
| 249 | + } | ||
| 250 | + }; | ||
| 251 | + | ||
| 226 | handleOk = () => { | 252 | handleOk = () => { |
| 227 | this.handleBtnSave(); | 253 | this.handleBtnSave(); |
| 228 | this.props.onSaveState({ | 254 | this.props.onSaveState({ |
| @@ -244,10 +270,11 @@ export default class StatementInfo extends Component { | @@ -244,10 +270,11 @@ export default class StatementInfo extends Component { | ||
| 244 | } = this.props; | 270 | } = this.props; |
| 245 | const pane = app.panes.filter(paneTmp => paneTmp.key === sTabId)[0]; | 271 | const pane = app.panes.filter(paneTmp => paneTmp.key === sTabId)[0]; |
| 246 | const { token } = this.props.app; | 272 | const { token } = this.props.app; |
| 273 | + // 使用state管理reportType,默认为'zh' | ||
| 274 | + const reportType = this.reportType || 'sChinese'; | ||
| 247 | const outProps = { | 275 | const outProps = { |
| 248 | - action: `${commonConfig.file_host_ebc}file/uploadReport?sModelsId=${sModelsId}&token=${token}&sName=${formSrcRoute}`, | ||
| 249 | - onChange: this.handleUploadChange, | ||
| 250 | - accept: '.jasper', | 276 | + action: `${commonConfig.file_host_ebc}file/uploadReport?sModelsId=${sModelsId}&token=${token}&sName=${formSrcRoute}&reportType=${reportType}`, onChange: this.handleUploadChange, |
| 277 | + accept: '.xlsx', | ||
| 251 | showUploadList: false, | 278 | showUploadList: false, |
| 252 | beforeUpload: () => { | 279 | beforeUpload: () => { |
| 253 | if (!this.props.reportPropsEnabled) return false; | 280 | if (!this.props.reportPropsEnabled) return false; |
| @@ -267,6 +294,13 @@ export default class StatementInfo extends Component { | @@ -267,6 +294,13 @@ export default class StatementInfo extends Component { | ||
| 267 | const BtnUpload = commonFunc.showMessage(app.commonConst, 'BtnUpload');/* 上传 */ | 294 | const BtnUpload = commonFunc.showMessage(app.commonConst, 'BtnUpload');/* 上传 */ |
| 268 | const BtnSave = commonFunc.showMessage(app.commonConst, 'BtnSave');/* 保存 */ | 295 | const BtnSave = commonFunc.showMessage(app.commonConst, 'BtnSave');/* 保存 */ |
| 269 | const btnTop = commonFunc.showMessage(app.commonConst, 'setTop');/* 置顶 */ | 296 | const btnTop = commonFunc.showMessage(app.commonConst, 'setTop');/* 置顶 */ |
| 297 | + const sLanguage = app.userinfo?.sLanguage; | ||
| 298 | + const BtnSure = commonFunc.showMessage(app.commonConst, 'BtnSure');/* 置顶 */ | ||
| 299 | + const modalTitle = sLanguage === 'sEnglish' ? 'Please confirm the upload' : '请确认上传'; | ||
| 300 | + | ||
| 301 | + const sChinseReport = sLanguage === 'sEnglish' ? 'Chinese Report' : '中文报表'; | ||
| 302 | + | ||
| 303 | + const sEnglishReport = sLanguage === 'sEnglish' ? 'English Report' : '英文报表'; | ||
| 270 | return ( | 304 | return ( |
| 271 | <div> | 305 | <div> |
| 272 | {(pane?.notCurrentPane ? false : this.props.visibleStatement) ? | 306 | {(pane?.notCurrentPane ? false : this.props.visibleStatement) ? |
| @@ -303,10 +337,38 @@ export default class StatementInfo extends Component { | @@ -303,10 +337,38 @@ export default class StatementInfo extends Component { | ||
| 303 | </a> | 337 | </a> |
| 304 | </li> | 338 | </li> |
| 305 | <li> | 339 | <li> |
| 306 | - <Upload {...outProps}> | ||
| 307 | - <a {...this.getDisabledProps('BtnUpload')}> | ||
| 308 | - <UploadOutlined />{BtnUpload} | ||
| 309 | - </a> | 340 | + <a {...this.getDisabledProps("BtnUpload")} onClick={this.handleShowUpload}> |
| 341 | + <UploadOutlined /> | ||
| 342 | + {BtnUpload} | ||
| 343 | + </a> | ||
| 344 | + <Modal | ||
| 345 | + title={modalTitle} | ||
| 346 | + visible={this.state.showUploadModal} | ||
| 347 | + footer={[ | ||
| 348 | + <Button key="submit" type="primary" onClick={this.handleUploadConfirm}> | ||
| 349 | + {BtnSure} | ||
| 350 | + </Button>, | ||
| 351 | + ]} | ||
| 352 | + width={500} // 设置固定宽度 | ||
| 353 | + bodyStyle={{ | ||
| 354 | + padding: "16px 24px", // 调整内边距 | ||
| 355 | + maxHeight: "60vh", // 限制最大高度 | ||
| 356 | + overflow: "auto", // 添加滚动条 | ||
| 357 | + }} | ||
| 358 | + > | ||
| 359 | + <Radio.Group | ||
| 360 | + defaultValue="zh" | ||
| 361 | + onChange={e => { | ||
| 362 | + this.reportType = e.target.value; | ||
| 363 | + }} | ||
| 364 | + > | ||
| 365 | + <Radio value="sChinese">{sChinseReport}</Radio> | ||
| 366 | + <Radio value="sEnglish">{sEnglishReport}</Radio> | ||
| 367 | + </Radio.Group> | ||
| 368 | + </Modal> | ||
| 369 | + | ||
| 370 | + <Upload {...outProps} style={{ display: "none" }} ref={ref => (this.uploadRef = ref)}> | ||
| 371 | + <a style={{ display: "none" }}></a> | ||
| 310 | </Upload> | 372 | </Upload> |
| 311 | </li> | 373 | </li> |
| 312 | <li> | 374 | <li> |
src/components/QuickQuote/index.less