From 70a5d3ae7bf1509afab3dcffe7de68710fa8c089 Mon Sep 17 00:00:00 2001 From: MustangDeng <670124965@qq.com> Date: Thu, 16 Jun 2022 20:58:54 +0800 Subject: [PATCH] fix bug 48 - 56 --- .../components/importModal/modalStep1.js | 46 ++++++++++++++----- .../programme/defaultSlideForm.js | 4 +- .../socialSecurityBenefits/programme/index.js | 6 --- pc4mobx/hrmSalary/stores/programme.js | 17 ++++--- 4 files changed, 46 insertions(+), 27 deletions(-) diff --git a/pc4mobx/hrmSalary/components/importModal/modalStep1.js b/pc4mobx/hrmSalary/components/importModal/modalStep1.js index 567d5b6c..ee1d23f8 100644 --- a/pc4mobx/hrmSalary/components/importModal/modalStep1.js +++ b/pc4mobx/hrmSalary/components/importModal/modalStep1.js @@ -14,7 +14,8 @@ export default class ModalStep1 extends React.Component { this.state = { datetime: "", taxAgentId: "", - hasData: "0" + hasData: "0", + fileList: [] } } @@ -23,6 +24,36 @@ export default class ModalStep1 extends React.Component { fetchTaxAgentOption(); } + handleChange(info) { + let fileList = info.fileList; + + // 1. 上传列表数量的限制 + // 只显示最近上传的一个,旧的会被新的顶掉 + fileList = fileList.slice(-1); + // 2. 读取远程路径并显示链接 + fileList = fileList.map((file) => { + if (file.response) { + // 组件会将 file.url 作为链接进行展示 + file.url = file.response.url; + } + return file; + }); + + // 3. 按照服务器返回信息筛选成功上传的文件 + fileList = fileList.filter((file) => { + if (file.response) { + return file.response.status === 1; + } + return true; + }); + + if(fileList && fileList.length > 0 && fileList[0].response && fileList[0].response.status === 1) { + this.props.onFileIdChange(fileList[0].response.data.fileid) + } + + this.setState({ fileList }); + } + render() { const { datetime, taxAgentId, hasData } = this.state const { taxAgentStore: {taxAgentOption}, isInit } = this.props; @@ -35,16 +66,7 @@ export default class ModalStep1 extends React.Component { multiple: false, action: "/api/doc/upload/uploadFile", //上传地址 onChange: (info) => { - const { status } = info.file; - if (status !== 'uploading') { - //获得服务端返回的资源url - console.log(info.file.response.data); - } - if (status === 'done') { - this.props.onFileIdChange(info.file.response.data.fileid) - } else if (status === 'error') { - message.error(`${info.file.name} file upload failed.`); - } + this.handleChange(info) }, }; return ( @@ -66,7 +88,7 @@ export default class ModalStep1 extends React.Component { 导入excel
- +

diff --git a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/defaultSlideForm.js b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/defaultSlideForm.js index ba827ba3..86bbacb4 100644 --- a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/defaultSlideForm.js +++ b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/defaultSlideForm.js @@ -222,9 +222,9 @@ export default class DefaultSlideForm extends React.Component {

{ this.state.selectItem == "个人" ? - +
: -
+
} diff --git a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/index.js b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/index.js index b84932c4..beacd85c 100644 --- a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/index.js +++ b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/index.js @@ -204,12 +204,6 @@ export default class Programme extends React.Component { } const rightMenu = [// 右键菜单 - { - key: 'BTN_COLUMN', - icon: , - content: '显示列定制', - onClick: this.showColumn - }, ]; const collectParams = { // 收藏功能配置 favname: '社保福利方案', diff --git a/pc4mobx/hrmSalary/stores/programme.js b/pc4mobx/hrmSalary/stores/programme.js index d8614d19..11754e24 100644 --- a/pc4mobx/hrmSalary/stores/programme.js +++ b/pc4mobx/hrmSalary/stores/programme.js @@ -224,14 +224,17 @@ export class ProgrammeStore { validateCustomRequest() { let flag = true; - this.formCondition.forEach(item => { - if(item.rules == "required") { - if(!notNull(this.customRequest[item.domkey[0]])) { - message.warning(item.label + "不能为空") - flag = false + try { + this.formCondition.forEach(item => { + if(item.rules == "required") { + if(!notNull(this.customRequest[item.domkey[0]])) { + message.warning(item.label + "不能为空") + throw new Error(item.label + "不能为空") + } } - } - }) + }) + } catch(e) { + flag = false } return flag; }